Understanding Bins and Ghost_pads

Tim-Philipp Müller t.i.m at zen.co.uk
Mon Dec 17 04:13:06 PST 2012


On Sat, 2012-12-15 at 14:47 +0000, Ian Davidson wrote:

Hi,

> I have compiled the helloWorld example from the GStreamer
> documentation and it worked.

(Our Hello World should really just be a playbin example..)


>   ghostsrc = gst_element_factory_make ("fakesrc",       "ghostsrc");
>   ghostsink =gst_element_factory_make ("fakesink",      "ghostsink");
> 
> ...
>   /* we add all elements into the pipeline */
>   /* file-source | ogg-demuxer | vorbis-decoder | converter |
> alsa-output */
>   g_print ("Step 1...\n");
>   gst_bin_add_many (GST_BIN (bin1),
>                     source, demuxer, decoder, ghostsrc, NULL);
>   g_print ("Step 2...\n"); 
>   pad1 = gst_element_get_static_pad (ghostsrc, "ghostsrc");

I think there's some confusion here about the strings/names passed to
pad function and gst_element_factory_make(), which also came through in
your other post about the documentation, where "sink" is used both as an
element name for the fakesink element created, and to retrieve the
"sink" pad from that same fakesink. Both "sink" strings have no
connection though.

gst-inspect-1.0 fakesrc

will show you which pads are available:

Pads:
  SRC: 'src'
    Implementation:
      Has getrangefunc(): gst_base_src_getrange
      Has custom eventfunc(): gst_base_src_event
      Has custom queryfunc(): gst_base_src_query
      Has custom iterintlinkfunc():
gst_pad_iterate_internal_links_default
    Pad Template: 'src'

That's what you need to pass to _get_static_pad(). ("src").

Cheers
 -Tim


>   g_print ("Step 2a...\n"); 
>   gst_element_add_pad (bin1, gst_ghost_pad_new ("ghostsrc", pad1));
>   g_print ("Step 2b...\n"); 
>   gst_object_unref (GST_OBJECT (pad1));
>   g_print ("Step 3...\n");
>   gst_bin_add_many (GST_BIN (bin2),
>                     ghostsink, conv, sink, NULL);
>   g_print ("Step 4...\n");   
>   pad2 = gst_element_get_static_pad (ghostsink, "ghostsink");
>   g_print ("Step 4a...\n"); 
>   gst_element_add_pad (bin2, gst_ghost_pad_new ("ghostsink", pad2));
>   g_print ("Step 4b...\n"); 
>   gst_object_unref (GST_OBJECT (pad2));   
>   g_print ("Step 5...\n");
>   gst_bin_add_many (GST_BIN (pipeline), bin1, bin2, NULL);
> 
>   /* we link the elements together */
>   /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter ->
> alsa-output */
>   g_print ("Step 6...\n");
>   gst_element_link (source, demuxer);
>   g_print ("Step 7...\n");
>   gst_element_link_many (conv, sink, NULL);
>   g_print ("Step 8...\n");
>   gst_element_link (bin1, bin2);
>   g_print ("Step 9...\n");
>   g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added),
> decoder);
> 
>   /* note that the demuxer will be linked to the decoder dynamically.
>      The reason is that Ogg may contain various streams (for example
>      audio and video). The source pad(s) will be created at run time,
>      by the demuxer when it detects the amount and nature of streams.
>      Therefore we connect a callback function which will be executed
>      when the "pad-added" is emitted.*/
> 
> 
>   /* Set the pipeline to "playing" state*/
>   g_print ("Now playing: %s\n", argv[1]);
>   gst_element_set_state (pipeline, GST_STATE_PLAYING);
> 
> 
>   /* Iterate */
>   g_print ("Running...\n");
>   g_main_loop_run (loop);
> 
> 
>   /* Out of the main loop, clean up nicely */
>   g_print ("Returned, stopping playback\n");
>   gst_element_set_state (pipeline, GST_STATE_NULL);
> 
>   g_print ("Deleting pipeline\n");
>   gst_object_unref (GST_OBJECT (pipeline));
>   g_source_remove (bus_watch_id);
>   g_main_loop_unref (loop);
> 
>   return 0;
> }
> 
> 
> 
> 
> 
> -- 
> --
> Ian Davidson
> --
> Facts used in this message may or may not reflect an underlying
> objective reality. Facts are supplied for personal use only.
> Recipients quoting supplied information do so at their own risk. Facts
> supplied may vary in whole or part from widely accepted standards.
> While painstakingly researched, facts may or may not be indicative of
> actually occurring events or natural phenomena.
> The author accepts no responsibility for personal loss or injury
> resulting from memorisation and subsequent use. 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




More information about the gstreamer-devel mailing list