[libcamera-devel] [PATCH v1] gstreamer: Factor out _pad_push_stream_start from _task_enter
Vedant Paranjape
vedantparanjape160201 at gmail.com
Sun Jul 18 08:48:50 CEST 2021
This patch creates gst_libcamera_pad_push_stream_start function to
create stream id and to push the stream start. This is a non functional
change.
Signed-off-by: Vedant Paranjape <vedantparanjape160201 at gmail.com>
---
src/gstreamer/gstlibcamerapad.cpp | 13 +++++++++++++
src/gstreamer/gstlibcamerapad.h | 2 ++
src/gstreamer/gstlibcamerasrc.cpp | 7 +------
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp
index c00e81c8..6f889472 100644
--- a/src/gstreamer/gstlibcamerapad.cpp
+++ b/src/gstreamer/gstlibcamerapad.cpp
@@ -155,6 +155,19 @@ gst_libcamera_pad_get_stream(GstPad *pad)
return nullptr;
}
+void
+gst_libcamera_pad_push_stream_start(GstPad *pad, const guint group_id)
+{
+ GstElement *element = gst_pad_get_parent_element(pad);
+ static gint stream_id_num = 0;
+
+ g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", group_id, stream_id_num++);
+ g_autofree gchar *stream_id = gst_pad_create_stream_id(pad, element, stream_id_intermediate);
+ GstEvent *event = gst_event_new_stream_start(stream_id);
+ gst_event_set_group_id(event, group_id);
+ gst_pad_push_event(pad, event);
+}
+
void
gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer)
{
diff --git a/src/gstreamer/gstlibcamerapad.h b/src/gstreamer/gstlibcamerapad.h
index 779f2d13..7693374f 100644
--- a/src/gstreamer/gstlibcamerapad.h
+++ b/src/gstreamer/gstlibcamerapad.h
@@ -26,6 +26,8 @@ void gst_libcamera_pad_set_pool(GstPad *pad, GstLibcameraPool *pool);
libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad);
+void gst_libcamera_pad_push_stream_start(GstPad *pad, const guint group_id);
+
void gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer);
GstFlowReturn gst_libcamera_pad_push_pending(GstPad *pad);
diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 79b0d867..f9ac50ef 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -364,15 +364,10 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
if (state->group_id_ == 0) {
state->group_id_ = gst_util_group_id_next();
}
- gint stream_id_num = 0;
StreamRoles roles;
for (GstPad *srcpad : state->srcpads_) {
/* Create stream-id and push stream-start. */
- g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", state->group_id_, stream_id_num++);
- g_autofree gchar *stream_id = gst_pad_create_stream_id(srcpad, GST_ELEMENT(self), stream_id_intermediate);
- GstEvent *event = gst_event_new_stream_start(stream_id);
- gst_event_set_group_id(event, state->group_id_);
- gst_pad_push_event(srcpad, event);
+ gst_libcamera_pad_push_stream_start(srcpad, state->group_id_);
/* Collect the streams roles for the next iteration. */
roles.push_back(gst_libcamera_pad_get_role(srcpad));
--
2.25.1
More information about the libcamera-devel
mailing list