public class AppSrc extends BaseSrc
Element that provides an easy way for applications to insert
data into a GStreamer pipeline.
See upstream documentation at https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gst-plugins-base-libs/html/gst-plugins-base-libs-appsrc.html
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 (not yet mapped). 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
pushBuffer(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" property controls 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 accessable 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
endOfStream() 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.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AppSrc.ENOUGH_DATA
Signal that the source has enough data.
|
static interface |
AppSrc.NEED_DATA
Signal that the source needs more data.
|
static interface |
AppSrc.SEEK_DATA
Seek to the given offset, expressed in terms of the
Format set on
the AppSrc. |
static class |
AppSrc.StreamType
The stream type.
|
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(AppSrc.ENOUGH_DATA listener)
Adds a listener for the
enough-data signal |
void |
connect(AppSrc.NEED_DATA listener)
Adds a listener for the
need-data signal |
void |
connect(AppSrc.SEEK_DATA listener)
Adds a listener for the
seek-data signal |
void |
disconnect(AppSrc.ENOUGH_DATA listener)
Removes a listener for the
enough-data signal |
void |
disconnect(AppSrc.NEED_DATA listener)
Removes a listener for the
need-data signal |
void |
disconnect(AppSrc.SEEK_DATA listener)
Removes a listener for the
seek-data signal |
FlowReturn |
endOfStream()
Indicates to the appsrc element that the last buffer queued in the
element is the last buffer of the stream.
|
Caps |
getCaps()
Get the configured Caps on the AppSrc.
|
long[] |
getLatency()
Get the latency.
|
long |
getMaxBytes()
Get the maximum number of bytes that can be queued.
|
long |
getSize()
Get the size of the stream in bytes.
|
AppSrc.StreamType |
getStreamType()
Get the stream type set on the appsrc.
|
FlowReturn |
pushBuffer(Buffer buffer)
Adds a buffer to the queue of buffers that the appsrc element will push
to its source pad.
|
void |
setCaps(Caps caps)
Set the capabilities on the appsrc element.
|
void |
setLatency(long min,
long max)
Configure the min and max latency in src .
|
void |
setMaxBytes(long max)
Set the maximum amount of bytes that can be queued in appsrc .
|
void |
setSize(long size)
Set the size of the stream in bytes.
|
void |
setStreamType(AppSrc.StreamType type)
Set the stream type on appsrc .
|
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 AppSrc(String name)
public void setCaps(Caps caps)
public Caps getCaps()
public void setSize(long size)
size - the size to set, or -1 if not knownpublic long getSize()
public void setStreamType(AppSrc.StreamType type)
type - stream typepublic AppSrc.StreamType getStreamType()
public void setMaxBytes(long max)
max - number of bytes to queuepublic long getMaxBytes()
public void setLatency(long min,
long max)
min - the minimum latencymax - the maximum latencypublic long[] getLatency()
long[]{min, max} public FlowReturn pushBuffer(Buffer buffer)
When the block property is TRUE, this function can block until free space becomes available in the queue.
buffer - a Buffer to pushpublic FlowReturn endOfStream()
public void connect(AppSrc.ENOUGH_DATA listener)
enough-data signallistener - Listener to be called this when appsrc fills its queue.public void disconnect(AppSrc.ENOUGH_DATA listener)
enough-data signallistener - The listener that was previously added.public void connect(AppSrc.NEED_DATA listener)
need-data signallistener - Listener to be called when appsrc needs data.public void disconnect(AppSrc.NEED_DATA listener)
need-data signallistener - The listener that was previously added.public void connect(AppSrc.SEEK_DATA listener)
seek-data signallistener - listener to be called when a seek is requestedpublic void disconnect(AppSrc.SEEK_DATA listener)
seek-data signallistener - The listener that was previously added.Copyright © 2021 gstreamer-java. All rights reserved.