caps: small doc improvement
[platform/upstream/gstreamer.git] / gst / gstghostpad.c
index d8fb3ea..953704b 100644 (file)
@@ -66,49 +66,10 @@ G_DEFINE_TYPE (GstProxyPad, gst_proxy_pad, GST_TYPE_PAD);
 
 static GstPad *gst_proxy_pad_get_target (GstPad * pad);
 
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
-#ifdef GST_DISABLE_DEPRECATED
-#include <libxml/parser.h>
-#endif
-static xmlNodePtr gst_proxy_pad_save_thyself (GstObject * object,
-    xmlNodePtr parent);
-#endif
-
-static void on_src_target_notify (GstPad * target,
-    GParamSpec * unused, gpointer user_data);
-
-static GParamSpec *pspec_caps = NULL;
-
-/**
- * gst_proxy_pad_query_type_default:
- * @pad: a #GstPad.
- *
- * Invoke the default query type handler of the proxy pad.
- *
- * Returns: (transfer none) (array zero-terminated=1): a zero-terminated array
- *     of #GstQueryType.
- *
- * Since: 0.10.36
- */
-const GstQueryType *
-gst_proxy_pad_query_type_default (GstPad * pad)
-{
-  GstPad *target;
-  const GstQueryType *res = NULL;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
-
-  target = gst_proxy_pad_get_target (pad);
-  if (target) {
-    res = gst_pad_get_query_types (target);
-    gst_object_unref (target);
-  }
-  return res;
-}
-
 /**
  * gst_proxy_pad_event_default:
  * @pad: a #GstPad to push the event to.
+ * @parent: the parent of @pad or NULL
  * @event: (transfer full): the #GstEvent to send to the pad.
  *
  * Invoke the default event of the proxy pad.
@@ -118,27 +79,105 @@ gst_proxy_pad_query_type_default (GstPad * pad)
  * Since: 0.10.36
  */
 gboolean
-gst_proxy_pad_event_default (GstPad * pad, GstEvent * event)
+gst_proxy_pad_event_default (GstPad * pad, GstObject * parent, GstEvent * event)
 {
-  gboolean res = FALSE;
+  gboolean res;
   GstPad *internal;
 
   g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
   g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
 
-  internal =
-      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad)));
-  if (internal) {
-    res = gst_pad_push_event (internal, event);
-    gst_object_unref (internal);
+  internal = GST_PROXY_PAD_INTERNAL (pad);
+  res = gst_pad_push_event (internal, event);
+
+  return res;
+}
+
+static gboolean
+gst_proxy_pad_query_caps (GstPad * pad, GstQuery * query)
+{
+  gboolean res;
+  GstPad *target;
+  GstCaps *result;
+  GstPadTemplate *templ;
+
+  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
+
+  templ = GST_PAD_PAD_TEMPLATE (pad);
+  target = gst_proxy_pad_get_target (pad);
+  if (target) {
+    /* if we have a real target, proxy the call */
+    res = gst_pad_query (target, query);
+
+    GST_DEBUG_OBJECT (pad, "get caps of target %s:%s : %" GST_PTR_FORMAT,
+        GST_DEBUG_PAD_NAME (target), query);
+
+    gst_object_unref (target);
+
+    /* filter against the template */
+    if (templ && res) {
+      GstCaps *filt, *tmp;
+
+      filt = GST_PAD_TEMPLATE_CAPS (templ);
+      if (filt) {
+        gst_query_parse_caps_result (query, &result);
+        tmp = gst_caps_intersect_full (result, filt, GST_CAPS_INTERSECT_FIRST);
+        gst_query_set_caps_result (query, tmp);
+        GST_DEBUG_OBJECT (pad,
+            "filtered against template gives %" GST_PTR_FORMAT, tmp);
+        gst_caps_unref (tmp);
+      }
+    }
+  } else {
+    GstCaps *filter;
+
+    res = TRUE;
+
+    gst_query_parse_caps (query, &filter);
+
+    /* else, if we have a template, use its caps. */
+    if (templ) {
+      result = GST_PAD_TEMPLATE_CAPS (templ);
+      GST_DEBUG_OBJECT (pad,
+          "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
+          result);
+
+      if (filter) {
+        GstCaps *intersection;
+
+        GST_DEBUG_OBJECT (pad, "intersect with filter");
+        intersection =
+            gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
+        gst_query_set_caps_result (query, intersection);
+        gst_caps_unref (intersection);
+      } else {
+        gst_query_set_caps_result (query, result);
+      }
+      goto done;
+    }
+
+    /* If there's a filter, return that */
+    if (filter != NULL) {
+      GST_DEBUG_OBJECT (pad, "return filter");
+      gst_query_set_caps_result (query, filter);
+      goto done;
+    }
+
+    /* last resort, any caps */
+    GST_DEBUG_OBJECT (pad, "pad has no template, returning ANY");
+    result = gst_caps_new_any ();
+    gst_query_set_caps_result (query, result);
+    gst_caps_unref (result);
   }
 
+done:
   return res;
 }
 
 /**
  * gst_proxy_pad_query_default:
  * @pad: a #GstPad to invoke the default query on.
+ * @parent: the parent of @pad or NULL
  * @query: (transfer none): the #GstQuery to perform.
  *
  * Invoke the default query function of the proxy pad.
@@ -148,26 +187,55 @@ gst_proxy_pad_event_default (GstPad * pad, GstEvent * event)
  * Since: 0.10.36
  */
 gboolean
