From patchwork Wed Jan 29 03:32:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 2754 Return-Path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81E35608C6 for ; Wed, 29 Jan 2020 04:35:44 +0100 (CET) Received: from nicolas-tpx395.localdomain (unknown [IPv6:2002:c0de:c115:0:66fc:8b:2a38:8313]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: nicolas) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6A00328EA9F; Wed, 29 Jan 2020 03:35:42 +0000 (GMT) From: Nicolas Dufresne To: libcamera-devel@lists.libcamera.org Cc: Nicolas Dufresne Date: Tue, 28 Jan 2020 22:32:07 -0500 Message-Id: <20200129033210.278800-21-nicolas@ndufresne.ca> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129033210.278800-1-nicolas@ndufresne.ca> References: <20200129033210.278800-1-nicolas@ndufresne.ca> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 20/23] gst: Add getters for Stream and FrameBuffer X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jan 2020 03:35:44 -0000 From: Nicolas Dufresne This add getters on pad/pool/allocator so that we can retrieve the Stream or FrameBuffer. Signed-off-by: Nicolas Dufresne Reviewed-by: Laurent Pinchart --- src/gstreamer/gstlibcameraallocator.cpp | 9 +++++++++ src/gstreamer/gstlibcameraallocator.h | 2 ++ src/gstreamer/gstlibcamerapad.cpp | 11 +++++++++++ src/gstreamer/gstlibcamerapad.h | 2 ++ src/gstreamer/gstlibcamerapool.cpp | 20 ++++++++++++++++++++ src/gstreamer/gstlibcamerapool.h | 7 +++++++ 6 files changed, 51 insertions(+) diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp index 0f248b4..bdc6de6 100644 --- a/src/gstreamer/gstlibcameraallocator.cpp +++ b/src/gstreamer/gstlibcameraallocator.cpp @@ -238,3 +238,12 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self, return pool->length; } + +FrameBuffer * +gst_libcamera_memory_get_frame_buffer(GstMemory *mem) +{ + gpointer data = gst_mini_object_get_qdata(GST_MINI_OBJECT_CAST(mem), + gst_libcamera_frame_quark()); + auto *frame = (FrameWrap *)data; + return frame->buffer_; +} diff --git a/src/gstreamer/gstlibcameraallocator.h b/src/gstreamer/gstlibcameraallocator.h index f2a0f58..b4de65a 100644 --- a/src/gstreamer/gstlibcameraallocator.h +++ b/src/gstreamer/gstlibcameraallocator.h @@ -26,4 +26,6 @@ bool gst_libcamera_allocator_prepare_buffer(GstLibcameraAllocator *self, gsize gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *allocator, libcamera::Stream *stream); +libcamera::FrameBuffer *gst_libcamera_memory_get_frame_buffer(GstMemory *mem); + #endif /* __GST_LIBCAMERA_ALLOCATOR_H__ */ diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp index b9e6dc5..6401810 100644 --- a/src/gstreamer/gstlibcamerapad.cpp +++ b/src/gstreamer/gstlibcamerapad.cpp @@ -125,3 +125,14 @@ gst_libcamera_pad_set_pool(GstPad *pad, GstLibcameraPool *pool) g_object_unref(self->pool); self->pool = pool; } + +Stream * +gst_libcamera_pad_get_stream(GstPad *pad) +{ + auto *self = GST_LIBCAMERA_PAD(pad); + + if (self->pool) + return gst_libcamera_pool_get_stream(self->pool); + + return nullptr; +} diff --git a/src/gstreamer/gstlibcamerapad.h b/src/gstreamer/gstlibcamerapad.h index 4570c0c..81d0d58 100644 --- a/src/gstreamer/gstlibcamerapad.h +++ b/src/gstreamer/gstlibcamerapad.h @@ -24,4 +24,6 @@ GstLibcameraPool *gst_libcamera_pad_get_pool(GstPad *pad); void gst_libcamera_pad_set_pool(GstPad *pad, GstLibcameraPool *pool); +libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad); + #endif /* __GST_LIBCAMERA_PAD_H__ */ diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp index f84d1d6..6ab01cb 100644 --- a/src/gstreamer/gstlibcamerapool.cpp +++ b/src/gstreamer/gstlibcamerapool.cpp @@ -107,3 +107,23 @@ gst_libcamera_pool_new(GstLibcameraAllocator *allocator, Stream *stream) return pool; } + +Stream * +gst_libcamera_pool_get_stream(GstLibcameraPool *self) +{ + return self->stream; +} + +Stream * +gst_libcamera_buffer_get_stream(GstBuffer *buffer) +{ + auto *self = (GstLibcameraPool *)buffer->pool; + return self->stream; +} + +FrameBuffer * +gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer) +{ + GstMemory *mem = gst_buffer_peek_memory(buffer, 0); + return gst_libcamera_memory_get_frame_buffer(mem); +} diff --git a/src/gstreamer/gstlibcamerapool.h b/src/gstreamer/gstlibcamerapool.h index ca6b299..8cc6cdf 100644 --- a/src/gstreamer/gstlibcamerapool.h +++ b/src/gstreamer/gstlibcamerapool.h @@ -24,4 +24,11 @@ G_DECLARE_FINAL_TYPE(GstLibcameraPool, gst_libcamera_pool, GstLibcameraPool *gst_libcamera_pool_new(GstLibcameraAllocator *allocator, libcamera::Stream *stream); +libcamera::Stream *gst_libcamera_pool_get_stream(GstLibcameraPool *self); + +libcamera::Stream *gst_libcamera_buffer_get_stream(GstBuffer *buffer); + +libcamera::FrameBuffer *gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer); + + #endif /* __GST_LIBCAMERA_POOL_H__ */