From 625eb00c063b8bc03bb2eee637599a02abec6a19 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 11 Dec 2019 17:30:50 +0100 Subject: [PATCH] qtdemux: send GAP events for lagging audio and video streams too The logic is taken straight from matroskademux, see 77403d0afee635f2de6c2e53a23e1f50ad0d00fa --- gst/isomp4/qtdemux.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index f7b4f3c12c..aa0fa6a58c 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -6359,18 +6359,25 @@ gst_qtdemux_loop_state_movie (GstQTDemux * qtdemux) /* gap events for subtitle streams */ for (i = 0; i < QTDEMUX_N_STREAMS (qtdemux); i++) { stream = QTDEMUX_NTH_STREAM (qtdemux, i); - if (stream->pad && (stream->subtype == FOURCC_subp - || stream->subtype == FOURCC_text - || stream->subtype == FOURCC_sbtl)) { - /* send one second gap events until the stream catches up */ + if (stream->pad) { + GstClockTime gap_threshold; + + /* Only send gap events on non-subtitle streams if lagging way behind. */ + if (stream->subtype == FOURCC_subp + || stream->subtype == FOURCC_text || stream->subtype == FOURCC_sbtl) + gap_threshold = 1 * GST_SECOND; + else + gap_threshold = 3 * GST_SECOND; + + /* send gap events until the stream catches up */ /* gaps can only be sent after segment is activated (segment.stop is no longer -1) */ while (GST_CLOCK_TIME_IS_VALID (stream->segment.stop) && GST_CLOCK_TIME_IS_VALID (stream->segment.position) && - stream->segment.position + GST_SECOND < min_time) { + stream->segment.position + gap_threshold < min_time) { GstEvent *gap = - gst_event_new_gap (stream->segment.position, GST_SECOND); + gst_event_new_gap (stream->segment.position, gap_threshold); gst_pad_push_event (stream->pad, gap); - stream->segment.position += GST_SECOND; + stream->segment.position += gap_threshold; } } }