[libcamera-devel,RFC,v1,1/2] gstreamer: Factor out _pad_push_stream_start from _task_enter
diff mbox series

Message ID 20210720173548.313901-1-vedantparanjape160201@gmail.com
State Superseded
Headers show
Series
  • [libcamera-devel,RFC,v1,1/2] gstreamer: Factor out _pad_push_stream_start from _task_enter
Related show

Commit Message

Vedant Paranjape July 20, 2021, 5:35 p.m. UTC
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@gmail.com>
---
 src/gstreamer/gstlibcamerapad.cpp | 13 +++++++++++++
 src/gstreamer/gstlibcamerapad.h   |  2 ++
 2 files changed, 15 insertions(+)

Comments

Nicolas Dufresne July 26, 2021, 7:26 p.m. UTC | #1
Hi Vedant,

Le mardi 20 juillet 2021 à 23:05 +0530, Vedant Paranjape a écrit :
> 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.

Thanks for the patch, non-functional changes means that code have been moved. In
this case you simply duplicate it. Perhaps you could rework the patch split and
make sure the new helper is used ?

> 
> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
> ---
>  src/gstreamer/gstlibcamerapad.cpp | 13 +++++++++++++
>  src/gstreamer/gstlibcamerapad.h   |  2 ++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp
> index c00e81c8..c5bd14f0 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)
> +{
> +	g_autoptr(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, g_atomic_int_add(&stream_id_num, 1));
> +	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);
Vedant Paranjape July 26, 2021, 7:39 p.m. UTC | #2
Hi Nicolas,
Here's the patch: https://patchwork.libcamera.org/patch/13063/

Regards,
*Vedant Paranjape*

On Tue, Jul 27, 2021 at 12:56 AM Nicolas Dufresne <nicolas@ndufresne.ca>
wrote:

> Hi Vedant,
>
> Le mardi 20 juillet 2021 à 23:05 +0530, Vedant Paranjape a écrit :
> > 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.
>
> Thanks for the patch, non-functional changes means that code have been
> moved. In
> this case you simply duplicate it. Perhaps you could rework the patch
> split and
> make sure the new helper is used ?
>
> >
> > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
> > ---
> >  src/gstreamer/gstlibcamerapad.cpp | 13 +++++++++++++
> >  src/gstreamer/gstlibcamerapad.h   |  2 ++
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/src/gstreamer/gstlibcamerapad.cpp
> b/src/gstreamer/gstlibcamerapad.cpp
> > index c00e81c8..c5bd14f0 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)
> > +{
> > +     g_autoptr(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, g_atomic_int_add(&stream_id_num, 1));
> > +     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);
>
>
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp
index c00e81c8..c5bd14f0 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)
+{
+	g_autoptr(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, g_atomic_int_add(&stream_id_num, 1));
+	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);