Documentation ¶
Overview ¶
Package app contains bindings for the gstreamer-app C API. If you are trying to build simple pipelines quickly (and optiionally readers/writers) see the gstauto/app package.
The location of this library may be different depending on your OS. It is usually either with the gst-plugins-base development headers or a separate package called gstreamer-app.
Index ¶
- Variables
- type Sink
- func (a *Sink) GetBufferListSupport() bool
- func (a *Sink) GetCaps() *gst.Caps
- func (a *Sink) GetDrop() bool
- func (a *Sink) GetEmitSignals() bool
- func (a *Sink) GetMaxBuffers() uint
- func (a *Sink) GetWaitOnEOS() bool
- func (a *Sink) Instance() *C.GstAppSink
- func (a *Sink) IsEOS() bool
- func (a *Sink) PullPreroll() *gst.Sample
- func (a *Sink) PullSample() *gst.Sample
- func (a *Sink) SetBufferListSupport(enabled bool)
- func (a *Sink) SetCallbacks(cbs *SinkCallbacks)
- func (a *Sink) SetCaps(caps *gst.Caps)
- func (a *Sink) SetDrop(drop bool)
- func (a *Sink) SetEmitSignals(emit bool)
- func (a *Sink) SetMaxBuffers(max uint)
- func (a *Sink) SetWaitOnEOS(wait bool)
- func (a *Sink) TryPullPreroll(timeout time.Duration) *gst.Sample
- func (a *Sink) TryPullSample(timeout time.Duration) *gst.Sample
- type SinkCallbacks
- type Source
- func (a *Source) EndStream() gst.FlowReturn
- func (a *Source) GetCaps() *gst.Caps
- func (a *Source) GetCurrentLevelBytes() uint64
- func (a *Source) GetDuration() time.Duration
- func (a *Source) GetEmitSignals() bool
- func (a *Source) GetLatency() (min, max uint64)
- func (a *Source) GetMaxBytes() uint64
- func (a *Source) GetSize() int64
- func (a *Source) GetStreamType() StreamType
- func (a *Source) Instance() *C.GstAppSrc
- func (a *Source) PushBuffer(buf *gst.Buffer) gst.FlowReturn
- func (a *Source) PushBufferList(bufList *gst.BufferList) gst.FlowReturn
- func (a *Source) PushSample(sample *gst.Sample) gst.FlowReturn
- func (a *Source) SetCallbacks(cbs *SourceCallbacks)
- func (a *Source) SetCaps(caps *gst.Caps)
- func (a *Source) SetDuration(dur time.Duration)
- func (a *Source) SetEmitSignals(emit bool)
- func (a *Source) SetLatency(min, max uint64)
- func (a *Source) SetMaxBytes(max uint64)
- func (a *Source) SetSize(size int64)
- func (a *Source) SetStreamType(streamType StreamType)
- type SourceCallbacks
- type StreamType
Constants ¶
This section is empty.
Variables ¶
var ErrEOS = errors.New("Pipeline has reached end-of-stream")
ErrEOS represents that the stream has ended.
Functions ¶
This section is empty.
Types ¶
type Sink ¶
type Sink struct{ *base.GstBaseSink }
Sink wraps an Element made with the appsink plugin with additional methods for pulling samples.
func NewAppSink ¶
NewAppSink returns a new appsink element. Unref after usage.
func SinkFromElement ¶
SinkFromElement checks if the given element is an appsink and if so returns a Sink interace.
func (*Sink) GetBufferListSupport ¶
GetBufferListSupport checks if appsink supports buffer lists.
func (*Sink) GetDrop ¶
GetDrop checks if appsink will drop old buffers when the maximum amount of queued buffers is reached.
func (*Sink) GetEmitSignals ¶
GetEmitSignals checks if appsink will emit the "new-preroll" and "new-sample" signals.
func (*Sink) GetMaxBuffers ¶
GetMaxBuffers gets the maximum amount of buffers that can be queued in appsink.
func (*Sink) GetWaitOnEOS ¶
GetWaitOnEOS checks if appsink will wait for all buffers to be consumed when an EOS is received.
func (*Sink) Instance ¶
func (a *Sink) Instance() *C.GstAppSink
Instance returns the native GstAppSink instance.
func (*Sink) PullPreroll ¶
PullPreroll gets 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 gst_app_sink_pull_sample.
If an EOS event was received before any buffers, this function returns NULL. Use gst_app_sink_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/NULL state.
func (*Sink) PullSample ¶
PullSample blocks until a sample or EOS becomes available or the appsink element is set to the READY/NULL 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 NULL. Use IsEOS() to check for the EOS condition.
func (*Sink) SetBufferListSupport ¶
SetBufferListSupport instructs appsink 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.
func (*Sink) SetCallbacks ¶
func (a *Sink) SetCallbacks(cbs *SinkCallbacks)
SetCallbacks sets callbacks which will be executed for each new preroll, new sample and eos. This is an alternative to using the signals, it has lower overhead and is thus less expensive, but also less flexible.
If callbacks are installed, no signals will be emitted for performance reasons.
Before 1.16.3 it was not possible to change the callbacks in a thread-safe way.
func (*Sink) SetCaps ¶
SetCaps sets 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.
func (*Sink) SetDrop ¶
SetDrop instructs appsink to drop old buffers when the maximum amount of queued buffers is reached.
func (*Sink) SetEmitSignals ¶
SetEmitSignals makes 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.
func (*Sink) SetMaxBuffers ¶
SetMaxBuffers sets 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.
func (*Sink) SetWaitOnEOS ¶
SetWaitOnEOS instructs appsink to wait for all buffers to be consumed when an EOS is received.
func (*Sink) TryPullPreroll ¶
TryPullPreroll gets 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 PullSample.
If an EOS event was received before any buffers or the timeout expires, this function returns NULL. Use IsEOS () 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/NULL state, or the timeout expires.
func (*Sink) TryPullSample ¶
TryPullSample blocks until a sample or EOS becomes available or the appsink element is set to the READY/NULL 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 NULL. Use IsEOS () to check for the EOS condition.
type SinkCallbacks ¶
type SinkCallbacks struct { EOSFunc func(appSink *Sink) NewPrerollFunc func(appSink *Sink) gst.FlowReturn NewSampleFunc func(appSink *Sink) gst.FlowReturn }
SinkCallbacks represents callbacks that can be installed on an app sink when data is available.
type Source ¶
type Source struct{ *base.GstBaseSrc }
Source wraps an Element made with the appsrc plugin with additional methods for pushing samples.
func SrcFromElement ¶
SrcFromElement checks if the given element is an appsrc and if so returns a Source interace.
func (*Source) EndStream ¶
func (a *Source) EndStream() gst.FlowReturn
EndStream signals to the app source that the stream has ended after the last queued buffer.
func (*Source) GetCurrentLevelBytes ¶
GetCurrentLevelBytes gets the number of currently queued bytes inside appsrc.
func (*Source) GetDuration ¶
GetDuration gets the duration of the stream in nanoseconds. A negative value means that the duration is not known.
func (*Source) GetEmitSignals ¶
GetEmitSignals checks if appsrc will emit the "new-preroll" and "new-buffer" signals.
func (*Source) GetLatency ¶
GetLatency retrieves the min and max latencies in min and max respectively.
func (*Source) GetMaxBytes ¶
GetMaxBytes gets the maximum amount of bytes that can be queued in appsrc.
func (*Source) GetSize ¶
GetSize gets the size of the stream in bytes. A value of -1 means that the size is not known.
func (*Source) GetStreamType ¶
func (a *Source) GetStreamType() StreamType
GetStreamType gets the stream type. Control the stream type of appsrc with SetStreamType.
func (*Source) PushBuffer ¶
func (a *Source) PushBuffer(buf *gst.Buffer) gst.FlowReturn
PushBuffer pushes a buffer to the appsrc. Currently by default this will block until the source is ready to accept the buffer.
func (*Source) PushBufferList ¶
func (a *Source) PushBufferList(bufList *gst.BufferList) gst.FlowReturn
PushBufferList 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.
func (*Source) PushSample ¶
func (a *Source) PushSample(sample *gst.Sample) gst.FlowReturn
PushSample 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.
func (*Source) SetCallbacks ¶
func (a *Source) SetCallbacks(cbs *SourceCallbacks)
SetCallbacks sets callbacks which will be executed when data is needed, enough data has been collected or when a seek should be performed. This is an alternative to using the signals, it has lower overhead and is thus less expensive, but also less flexible.
If callbacks are installed, no signals will be emitted for performance reasons.
Before 1.16.3 it was not possible to change the callbacks in a thread-safe way.
func (*Source) SetCaps ¶
SetCaps sets 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 NULL.
func (*Source) SetDuration ¶
SetDuration sets the duration of the source stream. You should call this if the value is known.
func (*Source) SetEmitSignals ¶
SetEmitSignals makes 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.
func (*Source) SetLatency ¶
SetLatency configures the min and max latency in src. If min is set to -1, the default latency calculations for pseudo-live sources will be used.
func (*Source) SetMaxBytes ¶
SetMaxBytes sets the maximum amount of bytes that can be queued in appsrc. After the maximum amount of bytes are queued, appsrc will emit the "enough-data" signal.
func (*Source) SetSize ¶
SetSize sets the size of the source stream in bytes. You should call this for streams of fixed length.
func (*Source) SetStreamType ¶
func (a *Source) SetStreamType(streamType StreamType)
SetStreamType sets the stream type on appsrc. For seekable streams, the "seek" signal must be connected to.
type SourceCallbacks ¶
type SourceCallbacks struct { NeedDataFunc func(src *Source, length uint) EnoughDataFunc func(src *Source) SeekDataFunc func(src *Source, offset uint64) bool }
SourceCallbacks represents callbacks to configure on an AppSource.
type StreamType ¶
type StreamType int
StreamType casts GstAppStreamType
const ( AppStreamTypeStream StreamType = C.GST_APP_STREAM_TYPE_STREAM // (0) – No seeking is supported in the stream, such as a live stream. AppStreamTypeSeekable StreamType = C.GST_APP_STREAM_TYPE_SEEKABLE // (1) – The stream is seekable but seeking might not be very fast, such as data from a webserver. AppStreamTypeRandomAccess StreamType = C.GST_APP_STREAM_TYPE_RANDOM_ACCESS // (2) – The stream is seekable and seeking is fast, such as in a local file. )
Type castings