pad: make an ACCEPT_CAPS query
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 9 Nov 2011 16:36:00 +0000 (17:36 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 9 Nov 2011 16:36:00 +0000 (17:36 +0100)
Replace the acceptcaps function with a query.

14 files changed:
gst/gstghostpad.c
gst/gstpad.c
gst/gstpad.h
gst/gstquark.c
gst/gstquark.h
gst/gstquery.c
gst/gstquery.h
libs/gst/base/gstbasetransform.c
plugins/elements/gstinputselector.c
plugins/elements/gstmultiqueue.c
plugins/elements/gstqueue.c
plugins/elements/gstqueue2.c
plugins/elements/gsttee.c
tools/gst-inspect.c

index 650ebd3..f1489c2 100644 (file)
@@ -107,32 +107,40 @@ gboolean
 gst_proxy_pad_query_default (GstPad * pad, GstQuery * query)
 {
   gboolean res;
+  GstPad *target;
 
   g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
   g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
 
+  target = gst_proxy_pad_get_target (pad);
+
   switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
+    {
+      if (target) {
+        res = gst_pad_query (target, query);
+        gst_object_unref (target);
+      } else {
+        GST_DEBUG_OBJECT (pad, "no target");
+        /* We don't have a target, we return TRUE and we assume that any future
+         * target will be able to deal with any configured caps. */
+        res = TRUE;
+      }
+      break;
+    }
     default:
     {
-      GstPad *target;
-
-      if (!(target = gst_proxy_pad_get_target (pad)))
-        goto no_target;
-
-      res = gst_pad_query (target, query);
-      gst_object_unref (target);
+      if (target) {
+        res = gst_pad_query (target, query);
+        gst_object_unref (target);
+      } else {
+        GST_DEBUG_OBJECT (pad, "no target pad");
+        res = FALSE;
+      }
       break;
     }
   }
-
   return res;
-
-  /* ERRORS */
-no_target:
-  {
-    GST_DEBUG_OBJECT (pad, "no target pad");
-    return FALSE;
-  }
 }
 
 /**
@@ -485,7 +493,6 @@ gst_proxy_pad_init (GstProxyPad * ppad)
       gst_proxy_pad_iterate_internal_links_default);
 
   gst_pad_set_getcaps_function (pad, gst_proxy_pad_getcaps_default);
-  gst_pad_set_acceptcaps_function (pad, gst_proxy_pad_acceptcaps_default);
   gst_pad_set_fixatecaps_function (pad, gst_proxy_pad_fixatecaps_default);
   gst_pad_set_unlink_function (pad, gst_proxy_pad_unlink_default);
 }
index df4865a..74b9685 100644 (file)
@@ -142,7 +142,6 @@ static void gst_pad_get_property (GObject * object, guint prop_id,
 static GstCaps *gst_pad_get_caps_unlocked (GstPad * pad, GstCaps * filter);
 static void gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ);
 static gboolean gst_pad_activate_default (GstPad * pad);
-static gboolean gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps);
 static void gst_pad_fixate_caps_default (GstPad * pad, GstCaps * caps);
 static GstFlowReturn gst_pad_chain_list_default (GstPad * pad,
     GstBufferList * list);
@@ -302,7 +301,6 @@ gst_pad_class_init (GstPadClass * klass)
   GST_DEBUG_REGISTER_FUNCPTR (gst_pad_event_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_pad_query_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_pad_iterate_internal_links_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_pad_acceptcaps_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_pad_chain_list_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_pad_fixate_caps_default);
 }
@@ -318,7 +316,6 @@ gst_pad_init (GstPad * pad)
   GST_PAD_EVENTFUNC (pad) = gst_pad_event_default;
   GST_PAD_QUERYFUNC (pad) = gst_pad_query_default;
   GST_PAD_ITERINTLINKFUNC (pad) = gst_pad_iterate_internal_links_default;
-  GST_PAD_ACCEPTCAPSFUNC (pad) = gst_pad_acceptcaps_default;
   GST_PAD_FIXATECAPSFUNC (pad) = gst_pad_fixate_caps_default;
   GST_PAD_CHAINLISTFUNC (pad) = gst_pad_chain_list_default;
 
@@ -1546,27 +1543,6 @@ gst_pad_set_getcaps_function (GstPad * pad, GstPadGetCapsFunction getcaps)
 }
 
 /**
- * gst_pad_set_acceptcaps_function:
- * @pad: a #GstPad.
- * @acceptcaps: the #GstPadAcceptCapsFunction to set.
- *
- * Sets the given acceptcaps function for the pad.  The acceptcaps function
- * will be called to check if the pad can accept the given caps. Setting the
- * acceptcaps function to NULL restores the default behaviour of allowing
- * any caps that matches the caps from gst_pad_get_caps().
- */
-void
-gst_pad_set_acceptcaps_function (GstPad * pad,
-    GstPadAcceptCapsFunction acceptcaps)
-{
-  g_return_if_fail (GST_IS_PAD (pad));
-
-  GST_PAD_ACCEPTCAPSFUNC (pad) = acceptcaps;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "acceptcapsfunc set to %s",
-      GST_DEBUG_FUNCPTR_NAME (acceptcaps));
-}
-
-/**
  * gst_pad_set_fixatecaps_function:
  * @pad: a #GstPad.
  * @fixatecaps: the #GstPadFixateCapsFunction to set.
@@ -2447,37 +2423,6 @@ gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
     fixatefunc (pad, caps);
 }
 
-/* Default accept caps implementation just checks against
- * against the allowed caps for the pad */
-static gboolean
-gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
-{
-  /* get the caps and see if it intersects to something not empty */
-  GstCaps *allowed;
-  gboolean result = FALSE;
-
-  GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
-
-  allowed = gst_pad_get_caps (pad, NULL);
-  if (!allowed)
-    goto nothing_allowed;
-
-  GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
-
-  result = gst_caps_is_subset (caps, allowed);
-
-  gst_caps_unref (allowed);
-
-  return result;
-
-  /* ERRORS */
-nothing_allowed:
-  {
-    GST_DEBUG_OBJECT (pad, "no caps allowed on the pad");
-    return FALSE;
-  }
-}
-
 /**
  * gst_pad_accept_caps:
  * @pad: a #GstPad to check
@@ -2490,54 +2435,23 @@ nothing_allowed:
 gboolean
 gst_pad_accept_caps (GstPad * pad, GstCaps * caps)
 {
-  gboolean result;
-  GstPadAcceptCapsFunction acceptfunc;
-#if 0
-  GstCaps *existing = NULL;
-#endif
+  gboolean res;
+  GstQuery *query;
 
   g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+  g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
 
-  /* any pad can be unnegotiated */
-  if (caps == NULL)
-    return TRUE;
-
-  /* lock for checking the existing caps */
   GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "accept caps of %p", caps);