-gst_proxy_pad_query_default (GstPad * pad, GstQuery * query)
+gst_proxy_pad_query_default (GstPad * pad, GstObject * parent, GstQuery * query)
 {
-  gboolean res = FALSE;
+  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);
-  if (target) {
-    res = gst_pad_query (target, query);
-    gst_object_unref (target);
-  }
 
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_ACCEPT_CAPS:
+    {
+      target = gst_proxy_pad_get_target (pad);
+      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;
+    }
+    case GST_QUERY_CAPS:
+    {
+      res = gst_proxy_pad_query_caps (pad, query);
+      break;
+    }
+    default:
+    {
+      target = gst_proxy_pad_get_target (pad);
+      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;
 }
 
 /**
  * gst_proyx_pad_iterate_internal_links_default:
  * @pad: the #GstPad to get the internal links of.
+ * @parent: the parent of @pad or NULL
  *
  * Invoke the default iterate internal links function of the proxy pad.
  *
@@ -177,68 +245,27 @@ gst_proxy_pad_query_default (GstPad * pad, GstQuery * query)
  * Since: 0.10.36
  */
 GstIterator *
-gst_proxy_pad_iterate_internal_links_default (GstPad * pad)
+gst_proxy_pad_iterate_internal_links_default (GstPad * pad, GstObject * parent)
 {
   GstIterator *res = NULL;
   GstPad *internal;
+  GValue v = { 0, };
 
   g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
 
-  internal =
-      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad)));
-
-  if (internal) {
-    res =
-        gst_iterator_new_single (GST_TYPE_PAD, internal,
-        (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
-    gst_object_unref (internal);
-  }
+  internal = GST_PROXY_PAD_INTERNAL (pad);
+  g_value_init (&v, GST_TYPE_PAD);
+  g_value_set_object (&v, internal);
+  res = gst_iterator_new_single (GST_TYPE_PAD, &v);
+  g_value_unset (&v);
 
   return res;
 }
 
 /**
- * gst_proxy_pad_bufferalloc_default:
- * @pad: a source #GstPad
- * @offset: the offset of the new buffer in the stream
- * @size: the size of the new buffer
- * @caps: the caps of the new buffer
- * @buf: a newly allocated buffer
- *
- * Invoke the default bufferalloc function of the proxy pad.
- *
- * Returns: a result code indicating success of the operation. Any
- * result code other than #GST_FLOW_OK is an error and @buf should
- * not be used.
- * An error can occur if the pad is not connected or when the downstream
- * peer elements cannot provide an acceptable buffer.
- *
- * Since: 0.10.36
- */
-GstFlowReturn
-gst_proxy_pad_bufferalloc_default (GstPad * pad, guint64 offset, guint size,
-    GstCaps * caps, GstBuffer ** buf)
-{
-  GstFlowReturn result = GST_FLOW_WRONG_STATE;
-  GstPad *internal;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), GST_FLOW_ERROR);
-  g_return_val_if_fail (caps == NULL || GST_IS_CAPS (caps), GST_FLOW_ERROR);
-  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
-
-  internal =
-      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad)));
-  if (internal) {
-    result = gst_pad_alloc_buffer (internal, offset, size, caps, buf);
-    gst_object_unref (internal);
-  }
-
-  return result;
-}
-
-/**
  * gst_proxy_pad_chain_default:
  * @pad: a sink #GstPad, returns GST_FLOW_ERROR if not.
+ * @parent: the parent of @pad or NULL
  * @buffer: (transfer full): the #GstBuffer to send, return GST_FLOW_ERROR
  *     if not.
  *
@@ -249,7 +276,8 @@ gst_proxy_pad_bufferalloc_default (GstPad * pad, guint64 offset, guint size,
  * Since: 0.10.36
  */
 GstFlowReturn
