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); } }