-#if 0
-  GST_OBJECT_LOCK (pad);
-  /* The current caps on a pad are trivially acceptable */
-  if (G_LIKELY ((existing = GST_PAD_CAPS (pad)))) {
-    if (caps == existing || gst_caps_is_equal (caps, existing))
-      goto is_same_caps;
-  }
-  GST_OBJECT_UNLOCK (pad);
-#endif
-  acceptfunc = GST_PAD_ACCEPTCAPSFUNC (pad);
 
-  /* Only null if the element explicitly unset it */
-  if (G_UNLIKELY (acceptfunc == NULL))
-    goto no_func;
-
-  /* we can call the function */
-  result = acceptfunc (pad, caps);
-  GST_DEBUG_OBJECT (pad, "acceptfunc returned %d", result);
-
-  return result;
-
-#if 0
-is_same_caps:
-  {
-    GST_DEBUG_OBJECT (pad, "pad had same caps");
-    GST_OBJECT_UNLOCK (pad);
-    return TRUE;
-  }
-#endif
-no_func:
-  {
-    GST_DEBUG_OBJECT (pad, "no acceptcaps function");
-    return FALSE;
+  query = gst_query_new_accept_caps (caps);
+  res = gst_pad_query (pad, query);
+  if (res) {
+    GST_DEBUG_OBJECT (pad, "query returned %d", res);
+    gst_query_parse_accept_caps_result (query, &res);
   }
+  gst_query_unref (query);
+
+  return res;
 }
 
 /**
@@ -2546,41 +2460,24 @@ no_func:
  * @caps: a #GstCaps to check on the pad
  *
  * Check if the peer of @pad accepts @caps. If @pad has no peer, this function
- * returns TRUE.
+ * returns FALSE.
  *
  * Returns: TRUE if the peer of @pad can accept the caps or @pad has no peer.
  */
 gboolean
 gst_pad_peer_accept_caps (GstPad * pad, GstCaps * caps)
 {
-  GstPad *peerpad;
   gboolean result;
+  GstQuery *query;
 
   g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+  g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
 
-  GST_OBJECT_LOCK (pad);
-
-  GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "peer accept caps of (%p)", pad);
-
-  peerpad = GST_PAD_PEER (pad);
-  if (G_UNLIKELY (peerpad == NULL))
-    goto no_peer;
-
-  gst_object_ref (peerpad);
-  /* release lock before calling external methods but keep ref to pad */
-  GST_OBJECT_UNLOCK (pad);
-
-  result = gst_pad_accept_caps (peerpad, caps);
-
-  gst_object_unref (peerpad);
+  query = gst_query_new_accept_caps (caps);
+  result = gst_pad_peer_query (pad, query);
+  gst_query_unref (query);
 
   return result;
