fix some circular includes
[platform/upstream/gstreamer.git] / gst / gstutils.c
index a674e71..21a0b5a 100644 (file)
@@ -25,7 +25,6 @@
  * SECTION:gstutils
  * @short_description: Various utility functions
  *
- * When defining own plugins, use the GST_BOILERPLATE ease gobject creation.
  */
 
 #include "gst_private.h"
@@ -39,6 +38,7 @@
 #include "gstparse.h"
 #include "gstvalue.h"
 #include "gst-i18n-lib.h"
+#include "glib-compat-private.h"
 #include <math.h>
 
 /**
@@ -704,7 +704,7 @@ guint32
 gst_util_seqnum_next (void)
 {
   static gint counter = 0;
-  return g_atomic_int_exchange_and_add (&counter, 1);
+  return G_ATOMIC_INT_ADD (&counter, 1);
 }
 
 /**
@@ -758,7 +758,7 @@ gst_print_pad_caps (GString * buf, gint indent, GstPad * pad)
 {
   GstCaps *caps;
 
-  caps = pad->caps;
+  caps = gst_pad_get_current_caps (pad);
 
   if (!caps) {
     string_append_indent (buf, indent);
@@ -770,6 +770,8 @@ gst_print_pad_caps (GString * buf, gint indent, GstPad * pad)
     s = gst_caps_to_string (caps);
     g_string_append (buf, s);
     g_free (s);
+
+    gst_caps_unref (caps);
   }
 }
 
@@ -1088,6 +1090,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
   GstCaps *templcaps;
   GstPad *foundpad = NULL;
   gboolean done;
+  GValue padptr = { 0, };
 
   g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
   g_return_val_if_fail (GST_IS_PAD (pad), NULL);
@@ -1110,8 +1113,6 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
   }
 
   while (!done) {
-    gpointer padptr;
-
     switch (gst_iterator_next (pads, &padptr)) {
       case GST_ITERATOR_OK:
       {
@@ -1120,7 +1121,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
         GstPad *srcpad;
         GstPad *sinkpad;
 
-        current = GST_PAD (padptr);
+        current = g_value_get_object (&padptr);
 
         GST_CAT_LOG (GST_CAT_ELEMENT_PADS, "examining pad %s:%s",
             GST_DEBUG_PAD_NAME (current));
@@ -1139,7 +1140,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
           gboolean compatible;
 
           /* Now check if the two pads' caps are compatible */
-          temp = gst_pad_get_caps (pad);
+          temp = gst_pad_get_caps (pad, NULL);
           if (caps) {
             intersection = gst_caps_intersect (temp, caps);
             gst_caps_unref (temp);
@@ -1147,7 +1148,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
             intersection = temp;
           }
 
-          temp = gst_pad_get_caps (current);
+          temp = gst_pad_get_caps (current, NULL);
           compatible = gst_caps_can_intersect (temp, intersection);
           gst_caps_unref (temp);
           gst_caps_unref (intersection);
@@ -1158,6 +1159,9 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
                 GST_DEBUG_PAD_NAME (current));
             gst_iterator_free (pads);
 
+            current = gst_object_ref (current);
+            g_value_unset (&padptr);
+
             return current;
           } else {
             GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "incompatible pads");
@@ -1168,7 +1172,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
         }
         GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "unreffing pads");
 
-        gst_object_unref (current);
+        g_value_reset (&padptr);
         if (peer)
           gst_object_unref (peer);
         break;
@@ -1184,6 +1188,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
         break;
     }
   }
