From f1566e85c004f752b47ab9282d5fc32a5594dcce Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 26 Aug 2011 11:24:42 +0200 Subject: [PATCH] basetransform: use pad direction like other vmethods --- libs/gst/base/gstbasetransform.c | 13 +++++++------ libs/gst/base/gstbasetransform.h | 11 ++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 8df15d4912..6550cb0efc 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -325,7 +325,7 @@ static gboolean gst_base_transform_setcaps (GstBaseTransform * trans, GstPad * pad, GstCaps * caps); static gboolean gst_base_transform_query (GstPad * pad, GstQuery * query); static gboolean gst_base_transform_default_query (GstBaseTransform * trans, - GstPad * pad, GstQuery * query); + GstPadDirection direction, GstQuery * query); static const GstQueryType *gst_base_transform_query_type (GstPad * pad); static GstFlowReturn default_prepare_output_buffer (GstBaseTransform * trans, @@ -1303,12 +1303,13 @@ failed_configure: static gboolean gst_base_transform_default_query (GstBaseTransform * trans, - GstPad * pad, GstQuery * query) + GstPadDirection direction, GstQuery * query) { gboolean ret = FALSE; - GstPad *otherpad; + GstPad *pad, *otherpad; - otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; + pad = (direction == GST_PAD_SRC) ? trans->srcpad : trans->sinkpad; + otherpad = (direction == GST_PAD_SINK) ? trans->sinkpad : trans->srcpad; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_ALLOCATION: @@ -1316,7 +1317,7 @@ gst_base_transform_default_query (GstBaseTransform * trans, gboolean passthrough; /* can only be done on the sinkpad */ - if (!GST_PAD_IS_SINK (pad)) + if (direction != GST_PAD_SINK) goto done; GST_BASE_TRANSFORM_LOCK (trans); @@ -1378,7 +1379,7 @@ gst_base_transform_query (GstPad * pad, GstQuery * query) bclass = GST_BASE_TRANSFORM_GET_CLASS (trans); if (bclass->query) - ret = bclass->query (trans, pad, query); + ret = bclass->query (trans, GST_PAD_DIRECTION (pad), query); else ret = gst_pad_query_default (pad, query); diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index ca0ffe8f10..521101a7c3 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -160,6 +160,13 @@ struct _GstBaseTransform { * Handle a requested query. Subclasses that implement this * should must chain up to the parent if they didn't handle the * query + * @decide_allocation: Decide what parameters you want upstream elements to use + * for the allocation of buffers. This function is only + * called when not operating in passthrough mode. + * @setup_allocation: Setup the allocation parameters for allocating output + * buffers. The passed in query contains the result of the + * downstream allocation query. This function is only called + * when not operating in passthrough mode. * @transform_size: Optional. Given the size of a buffer in the given direction * with the given caps, calculate the size in bytes of a buffer * on the other pad with the given other caps. @@ -225,9 +232,11 @@ struct _GstBaseTransformClass { GstCaps *caps); gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *incaps, GstCaps *outcaps); - gboolean (*query) (GstBaseTransform *trans, GstPad *pad, + gboolean (*query) (GstBaseTransform *trans, GstPadDirection direction, GstQuery *query); + /* decide allocation query parameters for input buffers */ + gboolean (*decide_allocation) (GstBaseTransform *trans, GstQuery *query); /* setup allocation query for output buffers */ gboolean (*setup_allocation) (GstBaseTransform *trans, GstQuery *query);