From b90bef8ee54634fb63f95c9256e5b47f65d85eda Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 8 Dec 2008 18:35:44 +0000 Subject: [PATCH] libs/gst/base/gstbasetransform.*: Add vmethod that is called before we start the transform and which can be used to c... Original commit message from CVS: * libs/gst/base/gstbasetransform.c: (gst_base_transform_prepare_output_buffer), (gst_base_transform_getrange), (gst_base_transform_chain): * libs/gst/base/gstbasetransform.h: Add vmethod that is called before we start the transform and which can be used to configure the transform, such as dynamic properties. --- ChangeLog | 9 +++++++++ libs/gst/base/gstbasetransform.c | 11 +++++++++++ libs/gst/base/gstbasetransform.h | 8 +++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8bf1fa9a77..14af40758a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-12-08 Wim Taymans + + * libs/gst/base/gstbasetransform.c: + (gst_base_transform_prepare_output_buffer), + (gst_base_transform_getrange), (gst_base_transform_chain): + * libs/gst/base/gstbasetransform.h: + Add vmethod that is called before we start the transform and which can + be used to configure the transform, such as dynamic properties. + 2008-12-05 David Schleef * gst/gst.c: diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index f9c36e9963..0c617d891d 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -1185,6 +1185,7 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans, /* only discard it when the input was not writable, otherwise, we reuse * the input buffer. */ discard = gst_buffer_is_writable (in_buf); + GST_DEBUG_OBJECT (trans, "discard: %d", discard); } else { GST_DEBUG_OBJECT (trans, "getting output size for copy transform"); /* copy transform, figure out the output size */ @@ -1948,6 +1949,7 @@ gst_base_transform_getrange (GstPad * pad, guint64 offset, guint length, GstBuffer ** buffer) { GstBaseTransform *trans; + GstBaseTransformClass *klass; GstFlowReturn ret; GstBuffer *inbuf; @@ -1957,6 +1959,10 @@ gst_base_transform_getrange (GstPad * pad, guint64 offset, if (G_UNLIKELY (ret != GST_FLOW_OK)) goto pull_error; + klass = GST_BASE_TRANSFORM_GET_CLASS (trans); + if (klass->before_transform) + klass->before_transform (trans, inbuf); + GST_BASE_TRANSFORM_LOCK (trans); ret = gst_base_transform_handle_buffer (trans, inbuf, buffer); GST_BASE_TRANSFORM_UNLOCK (trans); @@ -1979,6 +1985,7 @@ static GstFlowReturn gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) { GstBaseTransform *trans; + GstBaseTransformClass *klass; GstFlowReturn ret; GstClockTime last_stop = GST_CLOCK_TIME_NONE; GstBuffer *outbuf = NULL; @@ -1993,6 +2000,10 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) last_stop = GST_BUFFER_TIMESTAMP (buffer); } + klass = GST_BASE_TRANSFORM_GET_CLASS (trans); + if (klass->before_transform) + klass->before_transform (trans, buffer); + /* protect transform method and concurrent buffer alloc */ GST_BASE_TRANSFORM_LOCK (trans); ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf); diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index d5a3d3e10a..a5c201beb6 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -182,6 +182,10 @@ struct _GstBaseTransform { * analysis can return a subbuffer or even just * increment the reference to the input buffer (if in * passthrough mode) + * @before_transform: Optional. Since 0.10.22 + * This method is called right before the base class will + * start processing. Dynamic properties or other delayed + * configuration could be performed in this method. * * Subclasses can override any of the available virtual methods or not, as * needed. At minimum either @transform or @transform_ip need to be overridden. @@ -231,8 +235,10 @@ struct _GstBaseTransformClass { /* src event */ gboolean (*src_event) (GstBaseTransform *trans, GstEvent *event); + void (*before_transform) (GstBaseTransform *trans, GstBuffer *buffer); + /*< private >*/ - gpointer _gst_reserved[GST_PADDING_LARGE - 1]; + gpointer _gst_reserved[GST_PADDING_LARGE - 2]; }; GType gst_base_transform_get_type (void);