-
-no_peer:
-  {
-    GST_OBJECT_UNLOCK (pad);
-    return TRUE;
-  }
 }
 
 /**
@@ -3093,6 +2990,33 @@ gst_pad_event_default (GstPad * pad, GstEvent * event)
   return result;
 }
 
+/* Default accept caps implementation just checks against
+ * the allowed caps for the pad */
+static gboolean
+gst_pad_query_accept_caps (GstPad * pad, GstQuery * query)
+{
+  /* get the caps and see if it intersects to something not empty */
+  GstCaps *caps, *allowed;
+  gboolean result;
+
+  gst_query_parse_accept_caps (query, &caps);
+
+  GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
+
+  allowed = gst_pad_get_caps (pad, NULL);
+  if (allowed) {
+    GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
+    result = gst_caps_is_subset (caps, allowed);
+    gst_caps_unref (allowed);
+  } else {
+    GST_DEBUG_OBJECT (pad, "no caps allowed on the pad");
+    result = FALSE;
+  }
+  gst_query_set_accept_caps_result (query, result);
+
+  return TRUE;
+}
+
 /**
  * gst_pad_query_default:
  * @pad: a #GstPad to call the default query handler on.
@@ -3115,6 +3039,10 @@ gst_pad_query_default (GstPad * pad, GstQuery * query)
     case GST_QUERY_SCHEDULING:
       forward = FALSE;
       break;
+    case GST_QUERY_ACCEPT_CAPS:
+      ret = gst_pad_query_accept_caps (pad, query);
+      forward = FALSE;
+      break;
     case GST_QUERY_POSITION:
     case GST_QUERY_SEEKING:
     case GST_QUERY_FORMATS:
index 73152ce..5670196 100644 (file)
@@ -419,18 +419,6 @@ typedef void                       (*GstPadUnlinkFunction)         (GstPad *pad);
 typedef GstCaps*               (*GstPadGetCapsFunction)        (GstPad *pad, GstCaps *filter);
 
 /**
- * GstPadAcceptCapsFunction:
- * @pad: the #GstPad to check
- * @caps: the #GstCaps to check
- *
- * Check if @pad can accept @caps. By default this function will see if @caps
- * intersect with the result from gst_pad_get_caps() by can be overridden to
- * perform extra checks.
- *
- * Returns: TRUE if the caps can be accepted by the pad.
- */
-typedef gboolean               (*GstPadAcceptCapsFunction)     (GstPad *pad, GstCaps *caps);
-/**
  * GstPadFixateCapsFunction:
  * @pad: a #GstPad
  * @caps: the #GstCaps to fixate
@@ -626,7 +614,6 @@ typedef enum {
  * @block_cond: conditional to signal pad block
  * @probes: installed probes
  * @getcapsfunc: function to get caps of the pad
- * @acceptcapsfunc: function to check if pad can accept caps
  * @fixatecapsfunc: function to fixate caps
  * @mode: current activation mode of the pad
  * @activatefunc: pad activation function
@@ -668,7 +655,6 @@ struct _GstPad {
 
   /* the pad capabilities */
   GstPadGetCapsFunction                getcapsfunc;
-  GstPadAcceptCapsFunction      acceptcapsfunc;
   GstPadFixateCapsFunction      fixatecapsfunc;
 
   GstPadActivateMode            mode;
