Element states
Once you have created a pipeline packed with elements, nothing will happen
right away. This is where the different states come into play.
The different element states
An element can be in one of the following four states:
NULL: this is the default state all elements are in when they are created
and are doing nothing.
READY: An element is ready to start doing something.
PAUSED: The element is paused for a period of time.
PLAYING: The element is doing something.
All elements start with the NULL state. The elements will go throught
the following state changes: NULL -> READY -> PAUSED ->
PLAYING. When going from NULL to PLAYING, GStreamer will
internally go throught the intermediate states.
The state of an element can be changed with the following code:
GstElement *bin;
// create a bin, put elements in it and link them
...
gst_element_set_state (bin, GST_STATE_PLAYING);
...
You can set the following states on an element:
GST_STATE_NULL
Reset the state of an element.
GST_STATE_READY
will make the element ready to start processing data.
GST_STATE_PAUSED
temporary stops the data flow.
GST_STATE_PLAYING
means there really is data flowing through the graph.
The NULL state
When you created the pipeline all of the elements will be in the NULL state. There is
nothing special about the NULL state.
Don't forget to reset the pipeline to the NULL state when you are not going to use it
anymore. This will allow the elements to free the resources they might use.
The READY state
You will start the pipeline by first setting it to the READY state. This will allow the
pipeline and all the elements contained in it to prepare themselves for the actions
they are about to perform.
The typical actions that an element will perform in the READY state might be to open a file or
an audio device. Some more complex elements might have a non trivial action to perform in
the READY state such as connecting to a media server using a CORBA connection.
You can also go from the NULL to PLAYING state directly without
going through the READY state. This is a shortcut; the framework
will internally go through the READY and the PAUSED state for you.
The PAUSED state
A pipeline that is playing can be set to the PAUSED state. This will temporarily stop all
data flowing through the pipeline.
You can resume the data flow by setting the pipeline back to the PLAYING state.
The PAUSED state is available for temporarily freezing the pipeline.
Elements will typically not free their resources in the PAUSED state.
Use the NULL state if you want to stop the data flow permanently.
The pipeline has to be in the PAUSED or NULL state if you want to insert or modify an element
in the pipeline. We will cover dynamic pipeline behaviour in .
The PLAYING state
A Pipeline that is in the READY state can be started by setting it to the PLAYING state. At
that time data will start to flow all the way through the pipeline.