-gst_proxy_pad_chain_default (GstPad * pad, GstBuffer * buffer)
+gst_proxy_pad_chain_default (GstPad * pad, GstObject * parent,
+    GstBuffer * buffer)
 {
   GstFlowReturn res;
   GstPad *internal;
@@ -266,6 +294,7 @@ gst_proxy_pad_chain_default (GstPad * pad, GstBuffer * buffer)
 /**
  * gst_proxy_pad_chain_list_default:
  * @pad: a sink #GstPad, returns GST_FLOW_ERROR if not.
+ * @parent: the parent of @pad or NULL
  * @list: (transfer full): the #GstBufferList to send, return GST_FLOW_ERROR
  *     if not.
  *
@@ -276,7 +305,8 @@ gst_proxy_pad_chain_default (GstPad * pad, GstBuffer * buffer)
  * Since: 0.10.36
  */
 GstFlowReturn
-gst_proxy_pad_chain_list_default (GstPad * pad, GstBufferList * list)
+gst_proxy_pad_chain_list_default (GstPad * pad, GstObject * parent,
+    GstBufferList * list)
 {
   GstFlowReturn res;
   GstPad *internal;
@@ -305,8 +335,8 @@ gst_proxy_pad_chain_list_default (GstPad * pad, GstBufferList * list)
  * Since: 0.10.36
  */
 GstFlowReturn
-gst_proxy_pad_getrange_default (GstPad * pad, guint64 offset, guint size,
-    GstBuffer ** buffer)
+gst_proxy_pad_getrange_default (GstPad * pad, GstObject * parent,
+    guint64 offset, guint size, GstBuffer ** buffer)
 {
   GstFlowReturn res;
   GstPad *internal;
@@ -320,185 +350,6 @@ gst_proxy_pad_getrange_default (GstPad * pad, guint64 offset, guint size,
   return res;
 }
 
-/**
- * gst_proxy_pad_checkgetrange_default:
- * @pad: a src #GstPad, returns #GST_FLOW_ERROR if not.
- *
- * Invoke the default checkgetrange function of the proxy pad.
- *
- * Returns: a #gboolean from the pad.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_proxy_pad_checkgetrange_default (GstPad * pad)
-{
-  gboolean result;
-  GstPad *internal;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
-  internal = GST_PROXY_PAD_INTERNAL (pad);
-  result = gst_pad_check_pull_range (internal);
-
-  return result;
-}
-
-/**
- * gst_proxy_pad_getcaps_default:
- * @pad: a  #GstPad to get the capabilities of.
- *
- * Invoke the default getcaps function of the proxy pad.
- *
- * Returns: (transfer full): the caps of the pad with incremented ref-count
- *
- * Since: 0.10.36
- */
-GstCaps *
-gst_proxy_pad_getcaps_default (GstPad * pad)
-{
-  GstPad *target;
-  GstCaps *res;
-  GstPadTemplate *templ;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
-
-  templ = GST_PAD_PAD_TEMPLATE (pad);
-  target = gst_proxy_pad_get_target (pad);
-  if (target) {
-    /* if we have a real target, proxy the call */
-    res = gst_pad_get_caps_reffed (target);
-
-    GST_DEBUG_OBJECT (pad, "get caps of target %s:%s : %" GST_PTR_FORMAT,
-        GST_DEBUG_PAD_NAME (target), res);
-
-    gst_object_unref (target);
-
-    /* filter against the template */
-    if (templ && res) {
-      GstCaps *filt, *tmp;
-
-      filt = GST_PAD_TEMPLATE_CAPS (templ);
-      if (filt) {
-        tmp = gst_caps_intersect (filt, res);
-        gst_caps_unref (res);
-        res = tmp;
-        GST_DEBUG_OBJECT (pad,
-            "filtered against template gives %" GST_PTR_FORMAT, res);
-      }
-    }
-  } else {
-    /* else, if we have a template, use its caps. */
-    if (templ) {
-      res = GST_PAD_TEMPLATE_CAPS (templ);
-      GST_DEBUG_OBJECT (pad,
-          "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, res,
-          res);
-      res = gst_caps_ref (res);
-      goto done;
-    }
-
-    /* last resort, any caps */
-    GST_DEBUG_OBJECT (pad, "pad has no template, returning ANY");
-    res = gst_caps_new_any ();
-  }
-
-done:
-  return res;
-}
-
-/**
- * gst_proxy_pad_acceptcaps_default:
- * @pad: a #GstPad to check
- * @caps: a #GstCaps to check on the pad
- *
- * Invoke the default acceptcaps function of the proxy pad.
- *
- * Returns: TRUE if the pad can accept the caps.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_proxy_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
-{
-  GstPad *target;
-  gboolean res;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-  g_return_val_if_fail (caps == NULL || GST_IS_CAPS (caps), FALSE);
-
-  target = gst_proxy_pad_get_target (pad);
-  if (target) {
-    res = gst_pad_accept_caps (target, caps);
-    gst_object_unref (target);
-  } else {
-    /* 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;
-  }
-
-  return res;
-}
-
-/**
- * gst_proxy_pad_fixatecaps_default:
- * @pad: a  #GstPad to fixate
- * @caps: the  #GstCaps to fixate
- *
- * Invoke the default fixatecaps function of the proxy pad.
- *
- * Since: 0.10.36
- */
-void
-gst_proxy_pad_fixatecaps_default (GstPad * pad, GstCaps * caps)
-{
-  GstPad *target;
-
-  g_return_if_fail (GST_IS_PROXY_PAD (pad));
-  g_return_if_fail (GST_IS_CAPS (caps));
-
-  target = gst_proxy_pad_get_target (pad);
-  if (target) {
-    gst_pad_fixate_caps (target, caps);
-    gst_object_unref (target);
-  }
-}
-
-/**
- * gst_proxy_pad_setcaps_default:
- * @pad: a  #GstPad to set the capabilities of.
- * @caps: (transfer none): a #GstCaps to set.
- *
- * Invoke the default setcaps function of the proxy pad.
- *
- * Returns: TRUE if the caps could be set. FALSE if the caps were not fixed
- * or bad parameters were provided to this function.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_proxy_pad_setcaps_default (GstPad * pad, GstCaps * caps)
-{
-  GstPad *target;
-  gboolean res;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-  g_return_val_if_fail (caps == NULL || GST_IS_CAPS (caps), FALSE);
-
-  target = gst_proxy_pad_get_target (pad);
-  if (target) {
-    res = gst_pad_set_caps (target, caps);
-    gst_object_unref (target);
-  } else {
-    /* We don't have any target, but we shouldn't return FALSE since this
-     * would stop the actual push of a buffer (which might trigger a pad block
-     * or probe, or properly return GST_FLOW_NOT_LINKED.
-     */
-    res = TRUE;
-  }
-  return res;
-}
-
 static GstPad *
 gst_proxy_pad_get_target (GstPad * pad)
 {
@@ -563,31 +414,14 @@ gst_proxy_pad_class_init (GstProxyPadClass * klass)
 {
   g_type_class_add_private (klass, sizeof (GstProxyPadPrivate));
 
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
-  {
-    GstObjectClass *gstobject_class = (GstObjectClass *) klass;
-
-    gstobject_class->save_thyself =
-        ((gpointer (*)(GstObject * object,
-                gpointer self)) *
-        GST_DEBUG_FUNCPTR (gst_proxy_pad_save_thyself));
-  }
-#endif
   /* Register common function pointer descriptions */
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_query_type_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_event_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_query_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_iterate_internal_links_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_getcaps_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_acceptcaps_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_fixatecaps_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_setcaps_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_unlink_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_bufferalloc_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_list_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_getrange_default);
-  GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_checkgetrange_default);
 }
 
 static void
