AppSink

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 gstapp.app_sink.AppSink.pullSample and gstapp.app_sink.AppSink.pullPreroll 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, gstapp.app_sink.AppSink.tryPullSample and gstapp.app_sink.AppSink.tryPullPreroll, 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 "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 gstapp.app_sink.AppSink.isEos method.

The eos signal can also be used to be informed when the EOS state is reached to avoid polling.

Members

Functions

connectEos
ulong connectEos(T callback, Flag!"After" after)

Connect to Eos signal.

connectNewPreroll
ulong connectNewPreroll(T callback, Flag!"After" after)

Connect to NewPreroll signal.

connectNewSample
ulong connectNewSample(T callback, Flag!"After" after)

Connect to NewSample signal.

connectNewSerializedEvent
ulong connectNewSerializedEvent(T callback, Flag!"After" after)

Connect to NewSerializedEvent signal.

connectProposeAllocation
ulong connectProposeAllocation(T callback, Flag!"After" after)

Connect to ProposeAllocation signal.

connectPullPreroll
ulong connectPullPreroll(T callback, Flag!"After" after)

Connect to PullPreroll signal.

connectPullSample
ulong connectPullSample(T callback, Flag!"After" after)

Connect to PullSample signal.

connectTryPullObject
ulong connectTryPullObject(T callback, Flag!"After" after)

Connect to TryPullObject signal.

connectTryPullPreroll
ulong connectTryPullPreroll(T callback, Flag!"After" after)

Connect to TryPullPreroll signal.

connectTryPullSample
ulong connectTryPullSample(T callback, Flag!"After" after)

Connect to TryPullSample signal.

getBufferListSupport
bool getBufferListSupport()

Check if appsink supports buffer lists.

getCaps
gst.caps.Caps getCaps()

Get the configured caps on appsink.

getDrop
bool getDrop()

Check if appsink will drop old buffers when the maximum amount of queued data is reached (meaning max buffers, time or bytes limit, whichever is hit first).

getEmitSignals
bool getEmitSignals()

Check if appsink will emit the "new-preroll" and "new-sample" signals.

getMaxBuffers
uint getMaxBuffers()

Get the maximum amount of buffers that can be queued in appsink.

getMaxBytes
ulong getMaxBytes()

Get the maximum total size, in bytes, that can be queued in appsink.

getMaxTime
gst.types.ClockTime getMaxTime()

Get the maximum total duration that can be queued in appsink.

getWaitOnEos
bool getWaitOnEos()

Check if appsink will wait for all buffers to be consumed when an EOS is received.

isEos
bool isEos()

Check if appsink is EOS, which is when no more samples can be pulled because an EOS event was received.

pullPreroll
gst.sample.Sample pullPreroll()

Get the last preroll sample in appsink. This was the sample that caused the appsink to preroll in the PAUSED state.

pullSample
gst.sample.Sample pullSample()

This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/NULL state.

setBufferListSupport
void setBufferListSupport(bool enableLists)

Instruct appsink to enable or disable buffer list support.

setCaps
void setCaps(gst.caps.Caps 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, or incomplete, you must check the caps on the samples to get the actual used caps.

setDrop
void setDrop(bool drop)

Instruct appsink 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).

setEmitSignals
void setEmitSignals(bool emit)

Make appsink emit the "new-preroll" and "new-sample" signals. This option is by default disabled because signal emission is expensive and unneeded when the application prefers to operate in pull mode.

