gstreamer_core/gst/gstbuffer.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
   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)
       
   157 
   144 
   158 /**
   145 /**
   159  * GST_BUFFER_OFFSET_NONE:
   146  * GST_BUFFER_OFFSET_NONE:
   160  *
   147  *
   161  * Constant for no-offset return results.
   148  * Constant for no-offset return results.
   212  * @GST_BUFFER_FLAG_IN_CAPS: the buffer has been added as a field in a #GstCaps.
   199  * @GST_BUFFER_FLAG_IN_CAPS: the buffer has been added as a field in a #GstCaps.
   213  * @GST_BUFFER_FLAG_GAP: the buffer has been created to fill a gap in the
   200  * @GST_BUFFER_FLAG_GAP: the buffer has been created to fill a gap in the
   214  * stream and contains media neutral data (elements can switch to optimized code
   201  * stream and contains media neutral data (elements can switch to optimized code
   215  * path that ignores the buffer content).
   202  * path that ignores the buffer content).
   216  * @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently.
   203  * @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
       
   223  * @GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag.
   204  * @GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag.
   224  *
   205  *
   225  * A set of buffer flags used to describe properties of a #GstBuffer.
   206  * A set of buffer flags used to describe properties of a #GstBuffer.
   226  */
   207  */
   227 typedef enum {
   208 typedef enum {
   229   GST_BUFFER_FLAG_PREROLL    = (GST_MINI_OBJECT_FLAG_LAST << 0),
   210   GST_BUFFER_FLAG_PREROLL    = (GST_MINI_OBJECT_FLAG_LAST << 0),
   230   GST_BUFFER_FLAG_DISCONT    = (GST_MINI_OBJECT_FLAG_LAST << 1),
   211   GST_BUFFER_FLAG_DISCONT    = (GST_MINI_OBJECT_FLAG_LAST << 1),
   231   GST_BUFFER_FLAG_IN_CAPS    = (GST_MINI_OBJECT_FLAG_LAST << 2),
   212   GST_BUFFER_FLAG_IN_CAPS    = (GST_MINI_OBJECT_FLAG_LAST << 2),
   232   GST_BUFFER_FLAG_GAP        = (GST_MINI_OBJECT_FLAG_LAST << 3),
   213   GST_BUFFER_FLAG_GAP        = (GST_MINI_OBJECT_FLAG_LAST << 3),
   233   GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 4),
   214   GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 4),
   234   GST_BUFFER_FLAG_MEDIA1     = (GST_MINI_OBJECT_FLAG_LAST << 5),
   215   /* padding */
   235   GST_BUFFER_FLAG_MEDIA2     = (GST_MINI_OBJECT_FLAG_LAST << 6),
       
   236   GST_BUFFER_FLAG_MEDIA3     = (GST_MINI_OBJECT_FLAG_LAST << 7),
       
   237   GST_BUFFER_FLAG_LAST       = (GST_MINI_OBJECT_FLAG_LAST << 8)
   216   GST_BUFFER_FLAG_LAST       = (GST_MINI_OBJECT_FLAG_LAST << 8)
   238 } GstBufferFlag;
   217 } GstBufferFlag;
   239 
   218 
   240 /**
   219 /**
   241  * GstBuffer:
   220  * GstBuffer:
   253  *     For file data or compressed data this is the byte offset of the first
   232  *     For file data or compressed data this is the byte offset of the first
   254  *       byte in this buffer.
   233  *       byte in this buffer.
   255  * @offset_end: the last offset contained in this buffer. It has the same 
   234  * @offset_end: the last offset contained in this buffer. It has the same 
   256  *     format as @offset.
   235  *     format as @offset.
   257  * @malloc_data: a pointer to the allocated memory associated with this buffer.
   236  * @malloc_data: a pointer to the allocated memory associated with this buffer.
   258  *     When the buffer is freed, this data will freed with @free_func.
   237  *     When the buffer is freed, this data will freed with g_free().
   259  * @free_func: a custom function that will be called with @malloc_data, defaults
       
   260  *     to g_free(). Since 0.10.22.
       
   261  *
   238  *
   262  * The structure of a #GstBuffer. Use the associated macros to access the public
   239  * The structure of a #GstBuffer. Use the associated macros to access the public
   263  * variables.
   240  * variables.
   264  */
   241  */
   265 struct _GstBuffer {
   242 struct _GstBuffer {
   281   guint64		 offset;
   258   guint64		 offset;
   282   guint64		 offset_end;
   259   guint64		 offset_end;
   283 
   260 
   284   guint8                *malloc_data;
   261   guint8                *malloc_data;
   285 
   262 
   286   GFreeFunc              free_func;
       
   287 
       
   288   /*< private >*/
   263   /*< private >*/
   289   gpointer _gst_reserved[GST_PADDING - 1];
   264   gpointer _gst_reserved[GST_PADDING];
   290 };
   265 };
   291 
   266 
   292 struct _GstBufferClass {
   267 struct _GstBufferClass {
   293   GstMiniObjectClass    mini_object_class;
   268   GstMiniObjectClass    mini_object_class;
   294 };
   269 };
   356 #endif
   331 #endif
   357 
   332 
   358 static inline GstBuffer *
   333 static inline GstBuffer *
   359 gst_buffer_ref (GstBuffer * buf)
   334 gst_buffer_ref (GstBuffer * buf)
   360 {
   335 {
       
   336   /* not using a macro here because gcc-4.1 will complain
       
   337    * if the return value isn't used (because of the cast) */
   361   return (GstBuffer *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (buf));
   338   return (GstBuffer *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (buf));
   362 }
   339 }
   363 
   340 
   364 /**
   341 /**
   365  * gst_buffer_unref:
   342  * gst_buffer_unref:
   367  *
   344  *
   368  * Decreases the refcount of the buffer. If the refcount reaches 0, the buffer
   345  * Decreases the refcount of the buffer. If the refcount reaches 0, the buffer
   369  * will be freed. If GST_BUFFER_MALLOCDATA() is non-NULL, this pointer will
   346  * will be freed. If GST_BUFFER_MALLOCDATA() is non-NULL, this pointer will
   370  * also be freed at this time.
   347  * also be freed at this time.
   371  */
   348  */
   372 #ifdef _FOOL_GTK_DOC_
   349 #define		gst_buffer_unref(buf)		gst_mini_object_unref (GST_MINI_OBJECT_CAST (buf))
   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 }
       
   381 
   350 
   382 /* copy buffer */
   351 /* copy buffer */
   383 /**
   352 /**
   384  * gst_buffer_copy:
   353  * gst_buffer_copy:
   385  * @buf: a #GstBuffer.
   354  * @buf: a #GstBuffer.
   386  *
   355  *
   387  * Create a copy of the given buffer. This will also make a newly allocated
   356  * Create a copy of the given buffer. This will also make a newly allocated
   388  * copy of the data the source buffer contains.
   357  * copy of the data the source buffer contains.
   389  *
   358  */
   390  * Returns: a new copy of @buf.
   359 #define		gst_buffer_copy(buf)		GST_BUFFER_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (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 
       
   402 
   360 
   403 /**
   361 /**
   404  * GstBufferCopyFlags:
   362  * GstBufferCopyFlags:
   405  * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
   363  * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied
   406  * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration,
   364  * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration,