appsrc usage (push and pull mode)

distran distran.sensors at gmail.com
Mon Oct 21 16:46:41 CEST 2013


Hello.

I have some doubts regarding appsrc development and using appsrc in push vs
pull mode. I need to inject frames from a live source to a pipeline.
Basically, I have my source (producer) generating frames in one thread, and
putting them in a buffer (let's say these are just OpenCV generated images).
GStreamer thread should take the frame out of the buffer and push it to the
pipeline.

I noticed there are esencially two ways you can use appsrc - "push" mode
(for live sources) and "pull" mode (from non-live sources). I can understand
how should I use them but I am missing the practical point on when to use
one implementation over another. Let me give you two examples (I tried to
leave only the essence of my doubts)). Please correct me in my
understanding, if anything is wrong:

AppSrc in "pull" mode:
  - we connect a function "cb_need_data" to a signal "need_data" from a
source
  - if an appsrc needs data, it will emit "need-data" signal and then our
function ("cb_need_data") is invoked, where "push-buffer" signal is emmited
with a new buffer to transmit



AppSrc in "push" mode:
  - we connect a functions "start_feed" and "stop_feed" to a signals
"need_data" and "enough-data", within these functions we add function
"read_data" to Glib idle loop. Subsequently, "read_data" will be invoked
(according to documentation) "whenever there are no higher priority events
pending to the default main loop."



Questions:
  - In "push" mode - how often is actually "push-buffer" signal invoked?
What, if there are a lot of "higher priority events"? How precisely can we
control the rate with which "push-buffer" signal is emitted (for the
pipeline it is usually required to send frames with approximately specified
rate)?
  - What is the difference between g_signal_emit_by_name (app->appsrc,
"push-buffer", buffer, &ret); and using directly ret =
gst_app_src_push_buffer(app->src, buffer); ?
  - In both modes function, that emits "push-buffer" signal is invoked
somewhat automatically (in "pull" mode, when we receive "need-data" signal,
and in "push" mode when there are no higher priority events). Is it possible
to directly emit "push-buffer" signal when we have our frame ready to emit?
(as I said before, in my architecture I have an element, that generates
frames constantly with a certain frame rate. Would it be possible to emit
"push-buffer" every time frame is generated? What are the drawbacks of such
solution? - I tried emitting "push-buffer" signal directly from producer
thread and it seems to work well).

Thanks for all clarifications!

Regards,
Michal



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/appsrc-usage-push-and-pull-mode-tp4662768.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list