GstApp.AppSink¶
- Subclasses:
None
Methods¶
- Inherited:
GstBase.BaseSink (31), Gst.Element (82), Gst.Object (27), GObject.Object (37), Gst.URIHandler (4)
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
GstBase.BaseSink (18), Gst.Element (16), Gst.Object (1), GObject.Object (7), Gst.URIHandler (2)
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Use buffer lists |
||
r/w |
The allowed caps for the sink pad |
||
r/w |
Drop old buffers when the buffer queue is filled |
||
r/w |
Emit new-preroll and new-sample signals |
||
r |
Check if the sink is EOS or not started |
||
r/w |
The maximum number of buffers to queue internally (0 = unlimited) |
||
r/w |
The maximum amount of bytes to queue internally (0 = unlimited) |
||
r/w |
The maximum total duration to queue internally (in ns, 0 = unlimited) |
||
r/w |
Wait for all buffers to be processed after receiving an EOS |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Signal that the end-of-stream has been reached. |
|
Signal that a new preroll sample is available. |
|
Signal that a new sample is available. |
|
Signal that a new downstream serialized event is available. |
|
Signal that a new propose_allocation query is available. |
|
Get the last preroll sample in appsink. |
|
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/ |
|
This function blocks until a sample or an event becomes available or the appsink element is set to the READY/ |
|
Get the last preroll sample in appsink. |
|
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/ |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
basesink |
r |
Class Details¶
- class GstApp.AppSink(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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.AppSink.pull_sample
() andGstApp.AppSink.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,GstApp.AppSink.try_pull_sample
() andGstApp.AppSink.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 “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
None
, the appsink is stopped or in the EOS state. You can check for the EOS state with the “eos” property or with theGstApp.AppSink.is_eos
() method.The eos signal can also be used to be informed when the EOS state is reached to avoid polling.
- get_caps()[source]¶
- Returns:
the
Gst.Caps
accepted by the sink. gst_caps_unref() after usage.- Return type:
Get the configured caps on self.
- get_drop()[source]¶
-
Check if self will drop old buffers when the maximum amount of queued data is reached (meaning max buffers, time or bytes limit, whichever is hit first).
- get_max_buffers()[source]¶
- Returns:
The maximum amount of buffers that can be queued.
- Return type:
Get the maximum amount of buffers that can be queued in self.
- get_max_bytes()[source]¶
- Returns:
The maximum amount of bytes that can be queued
- Return type:
Get the maximum total size, in bytes, that can be queued in self.
New in version 1.24.
- get_max_time()[source]¶
- Returns:
The maximum total duration that can be queued.
- Return type:
Get the maximum total duration that can be queued in self.
New in version 1.24.
- get_wait_on_eos()[source]¶
- Returns:
True
if self will wait for all buffers to be consumed when an EOS is received.- Return type:
Check if self will wait for all buffers to be consumed when an EOS is received.
- is_eos()[source]¶
-
Check if self is EOS, which is when no more samples 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.
- pull_preroll()[source]¶
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
Get the last preroll sample in self. 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
GstApp.AppSink.pull_sample
().If an EOS event was received before any buffers, this function returns
None
. UseGstApp.AppSink.is_eos
() 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/
None
state.
- pull_sample()[source]¶
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
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
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.
- set_buffer_list_support(enable_lists)[source]¶
- Parameters:
enable_lists (
bool
) – enable or disable buffer list support
Instruct self to enable or disable buffer list support.
For backwards-compatibility reasons applications need to opt in to indicate that they will be able to handle buffer lists.
New in version 1.12.
- set_caps(caps)[source]¶
-
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.
- set_drop(drop)[source]¶
- Parameters:
drop (
bool
) – the new state
Instruct self 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).
- set_emit_signals(emit)[source]¶
- Parameters:
emit (
bool
) – the new state
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.
- set_max_buffers(max)[source]¶
- Parameters:
max (
int
) – the maximum number of buffers to queue
Set the maximum amount of buffers that can be queued in self. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a sample is pulled from self, unless ‘drop’ is set, in which case new buffers will be discarded.
- set_max_bytes(max)[source]¶
- Parameters:
max (
int
) – the maximum total size of buffers to queue, in bytes
Set the maximum total size that can be queued in self. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a sample is pulled from self, unless ‘drop’ is set, in which case new buffers will be discarded.
New in version 1.24.
- set_max_time(max)[source]¶
- Parameters:
max (
int
) – the maximum total duration to queue
Set the maximum total duration that can be queued in self. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a sample is pulled from self, unless ‘drop’ is set, in which case new buffers will be discarded.
New in version 1.24.
- set_wait_on_eos(wait)[source]¶
- Parameters:
wait (
bool
) – the new state
Instruct self to wait for all buffers to be consumed when an EOS is received.
- try_pull_preroll(timeout)[source]¶
- Parameters:
timeout (
int
) – the maximum amount of time to wait for the preroll sample- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
Get the last preroll sample in self. 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
GstApp.AppSink.pull_sample
().If an EOS event was received before any buffers or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.This function blocks until a preroll sample or EOS is received, the appsink element is set to the READY/
None
state, or the timeout expires.New in version 1.10.
- try_pull_sample(timeout)[source]¶
- Parameters:
timeout (
int
) – the maximum amount of time to wait for a sample- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
state or the timeout expires.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 or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.New in version 1.10.
- do_eos() virtual¶
- do_new_preroll() virtual¶
- Return type:
- do_new_sample() virtual¶
- Return type:
- do_pull_preroll() virtual¶
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
Get the last preroll sample in appsink. 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
GstApp.AppSink.pull_sample
().If an EOS event was received before any buffers, this function returns
None
. UseGstApp.AppSink.is_eos
() 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/
None
state.
- do_pull_sample() virtual¶
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
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
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.
- do_try_pull_preroll(timeout) virtual¶
- Parameters:
timeout (
int
) – the maximum amount of time to wait for the preroll sample- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
Get the last preroll sample in appsink. 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
GstApp.AppSink.pull_sample
().If an EOS event was received before any buffers or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.This function blocks until a preroll sample or EOS is received, the appsink element is set to the READY/
None
state, or the timeout expires.New in version 1.10.
- do_try_pull_sample(timeout) virtual¶
- Parameters:
timeout (
int
) – the maximum amount of time to wait for a sample- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires. Call gst_sample_unref() after usage.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
state or the timeout expires.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 or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.New in version 1.10.
Signal Details¶
- GstApp.AppSink.signals.eos(app_sink)¶
- Signal Name:
eos
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal
Signal that the end-of-stream has been reached. This signal is emitted from the streaming thread.
- GstApp.AppSink.signals.new_preroll(app_sink)¶
- Signal Name:
new-preroll
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal- Return type:
Signal that a new preroll sample is available.
This signal is emitted from the streaming thread and only when the “emit-signals” property is
True
.The new preroll sample can be retrieved with the “pull-preroll” action signal or
GstApp.AppSink.pull_preroll
() either from this signal callback or from any other thread.Note that this signal is only emitted when the “emit-signals” property is set to
True
, which it is not by default for performance reasons.
- GstApp.AppSink.signals.new_sample(app_sink)¶
- Signal Name:
new-sample
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal- Return type:
Signal that a new sample is available.
This signal is emitted from the streaming thread and only when the “emit-signals” property is
True
.The new sample can be retrieved with the “pull-sample” action signal or
GstApp.AppSink.pull_sample
() either from this signal callback or from any other thread.Note that this signal is only emitted when the “emit-signals” property is set to
True
, which it is not by default for performance reasons.
- GstApp.AppSink.signals.new_serialized_event(app_sink)¶
- Signal Name:
new-serialized-event
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal- Return type:
Signal that a new downstream serialized event is available.
This signal is emitted from the streaming thread and only when the “emit-signals” property is
True
.The new event can be retrieved with the “try-pull-object” action signal or gst_app_sink_pull_object() either from this signal callback or from any other thread.
EOS will not be notified using this signal, use
GstApp.AppSink
::eos
instead. EOS cannot be pulled either, useGstApp.AppSink.is_eos
() to check for it.Note that this signal is only emitted when the “emit-signals” property is set to
True
, which it is not by default for performance reasons.The callback should return
True
if the event has been handled, which will skip basesink handling of the event,False
otherwise.New in version 1.20.
- GstApp.AppSink.signals.propose_allocation(app_sink, query)¶
- Signal Name:
propose-allocation
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signalquery (
Gst.Query
) – the allocation query
- Return type:
Signal that a new propose_allocation query is available.
This signal is emitted from the streaming thread and only when the “emit-signals” property is
True
.New in version 1.24.
- GstApp.AppSink.signals.pull_preroll(app_sink)¶
- Signal Name:
pull-preroll
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS.- Return type:
Gst.Sample
orNone
Get the last preroll sample in appsink. 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
GstApp.AppSink.pull_sample
() or the “pull-sample” action signal.If an EOS event was received before any buffers, this function returns
None
. UseGstApp.AppSink.is_eos
() 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/
None
state.
- GstApp.AppSink.signals.pull_sample(app_sink)¶
- Signal Name:
pull-sample
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signal- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
state.This function will only return samples when the appsink is in the PLAYING state. All rendered samples 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 samples could consume a lot of memory, especially when dealing with raw video frames. It’s possible to control the behaviour of the queue with the “drop” and “max-buffers” / “max-bytes” / “max-time” set of properties.
If an EOS event was received before any buffers, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.
- GstApp.AppSink.signals.try_pull_object(app_sink, timeout)¶
- Signal Name:
try-pull-object
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signaltimeout (
int
) – the maximum amount of time to wait for a sample
- Returns:
a
Gst.Sample
or aGst.Event
orNone
when the appsink is stopped or EOS or the timeout expires.- Return type:
This function blocks until a sample or an event becomes available or the appsink element is set to the READY/
None
state or the timeout expires.This function will only return samples when the appsink is in the PLAYING state. All rendered samples and events will be put in a queue so that the application can pull them at its own rate. Events can be pulled when the appsink is in the READY, PAUSED or PLAYING state.
Note that when the application does not pull samples fast enough, the queued samples could consume a lot of memory, especially when dealing with raw video frames. It’s possible to control the behaviour of the queue with the “drop” and “max-buffers” / “max-bytes” / “max-time” set of properties.
This function will only pull serialized events, excluding the EOS event for which this functions returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.This signal is a variant of
GstApp.AppSink
::try-pull-sample
: that can be used to handle incoming events as well as samples.Note that future releases may extend this API to return other object types so make sure that your code is checking for the actual type it is handling.
New in version 1.20.
- GstApp.AppSink.signals.try_pull_preroll(app_sink, timeout)¶
- Signal Name:
try-pull-preroll
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signaltimeout (
int
) – the maximum amount of time to wait for the preroll sample
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires.- Return type:
Gst.Sample
orNone
Get the last preroll sample in appsink. 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
GstApp.AppSink.pull_sample
() or the “pull-sample” action signal.If an EOS event was received before any buffers or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.This function blocks until a preroll sample or EOS is received, the appsink element is set to the READY/
None
state, or the timeout expires.New in version 1.10.
- GstApp.AppSink.signals.try_pull_sample(app_sink, timeout)¶
- Signal Name:
try-pull-sample
- Flags:
- Parameters:
app_sink (
GstApp.AppSink
) – The object which received the signaltimeout (
int
) – the maximum amount of time to wait for a sample
- Returns:
a
Gst.Sample
orNone
when the appsink is stopped or EOS or the timeout expires.- Return type:
Gst.Sample
orNone
This function blocks until a sample or EOS becomes available or the appsink element is set to the READY/
None
state or the timeout expires.This function will only return samples when the appsink is in the PLAYING state. All rendered samples 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 samples could consume a lot of memory, especially when dealing with raw video frames. It’s possible to control the behaviour of the queue with the “drop” and “max-buffers” / “max-bytes” / “max-time” set of properties.
If an EOS event was received before any buffers or the timeout expires, this function returns
None
. UseGstApp.AppSink.is_eos
() to check for the EOS condition.New in version 1.10.
Property Details¶
- GstApp.AppSink.props.buffer_list¶
-
Use buffer lists
- GstApp.AppSink.props.caps¶
-
The allowed caps for the sink pad
- GstApp.AppSink.props.drop¶
-
Drop old buffers when the buffer queue is filled
- GstApp.AppSink.props.emit_signals¶
-
Emit new-preroll and new-sample signals
- GstApp.AppSink.props.eos¶
-
Check if the sink is EOS or not started
- GstApp.AppSink.props.max_buffers¶
-
Maximum amount of buffers in the queue (0 = unlimited).
- GstApp.AppSink.props.max_bytes¶
-
Maximum amount of bytes in the queue (0 = unlimited)
New in version 1.24.
- GstApp.AppSink.props.max_time¶
-
Maximum total duration of data in the queue (0 = unlimited)
New in version 1.24.