<div dir="ltr">Thanks Nirbheek. Your answer is exactly what I am looking for. Really appreciate it. <div><br></div><div>Jake</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 5, 2016 at 11:25 PM, Nirbheek Chauhan <span dir="ltr"><<a href="mailto:nirbheek.chauhan@gmail.com" target="_blank">nirbheek.chauhan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Sep 6, 2016 at 5:21 AM, Jake Zhang <<a href="mailto:zjpseudo@gmail.com">zjpseudo@gmail.com</a>> wrote:<br>
> I am implementing a fairly complicate custom plugin and this plugin<br>
> sometimes will hold on some input buffers by pushing them into a queue if<br>
> some timestamp condition does not meet yet, and sometimes it might push more<br>
> than one buffer to srcpads if certain condition is met. Do you guys see any<br>
> issue of doing this? I just want to make sure I will not have a big issue<br>
> with this unconventional chain function.<br>
><br>
> I have went through the gstpad.c source code, and if my understanding is<br>
> correctly the pad chain function will be called once every time each time<br>
> there is a input buffer. And I do not see any issue with my above<br>
> implementation.<br>
><br>
> Please correct me if I am wrong. Any input is appropriated.<br>
><br>
<br>
</span>Yes, it is a very common use-case to not always push a single buffer<br>
when chaining a buffer. All you have to do is make sure that you<br>
return GST_FLOW_OK when everything is fine. You can either push<br>
nothing, a single buffer, or multiple buffers, or a buffer list.<br>
<br>
There's roughly three things you can do here, depending on what your<br>
data looks like.<br>
<br>
If your data is meant to be concatenated/merged, then you can merge<br>
the contents of buffers and push them as a single buffer as needed.<br>
One way to do this is with GstAdapter[1]. This is commonly done in,<br>
for instance, payloaders and depayloaders.<br>
<br>
1. <a href="https://developer.gnome.org/gstreamer-libs/stable/GstAdapter.html" rel="noreferrer" target="_blank">https://developer.gnome.org/<wbr>gstreamer-libs/stable/<wbr>GstAdapter.html</a><br>
<br>
If you want to keep GstBuffers as they are, you can maintain a GList<br>
or GPtrArray of them and push multiple ones individually<br>
(gst_pad_push) in a single chain function invocation (be careful to do<br>
error checking for each push!). The third option is to both store and<br>
push them as a single GstBufferList[2] (gst_pad_push_list).<br>
<br>
2. <a href="https://developer.gnome.org/gstreamer/stable/gstreamer-GstBufferList.html" rel="noreferrer" target="_blank">https://developer.gnome.org/<wbr>gstreamer/stable/gstreamer-<wbr>GstBufferList.html</a><br>
<br>
The first and third options have the least overhead, if that matters<br>
for your use-case.<br>
<br>
Cheers,<br>
Nirbheek<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
~Nirbheek Chauhan<br>
______________________________<wbr>_________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.<wbr>freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/gstreamer-<wbr>devel</a><br>
</font></span></blockquote></div><br></div>