new proggy I never checked in
[platform/upstream/gstreamer.git] / docs / manual / basics-data.xml
1 <chapter id="cha-buffers">
2   <title>Buffers</title>
3   <para> 
4     Buffers contain the data that will flow through the pipeline you have
5     created. A source element will typically create a new buffer and pass
6     it through a pad to the next element in the chain.  When using the
7     GStreamer infrastructure to create a media pipeline you will not have
8     to deal with buffers yourself; the elements will do that for you.
9   </para>
10   <para> 
11     The most important information in the buffer is:
12
13     <itemizedlist>
14       <listitem>
15         <para>
16           A pointer to a piece of memory.
17         </para>
18       </listitem>
19       <listitem>
20         <para>
21           The size of the memory.
22         </para>
23       </listitem>
24       <listitem>
25         <para>
26           A refcount that indicates how many elements are using this
27           buffer. This refcount will be used to destroy the buffer when no
28           element is having a reference to it.
29         </para>
30       </listitem>
31     </itemizedlist>
32   </para>
33
34   <para> 
35     GStreamer provides functions to create custom buffer create/destroy algorithms, called
36     a <classname>GstBufferPool</classname>. This makes it possible to efficiently 
37     allocate and destroy buffer memory. It also makes it possible to exchange memory between
38     elements by passing the <classname>GstBufferPool</classname>. A video element can, 
39     for example, create a custom buffer allocation algorithm that creates buffers with XSHM 
40     as the buffer memory. An element can use this algorithm to create and fill the buffer 
41     with data.
42   </para>
43
44   <para> 
45     The simple case is that a buffer is created, memory allocated, data put
46     in it, and passed to the next element.  That element reads the data, does
47     something (like creating a new buffer and decoding into it), and
48     unreferences the buffer.  This causes the data to be freed and the buffer
49     to be destroyed. A typical MPEG audio decoder works like this.
50   </para>
51
52   <para> 
53     A more complex case is when the filter modifies the data in place.  It
54     does so and simply passes on the buffer to the next element.  This is just
55     as easy to deal with. An element that works in place has to be careful when
56     the buffer is used in more than one element; a copy on write has to made in this
57     situation.
58   </para>
59
60 </chapter>