Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gstreamer.git] / gst / playback / gsturidecodebin.c
index e0660b5..5fc319e 100644 (file)
@@ -21,7 +21,7 @@
  * SECTION:element-uridecodebin
  *
  * Decodes data from a URI into raw media. It selects a source element that can
- * handle the given #GstURIDecodeBin:uri scheme and connects it to a decodebin2.
+ * handle the given #GstURIDecodeBin:uri scheme and connects it to a decodebin.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -37,6 +37,7 @@
 #include "gstplay-marshal.h"
 #include "gstplay-enum.h"
 #include "gstrawcaps.h"
+#include "gstplayback.h"
 
 #define GST_TYPE_URI_DECODE_BIN \
   (gst_uri_decode_bin_get_type())
@@ -79,7 +80,7 @@ struct _GstURIDecodeBin
   GList *factories;             /* factories we can use for selecting elements */
 
   gchar *uri;
-  guint connection_speed;
+  guint64 connection_speed;
   GstCaps *caps;
   gchar *encoding;
 
@@ -98,7 +99,7 @@ struct _GstURIDecodeBin
   GSList *decodebins;
   GSList *pending_decodebins;
   GHashTable *streams;
-  gint numpads;
+  guint numpads;
 
   /* for dynamic sources */
   guint src_np_sig_id;          /* new-pad signal id */
@@ -136,7 +137,7 @@ struct _GstURIDecodeBinClass
   void (*drained) (GstElement * element);
 };
 
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src%d",
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src_%u",
     GST_PAD_SRC,
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS_ANY);
@@ -192,7 +193,8 @@ enum
 static guint gst_uri_decode_bin_signals[LAST_SIGNAL] = { 0 };
 
 GType gst_uri_decode_bin_get_type (void);