@@ -743,7 +729,6 @@ struct _GstPadClass {
 #define GST_PAD_UNLINKFUNC(pad)                (GST_PAD_CAST(pad)->unlinkfunc)
 
 #define GST_PAD_GETCAPSFUNC(pad)       (GST_PAD_CAST(pad)->getcapsfunc)
-#define GST_PAD_ACCEPTCAPSFUNC(pad)    (GST_PAD_CAST(pad)->acceptcapsfunc)
 #define GST_PAD_FIXATECAPSFUNC(pad)    (GST_PAD_CAST(pad)->fixatecapsfunc)
 
 #define GST_PAD_IS_SRC(pad)            (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
@@ -880,7 +865,6 @@ GstPad*                     gst_pad_get_peer                        (GstPad *pad);
 
 /* capsnego functions */
 void                   gst_pad_set_getcaps_function            (GstPad *pad, GstPadGetCapsFunction getcaps);
-void                   gst_pad_set_acceptcaps_function         (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
 void                   gst_pad_set_fixatecaps_function         (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
 
 GstCaps*                gst_pad_get_pad_template_caps          (GstPad *pad);
index 26b3f16..ffb72db 100644 (file)
@@ -54,7 +54,8 @@ static const gchar *_quark_strings[] = {
   "min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
   "GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
   "GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
-  "random-access", "sequential", "allocator", "GstEventFlushStop", "options"
+  "random-access", "sequential", "allocator", "GstEventFlushStop", "options",
+  "GstQueryAcceptCaps", "result"
 };
 
 GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 06eb709..430ba07 100644 (file)
@@ -155,8 +155,10 @@ typedef enum _GstQuarkId
   GST_QUARK_ALLOCATOR = 126,
   GST_QUARK_EVENT_FLUSH_STOP = 127,
   GST_QUARK_OPTIONS = 128,
+  GST_QUARK_QUERY_ACCEPT_CAPS = 129,
+  GST_QUARK_RESULT = 130,
 
-  GST_QUARK_MAX = 129
+  GST_QUARK_MAX = 131
 } GstQuarkId;
 
 extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 5053782..b9c828a 100644 (file)
@@ -105,6 +105,7 @@ static GstQueryTypeDefinition standard_definitions[] = {
   {GST_QUERY_URI, "uri", "URI of the source or sink", 0},
   {GST_QUERY_ALLOCATION, "allocation", "Allocation properties", 0},
   {GST_QUERY_SCHEDULING, "scheduling", "Scheduling properties", 0},
+  {GST_QUERY_ACCEPT_CAPS, "accept-caps", "Accept caps", 0},
   {GST_QUERY_NONE, NULL, NULL, 0}
 };
 
@@ -2002,3 +2003,63 @@ gst_query_parse_scheduling (GstQuery * query, gboolean * pull_mode,
       GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
       GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
 }
+
+/**
+ * gst_query_new_accept_caps
+ * @caps: a #GstCaps
+ *
+ * Constructs a new query object for querying if @caps are accepted.
+ *
+ * Free-function: gst_query_unref
+ *
+ * Returns: (transfer full): a new #GstQuery
+ */
+GstQuery *
+gst_query_new_accept_caps (GstCaps * caps)
+{
+  GstQuery *query;
+  GstStructure *structure;
+
+  structure = gst_structure_new_id (GST_QUARK (QUERY_ACCEPT_CAPS),
+      GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
+      GST_QUARK (RESULT), G_TYPE_BOOLEAN, FALSE, NULL);
+  query = gst_query_new (GST_QUERY_ACCEPT_CAPS, structure);
+
+  return query;
+}
+
+void
+gst_query_parse_accept_caps (GstQuery * query, GstCaps ** caps)
+{
+  GstStructure *structure;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+
+  structure = GST_QUERY_STRUCTURE (query);
+  gst_structure_id_get (structure, GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
+}
+
+void
+gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
+{
+  GstStructure *structure;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+  g_return_if_fail (gst_query_is_writable (query));
+
+  structure = GST_QUERY_STRUCTURE (query);
+  gst_structure_id_set (structure,
+      GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
+}
+
+void
+gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
+{
+  GstStructure *structure;
+
+  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+
+  structure = GST_QUERY_STRUCTURE (query);
+  gst_structure_id_get (structure,
+      GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
+}
index 7b83cbc..db0e9e4 100644 (file)
@@ -55,6 +55,7 @@ G_BEGIN_DECLS
  * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
  * @GST_QUERY_ALLOCATION: the buffer allocation properties
  * @GST_QUERY_SCHEDULING: the scheduling properties
+ * @GST_QUERY_ACCEPT_CAPS: the accept caps query
  *
  * Standard predefined Query types
  */
@@ -75,7 +76,9 @@ typedef enum {
   GST_QUERY_CUSTOM,
   GST_QUERY_URI,
   GST_QUERY_ALLOCATION,
-  GST_QUERY_SCHEDULING
+  GST_QUERY_SCHEDULING,
+  GST_QUERY_ACCEPT_CAPS,
+  GST_QUERY_LAST
 } GstQueryType;
 
 /**
@@ -378,6 +381,11 @@ void            gst_query_set_scheduling          (GstQuery *query, gboolean pul
 void            gst_query_parse_scheduling        (GstQuery *query, gboolean *pull_mode,
                                                    gboolean *random_access, gboolean *sequential,
                                                    gint *minsize, gint *maxsize, gint *align);
+/* accept-caps query */
+GstQuery *      gst_query_new_accept_caps          (GstCaps *caps);
+void            gst_query_parse_accept_caps        (GstQuery *query, GstCaps **caps);
+void            gst_query_set_accept_caps_result   (GstQuery *query, gboolean result);
+void            gst_query_parse_accept_caps_result (GstQuery *query, gboolean *result);
 
 G_END_DECLS
 
index 20851e3..198a4c2 100644 (file)
@@ -318,7 +318,6 @@ static GstFlowReturn gst_base_transform_getrange (GstPad * pad, guint64 offset,
 static GstFlowReturn gst_base_transform_chain (GstPad * pad,
     GstBuffer * buffer);
 static GstCaps *gst_base_transform_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps);
 static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps);
 static gboolean gst_base_transform_setcaps (GstBaseTransform * trans,
@@ -399,8 +398,6 @@ gst_base_transform_init (GstBaseTransform * trans,
   trans->sinkpad = gst_pad_new_from_template (pad_template, "sink");
   gst_pad_set_getcaps_function (trans->sinkpad,
       GST_DEBUG_FUNCPTR (gst_base_transform_getcaps));
-  gst_pad_set_acceptcaps_function (trans->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps));
   gst_pad_set_event_function (trans->sinkpad,
       GST_DEBUG_FUNCPTR (gst_base_transform_sink_event));
   gst_pad_set_chain_function (trans->sinkpad,
@@ -417,8 +414,6 @@ gst_base_transform_init (GstBaseTransform * trans,
   trans->srcpad = gst_pad_new_from_template (pad_template, "src");
   gst_pad_set_getcaps_function (trans->srcpad,
       GST_DEBUG_FUNCPTR (gst_base_transform_getcaps));
-  gst_pad_set_acceptcaps_function (trans->srcpad,
-      GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps));
   gst_pad_set_event_function (trans->srcpad,
       GST_DEBUG_FUNCPTR (gst_base_transform_src_event));
   gst_pad_set_getrange_function (trans->srcpad,
@@ -1182,24 +1177,6 @@ no_transform_possible:
   }
 }
 
-static gboolean
-gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps)
-{
-  gboolean ret = TRUE;
-  GstBaseTransform *trans;
-  GstBaseTransformClass *bclass;
-
-  trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
-  bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
-
-  if (bclass->accept_caps)
-    ret = bclass->accept_caps (trans, GST_PAD_DIRECTION (pad), caps);
-
-  gst_object_unref (trans);
-
-  return ret;
-}
-
 /* called when new caps arrive on the sink or source pad,
  * We try to find the best caps for the other side using our _find_transform()
  * function. If there are caps, we configure the transform for this new
@@ -1304,9 +1281,12 @@ gst_base_transform_default_query (GstBaseTransform * trans,
 {
   gboolean ret = FALSE;
   GstPad *otherpad;
+  GstBaseTransformClass *klass;
 
   otherpad = (direction == GST_PAD_SRC) ? trans->sinkpad : trans->srcpad;
 
+  klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
+
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_ALLOCATION:
     {
@@ -1324,11 +1304,7 @@ gst_base_transform_default_query (GstBaseTransform * trans,
         GST_DEBUG_OBJECT (trans, "doing passthrough query");
         ret = gst_pad_peer_query (otherpad, query);
       } else {
-        GstBaseTransformClass *klass;
-
         GST_DEBUG_OBJECT (trans, "propose allocation values");
-
-        klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
         /* pass the query to the propose_allocation vmethod if any */
         if (G_LIKELY (klass->propose_allocation))
           ret = klass->propose_allocation (trans, query);
@@ -1363,6 +1339,19 @@ gst_base_transform_default_query (GstBaseTransform * trans,
       }
       break;
     }
+    case GST_QUERY_ACCEPT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_query_parse_accept_caps (query, &caps);
+      if (klass->accept_caps) {
+        ret = klass->accept_caps (trans, direction, caps);
+        gst_query_set_accept_caps_result (query, ret);
+        /* return TRUE, we answered the query */
+        ret = TRUE;
+      }
+      break;
+    }
     default:
       ret = gst_pad_peer_query (otherpad, query);
       break;
index b4729c9..f318aa9 100644 (file)
@@ -180,7 +180,6 @@ static gint64 gst_selector_pad_get_running_time (GstSelectorPad * pad);
 static void gst_selector_pad_reset (GstSelectorPad * pad);
 static gboolean gst_selector_pad_event (GstPad * pad, GstEvent * event);
 static GstCaps *gst_selector_pad_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_selector_pad_acceptcaps (GstPad * pad, GstCaps * caps);
 static gboolean gst_selector_pad_query (GstPad * pad, GstQuery * query);
 static GstIterator *gst_selector_pad_iterate_linked_pads (GstPad * pad);
 static GstFlowReturn gst_selector_pad_chain (GstPad * pad, GstBuffer * buf);
@@ -506,6 +505,7 @@ gst_selector_pad_query (GstPad * pad, GstQuery * query)
   otherpad = gst_input_selector_get_linked_pad (sel, pad, TRUE);
 
   switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
     default:
       if (otherpad)
         res = gst_pad_peer_query (otherpad, query);
@@ -539,23 +539,6 @@ gst_selector_pad_getcaps (GstPad * pad, GstCaps * filter)
   return caps;
 }
 
-static gboolean
-gst_selector_pad_acceptcaps (GstPad * pad, GstCaps * caps)
-{
-  GstInputSelector *sel;
-  gboolean res;
-
-  sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
-  if (G_UNLIKELY (sel == NULL))
-    return FALSE;
-
-  GST_DEBUG_OBJECT (sel, "Checking acceptcaps of srcpad peer");
-  res = gst_pad_peer_accept_caps (sel->srcpad, caps);
-  gst_object_unref (sel);
-
-  return res;
-}
-
 /* must be called with the SELECTOR_LOCK, will block while the pad is blocked 
  * or return TRUE when flushing */
 static gboolean
@@ -1323,8 +1306,6 @@ gst_input_selector_request_new_pad (GstElement * element,
       GST_DEBUG_FUNCPTR (gst_selector_pad_event));
   gst_pad_set_getcaps_function (sinkpad,
       GST_DEBUG_FUNCPTR (gst_selector_pad_getcaps));
-  gst_pad_set_acceptcaps_function (sinkpad,
-      GST_DEBUG_FUNCPTR (gst_selector_pad_acceptcaps));
   gst_pad_set_query_function (sinkpad,
       GST_DEBUG_FUNCPTR (gst_selector_pad_query));
   gst_pad_set_chain_function (sinkpad,
index 5ff8376..57bbec0 100644 (file)
@@ -1036,16 +1036,10 @@ gst_single_queue_push_one (GstMultiQueue * mq, GstSingleQueue * sq,
   if (GST_IS_BUFFER (object)) {
     GstBuffer *buffer;
     GstClockTime timestamp, duration;
-#if 0
-    GstCaps *caps;
-#endif
 
     buffer = GST_BUFFER_CAST (object);
     timestamp = GST_BUFFER_TIMESTAMP (buffer);
     duration = GST_BUFFER_DURATION (buffer);
-#if 0
-    caps = GST_BUFFER_CAPS (buffer);
-#endif
 
     apply_buffer (mq, sq, timestamp, duration, &sq->src_segment);
 
@@ -1056,14 +1050,6 @@ gst_single_queue_push_one (GstMultiQueue * mq, GstSingleQueue * sq,
         "SingleQueue %d : Pushing buffer %p with ts %" GST_TIME_FORMAT,
         sq->id, buffer, GST_TIME_ARGS (timestamp));
 
-#if 0
-    /* Set caps on pad before pushing, this avoids core calling the acceptcaps
-     * function on the srcpad, which will call acceptcaps upstream, which might
-     * not accept these caps (anymore). */
-    if (caps && caps != GST_PAD_CAPS (sq->srcpad))
-      gst_pad_set_caps (sq->srcpad, caps);
-#endif
-
     result = gst_pad_push (sq->srcpad, buffer);
   } else if (GST_IS_EVENT (object)) {
     GstEvent *event;
@@ -1525,6 +1511,7 @@ gst_multi_queue_sink_query (GstPad * pad, GstQuery * query)
   gboolean res;
 
   switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
     default:
       /* default handling */
       res = gst_pad_peer_query (sq->srcpad, query);
@@ -1552,22 +1539,6 @@ gst_multi_queue_getcaps (GstPad * pad, GstCaps * filter)
 }
 
 static gboolean
-gst_multi_queue_acceptcaps (GstPad * pad, GstCaps * caps)
-{
-  GstSingleQueue *sq = gst_pad_get_element_private (pad);
-  GstPad *otherpad;
-  gboolean result;
-
-  otherpad = (pad == sq->srcpad) ? sq->sinkpad : sq->srcpad;
-
-  GST_LOG_OBJECT (otherpad, "Accept caps from the peer of this pad");
-
-  result = gst_pad_peer_accept_caps (otherpad, caps);
-
-  return result;
-}
-
-static gboolean
 gst_multi_queue_src_activate_push (GstPad * pad, gboolean active)
 {
   GstMultiQueue *mq;
@@ -1605,6 +1576,7 @@ gst_multi_queue_src_query (GstPad * pad, GstQuery * query)
 
   /* FIXME, Handle position offset depending on queue size */
   switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
     default:
       /* default handling */
       res = gst_pad_peer_query (sq->sinkpad, query);
@@ -1953,8 +1925,6 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id)
       GST_DEBUG_FUNCPTR (gst_multi_queue_sink_event));
   gst_pad_set_getcaps_function (sq->sinkpad,
       GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
-  gst_pad_set_acceptcaps_function (sq->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_multi_queue_acceptcaps));
   gst_pad_set_query_function (sq->sinkpad,
       GST_DEBUG_FUNCPTR (gst_multi_queue_sink_query));
   gst_pad_set_iterate_internal_links_function (sq->sinkpad,
@@ -1968,8 +1938,6 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id)
       GST_DEBUG_FUNCPTR (gst_multi_queue_src_activate_push));
   gst_pad_set_getcaps_function (sq->srcpad,
       GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
-  gst_pad_set_acceptcaps_function (sq->srcpad,
-      GST_DEBUG_FUNCPTR (gst_multi_queue_acceptcaps));
   gst_pad_set_event_function (sq->srcpad,
       GST_DEBUG_FUNCPTR (gst_multi_queue_src_event));
   gst_pad_set_query_function (sq->srcpad,
index fbc1d1a..0fb3cdf 100644 (file)
@@ -197,6 +197,7 @@ static GstFlowReturn gst_queue_push_one (GstQueue * queue);
 static void gst_queue_loop (GstPad * pad);
 
 static gboolean gst_queue_handle_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_queue_handle_sink_query (GstPad * pad, GstQuery * query);
 
 static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
 static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query);
@@ -370,6 +371,7 @@ gst_queue_class_init (GstQueueClass * klass)
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_chain);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_sink_activate_push);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_event);
+  GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_query);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_sink);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_getcaps);
   GST_DEBUG_REGISTER_FUNCPTR (gst_queue_acceptcaps);
