API: GstAggregatorPad.skip_buffer virtual method
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 28 Dec 2017 11:12:45 +0000 (12:12 +0100)
committerMathieu Duponchelle <mathieu@centricular.com>
Tue, 23 Jan 2018 19:17:44 +0000 (20:17 +0100)
Allows subclasses to prevent buffers from being queued.

https://bugzilla.gnome.org/show_bug.cgi?id=781928

libs/gst/base/gstaggregator.c
libs/gst/base/gstaggregator.h

index f7eaf3b..794657a 100644 (file)
@@ -2426,6 +2426,7 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
 {
   GstFlowReturn flow_return;
   GstClockTime buf_pts;
+  GstAggregatorPadClass *klass = GST_AGGREGATOR_PAD_GET_CLASS (aggpad);
 
   GST_DEBUG_OBJECT (aggpad, "Start chaining a buffer %" GST_PTR_FORMAT, buffer);
 
@@ -2434,6 +2435,9 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
   if (flow_return != GST_FLOW_OK)
     goto flushing;
 
+  if (klass->skip_buffer && klass->skip_buffer (aggpad, self, buffer))
+    goto skipped;
+
   PAD_UNLOCK (aggpad);
 
   buf_pts = GST_BUFFER_PTS (buffer);
@@ -2537,6 +2541,14 @@ flushing:
     gst_buffer_unref (buffer);
 
   return flow_return;
+
+skipped:
+  PAD_UNLOCK (aggpad);
+
+  GST_DEBUG_OBJECT (aggpad, "Skipped buffer %" GST_PTR_FORMAT, buffer);
+  gst_buffer_unref (buffer);
+
+  return GST_FLOW_OK;
 }
 
 static GstFlowReturn
index d350034..989e51a 100644 (file)
@@ -74,17 +74,21 @@ struct _GstAggregatorPad
 
 /**
  * GstAggregatorPadClass:
- * @flush:    Optional
- *            Called when the pad has received a flush stop, this is the place
- *            to flush any information specific to the pad, it allows for individual
- *            pads to be flushed while others might not be.
+ * @flush:       Optional
+ *               Called when the pad has received a flush stop, this is the place
+ *               to flush any information specific to the pad, it allows for individual
+ *               pads to be flushed while others might not be.
+ * @skip_buffer: Optional
+ *               Called before input buffers are queued in the pad, return %TRUE
+ *               if the buffer should be skipped.
  *
  */
 struct _GstAggregatorPadClass
 {
   GstPadClass   parent_class;
 
-  GstFlowReturn (*flush)     (GstAggregatorPad * aggpad, GstAggregator * aggregator);
+  GstFlowReturn (*flush)       (GstAggregatorPad * aggpad, GstAggregator * aggregator);
+  gboolean      (*skip_buffer) (GstAggregatorPad * aggpad, GstAggregator * aggregator, GstBuffer * buffer);
 
   /*< private >*/
   gpointer      _gst_reserved[GST_PADDING_LARGE];