caps: small doc improvement
[platform/upstream/gstreamer.git] / gst / gstghostpad.c
index 6b7fcf4..953704b 100644 (file)
@@ -69,6 +69,7 @@ static GstPad *gst_proxy_pad_get_target (GstPad * pad);
 /**
  * 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.
@@ -78,7 +79,7 @@ static GstPad *gst_proxy_pad_get_target (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;
   GstPad *internal;
@@ -234,6 +235,7 @@ gst_proxy_pad_query_default (GstPad * pad, GstObject * parent, GstQuery * query)
 /**
  * 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.
  *
@@ -243,7 +245,7 @@ gst_proxy_pad_query_default (GstPad * pad, GstObject * parent, 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;
@@ -263,6 +265,7 @@ gst_proxy_pad_iterate_internal_links_default (GstPad * pad)
 /**
  * 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.
  *
@@ -273,7 +276,8 @@ gst_proxy_pad_iterate_internal_links_default (GstPad * pad)
  * 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;
@@ -290,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.
  *
@@ -300,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;
@@ -329,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;
@@ -452,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));
 
@@ -514,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 */
@@ -531,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;
@@ -554,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));
 
@@ -587,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 */
@@ -604,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
@@ -673,10 +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_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
@@ -707,8 +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);
+  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. */
@@ -807,10 +831,8 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
   GST_PROXY_PAD_INTERNAL (internal) = 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);
 
@@ -895,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)