The application programmer can create custom bins packed with elements to perform a specific task. This allows you to write an MPEG audio decoder with just the following lines of code:
/* create the mp3player element */ GstElement *mp3player = gst_element_factory_make ("mp3player", "mp3player"); /* set the source mp3 audio file */ g_object_set (G_OBJECT (mp3player), "location", "helloworld.mp3", NULL); /* start playback */ gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_PLAYING); ... /* pause playback */ gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_PAUSED); ... /* stop */ gst_element_set_state (GST_ELEMENT (mp3player), GST_STATE_NULL);
Note that the above code assumes that the mp3player bin derives itself
from a GstThread
, which begins to play as soon
as its state is set to PLAYING. Other bin types may need explicit
iteration. For more information, see Chapter 21.
Custom bins can be created with a plugin or an XML description. You will find more information about creating custom bin in the Plugin Writers Guide (FIXME ref).