buffer: convert gst_buffer_* macros to functions

GObject Introspection does not support macros.
This is needed for bindings. We can still add back
macros or inline functions again later if we think
it's worth it.

https://bugzilla.gnome.org/show_bug.cgi?id=678301
This commit is contained in:
Evan Nemerson 2012-07-30 21:46:18 -07:00 committed by Tim-Philipp Müller
parent df2312fd6a
commit 237f707c75
2 changed files with 150 additions and 65 deletions

View file

@ -760,20 +760,32 @@ gst_buffer_n_memory (GstBuffer * buffer)
/** /**
* gst_buffer_prepend_memory: * gst_buffer_prepend_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @m: (transfer full): a #GstMemory. * @mem: (transfer full): a #GstMemory.
* *
* Prepend the memory block @m to @b. This function takes ownership * Prepend the memory block @mem to @buffer. This function takes
* of @m and thus doesn't increase its refcount. * ownership of @mem and thus doesn't increase its refcount.
*/ */
void
gst_buffer_prepend_memory (GstBuffer * buffer, GstMemory * mem)
{
gst_buffer_insert_memory (buffer, 0, mem);
}
/** /**
* gst_buffer_append_memory: * gst_buffer_append_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @m: (transfer full): a #GstMemory. * @mem: (transfer full): a #GstMemory.
* *
* Append the memory block @m to @b. This function takes ownership * Append the memory block @mem to @buffer. This function takes
* of @m and thus doesn't increase its refcount. * ownership of @mem and thus doesn't increase its refcount.
*/ */
void
gst_buffer_append_memory (GstBuffer * buffer, GstMemory * mem)
{
gst_buffer_insert_memory (buffer, -1, mem);
}
/** /**
* gst_buffer_insert_memory: * gst_buffer_insert_memory:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -846,17 +858,23 @@ gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
/** /**
* gst_buffer_get_memory: * gst_buffer_get_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @i: an index * @idx: an index
* *
* Get the memory block at index @i in @buffer. * Get the memory block at index @idx in @buffer.
* *
* Returns: (transfer full): a #GstMemory that contains the data of the * Returns: (transfer full): a #GstMemory that contains the data of the
* memory block at @idx. Use gst_memory_unref () after usage. * memory block at @idx. Use gst_memory_unref () after usage.
*/ */
GstMemory *
gst_buffer_get_memory (GstBuffer * buffer, guint idx)
{
return gst_buffer_get_memory_range (buffer, idx, 1);
}
/** /**
* gst_buffer_get_all_memory: * gst_buffer_get_all_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* *
* Get all the memory block in @buffer. The memory blocks will be merged * Get all the memory block in @buffer. The memory blocks will be merged
* into one large #GstMemory. * into one large #GstMemory.
@ -864,6 +882,12 @@ gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
* Returns: (transfer full): a #GstMemory that contains the merged memory. * Returns: (transfer full): a #GstMemory that contains the merged memory.
* Use gst_memory_unref () after usage. * Use gst_memory_unref () after usage.
*/ */
GstMemory *
gst_buffer_get_all_memory (GstBuffer * buffer)
{
return gst_buffer_get_memory_range (buffer, 0, -1);
}
/** /**
* gst_buffer_get_memory_range: * gst_buffer_get_memory_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -898,19 +922,31 @@ gst_buffer_get_memory_range (GstBuffer * buffer, guint idx, gint length)
/** /**
* gst_buffer_replace_memory: * gst_buffer_replace_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @i: an index * @idx: an index
* @m: (transfer full): a #GstMemory * @mem: (transfer full): a #GstMemory
* *
* Replaces the memory block at index @i in @b with @m. * Replaces the memory block at index @idx in @buffer with @mem.
*/ */
void
gst_buffer_replace_memory (GstBuffer * buffer, guint idx, GstMemory * mem)
{
gst_buffer_replace_memory_range (buffer, idx, 1, mem);
}
/** /**
* gst_buffer_replace_all_memory: * gst_buffer_replace_all_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @m: (transfer full): a #GstMemory * @mem: (transfer full): a #GstMemory
* *
* Replaces all memory in @b with @m. * Replaces all memory in @buffer with @mem.
*/ */
void
gst_buffer_replace_all_memory (GstBuffer * buffer, GstMemory * mem)
{
gst_buffer_replace_memory_range (buffer, 0, -1, mem);
}
/** /**
* gst_buffer_replace_memory_range: * gst_buffer_replace_memory_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -948,17 +984,29 @@ gst_buffer_replace_memory_range (GstBuffer * buffer, guint idx, gint length,
/** /**
* gst_buffer_remove_memory: * gst_buffer_remove_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @i: an index * @idx: an index
* *
* Remove the memory block in @b at index @i. * Remove the memory block in @b at index @i.
*/ */
void
gst_buffer_remove_memory (GstBuffer * buffer, guint idx)
{
gst_buffer_remove_memory_range (buffer, idx, 1);
}
/** /**
* gst_buffer_remove_all_memory: * gst_buffer_remove_all_memory:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* *
* Remove all the memory blocks in @b. * Remove all the memory blocks in @buffer.
*/ */
void
gst_buffer_remove_all_memory (GstBuffer * buffer)
{
gst_buffer_remove_memory_range (buffer, 0, -1);
}
/** /**
* gst_buffer_remove_memory_range: * gst_buffer_remove_memory_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -1064,28 +1112,40 @@ gst_buffer_find_memory (GstBuffer * buffer, gsize offset, gsize size,
/** /**
* gst_buffer_get_sizes: * gst_buffer_get_sizes:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @of: (out): a pointer to the offset * @offset: (out): a pointer to the offset
* @ms: (out): a pointer to the maxsize * @maxsize: (out): a pointer to the maxsize
* *
* Get the total size of the memory blocks in @b. * Get the total size of the memory blocks in @b.
* *
* When not %NULL, @of will contain the offset of the data in the first * When not %NULL, @offset will contain the offset of the data in the
* memory block in @buffer and @maxsize will contain the sum of the size * first memory block in @buffer and @maxsize will contain the sum of
* and @of and the amount of extra padding on the last memory block. * the size and @offset and the amount of extra padding on the last
* @of and @ms can be used to resize the buffer memory blocks with * memory block. @offset and @maxsize can be used to resize the
* gst_buffer_resize(). * buffer memory blocks with gst_buffer_resize().
* *
* Returns: total size of the memory blocks in @b. * Returns: total size of the memory blocks in @buffer.
*/ */
gsize
gst_buffer_get_sizes (GstBuffer * buffer, gsize * offset, gsize * maxsize)
{
return gst_buffer_get_sizes_range (buffer, 0, -1, offset, maxsize);
}
/** /**
* gst_buffer_get_size: * gst_buffer_get_size:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* *
* Get the total size of the memory blocks in @b. * Get the total size of the memory blocks in @buffer.
* *
* Returns: total size of the memory blocks in @b. * Returns: total size of the memory blocks in @buffer.
*/ */
gsize
gst_buffer_get_size (GstBuffer * buffer)
{
return gst_buffer_get_sizes_range (buffer, 0, -1, NULL, NULL);
}
/** /**
* gst_buffer_get_sizes_range: * gst_buffer_get_sizes_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -1160,19 +1220,31 @@ gst_buffer_get_sizes_range (GstBuffer * buffer, guint idx, gint length,
/** /**
* gst_buffer_resize: * gst_buffer_resize:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @of: the offset adjustement * @offset: the offset adjustement
* @s: the new size or -1 to just adjust the offset * @size: the new size or -1 to just adjust the offset
* *
* Set the offset and total size of the memory blocks in @b. * Set the offset and total size of the memory blocks in @buffer.
*/ */
void
gst_buffer_resize (GstBuffer * buffer, gssize offset, gssize size)
{
gst_buffer_resize_range (buffer, 0, -1, offset, size);
}
/** /**
* gst_buffer_set_size: * gst_buffer_set_size:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @s: the new size * @size: the new size
* *
* Set the total size of the memory blocks in @b. * Set the total size of the memory blocks in @buffer.
*/ */
void
gst_buffer_set_size (GstBuffer * buffer, gssize size)
{
gst_buffer_resize_range (buffer, 0, -1, 0, size);
}
/** /**
* gst_buffer_resize_range: * gst_buffer_resize_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -1268,25 +1340,32 @@ gst_buffer_resize_range (GstBuffer * buffer, guint idx, gint length,
/** /**
* gst_buffer_map: * gst_buffer_map:
* @b: a #GstBuffer. * @buffer: a #GstBuffer.
* @i: (out): info about the mapping * @info: (out): info about the mapping
* @f: flags for the mapping * @flags: flags for the mapping
* *
* This function fills @i with the #GstMapInfo of all merged memory blocks * This function fills @idx with the #GstMapInfo of all merged memory
* in @buffer. * blocks in @buffer.
* *
* @flags describe the desired access of the memory. When @flags is * @flags describe the desired access of the memory. When @flags is
* #GST_MAP_WRITE, @buffer should be writable (as returned from * #GST_MAP_WRITE, @buffer should be writable (as returned from
* gst_buffer_is_writable()). * gst_buffer_is_writable()).
* *
* When @buffer is writable but the memory isn't, a writable copy will * When @buffer is writable but the memory isn't, a writable copy will
* automatically be created and returned. The readonly copy of the buffer memory * automatically be created and returned. The readonly copy of the
* will then also be replaced with this writable copy. * buffer memory will then also be replaced with this writable copy.
* *
* The memory in @i should be unmapped with gst_buffer_unmap() after usage. * The memory in @idx should be unmapped with gst_buffer_unmap() after
* usage.
* *
* Returns: %TRUE if the map succeeded and @i contains valid data. * Returns: %TRUE if the map succeeded and @idx contains valid data.
*/ */
gboolean
gst_buffer_map (GstBuffer * buffer, GstMapInfo * info, GstMapFlags flags)
{
return gst_buffer_map_range (buffer, 0, -1, info, flags);
}
/** /**
* gst_buffer_map_range: * gst_buffer_map_range:
* @buffer: a #GstBuffer. * @buffer: a #GstBuffer.
@ -1661,6 +1740,12 @@ gst_buffer_copy_region (GstBuffer * buffer, GstBufferCopyFlags flags,
* Returns: (transfer full): the new #GstBuffer that contains the memory * Returns: (transfer full): the new #GstBuffer that contains the memory
* of the two source buffers. * of the two source buffers.
*/ */
GstBuffer *
gst_buffer_append (GstBuffer * buf1, GstBuffer * buf2)
{
return gst_buffer_append_region (buf1, buf2, 0, -1);
}
/** /**
* gst_buffer_append_region: * gst_buffer_append_region:
* @buf1: (transfer full): the first source #GstBuffer to append. * @buf1: (transfer full): the first source #GstBuffer to append.

View file

@ -271,14 +271,14 @@ GstMemory * gst_buffer_peek_memory (GstBuffer *buffer, guint idx);
GstMemory * gst_buffer_get_memory_range (GstBuffer *buffer, guint idx, gint length); 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_remove_memory_range (GstBuffer *buffer, guint idx, gint length);
#define gst_buffer_prepend_memory(b,m) gst_buffer_insert_memory ((b), 0, (m)) void gst_buffer_prepend_memory (GstBuffer *buffer, GstMemory *mem);
#define gst_buffer_append_memory(b,m) gst_buffer_insert_memory ((b), -1, (m)) void gst_buffer_append_memory (GstBuffer *buffer, GstMemory *mem);
#define gst_buffer_replace_memory(b,i,m) gst_buffer_replace_memory_range ((b), (i), 1, (m)) void gst_buffer_replace_memory (GstBuffer *buffer, guint idx, GstMemory *mem);
#define gst_buffer_replace_all_memory(b,m) gst_buffer_replace_memory_range ((b), 0, -1, (m)) void gst_buffer_replace_all_memory (GstBuffer *buffer, GstMemory *mem);
#define gst_buffer_get_memory(b,i) gst_buffer_get_memory_range ((b), (i), 1) GstMemory * gst_buffer_get_memory (GstBuffer *buffer, guint idx);
#define gst_buffer_get_all_memory(b) gst_buffer_get_memory_range ((b), 0, -1) GstMemory * gst_buffer_get_all_memory (GstBuffer *buffer);
#define gst_buffer_remove_memory(b,i) gst_buffer_remove_memory_range ((b), (i), 1) void gst_buffer_remove_memory (GstBuffer *buffer, guint idx);
#define gst_buffer_remove_all_memory(b) gst_buffer_remove_memory_range ((b), 0, -1) void gst_buffer_remove_all_memory (GstBuffer *buffer);
gboolean gst_buffer_find_memory (GstBuffer *buffer, gsize offset, gsize size, gboolean gst_buffer_find_memory (GstBuffer *buffer, gsize offset, gsize size,
guint *idx, guint *length, gsize *skip); guint *idx, guint *length, gsize *skip);
@ -297,14 +297,14 @@ gsize gst_buffer_get_sizes_range (GstBuffer *buffer, guint idx, gint l
void gst_buffer_resize_range (GstBuffer *buffer, guint idx, gint length, void gst_buffer_resize_range (GstBuffer *buffer, guint idx, gint length,
gssize offset, gssize size); gssize offset, gssize size);
#define gst_buffer_get_sizes(b,of,ms) gst_buffer_get_sizes_range ((b), 0, -1, (of), (ms)) gsize gst_buffer_get_sizes (GstBuffer *buffer, gsize *offset, gsize *maxsize);
#define gst_buffer_get_size(b) gst_buffer_get_sizes_range ((b), 0, -1, NULL, NULL) gsize gst_buffer_get_size (GstBuffer *buffer);
#define gst_buffer_resize(b,of,s) gst_buffer_resize_range ((b), 0, -1, (of), (s)) void gst_buffer_resize (GstBuffer *buffer, gssize offset, gssize size);
#define gst_buffer_set_size(b,s) gst_buffer_resize_range ((b), 0, -1, 0, (s)) void gst_buffer_set_size (GstBuffer *buffer, gssize size);
gboolean gst_buffer_map_range (GstBuffer *buffer, guint idx, gint length, gboolean gst_buffer_map_range (GstBuffer *buffer, guint idx, gint length,
GstMapInfo *info, GstMapFlags flags); GstMapInfo *info, GstMapFlags flags);
#define gst_buffer_map(b,i,f) gst_buffer_map_range ((b), 0, -1, (i), (f)) gboolean gst_buffer_map (GstBuffer *buffer, GstMapInfo *info, GstMapFlags flags);
void gst_buffer_unmap (GstBuffer *buffer, GstMapInfo *info); void gst_buffer_unmap (GstBuffer *buffer, GstMapInfo *info);
@ -474,7 +474,7 @@ GstBuffer* gst_buffer_copy_region (GstBuffer *parent, GstBufferCop
/* append two buffers */ /* append two buffers */
GstBuffer* gst_buffer_append_region (GstBuffer *buf1, GstBuffer *buf2, GstBuffer* gst_buffer_append_region (GstBuffer *buf1, GstBuffer *buf2,
gssize offset, gssize size); gssize offset, gssize size);
#define gst_buffer_append(b1,b2) gst_buffer_append_region ((b1), (b2), 0, -1) GstBuffer* gst_buffer_append (GstBuffer *buf1, GstBuffer *buf2);
/* metadata */ /* metadata */
#include <gst/gstmeta.h> #include <gst/gstmeta.h>