aggregator: forward gap event information to gap buffer
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 26 Nov 2020 17:11:12 +0000 (18:11 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 22 Apr 2022 17:43:50 +0000 (17:43 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/708>

subprojects/gstreamer/libs/gst/base/gstaggregator.c

index 7c71919..5990753 100644 (file)
@@ -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