qtdemux: send GAP events for lagging audio and video streams too
authorMathieu Duponchelle <mathieu@centricular.com>
Wed, 11 Dec 2019 16:30:50 +0000 (17:30 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 11 Dec 2019 19:59:13 +0000 (19:59 +0000)
The logic is taken straight from matroskademux, see
77403d0afee635f2de6c2e53a23e1f50ad0d00fa

gst/isomp4/qtdemux.c

index f7b4f3c..aa0fa6a 100644 (file)
@@ -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;
       }
     }
   }