From c27471eb9e998455931b044c6d7927f442db2c4c Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 30 Oct 2014 11:17:12 +0100 Subject: qtdemux: WIP: Support non-default TIME SEGMENT at beginning If we receive an initial TIME SEGMENT with a non-zero start value, we need to adjust it to take into account the fact that the buffers we will be pushing out will start from 0 (and not from the segment start value). This is just a workaround for now until the relationship of TIME SEGMENT values and container formats has been clarified upstream. --- gst/isomp4/qtdemux.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 23be06171..0ac2d6983 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -2028,11 +2028,23 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstObject * parent, segment.duration = demux->segment.duration; segment.base = gst_segment_to_running_time (&demux->segment, GST_FORMAT_TIME, demux->segment.position); + if (demux->n_streams == 0 && segment.start != 0) { + GstClockTime backdrift = segment.start; + /* If this is not a segment update, we shift the segment start/stop */ + GST_DEBUG_OBJECT (demux, "Shifting segment back by %" GST_TIME_FORMAT, + GST_TIME_ARGS (backdrift)); + segment.start = 0; + segment.position = 0; + segment.base = 0; + if (GST_CLOCK_TIME_IS_VALID (segment.stop)) + segment.stop -= backdrift; + } gst_segment_copy_into (&segment, &demux->segment); GST_DEBUG_OBJECT (demux, "Pushing newseg %" GST_SEGMENT_FORMAT, &segment); segment_event = gst_event_new_segment (&segment); gst_event_set_seqnum (segment_event, gst_event_get_seqnum (event)); + gst_event_replace (&demux->pending_newsegment, segment_event); gst_qtdemux_push_event (demux, segment_event); /* clear leftover in current segment, if any */ -- cgit v1.2.3