caps: avoid using in-place oprations
[platform/upstream/gstreamer.git] / docs / manual / advanced-autoplugging.xml
index 118671c..9186985 100644 (file)
@@ -29,7 +29,7 @@
   </para>
 
   <sect1 id="section-mime">
-    <title>MIME-types as a way to identity streams</title>
+    <title>MIME-types as a way to identify streams</title>
     <para>
       We have previously introduced the concept of capabilities as a way
       for elements (or, rather, pads) to agree on a media type when
       linkend="section-mime-img"/> shows what MIME-type belongs to each
       pad in this pipeline.
     </para>
-    <!-- FIXME: update for ogg/vorbis rather than mp3 -->
+
     <figure float="1" id="section-mime-img">
       <title>The Hello world pipeline with MIME types</title>
       <mediaobject>
         <imageobject>
-          <imagedata fileref="images/mime-world.&image;" format="&IMAGE;"/>
+          <imagedata scale="75" fileref="images/mime-world.&image;" format="&IMAGE;"/>
         </imageobject>
       </mediaobject>
     </figure>
+
     <para>
       Now that we have an idea how &GStreamer; identifies known media
       streams, we can look at methods &GStreamer; uses to setup pipelines
@@ -84,7 +85,7 @@
       concept of typefinding for this. Typefinding is a normal part of a
       pipeline, it will read data for as long as the type of a stream is
       unknown. During this period, it will provide data to all plugins
-      that implement a typefinder. when one of the typefinders recognizes
+      that implement a typefinder. When one of the typefinders recognizes
       the stream, the typefind element will emit a signal and act as a
       passthrough module from that point on. If no type was found, it will
       emit an error and further media processing will stop.
@@ -184,7 +185,7 @@ main (gint   argc,
       gchar *argv[])
 {
   GMainLoop *loop;
-  GstElement *pipeline, *filesrc, *typefind;
+  GstElement *pipeline, *filesrc, *typefind, *fakesink;
   GstBus *bus;
 
   /* init GStreamer */
@@ -209,10 +210,11 @@ main (gint   argc,
   g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
   typefind = gst_element_factory_make ("typefind", "typefinder");
   g_signal_connect (typefind, "have-type", G_CALLBACK (cb_typefound), loop);
+  fakesink = gst_element_factory_make ("fakesink", "sink");
 
   /* setup */
-  gst_bin_add_many (GST_BIN (pipeline), filesrc, typefind, NULL);
-  gst_element_link (filesrc, typefind);
+  gst_bin_add_many (GST_BIN (pipeline), filesrc, typefind, fakesink, NULL);
+  gst_element_link_many (filesrc, typefind, fakesink, NULL);
   gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
   g_main_loop_run (loop);
 
@@ -312,7 +314,7 @@ init_factories (void)
 {
   /* first filter out the interesting element factories */
   factories = gst_registry_feature_filter (
-      gst_registry_get_default (),
+      gst_registry_get (),
       (GstPluginFeatureFilter) cb_feature_filter, FALSE, NULL);
 
   /* sort them according to their ranks */
@@ -331,7 +333,7 @@ init_factories (void)
       which will continue with the above approach.
     </para>
     <programlisting><!-- example-begin dynamic.c c -->
-static void try_to_plug (GstPad *pad, const GstCaps *caps);
+static void try_to_plug (GstPad *pad, GstCaps *caps);
 
 static GstElement *audiosink;
 
@@ -342,7 +344,7 @@ cb_newpad (GstElement *element,
 {
   GstCaps *caps;
 
-  caps = gst_pad_get_caps (pad);
+  caps = gst_pad_query_caps (pad, NULL);
   try_to_plug (pad, caps);
   gst_caps_unref (caps);
 }
@@ -366,7 +368,7 @@ close_link (GstPad      *srcpad,
     gst_bin_add (GST_BIN (pipeline), sinkelement);
     gst_element_set_state (sinkelement, GST_STATE_READY);
   }
-  pad = gst_element_get_pad (sinkelement, padname);
+  pad = gst_element_get_static_pad (sinkelement, padname);
   gst_pad_link (srcpad, pad);
   if (sinkelement != audiosink) {
     gst_element_set_state (sinkelement, GST_STATE_PAUSED);
@@ -386,8 +388,8 @@ close_link (GstPad      *srcpad,
 
     switch (templ->presence) {
       case GST_PAD_ALWAYS: {
-        GstPad *pad = gst_element_get_pad (sinkelement, templ->name_template);
-        GstCaps *caps = gst_pad_get_caps (pad);
+        GstPad *pad = gst_element_get_static_pad (sinkelement, templ->name_template);
+        GstCaps *caps = gst_pad_query_caps (pad, NULL);
 
         /* link */
         try_to_plug (pad, caps);
@@ -411,7 +413,7 @@ close_link (GstPad      *srcpad,
 
 static void
 try_to_plug (GstPad        *pad,
-            const GstCaps *caps)
+            GstCaps       *caps)
 {
   GstObject *parent = GST_OBJECT (GST_OBJECT_PARENT (pad));
   const gchar *mime;
@@ -419,7 +421,7 @@ try_to_plug (GstPad        *pad,
   GstCaps *res, *audiocaps;
 
   /* don't plug if we're already plugged - FIXME: memleak for pad */
-  if (GST_PAD_IS_LINKED (gst_element_get_pad (audiosink, "sink"))) {
+  if (GST_PAD_IS_LINKED (gst_element_get_static_pad (audiosink, "sink"))) {
     g_print ("Omitting link for pad %s:%s because we're already linked\n",
             GST_OBJECT_NAME (parent), GST_OBJECT_NAME (pad));
     return;
@@ -434,7 +436,8 @@ try_to_plug (GstPad        *pad,
   }
 
   /* can it link to the audiopad? */
-  audiocaps = gst_pad_get_caps (gst_element_get_pad (audiosink, "sink"));
+  audiocaps = gst_pad_query_caps (gst_element_get_static_pad (audiosink, "sink"),
+  NULL);
   res = gst_caps_intersect (caps, audiocaps);
   if (res &amp;&amp; !gst_caps_is_empty (res)) {
     g_print ("Found pad to link to audiosink - plugging is now done\n");
@@ -503,7 +506,7 @@ cb_typefound (GstElement *typefind,
   g_free (s);
 
   /* actually plug now */
-  pad = gst_element_get_pad (typefind, "src");
+  pad = gst_element_get_static_pad (typefind, "src");
   try_to_plug (pad, caps);
   gst_object_unref (GST_OBJECT (pad));
 }
@@ -511,7 +514,7 @@ cb_typefound (GstElement *typefind,
     <para>
       By doing all this, we will be able to make a simple autoplugger that
       can automatically setup a pipeline for any media type. In the example
-      below, we will do this for audio only. However, we can also do this
+      above, we did this for audio only. However, we can also do this
       for video to create a player that plays both audio and video.
     </para>
     <!-- example-begin dynamic.c d --><!--
@@ -613,7 +616,8 @@ main (gint   argc,
       shortest-path-finding to make sure the most optimal pipeline is chosen,
       and so on. Basically, the features that you implement in an autoplugger
       depend on what you want to use it for. For full-blown implementations,
-      see the <quote>playbin</quote> and <quote>decodebin</quote> elements.
+      see the <quote>playbin</quote> and <quote>decodebin</quote> elements in
+      <xref linkend="chapter-components"/>.
     </para>
   </sect1>
 </chapter>