videoaggregator: keep old buffer when processing a MISSING_DATA gap
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 26 Nov 2020 17:18:52 +0000 (18:18 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 22 Apr 2022 17:43:50 +0000 (17:43 +0000)
GAP events flagged with MISSING_DATA are transformed into GAP buffers
flagged with CORRUPTED.

In these cases, it is preferable to simply keep rendering the previous
buffer (if there was one) instead of flashing the pad in and out of
view.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/708>

subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoaggregator.c

index cc63444..0f7d7b3 100644 (file)
@@ -1888,7 +1888,16 @@ gst_video_aggregator_fill_queues (GstVideoAggregator * vagg,
         GST_DEBUG_OBJECT (pad,
             "Taking new buffer with start time %" GST_TIME_FORMAT,
             GST_TIME_ARGS (start_running_time));
-        gst_buffer_replace (&pad->priv->buffer, buf);
+
+        if ((gst_buffer_get_size (buf) == 0 &&
+                GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP) &&
+                gst_buffer_get_custom_meta (buf,
+                    "GstAggregatorMissingDataMeta"))) {
+          GST_DEBUG_OBJECT (pad, "Consuming gap but keeping old buffer around");
+        } else {
+          gst_buffer_replace (&pad->priv->buffer, buf);
+        }
+
         if (pad->priv->pending_vinfo.finfo) {
           gst_caps_replace (&pad->priv->caps, pad->priv->pending_caps);
           gst_caps_replace (&pad->priv->pending_caps, NULL);
@@ -1908,7 +1917,15 @@ gst_video_aggregator_fill_queues (GstVideoAggregator * vagg,
         gst_buffer_unref (buf);
         eos = FALSE;
       } else {
-        gst_buffer_replace (&pad->priv->buffer, buf);
+        if ((gst_buffer_get_size (buf) == 0 &&
+                GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP) &&
+                gst_buffer_get_custom_meta (buf,
+                    "GstAggregatorMissingDataMeta"))) {
+          GST_DEBUG_OBJECT (pad, "Consuming gap but keeping old buffer around");
+        } else {
+          gst_buffer_replace (&pad->priv->buffer, buf);
+        }
+
         if (pad->priv->pending_vinfo.finfo) {
           gst_caps_replace (&pad->priv->caps, pad->priv->pending_caps);
           gst_caps_replace (&pad->priv->pending_caps, NULL);