X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstbuffer.h;h=0ebf1428b222563c93dffa93db51891d069700fd;hb=e10266e3f3cf9b05b69198b1ac6faa9a62840e30;hp=28c6284a3a4e26e0b6265cdfea12c43c5edf56f0;hpb=bb876588ac998061cef3b3343a8c00f01d119063;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 28c6284..0ebf142 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -16,8 +16,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ @@ -26,7 +26,7 @@ #include #include -#include +#include G_BEGIN_DECLS @@ -44,13 +44,13 @@ typedef struct _GstBufferPool GstBufferPool; * GST_BUFFER_FLAGS: * @buf: a #GstBuffer. * - * A flags word containing #GstBufferFlag flags set on this buffer. + * A flags word containing #GstBufferFlags flags set on this buffer. */ #define GST_BUFFER_FLAGS(buf) GST_MINI_OBJECT_FLAGS(buf) /** * GST_BUFFER_FLAG_IS_SET: * @buf: a #GstBuffer. - * @flag: the #GstBufferFlag to check. + * @flag: the #GstBufferFlags flag to check. * * Gives the status of a specific flag on a buffer. */ @@ -58,7 +58,7 @@ typedef struct _GstBufferPool GstBufferPool; /** * GST_BUFFER_FLAG_SET: * @buf: a #GstBuffer. - * @flag: the #GstBufferFlag to set. + * @flag: the #GstBufferFlags flag to set. * * Sets a buffer flag on a buffer. */ @@ -66,7 +66,7 @@ typedef struct _GstBufferPool GstBufferPool; /** * GST_BUFFER_FLAG_UNSET: * @buf: a #GstBuffer. - * @flag: the #GstBufferFlag to clear. + * @flag: the #GstBufferFlags flag to clear. * * Clears a buffer flag. */ @@ -163,8 +163,6 @@ typedef struct _GstBufferPool GstBufferPool; * @buffer: a #GstBuffer * * Tests if the buffer marks a discontinuity in the stream. - * - * Since: 0.10.9 */ #define GST_BUFFER_IS_DISCONT(buffer) (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) @@ -184,10 +182,9 @@ typedef struct _GstBufferPool GstBufferPool; * @GST_BUFFER_FLAG_CORRUPTED: the buffer data is corrupted. * @GST_BUFFER_FLAG_MARKER: the buffer contains a media specific marker. for * video this is typically the end of a frame boundary, for audio - * this is usually the end of a talkspurt. + * this is usually the start of a talkspurt. * @GST_BUFFER_FLAG_HEADER: the buffer contains header information that is - * needed to decode the following data. The buffer - * is also part of the headers of the STREAM_CONFIG event. + * needed to decode the following data. * @GST_BUFFER_FLAG_GAP: the buffer has been created to fill a gap in the * stream and contains media neutral data (elements can * switch to optimized code path that ignores the buffer @@ -195,6 +192,8 @@ typedef struct _GstBufferPool GstBufferPool; * @GST_BUFFER_FLAG_DROPPABLE: the buffer can be dropped without breaking the * stream, for example to reduce bandwidth. * @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently. + * @GST_BUFFER_FLAG_TAG_MEMORY: this flag is set when memory of the buffer + * is added/removed * @GST_BUFFER_FLAG_LAST: additional media specific flags can be added starting from * this flag. * @@ -211,6 +210,7 @@ typedef enum { GST_BUFFER_FLAG_GAP = (GST_MINI_OBJECT_FLAG_LAST << 7), GST_BUFFER_FLAG_DROPPABLE = (GST_MINI_OBJECT_FLAG_LAST << 8), GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 9), + GST_BUFFER_FLAG_TAG_MEMORY = (GST_MINI_OBJECT_FLAG_LAST << 10), GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16) } GstBufferFlags; @@ -256,6 +256,8 @@ struct _GstBuffer { GType gst_buffer_get_type (void); +guint gst_buffer_get_max_memory (void); + /* allocation */ GstBuffer * gst_buffer_new (void); GstBuffer * gst_buffer_new_allocate (GstAllocator * allocator, gsize size, @@ -266,24 +268,27 @@ GstBuffer * gst_buffer_new_wrapped_full (GstMemoryFlags flags, gpointer data, GstBuffer * gst_buffer_new_wrapped (gpointer data, gsize size); /* memory blocks */ -guint gst_buffer_n_memory (GstBuffer *buffer); -void gst_buffer_take_memory (GstBuffer *buffer, gint idx, GstMemory *mem); -void gst_buffer_replace_memory (GstBuffer *buffer, gint idx, GstMemory *mem); -GstMemory * gst_buffer_get_memory (GstBuffer *buffer, gint idx); -void gst_buffer_remove_memory_range (GstBuffer *buffer, guint idx, gint length); - -#define gst_buffer_append_memory(b,m) gst_buffer_take_memory ((b), -1, (m)) -#define gst_buffer_replace_all_memory(b,m) gst_buffer_replace_memory ((b), -1, (m)) -#define gst_buffer_get_merged_memory(b) gst_buffer_get_memory ((b), -1) -/** - * gst_buffer_remove_memory: - * @b: a #GstBuffer. - * @i: an index - * - * Remove the memory block in @b at @i. - */ -#define gst_buffer_remove_memory(b,i) gst_buffer_remove_memory_range ((b), (i), 1) -#define gst_buffer_remove_all_memory(b) gst_buffer_remove_memory_range ((b), 0, -1) +guint gst_buffer_n_memory (GstBuffer *buffer); +void gst_buffer_insert_memory (GstBuffer *buffer, gint idx, GstMemory *mem); +void gst_buffer_replace_memory_range (GstBuffer *buffer, guint idx, gint length, GstMemory *mem); +GstMemory * gst_buffer_peek_memory (GstBuffer *buffer, guint idx); +GstMemory * gst_buffer_get_memory_range (GstBuffer *buffer, guint idx, gint length); +void gst_buffer_remove_memory_range (GstBuffer *buffer, guint idx, gint length); + +void gst_buffer_prepend_memory (GstBuffer *buffer, GstMemory *mem); +void gst_buffer_append_memory (GstBuffer *buffer, GstMemory *mem); +void gst_buffer_replace_memory (GstBuffer *buffer, guint idx, GstMemory *mem); +void gst_buffer_replace_all_memory (GstBuffer *buffer, GstMemory *mem); +GstMemory * gst_buffer_get_memory (GstBuffer *buffer, guint idx); +GstMemory * gst_buffer_get_all_memory (GstBuffer *buffer); +void gst_buffer_remove_memory (GstBuffer *buffer, guint idx); +void gst_buffer_remove_all_memory (GstBuffer *buffer); + +gboolean gst_buffer_find_memory (GstBuffer *buffer, gsize offset, gsize size, + guint *idx, guint *length, gsize *skip); + +gboolean gst_buffer_is_memory_range_writable (GstBuffer *buffer, guint idx, gint length); +gboolean gst_buffer_is_all_memory_writable (GstBuffer *buffer); gsize gst_buffer_fill (GstBuffer *buffer, gsize offset, gconstpointer src, gsize size); @@ -294,28 +299,24 @@ gint gst_buffer_memcmp (GstBuffer *buffer, gsize offset, gsize gst_buffer_memset (GstBuffer *buffer, gsize offset, guint8 val, gsize size); +gsize gst_buffer_get_sizes_range (GstBuffer *buffer, guint idx, gint length, + gsize *offset, gsize *maxsize); +gboolean gst_buffer_resize_range (GstBuffer *buffer, guint idx, gint length, + gssize offset, gssize size); + gsize gst_buffer_get_sizes (GstBuffer *buffer, gsize *offset, gsize *maxsize); +gsize gst_buffer_get_size (GstBuffer *buffer); void gst_buffer_resize (GstBuffer *buffer, gssize offset, gssize size); +void gst_buffer_set_size (GstBuffer *buffer, gssize size); -/** - * gst_buffer_get_size: - * @b: a #GstBuffer. - * - * Get the size of @b. - */ -#define gst_buffer_get_size(b) gst_buffer_get_sizes ((b), NULL, NULL) -/** - * gst_buffer_set_size: - * @b: a #GstBuffer. - * @s: a new size - * - * Set the size of @b to @s. This will remove or trim the memory blocks - * in the buffer. - */ -#define gst_buffer_set_size(b,s) gst_buffer_resize ((b), 0, (s)) - +gboolean gst_buffer_map_range (GstBuffer *buffer, guint idx, gint length, + GstMapInfo *info, GstMapFlags flags); gboolean gst_buffer_map (GstBuffer *buffer, GstMapInfo *info, GstMapFlags flags); + void gst_buffer_unmap (GstBuffer *buffer, GstMapInfo *info); +void gst_buffer_extract_dup (GstBuffer *buffer, gsize offset, + gsize size, gpointer *dest, + gsize *dest_size); /* refcounting */ /** @@ -324,10 +325,9 @@ void gst_buffer_unmap (GstBuffer *buffer, GstMapInfo *info) * * Increases the refcount of the given buffer by one. * - * Note that the refcount affects the writeability - * of @buf and its metadata, see gst_buffer_is_writable() and - * gst_buffer_is_metadata_writable(). It is - * important to note that keeping additional references to + * Note that the refcount affects the writability + * of @buf and its metadata, see gst_buffer_is_writable(). + * It is important to note that keeping additional references to * GstBuffer instances can potentially increase the number * of memcpy operations in a pipeline. * @@ -386,13 +386,17 @@ gst_buffer_copy (const GstBuffer * buf) * @GST_BUFFER_COPY_NONE: copy nothing * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer pts, dts, - * duration, offset and offset_end should be copied - * @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be copied - * and appended to already existing memory + * duration, offset and offset_end should be copied + * @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be reffed + * and appended to already existing memory. Unless the memory is marked as + * NO_SHARE, no actual copy of the memory is made but it is simply reffed. + * Add @GST_BUFFER_COPY_DEEP to force a real copy. * @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be - * merged + * merged * @GST_BUFFER_COPY_META: flag indicating that buffer meta should be - * copied + * copied + * @GST_BUFFER_COPY_DEEP: flag indicating that memory should always be + * copied instead of reffed (Since 1.2) * * A set of flags that can be provided to the gst_buffer_copy_into() * function to specify which items should be copied. @@ -403,7 +407,8 @@ typedef enum { GST_BUFFER_COPY_TIMESTAMPS = (1 << 1), GST_BUFFER_COPY_META = (1 << 2), GST_BUFFER_COPY_MEMORY = (1 << 3), - GST_BUFFER_COPY_MERGE = (1 << 4) + GST_BUFFER_COPY_MERGE = (1 << 4), + GST_BUFFER_COPY_DEEP = (1 << 5) } GstBufferCopyFlags; /** @@ -424,7 +429,7 @@ typedef enum { #define GST_BUFFER_COPY_ALL ((GstBufferCopyFlags)(GST_BUFFER_COPY_METADATA | GST_BUFFER_COPY_MEMORY)) /* copies memory or metadata into newly allocated buffer */ -void gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src, +gboolean gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src, GstBufferCopyFlags flags, gsize offset, gsize size); @@ -432,10 +437,9 @@ void gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src * gst_buffer_is_writable: * @buf: a #GstBuffer * - * Tests if you can safely write data into a buffer's data array or validly - * modify the caps and timestamp metadata. Metadata in a GstBuffer is always - * writable, but it is only safe to change it when there is only one owner - * of the buffer - ie, the refcount is 1. + * Tests if you can safely write to a buffer's metadata or its memory array. + * It is only safe to change buffer metadata when the current reference is + * writable, i.e. nobody can see the modifications you will make. */ #define gst_buffer_is_writable(buf) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (buf)) /** @@ -463,9 +467,9 @@ void gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src * in some cases), and the reference counts are updated appropriately (the old * buffer is unreffed, the new is reffed). * - * Either @nbuf or the #GstBuffer pointed to by @obuf may be NULL. + * Either @nbuf or the #GstBuffer pointed to by @obuf may be %NULL. * - * Returns: TRUE when @obuf was different from @nbuf. + * Returns: %TRUE when @obuf was different from @nbuf. */ #ifdef _FOOL_GTK_DOC_ G_INLINE_FUNC gboolean gst_buffer_replace (GstBuffer **obuf, GstBuffer *nbuf); @@ -482,13 +486,15 @@ GstBuffer* gst_buffer_copy_region (GstBuffer *parent, GstBufferCop gsize offset, gsize size); /* append two buffers */ +GstBuffer* gst_buffer_append_region (GstBuffer *buf1, GstBuffer *buf2, + gssize offset, gssize size); GstBuffer* gst_buffer_append (GstBuffer *buf1, GstBuffer *buf2); /* metadata */ #include /** - * GstBufferMetaFunc: + * GstBufferForeachMetaFunc: * @buffer: a #GstBuffer * @meta: a pointer to a #GstMeta * @user_data: user data passed to gst_buffer_foreach_meta() @@ -501,7 +507,7 @@ GstBuffer* gst_buffer_append (GstBuffer *buf1, GstBuffer *buf * When this function returns %TRUE, the next meta will be * returned. When %FALSE is returned, gst_buffer_foreach_meta() will return. * - * When @meta is set to NULL, the item will be removed from the buffer. + * When @meta is set to %NULL, the item will be removed from the buffer. * * Returns: %FALSE when gst_buffer_foreach_meta() should stop */ @@ -515,7 +521,7 @@ gboolean gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *met GstMeta * gst_buffer_iterate_meta (GstBuffer *buffer, gpointer *state); -void gst_buffer_foreach_meta (GstBuffer *buffer, +gboolean gst_buffer_foreach_meta (GstBuffer *buffer, GstBufferForeachMetaFunc func, gpointer user_data);