GStreamer Base Plugins 0.10 Library Reference Manual | ||||
---|---|---|---|---|
#include <gst/app/gstappsink.h> GstAppSink; void gst_app_sink_set_caps (GstAppSink *appsink, const GstCaps *caps); GstCaps* gst_app_sink_get_caps (GstAppSink *appsink); gboolean gst_app_sink_is_eos (GstAppSink *appsink); void gst_app_sink_set_emit_signals (GstAppSink *appsink, gboolean emit); gboolean gst_app_sink_get_emit_signals (GstAppSink *appsink); void gst_app_sink_set_max_buffers (GstAppSink *appsink, guint max); guint gst_app_sink_get_max_buffers (GstAppSink *appsink); void gst_app_sink_set_drop (GstAppSink *appsink, gboolean drop); gboolean gst_app_sink_get_drop (GstAppSink *appsink); GstBuffer* gst_app_sink_pull_preroll (GstAppSink *appsink); GstBuffer* gst_app_sink_pull_buffer (GstAppSink *appsink); GstAppSinkCallbacks; void gst_app_sink_set_callbacks (GstAppSink *appsink, GstAppSinkCallbacks *callbacks, gpointer user_data, GDestroyNotify notify);
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 buffers from appsink is by using the
gst_app_sink_pull_buffer()
and gst_app_sink_pull_preroll()
methods.
These methods block until a buffer becomes available in the sink or when the
sink is shut down or reaches EOS.
Appsink will internally use a queue to collect buffers from the streaming thread. If the application is not pulling buffers fast enough, this queue will consume a lot of memory over time. The "max-buffers" property can be used to limit the queue size. The "drop" 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-buffer" and "new-preroll" signals
when a buffer 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 buffers can be obtained by getting the buffer caps.
If one of the pull-preroll or pull-buffer 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 gst_app_sink_is_eos()
method.
The eos signal can also be used to be informed when the EOS state is reached to avoid polling.
Last reviewed on 2008-12-17 (0.10.22)
void gst_app_sink_set_caps (GstAppSink *appsink, const GstCaps *caps);
Set the capabilities on the appsink element. This function takes
a copy of the caps structure. After calling this method, the sink will only
accept caps that match caps
. If caps
is non-fixed, you must check the caps
on the buffers to get the actual used caps.
appsink : |
a GstAppSink |
caps : |
caps to set |
Since 0.10.22
GstCaps* gst_app_sink_get_caps (GstAppSink *appsink);
Get the configured caps on appsink
.
appsink : |
a GstAppSink |
Returns : | the GstCaps accepted by the sink. gst_caps_unref() after usage.
|
Since 0.10.22
gboolean gst_app_sink_is_eos (GstAppSink *appsink);
Check if appsink
is EOS, which is when no more buffers can be pulled because
an EOS event was received.
This function also returns TRUE
when the appsink is not in the PAUSED or
PLAYING state.
appsink : |
a GstAppSink |
Returns : | TRUE if no more buffers can be pulled and the appsink is EOS.
|
Since 0.10.22
void gst_app_sink_set_emit_signals (GstAppSink *appsink, gboolean emit);
Make appsink emit the "new-preroll" and "new-buffer" signals. This option is by default disabled because signal emission is expensive and unneeded when the application prefers to operate in pull mode.
appsink : |
a GstAppSink |
emit : |
the new state |
Since 0.10.22
gboolean gst_app_sink_get_emit_signals (GstAppSink *appsink);
Check if appsink will emit the "new-preroll" and "new-buffer" signals.
appsink : |
a GstAppSink |
Returns : | TRUE if appsink is emiting the "new-preroll" and "new-buffer"
signals.
|
Since 0.10.22
void gst_app_sink_set_max_buffers (GstAppSink *appsink, guint max);
Set the maximum amount of buffers that can be queued in appsink
. After this
amount of buffers are queued in appsink, any more buffers will block upstream
elements until a buffer is pulled from appsink
.
appsink : |
a GstAppSink |
max : |
the maximum number of buffers to queue |
Since 0.10.22
guint gst_app_sink_get_max_buffers (GstAppSink *appsink);
Get the maximum amount of buffers that can be queued in appsink
.
appsink : |
a GstAppSink |
Returns : | The maximum amount of buffers that can be queued. |
Since 0.10.22
void gst_app_sink_set_drop (GstAppSink *appsink, gboolean drop);
Instruct appsink
to drop old buffers when the maximum amount of queued
buffers is reached.
appsink : |
a GstAppSink |
drop : |
the new state |
Since 0.10.22
gboolean gst_app_sink_get_drop (GstAppSink *appsink);
Check if appsink
will drop old buffers when the maximum amount of queued
buffers is reached.
appsink : |
a GstAppSink |
Returns : | TRUE if appsink is dropping old buffers when the queue is
filled.
|
Since 0.10.22
GstBuffer* gst_app_sink_pull_preroll (GstAppSink *appsink);
Get the last preroll buffer in appsink
. This was the buffer that caused the
appsink to preroll in the PAUSED state. This buffer can be pulled many times
and remains available to the application even after EOS.
This function is typically used when dealing with a pipeline in the PAUSED state. Calling this function after doing a seek will give the buffer right after the seek position.
Note that the preroll buffer will also be returned as the first buffer
when calling gst_app_sink_pull_buffer()
.
If an EOS event was received before any buffers, this function returns
NULL
. Use gst_app_sink_is_eos()
to check for the EOS condition.
This function blocks until a preroll buffer or EOS is received or the appsink element is set to the READY/NULL state.
appsink : |
a GstAppSink |
Returns : | a GstBuffer or NULL when the appsink is stopped or EOS. |
Since 0.10.22
GstBuffer* gst_app_sink_pull_buffer (GstAppSink *appsink);
This function blocks until a buffer or EOS becomes available or the appsink element is set to the READY/NULL state.
This function will only return buffers when the appsink is in the PLAYING state. All rendered buffers will be put in a queue so that the application can pull buffers at its own rate. Note that when the application does not pull buffers fast enough, the queued buffers could consume a lot of memory, especially when dealing with raw video frames.
If an EOS event was received before any buffers, this function returns
NULL
. Use gst_app_sink_is_eos()
to check for the EOS condition.
appsink : |
a GstAppSink |
Returns : | a GstBuffer or NULL when the appsink is stopped or EOS. |
Since 0.10.22
typedef struct { void (*eos) (GstAppSink *sink, gpointer user_data); GstFlowReturn (*new_preroll) (GstAppSink *sink, gpointer user_data); GstFlowReturn (*new_buffer) (GstAppSink *sink, gpointer user_data); GstFlowReturn (*new_buffer_list) (GstAppSink *sink, gpointer user_data); } GstAppSinkCallbacks;
A set of callbacks that can be installed on the appsink with
gst_app_sink_set_callbacks()
.
eos () |
Called when the end-of-stream has been reached. This callback is called from the steaming thread. |
new_preroll () |
Called when a new preroll buffer is available.
This callback is called from the steaming thread.
The new preroll buffer can be retrieved with
gst_app_sink_pull_preroll() either from this callback
or from any other thread.
|
new_buffer () |
Called when a new buffer is available.
This callback is called from the steaming thread.
The new buffer can be retrieved with
gst_app_sink_pull_buffer() either from this callback
or from any other thread.
|
new_buffer_list () |
Called when a new bufferlist is available.
This callback is called from the steaming thread.
The new bufferlist can be retrieved with
gst_app_sink_pull_buffer_list() either from this callback
or from any other thread.
|
Since 0.10.23
void gst_app_sink_set_callbacks (GstAppSink *appsink, GstAppSinkCallbacks *callbacks, gpointer user_data, GDestroyNotify notify);
Set callbacks which will be executed for each new preroll, new buffer and eos. This is an alternative to using the signals, it has lower overhead and is thus less expensive, but also less flexible.
If callbacks are installed, no signals will be emited for performance reasons.
appsink : |
a GstAppSink |
callbacks : |
the callbacks |
user_data : |
a user_data argument for the callbacks |
notify : |
a destroy notify function |
Since 0.10.23