@@ -598,73 +432,14 @@ gst_proxy_pad_init (GstProxyPad * ppad)
   GST_PROXY_PAD_PRIVATE (ppad) = G_TYPE_INSTANCE_GET_PRIVATE (ppad,
       GST_TYPE_PROXY_PAD, GstProxyPadPrivate);
 
-  gst_pad_set_query_type_function (pad, gst_proxy_pad_query_type_default);
   gst_pad_set_event_function (pad, gst_proxy_pad_event_default);
   gst_pad_set_query_function (pad, gst_proxy_pad_query_default);
   gst_pad_set_iterate_internal_links_function (pad,
       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_setcaps_function (pad, gst_proxy_pad_setcaps_default);
   gst_pad_set_unlink_function (pad, gst_proxy_pad_unlink_default);
 }
 
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
-/**
- * gst_proxy_pad_save_thyself:
- * @pad: a ghost #GstPad to save.
- * @parent: the parent #xmlNodePtr to save the description in.
- *
- * Saves the ghost pad into an xml representation.
- *
- * Returns: the #xmlNodePtr representation of the pad.
- */
-static xmlNodePtr
-gst_proxy_pad_save_thyself (GstObject * object, xmlNodePtr parent)
-{
-  xmlNodePtr self;
-  GstProxyPad *proxypad;
-  GstPad *pad;
-  GstPad *peer;
-
-  g_return_val_if_fail (GST_IS_PROXY_PAD (object), NULL);
-
-  self = xmlNewChild (parent, NULL, (xmlChar *) "ghostpad", NULL);
-  xmlNewChild (self, NULL, (xmlChar *) "name",
-      (xmlChar *) GST_OBJECT_NAME (object));
-  xmlNewChild (self, NULL, (xmlChar *) "parent",
-      (xmlChar *) GST_OBJECT_NAME (GST_OBJECT_PARENT (object)));
-
-  proxypad = GST_PROXY_PAD_CAST (object);
-  pad = GST_PAD_CAST (proxypad);
-  peer = GST_PAD_CAST (pad->peer);
-
-  if (GST_IS_PAD (pad)) {
-    if (GST_PAD_IS_SRC (pad))
-      xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "source");
-    else if (GST_PAD_IS_SINK (pad))
-      xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "sink");
-    else
-      xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "unknown");
-  } else {
-    xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "unknown");
-  }
-  if (GST_IS_PAD (peer)) {
-    gchar *content = g_strdup_printf ("%s.%s",
-        GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer));
-
-    xmlNewChild (self, NULL, (xmlChar *) "peer", (xmlChar *) content);
-    g_free (content);
-  } else {
-    xmlNewChild (self, NULL, (xmlChar *) "peer", NULL);
-  }
-
-  return self;
-}
-#endif /* GST_DISABLE_LOADSAVE */
-
 
 /***********************************************************************
  * Ghost pads, implemented as a pair of proxy pads (sort of)
@@ -676,8 +451,6 @@ gst_proxy_pad_save_thyself (GstObject * object, xmlNodePtr parent)
 struct _GstGhostPadPrivate
 {
   /* with PROXY_LOCK */
