basetransform: use pad direction like other vmethods
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 26 Aug 2011 09:24:42 +0000 (11:24 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 26 Aug 2011 09:24:42 +0000 (11:24 +0200)
libs/gst/base/gstbasetransform.c
libs/gst/base/gstbasetransform.h

index 8df15d4..6550cb0 100644 (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);
 
index ca0ffe8..521101a 100644 (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);