1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Data-passing buffer type, supporting sub-buffers and metadata
7 <!-- ##### SECTION Long_Description ##### -->
9 Buffers are the basic unit of data transfer in GST. The GstBuffer type
10 provides all the state necessary to define a region of memory as part of a
11 stream. Sub-buffer are also supported, allowing a smaller region of a
12 buffer to become its own buffer, with mechanisms in place to ensure that
13 neither memory space goes away. Metadata is supported as a list of
14 pointers to arbitrary metadata.
17 Buffers are usually created with gst_buffer_new(). After a buffer has been
18 created one will typically allocate memory for it and set the size of the
22 gint size, widht, height, bpp;
24 size = width * height * bpp;
26 buffer = gst_buffer_new ();
27 GST_BUFFER_SIZE (buffer) = size;
28 GST_BUFFER_DATA (buffer) = g_alloc (size);
34 GstBuffers can also be created from a GstBufferPool with
35 gst_buffer_new_from_pool(). The bufferpool can be obtained from a
36 peer element with gst_pad_get_bufferpool().
39 gst_buffer_ref() is used to increase the refcount of a buffer. This must be
40 done when you want to keep a handle to the buffer after pushing it to the
44 To efficiently create a smaller buffer out of an existing one, you can
45 use gst_buffer_create_sub().
48 Several flags of the buffer can be set and unset with the GST_BUFFER_FLAG_SET()
49 and GST_BUFFER_FLAG_UNSET() macros. Use GST_BUFFER_FLAG_IS_SET() to test it
50 a certain flag is set.
53 Buffers usually are freed by unreffing them with gst_buffer_unref().
54 gst_buffer_destroy() can also be used to effectively destroy the buffer
55 regardless of the refcount (dangerous).
58 <!-- ##### SECTION See_Also ##### -->
60 #GstBufferPool, #GstPad, #GstData
63 <!-- ##### MACRO GST_IS_BUFFER ##### -->
65 Check if the object is a buffer.
68 @buf: The object to check
71 <!-- ##### MACRO GST_BUFFER ##### -->
73 Cast an object to a GstBuffer
76 @buf: The object to cast.
79 <!-- ##### MACRO GST_BUFFER_FLAGS ##### -->
81 Get the flags from this buffer.
84 @buf: GstBuffer to retrieve the flags from
87 <!-- ##### MACRO GST_BUFFER_FLAG_IS_SET ##### -->
89 Gives the status of a given flag.
92 @buf: GstBuffer to query
93 @flag: the flag to check
96 <!-- ##### MACRO GST_BUFFER_FLAG_SET ##### -->
98 Set a flag in a buffer.
101 @buf: GstBuffer to query
102 @flag: the flag to set
105 <!-- ##### MACRO GST_BUFFER_FLAG_UNSET ##### -->
107 Clear a flag in a buffer.
110 @buf: GstBuffer to modify
111 @flag: the flag to clear
114 <!-- ##### MACRO GST_BUFFER_DATA ##### -->
116 Retrieves a pointer to the data element of this buffer
122 <!-- ##### MACRO GST_BUFFER_SIZE ##### -->
124 Get the size of the data in this buffer.
130 <!-- ##### MACRO GST_BUFFER_OFFSET ##### -->
132 Get the offset in the source file of this buffer.
138 <!-- ##### MACRO GST_BUFFER_MAXSIZE ##### -->
140 Gets the maximun size of this buffer.
146 <!-- ##### MACRO GST_BUFFER_TIMESTAMP ##### -->
148 Get the timestamp for this buffer.
154 <!-- ##### MACRO GST_BUFFER_BUFFERPOOL ##### -->
156 Get the bufferpool for this buffer.
162 <!-- ##### MACRO GST_BUFFER_POOL_PRIVATE ##### -->
164 Get the bufferpool private data.
170 <!-- ##### MACRO GST_BUFFER_LOCK ##### -->
172 This macro will obtain a lock on the object, making serialization
177 @buf: GstBuffer to lock
180 <!-- ##### MACRO GST_BUFFER_TRYLOCK ##### -->
182 This macro will try to obtain a lock on the object, but will return with
183 FALSE if it can't get it immediately.
187 @buf: GstBuffer to try to lock
190 <!-- ##### MACRO GST_BUFFER_UNLOCK ##### -->
192 This macro releases a lock on the object.
196 @buf: GstBuffer to unlock.
199 <!-- ##### MACRO GST_BUFFER_PARENT ##### -->
201 Get the parent of this buffer. The parent is set on subbuffers.
204 @buf: GstBuffer to get the parent of.
207 <!-- ##### MACRO GST_BUFFER_MAXAGE ##### -->
209 Get the maximun age of a buffer.
212 @buf: GstBuffer to get the maxage of.
215 <!-- ##### MACRO GST_BUFFER_COPY_FUNC ##### -->
217 Call the buffer specific copy function on the given buffer.
220 @buf: the buffer to copy.
223 <!-- ##### MACRO GST_BUFFER_FREE_FUNC ##### -->
225 Call the buffer specific free function on the given buffer.
228 @buf: the buffer to free.
231 <!-- ##### USER_FUNCTION GstBufferCopyFunc ##### -->
233 This function is used to copy the buffer contents.
236 @srcbuf: the src buffer
238 <!-- # Unused Parameters # -->
239 @dstbuf: the destination buffer
242 <!-- ##### USER_FUNCTION GstBufferFreeFunc ##### -->
244 The function called when the buffer data has to be freed
247 @buf: the buffer to clear the buffer data of.
250 <!-- ##### ENUM GstBufferFlags ##### -->
255 @GST_BUFFER_READONLY: the buffer is read only
256 @GST_BUFFER_ORIGINAL: this buffer not a copy
257 @GST_BUFFER_DONTFREE: do not try to free the data when this buffer is unref-ed
258 @GST_BUFFER_FLUSH: this buffer is not related to previous buffers. This flag is mainly
259 used when data in a stream has been skipped
260 @GST_BUFFER_EOS: this buffer is the last one in the stream
261 @GST_BUFFER_DISCONTINUOUS: The buffer has a discontinuity
263 <!-- ##### STRUCT GstBuffer ##### -->
281 <!-- ##### FUNCTION gst_buffer_new ##### -->
289 <!-- ##### FUNCTION gst_buffer_new_from_pool ##### -->
298 <!-- # Unused Parameters # -->
302 <!-- ##### FUNCTION gst_buffer_copy ##### -->
311 <!-- ##### FUNCTION gst_buffer_create_sub ##### -->
322 <!-- ##### FUNCTION gst_buffer_append ##### -->
330 <!-- # Unused Parameters # -->
335 <!-- ##### FUNCTION gst_buffer_ref ##### -->
343 <!-- ##### FUNCTION gst_buffer_ref_by_count ##### -->
352 <!-- ##### FUNCTION gst_buffer_unref ##### -->
360 <!-- ##### FUNCTION gst_buffer_destroy ##### -->
368 <!-- ##### FUNCTION gst_buffer_is_span_fast ##### -->
378 <!-- ##### FUNCTION gst_buffer_merge ##### -->
388 <!-- ##### FUNCTION gst_buffer_span ##### -->