[libcamera-devel,v2,13/27] gst: libcamerasrc: Send stream start event

Message ID 20200227200407.490616-14-nicolas.dufresne@collabora.com
State Accepted
Headers show
Series
  • GStreamer Element for libcamera
Related show

Commit Message

Nicolas Dufresne Feb. 27, 2020, 8:03 p.m. UTC
Prior to sending caps, we need to send a stream-start event. This requires
generating a stream and a group id. The stream id is random for live sources and
the group id is shared across all pads.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/gstreamer/gstlibcamerasrc.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 5a86a6d..e2c63d1 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -129,8 +129,19 @@  static void
 gst_libcamera_src_task_enter(GstTask *task, GThread *thread, gpointer user_data)
 {
 	GstLibcameraSrc *self = GST_LIBCAMERA_SRC(user_data);
+	GLibRecLocker(&self->stream_lock);
+	GstLibcameraSrcState *state = self->state;
 
 	GST_DEBUG_OBJECT(self, "Streaming thread has started");
+
+	guint group_id = gst_util_group_id_next();
+	for (GstPad *srcpad : state->srcpads) {
+		/* Create stream-id and push stream-start */
+		g_autofree gchar *stream_id = gst_pad_create_stream_id(srcpad, GST_ELEMENT(self), nullptr);
+		GstEvent *event = gst_event_new_stream_start(stream_id);
+		gst_event_set_group_id(event, group_id);
+		gst_pad_push_event(srcpad, event);
+	}
 }
 
 static void