From patchwork Mon Oct 13 06:38:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: uajain X-Patchwork-Id: 24609 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 813DDBF415 for ; Mon, 13 Oct 2025 06:38:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 342B460453; Mon, 13 Oct 2025 08:38:09 +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="lJLyW+Ul"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 842C26045C for ; Mon, 13 Oct 2025 08:38:06 +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=S+UfEgWxtxZ1NRta7y9s8lVpYyFQeWqMkWL6rKxu3uo=; b=lJLyW+Ulv3lrJRX4dtaceSyd6M qD7wZYEcyIij7MVtdxZjJNDb3d0BzJUtpF1mO6kM1uwykqxQnh2K5J/0+0le9ZTDhoH7s3hibHh9D 6uehONZciIvQtzxX1bn9IBMTIjRS51XKCZBnV15bKadf/JiMq1LKIdG5TY25R+63mrzrPIJ4t+x9u ZtAsnQXPpNe++s5eSJZ8R+0CaZCs03mxT7OYLLEz5+LiiV/r53Q9CXi7y43mamMlxIlv7j9RMiApR 3fnuPh+vFDfM+rh1V5JeCMZMhEPWmkco1xYvPCEbt3FKpYqv6wOJ4XvuRmBp4aAotl0G0+PPqXZij TIrJMy8w==; Received: from [49.36.127.56] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1v8CC5-008oXX-7j; Mon, 13 Oct 2025 08:38:05 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Nicolas Dufresne , Umang Jain , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2 1/3] gstreamer: Shorten function name Date: Mon, 13 Oct 2025 12:08:18 +0530 Message-ID: <20251013063820.90805-2-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013063820.90805-1-uajain@igalia.com> References: <20251013063820.90805-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 79a025a5..9ff90d9a 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -645,7 +645,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 && @@ -673,7 +673,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 Mon Oct 13 06:38:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: uajain X-Patchwork-Id: 24610 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 830E8BF415 for ; Mon, 13 Oct 2025 06:38:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9769E6045C; Mon, 13 Oct 2025 08:38:10 +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="dLRCid2P"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D35DB603DF for ; Mon, 13 Oct 2025 08:38:07 +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=zg9e/iDn82sZ/bWV8f47tp6S5SdSFAH19Lm5uOjsZmw=; b=dLRCid2PDqE+1XsDdScX4PEITx VftSWUTFF9fnHMFpSCa63qQdkIgEM4IkgmdBKdVqH+Lsfa7QS5bGgj8HojfBxY5KjOq6BFbZjDk+P 7U5DX1lM81rwSNxXfRhaM9wFjFKCSwcuBhLzwpsb3jLO4Zb0AYznyhjr8ECnOInkweoyrFmIiTBiH qisBxpko23fiO2OUFxUKL0a0zt5JXKPvDtHxLpyJve98aV9Kn8IiXpBCS19pSy6N35rXN3S6EWyQT 84dLHepYwbZx3Sn3wcFnKp6B6cbPN9znJQG/bez1l8NZNHGDdlNYIb8cHoj6Sk9HSWJecZR+SMwDX HiJstG6w==; Received: from [49.36.127.56] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1v8CC6-008oXX-Kn; Mon, 13 Oct 2025 08:38:07 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Nicolas Dufresne , Umang Jain Subject: [PATCH v2 2/3] gstreamer: Associate libcamera::Stream with Pad Date: Mon, 13 Oct 2025 12:08:19 +0530 Message-ID: <20251013063820.90805-3-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013063820.90805-1-uajain@igalia.com> References: <20251013063820.90805-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 9ff90d9a..07bb6b2f 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -363,7 +363,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) { @@ -698,6 +698,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); } @@ -894,6 +897,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 Mon Oct 13 06:38:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: uajain X-Patchwork-Id: 24611 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 ECCCFC3264 for ; Mon, 13 Oct 2025 06:38:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5046960464; Mon, 13 Oct 2025 08:38:12 +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="UjHpDvF0"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C44960464 for ; Mon, 13 Oct 2025 08:38:09 +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=ZVKL58T9bvVnSUeAwCdECV612uFHvtauHHtjmYzpxhs=; b=UjHpDvF0Rg30arNn+DKyP39zx+ G/DYXcpDIl7J8zSFGV66h7EeZFiBa0K5zmMikovP1oNcUxwXOHFEZewOZLkVyoMEsOFQiy4vfd20j ySzgoWD4zG1kBxKCO5JEE8Mlh/TgYt7yaqpnIjIe/ApEqSdXTGUxP+9uauOPlxibZBw/K5b5+Zvwx 1DhXDeZu5jw+Ulf9545E4mqhtpOKyYFE9FdCpZIzYwD8rLtFlhXf6wcfN4qiXwODBO/85ytzLVL/A gpwoXiJ8RRR8FKBLCmfUNMcGKbHOMdiVedh+/BQWv9wRBbBqx92PtpFnbi2adBn65XXaL1aKhZwDH GeQNWNHg==; Received: from [49.36.127.56] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1v8CC8-008oXX-1n; Mon, 13 Oct 2025 08:38:08 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Nicolas Dufresne , Umang Jain Subject: [PATCH v2 3/3] gstreamer: Improve logging for buffer pool activation Date: Mon, 13 Oct 2025 12:08:20 +0530 Message-ID: <20251013063820.90805-4-uajain@igalia.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013063820.90805-1-uajain@igalia.com> References: <20251013063820.90805-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 07bb6b2f..75e0864c 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -581,9 +581,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("Failed to activate buffer pool"); return { nullptr, -EINVAL }; } @@ -686,8 +684,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,