How to keep several GstBuffers inside my custom gstreamer transform element

chang wuchang.mech at gmail.com
Tue Nov 24 09:50:44 UTC 2020


Hello,

I am new to gstreamer, and I am trying to design a custom gstreamer plugin,
it will basically extracts some metadata from Gstbuffer, send them to remote
server through HTTP, and use its reply to process the buffer. So, I need to
"hold" the buffer inside the plugin for a while until I get the reply from
remote server, after that I can push the buffer to the next element. (Of
course, a maximum timeout is set to ensure the HTTP request won't block
forever). The logical part has been done (thanks to the convinent glib async
queue, gthread and glib threadpool).

*In other words, I want to controll the input and output of Gstbuffer at my
own pace *. In this case, an inevitable latency is caused by network, that's
OK, since every buffer is helded inside the plugin for a while. 

I have tried to derive from GstBaseTransfform class, override the
submit_input_buffer so it will not place any buffer in trans->queued_buf,
but put a wrapped buffer in my own queue (say, private_queue) . A thread
will repeatedly peek private_queue if job done and use gst_pad_push to push
the finished buffer to src pad. I also override the generate_outbuf method
to makesure outbuf is always NULL. Basically, I replaced the default buffer
transform method with my own one.

It actually works when the network latency is small, but when the latency
start to increase to 500~1000ms, the pipeline is becoming really slow and
lagging. I have prepared a large buffer queue, and I think theoretically, if
my http latency is large. Since the submit_input_buffer function will
continously feed new buffer into the queue, *more and more buffers will
enter the plugin, but little will be popped out*, in the end the queue will
be too full and triggers warning.

However, things do not happen like this, it seems that if I do not push
enough buffer out to src pad, the input acts like it has been blocked,
nothing coming in. So, one comes in only if one goes out. That why the
pipeline becomes slow.

*I with I can keep a number of buffers inside the plugin so I can do batch
process, what can I do? I can accept the pipeline freezing at the beginning
time, but it should soon be fluent after my plugin has accumulated enough
buffer in the queue pool*

I'm not sure if I made myself clear since my description is a bit complex,
if you found anything confusing, I can explain it in detail when needed.
Thank you.

Best,
Chang



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list