[v2,2/3] gstreamer: Associate libcamera::Stream with Pad
diff mbox series

Message ID 20251013063820.90805-3-uajain@igalia.com
State New
Headers show
Series
  • gstreamer: some assorted fixes
Related show

Commit Message

Umang Jain Oct. 13, 2025, 6:38 a.m. UTC
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 <uajain@igalia.com>
---
 src/gstreamer/gstlibcamerapad.cpp | 7 +------
 src/gstreamer/gstlibcamerasrc.cpp | 6 +++++-
 2 files changed, 6 insertions(+), 7 deletions(-)

Patch
diff mbox series

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<Stream *>(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);
 		}
 	}