public class AppSink extends BaseSink
Element that provides an easy way for applications to extract
samples from a pipeline.
See upstream documentation at https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gst-plugins-base-libs/html/gst-plugins-base-libs-appsink.html
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.
The normal way of retrieving samples from appsink is by using the
pullSample() and pullPreroll() methods. These methods block
until a sample becomes available in the sink or when the sink is shut down or
reaches EOS. (TODO - not currently mapped in the Java bindings.
There are also timed variants of these methods,
gst_app_sink_try_pull_sample() and gst_app_sink_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" 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-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 isEOS() method.
The eos signal can also be used to be informed when the EOS state is reached to avoid polling.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AppSink.EOS
Signal emitted when this
AppSink got EOS. |
static interface |
AppSink.NEW_PREROLL
Signal emitted when this
AppSink when a new buffer is ready. |
static interface |
AppSink.NEW_SAMPLE
Signal emitted when this
AppSink when a new Sample is ready. |
Element.NO_MORE_PADS, Element.PAD_ADDED, Element.PAD_REMOVEDGObject.GCallback, GObject.GInterfaceNativeObject.Initializer, NativeObject.TypeProvider, NativeObject.TypeRegistration<T extends NativeObject>| Modifier and Type | Field and Description |
|---|---|
static String |
GST_NAME |
static String |
GTYPE_NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
connect(AppSink.EOS listener)
Adds a listener for the
eos signal. |
void |
connect(AppSink.NEW_PREROLL listener)
Adds a listener for the
new-preroll signal. |
void |
connect(AppSink.NEW_SAMPLE listener)
Adds a listener for the
new-sample signal. |
void |
disconnect(AppSink.EOS listener)
Removes a listener for the
eos signal |
void |
disconnect(AppSink.NEW_PREROLL listener)
Removes a listener for the
new-preroll signal |
void |
disconnect(AppSink.NEW_SAMPLE listener)
Removes a listener for the
new-sample signal |
Caps |
getCaps()
Gets the
Caps configured on this AppSink |
boolean |
isEOS()
Check if this AppSink is EOS, which is when no more samples can be pulled
because an EOS event was received.
|
Sample |
pullPreroll()
Get the last preroll
Sample. |
Sample |
pullSample()
This function blocks until a
Sample or EOS becomes available or
the AppSink element is set to the READY/NULL state. |
void |
setCaps(Caps caps)
Sets the
Caps on the AppSink. |
addPad, connect, connect, connect, disconnect, disconnect, disconnect, getBaseTime, getBus, getClock, getContext, getFactory, getPads, getRequestPad, getSinkPads, getSrcPads, getStartTime, getState, getState, getState, getState, getStaticPad, isPlaying, link, linkFiltered, linkMany, linkPads, linkPadsFiltered, makeRawElement, pause, play, postMessage, query, queryDuration, queryPosition, ready, releaseRequestPad, removePad, seek, seekSimple, sendEvent, setBaseTime, setContext, setLockedState, setStartTime, setState, stop, syncStateWithParent, unlink, unlinkMany, unlinkPadsaddControlBinding, getAsString, getControlBinding, getName, getParent, hasActiveControlBindings, removeControlBinding, setAsString, setControlBindingDisabled, setControlBindingsDisabled, setName, suggestNextSync, syncValues, toStringaddCallback, connect, connect, disconnect, dispose, emit, emit, get, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getRefCount, getTypeName, invalidate, listPropertyNames, removeCallback, setclose, disown, equals, getPointer, getRawPointer, hashCodepublic static final String GST_NAME
public static final String GTYPE_NAME
public AppSink(String name)
public void setCaps(Caps caps)
Caps on the AppSink.
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.
public Caps getCaps()
Caps configured on this AppSinkpublic boolean isEOS()
This function also returns TRUE when the AppSink is not in the PAUSED or PLAYING state.
public Sample pullPreroll()
Sample. This was the Sample that caused the
AppSink to preroll in the PAUSED state.
This function is typically used when dealing with a pipeline in the PAUSED state. Calling this function after doing a seek will give the sample right after the seek position.
Calling this function will clear the internal reference to the preroll buffer.
Note that the preroll sample will also be returned as the first sample
when calling pullSample()
If an EOS event was received before any buffers, this function returns
NULL. Use isEOS() to check for the EOS condition.
This function blocks until a preroll sample or EOS is received or the AppSink element is set to the READY/NULL state.
public Sample pullSample()
Sample or EOS becomes available or
the AppSink element is set to the READY/NULL state.
This function will only return samples when the AppSink is in the PLAYING state. All rendered buffers will be put in a queue so that the application can pull samples at its own rate. Note that when the application does not pull samples 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 isEOS() to check for the EOS condition.
public void connect(AppSink.EOS listener)
eos signal.listener - public void disconnect(AppSink.EOS listener)
eos signallistener - The listener that was previously added.public void connect(AppSink.NEW_SAMPLE listener)
new-sample signal. 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
buffer can be pulled without blocking.listener - public void disconnect(AppSink.NEW_SAMPLE listener)
new-sample signallistener - a listener that was previously added.public void connect(AppSink.NEW_PREROLL listener)
new-preroll signal. 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.listener - public void disconnect(AppSink.NEW_PREROLL listener)
new-preroll signallistener - The listener that was previously added.Copyright © 2021 gstreamer-java. All rights reserved.