From 6b29a4507eb6d73ba350a26558a8e8a267998ab2 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 1 Jun 2018 21:08:10 +0900 Subject: [PATCH] qtdemux: Forward upstream time-format segment without mapping Sample table based segment event (genereted by qtdemux) could break presentation timeline. For example, qtdemux should not modify upstream time format segment (e.g., adaptivedemux use case) https://bugzilla.gnome.org/show_bug.cgi?id=796480 --- gst/isomp4/qtdemux.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 515687353b..7d9dc5b6c4 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -1038,21 +1038,25 @@ static void gst_qtdemux_push_pending_newsegment (GstQTDemux * qtdemux) { if (G_UNLIKELY (qtdemux->need_segment)) { - GstClockTime min_ts; GstEvent *newsegment; - if (!gst_qtdemux_streams_have_samples (qtdemux)) { - /* No samples yet, can't decide on segment.start */ - GST_DEBUG_OBJECT (qtdemux, "No samples yet, postponing segment event"); - return; + if (!qtdemux->upstream_format_is_time) { + GstClockTime min_ts; + + if (!gst_qtdemux_streams_have_samples (qtdemux)) { + /* No samples yet, can't decide on segment.start */ + GST_DEBUG_OBJECT (qtdemux, "No samples yet, postponing segment event"); + return; + } + + min_ts = gst_qtdemux_streams_get_first_sample_ts (qtdemux); + + /* have_samples() above should guarantee we have a valid time */ + g_assert (GST_CLOCK_TIME_IS_VALID (min_ts)); + + qtdemux->segment.start = min_ts; } - min_ts = gst_qtdemux_streams_get_first_sample_ts (qtdemux); - - /* have_samples() above should guarantee we have a valid time */ - g_assert (GST_CLOCK_TIME_IS_VALID (min_ts)); - - qtdemux->segment.start = min_ts; newsegment = gst_event_new_segment (&qtdemux->segment); if (qtdemux->segment_seqnum != GST_SEQNUM_INVALID) gst_event_set_seqnum (newsegment, qtdemux->segment_seqnum); @@ -6900,7 +6904,16 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force) demux->got_moov = TRUE; demux->need_segment = TRUE; - gst_qtdemux_map_and_push_segments (demux, &demux->segment); + + /* Forward upstream driven time format segment, and also do not try + * to map edit list with the upstream time format segment. + * It's upstream element's role (the origin of time format segment) + */ + if (demux->upstream_format_is_time) + gst_qtdemux_check_send_pending_segment (demux); + else + gst_qtdemux_map_and_push_segments (demux, &demux->segment); + if (demux->exposed) demux->need_segment = FALSE;