From 54b6ee0c55d0a64350dbac52d77785882aa87ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristofer=20Bj=C3=B6rkstr=C3=B6m?= Date: Wed, 1 Apr 2020 13:17:03 +0200 Subject: [PATCH] buffermemory: keep track of buffer size and current offset Added the possibility to get current offset and the total size of the buffer. --- gst/rtp/gstbuffermemory.c | 4 ++++ gst/rtp/gstbuffermemory.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/gst/rtp/gstbuffermemory.c b/gst/rtp/gstbuffermemory.c index 3b28417ba4..d6fd6477f3 100644 --- a/gst/rtp/gstbuffermemory.c +++ b/gst/rtp/gstbuffermemory.c @@ -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"); diff --git a/gst/rtp/gstbuffermemory.h b/gst/rtp/gstbuffermemory.h index cc00d4c1b1..3b78429898 100644 --- a/gst/rtp/gstbuffermemory.h +++ b/gst/rtp/gstbuffermemory.h @@ -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;