setMaxBuffers
void setMaxBuffers(uint 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 sample is pulled from appsink, unless 'drop' is set, in which case new buffers will be discarded.

setMaxBytes
void setMaxBytes(ulong max)

Set the maximum total size that can be queued in appsink. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a sample is pulled from appsink, unless 'drop' is set, in which case new buffers will be discarded.

setMaxTime
void setMaxTime(gst.types.ClockTime max)

Set the maximum total duration that can be queued in appsink. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a sample is pulled from appsink, unless 'drop' is set, in which case new buffers will be discarded.

setWaitOnEos
void setWaitOnEos(bool wait)

Instruct appsink to wait for all buffers to be consumed when an EOS is received.

tryPullPreroll
gst.sample.Sample tryPullPreroll(gst.types.ClockTime timeout)

Get the last preroll sample in appsink. This was the sample that caused the appsink to preroll in the PAUSED state.

tryPullSample
gst.sample.Sample tryPullSample(gst.types.ClockTime timeout)

This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/NULL state or the timeout expires.

Mixed In Members

From mixin URIHandlerT!()

getProtocols
string[] getProtocols()

Gets the list of protocols supported by handler. This list may not be modified.

getUri
string getUri()

Gets the currently handled URI.

getUriType
gst.types.URIType getUriType()

Gets the type of the given URI handler

setUri
bool setUri(string uri)

Tries to set the URI of the given handler.

Inherited Members

From BaseSink

doPreroll
gst.types.FlowReturn doPreroll(gst.mini_object.MiniObject obj)

If the sink spawns its own thread for pulling buffers from upstream it should call this method after it has pulled a buffer. If the element needed to preroll, this function will perform the preroll and will then block until the element state is changed.

getBlocksize
uint getBlocksize()

Get the number of bytes that the sink will pull when it is operating in pull mode.

getDropOutOfSegment
bool getDropOutOfSegment()

Checks if sink is currently configured to drop buffers which are outside the current segment

getLastSample
gst.sample.Sample getLastSample()

Get the last sample that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails.

getLatency
gst.types.ClockTime getLatency()

Get the currently configured latency.

getMaxBitrate
ulong getMaxBitrate()

Get the maximum amount of bits per second that the sink will render.

getMaxLateness
long getMaxLateness()

Gets the max lateness value. See gstbase.base_sink.BaseSink.setMaxLateness for more details.

getProcessingDeadline
gst.types.ClockTime getProcessingDeadline()

Get the processing deadline of sink. see gstbase.base_sink.BaseSink.setProcessingDeadline for more information about the processing deadline.

getRenderDelay
gst.types.ClockTime getRenderDelay()

Get the render delay of sink. see gstbase.base_sink.BaseSink.setRenderDelay for more information about the render delay.

getStats
gst.structure.Structure getStats()

Return various #GstBaseSink statistics. This function returns a #GstStructure with name application/x-gst-base-sink-stats with the following fields:

getSync
bool getSync()

Checks if sink is currently configured to synchronize against the clock.

getThrottleTime
ulong getThrottleTime()

Get the time that will be inserted between frames to control the maximum buffers per second.

getTsOffset
gst.types.ClockTimeDiff getTsOffset()

Get the synchronisation offset of sink.

isAsyncEnabled
bool isAsyncEnabled()

Checks if sink is currently configured to perform asynchronous state changes to PAUSED.

isLastSampleEnabled
bool isLastSampleEnabled()

Checks if sink is currently configured to store the last received sample in the last-sample property.

isQosEnabled
bool isQosEnabled()

Checks if sink is currently configured to send Quality-of-Service events upstream.

queryLatency
bool queryLatency(bool live, bool upstreamLive, gst.types.ClockTime minLatency, gst.types.ClockTime maxLatency)

Query the sink for the latency parameters. The latency will be queried from the upstream elements. live will be true if sink is configured to synchronize against the clock. upstream_live will be true if an upstream element is live.

setAsyncEnabled
void setAsyncEnabled(bool enabled)

Configures sink to perform all state changes asynchronously. When async is disabled, the sink will immediately go to PAUSED instead of waiting for a preroll buffer. This feature is useful if the sink does not synchronize against the clock or when it is dealing with sparse streams.

setBlocksize
void setBlocksize(uint blocksize)

Set the number of bytes that the sink will pull when it is operating in pull mode.

setDropOutOfSegment
void setDropOutOfSegment(bool dropOutOfSegment)

Configure sink to drop buffers which are outside the current segment

setLastSampleEnabled
void setLastSampleEnabled(bool enabled)

Configures sink to store the last received sample in the last-sample property.

setMaxBitrate
void setMaxBitrate(ulong maxBitrate)

Set the maximum amount of bits per second that the sink will render.

setMaxLateness
void setMaxLateness(long maxLateness)

Sets the new max lateness value to max_lateness. This value is used to decide if a buffer should be dropped or not based on the buffer timestamp and the current clock time. A value of -1 means an unlimited time.

setProcessingDeadline
void setProcessingDeadline(gst.types.ClockTime processingDeadline)

Maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines.

setQosEnabled
void setQosEnabled(bool enabled)

Configures sink to send Quality-of-Service events upstream.

setRenderDelay
void setRenderDelay(gst.types.ClockTime delay)

Set the render delay in sink to delay. The render delay is the time between actual rendering of a buffer and its synchronisation time. Some devices might delay media rendering which can be compensated for with this function.

setSync
void setSync(bool sync)

Configures sink to synchronize on the clock or not. When sync is false, incoming samples will be played as fast as possible. If sync is true, the timestamps of the incoming buffers will be used to schedule the exact render time of its contents.

setThrottleTime
void setThrottleTime(ulong throttle)

Set the time that will be inserted between rendered buffers. This can be used to control the maximum buffers per second that the sink will render.

setTsOffset
void setTsOffset(gst.types.ClockTimeDiff offset)

Adjust the synchronisation of sink with offset. A negative value will render buffers earlier than their timestamp. A positive value will delay rendering. This function can be used to fix playback of badly timestamped buffers.

wait
gst.types.FlowReturn wait(gst.types.ClockTime time, gst.types.ClockTimeDiff jitter)

This function will wait for preroll to complete and will then block until time is reached. It is usually called by subclasses that use their own internal synchronisation but want to let some synchronization (like EOS) be handled by the base class.

waitClock
gst.types.ClockReturn waitClock(gst.types.ClockTime time, gst.types.ClockTimeDiff jitter)

This function will block until time is reached. It is usually called by subclasses that use their own internal synchronisation.

waitPreroll
gst.types.FlowReturn waitPreroll()

If the #GstBaseSinkClass::render method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to render the remaining data.

From URIHandler

getProtocols
string[] getProtocols()

Gets the list of protocols supported by handler. This list may not be modified.

getUri
string getUri()

Gets the currently handled URI.

getUriType
gst.types.URIType getUriType()

Gets the type of the given URI handler

setUri
bool setUri(string uri)

Tries to set the URI of the given handler.