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

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Mon Jul 19 11:41:39 CEST 2021


Hi Vedant,

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'm confused. I'm talking about stream_id_num. The previous behavior is
that every gst_libcamera_src_task_enter() would assign the stream_id
from 0 to state->srcpads_.size(). The new behavior is that the stream_id
would be assigned from (0 * call_count) to (state->srcpads_.size() *
call_count), where call_count is the number of times
gst_libcamera_src_task_enter() has been called. That change is
intentional?


Paul

> 
> I will remove the non-functional part from commit message.
> 
> On Mon, 19 Jul, 2021, 12:54 , <paul.elder at ideasonboard.com> wrote:
> 
>     Hi Vedant,
> 
>     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.
> 
> 
>     Paul
> 
>     > +
>     > +     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