-GST_BOILERPLATE (GstURIDecodeBin, gst_uri_decode_bin, GstBin, GST_TYPE_BIN);
+#define gst_uri_decode_bin_parent_class parent_class
+G_DEFINE_TYPE (GstURIDecodeBin, gst_uri_decode_bin, GST_TYPE_BIN);
 
 static void remove_decoders (GstURIDecodeBin * bin, gboolean force);
 static void gst_uri_decode_bin_set_property (GObject * object, guint prop_id,
@@ -208,19 +210,6 @@ static gboolean gst_uri_decode_bin_query (GstElement * element,
 static GstStateChangeReturn gst_uri_decode_bin_change_state (GstElement *
     element, GstStateChange transition);
 
-static void
-gst_uri_decode_bin_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_static_pad_template (gstelement_class,
-      &srctemplate);
-  gst_element_class_set_details_simple (gstelement_class,
-      "URI Decoder", "Generic/Bin/Decoder",
-      "Autoplug and decode an URI to raw media",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
 static gboolean
 _gst_boolean_accumulator (GSignalInvocationHint * ihint,
     GValue * return_accu, const GValue * handler_return, gpointer dummy)
@@ -377,9 +366,9 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
           GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class, PROP_CONNECTION_SPEED,
-      g_param_spec_uint ("connection-speed", "Connection Speed",
+      g_param_spec_uint64 ("connection-speed", "Connection Speed",
           "Network connection speed in kbps (0 = unknown)",
-          0, G_MAXUINT / 1000, DEFAULT_CONNECTION_SPEED,
+          0, G_MAXUINT64 / 1000, DEFAULT_CONNECTION_SPEED,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class, PROP_CAPS,
@@ -497,8 +486,8 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
    *
    * Returns: #TRUE if you wish uridecodebin to look for elements that can
    * handle the given @caps. If #FALSE, those caps will be considered as
-   * final and the pad will be exposed as such (see 'new-decoded-pad'
-   * signal).
+   * final and the pad will be exposed as such (see 'pad-added' signal of
+   * #GstElement).
    */
   gst_uri_decode_bin_signals[SIGNAL_AUTOPLUG_CONTINUE] =
       g_signal_new ("autoplug-continue", G_TYPE_FROM_CLASS (klass),
@@ -546,8 +535,8 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
    * @caps: The #GstCaps.
    * @factories: A #GValueArray of possible #GstElementFactory to use.
    *
-   * Once decodebin2 has found the possible #GstElementFactory objects to try
-   * for @caps on @pad, this signal is emitted. The purpose of the signal is for
+   * Once decodebin has found the possible #GstElementFactory objects to try
+   * for @caps on @pad, this signal is emited. The purpose of the signal is for
    * the application to perform additional sorting or filtering on the element
    * factory array.
    *
@@ -585,7 +574,7 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
    * those factories, this signal is emitted.
    *
    * The signal handler should return a #GST_TYPE_AUTOPLUG_SELECT_RESULT enum
-   * value indicating what decodebin2 should do next.
+   * value indicating what decodebin should do next.
    *
    * A value of #GST_AUTOPLUG_SELECT_TRY will try to autoplug an element from
    * @factory.
@@ -643,6 +632,13 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
       G_SIGNAL_RUN_LAST, 0, NULL, NULL,
       gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&srctemplate));
+  gst_element_class_set_details_simple (gstelement_class,
+      "URI Decoder", "Generic/Bin/Decoder",
+      "Autoplug and decode an URI to raw media",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstelement_class->query = GST_DEBUG_FUNCPTR (gst_uri_decode_bin_query);
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_uri_decode_bin_change_state);
@@ -659,7 +655,7 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
 }
 
 static void
-gst_uri_decode_bin_init (GstURIDecodeBin * dec, GstURIDecodeBinClass * klass)
+gst_uri_decode_bin_init (GstURIDecodeBin * dec)
 {
   /* first filter out the interesting element factories */
   dec->factories_lock = g_mutex_new ();
@@ -678,7 +674,7 @@ gst_uri_decode_bin_init (GstURIDecodeBin * dec, GstURIDecodeBinClass * klass)
   dec->expose_allstreams = DEFAULT_EXPOSE_ALL_STREAMS;
   dec->ring_buffer_max_size = DEFAULT_RING_BUFFER_MAX_SIZE;
 
-  GST_OBJECT_FLAG_SET (dec, GST_ELEMENT_IS_SOURCE);
+  GST_OBJECT_FLAG_SET (dec, GST_ELEMENT_FLAG_SOURCE);
 }
 
 static void
@@ -736,7 +732,7 @@ gst_uri_decode_bin_set_property (GObject * object, guint prop_id,
       break;
     case PROP_CONNECTION_SPEED:
       GST_OBJECT_LOCK (dec);
-      dec->connection_speed = g_value_get_uint (value) * 1000;
+      dec->connection_speed = g_value_get_uint64 (value) * 1000;
       GST_OBJECT_UNLOCK (dec);
       break;
     case PROP_CAPS:
@@ -792,7 +788,7 @@ gst_uri_decode_bin_get_property (GObject * object, guint prop_id,
       break;
     case PROP_CONNECTION_SPEED:
       GST_OBJECT_LOCK (dec);
-      g_value_set_uint (value, dec->connection_speed / 1000);
+      g_value_set_uint64 (value, dec->connection_speed / 1000);
       GST_OBJECT_UNLOCK (dec);
       break;
     case PROP_CAPS:
@@ -840,8 +836,8 @@ do_async_start (GstURIDecodeBin * dbin)
 
   dbin->async_pending = TRUE;
 
-  message = gst_message_new_async_start (GST_OBJECT_CAST (dbin), FALSE);
-  parent_class->handle_message (GST_BIN_CAST (dbin), message);
+  message = gst_message_new_async_start (GST_OBJECT_CAST (dbin));
+  GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (dbin), message);
 }
 
 static void
@@ -851,8 +847,8 @@ do_async_done (GstURIDecodeBin * dbin)
 
   if (dbin->async_pending) {
     GST_DEBUG_OBJECT (dbin, "posting ASYNC_DONE");
-    message = gst_message_new_async_done (GST_OBJECT_CAST (dbin));
-    parent_class->handle_message (GST_BIN_CAST (dbin), message);
+    message = gst_message_new_async_done (GST_OBJECT_CAST (dbin), FALSE);
+    GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (dbin), message);
 
     dbin->async_pending = FALSE;
   }
@@ -991,10 +987,13 @@ configure_stream_buffering (GstURIDecodeBin * decoder)
   gst_object_unref (queue);
 }
 
-static gboolean
-decoded_pad_event_probe (GstPad * pad, GstEvent * event,
-    GstURIDecodeBin * decoder)
+static GstPadProbeReturn
+decoded_pad_event_probe (GstPad * pad, GstPadProbeInfo * info,
+    gpointer user_data)
 {
+  GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
+  GstURIDecodeBin *decoder = user_data;
+
   GST_LOG_OBJECT (pad, "%s, decoder %p", GST_EVENT_TYPE_NAME (event), decoder);
 
   /* look for a bitrate tag */
@@ -1018,7 +1017,7 @@ decoded_pad_event_probe (GstPad * pad, GstEvent * event,
         if (stream) {
           stream->bitrate = bitrate;
           /* no longer need this probe now */
-          gst_pad_remove_event_probe (pad, stream->probe_id);
+          gst_pad_remove_probe (pad, stream->probe_id);
           /* configure buffer if possible */
           configure_stream_buffering (decoder);
         }
@@ -1030,14 +1029,12 @@ decoded_pad_event_probe (GstPad * pad, GstEvent * event,
   }
 
   /* never drop */
-  return TRUE;
+  return GST_PAD_PROBE_OK;
 }
 
-/* Called by the signal handlers when a decodebin has
- * found a new raw pad.  
- */
+/* Called by the signal handlers when a decodebin has found a new raw pad */
 static void
-new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
+new_decoded_pad_added_cb (GstElement * element, GstPad * pad,
     GstURIDecodeBin * decoder)
 {
   GstPad *newpad;
@@ -1045,11 +1042,10 @@ new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
   gchar *padname;
   GstURIDecodeBinStream *stream;
 
-  GST_DEBUG_OBJECT (element, "new decoded pad, name: <%s>. Last: %d",
-      GST_PAD_NAME (pad), last);
+  GST_DEBUG_OBJECT (element, "new decoded pad, name: <%s>", GST_PAD_NAME (pad));
 
   GST_URI_DECODE_BIN_LOCK (decoder);
-  padname = g_strdup_printf ("src%d", decoder->numpads);
+  padname = g_strdup_printf ("src_%u", decoder->numpads);
   decoder->numpads++;
   GST_URI_DECODE_BIN_UNLOCK (decoder);
 
@@ -1064,8 +1060,8 @@ new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
   /* add event probe to monitor tags */
   stream = g_slice_alloc0 (sizeof (GstURIDecodeBinStream));
   stream->probe_id =
-      gst_pad_add_event_probe (pad, G_CALLBACK (decoded_pad_event_probe),
-      decoder);
+      gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
+      decoded_pad_event_probe, decoder, NULL);
   GST_URI_DECODE_BIN_LOCK (decoder);
   g_hash_table_insert (decoder->streams, pad, stream);
   GST_URI_DECODE_BIN_UNLOCK (decoder);
@@ -1074,10 +1070,13 @@ new_decoded_pad_cb (GstElement * element, GstPad * pad, gboolean last,
   gst_element_add_pad (GST_ELEMENT_CAST (decoder), newpad);
 }
 
-static gboolean
-source_pad_event_probe (GstPad * pad, GstEvent * event,
-    GstURIDecodeBin * decoder)
+static GstPadProbeReturn
+source_pad_event_probe (GstPad * pad, GstPadProbeInfo * info,
+    gpointer user_data)
 {
+  GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
+  GstURIDecodeBin *decoder = user_data;
+
   GST_LOG_OBJECT (pad, "%s, decoder %p", GST_EVENT_TYPE_NAME (event), decoder);
 
   if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
@@ -1087,7 +1086,7 @@ source_pad_event_probe (GstPad * pad, GstEvent * event,
         gst_uri_decode_bin_signals[SIGNAL_DRAINED], 0, NULL);
   }
   /* never drop events */
-  return TRUE;
+  return GST_PAD_PROBE_OK;
 }
 
 /* called when we found a raw pad on the source element. We need to set up a
@@ -1096,9 +1095,10 @@ static void
 expose_decoded_pad (GstElement * element, GstPad * pad,
     GstURIDecodeBin * decoder)
 {
-  gst_pad_add_event_probe (pad, G_CALLBACK (source_pad_event_probe), decoder);
+  gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
+      source_pad_event_probe, decoder, NULL);
 
-  new_decoded_pad_cb (element, pad, FALSE, decoder);
+  new_decoded_pad_added_cb (element, pad, decoder);
 }
 
 static void
@@ -1198,7 +1198,9 @@ static const gchar *download_media[] = {
 static GstElement *
 gen_source_element (GstURIDecodeBin * decoder)
 {
+  GObjectClass *source_class;
   GstElement *source;
+  GParamSpec *pspec;
 
   if (!decoder->uri)
     goto no_uri;
@@ -1223,25 +1225,34 @@ gen_source_element (GstURIDecodeBin * decoder)
   decoder->need_queue = IS_QUEUE_URI (decoder->uri);
   GST_LOG_OBJECT (decoder, "source needs queue: %d", decoder->need_queue);
 
+  source_class = G_OBJECT_GET_CLASS (source);
+
   /* make HTTP sources send extra headers so we get icecast
    * metadata in case the stream is an icecast stream */
   if (!strncmp (decoder->uri, "http://", 7) &&
-      g_object_class_find_property (G_OBJECT_GET_CLASS (source),
-          "iradio-mode")) {
+      g_object_class_find_property (source_class, "iradio-mode")) {
     GST_LOG_OBJECT (decoder, "configuring iradio-mode");
     g_object_set (source, "iradio-mode", TRUE, NULL);
   }
 
-  if (g_object_class_find_property (G_OBJECT_GET_CLASS (source),
-          "connection-speed")) {
-    GST_DEBUG_OBJECT (decoder,
-        "setting connection-speed=%d to source element",
-        decoder->connection_speed / 1000);
-    g_object_set (source, "connection-speed",
-        decoder->connection_speed / 1000, NULL);
+  pspec = g_object_class_find_property (source_class, "connection-speed");
+  if (pspec != NULL) {
+    if (G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_UINT64 ||
+        G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_INT64) {
+      GST_DEBUG_OBJECT (decoder,
+          "setting connection-speed=%" G_GUINT64_FORMAT " on source element %s",
+          decoder->connection_speed / 1000, G_OBJECT_TYPE_NAME (source));
+
+      g_object_set (source, "connection-speed",
+          decoder->connection_speed / 1000, NULL);
+    } else {
+      g_warning ("connection-speed property of '%s' is not a 64-bit int type",
+          G_OBJECT_TYPE_NAME (source));
+    }
   }
-  if (g_object_class_find_property (G_OBJECT_GET_CLASS (source),
-          "subtitle-encoding")) {
+
+  pspec = g_object_class_find_property (source_class, "subtitle-encoding");
+  if (pspec != NULL && G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_STRING) {
     GST_DEBUG_OBJECT (decoder,
         "setting subtitle-encoding=%s to source element", decoder->encoding);
     g_object_set (source, "subtitle-encoding", decoder->encoding, NULL);
@@ -1307,7 +1318,7 @@ has_all_raw_caps (GstPad * pad, GstCaps * rawcaps, gboolean * all_raw)
   gint capssize;
   gboolean res = FALSE;
 
-  caps = gst_pad_get_caps_reffed (pad);
+  caps = gst_pad_query_caps (pad, NULL);
   if (caps == NULL)
     return FALSE;
 
@@ -1373,6 +1384,7 @@ analyse_source (GstURIDecodeBin * decoder, gboolean * is_raw,
   gboolean res = TRUE;
   GstCaps *rawcaps;
   GstPad *pad;
+  GValue item = { 0, };
 
   *have_out = FALSE;
   *is_raw = FALSE;
@@ -1384,7 +1396,7 @@ analyse_source (GstURIDecodeBin * decoder, gboolean * is_raw,
 
   pads_iter = gst_element_iterate_src_pads (decoder->source);
   while (!done) {
-    switch (gst_iterator_next (pads_iter, (gpointer) & pad)) {
+    switch (gst_iterator_next (pads_iter, &item)) {
       case GST_ITERATOR_ERROR:
         res = FALSE;
         /* FALLTROUGH */
@@ -1399,12 +1411,13 @@ analyse_source (GstURIDecodeBin * decoder, gboolean * is_raw,
         gst_iterator_resync (pads_iter);
         break;
       case GST_ITERATOR_OK:
-        /* we now officially have an output pad */
+        pad = g_value_get_object (&item);
+        /* we now officially have an ouput pad */
         *have_out = TRUE;
 
         /* if FALSE, this pad has no caps and we continue with the next pad. */
         if (!has_all_raw_caps (pad, rawcaps, is_raw)) {
-          gst_object_unref (pad);
+          g_value_reset (&item);
           break;
         }
 
@@ -1437,10 +1450,11 @@ analyse_source (GstURIDecodeBin * decoder, gboolean * is_raw,
           }
           expose_decoded_pad (outelem, pad, decoder);
         }
-        gst_object_unref (pad);
+        g_value_reset (&item);
         break;
     }
   }
+  g_value_unset (&item);
   gst_iterator_free (pads_iter);
   gst_caps_unref (rawcaps);
 
@@ -1471,7 +1485,7 @@ no_queue2:
   {
     post_missing_plugin_error (GST_ELEMENT_CAST (decoder), "queue2");
 
-    gst_object_unref (pad);
+    g_value_unset (&item);
     gst_iterator_free (pads_iter);
     gst_caps_unref (rawcaps);
 
@@ -1479,10 +1493,10 @@ no_queue2:
   }
 }
 
-/* Remove all decodebin2 from ourself 
- * If force is FALSE, then the decodebin2 instances will be stored in
+/* Remove all decodebin from ourself
+ * If force is FALSE, then the decodebin instances will be stored in
  * pending_decodebins for re-use later on.
- * If force is TRUE, then all decodebin2 instances will be unreferenced
+ * If force is TRUE, then all decodebin instances will be unreferenced
  * and cleared, including the pending ones. */
 static void
 remove_decoders (GstURIDecodeBin * bin, gboolean force)
@@ -1528,7 +1542,7 @@ remove_decoders (GstURIDecodeBin * bin, gboolean force)
   }
 
   /* Don't loose the SOURCE flag */
-  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_IS_SOURCE);
+  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SOURCE);
 }
 
 static void
@@ -1615,18 +1629,18 @@ make_decoder (GstURIDecodeBin * decoder)
 {
   GstElement *decodebin;
 
-  /* re-use pending decodebin2 */
+  /* re-use pending decodebin */
   if (decoder->pending_decodebins) {
     GSList *first = decoder->pending_decodebins;
-    GST_LOG_OBJECT (decoder, "re-using pending decodebin2");
+    GST_LOG_OBJECT (decoder, "re-using pending decodebin");
     decodebin = (GstElement *) first->data;
     decoder->pending_decodebins =
         g_slist_delete_link (decoder->pending_decodebins, first);
   } else {
-    GST_LOG_OBJECT (decoder, "making new decodebin2");
+    GST_LOG_OBJECT (decoder, "making new decodebin");
 
     /* now create the decoder element */
-    decodebin = gst_element_factory_make ("decodebin2", NULL);
+    decodebin = gst_element_factory_make ("decodebin", NULL);
 
     if (!decodebin)
       goto no_decodebin;
@@ -1652,7 +1666,7 @@ make_decoder (GstURIDecodeBin * decoder)
     /* set up callbacks to create the links between decoded data
      * and video/audio/subtitle rendering/output. */
     g_signal_connect (decodebin,
-        "new-decoded-pad", G_CALLBACK (new_decoded_pad_cb), decoder);
+        "pad-added", G_CALLBACK (new_decoded_pad_added_cb), decoder);
     g_signal_connect (decodebin,
         "pad-removed", G_CALLBACK (pad_removed_cb), decoder);
     g_signal_connect (decodebin, "no-more-pads",
@@ -1704,16 +1718,16 @@ make_decoder (GstURIDecodeBin * decoder)
   /* ERRORS */
 no_decodebin:
   {
-    post_missing_plugin_error (GST_ELEMENT_CAST (decoder), "decodebin2");
+    post_missing_plugin_error (GST_ELEMENT_CAST (decoder), "decodebin");
     GST_ELEMENT_ERROR (decoder, CORE, MISSING_PLUGIN, (NULL),
-        ("No decodebin2 element, check your installation"));
+        ("No decodebin element, check your installation"));
     return NULL;
   }
 no_typefind:
   {
     gst_object_unref (decodebin);
     GST_ELEMENT_ERROR (decoder, CORE, MISSING_PLUGIN, (NULL),
-        ("No typefind element, decodebin2 is unusable, check your installation"));
+        ("No typefind element, decodebin is unusable, check your installation"));
     return NULL;
   }
 }
@@ -1737,11 +1751,11 @@ type_found (GstElement * typefind, guint probability,
   decoder->is_download = IS_DOWNLOAD_MEDIA (media_type) && decoder->download;
   /* only enable download buffering if the upstream duration is known */
   if (decoder->is_download) {
-    GstFormat fmt = GST_FORMAT_BYTES;
     gint64 dur;
 
-    decoder->is_download = (gst_element_query_duration (typefind, &fmt, &dur)
-        && fmt == GST_FORMAT_BYTES && dur != -1);
+    decoder->is_download =
+        (gst_element_query_duration (typefind, GST_FORMAT_BYTES, &dur)
+        && dur != -1);
   }
 
   dec_elem = make_decoder (decoder);
@@ -1823,7 +1837,7 @@ no_decodebin:
 could_not_link:
   {
     GST_ELEMENT_ERROR (decoder, CORE, NEGOTIATION,
-        (NULL), ("Can't link typefind to decodebin2 element"));
+        (NULL), ("Can't link typefind to decodebin element"));
     return;
   }
 no_queue2:
@@ -1835,7 +1849,7 @@ no_queue2:
 
 /* setup a streaming source. This will first plug a typefind element to the
  * source. After we find the type, we decide to plug a queue2 and continue to
- * plug a decodebin2 starting from the found caps */
+ * plug a decodebin starting from the found caps */
 static gboolean
 setup_streaming (GstURIDecodeBin * decoder)
 {
@@ -1877,7 +1891,7 @@ could_not_link:
         (NULL), ("Can't link source to typefind element"));
     gst_bin_remove (GST_BIN_CAST (decoder), typefind);
     /* Don't loose the SOURCE flag */
-    GST_OBJECT_FLAG_SET (decoder, GST_ELEMENT_IS_SOURCE);
+    GST_OBJECT_FLAG_SET (decoder, GST_ELEMENT_FLAG_SOURCE);
     return FALSE;
   }
 }
