app

package
v0.2.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: LGPL-2.1 Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func NewAppSink() (*Sink, error)

NewAppSink returns a new appsink element. Unref after usage.

func SinkFromElement

func SinkFromElement(elem *gst.Element) *Sink

SinkFromElement checks if the given element is an appsink and if so returns a Sink interace.

func (*Sink) GetBufferListSupport

func (a *Sink) GetBufferListSupport() bool

GetBufferListSupport checks if appsink supports buffer lists.

func (*Sink) GetCaps

func (a *Sink) GetCaps() *gst.Caps

GetCaps gets the configured caps on appsink.

func (*Sink) GetDrop

func (a *Sink) GetDrop() bool

GetDrop checks if appsink will drop old buffers when the maximum amount of queued buffers is reached.

func (*Sink) GetEmitSignals

func (a *Sink) GetEmitSignals() bool

GetEmitSignals checks if appsink will emit the "new-preroll" and "new-sample" signals.

func (*Sink) GetMaxBuffers

func (a *Sink) GetMaxBuffers() uint

GetMaxBuffers gets the maximum amount of buffers that can be queued in appsink.

func (*Sink) GetWaitOnEOS

func (a *Sink) GetWaitOnEOS() bool

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) IsEOS

func (a *Sink) IsEOS() bool

IsEOS returns true if this AppSink has reached the end-of-stream.

func (*Sink) PullPreroll

func (a *Sink) PullPreroll() *gst.Sample

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

func (a *Sink) PullSample() *gst.Sample

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

func (a *Sink) SetBufferListSupport(enabled bool)

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

func (a *Sink) SetCaps(caps *gst.Caps)

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

func (a *Sink) SetDrop(drop bool)

SetDrop instructs appsink to drop old buffers when the maximum amount of queued buffers is reached.

func (*Sink) SetEmitSignals

func (a *Sink) SetEmitSignals(emit bool)

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

func (a *Sink) SetMaxBuffers(max uint)

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

func (a *Sink) SetWaitOnEOS(wait bool)

SetWaitOnEOS instructs appsink to wait for all buffers to be consumed when an EOS is received.

func (*Sink) TryPullPreroll

func (a *Sink) TryPullPreroll(timeout time.Duration) *gst.Sample

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

func (a *Sink) TryPullSample(timeout time.Duration) *gst.Sample

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 NewAppSrc

func NewAppSrc() (*Source, error)

NewAppSrc returns a new AppSrc element.

func SrcFromElement

func SrcFromElement(elem *gst.Element) *Source

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) GetCaps

func (a *Source) GetCaps() *gst.Caps

GetCaps gets the configures caps on the app src.

func (*Source) GetCurrentLevelBytes

func (a *Source) GetCurrentLevelBytes() uint64

GetCurrentLevelBytes gets the number of currently queued bytes inside appsrc.

func (*Source) GetDuration

func (a *Source) GetDuration() time.Duration

GetDuration gets the duration of the stream in nanoseconds. A negative value means that the duration is not known.

func (*Source) GetEmitSignals

func (a *Source) GetEmitSignals() bool

GetEmitSignals checks if appsrc will emit the "new-preroll" and "new-buffer" signals.

func (*Source) GetLatency

func (a *Source) GetLatency() (min, max uint64)

GetLatency retrieves the min and max latencies in min and max respectively.

func (*Source) GetMaxBytes

func (a *Source) GetMaxBytes() uint64

GetMaxBytes gets the maximum amount of bytes that can be queued in appsrc.

func (*Source) GetSize

func (a *Source) GetSize() int64

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) Instance

func (a *Source) Instance() *C.GstAppSrc

Instance returns the native GstAppSink instance.

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

func (a *Source) SetCaps(caps *gst.Caps)

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

func (a *Source) SetDuration(dur time.Duration)

SetDuration sets the duration of the source stream. You should call this if the value is known.

func (*Source) SetEmitSignals

func (a *Source) SetEmitSignals(emit bool)

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

func (a *Source) SetLatency(min, max uint64)

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

func (a *Source) SetMaxBytes(max uint64)

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

func (a *Source) SetSize(size int64)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL