buffermemory: keep track of buffer size and current offset

Added the possibility to get current offset and the total size of the
buffer.
This commit is contained in:
Kristofer Björkström 2020-04-01 13:17:03 +02:00
parent d9aaa15a30
commit 54b6ee0c55
2 changed files with 6 additions and 0 deletions

View file

@ -45,6 +45,8 @@ gst_buffer_memory_map (GstBuffer * buffer, GstBufferMemoryMap * map)
map->data = map->map.data;
map->size = map->map.size;
map->index = 0;
map->total_size = gst_buffer_get_size (buffer);
map->offset = 0;
return TRUE;
}
@ -90,6 +92,8 @@ gst_buffer_memory_advance_bytes (GstBufferMemoryMap * map, gsize size)
g_return_val_if_fail (map != NULL, FALSE);
map->offset += size;
while (offset >= map->size) {
offset -= map->size;
GST_DEBUG ("switching memory");

View file

@ -32,11 +32,13 @@ struct _GstBufferMemoryMap
GstMemory *mem;
GstMapInfo map;
guint index;
gsize total_size;
/* public datas */
/* data of the currently mapped memory */
const guint8 *data;
guint offset;
/* size of the currently mapped memory */
gsize size;