GstApp.AppSrc¶
- Subclasses:
None
Methods¶
- Inherited:
GstBase.BaseSrc (23), Gst.Element (82), Gst.Object (27), GObject.Object (37), Gst.URIHandler (4)
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
GstBase.BaseSrc (19), Gst.Element (16), Gst.Object (1), GObject.Object (7), Gst.URIHandler (2)
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Block push-buffer when max-bytes are queued |
||
r/w |
The allowed caps for the src pad |
||
r |
The number of currently queued buffers |
||
r |
The number of currently queued bytes |
||
r |
The amount of currently queued time |
||
r/w |
The duration of the data stream in nanoseconds ( |
||
r/w |
Emit need-data, enough-data and seek-data signals |
||
r/w |
The format of the segment events and seek |
||
r/w |
Whether to detect and handle changed time format |
||
r/w |
Whether to act as a live source |
||
r/w |
Whether to drop buffers once the internal queue is full |
||
r/w |
The maximum number of buffers to queue internally (0 = unlimited) |
||
r/w |
The maximum number of bytes to queue internally (0 = unlimited) |
||
r/w |
The maximum latency (-1 = unlimited) |
||
r/w |
The maximum amount of time to queue internally (0 = unlimited) |
||
r/w |
The minimum latency (-1 = default) |
||
r/w |
Emit need-data when queued bytes drops below this percent of max-bytes |
||
r/w |
The size of the data stream in bytes (-1 if unknown) |
||
r/w |
the type of the stream |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Notify appsrc that no more buffer are available. |
|
Signal that the source has enough data. |
|
Signal that the source needs more data. |
|
Adds a buffer to the queue of buffers that the appsrc element will push to its source pad. |
|
Adds a buffer list to the queue of buffers and buffer lists that the appsrc element will push to its source pad. |
|
Extract a buffer from the provided sample and adds the extracted buffer to the queue of buffers that the appsrc element will push to its source pad. |
|
Seek to the given offset. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
basesrc |
r |
Class Details¶
- class GstApp.AppSrc(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The appsrc element can be used by applications to insert data into a GStreamer pipeline. Unlike most GStreamer elements, appsrc provides external API functions.
appsrc can be used by linking with the libgstapp library to access the methods directly or by using the appsrc action signals.
Before operating appsrc, the caps property must be set to fixed caps describing the format of the data that will be pushed with appsrc. An exception to this is when pushing buffers with unknown caps, in which case no caps should be set. This is typically true of file-like sources that push raw byte buffers. If you don’t want to explicitly set the caps, you can use
GstApp.AppSrc.push_sample
. This method gets the caps associated with the sample and sets them on the appsrc replacing any previously set caps (if different from sample’s caps).The main way of handing data to the appsrc element is by calling the
GstApp.AppSrc.push_buffer
() method or by emitting the push-buffer action signal. This will put the buffer onto a queue from which appsrc will read from in its streaming thread. It is important to note that data transport will not happen from the thread that performed the push-buffer call.The “max-bytes”, “max-buffers” and “max-time” properties control how much data can be queued in appsrc before appsrc considers the queue full. A filled internal queue will always signal the “enough-data” signal, which signals the application that it should stop pushing data into appsrc. The “block” property will cause appsrc to block the push-buffer method until free data becomes available again.
When the internal queue is running out of data, the “need-data” signal is emitted, which signals the application that it should start pushing more data into appsrc.
In addition to the “need-data” and “enough-data” signals, appsrc can emit the “seek-data” signal when the “stream-mode” property is set to “seekable” or “random-access”. The signal argument will contain the new desired position in the stream expressed in the unit set with the “format” property. After receiving the seek-data signal, the application should push-buffers from the new position.
These signals allow the application to operate the appsrc in two different ways:
The push mode, in which the application repeatedly calls the push-buffer/push-sample method with a new buffer/sample. Optionally, the queue size in the appsrc can be controlled with the enough-data and need-data signals by respectively stopping/starting the push-buffer/push-sample calls. This is a typical mode of operation for the stream-type “stream” and “seekable”. Use this mode when implementing various network protocols or hardware devices.
The pull mode, in which the need-data signal triggers the next push-buffer call. This mode is typically used in the “random-access” stream-type. Use this mode for file access or other randomly accessible sources. In this mode, a buffer of exactly the amount of bytes given by the need-data signal should be pushed into appsrc.
In all modes, the size property on appsrc should contain the total stream size in bytes. Setting this property is mandatory in the random-access mode. For the stream and seekable modes, setting this property is optional but recommended.
When the application has finished pushing data into appsrc, it should call
GstApp.AppSrc.end_of_stream
() or emit the end-of-stream action signal. After this call, no more buffers can be pushed into appsrc until a flushing seek occurs or the state of the appsrc has gone through READY.- end_of_stream()[source]¶
- Returns:
Gst.FlowReturn.OK
when the EOS was successfully queued.Gst.FlowReturn.FLUSHING
when self is not PAUSED or PLAYING.- Return type:
Indicates to the appsrc element that the last buffer queued in the element is the last buffer of the stream.
- get_caps()[source]¶
- Returns:
the
Gst.Caps
produced by the source. gst_caps_unref() after usage.- Return type:
Get the configured caps on self.
- get_current_level_buffers()[source]¶
- Returns:
The number of currently queued buffers.
- Return type:
Get the number of currently queued buffers inside self.
New in version 1.20.
- get_current_level_bytes()[source]¶
- Returns:
The number of currently queued bytes.
- Return type:
Get the number of currently queued bytes inside self.
New in version 1.2.
- get_current_level_time()[source]¶
- Returns:
The amount of currently queued time.
- Return type:
Get the amount of currently queued time inside self.
New in version 1.20.
- get_duration()[source]¶
- Returns:
the duration of the stream previously set with
GstApp.AppSrc.set_duration
();- Return type:
Get the duration of the stream in nanoseconds. A value of
Gst.CLOCK_TIME_NONE
means that the duration is not known.New in version 1.10.
- get_leaky_type()[source]¶
- Returns:
The currently set
GstApp.AppLeakyType
.- Return type:
Returns the currently set
GstApp.AppLeakyType
. SeeGstApp.AppSrc.set_leaky_type
() for more details.New in version 1.20.
- 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.
New in version 1.20.
- get_max_bytes()[source]¶
- Returns:
The maximum amount of bytes that can be queued.
- Return type:
Get the maximum amount of bytes that can be queued in self.
- get_max_time()[source]¶
- Returns:
The maximum amount of time that can be queued.
- Return type:
Get the maximum amount of time that can be queued in self.
New in version 1.20.
- get_size()[source]¶
- Returns:
the size of the stream previously set with
GstApp.AppSrc.set_size
();- Return type:
Get the size of the stream in bytes. A value of -1 means that the size is not known.
- get_stream_type()[source]¶
- Returns:
the stream type.
- Return type:
Get the stream type. Control the stream type of self with
GstApp.AppSrc.set_stream_type
().
- push_buffer(buffer)[source]¶
- Parameters:
buffer (
Gst.Buffer
) – aGst.Buffer
to push- Returns:
Gst.FlowReturn.OK
when the buffer was successfully queued.Gst.FlowReturn.FLUSHING
when self is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Adds a buffer to the queue of buffers that the appsrc element will push to its source pad. This function takes ownership of the buffer.
When the block property is
True
, this function can block until free space becomes available in the queue.
- push_buffer_list(buffer_list)[source]¶
- Parameters:
buffer_list (
Gst.BufferList
) – aGst.BufferList
to push- Returns:
Gst.FlowReturn.OK
when the buffer list was successfully queued.Gst.FlowReturn.FLUSHING
when self is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Adds a buffer list to the queue of buffers and buffer lists that the appsrc element will push to its source pad. This function takes ownership of buffer_list.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.14.
- push_sample(sample)[source]¶
- Parameters:
sample (
Gst.Sample
) – aGst.Sample
from which buffer and caps may be extracted- Returns:
Gst.FlowReturn.OK
when the buffer was successfully queued.Gst.FlowReturn.FLUSHING
when self is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Extract a buffer from the provided sample and adds it to the queue of buffers that the appsrc element will push to its source pad. Any previous caps that were set on appsrc will be replaced by the caps associated with the sample if not equal.
This function does not take ownership of the sample so the sample needs to be unreffed after calling this function.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.6.
- set_caps(caps)[source]¶
-
Set the capabilities on the appsrc element. This function takes a copy of the caps structure. After calling this method, the source will only produce caps that match caps. caps must be fixed and the caps on the buffers must match the caps or left
None
.
- set_duration(duration)[source]¶
- Parameters:
duration (
int
) – the duration to set
Set the duration of the stream in nanoseconds. A value of
Gst.CLOCK_TIME_NONE
means that the duration is not known.New in version 1.10.
- set_emit_signals(emit)[source]¶
- Parameters:
emit (
bool
) – the new state
Make appsrc 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.
- set_latency(min, max)[source]¶
-
Configure the min and max latency in src. If min is set to -1, the default latency calculations for pseudo-live sources will be used.
- set_leaky_type(leaky)[source]¶
- Parameters:
leaky (
GstApp.AppLeakyType
) – theGstApp.AppLeakyType
When set to any other value than
GstApp.AppLeakyType.NONE
then the appsrc will drop any buffers that are pushed into it once its internal queue is full. The selected type defines whether to drop the oldest or new buffers.New in version 1.20.
- 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 the maximum amount of buffers are queued, self will emit the “enough-data” signal.
New in version 1.20.
- set_max_bytes(max)[source]¶
- Parameters:
max (
int
) – the maximum number of bytes to queue
Set the maximum amount of bytes that can be queued in self. After the maximum amount of bytes are queued, self will emit the “enough-data” signal.
- set_max_time(max)[source]¶
- Parameters:
max (
int
) – the maximum amonut of time to queue
Set the maximum amount of time that can be queued in self. After the maximum amount of time are queued, self will emit the “enough-data” signal.
New in version 1.20.
- set_size(size)[source]¶
- Parameters:
size (
int
) – the size to set
Set the size of the stream in bytes. A value of -1 means that the size is not known.
- set_stream_type(type)[source]¶
- Parameters:
type (
GstApp.AppStreamType
) – the new state
Set the stream type on self. For seekable streams, the “seek” signal must be connected to.
A stream_type stream
- do_end_of_stream() virtual¶
- Returns:
Gst.FlowReturn.OK
when the EOS was successfully queued.Gst.FlowReturn.FLUSHING
when appsrc is not PAUSED or PLAYING.- Return type:
Indicates to the appsrc element that the last buffer queued in the element is the last buffer of the stream.
- do_enough_data() virtual¶
- do_push_buffer(buffer) virtual¶
- Parameters:
buffer (
Gst.Buffer
) – aGst.Buffer
to push- Returns:
Gst.FlowReturn.OK
when the buffer was successfully queued.Gst.FlowReturn.FLUSHING
when appsrc is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Adds a buffer to the queue of buffers that the appsrc element will push to its source pad. This function takes ownership of the buffer.
When the block property is
True
, this function can block until free space becomes available in the queue.
- do_push_buffer_list(buffer_list) virtual¶
- Parameters:
buffer_list (
Gst.BufferList
) – aGst.BufferList
to push- Returns:
Gst.FlowReturn.OK
when the buffer list was successfully queued.Gst.FlowReturn.FLUSHING
when appsrc is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Adds a buffer list to the queue of buffers and buffer lists that the appsrc element will push to its source pad. This function takes ownership of buffer_list.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.14.
- do_push_sample(sample) virtual¶
- Parameters:
sample (
Gst.Sample
) – aGst.Sample
from which buffer and caps may be extracted- Returns:
Gst.FlowReturn.OK
when the buffer was successfully queued.Gst.FlowReturn.FLUSHING
when appsrc is not PAUSED or PLAYING.Gst.FlowReturn.EOS
when EOS occurred.- Return type:
Extract a buffer from the provided sample and adds it to the queue of buffers that the appsrc element will push to its source pad. Any previous caps that were set on appsrc will be replaced by the caps associated with the sample if not equal.
This function does not take ownership of the sample so the sample needs to be unreffed after calling this function.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.6.
Signal Details¶
- GstApp.AppSrc.signals.end_of_stream(app_src)¶
- Signal Name:
end-of-stream
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signal- Return type:
Notify appsrc that no more buffer are available.
- GstApp.AppSrc.signals.enough_data(app_src)¶
- Signal Name:
enough-data
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signal
Signal that the source has enough data. It is recommended that the application stops calling push-buffer until the need-data signal is emitted again to avoid excessive buffer queueing.
- GstApp.AppSrc.signals.need_data(app_src, length)¶
- Signal Name:
need-data
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signallength (
int
) – the amount of bytes needed.
Signal that the source needs more data. In the callback or from another thread you should call push-buffer or end-of-stream.
length is just a hint and when it is set to -1, any number of bytes can be pushed into appsrc.
You can call push-buffer multiple times until the enough-data signal is fired.
- GstApp.AppSrc.signals.push_buffer(app_src, buffer)¶
- Signal Name:
push-buffer
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signalbuffer (
Gst.Buffer
) – a buffer to push
- Return type:
Adds a buffer to the queue of buffers that the appsrc element will push to its source pad.
This function does not take ownership of the buffer, but it takes a reference so the buffer can be unreffed at any time after calling this function.
When the block property is
True
, this function can block until free space becomes available in the queue.
- GstApp.AppSrc.signals.push_buffer_list(app_src, buffer_list)¶
- Signal Name:
push-buffer-list
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signalbuffer_list (
Gst.BufferList
) – a buffer list to push
- Return type:
Adds a buffer list to the queue of buffers and buffer lists that the appsrc element will push to its source pad.
This function does not take ownership of the buffer list, but it takes a reference so the buffer list can be unreffed at any time after calling this function.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.14.
- GstApp.AppSrc.signals.push_sample(app_src, sample)¶
- Signal Name:
push-sample
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signalsample (
Gst.Sample
) – a sample from which extract buffer to push
- Return type:
Extract a buffer from the provided sample and adds the extracted buffer to the queue of buffers that the appsrc element will push to its source pad. This function set the appsrc caps based on the caps in the sample and reset the caps if they change. Only the caps and the buffer of the provided sample are used and not for example the segment in the sample.
This function does not take ownership of the sample, but it takes a reference so the sample can be unreffed at any time after calling this function.
When the block property is
True
, this function can block until free space becomes available in the queue.New in version 1.6.
- GstApp.AppSrc.signals.seek_data(app_src, offset)¶
- Signal Name:
seek-data
- Flags:
- Parameters:
app_src (
GstApp.AppSrc
) – The object which received the signaloffset (
int
) – the offset to seek to
- Returns:
True
if the seek succeeded.- Return type:
Seek to the given offset. The next push-buffer should produce buffers from the new offset. This callback is only called for seekable stream types.
Property Details¶
- GstApp.AppSrc.props.block¶
-
When max-bytes are queued and after the enough-data signal has been emitted, block any further push-buffer calls until the amount of queued bytes drops below the max-bytes limit.
- GstApp.AppSrc.props.caps¶
-
The
Gst.Caps
that will negotiated downstream and will be put on outgoing buffers.
- GstApp.AppSrc.props.current_level_buffers¶
-
The number of currently queued buffers inside appsrc.
New in version 1.20.
- GstApp.AppSrc.props.current_level_bytes¶
-
The number of currently queued bytes inside appsrc.
New in version 1.2.
- GstApp.AppSrc.props.current_level_time¶
-
The amount of currently queued time inside appsrc.
New in version 1.20.
- GstApp.AppSrc.props.duration¶
-
The total duration in nanoseconds of the data stream. If the total duration is known, it is recommended to configure it with this property.
New in version 1.10.
- GstApp.AppSrc.props.emit_signals¶
-
Make appsrc emit the “need-data”, “enough-data” and “seek-data” signals. This option is by default enabled for backwards compatibility reasons but can disabled when needed because signal emission is expensive.
- GstApp.AppSrc.props.format¶
- Name:
format
- Type:
- Default Value:
- Flags:
The format to use for segment events. When the source is producing timestamped buffers this property should be set to
Gst.Format.TIME
.
- GstApp.AppSrc.props.handle_segment_change¶
-
When enabled, appsrc will check
Gst.Segment
inGst.Sample
which was pushed viaGstApp.AppSrc.push_sample
() or “push-sample” signal action. If aGst.Segment
is changed, corresponding segment event will be followed by next data flow.FIXME: currently only
Gst.Format.TIME
format is supported and thereforeGstApp.AppSrc
::format
should be time. However, possiblyGstApp.AppSrc
can support other formats.New in version 1.18.
- GstApp.AppSrc.props.is_live¶
-
Instruct the source to behave like a live source. This includes that it will only push out buffers in the PLAYING state.
- GstApp.AppSrc.props.leaky_type¶
- Name:
leaky-type
- Type:
- Default Value:
- Flags:
When set to any other value than
GstApp.AppLeakyType.NONE
then the appsrc will drop any buffers that are pushed into it once its internal queue is full. The selected type defines whether to drop the oldest or new buffers.New in version 1.20.
- GstApp.AppSrc.props.max_buffers¶
-
The maximum amount of buffers that can be queued internally. After the maximum amount of buffers are queued, appsrc will emit the “enough-data” signal.
New in version 1.20.
- GstApp.AppSrc.props.max_bytes¶
-
The maximum amount of bytes that can be queued internally. After the maximum amount of bytes are queued, appsrc will emit the “enough-data” signal.
- GstApp.AppSrc.props.max_latency¶
-
The maximum latency (-1 = unlimited)
- GstApp.AppSrc.props.max_time¶
-
The maximum amount of time that can be queued internally. After the maximum amount of time are queued, appsrc will emit the “enough-data” signal.
New in version 1.20.
- GstApp.AppSrc.props.min_latency¶
-
The minimum latency of the source. A value of -1 will use the default latency calculations of
GstBase.BaseSrc
.
- GstApp.AppSrc.props.min_percent¶
-
Make appsrc emit the “need-data” signal when the amount of bytes in the queue drops below this percentage of max-bytes.
- GstApp.AppSrc.props.size¶
-
The total size in bytes of the data stream. If the total size is known, it is recommended to configure it with this property.
- GstApp.AppSrc.props.stream_type¶
- Name:
stream-type
- Type:
- Default Value:
- Flags:
The type of stream that this source is producing. For seekable streams the application should connect to the seek-data signal.