From 4ef3b1ad8fc49e27fa59f256df1442e662218bdc Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 26 Nov 2020 18:18:52 +0100 Subject: [PATCH] videoaggregator: keep old buffer when processing a MISSING_DATA gap 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: --- .../gst-libs/gst/video/gstvideoaggregator.c | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoaggregator.c b/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoaggregator.c index cc63444e14..0f7d7b3400 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoaggregator.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoaggregator.c @@ -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);