[libcamera-devel,v4] gstreamer: Store group_id in GstLibcameraSrcState
diff mbox series

Message ID 20210720160034.233363-1-vedantparanjape160201@gmail.com
State Accepted
Headers show
Series
  • [libcamera-devel,v4] gstreamer: Store group_id in GstLibcameraSrcState
Related show

Commit Message

Vedant Paranjape July 20, 2021, 4 p.m. UTC
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@gmail.com>
---
 src/gstreamer/gstlibcamerasrc.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Nicolas Dufresne July 26, 2021, 9:03 p.m. UTC | #1
Le mardi 20 juillet 2021 à 21:30 +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@gmail.com>

Thanks for this version, I think this is good.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index ea53c2b5..b18f1efb 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,14 @@ 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();
>  	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. */
> @@ -578,6 +578,7 @@ gst_libcamera_src_change_state(GstElement *element, GstStateChange transition)
>  		break;
>  	case GST_STATE_CHANGE_READY_TO_PAUSED:
>  		/* This needs to be called after pads activation.*/
> +		self->state->group_id_ = gst_util_group_id_next();
>  		if (!gst_task_pause(self->task))
>  			return GST_STATE_CHANGE_FAILURE;
>  		ret = GST_STATE_CHANGE_NO_PREROLL;
Paul Elder July 28, 2021, 1:45 a.m. UTC | #2
Hi Vedant,

On Tue, Jul 20, 2021 at 09:30:34PM +0530, Vedant Paranjape wrote:
> 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@gmail.com>

Looks good.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

And pushed.

> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index ea53c2b5..b18f1efb 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,14 @@ 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();
>  	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. */
> @@ -578,6 +578,7 @@ gst_libcamera_src_change_state(GstElement *element, GstStateChange transition)
>  		break;
>  	case GST_STATE_CHANGE_READY_TO_PAUSED:
>  		/* This needs to be called after pads activation.*/
> +		self->state->group_id_ = gst_util_group_id_next();
>  		if (!gst_task_pause(self->task))
>  			return GST_STATE_CHANGE_FAILURE;
>  		ret = GST_STATE_CHANGE_NO_PREROLL;
> -- 
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index ea53c2b5..b18f1efb 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,14 @@  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();
 	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. */
@@ -578,6 +578,7 @@  gst_libcamera_src_change_state(GstElement *element, GstStateChange transition)
 		break;
 	case GST_STATE_CHANGE_READY_TO_PAUSED:
 		/* This needs to be called after pads activation.*/
+		self->state->group_id_ = gst_util_group_id_next();
 		if (!gst_task_pause(self->task))
 			return GST_STATE_CHANGE_FAILURE;
 		ret = GST_STATE_CHANGE_NO_PREROLL;