From patchwork Sat Oct 25 14:22:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 24813 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A1025BE080 for ; Sat, 25 Oct 2025 14:22:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DCF8F606CE; Sat, 25 Oct 2025 16:22:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="D5CG3gq6"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 289AC606B2 for ; Sat, 25 Oct 2025 16:22:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fB2RYBB3K1FhbnWAVYiakd77H5qkqo0kdGb3+iq8Qcs=; b=D5CG3gq6W0VoW0ULN6ktNNe+l+ zAxoC0w8Wcvtqz24GS81Eojy++8ZrhvzCLbFP+Ui8avJEf/DAH9Rv8E4kiL3MwzJZ/QmJFB0aUk6H DRUO3l6gFhgMVMVUSN2/ZSrKJRPLp9G3cjVjo2Z7u8qP19uLHyhn6XLXpuY1hrrD6Tw43mF2i7dxv Y40Ep8wUp7EmD9QsNdxezYHJK0uNmW6abMkDg9/d9KSu+/Cc0X16J3QrgNkwdWzmso1u4+T7zy5hy kH7MYtoilYgBNf9XF/cIGIUm0b0/F5k+UTP7BywMRqxINkW5Qe2SL31fRStZSovu+Q7rJVS8dTZul EmRuXlwg==; Received: from amazon1-vf-gw.lnd.cw.net ([195.89.103.118] helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vCfAE-00F7ub-GJ; Sat, 25 Oct 2025 16:22:38 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: barnabas.pocze@ideasonboard.com, Nicolas Dufresne , Umang Jain Subject: [PATCH v3 1/4] gstreamer: Shorten function name Date: Sat, 25 Oct 2025 15:22:57 +0100 Message-ID: <20251025142300.64480-2-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025142300.64480-1-uajain@igalia.com> References: <20251025142300.64480-1-uajain@igalia.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Shorten the following utility function name: gst_libcamera_stream_configuration_to_caps() to gst_libcamera_stream_cfg_to_caps() Comestic fix only for slight readability enhancement. Signed-off-by: Umang Jain Reviewed-by: Barnabás Pőcze Reviewed-by: Nicolas Dufresne --- src/gstreamer/gstlibcamera-utils.cpp | 4 ++-- src/gstreamer/gstlibcamera-utils.h | 4 ++-- src/gstreamer/gstlibcamerasrc.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index bfb094c9..09f274b5 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -408,8 +408,8 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) } GstCaps * -gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg, - GstVideoTransferFunction transfer) +gst_libcamera_stream_cfg_to_caps(const StreamConfiguration &stream_cfg, + GstVideoTransferFunction transfer) { GstCaps *caps = gst_caps_new_empty(); GstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat); diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h index 35df56fb..06ea9289 100644 --- a/src/gstreamer/gstlibcamera-utils.h +++ b/src/gstreamer/gstlibcamera-utils.h @@ -16,8 +16,8 @@ #include GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &formats); -GstCaps *gst_libcamera_stream_configuration_to_caps(const libcamera::StreamConfiguration &stream_cfg, - GstVideoTransferFunction transfer); +GstCaps *gst_libcamera_stream_cfg_to_caps(const libcamera::StreamConfiguration &stream_cfg, + GstVideoTransferFunction transfer); void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &stream_cfg, GstCaps *caps, GstVideoTransferFunction *transfer); void gst_libcamera_get_framerate_from_caps(GstCaps *caps, GstStructure *element_caps); diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 011a12fc..a1556cc5 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -639,7 +639,7 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self) GstPad *srcpad = state->srcpads_[i]; const StreamConfiguration &stream_cfg = state->config_->at(i); - g_autoptr(GstCaps) caps = gst_libcamera_stream_configuration_to_caps(stream_cfg, transfer[i]); + g_autoptr(GstCaps) caps = gst_libcamera_stream_cfg_to_caps(stream_cfg, transfer[i]); gst_libcamera_framerate_to_caps(caps, element_caps); if (status == CameraConfiguration::Adjusted && @@ -667,7 +667,7 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self) GstBufferPool *video_pool = nullptr; GstVideoInfo info; - g_autoptr(GstCaps) caps = gst_libcamera_stream_configuration_to_caps(stream_cfg, transfer[i]); + g_autoptr(GstCaps) caps = gst_libcamera_stream_cfg_to_caps(stream_cfg, transfer[i]); gst_video_info_from_caps(&info, caps); gst_libcamera_pad_set_video_info(srcpad, &info); From patchwork Sat Oct 25 14:22:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 24816 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 49736C32D4 for ; Sat, 25 Oct 2025 14:22:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8B66D606DB; Sat, 25 Oct 2025 16:22:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="na5O6jPh"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B0DF0606C5 for ; Sat, 25 Oct 2025 16:22:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=erzCrCZ3kCxtERMQLav6bLuT/GZbdQbsinW3ixG1RZw=; b=na5O6jPhiE/kMoCvibWniA1OBg hcYkqGRF3B0SS/qSD8/EX4L/wOQyhjAV3ZQhwwxwo1GWRC1LqJ9j9I8Zq+pJGZdrBHNoSI7a9BAFg 4R6pTOvkDmMSus+F8ROtRXZVxuKWPnYVdTLi4vIUaQhNy0aKeUoaBW+HZhr6Agx4jPJkqA6bgUUVL 0gdodTk2KrW/eLK05yA6HLpWpscFbl3CFJMEDvwg65MuTkz15LZwiHhsEOB+KRb3n9ps26tbsLxf0 9LyLQWP9xei4RMZbddUlZwEwBc8W6IWcpuhlqjtMcWj8SsuTp8iMhoRa6xTSr3Npx2y7g/0ZA0ARn OFuD3JXQ==; Received: from amazon1-vf-gw.lnd.cw.net ([195.89.103.118] helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vCfAE-00F7ub-RJ; Sat, 25 Oct 2025 16:22:38 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: barnabas.pocze@ideasonboard.com, Nicolas Dufresne , Umang Jain Subject: [PATCH v3 2/4] gstreamer: Associate libcamera::Stream with Pad Date: Sat, 25 Oct 2025 15:22:58 +0100 Message-ID: <20251025142300.64480-3-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025142300.64480-1-uajain@igalia.com> References: <20251025142300.64480-1-uajain@igalia.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Instead of trying to figure out which libcamera::Stream, the GstPad is configured with (from the libcamera pool), associate the Stream with the GstPad directly. The association can be set using gst_pad_set_element_private(). Adjust the gst_libcamera_pad_get_stream() to use to complementary getter gst_pad_get_element_private(). Signed-off-by: Umang Jain --- src/gstreamer/gstlibcamerapad.cpp | 7 +------ src/gstreamer/gstlibcamerasrc.cpp | 6 +++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp index 22b96719..90738489 100644 --- a/src/gstreamer/gstlibcamerapad.cpp +++ b/src/gstreamer/gstlibcamerapad.cpp @@ -192,12 +192,7 @@ void gst_libcamera_pad_set_video_info(GstPad *pad, const GstVideoInfo *info) 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; + return static_cast(gst_pad_get_element_private(pad)); } void diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a1556cc5..a3c48b1d 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -357,7 +357,7 @@ int GstLibcameraSrcState::processRequest() GstBuffer *buffer = wrap->detachBuffer(stream); FrameBuffer *fb = gst_libcamera_buffer_get_frame_buffer(buffer); - const StreamConfiguration &stream_cfg = config_->at(i); + const StreamConfiguration &stream_cfg = stream->configuration(); GstBufferPool *video_pool = gst_libcamera_pad_get_video_pool(srcpad); if (video_pool) { @@ -692,6 +692,9 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self) gst_libcamera_pad_set_pool(srcpad, pool); gst_libcamera_pad_set_video_pool(srcpad, video_pool); + /* Associate the configured stream with the src pad. */ + gst_pad_set_element_private(srcpad, stream_cfg.stream()); + /* Clear all reconfigure flags. */ gst_pad_check_reconfigure(srcpad); } @@ -888,6 +891,7 @@ gst_libcamera_src_task_leave([[maybe_unused]] GstTask *task, for (GstPad *srcpad : state->srcpads_) { gst_libcamera_pad_set_latency(srcpad, GST_CLOCK_TIME_NONE); gst_libcamera_pad_set_pool(srcpad, nullptr); + gst_pad_set_element_private(srcpad, nullptr); } } From patchwork Sat Oct 25 14:22:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 24814 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1F5E0BE080 for ; Sat, 25 Oct 2025 14:22:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34B76606F4; Sat, 25 Oct 2025 16:22:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="QLON1qQF"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0AFAF606CE for ; Sat, 25 Oct 2025 16:22:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=R4MLtg5PPjEyIy4KbFQpP4VfaWWwsFFOPsSHhn6kb7U=; b=QLON1qQFzQQz7jQrfHFA35as0s DuPifGUS7gOff0LO590FKEAglhwjgkaoDSyKbThu1pCTS16CVuGy4wpEnYNKzBj9GGqQUEEruMy7z i6xWIiGbXTISMvbxJCLrNX3Zsc1LocMSKQRXvYWL5QJFY2wNl305cBVrkUZ3/57c7mTERzFyqfqGU Ye2osV/OJB7mcDvQBVK8nTh0wrFQtJS2fIMg5lbwUxHCFXK6sOSkhXL2OGRz/AV0iu0uaW3m7i7Wj 83+VFCGXFGfz1e61UkV9KoELkrwyNAlnbYJtiuUUTYqaYDDlqCfaVagdG2qmfTeLPhA4xiuWeJBvs CsrY16kQ==; Received: from amazon1-vf-gw.lnd.cw.net ([195.89.103.118] helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vCfAF-00F7ub-5l; Sat, 25 Oct 2025 16:22:39 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: barnabas.pocze@ideasonboard.com, Nicolas Dufresne , Umang Jain Subject: [PATCH v3 3/4] gstreamer: Improve logging for buffer pool activation Date: Sat, 25 Oct 2025 15:22:59 +0100 Message-ID: <20251025142300.64480-4-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025142300.64480-1-uajain@igalia.com> References: <20251025142300.64480-1-uajain@igalia.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the negotiation is going to fail, log the GST_ELEMENT_ERROR in gst_libcamera_src_negotiate(), instead of logging in downstream method chain. Signed-off-by: Umang Jain Reviewed-by: Nicolas Dufresne Reviewed-by: Barnabás Pőcze --- src/gstreamer/gstlibcamerasrc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a3c48b1d..7bf42be2 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -575,9 +575,7 @@ gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad, } if (!gst_buffer_pool_set_active(pool, true)) { - GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS, - ("Failed to active buffer pool"), - ("gst_libcamera_src_negotiate() failed.")); + GST_ERROR_OBJECT(self, "Failed to activate buffer pool."); return { nullptr, -EINVAL }; } @@ -680,8 +678,12 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self) std::tie(video_pool, ret) = gst_libcamera_create_video_pool(self, srcpad, caps, &info); - if (ret) + if (ret) { + GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS, + ("Failed to create video pool: %s", g_strerror(-ret)), + ("gst_libcamera_src_negotiate() failed.")); return false; + } } GstLibcameraPool *pool = gst_libcamera_pool_new(self->allocator, From patchwork Sat Oct 25 14:23:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 24815 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C9F50C32CE for ; Sat, 25 Oct 2025 14:22:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77627606F8; Sat, 25 Oct 2025 16:22:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="dqXtMd1m"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 45004606CF for ; Sat, 25 Oct 2025 16:22:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+/WAzMSdmfSQ8a+q1c0ndIBPdKevgBxECBUuNP6wYHI=; b=dqXtMd1mjcetft+z7+NLXkklon caD11WE0aIQE0ohcvBTtLZMLIv+FzMvPYWk7BW46Wc3QW1CDOGEiznXdehRZGNaALQoQkLiqfhv6m 9YGo7/pIIsjEjC/QNac1zE0gKOqaCcKAkU1puVA5nZ9Ty9jLer33aY7mMdFaBGfsAVRuMYu59mdik MHhivLLM1w0v8Sb6THn2/YJiXvw+MB7b3nuJY7v9pHB0wLTUb5IPjckkyeKgyXy+rhk/OI5qzxZFr TkpjnGUua/gNomCU2AkExbyZ/fX3CzWMRaTZD8APAMy3SmmesC+13aNjP0vAu6sa+2uTsvrnHtxna bm+tS7lA==; Received: from amazon1-vf-gw.lnd.cw.net ([195.89.103.118] helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vCfAF-00F7ub-GX; Sat, 25 Oct 2025 16:22:39 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: barnabas.pocze@ideasonboard.com, Nicolas Dufresne , Umang Jain Subject: [PATCH v3 4/4] gstreamer: Track RequestWrap's GstBuffer using GstPad Date: Sat, 25 Oct 2025 15:23:00 +0100 Message-ID: <20251025142300.64480-5-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025142300.64480-1-uajain@igalia.com> References: <20251025142300.64480-1-uajain@igalia.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" GstPad is the link point where the buffers are pushed/pulled in the gstreamer pipeline hence, it makes more sense to associate and track GstBuffer(s) using GstPad rather than libcamera::Stream in RequestWrap. No functional changes intended as there is only one stream per pad configuration followed in libcamerasrc. Signed-off-by: Umang Jain --- src/gstreamer/gstlibcamerasrc.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 7bf42be2..5ca9e3b9 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -48,11 +48,11 @@ struct RequestWrap { RequestWrap(std::unique_ptr request); ~RequestWrap(); - void attachBuffer(Stream *stream, GstBuffer *buffer); - GstBuffer *detachBuffer(Stream *stream); + void attachBuffer(GstPad *srcpad, GstBuffer *buffer); + GstBuffer *detachBuffer(GstPad *srcpad); std::unique_ptr request_; - std::map buffers_; + std::map buffers_; GstClockTime latency_; GstClockTime pts_; @@ -65,32 +65,33 @@ RequestWrap::RequestWrap(std::unique_ptr request) RequestWrap::~RequestWrap() { - for (std::pair &item : buffers_) { + for (std::pair &item : buffers_) { if (item.second) gst_buffer_unref(item.second); } } -void RequestWrap::attachBuffer(Stream *stream, GstBuffer *buffer) +void RequestWrap::attachBuffer(GstPad *srcpad, GstBuffer *buffer) { FrameBuffer *fb = gst_libcamera_buffer_get_frame_buffer(buffer); + Stream *stream = gst_libcamera_pad_get_stream(srcpad); request_->addBuffer(stream, fb); - auto item = buffers_.find(stream); + auto item = buffers_.find(srcpad); if (item != buffers_.end()) { gst_buffer_unref(item->second); item->second = buffer; } else { - buffers_[stream] = buffer; + buffers_[srcpad] = buffer; } } -GstBuffer *RequestWrap::detachBuffer(Stream *stream) +GstBuffer *RequestWrap::detachBuffer(GstPad *srcpad) { GstBuffer *buffer = nullptr; - auto item = buffers_.find(stream); + auto item = buffers_.find(srcpad); if (item != buffers_.end()) { buffer = item->second; item->second = nullptr; @@ -189,7 +190,6 @@ int GstLibcameraSrcState::queueRequest() std::make_unique(std::move(request)); for (GstPad *srcpad : srcpads_) { - Stream *stream = gst_libcamera_pad_get_stream(srcpad); GstLibcameraPool *pool = gst_libcamera_pad_get_pool(srcpad); GstBuffer *buffer; GstFlowReturn ret; @@ -204,7 +204,7 @@ int GstLibcameraSrcState::queueRequest() return -ENOBUFS; } - wrap->attachBuffer(stream, buffer); + wrap->attachBuffer(srcpad, buffer); } GST_TRACE_OBJECT(src_, "Requesting buffers"); @@ -354,7 +354,7 @@ int GstLibcameraSrcState::processRequest() for (gsize i = 0; i < srcpads_.size(); i++) { GstPad *srcpad = srcpads_[i]; Stream *stream = gst_libcamera_pad_get_stream(srcpad); - GstBuffer *buffer = wrap->detachBuffer(stream); + GstBuffer *buffer = wrap->detachBuffer(srcpad); FrameBuffer *fb = gst_libcamera_buffer_get_frame_buffer(buffer); const StreamConfiguration &stream_cfg = stream->configuration();