@@ -192,12 +192,13 @@  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 static_cast<Stream *>(gst_pad_get_element_private(pad));
+}
 
-	return nullptr;
+void
+gst_libcamera_pad_set_stream(GstPad *pad, Stream *stream)
+{
+	gst_pad_set_element_private(pad, stream);
 }
 
 void
@@ -33,4 +33,6 @@  void gst_libcamera_pad_set_video_info(GstPad *pad, const GstVideoInfo *info);
 
 libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad);
 
+void gst_libcamera_pad_set_stream(GstPad *pad, libcamera::Stream *stream);
+
 void gst_libcamera_pad_set_latency(GstPad *pad, GstClockTime latency);
@@ -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 source pad. */
+		gst_libcamera_pad_set_stream(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_libcamera_pad_set_stream(srcpad, nullptr);
 		}
 	}
 
 
  
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(). Add the gst_libcamera_pad_set_stream() helper to associate the stream with the pad. Additionally, modify the gst_libcamera_pad_get_stream() to use to the getter helper gst_pad_get_element_private(). Signed-off-by: Umang Jain <uajain@igalia.com> --- src/gstreamer/gstlibcamerapad.cpp | 11 ++++++----- src/gstreamer/gstlibcamerapad.h | 2 ++ src/gstreamer/gstlibcamerasrc.cpp | 6 +++++- 3 files changed, 13 insertions(+), 6 deletions(-)