From da25b95bdf57f9023e7996853969e9801f81f7f5 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 26 Nov 2020 18:11:12 +0100 Subject: [PATCH] aggregator: forward gap event information to gap buffer When the GAP event was flagged with MISSING_DATA, subclasses may want to adopt a different behaviour, for example by repeating the last buffer. As we turn these gap events into gap buffers, we need to flag those, we do so with a new custom meta. Part-of: --- subprojects/gstreamer/libs/gst/base/gstaggregator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/subprojects/gstreamer/libs/gst/base/gstaggregator.c b/subprojects/gstreamer/libs/gst/base/gstaggregator.c index 7c7191904d..5990753314 100644 --- a/subprojects/gstreamer/libs/gst/base/gstaggregator.c +++ b/subprojects/gstreamer/libs/gst/base/gstaggregator.c @@ -79,6 +79,8 @@ * these into gap buffers with matching PTS and duration. It will also * flag these buffers with GST_BUFFER_FLAG_GAP and GST_BUFFER_FLAG_DROPPABLE * to ease their identification and subsequent processing. + * In addition, if the gap event was flagged with GST_GAP_FLAG_MISSING_DATA, + * a custom meta is added to the resulting gap buffer (GstAggregatorMissingDataMeta). * * * Subclasses must use (a subclass of) #GstAggregatorPad for both their * sink and source pads. @@ -1723,6 +1725,7 @@ gst_aggregator_default_sink_event (GstAggregator * self, GstClockTime pts, endpts; GstClockTime duration; GstBuffer *gapbuf; + GstGapFlags flags = 0; gst_event_parse_gap (event, &pts, &duration); @@ -1752,6 +1755,11 @@ gst_aggregator_default_sink_event (GstAggregator * self, GST_BUFFER_FLAG_SET (gapbuf, GST_BUFFER_FLAG_GAP); GST_BUFFER_FLAG_SET (gapbuf, GST_BUFFER_FLAG_DROPPABLE); + gst_event_parse_gap_flags (event, &flags); + if (flags & GST_GAP_FLAG_MISSING_DATA) { + gst_buffer_add_custom_meta (gapbuf, "GstAggregatorMissingDataMeta"); + } + /* Remove GAP event so we can replace it with the buffer */ PAD_LOCK (aggpad); if (g_queue_peek_tail (&aggpad->priv->data) == event) @@ -2741,6 +2749,7 @@ gst_aggregator_class_init (GstAggregatorClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; GstElementClass *gstelement_class = (GstElementClass *) klass; + static const gchar *meta_tags[] = { NULL }; aggregator_parent_class = g_type_class_peek_parent (klass); @@ -2855,6 +2864,9 @@ gst_aggregator_class_init (GstAggregatorClass * klass) GST_TYPE_SEGMENT | G_SIGNAL_TYPE_STATIC_SCOPE, GST_TYPE_CLOCK_TIME, GST_TYPE_CLOCK_TIME, GST_TYPE_CLOCK_TIME, GST_TYPE_STRUCTURE | G_SIGNAL_TYPE_STATIC_SCOPE); + + gst_meta_register_custom ("GstAggregatorMissingDataMeta", meta_tags, NULL, + NULL, NULL); } static inline gpointer