summaryrefslogtreecommitdiff
path: root/docs/manual/states.sgml
blob: 9027910bf3568d54c95c046d6f586eeac883a915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<chapter id="cha-states">
  <title>Element states</title>
  <para> 
    One you have created a pipeline packed with elements, nothing will happen yet.
    This is where the different states come into play. 
  </para>

  <sect1 id="sec-states">
    <title>The different element states</title>
    <para> 
      All elements can be in one of the following four states:
      <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>
  	    PAUSED: The element is paused for a period of time.
          </para>
        </listitem>
        <listitem>
          <para>
	    PLAYING: The element is doing something.
          </para>
        </listitem>
      </itemizedlist>
    </para>

    <para> 
      All elements start with the NULL state. The elements will go throught the following state changes:
      NULL -&gt; READY -&gt; PAUSED -&gt; PLAYING. Remember when going from PLAYING to READY GStreamer 
      will internally go throught the intermediate states.
    </para>
    <para> 
      The state of an element can be changed with the following code:
    </para>
    <programlisting>
  GstElement *bin;

  // create a bin, put elements in it and connect them
  ...
  gst_element_set_state (bin, GST_STATE_PLAYING);
  ...
    </programlisting>

    <para> 
      You can set the following states to an element:
    </para>
    <informaltable pgwide=1 frame="none" role="enum">
    <tgroup cols="2">
      <colspec colwidth="2*">
      <colspec colwidth="8*">
    <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>
        <entry><literal>GST_STATE_PAUSED</literal></entry>
        <entry>temporary stops the data flow.
        </entry>
      </row>
      <row>
        <entry><literal>GST_STATE_PLAYING</literal></entry>
        <entry>means there really is data flowing through the graph.
        </entry>
      </row>
    </tbody>
    </tgroup>
    </informaltable>

  </sect1>

  <sect1 id="sec-states-null">
    <title>The NULL state</title>
    <para> 
      When you created the pipeline all of the elements will be in the NULL state. There is
      nothing spectacular about the NULL state.
    </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>

  <sect1 id="sec-states-ready">
    <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>
    <note>
      <para> 
        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.
      </para> 
    </note>
  </sect1>

  <sect1 id="sec-states-playing">
    <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>

  <sect1 id="sec-states-paused">
    <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> 
	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 permanantly.  
      </para> 
    </note>
    <para> 
      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 ... <!-- fixme -->
    </para>
  </sect1>

</chapter>