139 * A pointer to any data allocated for this buffer using g_malloc(). If this is |
139 * A pointer to any data allocated for this buffer using g_malloc(). If this is |
140 * non-NULL, this memory will be freed at the end of the buffer's lifecycle |
140 * non-NULL, this memory will be freed at the end of the buffer's lifecycle |
141 * (i.e. when its refcount becomes zero). |
141 * (i.e. when its refcount becomes zero). |
142 */ |
142 */ |
143 #define GST_BUFFER_MALLOCDATA(buf) (GST_BUFFER_CAST(buf)->malloc_data) |
143 #define GST_BUFFER_MALLOCDATA(buf) (GST_BUFFER_CAST(buf)->malloc_data) |
|
144 /** |
|
145 * GST_BUFFER_FREE_FUNC: |
|
146 * @buf: a #GstBuffer. |
|
147 * |
|
148 * A pointer to a function that will be called on the buffer's malloc_data when |
|
149 * this buffer is finalized. Defaults to g_free(). |
|
150 * |
|
151 * Note that the free function only affects the buffer's malloc_data; if the |
|
152 * buffer's malloc_data is %NULL, the function will not be called. |
|
153 * |
|
154 * Since: 0.10.22 |
|
155 */ |
|
156 #define GST_BUFFER_FREE_FUNC(buf) (GST_BUFFER_CAST(buf)->free_func) |
144 |
157 |
145 /** |
158 /** |
146 * GST_BUFFER_OFFSET_NONE: |
159 * GST_BUFFER_OFFSET_NONE: |
147 * |
160 * |
148 * Constant for no-offset return results. |
161 * Constant for no-offset return results. |
199 * @GST_BUFFER_FLAG_IN_CAPS: the buffer has been added as a field in a #GstCaps. |
212 * @GST_BUFFER_FLAG_IN_CAPS: the buffer has been added as a field in a #GstCaps. |
200 * @GST_BUFFER_FLAG_GAP: the buffer has been created to fill a gap in the |
213 * @GST_BUFFER_FLAG_GAP: the buffer has been created to fill a gap in the |
201 * stream and contains media neutral data (elements can switch to optimized code |
214 * stream and contains media neutral data (elements can switch to optimized code |
202 * path that ignores the buffer content). |
215 * path that ignores the buffer content). |
203 * @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently. |
216 * @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently. |
|
217 * @GST_BUFFER_FLAG_MEDIA1: a flag whose use is specific to the caps of the buffer. |
|
218 * Since: 0.10.23 |
|
219 * @GST_BUFFER_FLAG_MEDIA2: a flag whose use is specific to the caps of the buffer. |
|
220 * Since: 0.10.23 |
|
221 * @GST_BUFFER_FLAG_MEDIA3: a flag whose use is specific to the caps of the buffer. |
|
222 * Since: 0.10.23 |
204 * @GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag. |
223 * @GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag. |
205 * |
224 * |
206 * A set of buffer flags used to describe properties of a #GstBuffer. |
225 * A set of buffer flags used to describe properties of a #GstBuffer. |
207 */ |
226 */ |
208 typedef enum { |
227 typedef enum { |
210 GST_BUFFER_FLAG_PREROLL = (GST_MINI_OBJECT_FLAG_LAST << 0), |
229 GST_BUFFER_FLAG_PREROLL = (GST_MINI_OBJECT_FLAG_LAST << 0), |
211 GST_BUFFER_FLAG_DISCONT = (GST_MINI_OBJECT_FLAG_LAST << 1), |
230 GST_BUFFER_FLAG_DISCONT = (GST_MINI_OBJECT_FLAG_LAST << 1), |
212 GST_BUFFER_FLAG_IN_CAPS = (GST_MINI_OBJECT_FLAG_LAST << 2), |
231 GST_BUFFER_FLAG_IN_CAPS = (GST_MINI_OBJECT_FLAG_LAST << 2), |
213 GST_BUFFER_FLAG_GAP = (GST_MINI_OBJECT_FLAG_LAST << 3), |
232 GST_BUFFER_FLAG_GAP = (GST_MINI_OBJECT_FLAG_LAST << 3), |
214 GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 4), |
233 GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 4), |
215 /* padding */ |
234 GST_BUFFER_FLAG_MEDIA1 = (GST_MINI_OBJECT_FLAG_LAST << 5), |
|
235 GST_BUFFER_FLAG_MEDIA2 = (GST_MINI_OBJECT_FLAG_LAST << 6), |
|
236 GST_BUFFER_FLAG_MEDIA3 = (GST_MINI_OBJECT_FLAG_LAST << 7), |
216 GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 8) |
237 GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 8) |
217 } GstBufferFlag; |
238 } GstBufferFlag; |
218 |
239 |
219 /** |
240 /** |
220 * GstBuffer: |
241 * GstBuffer: |
232 * For file data or compressed data this is the byte offset of the first |
253 * For file data or compressed data this is the byte offset of the first |
233 * byte in this buffer. |
254 * byte in this buffer. |
234 * @offset_end: the last offset contained in this buffer. It has the same |
255 * @offset_end: the last offset contained in this buffer. It has the same |
235 * format as @offset. |
256 * format as @offset. |
236 * @malloc_data: a pointer to the allocated memory associated with this buffer. |
257 * @malloc_data: a pointer to the allocated memory associated with this buffer. |
237 * When the buffer is freed, this data will freed with g_free(). |
258 * When the buffer is freed, this data will freed with @free_func. |
|
259 * @free_func: a custom function that will be called with @malloc_data, defaults |
|
260 * to g_free(). Since 0.10.22. |
238 * |
261 * |
239 * The structure of a #GstBuffer. Use the associated macros to access the public |
262 * The structure of a #GstBuffer. Use the associated macros to access the public |
240 * variables. |
263 * variables. |
241 */ |
264 */ |
242 struct _GstBuffer { |
265 struct _GstBuffer { |
344 * |
367 * |
345 * Decreases the refcount of the buffer. If the refcount reaches 0, the buffer |
368 * Decreases the refcount of the buffer. If the refcount reaches 0, the buffer |
346 * will be freed. If GST_BUFFER_MALLOCDATA() is non-NULL, this pointer will |
369 * will be freed. If GST_BUFFER_MALLOCDATA() is non-NULL, this pointer will |
347 * also be freed at this time. |
370 * also be freed at this time. |
348 */ |
371 */ |
349 #define gst_buffer_unref(buf) gst_mini_object_unref (GST_MINI_OBJECT_CAST (buf)) |
372 #ifdef _FOOL_GTK_DOC_ |
|
373 G_INLINE_FUNC void gst_buffer_unref (GstBuffer * buf); |
|
374 #endif |
|
375 |
|
376 static inline void |
|
377 gst_buffer_unref (GstBuffer * buf) |
|
378 { |
|
379 gst_mini_object_unref (GST_MINI_OBJECT_CAST (buf)); |
|
380 } |
350 |
381 |
351 /* copy buffer */ |
382 /* copy buffer */ |
352 /** |
383 /** |
353 * gst_buffer_copy: |
384 * gst_buffer_copy: |
354 * @buf: a #GstBuffer. |
385 * @buf: a #GstBuffer. |
355 * |
386 * |
356 * Create a copy of the given buffer. This will also make a newly allocated |
387 * Create a copy of the given buffer. This will also make a newly allocated |
357 * copy of the data the source buffer contains. |
388 * copy of the data the source buffer contains. |
358 */ |
389 * |
359 #define gst_buffer_copy(buf) GST_BUFFER_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buf))) |
390 * Returns: a new copy of @buf. |
|
391 */ |
|
392 #ifdef _FOOL_GTK_DOC_ |
|
393 G_INLINE_FUNC GstBuffer * gst_buffer_copy (const GstBuffer * buf); |
|
394 #endif |
|
395 |
|
396 static inline GstBuffer * |
|
397 gst_buffer_copy (const GstBuffer * buf) |
|
398 { |
|
399 return GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buf))); |
|
400 } |
|
401 |
360 |
402 |
361 /** |
403 /** |
362 * GstBufferCopyFlags: |
404 * GstBufferCopyFlags: |
363 * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied |
405 * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied |
364 * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration, |
406 * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration, |