X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=docs%2Fmanual%2Fadvanced-autoplugging.xml;h=9186985b90a6d420ad35171137994b071293b838;hb=43abf99a8a064cbe74f110658937088b95d09437;hp=118671ca541bf319f880ff6537c835f5b310ae8c;hpb=fe6deca584d680a16dfdf9b4709ffad0c3cab673;p=platform%2Fupstream%2Fgstreamer.git diff --git a/docs/manual/advanced-autoplugging.xml b/docs/manual/advanced-autoplugging.xml index 118671c..9186985 100644 --- a/docs/manual/advanced-autoplugging.xml +++ b/docs/manual/advanced-autoplugging.xml @@ -29,7 +29,7 @@ - MIME-types as a way to identity streams + MIME-types as a way to identify streams We have previously introduced the concept of capabilities as a way for elements (or, rather, pads) to agree on a media type when @@ -59,15 +59,16 @@ linkend="section-mime-img"/> shows what MIME-type belongs to each pad in this pipeline. - +
The Hello world pipeline with MIME types - +
+ 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. -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 && !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, 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.