-  gulong notify_id;
-
   gboolean constructed;
 };
 
@@ -685,57 +458,31 @@ G_DEFINE_TYPE (GstGhostPad, gst_ghost_pad, GST_TYPE_PROXY_PAD);
 
 static void gst_ghost_pad_dispose (GObject * object);
 
-/**
- * gst_ghost_pad_internal_activate_push_default:
- * @pad: the #GstPad to activate or deactivate.
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate push function of a proxy pad that is
- * owned by a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_ghost_pad_internal_activate_push_default (GstPad * pad, gboolean active)
+static gboolean
+gst_ghost_pad_internal_activate_push_default (GstPad * pad, GstObject * parent,
+    gboolean active)
 {
   gboolean ret;
   GstPad *other;
 
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
   GST_LOG_OBJECT (pad, "%sactivate push on %s:%s, we're ok",
       (active ? "" : "de"), GST_DEBUG_PAD_NAME (pad));
 
   /* in both cases (SRC and SINK) we activate just the internal pad. The targets
    * will be activated later (or already in case of a ghost sinkpad). */
   other = GST_PROXY_PAD_INTERNAL (pad);
-  ret = gst_pad_activate_push (other, active);
+  ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
 
   return ret;
 }
 
-/**
- * gst_ghost_pad_internal_activate_pull_default:
- * @pad: the #GstPad to activate or deactivate.
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate pull function of a proxy pad that is
- * owned by a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_ghost_pad_internal_activate_pull_default (GstPad * pad, gboolean active)
+static gboolean
+gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
+    gboolean active)
 {
   gboolean ret;
   GstPad *other;
 
-  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
   GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
       GST_DEBUG_PAD_NAME (pad));
 
@@ -747,12 +494,12 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, gboolean active)
      * further upstream */
     GST_LOG_OBJECT (pad, "pad is src, activate internal");
     other = GST_PROXY_PAD_INTERNAL (pad);
