[libcamera-devel] [PATCH v2] gstreamer: Store group_id in GstLibcameraSrcState
Nicolas Dufresne
nicolas at ndufresne.ca
Mon Jul 19 15:26:56 CEST 2021
Le dimanche 18 juillet 2021 à 00:32 +0530, Vedant Paranjape a écrit :
> This patch adds group_id in GstLibcameraSrcState, since group_id is
> something which should be same for all the pads, it can be reused
> later.
>
> Signed-off-by: Vedant Paranjape <vedantparanjape160201 at gmail.com>
> ---
> src/gstreamer/gstlibcamerasrc.cpp | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index ea53c2b5..79b0d867 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -113,6 +113,7 @@ struct GstLibcameraSrcState {
> std::unique_ptr<CameraConfiguration> config_;
> std::vector<GstPad *> srcpads_;
> std::queue<std::unique_ptr<RequestWrap>> requests_;
> + guint group_id_;
>
> void requestCompleted(Request *request);
> };
> @@ -360,15 +361,17 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
>
> GST_DEBUG_OBJECT(self, "Streaming thread has started");
>
> - guint group_id = gst_util_group_id_next();
> + if (state->group_id_ == 0) {
> + state->group_id_ = gst_util_group_id_next();
> + }
As you never reset this group ID, why don't you pick an ID directly in the
constructor ? (libcamera_src_init() function). Or perhaps we need to read again
the semantic of that group ID, and then grab a new one everything we cycle
through READ state ?
> 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", group_id, stream_id_num++);
> + 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, group_id);
> + gst_event_set_group_id(event, state->group_id_);
> gst_pad_push_event(srcpad, event);
>
> /* Collect the streams roles for the next iteration. */
> @@ -636,6 +639,7 @@ gst_libcamera_src_init(GstLibcameraSrc *self)
>
> state->srcpads_.push_back(gst_pad_new_from_template(templ, "src"));
> gst_element_add_pad(GST_ELEMENT(self), state->srcpads_[0]);
> + state->group_id_ = 0;
nit: Optional, GObject are initialized to 0.
>
> /* C-style friend. */
> state->src_ = self;
More information about the libcamera-devel
mailing list