From patchwork Thu Feb 27 20:04:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 2902 Return-Path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A5946273C for ; Thu, 27 Feb 2020 21:04:27 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id EE40729654A From: Nicolas Dufresne To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Feb 2020 15:04:00 -0500 Message-Id: <20200227200407.490616-21-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200227200407.490616-1-nicolas.dufresne@collabora.com> References: <20200227200407.490616-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 20/27] 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: Thu, 27 Feb 2020 20:04:30 -0000 This adds 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 | 8 ++++++++ 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 +++++++ src/gstreamer/gstlibcamerasrc.cpp | 1 - 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp index f268561..f87b52c 100644 --- a/src/gstreamer/gstlibcameraallocator.cpp +++ b/src/gstreamer/gstlibcameraallocator.cpp @@ -242,3 +242,11 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self, return pool->length; } + +FrameBuffer * +gst_libcamera_memory_get_frame_buffer(GstMemory *mem) +{ + auto *frame = reinterpret_cast(gst_mini_object_get_qdata(GST_MINI_OBJECT_CAST(mem), + FrameWrap::getQuark())); + return frame->buffer_; +} diff --git a/src/gstreamer/gstlibcameraallocator.h b/src/gstreamer/gstlibcameraallocator.h index 25cbf85..8839040 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 c4c466d..4f96546 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 ee106a7..f85c3aa 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 a764c75..6fd2913 100644 --- a/src/gstreamer/gstlibcamerapool.h +++ b/src/gstreamer/gstlibcamerapool.h @@ -23,4 +23,11 @@ G_DECLARE_FINAL_TYPE(GstLibcameraPool, gst_libcamera_pool, 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__ */ diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index fa9ff5b..83f93cc 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -256,7 +256,6 @@ gst_libcamera_src_task_leave(GstTask *task, GThread *thread, gpointer user_data) GstLibcameraSrcState *state = self->state; GST_DEBUG_OBJECT(self, "Streaming thread is about to stop"); - state->cam->stop(); for (GstPad *srcpad : state->srcpads) gst_libcamera_pad_set_pool(srcpad, NULL);