Appsink is a sink plugin that supports many different methods for making the application get a handle on the GStreamer data in a
pipeline.
Unlike most GStreamer elements, Appsink provides external API functions.
appsink can be used by linking to the gstappsink.h header file to access the methods or by using the appsink action signals and
properties.
The normal way of retrieving samples from appsink is by using the pull_sample
and pull_preroll methods. These methods block until a sample becomes available
in the sink or when the sink is shut down or reaches EOS. There are also timed variants of these methods,
try_pull_sample and
try_pull_preroll, which accept a timeout parameter to limit the amount of
time to wait.
Appsink will internally use a queue to collect buffers from the streaming thread. If the application is not pulling samples fast enough,
this queue will consume a lot of memory over time. The "max-buffers", "max-time" and "max-bytes" properties can be used to limit the queue
size. The "leaky-type" property controls whether the streaming thread blocks or if older buffers are dropped when the maximum queue size
is reached. Note that blocking the streaming thread can negatively affect real-time performance and should be avoided.
If a blocking behaviour is not desirable, setting the "emit-signals" property to true will make appsink
emit the "new-sample" and "new-preroll" signals when a sample can be pulled without blocking.
The "caps" property on appsink can be used to control the formats that appsink can receive. This property can contain non-fixed caps, the
format of the pulled samples can be obtained by getting the sample caps.
If one of the pull-preroll or pull-sample methods return null, the appsink is stopped or in the EOS
state. You can check for the EOS state with the "eos" property or with the is_eos
method.
The eos signal can also be used to be informed when the EOS state is reached to avoid polling.
- public bool get_buffer_list_support ()
Check if this supports buffer lists.
- public Caps get_caps ()
Get the configured caps on this.
- public bool get_drop ()
Check if this will drop old buffers
when the maximum amount of queued data is reached (meaning max buffers, time or bytes limit, whichever is hit first).
- public bool get_emit_signals ()
Check if appsink will emit the "new-preroll" and "new-sample" signals.
- public uint get_max_buffers ()
Get the maximum amount of buffers that can be queued in
this.
- public bool get_wait_on_eos ()
Check if this will wait for all
buffers to be consumed when an EOS is received.
- public bool is_eos ()
Check if this is EOS, which is when
no more samples can be pulled because an EOS event was received.
- public void set_buffer_list_support (bool enable_lists)
Instruct this to enable or disable
buffer list support.
- public void set_caps (Caps? caps)
Set the capabilities on the appsink element.
- public void set_drop (bool drop)
Instruct this to drop old buffers
when the maximum amount of queued data is reached, that is, when any configured limit is hit (max-buffers, max-time or max-bytes).
- public void set_emit_signals (bool emit)
Make appsink emit the "new-preroll" and "new-sample" signals.
- public void set_max_buffers (uint max)
Set the maximum amount of buffers that can be queued in
this.
- public void set_wait_on_eos (bool wait)
Instruct this to wait for all
buffers to be consumed when an EOS is received.