appsrc usage (push and pull mode)

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

On Tue, 14 Nov 2017 17:22:34 -0700 (MST)
HermannSW <hermann at> 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:
> <>  
> 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

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:

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


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

Antonio Ospite

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

More information about the gstreamer-devel mailing list