mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 15:38:53 +00:00
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:
parent
d9aaa15a30
commit
54b6ee0c55
2 changed files with 6 additions and 0 deletions
|
@ -45,6 +45,8 @@ gst_buffer_memory_map (GstBuffer * buffer, GstBufferMemoryMap * map)
|
||||||
map->data = map->map.data;
|
map->data = map->map.data;
|
||||||
map->size = map->map.size;
|
map->size = map->map.size;
|
||||||
map->index = 0;
|
map->index = 0;
|
||||||
|
map->total_size = gst_buffer_get_size (buffer);
|
||||||
|
map->offset = 0;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,8 @@ gst_buffer_memory_advance_bytes (GstBufferMemoryMap * map, gsize size)
|
||||||
|
|
||||||
g_return_val_if_fail (map != NULL, FALSE);
|
g_return_val_if_fail (map != NULL, FALSE);
|
||||||
|
|
||||||
|
map->offset += size;
|
||||||
|
|
||||||
while (offset >= map->size) {
|
while (offset >= map->size) {
|
||||||
offset -= map->size;
|
offset -= map->size;
|
||||||
GST_DEBUG ("switching memory");
|
GST_DEBUG ("switching memory");
|
||||||
|
|
|
@ -32,11 +32,13 @@ struct _GstBufferMemoryMap
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
guint index;
|
guint index;
|
||||||
|
gsize total_size;
|
||||||
|
|
||||||
/* public datas */
|
/* public datas */
|
||||||
|
|
||||||
/* data of the currently mapped memory */
|
/* data of the currently mapped memory */
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
|
guint offset;
|
||||||
|
|
||||||
/* size of the currently mapped memory */
|
/* size of the currently mapped memory */
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
Loading…
Reference in a new issue