API: GstAggregatorPad.skip_buffer virtual method
Allows subclasses to prevent buffers from being queued.
https://bugzilla.gnome.org/show_bug.cgi?id=781928
diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c
index f7eaf3b..794657a 100644
--- a/libs/gst/base/gstaggregator.c
+++ b/libs/gst/base/gstaggregator.c
@@ -2426,6 +2426,7 @@
{
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 @@
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 @@
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
diff --git a/libs/gst/base/gstaggregator.h b/libs/gst/base/gstaggregator.h
index d350034..989e51a 100644
--- a/libs/gst/base/gstaggregator.h
+++ b/libs/gst/base/gstaggregator.h
@@ -74,17 +74,21 @@
/**
* 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];