Could we push more than one buffer in pad chain function?

Jake Zhang zjpseudo at gmail.com
Tue Sep 6 10:46:27 UTC 2016


Thanks Nirbheek. Your answer is exactly what I am looking for. Really
appreciate it.

Jake

On Mon, Sep 5, 2016 at 11:25 PM, Nirbheek Chauhan <
nirbheek.chauhan at gmail.com> wrote:

> On Tue, Sep 6, 2016 at 5:21 AM, Jake Zhang <zjpseudo at gmail.com> wrote:
> > I am implementing a fairly complicate custom plugin and this plugin
> > sometimes will hold on some input buffers by pushing them into a queue if
> > some timestamp condition does not meet yet, and sometimes it might push
> more
> > than one buffer to srcpads if certain condition is met. Do you guys see
> any
> > issue of doing this? I just want to make sure I will not have a big issue
> > with this unconventional chain function.
> >
> > I have went through the gstpad.c source code, and if my understanding is
> > correctly the pad chain function will be called once every time each time
> > there is a input buffer. And I do not see any issue with my above
> > implementation.
> >
> > Please correct me if I am wrong. Any input is appropriated.
> >
>
> Yes, it is a very common use-case to not always push a single buffer
> when chaining a buffer. All you have to do is make sure that you
> return GST_FLOW_OK when everything is fine. You can either push
> nothing, a single buffer, or multiple buffers, or a buffer list.
>
> There's roughly three things you can do here, depending on what your
> data looks like.
>
> If your data is meant to be concatenated/merged, then you can merge
> the contents of buffers and push them as a single buffer as needed.
> One way to do this is with GstAdapter[1]. This is commonly done in,
> for instance, payloaders and depayloaders.
>
> 1. https://developer.gnome.org/gstreamer-libs/stable/GstAdapter.html
>
> If you want to keep GstBuffers as they are, you can maintain a GList
> or GPtrArray of them and push multiple ones individually
> (gst_pad_push) in a single chain function invocation (be careful to do
> error checking for each push!). The third option is to both store and
> push them as a single GstBufferList[2] (gst_pad_push_list).
>
> 2. https://developer.gnome.org/gstreamer/stable/gstreamer-
> GstBufferList.html
>
> The first and third options have the least overhead, if that matters
> for your use-case.
>
> Cheers,
> Nirbheek
>
> --
> ~Nirbheek Chauhan
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160906/bd57ce23/attachment.html>


More information about the gstreamer-devel mailing list