-    ret = gst_pad_activate_pull (other, active);
+    ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
   } else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
     /* We are SINK, the ghostpad is SRC, we propagate the activation upstream
      * since we hold a pointer to the upstream peer. */
     GST_LOG_OBJECT (pad, "activating peer");
-    ret = gst_pad_activate_pull (other, active);
+    ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
     gst_object_unref (other);
   } else {
     /* this is failure, we can't activate pull if there is no peer */
@@ -764,18 +511,43 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, gboolean active)
 }
 
 /**
- * gst_ghost_pad_activate_push_default:
+ * gst_ghost_pad_internal_activate_mode_default:
  * @pad: the #GstPad to activate or deactivate.
+ * @parent: the parent of @pad or NULL
+ * @mode: the requested activation mode
  * @active: whether the pad should be active or not.
  *
- * Invoke the default activate push function of a ghost pad.
+ * Invoke the default activate mode function of a proxy pad that is
+ * owned by a ghost pad.
  *
  * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
  */
 gboolean
-gst_ghost_pad_activate_push_default (GstPad * pad, gboolean active)
+gst_ghost_pad_internal_activate_mode_default (GstPad * pad, GstObject * parent,
+    GstPadMode mode, gboolean active)
+{
+  gboolean res;
+
+  g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
+
+  switch (mode) {
+    case GST_PAD_MODE_PULL:
+      res = gst_ghost_pad_internal_activate_pull_default (pad, parent, active);
+      break;
+    case GST_PAD_MODE_PUSH:
+      res = gst_ghost_pad_internal_activate_push_default (pad, parent, active);
+      break;
+    default:
+      GST_LOG_OBJECT (pad, "unknown activation mode %d", mode);
+      res = FALSE;
+      break;
+  }
+  return res;
+}
+
+static gboolean
+gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent,
+    gboolean active)
 {
   gboolean ret;
   GstPad *other;
@@ -787,30 +559,18 @@ gst_ghost_pad_activate_push_default (GstPad * pad, gboolean active)
 
   /* just activate the internal pad */
   other = GST_PROXY_PAD_INTERNAL (pad);
-  ret = gst_pad_activate_push (other, active);
+  ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
 
   return ret;
 }
 
-/**
- * gst_ghost_pad_activate_pull_default:
- * @pad: the #GstPad to activate or deactivate.
- * @active: whether the pad should be active or not.
- *
- * Invoke the default activate pull function of a ghost pad.
- *
- * Returns: %TRUE if the operation was successful.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_ghost_pad_activate_pull_default (GstPad * pad, gboolean active)
+static gboolean
+gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
+    gboolean active)
 {
   gboolean ret;
   GstPad *other;
 
-  g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
-
   GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
       GST_DEBUG_PAD_NAME (pad));
 
@@ -820,12 +580,12 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, gboolean active)
      * upstream */
     GST_LOG_OBJECT (pad, "pad is src, activate internal");
     other = GST_PROXY_PAD_INTERNAL (pad);
-    ret = gst_pad_activate_pull (other, active);
+    ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
   } else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
     /* We are SINK and activated by the internal pad, propagate activation
      * upstream because we hold a ref to the upstream peer */
     GST_LOG_OBJECT (pad, "activating peer");
