From db787adfa16d0aea219612b326cdd22a5ade436d Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 14 Feb 2020 21:57:34 -0500 Subject: [PATCH] v4l2codec: Add getter for buffer index in allocator and pool --- sys/v4l2codecs/gstv4l2codecallocator.c | 12 ++++++++++++ sys/v4l2codecs/gstv4l2codecallocator.h | 2 ++ sys/v4l2codecs/gstv4l2codecpool.c | 7 +++++++ sys/v4l2codecs/gstv4l2codecpool.h | 2 ++ 4 files changed, 23 insertions(+) diff --git a/sys/v4l2codecs/gstv4l2codecallocator.c b/sys/v4l2codecs/gstv4l2codecallocator.c index d29a5ad..c87f6ae 100644 --- a/sys/v4l2codecs/gstv4l2codecallocator.c +++ b/sys/v4l2codecs/gstv4l2codecallocator.c @@ -323,3 +323,15 @@ gst_v4l2_codec_allocator_detach (GstV4l2CodecAllocator * self) } GST_OBJECT_UNLOCK (self); } + +guint32 +gst_v4l2_codec_memory_get_index (GstMemory * mem) +{ + GstV4l2CodecBuffer *buf; + + buf = gst_mini_object_get_qdata (GST_MINI_OBJECT (mem), + gst_v4l2_codec_buffer_quark ()); + g_return_val_if_fail (buf, G_MAXUINT32); + + return buf->index; +} diff --git a/sys/v4l2codecs/gstv4l2codecallocator.h b/sys/v4l2codecs/gstv4l2codecallocator.h index 62c2332..24cf984 100644 --- a/sys/v4l2codecs/gstv4l2codecallocator.h +++ b/sys/v4l2codecs/gstv4l2codecallocator.h @@ -45,4 +45,6 @@ guint gst_v4l2_codec_allocator_get_pool_size (GstV4l2CodecAllo void gst_v4l2_codec_allocator_detach (GstV4l2CodecAllocator * self); +guint32 gst_v4l2_codec_memory_get_index (GstMemory * mem); + #endif /* _GST_V4L2_CODECS_ALLOCATOR_H_ */ diff --git a/sys/v4l2codecs/gstv4l2codecpool.c b/sys/v4l2codecs/gstv4l2codecpool.c index 5ef9fea..1bab3f2 100644 --- a/sys/v4l2codecs/gstv4l2codecpool.c +++ b/sys/v4l2codecs/gstv4l2codecpool.c @@ -114,3 +114,10 @@ gst_v4l2_codec_pool_new (GstV4l2CodecAllocator * allocator) return pool; } + +guint32 +gst_v4l2_codec_buffer_get_index (GstBuffer * buffer) +{ + GstMemory *mem = gst_buffer_peek_memory (buffer, 0); + return gst_v4l2_codec_memory_get_index (mem); +} diff --git a/sys/v4l2codecs/gstv4l2codecpool.h b/sys/v4l2codecs/gstv4l2codecpool.h index 9468139..aca389b 100644 --- a/sys/v4l2codecs/gstv4l2codecpool.h +++ b/sys/v4l2codecs/gstv4l2codecpool.h @@ -31,4 +31,6 @@ G_DECLARE_FINAL_TYPE(GstV4l2CodecPool, gst_v4l2_codec_pool, GST, GstV4l2CodecPool *gst_v4l2_codec_pool_new (GstV4l2CodecAllocator *allocator); +guint32 gst_v4l2_codec_buffer_get_index (GstBuffer * buffer); + #endif /* __GST_V4L2_CODEC_POOL_H__ */ -- 2.7.4