+  g_value_unset (&padptr);
   gst_iterator_free (pads);
 
   GST_CAT_DEBUG_OBJECT (GST_CAT_ELEMENT_PADS, element,
@@ -1193,10 +1198,10 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
   /* try to create a new one */
   /* requesting is a little crazy, we need a template. Let's create one */
   /* FIXME: why not gst_pad_get_pad_template (pad); */
-  templcaps = gst_pad_get_caps (pad);
-
+  templcaps = gst_pad_get_caps (pad, NULL);
   templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
       GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
+  gst_caps_unref (templcaps);
 
   foundpad = gst_element_request_compatible_pad (element, templ);
   gst_object_unref (templ);
@@ -1286,9 +1291,13 @@ gst_element_factory_can_accept_all_caps_in_direction (GstElementFactory *
     GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
 
     if (template->direction == direction) {
-      if (gst_caps_is_always_compatible (caps,
-              gst_static_caps_get (&template->static_caps)))
+      GstCaps *templcaps = gst_static_caps_get (&template->static_caps);
+
+      if (gst_caps_is_always_compatible (caps, templcaps)) {
+        gst_caps_unref (templcaps);
         return TRUE;
+      }
+      gst_caps_unref (templcaps);
     }
     templates = g_list_next (templates);
   }
@@ -1311,9 +1320,13 @@ gst_element_factory_can_accept_any_caps_in_direction (GstElementFactory *
     GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
 
     if (template->direction == direction) {
-      if (gst_caps_can_intersect (caps,
-              gst_static_caps_get (&template->static_caps)))
+      GstCaps *templcaps = gst_static_caps_get (&template->static_caps);
+
+      if (gst_caps_can_intersect (caps, templcaps)) {
+        gst_caps_unref (templcaps);
         return TRUE;
+      }
+      gst_caps_unref (templcaps);
     }
     templates = g_list_next (templates);
   }
@@ -1831,8 +1844,11 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname,
           desttempl = (GstPadTemplate *) l->data;
           if (desttempl->presence == GST_PAD_REQUEST &&
               desttempl->direction != srctempl->direction) {
-            if (gst_caps_is_always_compatible (gst_pad_template_get_caps
-                    (srctempl), gst_pad_template_get_caps (desttempl))) {
+            GstCaps *srccaps, *destcaps;
+
+            srccaps = gst_pad_template_get_caps (srctempl);
+            destcaps = gst_pad_template_get_caps (desttempl);
+            if (gst_caps_is_always_compatible (srccaps, destcaps)) {
               srcpad =
                   gst_element_request_pad (src, srctempl,
                   srctempl->name_template, NULL);
@@ -1846,6 +1862,8 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname,
                     GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad));
                 gst_object_unref (srcpad);
                 gst_object_unref (destpad);
+                gst_caps_unref (srccaps);
+                gst_caps_unref (destcaps);
                 return TRUE;
               }
               /* it failed, so we release the request pads */
@@ -1854,6 +1872,8 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname,
               if (destpad)
                 gst_element_release_request_pad (dest, destpad);
             }
+            gst_caps_unref (srccaps);
+            gst_caps_unref (destcaps);
           }
         }
       }
@@ -2164,6 +2184,7 @@ gst_element_unlink (GstElement * src, GstElement * dest)
 {
   GstIterator *pads;
   gboolean done = FALSE;
+  GValue data = { 0, };
 
   g_return_if_fail (GST_IS_ELEMENT (src));
   g_return_if_fail (GST_IS_ELEMENT (dest));
@@ -2173,12 +2194,10 @@ gst_element_unlink (GstElement * src, GstElement * dest)
 
   pads = gst_element_iterate_pads (src);
   while (!done) {
-    gpointer data;
-
     switch (gst_iterator_next (pads, &data)) {
       case GST_ITERATOR_OK:
       {
-        GstPad *pad = GST_PAD_CAST (data);
+        GstPad *pad = g_value_get_object (&data);
 
         if (GST_PAD_IS_SRC (pad)) {
           GstPad *peerpad = gst_pad_get_peer (pad);
@@ -2198,7 +2217,7 @@ gst_element_unlink (GstElement * src, GstElement * dest)
             gst_object_unref (peerpad);
           }
         }
-        gst_object_unref (pad);
+        g_value_reset (&data);
         break;
       }
       case GST_ITERATOR_RESYNC:
@@ -2212,6 +2231,7 @@ gst_element_unlink (GstElement * src, GstElement * dest)
         break;
     }
   }
+  g_value_unset (&data);
   gst_iterator_free (pads);
 }
 