-    ret = gst_pad_activate_pull (other, active);
+    ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
     gst_object_unref (other);
   } else {
     /* no peer, we fail */
@@ -837,6 +597,40 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, gboolean active)
 }
 
 /**
+ * gst_ghost_pad_activate_mode_default:
+ * @pad: the #GstPad to activate or deactivate.
+ * @parent: the parent of @pad or NULL
+ * @mode: the requested activation mode
+ * @active: whether the pad should be active or not.
+ *
+ * Invoke the default activate mode function of a ghost pad.
+ *
+ * Returns: %TRUE if the operation was successful.
+ */
+gboolean
+gst_ghost_pad_activate_mode_default (GstPad * pad, GstObject * parent,
+    GstPadMode mode, gboolean active)
+{
+  gboolean res;
+
+  g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
+
+  switch (mode) {
+    case GST_PAD_MODE_PULL:
+      res = gst_ghost_pad_activate_pull_default (pad, parent, active);
+      break;
+    case GST_PAD_MODE_PUSH:
+      res = gst_ghost_pad_activate_push_default (pad, parent, active);
+      break;
+    default:
+      GST_LOG_OBJECT (pad, "unknown activation mode %d", mode);
+      res = FALSE;
+      break;
+  }
+  return res;
+}
+
+/**
  * gst_ghost_pad_link_default:
  * @pad: the #GstPad to link.
  * @peer: the #GstPad peer
@@ -887,101 +681,14 @@ gst_ghost_pad_unlink_default (GstPad * pad)
 }
 
 static void
-on_int_notify (GstPad * internal, GParamSpec * unused, GstGhostPad * pad)
-{
-  GstCaps *caps;
-
-  g_object_get (internal, "caps", &caps, NULL);
-
-  GST_DEBUG_OBJECT (pad, "notified %p %" GST_PTR_FORMAT, caps, caps);
-  gst_pad_set_caps (GST_PAD_CAST (pad), caps);
-
-  if (caps)
-    gst_caps_unref (caps);
-}
-
-static void
-on_src_target_notify (GstPad * target, GParamSpec * unused, gpointer user_data)
-{
-  GstProxyPad *proxypad;
-  GstGhostPad *gpad;
-  GstCaps *caps;
-
-  g_object_get (target, "caps", &caps, NULL);
-
-  GST_OBJECT_LOCK (target);
-  /* First check if the peer is still available and our proxy pad */
-  if (!GST_PAD_PEER (target) || !GST_IS_PROXY_PAD (GST_PAD_PEER (target))) {
-    GST_OBJECT_UNLOCK (target);
-    goto done;
-  }
-
-  proxypad = GST_PROXY_PAD (GST_PAD_PEER (target));
-  GST_OBJECT_LOCK (proxypad);
-  /* Now check if the proxypad's internal pad is still there and
-   * a ghostpad */
-  if (!GST_PROXY_PAD_INTERNAL (proxypad) ||
-      !GST_IS_GHOST_PAD (GST_PROXY_PAD_INTERNAL (proxypad))) {
-    GST_OBJECT_UNLOCK (proxypad);
-    GST_OBJECT_UNLOCK (target);
-    goto done;
-  }
-  gpad = GST_GHOST_PAD (GST_PROXY_PAD_INTERNAL (proxypad));
-  g_object_ref (gpad);
-  GST_OBJECT_UNLOCK (proxypad);
-  GST_OBJECT_UNLOCK (target);
-
-  gst_pad_set_caps (GST_PAD_CAST (gpad), caps);
-
-  g_object_unref (gpad);
-
-done:
-  if (caps)
-    gst_caps_unref (caps);
-}
-
-static void
-on_src_target_unlinked (GstPad * pad, GstPad * peer, gpointer user_data)
-{
-  g_signal_handlers_disconnect_by_func (pad,
-      (gpointer) on_src_target_notify, NULL);
-}
-
-/**
- * gst_ghost_pad_setcaps_default:
- * @pad: the #GstPad to link.
- * @caps: (transfer none): the #GstCaps to set
- *
- * Invoke the default setcaps function of a ghost pad.
- *
- * Returns: %TRUE if the operation was successful
- *
- * Since: 0.10.36
- */
-gboolean
-gst_ghost_pad_setcaps_default (GstPad * pad, GstCaps * caps)
-{
-  g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
-  g_return_val_if_fail (caps == NULL || GST_IS_CAPS (caps), FALSE);
-
-  if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
-    return TRUE;
-
-  return gst_proxy_pad_setcaps_default (pad, caps);
-}
-
-static void
 gst_ghost_pad_class_init (GstGhostPadClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
 
   g_type_class_add_private (klass, sizeof (GstGhostPadPrivate));
 
-  pspec_caps = g_object_class_find_property (gobject_class, "caps");
-
   gobject_class->dispose = gst_ghost_pad_dispose;
 
-  GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_setcaps_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_activate_pull_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_activate_push_default);
   GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_link_default);
@@ -993,12 +700,8 @@ gst_ghost_pad_init (GstGhostPad * pad)
   GST_GHOST_PAD_PRIVATE (pad) = G_TYPE_INSTANCE_GET_PRIVATE (pad,
       GST_TYPE_GHOST_PAD, GstGhostPadPrivate);
 
-  gst_pad_set_setcaps_function (GST_PAD_CAST (pad),
-      gst_ghost_pad_setcaps_default);
-  gst_pad_set_activatepull_function (GST_PAD_CAST (pad),
-      gst_ghost_pad_activate_pull_default);
-  gst_pad_set_activatepush_function (GST_PAD_CAST (pad),
-      gst_ghost_pad_activate_push_default);
+  gst_pad_set_activatemode_function (GST_PAD_CAST (pad),
+      gst_ghost_pad_activate_mode_default);
 }
 
 static void
