API: GstAggregatorPad.skip_buffer virtual method

Allows subclasses to prevent buffers from being queued.

https://bugzilla.gnome.org/show_bug.cgi?id=781928
This commit is contained in:
Mathieu Duponchelle 2017-12-28 12:12:45 +01:00
parent ac7434088e
commit 9f69034d41
2 changed files with 21 additions and 5 deletions

View 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

View 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];