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 gst_app_src_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
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
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.
- public bool block { get; set; }
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.
- public Caps caps { owned get; set; }
The GstCaps that will negotiated downstream and will be put on
outgoing buffers.
- public uint64 current_level_buffers { get; }
The number of currently queued buffers inside appsrc.
- public uint64 current_level_bytes { get; }
The number of currently queued bytes inside appsrc.
- public uint64 current_level_time { get; }
The amount of currently queued time inside appsrc.
- public uint64 duration { get; set; }
The total duration in nanoseconds of the data stream.
- public bool emit_signals { get; set; }
Make appsrc emit the "need-data", "enough-data" and "seek-data"
signals.
- public Format format { get; set; }
The format to use for segment events.
- public bool handle_segment_change { get; set; }
When enabled, appsrc will check GstSegment in GstSample which was
pushed via push_sample or "push-sample" signal action.
- public bool is_live { get; set; }
Instruct the source to behave like a live source.
- public LeakyType leaky_type { get; set; }
When set to any other value than GST_APP_LEAKY_TYPE_NONE then the
appsrc will drop any buffers that are pushed into it once its internal queue is full.
- public uint64 max_buffers { get; set; }
The maximum amount of buffers that can be queued internally.
- public uint64 max_bytes { get; set; }
The maximum amount of bytes that can be queued internally.
- public int64 max_latency { get; set; }
- public uint64 max_time { get; set; }
The maximum amount of time that can be queued internally.
- public int64 min_latency { get; set; }
The minimum latency of the source.
- public uint min_percent { get; set; }
Make appsrc emit the "need-data" signal when the amount of bytes in
the queue drops below this percentage of max-bytes.
- public int64 size { get; set; }
The total size in bytes of the data stream.
- public StreamType stream_type { get; set; }
The type of stream that this source is producing.
- public Caps get_caps ()
Get the configured caps on this.
- public uint64 get_current_level_buffers ()
Get the number of currently queued buffers inside
this.
- public uint64 get_current_level_bytes ()
Get the number of currently queued bytes inside
this.
- public ClockTime get_current_level_time ()
Get the amount of currently queued time inside
this.
- public ClockTime get_duration ()
Get the duration of the stream in nanoseconds.
- public bool get_emit_signals ()
Check if appsrc will emit the "new-preroll" and "new-buffer" signals.
- public void get_latency (out uint64 min, out uint64 max)
Retrieve the min and max latencies in min
and max
respectively.
- public LeakyType get_leaky_type ()
- public uint64 get_max_buffers ()
Get the maximum amount of buffers that can be queued in
this.
- public uint64 get_max_bytes ()
Get the maximum amount of bytes that can be queued in
this.
- public ClockTime get_max_time ()
Get the maximum amount of time that can be queued in
this.
- public int64 get_size ()
Get the size of the stream in bytes.
- public StreamType get_stream_type ()
Get the stream type.
- public virtual FlowReturn push_buffer (owned Buffer buffer)
Adds a buffer to the queue of buffers that the appsrc element will
push to its source pad.
- public virtual FlowReturn push_buffer_list (owned BufferList buffer_list)
Adds a buffer list to the queue of buffers and buffer lists that the
appsrc element will push to its source pad.
- public void set_caps (Caps? caps)
Set the capabilities on the appsrc element.
- public void set_duration (ClockTime duration)
Set the duration of the stream in nanoseconds.
- public void set_emit_signals (bool emit)
Make appsrc emit the "new-preroll" and "new-buffer" signals.
- public void set_latency (uint64 min, uint64 max)
Configure the min
and max
latency in
src
.
- public void set_leaky_type (LeakyType leaky)
When set to any other value than GST_APP_LEAKY_TYPE_NONE then the
appsrc will drop any buffers that are pushed into it once its internal queue is full.
- public void set_max_buffers (uint64 max)
Set the maximum amount of buffers that can be queued in
this.
- public void set_max_bytes (uint64 max)
Set the maximum amount of bytes that can be queued in
this.
- public void set_max_time (ClockTime max)
Set the maximum amount of time that can be queued in
this.
- public void set_size (int64 size)
Set the size of the stream in bytes.
- public void set_stream_type (StreamType type)
Set the stream type on this.