2002-01-15 00:41:22 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
|
|
|
GstBuffer
|
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
2002-07-12 23:21:20 +00:00
|
|
|
Data-passing buffer type, supporting sub-buffers.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Buffers are the basic unit of data transfer in GStreamer. The GstBuffer type
|
2002-01-15 00:41:22 +00:00
|
|
|
provides all the state necessary to define a region of memory as part of a
|
2002-04-17 12:28:32 +00:00
|
|
|
stream. Sub-buffers are also supported, allowing a smaller region of a
|
2002-01-15 00:41:22 +00:00
|
|
|
buffer to become its own buffer, with mechanisms in place to ensure that
|
2002-07-12 23:21:20 +00:00
|
|
|
neither memory space goes away.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Buffers are usually created with gst_buffer_new(). After a buffer has been
|
|
|
|
created one will typically allocate memory for it and set the size of the
|
2002-08-30 14:54:58 +00:00
|
|
|
buffer data. The following example creates a buffer that can hold a given
|
|
|
|
video frame with a given width, height and bits per plane.
|
2002-01-15 00:41:22 +00:00
|
|
|
<programlisting>
|
|
|
|
GstBuffer *buffer;
|
2002-08-30 14:54:58 +00:00
|
|
|
gint size, width, height, bpp;
|
|
|
|
|
|
|
|
...
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
size = width * height * bpp;
|
|
|
|
|
|
|
|
buffer = gst_buffer_new ();
|
|
|
|
GST_BUFFER_SIZE (buffer) = size;
|
|
|
|
GST_BUFFER_DATA (buffer) = g_alloc (size);
|
|
|
|
...
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Alternatively, use gst_buffer_new_and_alloc()
|
|
|
|
to create a buffer with preallocated
|
2002-07-12 23:21:20 +00:00
|
|
|
data of a given size.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
GstBuffers can also be created from a #GstBufferPool with
|
2002-01-15 00:41:22 +00:00
|
|
|
gst_buffer_new_from_pool(). The bufferpool can be obtained from a
|
|
|
|
peer element with gst_pad_get_bufferpool().
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
gst_buffer_ref() is used to increase the refcount of a buffer. This must be
|
|
|
|
done when you want to keep a handle to the buffer after pushing it to the
|
|
|
|
next element.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
To efficiently create a smaller buffer out of an existing one, you can
|
|
|
|
use gst_buffer_create_sub().
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
If the plug-in wants to modify the buffer in-place, it should first obtain
|
|
|
|
a buffer that is safe to modify by using gst_buffer_copy_on_write(). This
|
|
|
|
function is optimized so that a copy will only be made when it is necessary.
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-01-15 00:41:22 +00:00
|
|
|
Several flags of the buffer can be set and unset with the GST_BUFFER_FLAG_SET()
|
|
|
|
and GST_BUFFER_FLAG_UNSET() macros. Use GST_BUFFER_FLAG_IS_SET() to test it
|
2002-08-30 14:54:58 +00:00
|
|
|
a certain #GstBufferFlag is set.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2002-07-12 23:21:20 +00:00
|
|
|
Buffers can be efficiently merged into a larger buffer with gst_buffer_merge() and
|
|
|
|
gst_buffer_span() if the gst_buffer_is_span_fast() function returns TRUE.
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
An element should either unref the buffer or push it out on a src pad
|
|
|
|
using gst_pad_push() (see #GstPad).
|
|
|
|
|
2002-01-15 00:41:22 +00:00
|
|
|
Buffers usually are freed by unreffing them with gst_buffer_unref().
|
2002-08-30 14:54:58 +00:00
|
|
|
Do not use gst_buffer_free() : this function effectively frees the buffer
|
|
|
|
regardless of the refcount, which is dangerous.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Last reviewed on August 30th, 2002 (0.4.0.1)
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
|
|
<para>
|
|
|
|
#GstBufferPool, #GstPad, #GstData
|
|
|
|
</para>
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### MACRO GST_BUFFER ##### -->
|
|
|
|
<para>
|
|
|
|
Casts an object to a GstBuffer.
|
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: an object to cast.
|
|
|
|
@Returns: the #GstBuffer to which the given object points.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
2002-01-15 00:41:22 +00:00
|
|
|
<!-- ##### MACRO GST_IS_BUFFER ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Checks if the pointer is a GstBuffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a pointer to query.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### MACRO GST_BUFFER_REFCOUNT ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Gets a handle to the refcount structure of the buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get the refcount structure of.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_REFCOUNT_VALUE ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Gets the current refcount value of the buffer.
|
2002-07-12 23:21:20 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get the refcount value of.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_COPY_FUNC ##### -->
|
|
|
|
<para>
|
|
|
|
Calls the buffer-specific copy function on the given buffer.
|
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to copy.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FREE_FUNC ##### -->
|
|
|
|
<para>
|
|
|
|
Calls the buffer-specific free function on the given buffer.
|
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to free.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FLAGS ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the flags from this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to retrieve the flags from.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FLAG_IS_SET ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Gives the status of a given flag of a buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to query flags of.
|
|
|
|
@flag: the #GstBufferFlag to check.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FLAG_SET ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Sets a buffer flag.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to modify flags of.
|
|
|
|
@flag: the #GstBufferFlag to set.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FLAG_UNSET ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Clears a buffer flag.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to modify flags of.
|
|
|
|
@flag: the #GstBufferFlag to clear.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_DATA ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Retrieves a pointer to the data element of this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get data pointer of.
|
|
|
|
@Returns: the pointer to the actual data contents of the buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_SIZE ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the size of the data in this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get data size of.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_MAXSIZE ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the maximum size of this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get maximum size of.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_TIMESTAMP ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the timestamp for this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get timestamp of.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### MACRO GST_BUFFER_OFFSET ##### -->
|
|
|
|
<para>
|
|
|
|
Gets the offset in the source file of this buffer.
|
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get offset of.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
2002-01-15 00:41:22 +00:00
|
|
|
<!-- ##### MACRO GST_BUFFER_BUFFERPOOL ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the bufferpool for this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get the bufferpool of.
|
|
|
|
@Returns: the #GstBufferPool of this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_POOL_PRIVATE ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the bufferpool private data.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to get bufferpool's private data of.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### ENUM GstBufferFlag ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
A set of buffer flags used to describe properties of a #GstBuffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@GST_BUFFER_READONLY: the buffer is read-only.
|
|
|
|
@GST_BUFFER_SUBBUFFER: the buffer is a subbuffer, the parent buffer can be
|
|
|
|
found with the GST_BUFFER_POOL_PRIVATE() macro.
|
|
|
|
@GST_BUFFER_ORIGINAL: buffer is not a copy of another buffer.
|
|
|
|
@GST_BUFFER_DONTFREE: do not try to free the data when this buffer is
|
|
|
|
unreferenced.
|
|
|
|
@GST_BUFFER_DISCONTINUOUS: the buffer is the first one after a discontinuity
|
|
|
|
in the stream.
|
|
|
|
@GST_BUFFER_KEY_UNIT: the buffer holds a key unit, a unit that can be
|
|
|
|
decoded independently of other buffers.
|
|
|
|
@GST_BUFFER_PREROLL: the buffer should be decoded but not rendered, it is
|
|
|
|
mainly used to resynchronise the stream.
|
|
|
|
@GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
<!-- ##### STRUCT GstBuffer ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
The basic structure of a buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
@data_type:
|
|
|
|
@data:
|
|
|
|
@size:
|
|
|
|
@maxsize:
|
|
|
|
@timestamp:
|
2002-07-11 19:40:06 +00:00
|
|
|
@offset:
|
2002-01-15 00:41:22 +00:00
|
|
|
@pool:
|
|
|
|
@pool_private:
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_new ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_new_and_alloc ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@size:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2002-01-15 00:41:22 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_new_from_pool ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@pool:
|
|
|
|
@offset:
|
|
|
|
@size:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_default_free ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_default_copy ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
@buffer:
|
2002-01-15 00:41:22 +00:00
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2002-07-11 19:40:06 +00:00
|
|
|
<!-- ##### MACRO gst_buffer_ref ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Increases the refcount of the given buffer by one.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to increase the refcount of.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-11 19:40:06 +00:00
|
|
|
<!-- ##### MACRO gst_buffer_ref_by_count ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Increases the refcount of the buffer by the given value.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to increase the refcount of.
|
|
|
|
@c: the value to add to the refcount.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-11 19:40:06 +00:00
|
|
|
<!-- ##### MACRO gst_buffer_unref ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Decreases the refcount of the buffer. If the refcount reaches 0, the buffer
|
2002-07-12 23:21:20 +00:00
|
|
|
will be freed.
|
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to unref.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO gst_buffer_copy ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Copies the given buffer using the copy function of the parent GstData structure.
|
2002-07-12 23:21:20 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-30 14:54:58 +00:00
|
|
|
@buf: a #GstBuffer to copy.
|
|
|
|
@Returns: a new #GstBuffer copy of the buffer.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO gst_buffer_copy_on_write ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
This function returns a buffer that is safe to write to.
|
|
|
|
Copy the buffer if the refcount > 1 so that the newly
|
|
|
|
created buffer can be safely written to.
|
|
|
|
If the refcount is 1, this function just returns the original buffer.
|
2002-07-12 23:21:20 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-31 18:17:02 +00:00
|
|
|
@buf:
|
2002-08-30 14:54:58 +00:00
|
|
|
@Returns: the #GstBuffer that can safely be written to.
|
2002-08-31 18:17:02 +00:00
|
|
|
<!-- # Unused Parameters # -->
|
|
|
|
@buffer: a #GstBuffer to copy.
|
2002-07-12 23:21:20 +00:00
|
|
|
|
2002-01-15 00:41:22 +00:00
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### MACRO gst_buffer_free ##### -->
|
|
|
|
<para>
|
2002-08-30 14:54:58 +00:00
|
|
|
Frees the given buffer, regardless of the refcount.
|
|
|
|
It is dangerous to use this function, you should use gst_buffer_unref() instead.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-08-31 18:17:02 +00:00
|
|
|
@buf:
|
|
|
|
<!-- # Unused Parameters # -->
|
2002-08-30 14:54:58 +00:00
|
|
|
@buffer: a #GstBuffer to free.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_create_sub ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@parent:
|
|
|
|
@offset:
|
|
|
|
@size:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_merge ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@buf2:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2002-07-12 23:21:20 +00:00
|
|
|
<!-- ##### FUNCTION gst_buffer_is_span_fast ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@buf2:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_span ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@offset:
|
|
|
|
@buf2:
|
|
|
|
@len:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_print_stats ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|