@@ -388,9 +390,9 @@ gst_queue_init (GstQueue * queue)
   gst_pad_set_activatepush_function (queue->sinkpad,
       gst_queue_sink_activate_push);
   gst_pad_set_event_function (queue->sinkpad, gst_queue_handle_sink_event);
+  gst_pad_set_query_function (queue->sinkpad, gst_queue_handle_sink_query);
   gst_pad_set_link_function (queue->sinkpad, gst_queue_link_sink);
   gst_pad_set_getcaps_function (queue->sinkpad, gst_queue_getcaps);
-  gst_pad_set_acceptcaps_function (queue->sinkpad, gst_queue_acceptcaps);
   gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
 
   queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
@@ -398,7 +400,6 @@ gst_queue_init (GstQueue * queue)
   gst_pad_set_activatepush_function (queue->srcpad,
       gst_queue_src_activate_push);
   gst_pad_set_link_function (queue->srcpad, gst_queue_link_src);
-  gst_pad_set_acceptcaps_function (queue->srcpad, gst_queue_acceptcaps);
   gst_pad_set_getcaps_function (queue->srcpad, gst_queue_getcaps);
   gst_pad_set_event_function (queue->srcpad, gst_queue_handle_src_event);
   gst_pad_set_query_function (queue->srcpad, gst_queue_handle_src_query);
