2002-01-15 00:41:22 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
|
|
|
GstBuffer
|
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
|
|
|
Data-passing buffer type, supporting sub-buffers and metadata
|
|
|
|
|
|
|
|
<!-- ##### 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
|
|
|
|
neither memory space goes away. Metadata is supported as a list of
|
|
|
|
pointers to arbitrary metadata.
|
|
|
|
</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
|
|
|
|
buffer data.
|
|
|
|
<programlisting>
|
|
|
|
GstBuffer *buffer;
|
|
|
|
gint size, widht, height, bpp;
|
|
|
|
|
|
|
|
size = width * height * bpp;
|
|
|
|
|
|
|
|
buffer = gst_buffer_new ();
|
|
|
|
GST_BUFFER_SIZE (buffer) = size;
|
|
|
|
GST_BUFFER_DATA (buffer) = g_alloc (size);
|
|
|
|
...
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
GstBuffers can also be created from a GstBufferPool with
|
|
|
|
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>
|
|
|
|
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
|
|
|
|
a certain flag is set.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Buffers usually are freed by unreffing them with gst_buffer_unref().
|
|
|
|
gst_buffer_destroy() can also be used to effectively destroy the buffer
|
|
|
|
regardless of the refcount (dangerous).
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
|
|
<para>
|
|
|
|
#GstBufferPool, #GstPad, #GstData
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_IS_BUFFER ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Checks if the object is a buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 12:28:32 +00:00
|
|
|
@buf: object to check
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Casts an object to a GstBuffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 12:28:32 +00:00
|
|
|
@buf: object to cast
|
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-04-17 14:58:17 +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-04-17 12:28:32 +00:00
|
|
|
Gives the status of a given #GstBufferFlag.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to query
|
2002-04-17 12:28:32 +00:00
|
|
|
@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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to modify
|
|
|
|
@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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to modify
|
|
|
|
@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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get data pointer of
|
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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get data size of
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_OFFSET ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the offset in the source file of this buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get offset 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-04-17 14:58:17 +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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get timestamp of
|
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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get bufferpool of
|
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-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get bufferpool's private data of
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_LOCK ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Obtains a lock on the object, making serialization possible.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to lock
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_TRYLOCK ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Tries to obtain a lock on the buffer.
|
|
|
|
If it can't get immediately, will return FALSE.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to try to lock
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_UNLOCK ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Releases a lock on the buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to unlock
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_PARENT ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the parent of this buffer. The parent is set on sub-buffers.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get parent of
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_MAXAGE ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Gets the maximum age of a buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to get maximum age of
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_COPY_FUNC ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Calls the buffer-specific copy function on the given buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to copy
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO GST_BUFFER_FREE_FUNC ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
Calls the buffer-specific free function on the given buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to free
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### USER_FUNCTION GstBufferCopyFunc ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
This supplied function is used to copy the buffer contents.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@srcbuf: a #GstBuffer to copy from
|
|
|
|
@Returns: a newly allocated #GstBuffer copy of srcbuf
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### USER_FUNCTION GstBufferFreeFunc ##### -->
|
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
This supplied function is called when the buffer data has to be freed.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 14:58:17 +00:00
|
|
|
@buf: a #GstBuffer to clear the buffer data of
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
|
2002-04-17 12:28:32 +00:00
|
|
|
<!-- ##### ENUM GstBufferFlag ##### -->
|
2002-01-15 00:41:22 +00:00
|
|
|
<para>
|
2002-04-17 12:28:32 +00:00
|
|
|
This enumeration type describes the flags that can be used for a buffer.
|
2002-01-15 00:41:22 +00:00
|
|
|
</para>
|
|
|
|
|
2002-04-17 12:28:32 +00:00
|
|
|
@GST_BUFFER_READONLY: buffer is read-only
|
|
|
|
@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
|
2002-01-15 00:41:22 +00:00
|
|
|
|
|
|
|
<!-- ##### STRUCT GstBuffer ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@data_type:
|
|
|
|
@lock:
|
|
|
|
@data:
|
|
|
|
@size:
|
|
|
|
@maxsize:
|
|
|
|
@offset:
|
|
|
|
@timestamp:
|
|
|
|
@maxage:
|
|
|
|
@parent:
|
|
|
|
@pool:
|
|
|
|
@pool_private:
|
|
|
|
@free:
|
|
|
|
@copy:
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_new ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_new_from_pool ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@pool:
|
|
|
|
@offset:
|
|
|
|
@size:
|
|
|
|
@Returns:
|
|
|
|
<!-- # Unused Parameters # -->
|
|
|
|
@location:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_copy ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_create_sub ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@parent:
|
|
|
|
@offset:
|
|
|
|
@size:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_append ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
@append:
|
|
|
|
@Returns:
|
|
|
|
<!-- # Unused Parameters # -->
|
|
|
|
@buf:
|
|
|
|
@buf2:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_ref ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_ref_by_count ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
@count:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_unref ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_destroy ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buffer:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_is_span_fast ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@buf2:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_merge ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@buf2:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_span ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@buf1:
|
|
|
|
@offset:
|
|
|
|
@buf2:
|
|
|
|
@len:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gst_buffer_print_stats ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|