[libcamera-devel] [PATCH v1] gstreamer: Factor out _pad_push_stream_start from _task_enter

Vedant Paranjape vedantparanjape160201 at gmail.com
Tue Jul 20 13:40:32 CEST 2021


Hi Laurent,
Sure, I will divide it into 2 patches.

Regards,
Vedant Paranjape

On Mon, Jul 19, 2021 at 8:36 PM Laurent Pinchart <
laurent.pinchart at ideasonboard.com> wrote:

> On Mon, Jul 19, 2021 at 12:56:55PM +0530, Vedant Paranjape wrote:
> > Hi Paul,
> > Yes, it is expected behaviour. group_id should stay same throughout
> > lifetime of application.
> >
> > I will remove the non-functional part from commit message.
>
> Better, please split the patch in two, with the non-functional
> refactoring and the functional change in two separate patches.
>
> > On Mon, 19 Jul, 2021, 12:54 , <paul.elder at ideasonboard.com> wrote:
> > > On Sun, Jul 18, 2021 at 12:18:50PM +0530, Vedant Paranjape wrote:
> > > > 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;
> > >
> > > If gst_libcamera_src_task_enter() is called more than once then this
> won't
> > > be reset to zero, as the original behavior was.
> > >
> > > > +
> > > > +     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));
>
> --
> Regards,
>
> Laurent Pinchart
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210720/236ad139/attachment.htm>


More information about the libcamera-devel mailing list