buffer: add peek_memory method

Add a peerk_memory method that simply fetches the memory at an offset without
refcounting or merging.
This commit is contained in:
Wim Taymans 2012-03-31 17:10:35 +02:00
parent 3db0ce476f
commit 113b9dc535
3 changed files with 29 additions and 0 deletions

View file

@ -772,6 +772,33 @@ _get_mapped (GstBuffer * buffer, guint idx, GstMapInfo * info,
return mem;
}
/**
* gst_buffer_peek_memory:
* @buffer: a #GstBuffer.
* @idx: an index
*
* Get the memory block at @idx in @buffer. The memory block stays valid until
* the memory block in @buffer is removed, replaced or merged, typically with
* any call that modifies the memory in @buffer.
*
* Since this call does not influence the refcount of the memory,
* gst_memory_is_exclusive() can be used to check if @buffer is the sole owner
* of the returned memory.
*
* Returns: (transfer none): the #GstMemory at @idx.
*/
GstMemory *
gst_buffer_peek_memory (GstBuffer * buffer, guint idx)
{
guint len;
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
len = GST_BUFFER_MEM_LEN (buffer);
g_return_val_if_fail (idx < len, NULL);
return GST_BUFFER_MEM_PTR (buffer, idx);
}
/**
* gst_buffer_get_memory_range:
* @buffer: a #GstBuffer.

View file

@ -269,6 +269,7 @@ GstBuffer * gst_buffer_new_wrapped (gpointer data, gsize size);
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);

View file

@ -120,6 +120,7 @@ EXPORTS
gst_buffer_new_allocate
gst_buffer_new_wrapped
gst_buffer_new_wrapped_full
gst_buffer_peek_memory
gst_buffer_pool_acquire_buffer
gst_buffer_pool_acquire_flags_get_type
gst_buffer_pool_config_add_option