@@ -863,6 +864,26 @@ out_eos:
 }
 
 static gboolean
+gst_queue_handle_sink_query (GstPad * pad, GstQuery * query)
+{
+  GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
+  gboolean res;
+
+  if (G_UNLIKELY (queue == NULL))
+    return FALSE;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
+    default:
+      res = gst_pad_peer_query (queue->srcpad, query);
+      break;
+  }
+  gst_object_unref (queue);
+
+  return res;
+}
+
+static gboolean
 gst_queue_is_empty (GstQueue * queue)
 {
   if (queue->queue.length == 0)
@@ -1273,19 +1294,12 @@ static gboolean
 gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
 {
   GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
-  GstPad *peer;
   gboolean res;
 
   if (G_UNLIKELY (queue == NULL))
     return FALSE;
 
-  if (!(peer = gst_pad_get_peer (queue->sinkpad))) {
-    gst_object_unref (queue);
-    return FALSE;
-  }
-
-  res = gst_pad_query (peer, query);
-  gst_object_unref (peer);
+  res = gst_pad_peer_query (queue->sinkpad, query);
   if (!res) {
     gst_object_unref (queue);
     return FALSE;
index d868c24..a6a380d 100644 (file)
@@ -228,6 +228,7 @@ static GstFlowReturn gst_queue2_push_one (GstQueue2 * queue);
 static void gst_queue2_loop (GstPad * pad);
 
 static gboolean gst_queue2_handle_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_queue2_handle_sink_query (GstPad * pad, GstQuery * query);
 
 static gboolean gst_queue2_handle_src_event (GstPad * pad, GstEvent * event);
 static gboolean gst_queue2_handle_src_query (GstPad * pad, GstQuery * query);
@@ -235,7 +236,6 @@ static gboolean gst_queue2_handle_query (GstElement * element,
     GstQuery * query);
 
 static GstCaps *gst_queue2_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_queue2_acceptcaps (GstPad * pad, GstCaps * caps);
 
 static GstFlowReturn gst_queue2_get_range (GstPad * pad, guint64 offset,
     guint length, GstBuffer ** buffer);
@@ -379,10 +379,10 @@ gst_queue2_init (GstQueue2 * queue)
       GST_DEBUG_FUNCPTR (gst_queue2_sink_activate_push));
   gst_pad_set_event_function (queue->sinkpad,
       GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_event));
+  gst_pad_set_query_function (queue->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_query));
   gst_pad_set_getcaps_function (queue->sinkpad,
       GST_DEBUG_FUNCPTR (gst_queue2_getcaps));
