2004-01-28 15:08:17 +00:00
|
|
|
<chapter id="chapter-states">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>Element states</title>
|
|
|
|
<para>
|
2002-09-14 14:13:34 +00:00
|
|
|
Once you have created a pipeline packed with elements, nothing will happen
|
|
|
|
right away. This is where the different states come into play.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-states">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>The different element states</title>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
An element can be in one of the following four states:
|
2000-08-16 21:38:57 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
NULL: this is the default state all elements are in when they are created
|
|
|
|
and are doing nothing.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
READY: An element is ready to start doing something.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2001-06-15 21:46:57 +00:00
|
|
|
PAUSED: The element is paused for a period of time.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2001-06-15 21:46:57 +00:00
|
|
|
PLAYING: The element is doing something.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
All elements start with the NULL state. The elements will go throught
|
|
|
|
the following state changes: NULL -> READY -> PAUSED ->
|
2003-10-09 12:42:49 +00:00
|
|
|
PLAYING. When going from NULL to PLAYING, GStreamer will
|
2002-09-08 21:17:16 +00:00
|
|
|
internally go throught the intermediate states.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
2001-01-08 22:08:40 +00:00
|
|
|
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
You can set the following states on an element:
|
2001-01-08 22:08:40 +00:00
|
|
|
</para>
|
2001-12-15 23:13:04 +00:00
|
|
|
<informaltable pgwide="1" frame="none" role="enum">
|
2001-01-08 22:08:40 +00:00
|
|
|
<tgroup cols="2">
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry><literal>GST_STATE_NULL</literal></entry>
|
|
|
|
<entry>Reset the state of an element.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><literal>GST_STATE_READY</literal></entry>
|
|
|
|
<entry>will make the element ready to start processing data.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2001-06-15 21:46:57 +00:00
|
|
|
<entry><literal>GST_STATE_PAUSED</literal></entry>
|
|
|
|
<entry>temporary stops the data flow.
|
2001-01-08 22:08:40 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2001-06-15 21:46:57 +00:00
|
|
|
<entry><literal>GST_STATE_PLAYING</literal></entry>
|
|
|
|
<entry>means there really is data flowing through the graph.
|
2001-01-08 22:08:40 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
|
2000-08-16 21:38:57 +00:00
|
|
|
</sect1>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-states-null">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>The NULL state</title>
|
|
|
|
<para>
|
|
|
|
When you created the pipeline all of the elements will be in the NULL state. There is
|
2003-10-09 12:42:49 +00:00
|
|
|
nothing special about the NULL state.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</sect1>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-states-ready">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>The READY state</title>
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
2001-01-04 23:35:50 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
You can also go from the NULL to PLAYING state directly without
|
2002-09-14 14:13:34 +00:00
|
|
|
going through the READY state. This is a shortcut; the framework
|
2002-09-08 21:17:16 +00:00
|
|
|
will internally go through the READY and the PAUSED state for you.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
2000-08-16 21:38:57 +00:00
|
|
|
</sect1>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-states-paused">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>The PAUSED state</title>
|
|
|
|
<para>
|
|
|
|
A pipeline that is playing can be set to the PAUSED state. This will temporarily stop all
|
|
|
|
data flowing through the pipeline.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
You can resume the data flow by setting the pipeline back to the PLAYING state.
|
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
The PAUSED state is available for temporarily freezing the pipeline.
|
|
|
|
Elements will typically not free their resources in the PAUSED state.
|
2002-09-14 14:13:34 +00:00
|
|
|
Use the NULL state if you want to stop the data flow permanently.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
<para>
|
|
|
|
The pipeline has to be in the PAUSED or NULL state if you want to insert or modify an element
|
2004-01-28 15:08:17 +00:00
|
|
|
in the pipeline. We will cover dynamic pipeline behaviour in <xref linkend="chapter-dynamic"/>.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</sect1>
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-states-playing">
|
2003-10-09 12:42:49 +00:00
|
|
|
<title>The PLAYING state</title>
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
2000-08-16 21:38:57 +00:00
|
|
|
|
|
|
|
</chapter>
|