Make appsrc support custom segments
At the moment, it's a bit tricky to pass data with a non-zero-based segment from an appsink to an appsrc elsewhere, because appsrc always outputs a segment that starts at 0. I've seen people either push a segment event manually (leaving appsrc/basesrc without knowledge of the true segment), or else send a seek event to change the starting segment before sending data.
It would be better if you could make appsrc respect the segment inside a GstSample.
Here's a proposal:
- To keep backwards compat, add a handle-segments (or so) boolean property on appsrc that defaults to FALSE
- For efficiency, GstSample should signal when the segment has changed, so appsrc doesn't have to compare every incoming segment and look for changes. Luckily GstSample is a GstMiniObject with a full set of flags available, so:
- Add GST_SAMPLE_FLAGS_SEGMENT_CHANGED to GstSample
- It's awkward for a sub-class to get GstBaseSrc to send out a new segment event spontaneously. There's gst_base_src_new_seamless_segment, but it is from the 0.10 days before GstSegment existed and needs updating:
- Add gst_base_src_update_segment (GstBaseSrc *src, GstSegment *segment) that outputs exactly the segment requested before the next buffer and updates the GstSegment in basesrc.
With that in place, it'll be simpler to pass data streams intact between an appsink and appsrc pair.