From 9f69034d4155c89f71e3f885b39a9e949768b606 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 28 Dec 2017 12:12:45 +0100 Subject: [PATCH] API: GstAggregatorPad.skip_buffer virtual method Allows subclasses to prevent buffers from being queued. https://bugzilla.gnome.org/show_bug.cgi?id=781928 --- libs/gst/base/gstaggregator.c | 12 ++++++++++++ libs/gst/base/gstaggregator.h | 14 +++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c index f7eaf3bc08..794657a419 100644 --- a/libs/gst/base/gstaggregator.c +++ b/libs/gst/base/gstaggregator.c @@ -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 diff --git a/libs/gst/base/gstaggregator.h b/libs/gst/base/gstaggregator.h index d350034899..989e51a4f6 100644 --- a/libs/gst/base/gstaggregator.h +++ b/libs/gst/base/gstaggregator.h @@ -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];