@@ -1926,7 +1940,7 @@ remove_source (GstURIDecodeBin * bin)
     bin->streams = NULL;
   }
   /* Don't loose the SOURCE flag */
-  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_IS_SOURCE);
+  GST_OBJECT_FLAG_SET (bin, GST_ELEMENT_FLAG_SOURCE);
 }
 
 /* is called when a dynamic source element created a new pad. */
@@ -2139,14 +2153,17 @@ handle_redirect_message (GstURIDecodeBin * dec, GstMessage * msg)
   GList *l_good = NULL, *l_neutral = NULL, *l_bad = NULL;
   GValue new_list = { 0, };
   guint size, i;
+  const GstStructure *structure;
 
   GST_DEBUG_OBJECT (dec, "redirect message: %" GST_PTR_FORMAT, msg);
-  GST_DEBUG_OBJECT (dec, "connection speed: %u", dec->connection_speed);
+  GST_DEBUG_OBJECT (dec, "connection speed: %" G_GUINT64_FORMAT,
+      dec->connection_speed);
 
-  if (dec->connection_speed == 0 || msg->structure == NULL)
+  structure = gst_message_get_structure (msg);
+  if (dec->connection_speed == 0 || structure == NULL)
     return msg;
 
-  locations_list = gst_structure_get_value (msg->structure, "locations");
+  locations_list = gst_structure_get_value (structure, "locations");
   if (locations_list == NULL)
     return msg;
 