@@ -1029,11 +732,7 @@ gst_ghost_pad_dispose (GObject * object)
   GST_OBJECT_LOCK (pad);
   internal = GST_PROXY_PAD_INTERNAL (pad);
 
-  gst_pad_set_activatepull_function (internal, NULL);
-  gst_pad_set_activatepush_function (internal, NULL);
-
-  g_signal_handler_disconnect (internal,
-      GST_GHOST_PAD_PRIVATE (pad)->notify_id);
+  gst_pad_set_activatemode_function (internal, NULL);
 
   /* disposes of the internal pad, since the ghostpad is the only possible object
    * that has a refcount on the internal pad. */
@@ -1079,13 +778,10 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
 
   /* Set directional padfunctions for ghostpad */
   if (dir == GST_PAD_SINK) {
-    gst_pad_set_bufferalloc_function (pad, gst_proxy_pad_bufferalloc_default);
     gst_pad_set_chain_function (pad, gst_proxy_pad_chain_default);
     gst_pad_set_chain_list_function (pad, gst_proxy_pad_chain_list_default);
   } else {
     gst_pad_set_getrange_function (pad, gst_proxy_pad_getrange_default);
-    gst_pad_set_checkgetrange_function (pad,
-        gst_proxy_pad_checkgetrange_default);
   }
 
   /* link/unlink functions */
@@ -1109,15 +805,11 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
 
   /* Set directional padfunctions for internal pad */
   if (dir == GST_PAD_SRC) {
-    gst_pad_set_bufferalloc_function (internal,
-        gst_proxy_pad_bufferalloc_default);
     gst_pad_set_chain_function (internal, gst_proxy_pad_chain_default);
     gst_pad_set_chain_list_function (internal,
         gst_proxy_pad_chain_list_default);
   } else {
     gst_pad_set_getrange_function (internal, gst_proxy_pad_getrange_default);
-    gst_pad_set_checkgetrange_function (internal,
-        gst_proxy_pad_checkgetrange_default);
   }
 
   GST_OBJECT_LOCK (pad);
@@ -1138,23 +830,12 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
   GST_PROXY_PAD_INTERNAL (pad) = internal;
   GST_PROXY_PAD_INTERNAL (internal) = pad;
 
-  /* could be more general here, iterating over all writable properties...
-   * taking the short road for now tho */
-  GST_GHOST_PAD_PRIVATE (pad)->notify_id =
-      g_signal_connect (internal, "notify::caps", G_CALLBACK (on_int_notify),
-      pad);
-
   /* special activation functions for the internal pad */
-  gst_pad_set_activatepull_function (internal,
-      gst_ghost_pad_internal_activate_pull_default);
-  gst_pad_set_activatepush_function (internal,
-      gst_ghost_pad_internal_activate_push_default);
+  gst_pad_set_activatemode_function (internal,
+      gst_ghost_pad_internal_activate_mode_default);
 
   GST_OBJECT_UNLOCK (pad);
 
-  /* call function to init values of the pad caps */
-  on_int_notify (internal, NULL, GST_GHOST_PAD_CAST (pad));
-
   GST_GHOST_PAD_PRIVATE (gpad)->constructed = TRUE;
   return TRUE;
 
@@ -1236,7 +917,7 @@ gst_ghost_pad_new_no_target (const gchar * name, GstPadDirection dir)
  *
  * Will ref the target.
  *
- * Returns: (transfer full): a new #GstPad, or NULL in case of an error.
+ * Returns: (transfer floating): a new #GstPad, or NULL in case of an error.
  */
 GstPad *
 gst_ghost_pad_new (const gchar * name, GstPad * target)
@@ -1408,13 +1089,6 @@ gst_ghost_pad_set_target (GstGhostPad * gpad, GstPad * newtarget)
   }
 
   if (newtarget) {
-    if (GST_PAD_IS_SRC (newtarget)) {
-      g_signal_connect (newtarget, "notify::caps",
-          G_CALLBACK (on_src_target_notify), NULL);
-      g_signal_connect (newtarget, "unlinked",
-          G_CALLBACK (on_src_target_unlinked), NULL);
-    }
-
     /* and link to internal pad without any checks */
     GST_DEBUG_OBJECT (gpad, "connecting internal pad to target");