appsrc usage (push and pull mode)

Antonio Ospite ao2 at ao2.it
Wed Nov 15 07:56:38 UTC 2017


On Tue, 14 Nov 2017 17:22:34 -0700 (MST)
HermannSW <hermann at stamm-wilbrandt.de> wrote:

> This thread is old, but really interesting.
> 
> I tried to use  gst_app_src_push_buffer()  and   g_idle_add(), details and
> source files attached here:
> https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=197124&p=1234930#p1234930
> <https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=197124&p=1234930#p1234930>  
> 
> I seem to be missing a step that is needed in order to not freeze pipeline.
> The diff to working sample is very small.
>
> What needs to be done to get  gst_app_src_push_buffer()  program streaming?
>

The problem is not about gst_app_src_push_buffer() but about
read_data().

The callback you set with g_idle_add() needs to return TRUE (or its
alias G_SOURCE_CONTINUE) if you want it to be called again and
G_SOURCE_REMOVE if you don't.

See the documentation:
https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-idle-add
https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#GSourceFunc

In a _synthetic_ example for push mode like yours you may also want some
rate limiting (e.g. a sleep) to avoid thrashing your system.

And about pull mode (appsrc-launch2.c), remember that when the
cb_need_data() function returns you must _always_ have pushed a buffer
(or sent an EOS), otherwise the pipeline stalls. Your simple example
does that, but when there is more logic involved this detail may be
overlooked, at least it happened to me in
https://git.ao2.it/gst-aseq-appsrc.git/

Ciao,
   Antonio

P.S. use "diff -u" when you can.

-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


More information about the gstreamer-devel mailing list