summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-12-04 11:24:47 +0000
committerTim-Philipp Müller <tim@centricular.com>2017-12-04 15:27:04 +0000
commit76b54099bd86c53ef2215b1334b1ae4960e68907 (patch)
treecf45a3a571a07afa7d7331f8f65e41aa9ec21db4
parente9483fbffb6fcfee92350ae3f7325350fa7b2348 (diff)
aggregator: add finish_buffer() vfunc
So subclasses can override the finish behaviour and/or decorate or modify buffers before they get pushed out. https://bugzilla.gnome.org/show_bug.cgi?id=760981
-rw-r--r--libs/gst/base/gstaggregator.c34
-rw-r--r--libs/gst/base/gstaggregator.h12
2 files changed, 34 insertions, 12 deletions
diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c
index 7b8b093d1..06c7cbb37 100644
--- a/libs/gst/base/gstaggregator.c
+++ b/libs/gst/base/gstaggregator.c
@@ -539,17 +539,8 @@ gst_aggregator_set_src_caps (GstAggregator * self, GstCaps * caps)
GST_PAD_STREAM_UNLOCK (self->srcpad);
}
-/**
- * gst_aggregator_finish_buffer:
- * @self: The #GstAggregator
- * @buffer: (transfer full): the #GstBuffer to push.
- *
- * This method will push the provided output buffer downstream. If needed,
- * mandatory events such as stream-start, caps, and segment events will be
- * sent before pushing the buffer.
- */
-GstFlowReturn
-gst_aggregator_finish_buffer (GstAggregator * self, GstBuffer * buffer)
+static GstFlowReturn
+gst_aggregator_default_finish_buffer (GstAggregator * self, GstBuffer * buffer)
{
gst_aggregator_push_mandatory_events (self);
@@ -567,6 +558,25 @@ gst_aggregator_finish_buffer (GstAggregator * self, GstBuffer * buffer)
}
}
+/**
+ * gst_aggregator_finish_buffer:
+ * @aggregator: The #GstAggregator
+ * @buffer: (transfer full): the #GstBuffer to push.
+ *
+ * This method will push the provided output buffer downstream. If needed,
+ * mandatory events such as stream-start, caps, and segment events will be
+ * sent before pushing the buffer.
+ */
+GstFlowReturn
+gst_aggregator_finish_buffer (GstAggregator * aggregator, GstBuffer * buffer)
+{
+ GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (aggregator);
+
+ g_assert (klass->finish_buffer != NULL);
+
+ return klass->finish_buffer (aggregator, buffer);
+}
+
static void
gst_aggregator_push_eos (GstAggregator * self)
{
@@ -2233,6 +2243,8 @@ gst_aggregator_class_init (GstAggregatorClass * klass)
GST_DEBUG_CATEGORY_INIT (aggregator_debug, "aggregator",
GST_DEBUG_FG_MAGENTA, "GstAggregator");
+ klass->finish_buffer = gst_aggregator_default_finish_buffer;
+
klass->sink_event = gst_aggregator_default_sink_event;
klass->sink_query = gst_aggregator_default_sink_query;
diff --git a/libs/gst/base/gstaggregator.h b/libs/gst/base/gstaggregator.h
index ecbd1529b..a2bff124b 100644
--- a/libs/gst/base/gstaggregator.h
+++ b/libs/gst/base/gstaggregator.h
@@ -159,6 +159,13 @@ struct _GstAggregator
* clipping of input buffer. This function takes ownership of
* buf and should output a buffer or return NULL in
* if the buffer should be dropped.
+ * @finish_buffer: Optional.
+ * Called when a subclass calls gst_aggregator_finish_buffer()
+ * from their aggregate function to push out a buffer.
+ * Subclasses can override this to modify or decorate buffers
+ * before they get pushed out. This function takes ownership
+ * of the buffer passed. Subclasses that override this method
+ * should always chain up to the parent class virtual method.
* @sink_event: Optional.
* Called when an event is received on a sink pad, the subclass
* should always chain up.
@@ -231,6 +238,9 @@ struct _GstAggregatorClass {
GstAggregatorPad * aggregator_pad,
GstBuffer * buf);
+ GstFlowReturn (*finish_buffer) (GstAggregator * aggregator,
+ GstBuffer * buffer);
+
/* sinkpads virtual methods */
gboolean (*sink_event) (GstAggregator * aggregator,
GstAggregatorPad * aggregator_pad,
@@ -300,7 +310,7 @@ struct _GstAggregatorClass {
************************/
GST_EXPORT
-GstFlowReturn gst_aggregator_finish_buffer (GstAggregator * self,
+GstFlowReturn gst_aggregator_finish_buffer (GstAggregator * aggregator,
GstBuffer * buffer);
GST_EXPORT