2004-01-28 15:08:17 +00:00
|
|
|
<chapter id="chapter-buffers">
|
2000-08-16 21:38:57 +00:00
|
|
|
<title>Buffers</title>
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
Buffers contain the data that will flow through the pipeline you have
|
|
|
|
created. A source element will typically create a new buffer and pass
|
2002-09-14 14:13:34 +00:00
|
|
|
it through a pad to the next element in the chain. When using the
|
2002-09-08 21:17:16 +00:00
|
|
|
GStreamer infrastructure to create a media pipeline you will not have
|
|
|
|
to deal with buffers yourself; the elements will do that for you.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
A buffer consists of:
|
2000-08-16 21:38:57 +00:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
a pointer to a piece of memory.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
the size of the memory.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a timestamp for the buffer.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
A refcount that indicates how many elements are using this
|
|
|
|
buffer. This refcount will be used to destroy the buffer when no
|
2003-10-09 12:42:49 +00:00
|
|
|
element has a reference to it.
|
2000-08-16 21:38:57 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
2004-07-27 15:01:10 +00:00
|
|
|
<para>
|
|
|
|
<!-- FIXME: this is outdated, there is no GstBufferPool in gst-0.8.X -->
|
2000-08-16 21:38:57 +00:00
|
|
|
GStreamer provides functions to create custom buffer create/destroy algorithms, called
|
|
|
|
a <classname>GstBufferPool</classname>. This makes it possible to efficiently
|
|
|
|
allocate and destroy buffer memory. It also makes it possible to exchange memory between
|
|
|
|
elements by passing the <classname>GstBufferPool</classname>. A video element can,
|
|
|
|
for example, create a custom buffer allocation algorithm that creates buffers with XSHM
|
|
|
|
as the buffer memory. An element can use this algorithm to create and fill the buffer
|
|
|
|
with data.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The simple case is that a buffer is created, memory allocated, data put
|
2002-09-14 14:13:34 +00:00
|
|
|
in it, and passed to the next element. That element reads the data, does
|
2000-08-16 21:38:57 +00:00
|
|
|
something (like creating a new buffer and decoding into it), and
|
|
|
|
unreferences the buffer. This causes the data to be freed and the buffer
|
|
|
|
to be destroyed. A typical MPEG audio decoder works like this.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
A more complex case is when the filter modifies the data in place. It
|
|
|
|
does so and simply passes on the buffer to the next element. This is just
|
2002-04-07 23:32:16 +00:00
|
|
|
as easy to deal with. An element that works in place has to be careful when
|
2000-08-16 21:38:57 +00:00
|
|
|
the buffer is used in more than one element; a copy on write has to made in this
|
|
|
|
situation.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</chapter>
|