@@ -2198,8 +2215,8 @@ handle_redirect_message (GstURIDecodeBin * dec, GstMessage * msg)
 static void
 handle_message (GstBin * bin, GstMessage * msg)
 {
-  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT && msg->structure != NULL
-      && gst_structure_has_name (msg->structure, "redirect")) {
+  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT
+      && gst_message_has_name (msg, "redirect")) {
     /* sort redirect messages based on the connection speed. This simplifies
      * the user of this element as it can in most cases just pick the first item
      * of the sorted list as a good redirection candidate. It can of course
@@ -2236,9 +2253,12 @@ decoder_query_init (GstURIDecodeBin * dec, QueryFold * fold)
 }
 
 static gboolean
-decoder_query_duration_fold (GstPad * item, GValue * ret, QueryFold * fold)
+decoder_query_duration_fold (const GValue * item, GValue * ret,
+    QueryFold * fold)
 {
-  if (gst_pad_query (item, fold->query)) {
+  GstPad *pad = g_value_get_object (item);
+
+  if (gst_pad_query (pad, fold->query)) {
     gint64 duration;
 
     g_value_set_boolean (ret, TRUE);
@@ -2250,7 +2270,6 @@ decoder_query_duration_fold (GstPad * item, GValue * ret, QueryFold * fold)
     if (duration > fold->max)
       fold->max = duration;
   }
-  gst_object_unref (item);
   return TRUE;
 }
 
@@ -2267,9 +2286,12 @@ decoder_query_duration_done (GstURIDecodeBin * dec, QueryFold * fold)
 }
 
 static gboolean
-decoder_query_position_fold (GstPad * item, GValue * ret, QueryFold * fold)
+decoder_query_position_fold (const GValue * item, GValue * ret,
+    QueryFold * fold)
 {
-  if (gst_pad_query (item, fold->query)) {
+  GstPad *pad = g_value_get_object (item);
+
+  if (gst_pad_query (pad, fold->query)) {
     gint64 position;
 
     g_value_set_boolean (ret, TRUE);
@@ -2282,7 +2304,6 @@ decoder_query_position_fold (GstPad * item, GValue * ret, QueryFold * fold)
       fold->max = position;
   }
 
-  gst_object_unref (item);
   return TRUE;
 }
 
@@ -2299,9 +2320,11 @@ decoder_query_position_done (GstURIDecodeBin * dec, QueryFold * fold)
 }
 
 static gboolean
-decoder_query_latency_fold (GstPad * item, GValue * ret, QueryFold * fold)
+decoder_query_latency_fold (const GValue * item, GValue * ret, QueryFold * fold)
 {
-  if (gst_pad_query (item, fold->query)) {
+  GstPad *pad = g_value_get_object (item);
+
+  if (gst_pad_query (pad, fold->query)) {
     GstClockTime min, max;
     gboolean live;
 
@@ -2325,7 +2348,6 @@ decoder_query_latency_fold (GstPad * item, GValue * ret, QueryFold * fold)
       fold->live = live;
   }
 
-  gst_object_unref (item);
   return TRUE;
 }
 
@@ -2343,9 +2365,11 @@ decoder_query_latency_done (GstURIDecodeBin * dec, QueryFold * fold)
 
 /* we are seekable if all srcpads are seekable */
 static gboolean
-decoder_query_seeking_fold (GstPad * item, GValue * ret, QueryFold * fold)
+decoder_query_seeking_fold (const GValue * item, GValue * ret, QueryFold * fold)
 {
-  if (gst_pad_query (item, fold->query)) {
+  GstPad *pad = g_value_get_object (item);
+
+  if (gst_pad_query (pad, fold->query)) {
     gboolean seekable;
 
     g_value_set_boolean (ret, TRUE);
@@ -2356,7 +2380,6 @@ decoder_query_seeking_fold (GstPad * item, GValue * ret, QueryFold * fold)
     if (fold->seekable == TRUE)
       fold->seekable = seekable;
   }
-  gst_object_unref (item);
 
   return TRUE;
 }
@@ -2374,17 +2397,16 @@ decoder_query_seeking_done (GstURIDecodeBin * dec, QueryFold * fold)
 
 /* generic fold, return first valid result */
 static gboolean
-decoder_query_generic_fold (GstPad * item, GValue * ret, QueryFold * fold)
+decoder_query_generic_fold (const GValue * item, GValue * ret, QueryFold * fold)
 {
+  GstPad *pad = g_value_get_object (item);
   gboolean res;
 
-  if ((res = gst_pad_query (item, fold->query))) {
+  if ((res = gst_pad_query (pad, fold->query))) {
     g_value_set_boolean (ret, TRUE);
     GST_DEBUG_OBJECT (item, "answered query %p", fold->query);
   }
 
-  gst_object_unref (item);
-
   /* and stop as soon as we have a valid result */
   return !res;
 }
@@ -2532,38 +2554,12 @@ setup_failed:
   }
 }
 
-gboolean gst_decode_bin_plugin_init (GstPlugin * plugin);
-
-static gboolean
+gboolean
 gst_uri_decode_bin_plugin_init (GstPlugin * plugin)
 {
   GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin_debug, "uridecodebin", 0,
       "URI decoder element");
 
-#ifdef ENABLE_NLS
-  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
-      LOCALEDIR);
-  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
   return gst_element_register (plugin, "uridecodebin", GST_RANK_NONE,
       GST_TYPE_URI_DECODE_BIN);
 }
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  if (!gst_decode_bin_plugin_init (plugin))
-    return FALSE;
-  if (!gst_uri_decode_bin_plugin_init (plugin))
-    return FALSE;
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "uridecodebin",
-    "URI Decoder bin", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
-    GST_PACKAGE_ORIGIN)