basetransform: use pad direction like other vmethods

This commit is contained in:
Wim Taymans 2011-08-26 11:24:42 +02:00
parent 31b70ea701
commit f1566e85c0
2 changed files with 17 additions and 7 deletions

View file

@ -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);

View file

@ -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);