@@ -2366,9 +2386,8 @@ gst_element_seek_simple (GstElement * element, GstFormat format,
  * gst_pad_use_fixed_caps:
  * @pad: the pad to use
  *
- * A helper function you can use that sets the
- * @gst_pad_get_fixed_caps_func as the getcaps function for the
- * pad. This way the function will always return the negotiated caps
+ * A helper function you can use that sets the FIXED_CAPS flag
+ * This way the default getcaps function will always return the negotiated caps
  * or in case the pad is not negotiated, the padtemplate caps.
  *
  * Use this function on a pad that, once gst_pad_set_caps() has been called
@@ -2377,52 +2396,7 @@ gst_element_seek_simple (GstElement * element, GstFormat format,
 void
 gst_pad_use_fixed_caps (GstPad * pad)
 {
-  gst_pad_set_getcaps_function (pad, gst_pad_get_fixed_caps_func);
-}
-
-/**
- * gst_pad_get_fixed_caps_func:
- * @pad: the pad to use
- *
- * A helper function you can use as a GetCaps function that
- * will return the currently negotiated caps or the padtemplate
- * when NULL.
- *
- * Free-function: gst_caps_unref
- *
- * Returns: (transfer full): the currently negotiated caps or the padtemplate.
- */
-GstCaps *
-gst_pad_get_fixed_caps_func (GstPad * pad)
-{
-  GstCaps *result;
-
-  g_return_val_if_fail (GST_IS_PAD (pad), NULL);
-
-  GST_OBJECT_LOCK (pad);
-  if (GST_PAD_CAPS (pad)) {
-    result = GST_PAD_CAPS (pad);
-
-    GST_CAT_DEBUG (GST_CAT_CAPS,
-        "using pad caps %p %" GST_PTR_FORMAT, result, result);
-
-    result = gst_caps_ref (result);
-  } else if (GST_PAD_PAD_TEMPLATE (pad)) {
-    GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
-
-    result = GST_PAD_TEMPLATE_CAPS (templ);
-    GST_CAT_DEBUG (GST_CAT_CAPS,
-        "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
-        result);
-
-    result = gst_caps_ref (result);
-  } else {
-    GST_CAT_DEBUG (GST_CAT_CAPS, "pad has no caps");
-    result = gst_caps_new_empty ();
-  }
-  GST_OBJECT_UNLOCK (pad);
-
-  return result;
+  GST_OBJECT_FLAG_SET (pad, GST_PAD_FIXED_CAPS);
 }
 
 /**
@@ -2459,7 +2433,8 @@ gst_pad_get_parent_element (GstPad * pad)
  * @error: (in): the GError.
  * @debug: (in) (allow-none): an additional debug information string, or NULL
  *
- * A default error function.
+ * A default error function that uses g_printerr() to display the error message
+ * and the optional debug sting..
  *
  * The default handler will simply print the error string using g_print.
  */
@@ -2469,10 +2444,9 @@ gst_object_default_error (GstObject * source, const GError * error,
 {
   gchar *name = gst_object_get_path_string (source);
 
-  /* FIXME 0.11: should change this to g_printerr() */
-  g_print (_("ERROR: from element %s: %s\n"), name, error->message);
+  g_printerr (_("ERROR: from element %s: %s\n"), name, error->message);
   if (debug)
-    g_print (_("Additional debug info:\n%s\n"), debug);
+    g_printerr (_("Additional debug info:\n%s\n"), debug);
 
   g_free (name);
 }
@@ -2724,15 +2698,15 @@ gst_buffer_join (GstBuffer * buf1, GstBuffer * buf2)
   return result;
 }
 
-
 static gboolean
-getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
+getcaps_fold_func (const GValue * vpad, GValue * ret, GstCaps * filter)
 {
+  GstPad *pad = g_value_get_object (vpad);
   gboolean empty = FALSE;
   GstCaps *peercaps, *existing;
 
   existing = g_value_get_pointer (ret);
-  peercaps = gst_pad_peer_get_caps (pad);
+  peercaps = gst_pad_peer_get_caps (pad, filter);
   if (G_LIKELY (peercaps)) {
     GstCaps *intersection = gst_caps_intersect (existing, peercaps);
 
@@ -2742,13 +2716,13 @@ getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
     gst_caps_unref (existing);
     gst_caps_unref (peercaps);
   }
-  gst_object_unref (pad);
   return !empty;
 }
 
 /**
  * gst_pad_proxy_getcaps:
  * @pad: a #GstPad to proxy.
+ * @filter: a #GstCaps filter.
  *
  * Calls gst_pad_get_allowed_caps() for every other pad belonging to the
  * same element as @pad, and returns the intersection of the results.
@@ -2762,7 +2736,7 @@ getcaps_fold_func (GstPad * pad, GValue * ret, GstPad * orig)
  * Returns: (transfer full): the intersection of the other pads' allowed caps.
  */
 GstCaps *
-gst_pad_proxy_getcaps (GstPad * pad)
+gst_pad_proxy_getcaps (GstPad * pad, GstCaps * filter)
 {
   GstElement *element;
   GstCaps *caps, *intersected;
@@ -2793,7 +2767,7 @@ gst_pad_proxy_getcaps (GstPad * pad)
   while (1) {
     res =
         gst_iterator_fold (iter, (GstIteratorFoldFunction) getcaps_fold_func,
-        &ret, pad);
+        &ret, filter);
     switch (res) {
       case GST_ITERATOR_RESYNC:
         /* unref any value stored */
@@ -2851,105 +2825,6 @@ error:
   }
 }
 
-typedef struct
-{
-  GstPad *orig;
-  GstCaps *caps;
-} SetCapsFoldData;
-
-static gboolean
-setcaps_fold_func (GstPad * pad, GValue * ret, SetCapsFoldData * data)
-{
-  gboolean success = TRUE;
-
-  if (pad != data->orig) {
-    success = gst_pad_set_caps (pad, data->caps);
-    g_value_set_boolean (ret, success);
-  }
-  gst_object_unref (pad);
-
-  return success;
-}
-
-/**
- * gst_pad_proxy_setcaps
- * @pad: a #GstPad to proxy from
- * @caps: (transfer none): the #GstCaps to link with
- *
- * Calls gst_pad_set_caps() for every other pad belonging to the
- * same element as @pad.  If gst_pad_set_caps() fails on any pad,
- * the proxy setcaps fails. May be used only during negotiation.
- *
- * Returns: TRUE if sucessful
- */
-gboolean
-gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
-{
-  GstElement *element;
-  GstIterator *iter;
-  GstIteratorResult res;
-  GValue ret = { 0, };
-  SetCapsFoldData data;
-
-  g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
-  g_return_val_if_fail (caps != NULL, FALSE);
-
-  GST_CAT_DEBUG (GST_CAT_PADS, "proxying pad link for %s:%s",
-      GST_DEBUG_PAD_NAME (pad));
-
-  element = gst_pad_get_parent_element (pad);
-  if (element == NULL)
-    return FALSE;
-
-  /* only iterate the pads in the oposite direction */
-  if (GST_PAD_IS_SRC (pad))
-    iter = gst_element_iterate_sink_pads (element);
-  else
-    iter = gst_element_iterate_src_pads (element);
-
-  g_value_init (&ret, G_TYPE_BOOLEAN);
-  g_value_set_boolean (&ret, TRUE);
-  data.orig = pad;
-  data.caps = caps;
-
-  while (1) {
-    res = gst_iterator_fold (iter, (GstIteratorFoldFunction) setcaps_fold_func,
-        &ret, &data);
-
-    switch (res) {
-      case GST_ITERATOR_RESYNC:
-        /* reset return value */
-        g_value_set_boolean (&ret, TRUE);
-        gst_iterator_resync (iter);
-        break;
-      case GST_ITERATOR_DONE:
-        /* all pads iterated, return collected value */
-        goto done;
-      default:
-        /* iterator returned _ERROR or premature end with _OK,
-         * mark an error and exit */
-        goto error;
-    }
-  }
-done:
-  gst_iterator_free (iter);
-
-  gst_object_unref (element);
-
-  /* ok not to unset the gvalue */
-  return g_value_get_boolean (&ret);
-
-  /* ERRORS */
-error:
-  {
-    g_warning ("Pad list return error on element %s",
-        GST_ELEMENT_NAME (element));
-    gst_iterator_free (iter);
-    gst_object_unref (element);
-    return FALSE;
-  }
-}
-
 /**
  * gst_pad_query_position:
  * @pad: a #GstPad to invoke the position query on.
@@ -3154,291 +3029,6 @@ gst_pad_query_peer_convert (GstPad * pad, GstFormat src_format, gint64 src_val,
 }
 
 /**
- * gst_pad_add_data_probe:
- * @pad: pad to add the data probe handler to
- * @handler: function to call when data is passed over pad
- * @data: (closure): data to pass along with the handler
- *
- * Adds a "data probe" to a pad. This function will be called whenever data
- * passes through a pad. In this case data means both events and buffers. The
- * probe will be called with the data as an argument, meaning @handler should
- * have the same callback signature as the #GstPad::have-data signal.
- * Note that the data will have a reference count greater than 1, so it will
- * be immutable -- you must not change it.
- *
- * For source pads, the probe will be called after the blocking function, if any
- * (see gst_pad_set_blocked_async()), but before looking up the peer to chain
- * to. For sink pads, the probe function will be called before configuring the
- * sink with new caps, if any, and before calling the pad's chain function.
- *
- * Your data probe should return TRUE to let the data continue to flow, or FALSE
- * to drop it. Dropping data is rarely useful, but occasionally comes in handy
- * with events.
- *
- * Although probes are implemented internally by connecting @handler to the
- * have-data signal on the pad, if you want to remove a probe it is insufficient
- * to only call g_signal_handler_disconnect on the returned handler id. To
- * remove a probe, use the appropriate function, such as
- * gst_pad_remove_data_probe().
- *
- * Returns: The handler id.
- */
-gulong
-gst_pad_add_data_probe (GstPad * pad, GCallback handler, gpointer data)
-{
-  return gst_pad_add_data_probe_full (pad, handler, data, NULL);
-}
-
-/**
- * gst_pad_add_data_probe_full:
- * @pad: pad to add the data probe handler to
- * @handler: function to call when data is passed over pad
- * @data: (closure): data to pass along with the handler
- * @notify: (allow-none): function to call when the probe is disconnected,
- *     or NULL
- *
- * Adds a "data probe" to a pad. This function will be called whenever data
- * passes through a pad. In this case data means both events and buffers. The
- * probe will be called with the data as an argument, meaning @handler should
- * have the same callback signature as the #GstPad::have-data signal.
- * Note that the data will have a reference count greater than 1, so it will
- * be immutable -- you must not change it.
- *
- * For source pads, the probe will be called after the blocking function, if any
- * (see gst_pad_set_blocked_async()), but before looking up the peer to chain
- * to. For sink pads, the probe function will be called before configuring the
- * sink with new caps, if any, and before calling the pad's chain function.
- *
- * Your data probe should return TRUE to let the data continue to flow, or FALSE
- * to drop it. Dropping data is rarely useful, but occasionally comes in handy
- * with events.
- *
- * Although probes are implemented internally by connecting @handler to the
- * have-data signal on the pad, if you want to remove a probe it is insufficient
- * to only call g_signal_handler_disconnect on the returned handler id. To
- * remove a probe, use the appropriate function, such as
- * gst_pad_remove_data_probe().
- *
- * The @notify function is called when the probe is disconnected and usually
- * used to free @data.
- *
- * Returns: The handler id.
- *
- * Since: 0.10.20
- */
-gulong
-gst_pad_add_data_probe_full (GstPad * pad, GCallback handler,
-    gpointer data, GDestroyNotify notify)
-{
-  gulong sigid;
-
-  g_return_val_if_fail (GST_IS_PAD (pad), 0);
-  g_return_val_if_fail (handler != NULL, 0);
-
-  GST_OBJECT_LOCK (pad);
-
-  /* we only expose a GDestroyNotify in our API because that's less confusing */
-  sigid = g_signal_connect_data (pad, "have-data", handler, data,
-      (GClosureNotify) notify, 0);
-
-  GST_PAD_DO_EVENT_SIGNALS (pad)++;
-  GST_PAD_DO_BUFFER_SIGNALS (pad)++;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
-      "adding data probe, now %d data, %d event probes",
-      GST_PAD_DO_BUFFER_SIGNALS (pad), GST_PAD_DO_EVENT_SIGNALS (pad));
-  _priv_gst_pad_invalidate_cache (pad);
-  GST_OBJECT_UNLOCK (pad);
-
-  return sigid;
-}
-
-/**
- * gst_pad_add_event_probe:
- * @pad: pad to add the event probe handler to
- * @handler: function to call when events are passed over pad
- * @data: (closure): data to pass along with the handler
- *
- * Adds a probe that will be called for all events passing through a pad. See
- * gst_pad_add_data_probe() for more information.
- *
- * Returns: The handler id
- */
-gulong
-gst_pad_add_event_probe (GstPad * pad, GCallback handler, gpointer data)
-{
-  return gst_pad_add_event_probe_full (pad, handler, data, NULL);
-}
-
-/**
- * gst_pad_add_event_probe_full:
- * @pad: pad to add the event probe handler to
- * @handler: function to call when events are passed over pad
- * @data: (closure): data to pass along with the handler, or NULL
- * @notify: (allow-none): function to call when probe is disconnected, or NULL
- *
- * Adds a probe that will be called for all events passing through a pad. See
- * gst_pad_add_data_probe() for more information.
- *
- * The @notify function is called when the probe is disconnected and usually
- * used to free @data.
- *
- * Returns: The handler id
- *
- * Since: 0.10.20
- */
-gulong
-gst_pad_add_event_probe_full (GstPad * pad, GCallback handler,
-    gpointer data, GDestroyNotify notify)
-{
-  gulong sigid;
-
-  g_return_val_if_fail (GST_IS_PAD (pad), 0);
-  g_return_val_if_fail (handler != NULL, 0);
-
-  GST_OBJECT_LOCK (pad);
-
-  /* we only expose a GDestroyNotify in our API because that's less confusing */
-  sigid = g_signal_connect_data (pad, "have-data::event", handler, data,
-      (GClosureNotify) notify, 0);
-
-  GST_PAD_DO_EVENT_SIGNALS (pad)++;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "adding event probe, now %d probes",
-      GST_PAD_DO_EVENT_SIGNALS (pad));
-  _priv_gst_pad_invalidate_cache (pad);
-  GST_OBJECT_UNLOCK (pad);
-
-  return sigid;
-}
-
-/**
- * gst_pad_add_buffer_probe:
- * @pad: pad to add the buffer probe handler to
- * @handler: function to call when buffers are passed over pad
- * @data: (closure): data to pass along with the handler
- *
- * Adds a probe that will be called for all buffers passing through a pad. See
- * gst_pad_add_data_probe() for more information.
- *
- * Returns: The handler id
- */
-gulong
-gst_pad_add_buffer_probe (GstPad * pad, GCallback handler, gpointer data)
-{
-  return gst_pad_add_buffer_probe_full (pad, handler, data, NULL);
-}
-
-/**
- * gst_pad_add_buffer_probe_full:
- * @pad: pad to add the buffer probe handler to
- * @handler: function to call when buffer are passed over pad
- * @data: (closure): data to pass along with the handler
- * @notify: (allow-none): function to call when the probe is disconnected,
- *     or NULL
- *
- * Adds a probe that will be called for all buffers passing through a pad. See
- * gst_pad_add_data_probe() for more information.
- *
- * The @notify function is called when the probe is disconnected and usually
- * used to free @data.
- *
- * Returns: The handler id
- *
- * Since: 0.10.20
- */
-gulong
-gst_pad_add_buffer_probe_full (GstPad * pad, GCallback handler,
-    gpointer data, GDestroyNotify notify)
-{
-  gulong sigid;
-
-  g_return_val_if_fail (GST_IS_PAD (pad), 0);
-  g_return_val_if_fail (handler != NULL, 0);
-
-  GST_OBJECT_LOCK (pad);
-
-  /* we only expose a GDestroyNotify in our API because that's less confusing */
-  sigid = g_signal_connect_data (pad, "have-data::buffer", handler, data,
-      (GClosureNotify) notify, 0);
-
-  GST_PAD_DO_BUFFER_SIGNALS (pad)++;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "adding buffer probe, now %d probes",
-      GST_PAD_DO_BUFFER_SIGNALS (pad));
-  _priv_gst_pad_invalidate_cache (pad);
-  GST_OBJECT_UNLOCK (pad);
-
-  return sigid;
-}
-
-/**
- * gst_pad_remove_data_probe:
- * @pad: pad to remove the data probe handler from
- * @handler_id: handler id returned from gst_pad_add_data_probe
- *
- * Removes a data probe from @pad.
- */
-void
-gst_pad_remove_data_probe (GstPad * pad, guint handler_id)
-{
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (handler_id > 0);
-
-  GST_OBJECT_LOCK (pad);
-  g_signal_handler_disconnect (pad, handler_id);
-  GST_PAD_DO_BUFFER_SIGNALS (pad)--;
-  GST_PAD_DO_EVENT_SIGNALS (pad)--;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
-      "removed data probe, now %d event, %d buffer probes",
-      GST_PAD_DO_EVENT_SIGNALS (pad), GST_PAD_DO_BUFFER_SIGNALS (pad));
-  GST_OBJECT_UNLOCK (pad);
-
-}
-
-/**
- * gst_pad_remove_event_probe:
- * @pad: pad to remove the event probe handler from
- * @handler_id: handler id returned from gst_pad_add_event_probe
- *
- * Removes an event probe from @pad.
- */
-void
-gst_pad_remove_event_probe (GstPad * pad, guint handler_id)
-{
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (handler_id > 0);
-
-  GST_OBJECT_LOCK (pad);
-  g_signal_handler_disconnect (pad, handler_id);
-  GST_PAD_DO_EVENT_SIGNALS (pad)--;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
-      "removed event probe, now %d event probes",
-      GST_PAD_DO_EVENT_SIGNALS (pad));
-  GST_OBJECT_UNLOCK (pad);
-}
-
-/**
- * gst_pad_remove_buffer_probe:
- * @pad: pad to remove the buffer probe handler from
- * @handler_id: handler id returned from gst_pad_add_buffer_probe
- *
- * Removes a buffer probe from @pad.
- */
-void
-gst_pad_remove_buffer_probe (GstPad * pad, guint handler_id)
-{
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (handler_id > 0);
-
-  GST_OBJECT_LOCK (pad);
-  g_signal_handler_disconnect (pad, handler_id);
-  GST_PAD_DO_BUFFER_SIGNALS (pad)--;
-  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
-      "removed buffer probe, now %d buffer probes",
-      GST_PAD_DO_BUFFER_SIGNALS (pad));
-  GST_OBJECT_UNLOCK (pad);
-
-}
-
-/**
  * gst_element_found_tags_for_pad:
  * @element: element for which to post taglist to bus.
  * @pad: (transfer none): pad on which to push tag-event
@@ -3465,11 +3055,11 @@ gst_element_found_tags_for_pad (GstElement * element,
 }
 
 static void
-push_and_ref (GstPad * pad, GstEvent * event)
+push_and_ref (const GValue * vpad, GstEvent * event)
 {
+  GstPad *pad = g_value_get_object (vpad);
+
   gst_pad_push_event (pad, gst_event_ref (event));
-  /* iterator refs pad, we unref when we are done with it */
-  gst_object_unref (pad);
 }
 
 /**
@@ -3494,7 +3084,7 @@ gst_element_found_tags (GstElement * element, GstTagList * list)
 
   iter = gst_element_iterate_src_pads (element);
   event = gst_event_new_tag (gst_tag_list_copy (list));
-  gst_iterator_foreach (iter, (GFunc) push_and_ref, event);
+  gst_iterator_foreach (iter, (GstIteratorForeachFunction) push_and_ref, event);
   gst_iterator_free (iter);
   gst_event_unref (event);
 
@@ -3508,6 +3098,7 @@ element_find_unlinked_pad (GstElement * element, GstPadDirection direction)
   GstIterator *iter;
   GstPad *unlinked_pad = NULL;
   gboolean done;
+  GValue data = { 0, };
 
   switch (direction) {
     case GST_PAD_SRC:
@@ -3522,26 +3113,25 @@ element_find_unlinked_pad (GstElement * element, GstPadDirection direction)
 
   done = FALSE;
   while (!done) {
-    gpointer pad;
-
-    switch (gst_iterator_next (iter, &pad)) {
+    switch (gst_iterator_next (iter, &data)) {
       case GST_ITERATOR_OK:{
         GstPad *peer;
+        GstPad *pad = g_value_get_object (&data);
 
         GST_CAT_LOG (GST_CAT_ELEMENT_PADS, "examining pad %s:%s",
             GST_DEBUG_PAD_NAME (pad));
 
-        peer = gst_pad_get_peer (GST_PAD (pad));
+        peer = gst_pad_get_peer (pad);
         if (peer == NULL) {
-          unlinked_pad = pad;
+          unlinked_pad = gst_object_ref (pad);
           done = TRUE;
           GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
               "found existing unlinked pad %s:%s",
               GST_DEBUG_PAD_NAME (unlinked_pad));
         } else {
-          gst_object_unref (pad);
           gst_object_unref (peer);
         }
+        g_value_reset (&data);
         break;
       }
       case GST_ITERATOR_DONE:
@@ -3555,7 +3145,7 @@ element_find_unlinked_pad (GstElement * element, GstPadDirection direction)
         break;
     }
   }
-
+  g_value_unset (&data);
   gst_iterator_free (iter);
 
   return unlinked_pad;
@@ -3582,6 +3172,7 @@ gst_bin_find_unlinked_pad (GstBin * bin, GstPadDirection direction)
   GstIterator *iter;
   gboolean done;
   GstPad *pad = NULL;
+  GValue data = { 0, };
 
   g_return_val_if_fail (GST_IS_BIN (bin), NULL);
   g_return_val_if_fail (direction != GST_PAD_UNKNOWN, NULL);
@@ -3589,15 +3180,16 @@ gst_bin_find_unlinked_pad (GstBin * bin, GstPadDirection direction)
   done = FALSE;
   iter = gst_bin_iterate_recurse (bin);
   while (!done) {
-    gpointer element;
+    switch (gst_iterator_next (iter, &data)) {
+      case GST_ITERATOR_OK:{
+        GstElement *element = g_value_get_object (&data);
 
-    switch (gst_iterator_next (iter, &element)) {
-      case GST_ITERATOR_OK:
-        pad = element_find_unlinked_pad (GST_ELEMENT (element), direction);
-        gst_object_unref (element);
+        pad = element_find_unlinked_pad (element, direction);
         if (pad != NULL)
           done = TRUE;
+        g_value_reset (&data);
         break;
+      }
       case GST_ITERATOR_DONE:
         done = TRUE;
         break;
@@ -3609,7 +3201,7 @@ gst_bin_find_unlinked_pad (GstBin * bin, GstPadDirection direction)
         break;
     }
   }
-
+  g_value_unset (&data);
   gst_iterator_free (iter);
 
   return pad;
@@ -3641,7 +3233,7 @@ gst_parse_bin_from_description (const gchar * bin_description,
     gboolean ghost_unlinked_pads, GError ** err)
 {
   return gst_parse_bin_from_description_full (bin_description,
-      ghost_unlinked_pads, NULL, 0, err);
+      ghost_unlinked_pads, NULL, GST_PARSE_FLAG_NONE, err);
 }
 
 /**
@@ -3821,7 +3413,7 @@ gst_util_get_timestamp (void)
  * @array: the sorted input array
  * @num_elements: number of elements in the array
  * @element_size: size of every element in bytes
- * @search_func: function to compare two elements, @search_data will always be passed as second argument
+ * @search_func: (scope call): function to compare two elements, @search_data will always be passed as second argument
  * @mode: search mode that should be used
  * @search_data: element that should be found
  * @user_data: (closure): data to pass to @search_func
@@ -3834,7 +3426,7 @@ gst_util_get_timestamp (void)
  *
  * The complexity of this search function is O(log (num_elements)).
  *
- * Returns: The address of the found element or %NULL if nothing was found
+ * Returns: (transfer none): The address of the found element or %NULL if nothing was found
  *
  * Since: 0.10.23
  */
@@ -3939,7 +3531,7 @@ gst_util_greatest_common_divisor (gint a, gint b)
  * @src_d: Fraction denominator #gint
  * @dest: (out): pointer to a #gdouble for the result
  *
- * Transforms a #gdouble to a fraction and simplifies the result.
+ * Transforms a fraction to a #gdouble.
  *
  * Since: 0.10.26
  */