-  gst_pad_set_acceptcaps_function (queue->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_queue2_acceptcaps));
   gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
 
   queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
@@ -395,8 +395,6 @@ gst_queue2_init (GstQueue2 * queue)
       GST_DEBUG_FUNCPTR (gst_queue2_get_range));
   gst_pad_set_getcaps_function (queue->srcpad,
       GST_DEBUG_FUNCPTR (gst_queue2_getcaps));
-  gst_pad_set_acceptcaps_function (queue->srcpad,
-      GST_DEBUG_FUNCPTR (gst_queue2_acceptcaps));
   gst_pad_set_event_function (queue->srcpad,
       GST_DEBUG_FUNCPTR (gst_queue2_handle_src_event));
   gst_pad_set_query_function (queue->srcpad,
@@ -611,21 +609,6 @@ init_ranges (GstQueue2 * queue)
   queue->current = add_range (queue, 0);
 }
 
-static gboolean
-gst_queue2_acceptcaps (GstPad * pad, GstCaps * caps)
-{
-  GstQueue2 *queue;
-  GstPad *otherpad;
-  gboolean result;
-
-  queue = GST_QUEUE2 (GST_PAD_PARENT (pad));
-
-  otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad);
-  result = gst_pad_peer_accept_caps (otherpad, caps);
-
-  return result;
-}
-
 static GstCaps *
 gst_queue2_getcaps (GstPad * pad, GstCaps * filter)
 {
@@ -2056,6 +2039,26 @@ out_eos:
 }
 
 static gboolean
