Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst-libs / gst / pbutils / gstdiscoverer.c
index c41acee..f38c989 100644 (file)
@@ -409,8 +409,9 @@ gst_discoverer_set_timeout (GstDiscoverer * dc, GstClockTime timeout)
   DISCO_UNLOCK (dc);
 }
 
-static gboolean
-_event_probe (GstPad * pad, GstEvent * event, PrivateStream * ps)
+static GstProbeReturn
+_event_probe (GstPad * pad, GstProbeType type, GstEvent * event,
+    PrivateStream * ps)
 {
   if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
     GstTagList *tl = NULL, *tmp;
@@ -434,7 +435,7 @@ _event_probe (GstPad * pad, GstEvent * event, PrivateStream * ps)
     DISCO_UNLOCK (ps->dc);
   }
 
-  return TRUE;
+  return GST_PROBE_OK;
 }
 
 static void
@@ -468,7 +469,7 @@ uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad,
   g_object_set (ps->sink, "silent", TRUE, NULL);
   g_object_set (ps->queue, "max-size-buffers", 1, "silent", TRUE, NULL);
 
-  caps = gst_pad_get_caps_reffed (pad);
+  caps = gst_pad_get_caps (pad, NULL);
 
   if (gst_caps_can_intersect (caps, subs_caps)) {
     /* Subtitle streams are sparse and don't provide any information - don't
@@ -497,7 +498,8 @@ uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad,
   gst_object_unref (sinkpad);
 
   /* Add an event probe */
-  gst_pad_add_event_probe (pad, G_CALLBACK (_event_probe), ps);
+  gst_pad_add_probe (pad, GST_PROBE_TYPE_EVENT,
+      (GstPadProbeCallback) _event_probe, ps, NULL);
 
   DISCO_LOCK (dc);
   dc->priv->streams = g_list_append (dc->priv->streams, ps);
@@ -582,7 +584,7 @@ collect_stream_information (GstDiscoverer * dc, PrivateStream * ps, guint idx)
   if (!caps) {
     GST_WARNING ("Couldn't get negotiated caps from %s:%s",
         GST_DEBUG_PAD_NAME (ps->pad));
-    caps = gst_pad_get_caps (ps->pad);
+    caps = gst_pad_get_caps (ps->pad, NULL);
   }
   if (caps) {
     GST_DEBUG ("Got caps %" GST_PTR_FORMAT, caps);
@@ -606,9 +608,8 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
   GstCaps *caps;
   GstStructure *caps_st, *tags_st;
   const gchar *name;
-  int tmp, tmp2;
+  int tmp;
   guint utmp;
-  gboolean btmp;
 
   if (!st || !gst_structure_id_has_field (st, _CAPS_QUARK)) {
     GST_WARNING ("Couldn't find caps !");
@@ -616,7 +617,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       return parent;
     else
       return (GstDiscovererStreamInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
   }
 
   gst_structure_id_get (st, _CAPS_QUARK, GST_TYPE_CAPS, &caps, NULL);
@@ -630,7 +631,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       info = (GstDiscovererAudioInfo *) parent;
     else {
       info = (GstDiscovererAudioInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
       info->parent.caps = caps;
     }
 
@@ -665,36 +666,30 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
   } else if (g_str_has_prefix (name, "video/") ||
       g_str_has_prefix (name, "image/")) {
     GstDiscovererVideoInfo *info;
-    GstVideoFormat format;
+    GstVideoInfo vinfo;
 
     if (parent)
       info = (GstDiscovererVideoInfo *) parent;
     else {
       info = (GstDiscovererVideoInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
       info->parent.caps = caps;
     }
 
-    if (gst_video_format_parse_caps (caps, &format, &tmp, &tmp2)) {
-      info->width = (guint) tmp;
-      info->height = (guint) tmp2;
-    }
+    if (gst_video_info_from_caps (&vinfo, caps)) {
+      info->width = (guint) vinfo.width;
+      info->height = (guint) vinfo.height;
 
-    if (gst_structure_get_int (caps_st, "depth", &tmp))
-      info->depth = (guint) tmp;
+      info->depth = (guint) 0;
 
-    if (gst_video_parse_caps_pixel_aspect_ratio (caps, &tmp, &tmp2)) {
-      info->par_num = tmp;
-      info->par_denom = tmp2;
-    }
+      info->par_num = vinfo.par_n;
+      info->par_denom = vinfo.par_d;
 
-    if (gst_video_parse_caps_framerate (caps, &tmp, &tmp2)) {
-      info->framerate_num = tmp;
-      info->framerate_denom = tmp2;
-    }
+      info->framerate_num = vinfo.fps_n;
+      info->framerate_denom = vinfo.fps_d;
 
-    if (gst_video_format_parse_caps_interlaced (caps, &btmp))
-      info->interlaced = btmp;
+      info->interlaced = (vinfo.flags & GST_VIDEO_FLAG_INTERLACED) != 0;
+    }
 
     if (gst_structure_id_has_field (st, _TAGS_QUARK)) {
       gst_structure_id_get (st, _TAGS_QUARK,
@@ -722,7 +717,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       info = parent;
     else {
       info = (GstDiscovererStreamInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
       info->caps = caps;
     }
 
@@ -885,7 +880,7 @@ parse_stream_topology (GstDiscoverer * dc, const GstStructure * topology,
     GST_DEBUG ("next is a list of %d entries", len);
 
     cont = (GstDiscovererContainerInfo *)
-        gst_mini_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO);
+        g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
     cont->parent.caps = caps;
     res = (GstDiscovererStreamInfo *) cont;
 
@@ -989,8 +984,8 @@ discoverer_collect (GstDiscoverer * dc)
           gst_caps_get_structure (dc->priv->current_info->stream_info->caps, 0);
 
       if (g_str_has_prefix (gst_structure_get_name (st), "image/"))
-        ((GstDiscovererVideoInfo *) dc->priv->current_info->
-            stream_info)->is_image = TRUE;
+        ((GstDiscovererVideoInfo *) dc->priv->current_info->stream_info)->
+            is_image = TRUE;
     }
   }
 
@@ -1079,16 +1074,20 @@ handle_message (GstDiscoverer * dc, GstMessage * msg)
 
     case GST_MESSAGE_ELEMENT:
     {
-      GQuark sttype = gst_structure_get_name_id (msg->structure);
+      GQuark sttype;
+      const GstStructure *structure;
+
+      structure = gst_message_get_structure (msg);
+      sttype = gst_structure_get_name_id (structure);
       GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg),
-          "structure %" GST_PTR_FORMAT, msg->structure);
+          "structure %" GST_PTR_FORMAT, structure);
       if (sttype == _MISSING_PLUGIN_QUARK) {
         GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg),
             "Setting result to MISSING_PLUGINS");
         dc->priv->current_info->result = GST_DISCOVERER_MISSING_PLUGINS;
-        dc->priv->current_info->misc = gst_structure_copy (msg->structure);
+        dc->priv->current_info->misc = gst_structure_copy (structure);
       } else if (sttype == _STREAM_TOPOLOGY_QUARK) {
-        dc->priv->current_topology = gst_structure_copy (msg->structure);
+        dc->priv->current_topology = gst_structure_copy (structure);
       }
     }
       break;
@@ -1162,7 +1161,7 @@ _setup_locked (GstDiscoverer * dc)
 
   /* Pop URI off the pending URI list */
   dc->priv->current_info =
-      (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
+      (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
   dc->priv->current_info->uri = (gchar *) dc->priv->pending_uris->data;
   dc->priv->pending_uris =
       g_list_delete_link (dc->priv->pending_uris, dc->priv->pending_uris);