adapter: Adapt gst_adapter_copy() for bindings

This is done by introducing a new gst_adapter_copy_bytes() call that
returns a GBytes structure.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=725476
This commit is contained in:
Sebastian Rasmussen 2014-03-01 23:18:44 +01:00 committed by Sebastian Dröge
parent a6cd61b86a
commit 3de939cb5b
4 changed files with 31 additions and 1 deletions

View file

@ -159,6 +159,7 @@ gst_adapter_push
gst_adapter_map
gst_adapter_unmap
gst_adapter_copy
gst_adapter_copy_bytes
gst_adapter_flush
gst_adapter_available
gst_adapter_available_fast

View file

@ -526,7 +526,7 @@ gst_adapter_unmap (GstAdapter * adapter)
}
/**
* gst_adapter_copy:
* gst_adapter_copy: (skip)
* @adapter: a #GstAdapter
* @dest: (out caller-allocates) (array length=size) (element-type guint8):
* the memory to copy into
@ -550,6 +550,32 @@ gst_adapter_copy (GstAdapter * adapter, gpointer dest, gsize offset, gsize size)
copy_into_unchecked (adapter, dest, offset + adapter->skip, size);
}
/**
* gst_adapter_copy_bytes:
* @adapter: a #GstAdapter
* @offset: the bytes offset in the adapter to start from
* @size: the number of bytes to copy
*
* Similar to gst_adapter_copy, but more suitable for language bindings. @size
* bytes of data starting at @offset will be copied out of the buffers contained
* in @adapter and into a new #GBytes structure which is returned. Depending on
* the value of the @size argument an empty #GBytes structure may be returned.
*
* Returns: (transfer full): A new #GBytes structure containing the copied data.
*
* Rename to: gst_adapter_copy
*
* Since: 1.4
*/
GBytes *
gst_adapter_copy_bytes (GstAdapter * adapter, gsize offset, gsize size)
{
gpointer data;
data = g_malloc (size);
gst_adapter_copy (adapter, data, offset, size);
return g_bytes_new_take (data, size);
}
/*Flushes the first @flush bytes in the @adapter*/
static void
gst_adapter_flush_unchecked (GstAdapter * adapter, gsize flush)

View file

@ -56,6 +56,8 @@ gconstpointer gst_adapter_map (GstAdapter *adapter, gs
void gst_adapter_unmap (GstAdapter *adapter);
void gst_adapter_copy (GstAdapter *adapter, gpointer dest,
gsize offset, gsize size);
GBytes * gst_adapter_copy_bytes (GstAdapter *adapter,
gsize offset, gsize size);
void gst_adapter_flush (GstAdapter *adapter, gsize flush);
gpointer gst_adapter_take (GstAdapter *adapter, gsize nbytes);
GstBuffer* gst_adapter_take_buffer (GstAdapter *adapter, gsize nbytes);

View file

@ -3,6 +3,7 @@ EXPORTS
gst_adapter_available_fast
gst_adapter_clear
gst_adapter_copy
gst_adapter_copy_bytes
gst_adapter_flush
gst_adapter_get_type
gst_adapter_map