+gst_queue2_handle_sink_query (GstPad * pad, GstQuery * query)
+{
+  gboolean res;
+  GstQueue2 *queue;
+
+  queue = GST_QUEUE2 (gst_pad_get_parent (pad));
+  if (G_UNLIKELY (queue == NULL))
+    return FALSE;
+
+  switch (GST_QUERY_TYPE (query)) {
+    default:
+      res = gst_pad_peer_query (queue->srcpad, query);
+      break;
+  }
+  gst_object_unref (queue);
+
+  return res;
+}
+
+static gboolean
 gst_queue2_is_empty (GstQueue2 * queue)
 {
   /* never empty on EOS */
@@ -2411,19 +2414,6 @@ gst_queue2_handle_src_event (GstPad * pad, GstEvent * event)
 }
 
 static gboolean
-gst_queue2_peer_query (GstQueue2 * queue, GstPad * pad, GstQuery * query)
-{
-  gboolean ret = FALSE;
-  GstPad *peer;
-
-  if ((peer = gst_pad_get_peer (pad))) {
-    ret = gst_pad_query (peer, query);
-    gst_object_unref (peer);
-  }
-  return ret;
-}
-
-static gboolean
 gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
 {
   GstQueue2 *queue;
@@ -2438,7 +2428,7 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
       gint64 peer_pos;
       GstFormat format;
 
-      if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+      if (!gst_pad_peer_query (queue->sinkpad, query))
         goto peer_failed;
 
       /* get peer position */
@@ -2465,7 +2455,7 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
     {
       GST_DEBUG_OBJECT (queue, "doing peer query");
 
-      if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+      if (!gst_pad_peer_query (queue->sinkpad, query))
         goto peer_failed;
 
       GST_DEBUG_OBJECT (queue, "peer query success");
@@ -2480,7 +2470,7 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
       /* FIXME - is this condition correct? what should ring buffer do? */
       if (QUEUE_IS_USING_QUEUE (queue)) {
         /* no temp file, just forward to the peer */
-        if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+        if (!gst_pad_peer_query (queue->sinkpad, query))
           goto peer_failed;
         GST_DEBUG_OBJECT (queue, "buffering forwarded to peer");
       } else {
@@ -2604,7 +2594,7 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
     }
     default:
       /* peer handled other queries */
-      if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+      if (!gst_pad_peer_query (queue->sinkpad, query))
         goto peer_failed;
       break;
   }
index ce5f91c..5e22d28 100644 (file)
@@ -139,6 +139,7 @@ static void gst_tee_dispose (GObject * object);
 static GstFlowReturn gst_tee_chain (GstPad * pad, GstBuffer * buffer);
 static GstFlowReturn gst_tee_chain_list (GstPad * pad, GstBufferList * list);
 static gboolean gst_tee_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_tee_sink_query (GstPad * pad, GstQuery * query);
 static gboolean gst_tee_sink_acceptcaps (GstPad * pad, GstCaps * caps);
 static gboolean gst_tee_sink_activate_push (GstPad * pad, gboolean active);
 static gboolean gst_tee_src_query (GstPad * pad, GstQuery * query);
@@ -249,10 +250,10 @@ gst_tee_init (GstTee * tee)
 
   gst_pad_set_event_function (tee->sinkpad,
       GST_DEBUG_FUNCPTR (gst_tee_sink_event));
+  gst_pad_set_query_function (tee->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_tee_sink_query));
   gst_pad_set_getcaps_function (tee->sinkpad,
       GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-  gst_pad_set_acceptcaps_function (tee->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_tee_sink_acceptcaps));
   gst_pad_set_activatepush_function (tee->sinkpad,
       GST_DEBUG_FUNCPTR (gst_tee_sink_activate_push));
   gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
@@ -533,6 +534,30 @@ gst_tee_sink_acceptcaps (GstPad * pad, GstCaps * caps)
   return res;
 }
 
+static gboolean
+gst_tee_sink_query (GstPad * pad, GstQuery * query)
+{
+  gboolean res;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_query_parse_accept_caps (query, &caps);
+      res = gst_tee_sink_acceptcaps (pad, caps);
+      gst_query_set_accept_caps_result (query, res);
+      res = TRUE;
+      break;
+    }
+    default:
+      res = gst_pad_query_default (pad, query);
+      break;
+  }
+
+  return res;
+}
+
 static void
 gst_tee_do_message (GstTee * tee, GstPad * pad, gpointer data, gboolean is_list)
 {
index e159fac..1d7519f 100644 (file)
@@ -810,10 +810,6 @@ print_pad_info (GstElement * element)
     if (pad->getcapsfunc)
       n_print ("      Has getcapsfunc(): %s\n",
           GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
-    /* gst_pad_acceptcaps_default is static :/ */
-    if (pad->acceptcapsfunc)
-      n_print ("      Has acceptcapsfunc(): %s\n",
-          GST_DEBUG_FUNCPTR_NAME (pad->acceptcapsfunc));
     if (pad->fixatecapsfunc)
       n_print ("      Has fixatecapsfunc(): %s\n",
           GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc));