[{"id":36676,"web_url":"https://patchwork.libcamera.org/comment/36676/","msgid":"<8079ce851afcda757a8066d9fb38c239c1ea6def.camel@collabora.com>","date":"2025-11-04T13:40:08","subject":"Re: [PATCH v4 1/3] gstreamer: Associate libcamera::Stream with\n\tGstPad","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Le lundi 03 novembre 2025 à 21:30 +0000, Umang Jain a écrit :\n> Instead of trying to figure out which libcamera::Stream, the GstPad\n> is configured with (from the libcamera pool), associate the Stream\n> with the GstPad directly. The association can be set using\n> gst_pad_set_element_private().\n> \n> Add the gst_libcamera_pad_set_stream() helper to associate the stream\n> with the pad. Additionally, modify the gst_libcamera_pad_get_stream()\n> to use to the getter helper gst_pad_get_element_private().\n> \n> Signed-off-by: Umang Jain <uajain@igalia.com>\n\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\n> ---\n>  src/gstreamer/gstlibcamerapad.cpp | 11 ++++++-----\n>  src/gstreamer/gstlibcamerapad.h   |  2 ++\n>  src/gstreamer/gstlibcamerasrc.cpp |  6 +++++-\n>  3 files changed, 13 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/gstreamer/gstlibcamerapad.cpp\n> b/src/gstreamer/gstlibcamerapad.cpp\n> index 22b96719..b37c4b34 100644\n> --- a/src/gstreamer/gstlibcamerapad.cpp\n> +++ b/src/gstreamer/gstlibcamerapad.cpp\n> @@ -192,12 +192,13 @@ void gst_libcamera_pad_set_video_info(GstPad *pad, const\n> GstVideoInfo *info)\n>  Stream *\n>  gst_libcamera_pad_get_stream(GstPad *pad)\n>  {\n> -\tauto *self = GST_LIBCAMERA_PAD(pad);\n> -\n> -\tif (self->pool)\n> -\t\treturn gst_libcamera_pool_get_stream(self->pool);\n> +\treturn static_cast<Stream *>(gst_pad_get_element_private(pad));\n> +}\n>  \n> -\treturn nullptr;\n> +void\n> +gst_libcamera_pad_set_stream(GstPad *pad, Stream *stream)\n> +{\n> +\tgst_pad_set_element_private(pad, stream);\n>  }\n>  \n>  void\n> diff --git a/src/gstreamer/gstlibcamerapad.h b/src/gstreamer/gstlibcamerapad.h\n> index f98b8a7f..bbd7c687 100644\n> --- a/src/gstreamer/gstlibcamerapad.h\n> +++ b/src/gstreamer/gstlibcamerapad.h\n> @@ -33,4 +33,6 @@ void gst_libcamera_pad_set_video_info(GstPad *pad, const\n> GstVideoInfo *info);\n>  \n>  libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad);\n>  \n> +void gst_libcamera_pad_set_stream(GstPad *pad, libcamera::Stream *stream);\n> +\n>  void gst_libcamera_pad_set_latency(GstPad *pad, GstClockTime latency);\n> diff --git a/src/gstreamer/gstlibcamerasrc.cpp\n> b/src/gstreamer/gstlibcamerasrc.cpp\n> index 011a12fc..bd79b769 100644\n> --- a/src/gstreamer/gstlibcamerasrc.cpp\n> +++ b/src/gstreamer/gstlibcamerasrc.cpp\n> @@ -357,7 +357,7 @@ int GstLibcameraSrcState::processRequest()\n>  \t\tGstBuffer *buffer = wrap->detachBuffer(stream);\n>  \n>  \t\tFrameBuffer *fb =\n> gst_libcamera_buffer_get_frame_buffer(buffer);\n> -\t\tconst StreamConfiguration &stream_cfg = config_->at(i);\n> +\t\tconst StreamConfiguration &stream_cfg = stream-\n> >configuration();\n>  \t\tGstBufferPool *video_pool =\n> gst_libcamera_pad_get_video_pool(srcpad);\n>  \n>  \t\tif (video_pool) {\n> @@ -692,6 +692,9 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self)\n>  \t\tgst_libcamera_pad_set_pool(srcpad, pool);\n>  \t\tgst_libcamera_pad_set_video_pool(srcpad, video_pool);\n>  \n> +\t\t/* Associate the configured stream with the source pad. */\n> +\t\tgst_libcamera_pad_set_stream(srcpad, stream_cfg.stream());\n> +\n>  \t\t/* Clear all reconfigure flags. */\n>  \t\tgst_pad_check_reconfigure(srcpad);\n>  \t}\n> @@ -888,6 +891,7 @@ gst_libcamera_src_task_leave([[maybe_unused]] GstTask\n> *task,\n>  \t\tfor (GstPad *srcpad : state->srcpads_) {\n>  \t\t\tgst_libcamera_pad_set_latency(srcpad,\n> GST_CLOCK_TIME_NONE);\n>  \t\t\tgst_libcamera_pad_set_pool(srcpad, nullptr);\n> +\t\t\tgst_libcamera_pad_set_stream(srcpad, nullptr);\n>  \t\t}\n>  \t}\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BE3E7BDE4C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Nov 2025 13:40:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 725146069A;\n\tTue,  4 Nov 2025 14:40:13 +0100 (CET)","from bali.collaboradmins.com (bali.collaboradmins.com\n\t[IPv6:2a01:4f8:201:9162::2])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F1C56069A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Nov 2025 14:40:11 +0100 (CET)","from [IPv6:2606:6d00:17:ebd3::5ac] (unknown\n\t[IPv6:2606:6d00:17:ebd3::5ac])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby bali.collaboradmins.com (Postfix) with ESMTPSA id 5572817E12AA;\n\tTue,  4 Nov 2025 14:40:10 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=collabora.com header.i=@collabora.com\n\theader.b=\"cdsO0A8x\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com;\n\ts=mail; t=1762263610;\n\tbh=6cvuV5kOoKcT8mRi1O/rAJY+4wYQ4lmC4aJJ8iH0scc=;\n\th=Subject:From:To:Date:In-Reply-To:References:From;\n\tb=cdsO0A8xZdt4CJfSNgibMrINwVyy71wG+omy0BxBSzD20A2fOYgG8ocPzPu8tXkGP\n\tsBzmneA3NDBOjo6Zdzc2YElq3J+Ocnu2ca4bqu2x1nPPkvIDD07VBjgW78LV4bsXwx\n\t/OJJcrAOBzGcbJPlEvxCAStxCJ8WjneppwbLHkv5uEISVq2j+ccKVpr72dspnTHP9G\n\taecL5hnkstyBMzzVpZzZd0zNByaAZiZHWki4t1WpxbUo+FyE47rZuhxrZaetn5mZZZ\n\tUAA0axMa/jw6o599UOP/cjKNyoDDY77SQJoYuvZ8xRCTErnptJ+8aJIfM68mERgl+s\n\tVssP93dqp1OKQ==","Message-ID":"<8079ce851afcda757a8066d9fb38c239c1ea6def.camel@collabora.com>","Subject":"Re: [PATCH v4 1/3] gstreamer: Associate libcamera::Stream with\n\tGstPad","From":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","To":"Umang Jain <uajain@igalia.com>, libcamera-devel@lists.libcamera.org","Date":"Tue, 04 Nov 2025 08:40:08 -0500","In-Reply-To":"<20251103213014.62713-2-uajain@igalia.com>","References":"<20251103213014.62713-1-uajain@igalia.com>\n\t<20251103213014.62713-2-uajain@igalia.com>","Autocrypt":"addr=nicolas.dufresne@collabora.com; prefer-encrypt=mutual;\n\tkeydata=mDMEaCN2ixYJKwYBBAHaRw8BAQdAM0EHepTful3JOIzcPv6ekHOenE1u0vDG1gdHFrChD\n\t/e0J05pY29sYXMgRHVmcmVzbmUgPG5pY29sYXNAbmR1ZnJlc25lLmNhPoicBBMWCgBEAhsDBQsJCA\n\tcCAiICBhUKCQgLAgQWAgMBAh4HAheABQkJZfd1FiEE7w1SgRXEw8IaBG8S2UGUUSlgcvQFAmibrjo\n\tCGQEACgkQ2UGUUSlgcvQlQwD/RjpU1SZYcKG6pnfnQ8ivgtTkGDRUJ8gP3fK7+XUjRNIA/iXfhXMN\n\tabIWxO2oCXKf3TdD7aQ4070KO6zSxIcxgNQFtDFOaWNvbGFzIER1ZnJlc25lIDxuaWNvbGFzLmR1Z\n\tnJlc25lQGNvbGxhYm9yYS5jb20+iJkEExYKAEECGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4\n\tAWIQTvDVKBFcTDwhoEbxLZQZRRKWBy9AUCaCyyxgUJCWX3dQAKCRDZQZRRKWBy9ARJAP96pFmLffZ\n\tsmBUpkyVBfFAf+zq6BJt769R0al3kHvUKdgD9G7KAHuioxD2v6SX7idpIazjzx8b8rfzwTWyOQWHC\n\tAAS0LU5pY29sYXMgRHVmcmVzbmUgPG5pY29sYXMuZHVmcmVzbmVAZ21haWwuY29tPoiZBBMWCgBBF\n\tiEE7w1SgRXEw8IaBG8S2UGUUSlgcvQFAmibrGYCGwMFCQll93UFCwkIBwICIgIGFQoJCAsCBBYCAw\n\tECHgcCF4AACgkQ2UGUUSlgcvRObgD/YnQjfi4+L8f4fI7p1pPMTwRTcaRdy6aqkKEmKsCArzQBAK8\n\tbRLv9QjuqsE6oQZra/RB4widZPvphs78H0P6NmpIJ","Organization":"Collabora Canada","Content-Type":"multipart/signed; micalg=\"pgp-sha512\";\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"=-+M9+5LGTFK8Br3pSV95d\"","User-Agent":"Evolution 3.56.2 (3.56.2-2.fc42) ","MIME-Version":"1.0","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]