gstbase

package
v0.0.0-...-ccbbe8a Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BASE_PARSE_FLAG_DRAINING = 2
View Source
const BASE_PARSE_FLAG_LOST_SYNC = 1
View Source
const BASE_TRANSFORM_SINK_NAME = "sink"

BASE_TRANSFORM_SINK_NAME: name of the templates for the sink pad.

View Source
const BASE_TRANSFORM_SRC_NAME = "src"

BASE_TRANSFORM_SRC_NAME: name of the templates for the source pad.

Variables

View Source
var (
	GTypeAggregator    = coreglib.Type(C.gst_aggregator_get_type())
	GTypeAggregatorPad = coreglib.Type(C.gst_aggregator_pad_get_type())
)

GType values.

View Source
var (
	GTypeBaseParse      = coreglib.Type(C.gst_base_parse_get_type())
	GTypeBaseParseFrame = coreglib.Type(C.gst_base_parse_frame_get_type())
)

GType values.

View Source
var (
	GTypeAdapter = coreglib.Type(C.gst_adapter_get_type())
)

GType values.

View Source
var (
	GTypeAggregatorStartTimeSelection = coreglib.Type(C.gst_aggregator_start_time_selection_get_type())
)

GType values.

View Source
var (
	GTypeBaseSink = coreglib.Type(C.gst_base_sink_get_type())
)

GType values.

View Source
var (
	GTypeBaseSrc = coreglib.Type(C.gst_base_src_get_type())
)

GType values.

View Source
var (
	GTypeBaseTransform = coreglib.Type(C.gst_base_transform_get_type())
)

GType values.

View Source
var (
	GTypeCollectPads = coreglib.Type(C.gst_collect_pads_get_type())
)

GType values.

View Source
var (
	GTypeDataQueue = coreglib.Type(C.gst_data_queue_get_type())
)

GType values.

View Source
var (
	GTypeFlowCombiner = coreglib.Type(C.gst_flow_combiner_get_type())
)

GType values.

View Source
var (
	GTypePushSrc = coreglib.Type(C.gst_push_src_get_type())
)

GType values.

Functions

func TypeFindHelper

func TypeFindHelper(src *gst.Pad, size uint64) *gst.Caps

TypeFindHelper tries to find what type of data is flowing from the given source Pad.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • src: source Pad.
  • size: length in bytes.

The function returns the following values:

  • caps (optional) corresponding to the data stream. Returns NULL if no Caps matches the data stream.

func TypeFindHelperForBuffer

func TypeFindHelperForBuffer(obj gst.GstObjector, buf *gst.Buffer) (gst.TypeFindProbability, *gst.Caps)

TypeFindHelperForBuffer tries to find what type of data is contained in the given Buffer, the assumption being that the buffer represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of GST_TYPE_FIND_MAXIMUM, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or NULL if the content of the buffer could not be identified.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • obj (optional): object doing the typefinding, or NULL (used for logging).
  • buf with data to typefind.

The function returns the following values:

  • prob (optional): location to store the probability of the found caps, or NULL.
  • caps (optional) corresponding to the data, or NULL if no type could be found. The caller should free the caps returned with gst_caps_unref().

func TypeFindHelperForBufferWithExtension

func TypeFindHelperForBufferWithExtension(obj gst.GstObjector, buf *gst.Buffer, extension string) (gst.TypeFindProbability, *gst.Caps)

TypeFindHelperForBufferWithExtension tries to find what type of data is contained in the given Buffer, the assumption being that the buffer represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of GST_TYPE_FIND_MAXIMUM, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or NULL if the content of the buffer could not be identified.

When extension is not NULL, this function will first try the typefind functions for the given extension, which might speed up the typefinding in many cases.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • obj (optional): object doing the typefinding, or NULL (used for logging).
  • buf with data to typefind.
  • extension (optional) of the media, or NULL.

The function returns the following values:

  • prob (optional): location to store the probability of the found caps, or NULL.
  • caps (optional) corresponding to the data, or NULL if no type could be found. The caller should free the caps returned with gst_caps_unref().

func TypeFindHelperForData

func TypeFindHelperForData(obj gst.GstObjector, data []byte) (gst.TypeFindProbability, *gst.Caps)

TypeFindHelperForData tries to find what type of data is contained in the given data, the assumption being that the data represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of GST_TYPE_FIND_MAXIMUM, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or NULL if the content of data could not be identified.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • obj (optional): object doing the typefinding, or NULL (used for logging).
  • data: * a pointer with data to typefind.

The function returns the following values:

  • prob (optional): location to store the probability of the found caps, or NULL.
  • caps (optional) corresponding to the data, or NULL if no type could be found. The caller should free the caps returned with gst_caps_unref().

func TypeFindHelperForDataWithExtension

func TypeFindHelperForDataWithExtension(obj gst.GstObjector, data []byte, extension string) (gst.TypeFindProbability, *gst.Caps)

TypeFindHelperForDataWithExtension tries to find what type of data is contained in the given data, the assumption being that the data represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of GST_TYPE_FIND_MAXIMUM, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or NULL if the content of data could not be identified.

When extension is not NULL, this function will first try the typefind functions for the given extension, which might speed up the typefinding in many cases.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • obj (optional): object doing the typefinding, or NULL (used for logging).
  • data: * a pointer with data to typefind.
  • extension (optional) of the media, or NULL.

The function returns the following values:

  • prob (optional): location to store the probability of the found caps, or NULL.
  • caps (optional) corresponding to the data, or NULL if no type could be found. The caller should free the caps returned with gst_caps_unref().

func TypeFindHelperForExtension

func TypeFindHelperForExtension(obj gst.GstObjector, extension string) *gst.Caps

TypeFindHelperForExtension tries to find the best Caps associated with extension.

All available typefinders will be checked against the extension in order of rank. The caps of the first typefinder that can handle extension will be returned.

Free-function: gst_caps_unref.

The function takes the following parameters:

  • obj (optional): object doing the typefinding, or NULL (used for logging).
  • extension: extension.

The function returns the following values:

  • caps (optional) corresponding to extension, or NULL if no type could be found. The caller should free the caps returned with gst_caps_unref().

Types

type Adapter

type Adapter struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

Adapter: this class is for elements that receive buffers in an undesired size. While for example raw video contains one image per buffer, the same is not true for a lot of other formats, especially those that come directly from a file. So if you have undefined buffer sizes and require a specific size, this object is for you.

An adapter is created with gst_adapter_new(). It can be freed again with g_object_unref().

The theory of operation is like this: All buffers received are put into the adapter using gst_adapter_push() and the data is then read back in chunks of the desired size using gst_adapter_map()/gst_adapter_unmap() and/or gst_adapter_copy(). After the data has been processed, it is freed using gst_adapter_unmap().

Other methods such as gst_adapter_take() and gst_adapter_take_buffer() combine gst_adapter_map() and gst_adapter_unmap() in one method and are potentially more convenient for some use cases.

For example, a sink pad's chain function that needs to pass data to a library in 512-byte chunks could be implemented like this:

static GstFlowReturn
sink_pad_chain (GstPad *pad, GstObject *parent, GstBuffer *buffer)
{
  MyElement *this;
  GstAdapter *adapter;
  GstFlowReturn ret = GST_FLOW_OK;

  this = MY_ELEMENT (parent);

  adapter = this->adapter;

  // put buffer into adapter
  gst_adapter_push (adapter, buffer);

  // while we can read out 512 bytes, process them
  while (gst_adapter_available (adapter) >= 512 && ret == GST_FLOW_OK) {
    const guint8 *data = gst_adapter_map (adapter, 512);
    // use flowreturn as an error value
    ret = my_library_foo (data);
    gst_adapter_unmap (adapter);
    gst_adapter_flush (adapter, 512);
  }
  return ret;
}

For another example, a simple element inside GStreamer that uses Adapter is the libvisual element.

An element using Adapter in its sink pad chain function should ensure that when the FLUSH_STOP event is received, that any queued data is cleared using gst_adapter_clear(). Data should also be cleared or processed on EOS and when changing state from GST_STATE_PAUSED to GST_STATE_READY.

Also check the GST_BUFFER_FLAG_DISCONT flag on the buffer. Some elements might need to clear the adapter after a discontinuity.

The adapter will keep track of the timestamps of the buffers that were pushed. The last seen timestamp before the current position can be queried with gst_adapter_prev_pts(). This function can optionally return the number of bytes between the start of the buffer that carried the timestamp and the current adapter position. The distance is useful when dealing with, for example, raw audio samples because it allows you to calculate the timestamp of the current adapter position by using the last seen timestamp and the amount of bytes since. Additionally, the gst_adapter_prev_pts_at_offset() can be used to determine the last seen timestamp at a particular offset in the adapter.

The adapter will also keep track of the offset of the buffers (T_BUFFER_OFFSET) that were pushed. The last seen offset before the current position can be queried with gst_adapter_prev_offset(). This function can optionally return the number of bytes between the start of the buffer that carried the offset and the current adapter position.

Additionally the adapter also keeps track of the PTS, DTS and buffer offset at the last discontinuity, which can be retrieved with gst_adapter_pts_at_discont(), gst_adapter_dts_at_discont() and gst_adapter_offset_at_discont(). The number of bytes that were consumed since then can be queried with gst_adapter_distance_from_discont().

A last thing to note is that while Adapter is pretty optimized, merging buffers still might be an operation that requires a malloc() and memcpy() operation, and these operations are not the fastest. Because of this, some functions like gst_adapter_available_fast() are provided to help speed up such cases should you want to. To avoid repeated memory allocations, gst_adapter_copy() can be used to copy data into a (statically allocated) user provided buffer.

Adapter is not MT safe. All operations on an adapter must be serialized by the caller. This is not normally a problem, however, as the normal use case of Adapter is inside one pad's chain function, in which case access is serialized via the pad's STREAM_LOCK.

Note that gst_adapter_push() takes ownership of the buffer passed. Use gst_buffer_ref() before pushing it into the adapter if you still want to access the buffer later. The adapter will never modify the data in the buffer pushed in it.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new Adapter. Free with g_object_unref().

The function returns the following values:

  • adapter: new Adapter.

func (*Adapter) Available

func (adapter *Adapter) Available() uint

Available gets the maximum amount of bytes available, that is it returns the maximum value that can be supplied to gst_adapter_map() without that function returning NULL.

The function returns the following values:

  • gsize: number of bytes available in adapter.

func (*Adapter) AvailableFast

func (adapter *Adapter) AvailableFast() uint

AvailableFast gets the maximum number of bytes that are immediately available without requiring any expensive operations (like copying the data into a temporary buffer).

The function returns the following values:

  • gsize: number of bytes that are available in adapter without expensive operations.

func (*Adapter) Buffer

func (adapter *Adapter) Buffer(nbytes uint) *gst.Buffer

Buffer returns a Buffer containing the first nbytes of the adapter, but does not flush them from the adapter. See gst_adapter_take_buffer() for details.

Caller owns a reference to the returned buffer. gst_buffer_unref() after usage.

Free-function: gst_buffer_unref.

The function takes the following parameters:

  • nbytes: number of bytes to get.

The function returns the following values:

  • buffer (optional) containing the first nbytes of the adapter, or NULL if nbytes bytes are not available. gst_buffer_unref() when no longer needed.

func (*Adapter) BufferFast

func (adapter *Adapter) BufferFast(nbytes uint) *gst.Buffer

BufferFast returns a Buffer containing the first nbytes of the adapter, but does not flush them from the adapter. See gst_adapter_take_buffer_fast() for details.

Caller owns a reference to the returned buffer. gst_buffer_unref() after usage.

Free-function: gst_buffer_unref.

The function takes the following parameters:

  • nbytes: number of bytes to get.

The function returns the following values:

  • buffer (optional) containing the first nbytes of the adapter, or NULL if nbytes bytes are not available. gst_buffer_unref() when no longer needed.

func (*Adapter) BufferList

func (adapter *Adapter) BufferList(nbytes uint) *gst.BufferList

BufferList returns a BufferList of buffers containing the first nbytes bytes of the adapter but does not flush them from the adapter. See gst_adapter_take_buffer_list() for details.

Caller owns the returned list. Call gst_buffer_list_unref() to free the list after usage.

The function takes the following parameters:

  • nbytes: number of bytes to get.

The function returns the following values:

  • bufferList (optional) of buffers containing the first nbytes of the adapter, or NULL if nbytes bytes are not available.

func (*Adapter) Clear

func (adapter *Adapter) Clear()

Clear removes all buffers from adapter.

func (*Adapter) Copy

func (adapter *Adapter) Copy(offset, size uint) *glib.Bytes

Copy: similar to gst_adapter_copy, but more suitable for language bindings. size bytes of data starting at offset will be copied out of the buffers contained in adapter and into a new #GBytes structure which is returned. Depending on the value of the size argument an empty #GBytes structure may be returned.

The function takes the following parameters:

  • offset bytes offset in the adapter to start from.
  • size: number of bytes to copy.

The function returns the following values:

  • bytes: new #GBytes structure containing the copied data.

func (*Adapter) DistanceFromDiscont

func (adapter *Adapter) DistanceFromDiscont() uint64

DistanceFromDiscont: get the distance in bytes since the last buffer with the GST_BUFFER_FLAG_DISCONT flag.

The distance will be reset to 0 for all buffers with GST_BUFFER_FLAG_DISCONT on them, and then calculated for all other following buffers based on their size.

The function returns the following values:

  • guint64: offset. Can be GST_BUFFER_OFFSET_NONE.

func (*Adapter) DtsAtDiscont

func (adapter *Adapter) DtsAtDiscont() gst.ClockTime

DtsAtDiscont: get the DTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT flag, or GST_CLOCK_TIME_NONE.

The function returns the following values:

  • clockTime: DTS at the last discont or GST_CLOCK_TIME_NONE.

func (*Adapter) Flush

func (adapter *Adapter) Flush(flush uint)

Flush flushes the first flush bytes in the adapter. The caller must ensure that at least this many bytes are available.

See also: gst_adapter_map(), gst_adapter_unmap().

The function takes the following parameters:

  • flush: number of bytes to flush.

func (*Adapter) List

func (adapter *Adapter) List(nbytes uint) []*gst.Buffer

List returns a #GList of buffers containing the first nbytes bytes of the adapter, but does not flush them from the adapter. See gst_adapter_take_list() for details.

Caller owns returned list and contained buffers. gst_buffer_unref() each buffer in the list before freeing the list after usage.

The function takes the following parameters:

  • nbytes: number of bytes to get.

The function returns the following values:

  • list (optional) of buffers containing the first nbytes of the adapter, or NULL if nbytes bytes are not available.

func (*Adapter) MaskedScanUint32

func (adapter *Adapter) MaskedScanUint32(mask, pattern uint32, offset, size uint) int

MaskedScanUint32: scan for pattern pattern with applied mask mask in the adapter data, starting from offset offset.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the adapter for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the adapter.

This function calls gst_adapter_masked_scan_uint32_peek() passing NULL for value.

The function takes the following parameters:

  • mask to apply to data before matching against pattern.
  • pattern to match (after mask is applied).
  • offset into the adapter data from which to start scanning, returns the last scanned position.
  • size: number of bytes to scan from offset.

The function returns the following values:

  • gssize: offset of the first match, or -1 if no match was found.

    Example:

    // Assume the adapter contains 0x00 0x01 0x02 ... 0xfe 0xff

    gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x00010203, 0, 256); // -> returns 0 gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x00010203, 1, 255); // -> returns -1 gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x01020304, 1, 255); // -> returns 1 gst_adapter_masked_scan_uint32 (adapter, 0xffff, 0x0001, 0, 256); // -> returns -1 gst_adapter_masked_scan_uint32 (adapter, 0xffff, 0x0203, 0, 256); // -> returns 0 gst_adapter_masked_scan_uint32 (adapter, 0xffff0000, 0x02030000, 0, 256); // -> returns 2 gst_adapter_masked_scan_uint32 (adapter, 0xffff0000, 0x02030000, 0, 4); // -> returns -1.

func (*Adapter) MaskedScanUint32Peek

func (adapter *Adapter) MaskedScanUint32Peek(mask, pattern uint32, offset, size uint) (uint32, int)

MaskedScanUint32Peek: scan for pattern pattern with applied mask mask in the adapter data, starting from offset offset. If a match is found, the value that matched is returned through value, otherwise value is left untouched.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the adapter for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the adapter.

The function takes the following parameters:

  • mask to apply to data before matching against pattern.
  • pattern to match (after mask is applied).
  • offset into the adapter data from which to start scanning, returns the last scanned position.
  • size: number of bytes to scan from offset.

The function returns the following values:

  • value (optional): pointer to uint32 to return matching data.
  • gssize: offset of the first match, or -1 if no match was found.

func (*Adapter) OffsetAtDiscont

func (adapter *Adapter) OffsetAtDiscont() uint64

OffsetAtDiscont: get the offset that was on the last buffer with the GST_BUFFER_FLAG_DISCONT flag, or GST_BUFFER_OFFSET_NONE.

The function returns the following values:

  • guint64: offset at the last discont or GST_BUFFER_OFFSET_NONE.

func (*Adapter) PrevDts

func (adapter *Adapter) PrevDts() (uint64, gst.ClockTime)

PrevDts: get the dts that was before the current byte in the adapter. When distance is given, the amount of bytes between the dts and the current position is returned.

The dts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when the adapter is first created or when it is cleared. This also means that before the first byte with a dts is removed from the adapter, the dts and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.

The function returns the following values:

  • distance (optional): pointer to location for distance, or NULL.
  • clockTime: previously seen dts.

func (*Adapter) PrevDtsAtOffset

func (adapter *Adapter) PrevDtsAtOffset(offset uint) (uint64, gst.ClockTime)

PrevDtsAtOffset: get the dts that was before the byte at offset offset in the adapter. When distance is given, the amount of bytes between the dts and the current position is returned.

The dts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when the adapter is first created or when it is cleared. This also means that before the first byte with a dts is removed from the adapter, the dts and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.

The function takes the following parameters:

  • offset in the adapter at which to get timestamp.

The function returns the following values:

  • distance (optional): pointer to location for distance, or NULL.
  • clockTime: previously seen dts at given offset.

func (*Adapter) PrevOffset

func (adapter *Adapter) PrevOffset() (distance, guint64 uint64)

PrevOffset: get the offset that was before the current byte in the adapter. When distance is given, the amount of bytes between the offset and the current position is returned.

The offset is reset to GST_BUFFER_OFFSET_NONE and the distance is set to 0 when the adapter is first created or when it is cleared. This also means that before the first byte with an offset is removed from the adapter, the offset and distance returned are GST_BUFFER_OFFSET_NONE and 0 respectively.

The function returns the following values:

  • distance (optional): pointer to a location for distance, or NULL.
  • guint64 previous seen offset.

func (*Adapter) PrevPts

func (adapter *Adapter) PrevPts() (uint64, gst.ClockTime)

PrevPts: get the pts that was before the current byte in the adapter. When distance is given, the amount of bytes between the pts and the current position is returned.

The pts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when the adapter is first created or when it is cleared. This also means that before the first byte with a pts is removed from the adapter, the pts and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.

The function returns the following values:

  • distance (optional): pointer to location for distance, or NULL.
  • clockTime: previously seen pts.

func (*Adapter) PrevPtsAtOffset

func (adapter *Adapter) PrevPtsAtOffset(offset uint) (uint64, gst.ClockTime)

PrevPtsAtOffset: get the pts that was before the byte at offset offset in the adapter. When distance is given, the amount of bytes between the pts and the current position is returned.

The pts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when the adapter is first created or when it is cleared. This also means that before the first byte with a pts is removed from the adapter, the pts and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.

The function takes the following parameters:

  • offset in the adapter at which to get timestamp.

The function returns the following values:

  • distance (optional): pointer to location for distance, or NULL.
  • clockTime: previously seen pts at given offset.

func (*Adapter) PtsAtDiscont

func (adapter *Adapter) PtsAtDiscont() gst.ClockTime

PtsAtDiscont: get the PTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT flag, or GST_CLOCK_TIME_NONE.

The function returns the following values:

  • clockTime: PTS at the last discont or GST_CLOCK_TIME_NONE.

func (*Adapter) Push

func (adapter *Adapter) Push(buf *gst.Buffer)

Push adds the data from buf to the data stored inside adapter and takes ownership of the buffer.

The function takes the following parameters:

  • buf to add to queue in the adapter.

func (*Adapter) TakeBuffer

func (adapter *Adapter) TakeBuffer(nbytes uint) *gst.Buffer

TakeBuffer returns a Buffer containing the first nbytes bytes of the adapter. The returned bytes will be flushed from the adapter. This function is potentially more performant than gst_adapter_take() since it can reuse the memory in pushed buffers by subbuffering or merging. This function will always return a buffer with a single memory region.

Note that no assumptions should be made as to whether certain buffer flags such as the DISCONT flag are set on the returned buffer, or not. The caller needs to explicitly set or unset flags that should be set or unset.

Since 1.6 this will also copy over all GstMeta of the input buffers except for meta with the GST_META_FLAG_POOLED flag or with the "memory" tag.

Caller owns a reference to the returned buffer. gst_buffer_unref() after usage.

Free-function: gst_buffer_unref.

The function takes the following parameters:

  • nbytes: number of bytes to take.

The function returns the following values:

  • buffer (optional) containing the first nbytes of the adapter, or NULL if nbytes bytes are not available. gst_buffer_unref() when no longer needed.

func (*Adapter) TakeBufferFast

func (adapter *Adapter) TakeBufferFast(nbytes uint) *gst.Buffer

TakeBufferFast returns a Buffer containing the first nbytes of the adapter. The returned bytes will be flushed from the adapter. This function is potentially more performant than gst_adapter_take_buffer() since it can reuse the memory in pushed buffers by subbuffering or merging. Unlike gst_adapter_take_buffer(), the returned buffer may be composed of multiple non-contiguous Memory objects, no copies are made.

Note that no assumptions should be made as to whether certain buffer flags such as the DISCONT flag are set on the returned buffer, or not. The caller needs to explicitly set or unset flags that should be set or unset.

This will also copy over all GstMeta of the input buffers except for meta with the GST_META_FLAG_POOLED flag or with the "memory" tag.

This function can return buffer up to the return value of gst_adapter_available() without making copies if possible.

Caller owns a reference to the returned buffer. gst_buffer_unref() after usage.

Free-function: gst_buffer_unref.

The function takes the following parameters:

  • nbytes: number of bytes to take.

The function returns the following values:

  • buffer (optional) containing the first nbytes of the adapter, or NULL if nbytes bytes are not available. gst_buffer_unref() when no longer needed.

func (*Adapter) TakeBufferList

func (adapter *Adapter) TakeBufferList(nbytes uint) *gst.BufferList

TakeBufferList returns a BufferList of buffers containing the first nbytes bytes of the adapter. The returned bytes will be flushed from the adapter. When the caller can deal with individual buffers, this function is more performant because no memory should be copied.

Caller owns the returned list. Call gst_buffer_list_unref() to free the list after usage.

The function takes the following parameters:

  • nbytes: number of bytes to take.

The function returns the following values:

  • bufferList (optional) of buffers containing the first nbytes of the adapter, or NULL if nbytes bytes are not available.

func (*Adapter) TakeList

func (adapter *Adapter) TakeList(nbytes uint) []*gst.Buffer

TakeList returns a #GList of buffers containing the first nbytes bytes of the adapter. The returned bytes will be flushed from the adapter. When the caller can deal with individual buffers, this function is more performant because no memory should be copied.

Caller owns returned list and contained buffers. gst_buffer_unref() each buffer in the list before freeing the list after usage.

The function takes the following parameters:

  • nbytes: number of bytes to take.

The function returns the following values:

  • list (optional) of buffers containing the first nbytes of the adapter, or NULL if nbytes bytes are not available.

func (*Adapter) Unmap

func (adapter *Adapter) Unmap()

Unmap releases the memory obtained with the last gst_adapter_map().

type Aggregator

type Aggregator struct {
	gst.Element
	// contains filtered or unexported fields
}

Aggregator manages a set of pads with the purpose of aggregating their buffers. Control is given to the subclass when all pads have data.

  • Base class for mixers and muxers. Subclasses should at least implement the AggregatorClass::aggregate virtual method.

  • Installs a PadChainFunction, a PadEventFullFunction and a PadQueryFunction to queue all serialized data packets per sink pad. Subclasses should not overwrite those, but instead implement AggregatorClass::sink_event and AggregatorClass::sink_query as needed.

  • When data is queued on all pads, the aggregate vmethod is called.

  • One can peek at the data on any given GstAggregatorPad with the gst_aggregator_pad_peek_buffer() method, and remove it from the pad with the gst_aggregator_pad_pop_buffer () method. When a buffer has been taken with pop_buffer (), a new buffer can be queued on that pad.

  • When gst_aggregator_pad_peek_buffer() or gst_aggregator_pad_has_buffer() are called, a reference is taken to the returned buffer, which stays valid until either:

  • gst_aggregator_pad_pop_buffer() is called, in which case the caller is guaranteed that the buffer they receive is the same as the peeked buffer.

  • gst_aggregator_pad_drop_buffer() is called, in which case the caller is guaranteed that the dropped buffer is the one that was peeked.

  • the subclass implementation of AggregatorClass.aggregate returns.

    Subsequent calls to gst_aggregator_pad_peek_buffer() or gst_aggregator_pad_has_buffer() return / check the same buffer that was returned / checked, until one of the conditions listed above is met.

    Subclasses are only allowed to call these methods from the aggregate thread.

  • If the subclass wishes to push a buffer downstream in its aggregate implementation, it should do so through the gst_aggregator_finish_buffer() method. This method will take care of sending and ordering mandatory events such as stream start, caps and segment. Buffer lists can also be pushed out with gst_aggregator_finish_buffer_list().

  • Same goes for EOS events, which should not be pushed directly by the subclass, it should instead return GST_FLOW_EOS in its aggregate implementation.

  • Note that the aggregator logic regarding gap event handling is to turn these into gap buffers with matching PTS and duration. It will also flag these buffers with GST_BUFFER_FLAG_GAP and GST_BUFFER_FLAG_DROPPABLE to ease their identification and subsequent processing.

  • Subclasses must use (a subclass of) AggregatorPad for both their sink and source pads. See gst_element_class_add_static_pad_template_with_gtype().

This class used to live in gst-plugins-bad and was moved to core.

func BaseAggregator

func BaseAggregator(obj Aggregatorrer) *Aggregator

BaseAggregator returns the underlying base object.

func (*Aggregator) Allocator

func (self *Aggregator) Allocator() (gst.Allocatorrer, *gst.AllocationParams)

Allocator lets Aggregator sub-classes get the memory allocator acquired by the base class and its params.

Unref the allocator after use it.

The function returns the following values:

  • allocator (optional): Allocator used.
  • params (optional) the AllocationParams of allocator.

func (*Aggregator) BufferPool

func (self *Aggregator) BufferPool() *gst.BufferPool

The function returns the following values:

  • bufferPool (optional): instance of the BufferPool used by trans; free it after use it.

func (*Aggregator) ConnectSamplesSelected

func (aggregator *Aggregator) ConnectSamplesSelected(f func(segment *gst.Segment, pts, dts, duration uint64, info *gst.Structure)) coreglib.SignalHandle

ConnectSamplesSelected signals that the Aggregator subclass has selected the next set of input samples it will aggregate. Handlers may call gst_aggregator_peek_next_sample() at that point.

func (*Aggregator) FinishBuffer

func (aggregator *Aggregator) FinishBuffer(buffer *gst.Buffer) gst.FlowReturn

FinishBuffer: this method will push the provided output buffer downstream. If needed, mandatory events such as stream-start, caps, and segment events will be sent before pushing the buffer.

The function takes the following parameters:

  • buffer to push.

The function returns the following values:

func (*Aggregator) FinishBufferList

func (aggregator *Aggregator) FinishBufferList(bufferlist *gst.BufferList) gst.FlowReturn

FinishBufferList: this method will push the provided output buffer list downstream. If needed, mandatory events such as stream-start, caps, and segment events will be sent before pushing the buffer.

The function takes the following parameters:

  • bufferlist to push.

The function returns the following values:

func (*Aggregator) IgnoreInactivePads

func (self *Aggregator) IgnoreInactivePads() bool

The function returns the following values:

  • ok: whether inactive pads will not be waited on.

func (*Aggregator) Latency

func (self *Aggregator) Latency() gst.ClockTime

Latency retrieves the latency values reported by self in response to the latency query, or GST_CLOCK_TIME_NONE if there is not live source connected and the element will not wait for the clock.

Typically only called by subclasses.

The function returns the following values:

  • clockTime: latency or GST_CLOCK_TIME_NONE if the element does not sync.

func (*Aggregator) Negotiate

func (self *Aggregator) Negotiate() bool

Negotiate negotiates src pad caps with downstream elements. Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again if AggregatorClass::negotiate fails.

The function returns the following values:

  • ok: TRUE if the negotiation succeeded, else FALSE.

func (*Aggregator) PeekNextSample

func (self *Aggregator) PeekNextSample(pad *AggregatorPad) *gst.Sample

PeekNextSample: use this function to determine what input buffers will be aggregated to produce the next output buffer. This should only be called from a Aggregator::samples-selected handler, and can be used to precisely control aggregating parameters for a given set of input samples.

The function takes the following parameters:

The function returns the following values:

  • sample (optional) that is about to be aggregated. It may hold a Buffer or a BufferList. The contents of its info structure is subclass-dependent, and documented on a subclass basis. The buffers held by the sample are not writable.

func (*Aggregator) SelectedSamples

func (self *Aggregator) SelectedSamples(pts, dts, duration gst.ClockTime, info *gst.Structure)

SelectedSamples subclasses should call this when they have prepared the buffers they will aggregate for each of their sink pads, but before using any of the properties of the pads that govern *how* aggregation should be performed, for example z-index for video aggregators.

If gst_aggregator_update_segment() is used by the subclass, it MUST be called before gst_aggregator_selected_samples().

This function MUST only be called from the AggregatorClass::aggregate() function.

The function takes the following parameters:

  • pts: presentation timestamp of the next output buffer.
  • dts: decoding timestamp of the next output buffer.
  • duration of the next output buffer.
  • info (optional) containing additional information.

func (*Aggregator) SetIgnoreInactivePads

func (self *Aggregator) SetIgnoreInactivePads(ignore bool)

SetIgnoreInactivePads subclasses should call this when they don't want to time out waiting for a pad that hasn't yet received any buffers in live mode.

Aggregator will still wait once on each newly-added pad, making sure upstream has had a fair chance to start up.

The function takes the following parameters:

  • ignore: whether inactive pads should not be waited on.

func (*Aggregator) SetLatency

func (self *Aggregator) SetLatency(minLatency, maxLatency gst.ClockTime)

SetLatency lets Aggregator sub-classes tell the baseclass what their internal latency is. Will also post a LATENCY message on the bus so the pipeline can reconfigure its global latency.

The function takes the following parameters:

  • minLatency: minimum latency.
  • maxLatency: maximum latency.

func (*Aggregator) SetSrcCaps

func (self *Aggregator) SetSrcCaps(caps *gst.Caps)

SetSrcCaps sets the caps to be used on the src pad.

The function takes the following parameters:

  • caps to set on the src pad.

func (*Aggregator) SimpleGetNextTime

func (self *Aggregator) SimpleGetNextTime() gst.ClockTime

SimpleGetNextTime: this is a simple AggregatorClass::get_next_time implementation that just looks at the Segment on the srcpad of the aggregator and bases the next time on the running time there.

This is the desired behaviour in most cases where you have a live source and you have a dead line based aggregator subclass.

The function returns the following values:

  • clockTime: running time based on the position.

func (*Aggregator) UpdateSegment

func (self *Aggregator) UpdateSegment(segment *gst.Segment)

UpdateSegment subclasses should use this to update the segment on their source pad, instead of directly pushing new segment events downstream.

Subclasses MUST call this before gst_aggregator_selected_samples(), if it is used at all.

The function takes the following parameters:

type AggregatorClass

type AggregatorClass struct {
	// contains filtered or unexported fields
}

AggregatorClass: aggregator base class will handle in a thread-safe way all manners of concurrent flushes, seeks, pad additions and removals, leaving to the subclass the responsibility of clipping buffers, and aggregating buffers in the way the implementor sees fit.

It will also take care of event ordering (stream-start, segment, eos).

Basically, a simple implementation will override aggregate, and call _finish_buffer from inside that function.

An instance of this type is always passed by reference.

func (*AggregatorClass) ParentClass

func (a *AggregatorClass) ParentClass() *gst.ElementClass

type AggregatorOverrides

type AggregatorOverrides struct {
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Aggregate func(timeout bool) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - aggregatorPad
	//    - buf
	//
	// The function returns the following values:
	//
	Clip func(aggregatorPad *AggregatorPad, buf *gst.Buffer) *gst.Buffer
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	DecideAllocation func(query *gst.Query) bool
	// FinishBuffer: this method will push the provided output buffer
	// downstream. If needed, mandatory events such as stream-start, caps, and
	// segment events will be sent before pushing the buffer.
	//
	// The function takes the following parameters:
	//
	//    - buffer to push.
	//
	// The function returns the following values:
	//
	FinishBuffer func(buffer *gst.Buffer) gst.FlowReturn
	// FinishBufferList: this method will push the provided output buffer list
	// downstream. If needed, mandatory events such as stream-start, caps, and
	// segment events will be sent before pushing the buffer.
	//
	// The function takes the following parameters:
	//
	//    - bufferlist to push.
	//
	// The function returns the following values:
	//
	FinishBufferList func(bufferlist *gst.BufferList) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	FixateSrcCaps func(caps *gst.Caps) *gst.Caps
	// The function returns the following values:
	//
	Flush func() gst.FlowReturn
	// The function returns the following values:
	//
	NextTime func() gst.ClockTime
	// Negotiate negotiates src pad caps with downstream elements. Unmarks
	// GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again if
	// AggregatorClass::negotiate fails.
	//
	// The function returns the following values:
	//
	//    - ok: TRUE if the negotiation succeeded, else FALSE.
	//
	Negotiate func() bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	NegotiatedSrcCaps func(caps *gst.Caps) bool
	// PeekNextSample: use this function to determine what input buffers will be
	// aggregated to produce the next output buffer. This should only be called
	// from a Aggregator::samples-selected handler, and can be used to precisely
	// control aggregating parameters for a given set of input samples.
	//
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - sample (optional) that is about to be aggregated. It may hold a
	//      Buffer or a BufferList. The contents of its info structure is
	//      subclass-dependent, and documented on a subclass basis. The buffers
	//      held by the sample are not writable.
	//
	PeekNextSample func(aggregatorPad *AggregatorPad) *gst.Sample
	// The function takes the following parameters:
	//
	//    - pad
	//    - decideQuery
	//    - query
	//
	// The function returns the following values:
	//
	ProposeAllocation func(pad *AggregatorPad, decideQuery, query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - aggregatorPad
	//    - event
	//
	// The function returns the following values:
	//
	SinkEvent func(aggregatorPad *AggregatorPad, event *gst.Event) bool
	// The function takes the following parameters:
	//
	//    - aggregatorPad
	//    - event
	//
	// The function returns the following values:
	//
	SinkEventPreQueue func(aggregatorPad *AggregatorPad, event *gst.Event) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - aggregatorPad
	//    - query
	//
	// The function returns the following values:
	//
	SinkQuery func(aggregatorPad *AggregatorPad, query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - aggregatorPad
	//    - query
	//
	// The function returns the following values:
	//
	SinkQueryPreQueue func(aggregatorPad *AggregatorPad, query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - mode
	//    - active
	//
	// The function returns the following values:
	//
	SrcActivate func(mode gst.PadMode, active bool) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SrcEvent func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SrcQuery func(query *gst.Query) bool
	// The function returns the following values:
	//
	Start func() bool
	// The function returns the following values:
	//
	Stop func() bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - ret (optional)
	//    - flowReturn
	//
	UpdateSrcCaps func(caps *gst.Caps) (*gst.Caps, gst.FlowReturn)
}

AggregatorOverrides contains methods that are overridable.

type AggregatorPad

type AggregatorPad struct {
	gst.Pad
	// contains filtered or unexported fields
}

AggregatorPad pads managed by a Aggregator subclass.

This class used to live in gst-plugins-bad and was moved to core.

func (*AggregatorPad) ConnectBufferConsumed

func (pad *AggregatorPad) ConnectBufferConsumed(f func(object *gst.Buffer)) coreglib.SignalHandle

func (*AggregatorPad) DropBuffer

func (pad *AggregatorPad) DropBuffer() bool

DropBuffer: drop the buffer currently queued in pad.

The function returns the following values:

  • ok: TRUE if there was a buffer queued in pad, or FALSE if not.

func (*AggregatorPad) HasBuffer

func (pad *AggregatorPad) HasBuffer() bool

HasBuffer: this checks if a pad has a buffer available that will be returned by a call to gst_aggregator_pad_peek_buffer() or gst_aggregator_pad_pop_buffer().

The function returns the following values:

  • ok: TRUE if the pad has a buffer available as the next thing.

func (*AggregatorPad) IsEos

func (pad *AggregatorPad) IsEos() bool

The function returns the following values:

  • ok: TRUE if the pad is EOS, otherwise FALSE.

func (*AggregatorPad) IsInactive

func (pad *AggregatorPad) IsInactive() bool

IsInactive: it is only valid to call this method from AggregatorClass::aggregate().

The function returns the following values:

  • ok: TRUE if the pad is inactive, FALSE otherwise. See gst_aggregator_ignore_inactive_pads() for more info.

func (*AggregatorPad) PeekBuffer

func (pad *AggregatorPad) PeekBuffer() *gst.Buffer

The function returns the following values:

  • buffer (optional): reference to the buffer in pad or NULL if no buffer was queued. You should unref the buffer after usage.

func (*AggregatorPad) PopBuffer

func (pad *AggregatorPad) PopBuffer() *gst.Buffer

PopBuffer: steal the ref to the buffer currently queued in pad.

The function returns the following values:

  • buffer (optional) in pad or NULL if no buffer was queued. You should unref the buffer after usage.

type AggregatorPadClass

type AggregatorPadClass struct {
	// contains filtered or unexported fields
}

AggregatorPadClass: instance of this type is always passed by reference.

func (*AggregatorPadClass) ParentClass

func (a *AggregatorPadClass) ParentClass() *gst.PadClass

type AggregatorPadOverrides

type AggregatorPadOverrides struct {
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Flush func(aggregator Aggregatorrer) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - aggregator
	//    - buffer
	//
	// The function returns the following values:
	//
	SkipBuffer func(aggregator Aggregatorrer, buffer *gst.Buffer) bool
}

AggregatorPadOverrides contains methods that are overridable.

type AggregatorStartTimeSelection

type AggregatorStartTimeSelection C.gint
const (
	// AggregatorStartTimeSelectionZero: start at running time 0.
	AggregatorStartTimeSelectionZero AggregatorStartTimeSelection = iota
	// AggregatorStartTimeSelectionFirst: start at the running time of the first
	// buffer that is received.
	AggregatorStartTimeSelectionFirst
	// AggregatorStartTimeSelectionSet: start at the running time selected by
	// the start-time property.
	AggregatorStartTimeSelectionSet
)

func (AggregatorStartTimeSelection) String

String returns the name in string for AggregatorStartTimeSelection.

type Aggregatorrer

type Aggregatorrer interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

Aggregatorrer describes types inherited from class Aggregator.

To get the original type, the caller must assert this to an interface or another type.

type BaseParse

type BaseParse struct {
	gst.Element
	// contains filtered or unexported fields
}

BaseParse: this base class is for parser elements that process data and splits it into separate audio/video/whatever frames.

It provides for:

  • provides one sink pad and one source pad
  • handles state changes
  • can operate in pull mode or push mode
  • handles seeking in both modes
  • handles events (SEGMENT/EOS/FLUSH)
  • handles queries (POSITION/DURATION/SEEKING/FORMAT/CONVERT)
  • handles flushing

The purpose of this base class is to provide the basic functionality of a parser and share a lot of rather complex code.

Description of the parsing mechanism:

Set-up phase

  • BaseParse calls BaseParseClass::start to inform subclass that data processing is about to start now.

  • BaseParse class calls BaseParseClass::set_sink_caps to inform the subclass about incoming sinkpad caps. Subclass could already set the srcpad caps accordingly, but this might be delayed until calling gst_base_parse_finish_frame() with a non-queued frame.

  • At least at this point subclass needs to tell the BaseParse class how big data chunks it wants to receive (minimum frame size ). It can do this with gst_base_parse_set_min_frame_size().

  • BaseParse class sets up appropriate data passing mode (pull/push) and starts to process the data.

Parsing phase

  • BaseParse gathers at least min_frame_size bytes of data either by pulling it from upstream or collecting buffers in an internal Adapter.

  • A buffer of (at least) min_frame_size bytes is passed to subclass with BaseParseClass::handle_frame. Subclass checks the contents and can optionally return T_FLOW_OK along with an amount of data to be skipped to find a valid frame (which will result in a subsequent DISCONT). If, otherwise, the buffer does not hold a complete frame, BaseParseClass::handle_frame can merely return and will be called again when additional data is available. In push mode this amounts to an additional input buffer (thus minimal additional latency), in pull mode this amounts to some arbitrary reasonable buffer size increase.

    Of course, gst_base_parse_set_min_frame_size() could also be used if a very specific known amount of additional data is required. If, however, the buffer holds a complete valid frame, it can pass the size of this frame to gst_base_parse_finish_frame().

    If acting as a converter, it can also merely indicate consumed input data while simultaneously providing custom output data. Note that baseclass performs some processing (such as tracking overall consumed data rate versus duration) for each finished frame, but other state is only updated upon each call to BaseParseClass::handle_frame (such as tracking upstream input timestamp).

    Subclass is also responsible for setting the buffer metadata (e.g. buffer timestamp and duration, or keyframe if applicable). (although the latter can also be done by BaseParse if it is appropriately configured, see below). Frame is provided with timestamp derived from upstream (as much as generally possible), duration obtained from configuration (see below), and offset if meaningful (in pull mode).

    Note that BaseParseClass::handle_frame might receive any small amount of input data when leftover data is being drained (e.g. at EOS).

  • As part of finish frame processing, just prior to actually pushing the buffer in question, it is passed to BaseParseClass::pre_push_frame which gives subclass yet one last chance to examine buffer metadata, or to send some custom (tag) events, or to perform custom (segment) filtering.

  • During the parsing process BaseParseClass will handle both srcpad and sinkpad events. They will be passed to subclass if BaseParseClass::sink_event or BaseParseClass::src_event implementations have been provided.

Shutdown phase

* BaseParse class calls BaseParseClass::stop to inform the subclass that data parsing will be stopped.

Subclass is responsible for providing pad template caps for source and sink pads. The pads need to be named "sink" and "src". It also needs to set the fixed caps on srcpad, when the format is ensured (e.g. when base class calls subclass' BaseParseClass::set_sink_caps function).

This base class uses GST_FORMAT_DEFAULT as a meaning of frames. So, subclass conversion routine needs to know that conversion from GST_FORMAT_TIME to GST_FORMAT_DEFAULT must return the frame number that can be found from the given byte position.

BaseParse uses subclasses conversion methods also for seeking (or otherwise uses its own default one, see also below).

Subclass start and stop functions will be called to inform the beginning and end of data processing.

Things that subclass need to take care of:

* Provide pad templates * Fixate the source pad caps when appropriate * Inform base class how big data chunks should be retrieved. This is done with gst_base_parse_set_min_frame_size() function. * Examine data chunks passed to subclass with BaseParseClass::handle_frame and pass proper frame(s) to gst_base_parse_finish_frame(), and setting src pad caps and timestamps on frame. * Provide conversion functions * Update the duration information with gst_base_parse_set_duration() * Optionally passthrough using gst_base_parse_set_passthrough() * Configure various baseparse parameters using gst_base_parse_set_average_bitrate(), gst_base_parse_set_syncable() and gst_base_parse_set_frame_rate().

* In particular, if subclass is unable to determine a duration, but parsing (or specs) yields a frames per seconds rate, then this can be provided to BaseParse to enable it to cater for buffer time metadata (which will be taken from upstream as much as possible). Internally keeping track of frame durations and respective sizes that have been pushed provides BaseParse with an estimated bitrate. A default BaseParseClass::convert (used if not overridden) will then use these rates to perform obvious conversions. These rates are also used to update (estimated) duration at regular frame intervals.

func BaseBaseParse

func BaseBaseParse(obj BaseParser) *BaseParse

BaseBaseParse returns the underlying base object.

func (*BaseParse) AddIndexEntry

func (parse *BaseParse) AddIndexEntry(offset uint64, ts gst.ClockTime, key, force bool) bool

AddIndexEntry adds an entry to the index associating offset to ts. It is recommended to only add keyframe entries. force allows to bypass checks, such as whether the stream is (upstream) seekable, another entry is already "close" to the new entry, etc.

The function takes the following parameters:

  • offset of entry.
  • ts: timestamp associated with offset.
  • key: whether entry refers to keyframe.
  • force: add entry disregarding sanity checks.

The function returns the following values:

  • ok indicating whether entry was added.

func (*BaseParse) ConvertDefault

func (parse *BaseParse) ConvertDefault(srcFormat gst.Format, srcValue int64, destFormat gst.Format) (int64, bool)

ConvertDefault: default implementation of BaseParseClass::convert.

The function takes the following parameters:

  • srcFormat describing the source format.
  • srcValue: source value to be converted.
  • destFormat defining the converted format.

The function returns the following values:

  • destValue: pointer where the conversion result will be put.
  • ok: TRUE if conversion was successful.

func (*BaseParse) Drain

func (parse *BaseParse) Drain()

Drain drains the adapter until it is empty. It decreases the min_frame_size to match the current adapter size and calls chain method until the adapter is emptied or chain returns with error.

func (*BaseParse) FinishFrame

func (parse *BaseParse) FinishFrame(frame *BaseParseFrame, size int) gst.FlowReturn

FinishFrame collects parsed data and pushes this downstream. Source pad caps must be set when this is called.

If frame's out_buffer is set, that will be used as subsequent frame data. Otherwise, size samples will be taken from the input and used for output, and the output's metadata (timestamps etc) will be taken as (optionally) set by the subclass on frame's (input) buffer (which is otherwise ignored for any but the above purpose/information).

Note that the latter buffer is invalidated by this call, whereas the caller retains ownership of frame.

The function takes the following parameters:

  • frame: BaseParseFrame.
  • size: consumed input data represented by frame.

The function returns the following values:

  • flowReturn that should be escalated to caller (of caller).

func (*BaseParse) PushFrame

func (parse *BaseParse) PushFrame(frame *BaseParseFrame) gst.FlowReturn

PushFrame pushes the frame's buffer downstream, sends any pending events and does some timestamp and segment handling. Takes ownership of frame's buffer, though caller retains ownership of frame.

This must be called with sinkpad STREAM_LOCK held.

The function takes the following parameters:

  • frame: BaseParseFrame.

The function returns the following values:

  • flowReturn: FlowReturn.

func (*BaseParse) SetAverageBitrate

func (parse *BaseParse) SetAverageBitrate(bitrate uint)

SetAverageBitrate: optionally sets the average bitrate detected in media (if non-zero), e.g. based on metadata, as it will be posted to the application.

By default, announced average bitrate is estimated. The average bitrate is used to estimate the total duration of the stream and to estimate a seek position, if there's no index and the format is syncable (see gst_base_parse_set_syncable()).

The function takes the following parameters:

  • bitrate: average bitrate in bits/second.

func (*BaseParse) SetDuration

func (parse *BaseParse) SetDuration(fmt gst.Format, duration int64, interval int)

SetDuration sets the duration of the currently playing media. Subclass can use this when it is able to determine duration and/or notices a change in the media duration. Alternatively, if interval is non-zero (default), then stream duration is determined based on estimated bitrate, and updated every interval frames.

The function takes the following parameters:

  • fmt: Format.
  • duration value.
  • interval: how often to update the duration estimate based on bitrate, or 0.

func (*BaseParse) SetFrameRate

func (parse *BaseParse) SetFrameRate(fpsNum, fpsDen, leadIn, leadOut uint)

SetFrameRate: if frames per second is configured, parser can take care of buffer duration and timestamping. When performing segment clipping, or seeking to a specific location, a corresponding decoder might need an initial lead_in and a following lead_out number of frames to ensure the desired segment is entirely filled upon decoding.

The function takes the following parameters:

  • fpsNum frames per second (numerator).
  • fpsDen frames per second (denominator).
  • leadIn frames needed before a segment for subsequent decode.
  • leadOut frames needed after a segment.

func (*BaseParse) SetHasTimingInfo

func (parse *BaseParse) SetHasTimingInfo(hasTiming bool)

SetHasTimingInfo: set if frames carry timing information which the subclass can (generally) parse and provide. In particular, intrinsic (rather than estimated) time can be obtained following a seek.

The function takes the following parameters:

  • hasTiming: whether frames carry timing information.

func (*BaseParse) SetInferTs

func (parse *BaseParse) SetInferTs(inferTs bool)

SetInferTs: by default, the base class might try to infer PTS from DTS and vice versa. While this is generally correct for audio data, it may not be otherwise. Sub-classes implementing such formats should disable timestamp inferring.

The function takes the following parameters:

  • inferTs: TRUE if parser should infer DTS/PTS from each other.

func (*BaseParse) SetLatency

func (parse *BaseParse) SetLatency(minLatency, maxLatency gst.ClockTime)

SetLatency sets the minimum and maximum (which may likely be equal) latency introduced by the parsing process. If there is such a latency, which depends on the particular parsing of the format, it typically corresponds to 1 frame duration.

The function takes the following parameters:

  • minLatency: minimum parse latency.
  • maxLatency: maximum parse latency.

func (*BaseParse) SetMinFrameSize

func (parse *BaseParse) SetMinFrameSize(minSize uint)

SetMinFrameSize subclass can use this function to tell the base class that it needs to be given buffers of at least min_size bytes.

The function takes the following parameters:

  • minSize: minimum size in bytes of the data that this base class should give to subclass.

func (*BaseParse) SetPassthrough

func (parse *BaseParse) SetPassthrough(passthrough bool)

SetPassthrough: set if the nature of the format or configuration does not allow (much) parsing, and the parser should operate in passthrough mode (which only applies when operating in push mode). That is, incoming buffers are pushed through unmodified, i.e. no BaseParseClass::handle_frame will be invoked, but BaseParseClass::pre_push_frame will still be invoked, so subclass can perform as much or as little is appropriate for passthrough semantics in BaseParseClass::pre_push_frame.

The function takes the following parameters:

  • passthrough: TRUE if parser should run in passthrough mode.

func (*BaseParse) SetPtsInterpolation

func (parse *BaseParse) SetPtsInterpolation(ptsInterpolate bool)

SetPtsInterpolation: by default, the base class will guess PTS timestamps using a simple interpolation (previous timestamp + duration), which is incorrect for data streams with reordering, where PTS can go backward. Sub-classes implementing such formats should disable PTS interpolation.

The function takes the following parameters:

  • ptsInterpolate: TRUE if parser should interpolate PTS timestamps.

func (*BaseParse) SetSyncable

func (parse *BaseParse) SetSyncable(syncable bool)

SetSyncable: set if frame starts can be identified. This is set by default and determines whether seeking based on bitrate averages is possible for a format/stream.

The function takes the following parameters:

  • syncable: set if frame starts can be identified.

func (*BaseParse) SetTsAtOffset

func (parse *BaseParse) SetTsAtOffset(offset uint)

SetTsAtOffset: this function should only be called from a handle_frame implementation.

BaseParse creates initial timestamps for frames by using the last timestamp seen in the stream before the frame starts. In certain cases, the correct timestamps will occur in the stream after the start of the frame, but before the start of the actual picture data. This function can be used to set the timestamps based on the offset into the frame data that the picture starts.

The function takes the following parameters:

  • offset into current buffer.

type BaseParseClass

type BaseParseClass struct {
	// contains filtered or unexported fields
}

BaseParseClass subclasses can override any of the available virtual methods or not, as needed. At minimum handle_frame needs to be overridden.

An instance of this type is always passed by reference.

func (*BaseParseClass) ParentClass

func (b *BaseParseClass) ParentClass() *gst.ElementClass

ParentClass: parent class.

type BaseParseFrame

type BaseParseFrame struct {
	// contains filtered or unexported fields
}

BaseParseFrame: frame (context) data passed to each frame parsing virtual methods. In addition to providing the data to be checked for a valid frame or an already identified frame, it conveys additional metadata or control information from and to the subclass w.r.t. the particular frame in question (rather than global parameters). Some of these may apply to each parsing stage, others only to some a particular one. These parameters are effectively zeroed at start of each frame's processing, i.e. parsing virtual method invocation sequence.

An instance of this type is always passed by reference.

func NewBaseParseFrame

func NewBaseParseFrame(buffer *gst.Buffer, flags BaseParseFrameFlags, overhead int) *BaseParseFrame

NewBaseParseFrame constructs a struct BaseParseFrame.

func (*BaseParseFrame) Buffer

func (b *BaseParseFrame) Buffer() *gst.Buffer

Buffer: input data to be parsed for frames.

func (*BaseParseFrame) Copy

func (frame *BaseParseFrame) Copy() *BaseParseFrame

Copy copies a BaseParseFrame.

The function returns the following values:

  • baseParseFrame: copy of frame.

func (*BaseParseFrame) Flags

func (b *BaseParseFrame) Flags() uint

Flags: combination of input and output BaseParseFrameFlags that convey additional context to subclass or allow subclass to tune subsequent BaseParse actions.

func (*BaseParseFrame) Init

func (frame *BaseParseFrame) Init()

Init sets a BaseParseFrame to initial state. Currently this means all public fields are zero-ed and a private flag is set to make sure gst_base_parse_frame_free() only frees the contents but not the actual frame. Use this function to initialise a BaseParseFrame allocated on the stack.

func (*BaseParseFrame) Offset

func (b *BaseParseFrame) Offset() uint64

Offset: media specific offset of input frame Note that a converter may have a different one on the frame's buffer.

func (*BaseParseFrame) OutBuffer

func (b *BaseParseFrame) OutBuffer() *gst.Buffer

OutBuffer: output data.

func (*BaseParseFrame) Overhead

func (b *BaseParseFrame) Overhead() int

Overhead subclass can set this to indicates the metadata overhead for the given frame, which is then used to enable more accurate bitrate computations. If this is -1, it is assumed that this frame should be skipped in bitrate calculation.

func (*BaseParseFrame) SetFlags

func (b *BaseParseFrame) SetFlags(flags uint)

Flags: combination of input and output BaseParseFrameFlags that convey additional context to subclass or allow subclass to tune subsequent BaseParse actions.

func (*BaseParseFrame) SetOffset

func (b *BaseParseFrame) SetOffset(offset uint64)

Offset: media specific offset of input frame Note that a converter may have a different one on the frame's buffer.

func (*BaseParseFrame) SetOverhead

func (b *BaseParseFrame) SetOverhead(overhead int)

Overhead subclass can set this to indicates the metadata overhead for the given frame, which is then used to enable more accurate bitrate computations. If this is -1, it is assumed that this frame should be skipped in bitrate calculation.

type BaseParseFrameFlags

type BaseParseFrameFlags C.guint

BaseParseFrameFlags flags to be used in a BaseParseFrame.

const (
	// BaseParseFrameFlagNone: no flag.
	BaseParseFrameFlagNone BaseParseFrameFlags = 0b0
	// BaseParseFrameFlagNewFrame: set by baseclass if current frame is passed
	// for processing to the subclass for the first time (and not set on
	// subsequent calls with same data).
	BaseParseFrameFlagNewFrame BaseParseFrameFlags = 0b1
	// BaseParseFrameFlagNoFrame: set to indicate this buffer should not be
	// counted as frame, e.g. if this frame is dependent on a previous one. As
	// it is not counted as a frame, bitrate increases but frame to time
	// conversions are maintained.
	BaseParseFrameFlagNoFrame BaseParseFrameFlags = 0b10
	// BaseParseFrameFlagClip: pre_push_frame can set this to indicate that
	// regular segment clipping can still be performed (as opposed to any custom
	// one having been done).
	BaseParseFrameFlagClip BaseParseFrameFlags = 0b100
	// BaseParseFrameFlagDrop indicates to finish_frame that the the frame
	// should be dropped (and might be handled internally by subclass).
	BaseParseFrameFlagDrop BaseParseFrameFlags = 0b1000
	// BaseParseFrameFlagQueue indicates to finish_frame that the the frame
	// should be queued for now and processed fully later when the first
	// non-queued frame is finished.
	BaseParseFrameFlagQueue BaseParseFrameFlags = 0b10000
)

func (BaseParseFrameFlags) Has

Has returns true if b contains other.

func (BaseParseFrameFlags) String

func (b BaseParseFrameFlags) String() string

String returns the names in string for BaseParseFrameFlags.

type BaseParseOverrides

type BaseParseOverrides struct {
	// The function takes the following parameters:
	//
	//    - srcFormat
	//    - srcValue
	//    - destFormat
	//    - destValue
	//
	// The function returns the following values:
	//
	Convert func(srcFormat gst.Format, srcValue int64, destFormat gst.Format, destValue *int64) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Detect func(buffer *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SinkCaps func(filter *gst.Caps) *gst.Caps
	// HandleFrame parses the input data into valid frames as defined by
	// subclass which should be passed to gst_base_parse_finish_frame(). The
	// frame's input buffer is guaranteed writable, whereas the input frame
	// ownership is held by caller (so subclass should make a copy if it needs
	// to hang on). Input buffer (data) is provided by baseclass with as much
	// metadata set as possible by baseclass according to upstream information
	// and/or subclass settings, though subclass may still set buffer timestamp
	// and duration if desired.
	//
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - skipsize
	//    - flowReturn
	//
	HandleFrame func(frame *BaseParseFrame) (int, gst.FlowReturn)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	PrePushFrame func(frame *BaseParseFrame) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SetSinkCaps func(caps *gst.Caps) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SinkEvent func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SinkQuery func(query *gst.Query) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SrcEvent func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SrcQuery func(query *gst.Query) bool
	// The function returns the following values:
	//
	Start func() bool
	// The function returns the following values:
	//
	Stop func() bool
}

BaseParseOverrides contains methods that are overridable.

type BaseParser

type BaseParser interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

BaseParser describes types inherited from class BaseParse.

To get the original type, the caller must assert this to an interface or another type.

type BaseSink

type BaseSink struct {
	gst.Element
	// contains filtered or unexported fields
}

BaseSink is the base class for sink elements in GStreamer, such as xvimagesink or filesink. It is a layer on top of Element that provides a simplified interface to plugin writers. BaseSink handles many details for you, for example: preroll, clock synchronization, state changes, activation in push or pull mode, and queries.

In most cases, when writing sink elements, there is no need to implement class methods from Element or to set functions on pads, because the BaseSink infrastructure should be sufficient.

BaseSink provides support for exactly one sink pad, which should be named "sink". A sink implementation (subclass of BaseSink) should install a pad template in its class_init function, like so:

static void
my_element_class_init (GstMyElementClass *klass)
{
  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);

  // sinktemplate should be a StaticPadTemplate with direction
  // GST_PAD_SINK and name "sink"
  gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);

  gst_element_class_set_static_metadata (gstelement_class,
      "Sink name",
      "Sink",
      "My Sink element",
      "The author <my.sinkmy.email>");
}

BaseSink will handle the prerolling correctly. This means that it will return GST_STATE_CHANGE_ASYNC from a state change to PAUSED until the first buffer arrives in this element. The base class will call the BaseSinkClass::preroll vmethod with this preroll buffer and will then commit the state change to the next asynchronously pending state.

When the element is set to PLAYING, BaseSink will synchronise on the clock using the times returned from BaseSinkClass::get_times. If this function returns GST_CLOCK_TIME_NONE for the start time, no synchronisation will be done. Synchronisation can be disabled entirely by setting the object BaseSink:sync property to FALSE.

After synchronisation the virtual method BaseSinkClass::render will be called. Subclasses should minimally implement this method.

Subclasses that synchronise on the clock in the BaseSinkClass::render method are supported as well. These classes typically receive a buffer in the render method and can then potentially block on the clock while rendering. A typical example is an audiosink. These subclasses can use gst_base_sink_wait_preroll() to perform the blocking wait.

Upon receiving the EOS event in the PLAYING state, BaseSink will wait for the clock to reach the time indicated by the stop time of the last BaseSinkClass::get_times call before posting an EOS message. When the element receives EOS in PAUSED, preroll completes, the event is queued and an EOS message is posted when going to PLAYING.

BaseSink will internally use the GST_EVENT_SEGMENT events to schedule synchronisation and clipping of buffers. Buffers that fall completely outside of the current segment are dropped. Buffers that fall partially in the segment are rendered (and prerolled). Subclasses should do any subbuffer clipping themselves when needed.

BaseSink will by default report the current playback position in GST_FORMAT_TIME based on the current clock time and segment information. If no clock has been set on the element, the query will be forwarded upstream.

The BaseSinkClass::set_caps function will be called when the subclass should configure itself to process a specific media type.

The BaseSinkClass::start and BaseSinkClass::stop virtual methods will be called when resources should be allocated. Any BaseSinkClass::preroll, BaseSinkClass::render and BaseSinkClass::set_caps function will be called between the BaseSinkClass::start and BaseSinkClass::stop calls.

The BaseSinkClass::event virtual method will be called when an event is received by BaseSink. Normally this method should only be overridden by very specific elements (such as file sinks) which need to handle the newsegment event specially.

The BaseSinkClass::unlock method is called when the elements should unblock any blocking operations they perform in the BaseSinkClass::render method. This is mostly useful when the BaseSinkClass::render method performs a blocking write on a file descriptor, for example.

The BaseSink:max-lateness property affects how the sink deals with buffers that arrive too late in the sink. A buffer arrives too late in the sink when the presentation time (as a combination of the last segment, buffer timestamp and element base_time) plus the duration is before the current time of the clock. If the frame is later than max-lateness, the sink will drop the buffer without calling the render method. This feature is disabled if sync is disabled, the BaseSinkClass::get_times method does not return a valid start time or max-lateness is set to -1 (the default). Subclasses can use gst_base_sink_set_max_lateness() to configure the max-lateness value.

The BaseSink:qos property will enable the quality-of-service features of the basesink which gather statistics about the real-time performance of the clock synchronisation. For each buffer received in the sink, statistics are gathered and a QOS event is sent upstream with these numbers. This information can then be used by upstream elements to reduce their processing rate, for example.

The BaseSink:async property can be used to instruct the sink to never perform an ASYNC state change. This feature is mostly usable when dealing with non-synchronized streams or sparse streams.

func BaseBaseSink

func BaseBaseSink(obj BaseSinker) *BaseSink

BaseBaseSink returns the underlying base object.

func (*BaseSink) Blocksize

func (sink *BaseSink) Blocksize() uint

Blocksize: get the number of bytes that the sink will pull when it is operating in pull mode.

The function returns the following values:

  • guint: number of bytes sink will pull in pull mode.

func (*BaseSink) DoPreroll

func (sink *BaseSink) DoPreroll(obj *gst.MiniObject) gst.FlowReturn

DoPreroll: if the sink spawns its own thread for pulling buffers from upstream it should call this method after it has pulled a buffer. If the element needed to preroll, this function will perform the preroll and will then block until the element state is changed.

This function should be called with the PREROLL_LOCK held.

The function takes the following parameters:

  • obj: mini object that caused the preroll.

The function returns the following values:

  • flowReturn: GST_FLOW_OK if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod.

func (*BaseSink) DropOutOfSegment

func (sink *BaseSink) DropOutOfSegment() bool

DropOutOfSegment checks if sink is currently configured to drop buffers which are outside the current segment.

The function returns the following values:

  • ok: TRUE if the sink is configured to drop buffers outside the current segment.

func (*BaseSink) IsAsyncEnabled

func (sink *BaseSink) IsAsyncEnabled() bool

IsAsyncEnabled checks if sink is currently configured to perform asynchronous state changes to PAUSED.

The function returns the following values:

  • ok: TRUE if the sink is configured to perform asynchronous state changes.

func (*BaseSink) IsLastSampleEnabled

func (sink *BaseSink) IsLastSampleEnabled() bool

IsLastSampleEnabled checks if sink is currently configured to store the last received sample in the last-sample property.

The function returns the following values:

  • ok: TRUE if the sink is configured to store the last received sample.

func (*BaseSink) IsQosEnabled

func (sink *BaseSink) IsQosEnabled() bool

IsQosEnabled checks if sink is currently configured to send Quality-of-Service events upstream.

The function returns the following values:

  • ok: TRUE if the sink is configured to perform Quality-of-Service.

func (*BaseSink) LastSample

func (sink *BaseSink) LastSample() *gst.Sample

LastSample: get the last sample that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails.

The Caps on the sample can be used to determine the type of the buffer.

Free-function: gst_sample_unref.

The function returns the following values:

  • sample (optional) gst_sample_unref() after usage. This function returns NULL when no buffer has arrived in the sink yet or when the sink is not in PAUSED or PLAYING.

func (*BaseSink) Latency

func (sink *BaseSink) Latency() gst.ClockTime

Latency: get the currently configured latency.

The function returns the following values:

  • clockTime: configured latency.

func (*BaseSink) MaxBitrate

func (sink *BaseSink) MaxBitrate() uint64

MaxBitrate: get the maximum amount of bits per second that the sink will render.

The function returns the following values:

  • guint64: maximum number of bits per second sink will render.

func (*BaseSink) MaxLateness

func (sink *BaseSink) MaxLateness() int64

MaxLateness gets the max lateness value. See gst_base_sink_set_max_lateness() for more details.

The function returns the following values:

  • gint64: maximum time in nanoseconds that a buffer can be late before it is dropped and not rendered. A value of -1 means an unlimited time.

func (*BaseSink) ProcessingDeadline

func (sink *BaseSink) ProcessingDeadline() gst.ClockTime

ProcessingDeadline: get the processing deadline of sink. see gst_base_sink_set_processing_deadline() for more information about the processing deadline.

The function returns the following values:

  • clockTime: processing deadline.

func (*BaseSink) QueryLatency

func (sink *BaseSink) QueryLatency() (live, upstreamLive bool, minLatency, maxLatency gst.ClockTime, ok bool)

QueryLatency: query the sink for the latency parameters. The latency will be queried from the upstream elements. live will be TRUE if sink is configured to synchronize against the clock. upstream_live will be TRUE if an upstream element is live.

If both live and upstream_live are TRUE, the sink will want to compensate for the latency introduced by the upstream elements by setting the min_latency to a strictly positive value.

This function is mostly used by subclasses.

The function returns the following values:

  • live (optional): if the sink is live.
  • upstreamLive (optional): if an upstream element is live.
  • minLatency (optional): min latency of the upstream elements.
  • maxLatency (optional): max latency of the upstream elements.
  • ok: TRUE if the query succeeded.

func (*BaseSink) RenderDelay

func (sink *BaseSink) RenderDelay() gst.ClockTime

RenderDelay: get the render delay of sink. see gst_base_sink_set_render_delay() for more information about the render delay.

The function returns the following values:

  • clockTime: render delay of sink.

func (*BaseSink) SetAsyncEnabled

func (sink *BaseSink) SetAsyncEnabled(enabled bool)

SetAsyncEnabled configures sink to perform all state changes asynchronously. When async is disabled, the sink will immediately go to PAUSED instead of waiting for a preroll buffer. This feature is useful if the sink does not synchronize against the clock or when it is dealing with sparse streams.

The function takes the following parameters:

  • enabled: new async value.

func (*BaseSink) SetBlocksize

func (sink *BaseSink) SetBlocksize(blocksize uint)

SetBlocksize: set the number of bytes that the sink will pull when it is operating in pull mode.

The function takes the following parameters:

  • blocksize in bytes.

func (*BaseSink) SetDropOutOfSegment

func (sink *BaseSink) SetDropOutOfSegment(dropOutOfSegment bool)

SetDropOutOfSegment: configure sink to drop buffers which are outside the current segment.

The function takes the following parameters:

  • dropOutOfSegment: drop buffers outside the segment.

func (*BaseSink) SetLastSampleEnabled

func (sink *BaseSink) SetLastSampleEnabled(enabled bool)

SetLastSampleEnabled configures sink to store the last received sample in the last-sample property.

The function takes the following parameters:

  • enabled: new enable-last-sample value.

func (*BaseSink) SetMaxBitrate

func (sink *BaseSink) SetMaxBitrate(maxBitrate uint64)

SetMaxBitrate: set the maximum amount of bits per second that the sink will render.

The function takes the following parameters:

  • maxBitrate: max_bitrate in bits per second.

func (*BaseSink) SetMaxLateness

func (sink *BaseSink) SetMaxLateness(maxLateness int64)

SetMaxLateness sets the new max lateness value to max_lateness. This value is used to decide if a buffer should be dropped or not based on the buffer timestamp and the current clock time. A value of -1 means an unlimited time.

The function takes the following parameters:

  • maxLateness: new max lateness value.

func (*BaseSink) SetProcessingDeadline

func (sink *BaseSink) SetProcessingDeadline(processingDeadline gst.ClockTime)

SetProcessingDeadline: maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines.

This function is usually called by subclasses.

The function takes the following parameters:

  • processingDeadline: new processing deadline in nanoseconds.

func (*BaseSink) SetQosEnabled

func (sink *BaseSink) SetQosEnabled(enabled bool)

SetQosEnabled configures sink to send Quality-of-Service events upstream.

The function takes the following parameters:

  • enabled: new qos value.

func (*BaseSink) SetRenderDelay

func (sink *BaseSink) SetRenderDelay(delay gst.ClockTime)

SetRenderDelay: set the render delay in sink to delay. The render delay is the time between actual rendering of a buffer and its synchronisation time. Some devices might delay media rendering which can be compensated for with this function.

After calling this function, this sink will report additional latency and other sinks will adjust their latency to delay the rendering of their media.

This function is usually called by subclasses.

The function takes the following parameters:

  • delay: new delay.

func (*BaseSink) SetSync

func (sink *BaseSink) SetSync(sync bool)

SetSync configures sink to synchronize on the clock or not. When sync is FALSE, incoming samples will be played as fast as possible. If sync is TRUE, the timestamps of the incoming buffers will be used to schedule the exact render time of its contents.

The function takes the following parameters:

  • sync: new sync value.

func (*BaseSink) SetThrottleTime

func (sink *BaseSink) SetThrottleTime(throttle uint64)

SetThrottleTime: set the time that will be inserted between rendered buffers. This can be used to control the maximum buffers per second that the sink will render.

The function takes the following parameters:

  • throttle time in nanoseconds.

func (*BaseSink) SetTsOffset

func (sink *BaseSink) SetTsOffset(offset gst.ClockTimeDiff)

SetTsOffset: adjust the synchronisation of sink with offset. A negative value will render buffers earlier than their timestamp. A positive value will delay rendering. This function can be used to fix playback of badly timestamped buffers.

The function takes the following parameters:

  • offset: new offset.

func (*BaseSink) Stats

func (sink *BaseSink) Stats() *gst.Structure

Stats: return various BaseSink statistics. This function returns a Structure with name application/x-gst-base-sink-stats with the following fields:

- "average-rate" G_TYPE_DOUBLE average frame rate

- "dropped" G_TYPE_UINT64 Number of dropped frames

- "rendered" G_TYPE_UINT64 Number of rendered frames.

The function returns the following values:

  • structure: pointer to Structure.

func (*BaseSink) Sync

func (sink *BaseSink) Sync() bool

Sync checks if sink is currently configured to synchronize against the clock.

The function returns the following values:

  • ok: TRUE if the sink is configured to synchronize against the clock.

func (*BaseSink) ThrottleTime

func (sink *BaseSink) ThrottleTime() uint64

ThrottleTime: get the time that will be inserted between frames to control the maximum buffers per second.

The function returns the following values:

  • guint64: number of nanoseconds sink will put between frames.

func (*BaseSink) TsOffset

func (sink *BaseSink) TsOffset() gst.ClockTimeDiff

TsOffset: get the synchronisation offset of sink.

The function returns the following values:

  • clockTimeDiff: synchronisation offset.

func (*BaseSink) Wait

func (sink *BaseSink) Wait(time gst.ClockTime) (gst.ClockTimeDiff, gst.FlowReturn)

Wait: this function will wait for preroll to complete and will then block until time is reached. It is usually called by subclasses that use their own internal synchronisation but want to let some synchronization (like EOS) be handled by the base class.

This function should only be called with the PREROLL_LOCK held (like when receiving an EOS event in the ::event vmethod or when handling buffers in ::render).

The time argument should be the running_time of when the timeout should happen and will be adjusted with any latency and offset configured in the sink.

The function takes the following parameters:

  • time to be reached.

The function returns the following values:

  • jitter (optional) to be filled with time diff, or NULL.
  • flowReturn: FlowReturn.

func (*BaseSink) WaitClock

func (sink *BaseSink) WaitClock(time gst.ClockTime) (gst.ClockTimeDiff, gst.ClockReturn)

WaitClock: this function will block until time is reached. It is usually called by subclasses that use their own internal synchronisation.

If time is not valid, no synchronisation is done and GST_CLOCK_BADTIME is returned. Likewise, if synchronisation is disabled in the element or there is no clock, no synchronisation is done and GST_CLOCK_BADTIME is returned.

This function should only be called with the PREROLL_LOCK held, like when receiving an EOS event in the BaseSinkClass::event vmethod or when receiving a buffer in the BaseSinkClass::render vmethod.

The time argument should be the running_time of when this method should return and is not adjusted with any latency or offset configured in the sink.

The function takes the following parameters:

  • time to be reached.

The function returns the following values:

  • jitter (optional) to be filled with time diff, or NULL.
  • clockReturn: ClockReturn.

func (*BaseSink) WaitPreroll

func (sink *BaseSink) WaitPreroll() gst.FlowReturn

WaitPreroll: if the BaseSinkClass::render method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to render the remaining data.

If the BaseSinkClass::render method can block on something else than the clock, it must also be ready to unblock immediately on the BaseSinkClass::unlock method and cause the BaseSinkClass::render method to immediately call this function. In this case, the subclass must be prepared to continue rendering where it left off if this function returns GST_FLOW_OK.

This function will block until a state change to PLAYING happens (in which case this function returns GST_FLOW_OK) or the processing must be stopped due to a state change to READY or a FLUSH event (in which case this function returns GST_FLOW_FLUSHING).

This function should only be called with the PREROLL_LOCK held, like in the render function.

The function returns the following values:

  • flowReturn: GST_FLOW_OK if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod.

type BaseSinkClass

type BaseSinkClass struct {
	// contains filtered or unexported fields
}

BaseSinkClass subclasses can override any of the available virtual methods or not, as needed. At the minimum, the render method should be overridden to output/present buffers.

An instance of this type is always passed by reference.

func (*BaseSinkClass) ParentClass

func (b *BaseSinkClass) ParentClass() *gst.ElementClass

ParentClass: element parent class.

type BaseSinkOverrides

type BaseSinkOverrides struct {
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	ActivatePull func(active bool) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Event func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Fixate func(caps *gst.Caps) *gst.Caps
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Caps func(filter *gst.Caps) *gst.Caps
	// The function takes the following parameters:
	//
	//    - buffer
	//    - start
	//    - end
	//
	Times func(buffer *gst.Buffer, start, end *gst.ClockTime)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Prepare func(buffer *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	PrepareList func(bufferList *gst.BufferList) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Preroll func(buffer *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	ProposeAllocation func(query *gst.Query) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Query func(query *gst.Query) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Render func(buffer *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	RenderList func(bufferList *gst.BufferList) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SetCaps func(caps *gst.Caps) bool
	// The function returns the following values:
	//
	Start func() bool
	// The function returns the following values:
	//
	Stop func() bool
	// The function returns the following values:
	//
	Unlock func() bool
	// The function returns the following values:
	//
	UnlockStop func() bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	WaitEvent func(event *gst.Event) gst.FlowReturn
}

BaseSinkOverrides contains methods that are overridable.

type BaseSinker

type BaseSinker interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

BaseSinker describes types inherited from class BaseSink.

To get the original type, the caller must assert this to an interface or another type.

type BaseSrc

type BaseSrc struct {
	gst.Element
	// contains filtered or unexported fields
}

BaseSrc: this is a generic base class for source elements. The following types of sources are supported:

  • random access sources like files
  • seekable sources
  • live sources

The source can be configured to operate in any Format with the gst_base_src_set_format() method. The currently set format determines the format of the internal Segment and any GST_EVENT_SEGMENT events. The default format for BaseSrc is GST_FORMAT_BYTES.

BaseSrc always supports push mode scheduling. If the following conditions are met, it also supports pull mode scheduling:

  • The format is set to GST_FORMAT_BYTES (default).
  • BaseSrcClass::is_seekable returns TRUE.

If all the conditions are met for operating in pull mode, BaseSrc is automatically seekable in push mode as well. The following conditions must be met to make the element seekable in push mode when the format is not GST_FORMAT_BYTES:

* BaseSrcClass::is_seekable returns TRUE. * BaseSrcClass::query can convert all supported seek formats to the internal format as set with gst_base_src_set_format(). * BaseSrcClass::do_seek is implemented, performs the seek and returns TRUE.

When the element does not meet the requirements to operate in pull mode, the offset and length in the BaseSrcClass::create method should be ignored. It is recommended to subclass PushSrc instead, in this situation. If the element can operate in pull mode but only with specific offsets and lengths, it is allowed to generate an error when the wrong values are passed to the BaseSrcClass::create function.

BaseSrc has support for live sources. Live sources are sources that when paused discard data, such as audio or video capture devices. A typical live source also produces data at a fixed rate and thus provides a clock to publish this rate. Use gst_base_src_set_live() to activate the live source mode.

A live source does not produce data in the PAUSED state. This means that the BaseSrcClass::create method will not be called in PAUSED but only in PLAYING. To signal the pipeline that the element will not produce data, the return value from the READY to PAUSED state will be GST_STATE_CHANGE_NO_PREROLL.

A typical live source will timestamp the buffers it creates with the current running time of the pipeline. This is one reason why a live source can only produce data in the PLAYING state, when the clock is actually distributed and running.

Live sources that synchronize and block on the clock (an audio source, for example) can use gst_base_src_wait_playing() when the BaseSrcClass::create function was interrupted by a state change to PAUSED.

The BaseSrcClass::get_times method can be used to implement pseudo-live sources. It only makes sense to implement the BaseSrcClass::get_times function if the source is a live source. The BaseSrcClass::get_times function should return timestamps starting from 0, as if it were a non-live source. The base class will make sure that the timestamps are transformed into the current running_time. The base source will then wait for the calculated running_time before pushing out the buffer.

For live sources, the base class will by default report a latency of 0. For pseudo live sources, the base class will by default measure the difference between the first buffer timestamp and the start time of get_times and will report this value as the latency. Subclasses should override the query function when this behaviour is not acceptable.

There is only support in BaseSrc for exactly one source pad, which should be named "src". A source implementation (subclass of BaseSrc) should install a pad template in its class_init function, like so:

static void
my_element_class_init (GstMyElementClass *klass)
{
  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
  // srctemplate should be a StaticPadTemplate with direction
  // GST_PAD_SRC and name "src"
  gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);

  gst_element_class_set_static_metadata (gstelement_class,
     "Source name",
     "Source",
     "My Source element",
     "The author <my.sinkmy.email>");
}

Controlled shutdown of live sources in applications

Applications that record from a live source may want to stop recording in a controlled way, so that the recording is stopped, but the data already in the pipeline is processed to the end (remember that many live sources would go on recording forever otherwise). For that to happen the application needs to make the source stop recording and send an EOS event down the pipeline. The application would then wait for an EOS message posted on the pipeline's bus to know when all data has been processed and the pipeline can safely be stopped.

An application may send an EOS event to a source element to make it perform the EOS logic (send EOS event downstream or post a GST_MESSAGE_SEGMENT_DONE on the bus). This can typically be done with the gst_element_send_event() function on the element or its parent bin.

After the EOS has been sent to the element, the application should wait for an EOS message to be posted on the pipeline's bus. Once this EOS message is received, it may safely shut down the entire pipeline.

func BaseBaseSrc

func BaseBaseSrc(obj BaseSrcer) *BaseSrc

BaseBaseSrc returns the underlying base object.

func (*BaseSrc) Allocator

func (src *BaseSrc) Allocator() (gst.Allocatorrer, *gst.AllocationParams)

Allocator lets BaseSrc sub-classes to know the memory allocator used by the base class and its params.

Unref the allocator after usage.

The function returns the following values:

  • allocator (optional): Allocator used.
  • params (optional) of allocator.

func (*BaseSrc) Blocksize

func (src *BaseSrc) Blocksize() uint

Blocksize: get the number of bytes that src will push out with each buffer.

The function returns the following values:

  • guint: number of bytes pushed with each buffer.

func (*BaseSrc) BufferPool

func (src *BaseSrc) BufferPool() *gst.BufferPool

The function returns the following values:

  • bufferPool (optional): instance of the BufferPool used by the src; unref it after usage.

func (*BaseSrc) DoTimestamp

func (src *BaseSrc) DoTimestamp() bool

DoTimestamp: query if src timestamps outgoing buffers based on the current running_time.

The function returns the following values:

  • ok: TRUE if the base class will automatically timestamp outgoing buffers.

func (*BaseSrc) IsAsync

func (src *BaseSrc) IsAsync() bool

IsAsync: get the current async behaviour of src. See also gst_base_src_set_async().

The function returns the following values:

  • ok: TRUE if src is operating in async mode.

func (*BaseSrc) IsLive

func (src *BaseSrc) IsLive() bool

IsLive: check if an element is in live mode.

The function returns the following values:

  • ok: TRUE if element is in live mode.

func (*BaseSrc) Negotiate

func (src *BaseSrc) Negotiate() bool

Negotiate negotiates src pad caps with downstream elements. Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again if BaseSrcClass::negotiate fails.

Do not call this in the BaseSrcClass::fill vmethod. Call this in BaseSrcClass::create or in BaseSrcClass::alloc, _before_ any buffer is allocated.

The function returns the following values:

  • ok: TRUE if the negotiation succeeded, else FALSE.

func (*BaseSrc) NewSeamlessSegment deprecated

func (src *BaseSrc) NewSeamlessSegment(start, stop, time int64) bool

NewSeamlessSegment: prepare a new seamless segment for emission downstream. This function must only be called by derived sub-classes, and only from the BaseSrcClass::create function, as the stream-lock needs to be held.

The format for the new segment will be the current format of the source, as configured with gst_base_src_set_format()

Deprecated: Use gst_base_src_new_segment().

The function takes the following parameters:

  • start: new start value for the segment.
  • stop: stop value for the new segment.
  • time: new time value for the start of the new segment.

The function returns the following values:

  • ok: TRUE if preparation of the seamless segment succeeded.

func (*BaseSrc) NewSegment

func (src *BaseSrc) NewSegment(segment *gst.Segment) bool

NewSegment: prepare a new segment for emission downstream. This function must only be called by derived sub-classes, and only from the BaseSrcClass::create function, as the stream-lock needs to be held.

The format for the segment must be identical with the current format of the source, as configured with gst_base_src_set_format().

The format of src must not be GST_FORMAT_UNDEFINED and the format should be configured via gst_base_src_set_format() before calling this method.

The function takes the following parameters:

  • segment: pointer to a Segment.

The function returns the following values:

  • ok: TRUE if preparation of new segment succeeded.

func (*BaseSrc) QueryLatency

func (src *BaseSrc) QueryLatency() (live bool, minLatency, maxLatency gst.ClockTime, ok bool)

QueryLatency: query the source for the latency parameters. live will be TRUE when src is configured as a live source. min_latency and max_latency will be set to the difference between the running time and the timestamp of the first buffer.

This function is mostly used by subclasses.

The function returns the following values:

  • live (optional): if the source is live.
  • minLatency (optional): min latency of the source.
  • maxLatency (optional): max latency of the source.
  • ok: TRUE if the query succeeded.

func (*BaseSrc) SetAsync

func (src *BaseSrc) SetAsync(async bool)

SetAsync: configure async behaviour in src, no state change will block. The open, close, start, stop, play and pause virtual methods will be executed in a different thread and are thus allowed to perform blocking operations. Any blocking operation should be unblocked with the unlock vmethod.

The function takes the following parameters:

  • async: new async mode.

func (*BaseSrc) SetAutomaticEos

func (src *BaseSrc) SetAutomaticEos(automaticEos bool)

SetAutomaticEos: if automatic_eos is TRUE, src will automatically go EOS if a buffer after the total size is returned. By default this is TRUE but sources that can't return an authoritative size and only know that they're EOS when trying to read more should set this to FALSE.

When src operates in GST_FORMAT_TIME, BaseSrc will send an EOS when a buffer outside of the currently configured segment is pushed if automatic_eos is TRUE. Since 1.16, if automatic_eos is FALSE an EOS will be pushed only when the BaseSrcClass::create implementation returns GST_FLOW_EOS.

The function takes the following parameters:

  • automaticEos: automatic eos.

func (*BaseSrc) SetBlocksize

func (src *BaseSrc) SetBlocksize(blocksize uint)

SetBlocksize: set the number of bytes that src will push out with each buffer. When blocksize is set to -1, a default length will be used.

The function takes the following parameters:

  • blocksize: new blocksize in bytes.

func (*BaseSrc) SetCaps

func (src *BaseSrc) SetCaps(caps *gst.Caps) bool

SetCaps: set new caps on the basesrc source pad.

The function takes the following parameters:

  • caps: Caps.

The function returns the following values:

  • ok: TRUE if the caps could be set.

func (*BaseSrc) SetDoTimestamp

func (src *BaseSrc) SetDoTimestamp(timestamp bool)

SetDoTimestamp: configure src to automatically timestamp outgoing buffers based on the current running_time of the pipeline. This property is mostly useful for live sources.

The function takes the following parameters:

  • timestamp: enable or disable timestamping.

func (*BaseSrc) SetDynamicSize

func (src *BaseSrc) SetDynamicSize(dynamic bool)

SetDynamicSize: if not dynamic, size is only updated when needed, such as when trying to read past current tracked size. Otherwise, size is checked for upon each read.

The function takes the following parameters:

  • dynamic: new dynamic size mode.

func (*BaseSrc) SetFormat

func (src *BaseSrc) SetFormat(format gst.Format)

SetFormat sets the default format of the source. This will be the format used for sending SEGMENT events and for performing seeks.

If a format of GST_FORMAT_BYTES is set, the element will be able to operate in pull mode if the BaseSrcClass::is_seekable returns TRUE.

This function must only be called in states < GST_STATE_PAUSED.

The function takes the following parameters:

  • format to use.

func (*BaseSrc) SetLive

func (src *BaseSrc) SetLive(live bool)

SetLive: if the element listens to a live source, live should be set to TRUE.

A live source will not produce data in the PAUSED state and will therefore not be able to participate in the PREROLL phase of a pipeline. To signal this fact to the application and the pipeline, the state change return value of the live source will be GST_STATE_CHANGE_NO_PREROLL.

The function takes the following parameters:

  • live: new live-mode.

func (*BaseSrc) StartComplete

func (basesrc *BaseSrc) StartComplete(ret gst.FlowReturn)

StartComplete: complete an asynchronous start operation. When the subclass overrides the start method, it should call gst_base_src_start_complete() when the start operation completes either from the same thread or from an asynchronous helper thread.

The function takes the following parameters:

  • ret: FlowReturn.

func (*BaseSrc) StartWait

func (basesrc *BaseSrc) StartWait() gst.FlowReturn

StartWait: wait until the start operation completes.

The function returns the following values:

  • flowReturn: FlowReturn.

func (*BaseSrc) SubmitBufferList

func (src *BaseSrc) SubmitBufferList(bufferList *gst.BufferList)

SubmitBufferList subclasses can call this from their create virtual method implementation to submit a buffer list to be pushed out later. This is useful in cases where the create function wants to produce multiple buffers to be pushed out in one go in form of a BufferList, which can reduce overhead drastically, especially for packetised inputs (for data streams where the packetisation/chunking is not important it is usually more efficient to return larger buffers instead).

Subclasses that use this function from their create function must return GST_FLOW_OK and no buffer from their create virtual method implementation. If a buffer is returned after a buffer list has also been submitted via this function the behaviour is undefined.

Subclasses must only call this function once per create function call and subclasses must only call this function when the source operates in push mode.

The function takes the following parameters:

  • bufferList: BufferList.

func (*BaseSrc) WaitPlaying

func (src *BaseSrc) WaitPlaying() gst.FlowReturn

WaitPlaying: if the BaseSrcClass::create method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to produce the remaining data.

This function will block until a state change to PLAYING happens (in which case this function returns GST_FLOW_OK) or the processing must be stopped due to a state change to READY or a FLUSH event (in which case this function returns GST_FLOW_FLUSHING).

The function returns the following values:

  • flowReturn: GST_FLOW_OK if src is PLAYING and processing can continue. Any other return value should be returned from the create vmethod.

type BaseSrcClass

type BaseSrcClass struct {
	// contains filtered or unexported fields
}

BaseSrcClass subclasses can override any of the available virtual methods or not, as needed. At the minimum, the create method should be overridden to produce buffers.

An instance of this type is always passed by reference.

func (*BaseSrcClass) ParentClass

func (b *BaseSrcClass) ParentClass() *gst.ElementClass

ParentClass: element parent class.

type BaseSrcFlags

type BaseSrcFlags C.guint

BaseSrcFlags flags that a basesrc element may have.

const (
	// BaseSrcFlagStarting has source is starting.
	BaseSrcFlagStarting BaseSrcFlags = 0b100000000000000
	// BaseSrcFlagStarted has source been started.
	BaseSrcFlagStarted BaseSrcFlags = 0b1000000000000000
	// BaseSrcFlagLast: offset to define more flags.
	BaseSrcFlagLast BaseSrcFlags = 0b100000000000000000000
)

func (BaseSrcFlags) Has

func (b BaseSrcFlags) Has(other BaseSrcFlags) bool

Has returns true if b contains other.

func (BaseSrcFlags) String

func (b BaseSrcFlags) String() string

String returns the names in string for BaseSrcFlags.

type BaseSrcOverrides

type BaseSrcOverrides struct {
	// Alloc: ask the subclass to allocate an output buffer with offset and
	// size, the default implementation will use the negotiated allocator.
	//
	// The function takes the following parameters:
	//
	//    - offset
	//    - size
	//
	// The function returns the following values:
	//
	//    - buf
	//    - flowReturn
	//
	Alloc func(offset uint64, size uint) (*gst.Buffer, gst.FlowReturn)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	DecideAllocation func(query *gst.Query) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	DoSeek func(segment *gst.Segment) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Event func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	//    - offset
	//    - size
	//    - buf
	//
	// The function returns the following values:
	//
	Fill func(offset uint64, size uint, buf *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Fixate func(caps *gst.Caps) *gst.Caps
	// Caps: called to get the caps to report.
	//
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Caps func(filter *gst.Caps) *gst.Caps
	// Size: get the total size of the resource in the format set by
	// gst_base_src_set_format().
	//
	// The function returns the following values:
	//
	//    - size
	//    - ok: TRUE if the size is available and has been set.
	//
	Size func() (uint64, bool)
	// Times: given buffer, return start and end time when it should be pushed
	// out. The base class will sync on the clock using these times.
	//
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - start
	//    - end
	//
	Times func(buffer *gst.Buffer) (start, end gst.ClockTime)
	// The function returns the following values:
	//
	IsSeekable func() bool
	// Negotiate negotiates src pad caps with downstream elements. Unmarks
	// GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again if
	// BaseSrcClass::negotiate fails.
	//
	// Do not call this in the BaseSrcClass::fill vmethod. Call this in
	// BaseSrcClass::create or in BaseSrcClass::alloc, _before_ any buffer is
	// allocated.
	//
	// The function returns the following values:
	//
	//    - ok: TRUE if the negotiation succeeded, else FALSE.
	//
	Negotiate func() bool
	// The function takes the following parameters:
	//
	//    - seek
	//    - segment
	//
	// The function returns the following values:
	//
	PrepareSeekSegment func(seek *gst.Event, segment *gst.Segment) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Query func(query *gst.Query) bool
	// SetCaps: set new caps on the basesrc source pad.
	//
	// The function takes the following parameters:
	//
	//    - caps: Caps.
	//
	// The function returns the following values:
	//
	//    - ok: TRUE if the caps could be set.
	//
	SetCaps func(caps *gst.Caps) bool
	// The function returns the following values:
	//
	Start func() bool
	// The function returns the following values:
	//
	Stop func() bool
	// The function returns the following values:
	//
	Unlock func() bool
	// The function returns the following values:
	//
	UnlockStop func() bool
}

BaseSrcOverrides contains methods that are overridable.

type BaseSrcer

type BaseSrcer interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

BaseSrcer describes types inherited from class BaseSrc.

To get the original type, the caller must assert this to an interface or another type.

type BaseTransform

type BaseTransform struct {
	gst.Element
	// contains filtered or unexported fields
}

BaseTransform: this base class is for filter elements that process data. Elements that are suitable for implementation using BaseTransform are ones where the size and caps of the output is known entirely from the input caps and buffer sizes. These include elements that directly transform one buffer into another, modify the contents of a buffer in-place, as well as elements that collate multiple input buffers into one output buffer, or that expand one input buffer into multiple output buffers. See below for more concrete use cases.

It provides for:

* one sinkpad and one srcpad * Possible formats on sink and source pad implemented with custom transform_caps function. By default uses same format on sink and source.

* Handles state changes * Does flushing * Push mode * Pull mode if the sub-class transform can operate on arbitrary data

Use Cases

Passthrough mode

  • Element has no interest in modifying the buffer. It may want to inspect it, in which case the element should have a transform_ip function. If there is no transform_ip function in passthrough mode, the buffer is pushed intact.

  • The BaseTransformClass.passthrough_on_same_caps variable will automatically set/unset passthrough based on whether the element negotiates the same caps on both pads.

  • BaseTransformClass.passthrough_on_same_caps on an element that doesn't implement a transform_caps function is useful for elements that only inspect data (such as level)

  • Example elements

  • Level

  • Videoscale, audioconvert, videoconvert, audioresample in certain modes.

Modifications in-place - input buffer and output buffer are the same thing.

* The element must implement a transform_ip function. * Output buffer size must <= input buffer size * If the always_in_place flag is set, non-writable buffers will be copied and passed to the transform_ip function, otherwise a new buffer will be created and the transform function called.

* Incoming writable buffers will be passed to the transform_ip function immediately. * only implementing transform_ip and not transform implies always_in_place = TRUE

  • Example elements:
  • Volume
  • Audioconvert in certain modes (signed/unsigned conversion)
  • videoconvert in certain modes (endianness swapping)

Modifications only to the caps/metadata of a buffer

* The element does not require writable data, but non-writable buffers should be subbuffered so that the meta-information can be replaced.

* Elements wishing to operate in this mode should replace the prepare_output_buffer method to create subbuffers of the input buffer and set always_in_place to TRUE

* Example elements * Capsfilter when setting caps on outgoing buffers that have none. * identity when it is going to re-timestamp buffers by datarate.

Normal mode

  • always_in_place flag is not set, or there is no transform_ip function
  • Element will receive an input buffer and output buffer to operate on.
  • Output buffer is allocated by calling the prepare_output_buffer function.
  • Example elements:
  • Videoscale, videoconvert, audioconvert when doing scaling/conversions

Special output buffer allocations

  • Elements which need to do special allocation of their output buffers beyond allocating output buffers via the negotiated allocator or buffer pool should implement the prepare_output_buffer method.

  • Example elements:

  • efence

Sub-class settable flags on GstBaseTransform

* passthrough

  • Implies that in the current configuration, the sub-class is not interested in modifying the buffers.
  • Elements which are always in passthrough mode whenever the same caps has been negotiated on both pads can set the class variable passthrough_on_same_caps to have this behaviour automatically.

* always_in_place * Determines whether a non-writable buffer will be copied before passing to the transform_ip function.

  • Implied TRUE if no transform function is implemented.
  • Implied FALSE if ONLY transform function is implemented.

func BaseBaseTransform

func BaseBaseTransform(obj BaseTransformer) *BaseTransform

BaseBaseTransform returns the underlying base object.

func (*BaseTransform) Allocator

func (trans *BaseTransform) Allocator() (gst.Allocatorrer, *gst.AllocationParams)

Allocator lets BaseTransform sub-classes know the memory allocator used by the base class and its params.

Unref the allocator after use.

The function returns the following values:

  • allocator (optional): Allocator used.
  • params (optional) of allocator.

func (*BaseTransform) BufferPool

func (trans *BaseTransform) BufferPool() *gst.BufferPool

The function returns the following values:

  • bufferPool (optional): instance of the BufferPool used by trans; free it after use.

func (*BaseTransform) IsInPlace

func (trans *BaseTransform) IsInPlace() bool

IsInPlace: see if trans is configured as a in_place transform.

The function returns the following values:

  • ok: TRUE if the transform is configured in in_place mode.

    MT safe.

func (*BaseTransform) IsPassthrough

func (trans *BaseTransform) IsPassthrough() bool

IsPassthrough: see if trans is configured as a passthrough transform.

The function returns the following values:

  • ok: TRUE if the transform is configured in passthrough mode.

    MT safe.

func (*BaseTransform) IsQosEnabled

func (trans *BaseTransform) IsQosEnabled() bool

IsQosEnabled queries if the transform will handle QoS.

The function returns the following values:

  • ok: TRUE if QoS is enabled.

    MT safe.

func (*BaseTransform) Reconfigure

func (trans *BaseTransform) Reconfigure() bool

Reconfigure negotiates src pad caps with downstream elements if the source pad is marked as needing reconfiguring. Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again if negotiation fails.

Do not call this in the BaseTransformClass::transform or BaseTransformClass::transform_ip vmethod. Call this in BaseTransformClass::submit_input_buffer, BaseTransformClass::prepare_output_buffer or in BaseTransformClass::generate_output _before_ any output buffer is allocated.

It will be default be called when handling an ALLOCATION query or at the very beginning of the default BaseTransformClass::submit_input_buffer implementation.

The function returns the following values:

  • ok: TRUE if the negotiation succeeded, else FALSE.

func (*BaseTransform) ReconfigureSink

func (trans *BaseTransform) ReconfigureSink()

ReconfigureSink instructs trans to request renegotiation upstream. This function is typically called after properties on the transform were set that influence the input format.

func (*BaseTransform) ReconfigureSrc

func (trans *BaseTransform) ReconfigureSrc()

ReconfigureSrc instructs trans to renegotiate a new downstream transform on the next buffer. This function is typically called after properties on the transform were set that influence the output format.

func (*BaseTransform) SetGapAware

func (trans *BaseTransform) SetGapAware(gapAware bool)

SetGapAware: if gap_aware is FALSE (the default), output buffers will have the GST_BUFFER_FLAG_GAP flag unset.

If set to TRUE, the element must handle output buffers with this flag set correctly, i.e. it can assume that the buffer contains neutral data but must unset the flag if the output is no neutral data.

MT safe.

The function takes the following parameters:

  • gapAware: new state.

func (*BaseTransform) SetInPlace

func (trans *BaseTransform) SetInPlace(inPlace bool)

SetInPlace determines whether a non-writable buffer will be copied before passing to the transform_ip function.

  • Always TRUE if no transform function is implemented.
  • Always FALSE if ONLY transform function is implemented.

MT safe.

The function takes the following parameters:

  • inPlace: boolean value indicating that we would like to operate on in_place buffers.

func (*BaseTransform) SetPassthrough

func (trans *BaseTransform) SetPassthrough(passthrough bool)

SetPassthrough: set passthrough mode for this filter by default. This is mostly useful for filters that do not care about negotiation.

Always TRUE for filters which don't implement either a transform or transform_ip or generate_output method.

MT safe.

The function takes the following parameters:

  • passthrough: boolean indicating passthrough mode.

func (*BaseTransform) SetPreferPassthrough

func (trans *BaseTransform) SetPreferPassthrough(preferPassthrough bool)

SetPreferPassthrough: if prefer_passthrough is TRUE (the default), trans will check and prefer passthrough caps from the list of caps returned by the transform_caps vmethod.

If set to FALSE, the element must order the caps returned from the transform_caps function in such a way that the preferred format is first in the list. This can be interesting for transforms that can do passthrough transforms but prefer to do something else, like a capsfilter.

MT safe.

The function takes the following parameters:

  • preferPassthrough: new state.

func (*BaseTransform) SetQosEnabled

func (trans *BaseTransform) SetQosEnabled(enabled bool)

SetQosEnabled: enable or disable QoS handling in the transform.

MT safe.

The function takes the following parameters:

  • enabled: new state.

func (*BaseTransform) UpdateQos

func (trans *BaseTransform) UpdateQos(proportion float64, diff gst.ClockTimeDiff, timestamp gst.ClockTime)

UpdateQos: set the QoS parameters in the transform. This function is called internally when a QOS event is received but subclasses can provide custom information when needed.

MT safe.

The function takes the following parameters:

  • proportion: proportion.
  • diff against the clock.
  • timestamp of the buffer generating the QoS expressed in running_time.

func (*BaseTransform) UpdateSrcCaps

func (trans *BaseTransform) UpdateSrcCaps(updatedCaps *gst.Caps) bool

UpdateSrcCaps updates the srcpad caps and sends the caps downstream. This function can be used by subclasses when they have already negotiated their caps but found a change in them (or computed new information). This way, they can notify downstream about that change without losing any buffer.

The function takes the following parameters:

  • updatedCaps: updated version of the srcpad caps to be pushed downstream.

The function returns the following values:

  • ok: TRUE if the caps could be sent downstream FALSE otherwise.

type BaseTransformClass

type BaseTransformClass struct {
	// contains filtered or unexported fields
}

BaseTransformClass subclasses can override any of the available virtual methods or not, as needed. At minimum either transform or transform_ip need to be overridden. If the element can overwrite the input data with the results (data is of the same type and quantity) it should provide transform_ip.

An instance of this type is always passed by reference.

func (*BaseTransformClass) ParentClass

func (b *BaseTransformClass) ParentClass() *gst.ElementClass

ParentClass: element parent class.

func (*BaseTransformClass) PassthroughOnSameCaps

func (b *BaseTransformClass) PassthroughOnSameCaps() bool

PassthroughOnSameCaps: if set to TRUE, passthrough mode will be automatically enabled if the caps are the same. Set to FALSE by default.

func (*BaseTransformClass) TransformIPOnPassthrough

func (b *BaseTransformClass) TransformIPOnPassthrough() bool

TransformIPOnPassthrough: if set to TRUE, transform_ip will be called in passthrough mode. The passed buffer might not be writable. When FALSE, neither transform nor transform_ip will be called in passthrough mode. Set to TRUE by default.

type BaseTransformOverrides

type BaseTransformOverrides struct {
	// The function takes the following parameters:
	//
	//    - direction
	//    - caps
	//
	// The function returns the following values:
	//
	AcceptCaps func(direction gst.PadDirection, caps *gst.Caps) bool
	// The function takes the following parameters:
	//
	BeforeTransform func(buffer *gst.Buffer)
	// The function takes the following parameters:
	//
	//    - input
	//    - outbuf
	//
	// The function returns the following values:
	//
	CopyMetadata func(input, outbuf *gst.Buffer) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	DecideAllocation func(query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - query
	//    - api
	//    - params
	//
	// The function returns the following values:
	//
	FilterMeta func(query *gst.Query, api coreglib.Type, params *gst.Structure) bool
	// The function takes the following parameters:
	//
	//    - direction
	//    - caps
	//    - othercaps
	//
	// The function returns the following values:
	//
	FixateCaps func(direction gst.PadDirection, caps, othercaps *gst.Caps) *gst.Caps
	// The function returns the following values:
	//
	//    - outbuf
	//    - flowReturn
	//
	GenerateOutput func() (*gst.Buffer, gst.FlowReturn)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - size
	//    - ok
	//
	UnitSize func(caps *gst.Caps) (uint, bool)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	//    - outbuf
	//    - flowReturn
	//
	PrepareOutputBuffer func(input *gst.Buffer) (*gst.Buffer, gst.FlowReturn)
	// The function takes the following parameters:
	//
	//    - decideQuery
	//    - query
	//
	// The function returns the following values:
	//
	ProposeAllocation func(decideQuery, query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - direction
	//    - query
	//
	// The function returns the following values:
	//
	Query func(direction gst.PadDirection, query *gst.Query) bool
	// The function takes the following parameters:
	//
	//    - incaps
	//    - outcaps
	//
	// The function returns the following values:
	//
	SetCaps func(incaps, outcaps *gst.Caps) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SinkEvent func(event *gst.Event) bool
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	SrcEvent func(event *gst.Event) bool
	// The function returns the following values:
	//
	Start func() bool
	// The function returns the following values:
	//
	Stop func() bool
	// The function takes the following parameters:
	//
	//    - isDiscont
	//    - input
	//
	// The function returns the following values:
	//
	SubmitInputBuffer func(isDiscont bool, input *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - inbuf
	//    - outbuf
	//
	// The function returns the following values:
	//
	Transform func(inbuf, outbuf *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - direction
	//    - caps
	//    - filter
	//
	// The function returns the following values:
	//
	TransformCaps func(direction gst.PadDirection, caps, filter *gst.Caps) *gst.Caps
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	TransformIP func(buf *gst.Buffer) gst.FlowReturn
	// The function takes the following parameters:
	//
	//    - outbuf
	//    - meta
	//    - inbuf
	//
	// The function returns the following values:
	//
	TransformMeta func(outbuf *gst.Buffer, meta *gst.Meta, inbuf *gst.Buffer) bool
	// The function takes the following parameters:
	//
	//    - direction
	//    - caps
	//    - size
	//    - othercaps
	//
	// The function returns the following values:
	//
	//    - othersize
	//    - ok
	//
	TransformSize func(direction gst.PadDirection, caps *gst.Caps, size uint, othercaps *gst.Caps) (uint, bool)
}

BaseTransformOverrides contains methods that are overridable.

type BaseTransformer

type BaseTransformer interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

BaseTransformer describes types inherited from class BaseTransform.

To get the original type, the caller must assert this to an interface or another type.

type BitReader

type BitReader struct {
	// contains filtered or unexported fields
}

BitReader provides a bit reader that can read any number of bits from a memory buffer. It provides functions for reading any number of bits into 8, 16, 32 and 64 bit variables.

An instance of this type is always passed by reference.

func (*BitReader) BitsUint16

func (reader *BitReader) BitsUint16(nbits uint) (uint16, bool)

BitsUint16: read nbits bits into val and update the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) BitsUint32

func (reader *BitReader) BitsUint32(nbits uint) (uint32, bool)

BitsUint32: read nbits bits into val and update the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) BitsUint64

func (reader *BitReader) BitsUint64(nbits uint) (uint64, bool)

BitsUint64: read nbits bits into val and update the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) BitsUint8

func (reader *BitReader) BitsUint8(nbits uint) (byte, bool)

BitsUint8: read nbits bits into val and update the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) Init

func (reader *BitReader) Init(data []byte)

Init initializes a BitReader instance to read from data. This function can be called on already initialized instances.

The function takes the following parameters:

  • data from which the bit reader should read.

func (*BitReader) PeekBitsUint16

func (reader *BitReader) PeekBitsUint16(nbits uint) (uint16, bool)

PeekBitsUint16: read nbits bits into val but keep the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) PeekBitsUint32

func (reader *BitReader) PeekBitsUint32(nbits uint) (uint32, bool)

PeekBitsUint32: read nbits bits into val but keep the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) PeekBitsUint64

func (reader *BitReader) PeekBitsUint64(nbits uint) (uint64, bool)

PeekBitsUint64: read nbits bits into val but keep the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) PeekBitsUint8

func (reader *BitReader) PeekBitsUint8(nbits uint) (byte, bool)

PeekBitsUint8: read nbits bits into val but keep the current position.

The function takes the following parameters:

  • nbits: number of bits to read.

The function returns the following values:

  • val: pointer to a #guint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*BitReader) Pos

func (reader *BitReader) Pos() uint

Pos returns the current position of a BitReader instance in bits.

The function returns the following values:

  • guint: current position of reader in bits.

func (*BitReader) Remaining

func (reader *BitReader) Remaining() uint

Remaining returns the remaining number of bits of a BitReader instance.

The function returns the following values:

  • guint: remaining number of bits of reader instance.

func (*BitReader) SetPos

func (reader *BitReader) SetPos(pos uint) bool

SetPos sets the new position of a BitReader instance to pos in bits.

The function takes the following parameters:

  • pos: new position in bits.

The function returns the following values:

  • ok: TRUE if the position could be set successfully, FALSE otherwise.

func (*BitReader) Size

func (reader *BitReader) Size() uint

Size returns the total number of bits of a BitReader instance.

The function returns the following values:

  • guint: total number of bits of reader instance.

func (*BitReader) Skip

func (reader *BitReader) Skip(nbits uint) bool

Skip skips nbits bits of the BitReader instance.

The function takes the following parameters:

  • nbits: number of bits to skip.

The function returns the following values:

  • ok: TRUE if nbits bits could be skipped, FALSE otherwise.

func (*BitReader) SkipToByte

func (reader *BitReader) SkipToByte() bool

SkipToByte skips until the next byte.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

type BitWriter

type BitWriter struct {
	// contains filtered or unexported fields
}

BitWriter provides a bit writer that can write any number of bits into a memory buffer. It provides functions for writing any number of bits into 8, 16, 32 and 64 bit variables.

An instance of this type is always passed by reference.

func (*BitWriter) AlignBytes

func (bitwriter *BitWriter) AlignBytes(trailingBit byte) bool

AlignBytes: write trailing bit to align last byte of data. trailing_bit can only be 1 or 0.

The function takes the following parameters:

  • trailingBit: trailing bits of last byte, 0 or 1.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

func (*BitWriter) BitSize

func (b *BitWriter) BitSize() uint

BitSize: size of written data in bits.

func (*BitWriter) Data

func (b *BitWriter) Data() *byte

Data: allocated data for bit writer to write.

func (*BitWriter) FreeAndGetBuffer

func (bitwriter *BitWriter) FreeAndGetBuffer() *gst.Buffer

FreeAndGetBuffer frees bitwriter without destroying the internal data, which is returned as Buffer.

Free-function: gst_buffer_unref.

The function returns the following values:

  • buffer: new allocated Buffer wrapping the data inside. gst_buffer_unref() after usage.

func (*BitWriter) PutBitsUint16

func (bitwriter *BitWriter) PutBitsUint16(value uint16, nbits uint) bool

PutBitsUint16: write nbits bits of value to BitWriter.

The function takes the following parameters:

  • value of #guint16 to write.
  • nbits: number of bits to write.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

func (*BitWriter) PutBitsUint32

func (bitwriter *BitWriter) PutBitsUint32(value uint32, nbits uint) bool

PutBitsUint32: write nbits bits of value to BitWriter.

The function takes the following parameters:

  • value of #guint32 to write.
  • nbits: number of bits to write.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

func (*BitWriter) PutBitsUint64

func (bitwriter *BitWriter) PutBitsUint64(value uint64, nbits uint) bool

PutBitsUint64: write nbits bits of value to BitWriter.

The function takes the following parameters:

  • value of #guint64 to write.
  • nbits: number of bits to write.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

func (*BitWriter) PutBitsUint8

func (bitwriter *BitWriter) PutBitsUint8(value byte, nbits uint) bool

PutBitsUint8: write nbits bits of value to BitWriter.

The function takes the following parameters:

  • value of #guint8 to write.
  • nbits: number of bits to write.

The function returns the following values:

  • ok: TRUE if successful, FALSE otherwise.

func (*BitWriter) Remaining

func (bitwriter *BitWriter) Remaining() uint

The function returns the following values:

func (*BitWriter) Reset

func (bitwriter *BitWriter) Reset()

Reset resets bitwriter and frees the data if it's owned by bitwriter.

func (*BitWriter) ResetAndGetBuffer

func (bitwriter *BitWriter) ResetAndGetBuffer() *gst.Buffer

ResetAndGetBuffer resets bitwriter and returns the current data as Buffer.

Free-function: gst_buffer_unref.

The function returns the following values:

  • buffer: new allocated Buffer wrapping the current data. gst_buffer_unref() after usage.

func (*BitWriter) SetBitSize

func (b *BitWriter) SetBitSize(bitSize uint)

BitSize: size of written data in bits.

func (*BitWriter) SetPos

func (bitwriter *BitWriter) SetPos(pos uint) bool

The function takes the following parameters:

The function returns the following values:

func (*BitWriter) Size

func (bitwriter *BitWriter) Size() uint

Size: get size of written data.

The function returns the following values:

  • guint: size of bits written in data.

type ByteReader

type ByteReader struct {
	// contains filtered or unexported fields
}

ByteReader provides a byte reader that can read different integer and floating point types from a memory buffer. It provides functions for reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to read NUL-terminated strings in various character encodings.

An instance of this type is always passed by reference.

func (*ByteReader) DupStringUTF16

func (reader *ByteReader) DupStringUTF16() ([]uint16, bool)

DupStringUTF16: free-function: g_free

Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-16 string in the data (this could be an empty string as well), and advances the current position.

No input checking for valid UTF-16 is done. This function is endianness agnostic - you should not assume the UTF-16 characters are in host endianness.

This function will fail if no NUL-terminator was found in in the data.

Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-16 string.

The function returns the following values:

  • str address of a #guint16 pointer variable in which to store the result.
  • ok: TRUE if a string could be read, FALSE otherwise. The string put into str must be freed with g_free() when no longer needed.

func (*ByteReader) DupStringUTF32

func (reader *ByteReader) DupStringUTF32() ([]uint32, bool)

DupStringUTF32: free-function: g_free

Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-32 string in the data (this could be an empty string as well), and advances the current position.

No input checking for valid UTF-32 is done. This function is endianness agnostic - you should not assume the UTF-32 characters are in host endianness.

This function will fail if no NUL-terminator was found in in the data.

Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-32 string.

The function returns the following values:

  • str address of a #guint32 pointer variable in which to store the result.
  • ok: TRUE if a string could be read, FALSE otherwise. The string put into str must be freed with g_free() when no longer needed.

func (*ByteReader) Float32Be

func (reader *ByteReader) Float32Be() (float32, bool)

Float32Be: read a 32 bit big endian floating point value into val and update the current position.

The function returns the following values:

  • val: pointer to a #gfloat to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Float32LE

func (reader *ByteReader) Float32LE() (float32, bool)

Float32LE: read a 32 bit little endian floating point value into val and update the current position.

The function returns the following values:

  • val: pointer to a #gfloat to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Float64Be

func (reader *ByteReader) Float64Be() (float64, bool)

Float64Be: read a 64 bit big endian floating point value into val and update the current position.

The function returns the following values:

  • val: pointer to a #gdouble to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Float64LE

func (reader *ByteReader) Float64LE() (float64, bool)

Float64LE: read a 64 bit little endian floating point value into val and update the current position.

The function returns the following values:

  • val: pointer to a #gdouble to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Init

func (reader *ByteReader) Init(data []byte)

Init initializes a ByteReader instance to read from data. This function can be called on already initialized instances.

The function takes the following parameters:

  • data from which the ByteReader should read.

func (*ByteReader) Int16Be

func (reader *ByteReader) Int16Be() (int16, bool)

Int16Be: read a signed 16 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int16LE

func (reader *ByteReader) Int16LE() (int16, bool)

Int16LE: read a signed 16 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int24Be

func (reader *ByteReader) Int24Be() (int32, bool)

Int24Be: read a signed 24 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int24LE

func (reader *ByteReader) Int24LE() (int32, bool)

Int24LE: read a signed 24 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int32Be

func (reader *ByteReader) Int32Be() (int32, bool)

Int32Be: read a signed 32 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int32LE

func (reader *ByteReader) Int32LE() (int32, bool)

Int32LE: read a signed 32 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int64Be

func (reader *ByteReader) Int64Be() (int64, bool)

Int64Be: read a signed 64 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int64LE

func (reader *ByteReader) Int64LE() (int64, bool)

Int64LE: read a signed 64 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Int8

func (reader *ByteReader) Int8() (int8, bool)

Int8: read a signed 8 bit integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #gint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) MaskedScanUint32

func (reader *ByteReader) MaskedScanUint32(mask uint32, pattern uint32, offset uint, size uint) uint

MaskedScanUint32: scan for pattern pattern with applied mask mask in the byte reader data, starting from offset offset relative to the current position.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader.

The function takes the following parameters:

  • mask to apply to data before matching against pattern.
  • pattern to match (after mask is applied).
  • offset from which to start scanning, relative to the current position.
  • size: number of bytes to scan from offset.

The function returns the following values:

  • guint: offset of the first match, or -1 if no match was found.

    Example:

    // Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff

    gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 0, 256); // -> returns 0 gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 1, 255); // -> returns -1 gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x01020304, 1, 255); // -> returns 1 gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0001, 0, 256); // -> returns -1 gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0203, 0, 256); // -> returns 0 gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 256); // -> returns 2 gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 4); // -> returns -1.

func (*ByteReader) MaskedScanUint32Peek

func (reader *ByteReader) MaskedScanUint32Peek(mask uint32, pattern uint32, offset uint, size uint) (uint32, uint)

MaskedScanUint32Peek: scan for pattern pattern with applied mask mask in the byte reader data, starting from offset offset relative to the current position.

The bytes in pattern and mask are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out.

It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader.

The function takes the following parameters:

  • mask to apply to data before matching against pattern.
  • pattern to match (after mask is applied).
  • offset from which to start scanning, relative to the current position.
  • size: number of bytes to scan from offset.

The function returns the following values:

  • value: pointer to uint32 to return matching data.
  • guint: offset of the first match, or -1 if no match was found.

func (*ByteReader) PeekFloat32Be

func (reader *ByteReader) PeekFloat32Be() (float32, bool)

PeekFloat32Be: read a 32 bit big endian floating point value into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gfloat to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekFloat32LE

func (reader *ByteReader) PeekFloat32LE() (float32, bool)

PeekFloat32LE: read a 32 bit little endian floating point value into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gfloat to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekFloat64Be

func (reader *ByteReader) PeekFloat64Be() (float64, bool)

PeekFloat64Be: read a 64 bit big endian floating point value into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gdouble to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekFloat64LE

func (reader *ByteReader) PeekFloat64LE() (float64, bool)

PeekFloat64LE: read a 64 bit little endian floating point value into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gdouble to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt16Be

func (reader *ByteReader) PeekInt16Be() (int16, bool)

PeekInt16Be: read a signed 16 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt16LE

func (reader *ByteReader) PeekInt16LE() (int16, bool)

PeekInt16LE: read a signed 16 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt24Be

func (reader *ByteReader) PeekInt24Be() (int32, bool)

PeekInt24Be: read a signed 24 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt24LE

func (reader *ByteReader) PeekInt24LE() (int32, bool)

PeekInt24LE: read a signed 24 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt32Be

func (reader *ByteReader) PeekInt32Be() (int32, bool)

PeekInt32Be: read a signed 32 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt32LE

func (reader *ByteReader) PeekInt32LE() (int32, bool)

PeekInt32LE: read a signed 32 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt64Be

func (reader *ByteReader) PeekInt64Be() (int64, bool)

PeekInt64Be: read a signed 64 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt64LE

func (reader *ByteReader) PeekInt64LE() (int64, bool)

PeekInt64LE: read a signed 64 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekInt8

func (reader *ByteReader) PeekInt8() (int8, bool)

PeekInt8: read a signed 8 bit integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #gint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint16Be

func (reader *ByteReader) PeekUint16Be() (uint16, bool)

PeekUint16Be: read an unsigned 16 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint16LE

func (reader *ByteReader) PeekUint16LE() (uint16, bool)

PeekUint16LE: read an unsigned 16 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint24Be

func (reader *ByteReader) PeekUint24Be() (uint32, bool)

PeekUint24Be: read an unsigned 24 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint24LE

func (reader *ByteReader) PeekUint24LE() (uint32, bool)

PeekUint24LE: read an unsigned 24 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint32Be

func (reader *ByteReader) PeekUint32Be() (uint32, bool)

PeekUint32Be: read an unsigned 32 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint32LE

func (reader *ByteReader) PeekUint32LE() (uint32, bool)

PeekUint32LE: read an unsigned 32 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint64Be

func (reader *ByteReader) PeekUint64Be() (uint64, bool)

PeekUint64Be: read an unsigned 64 bit big endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint64LE

func (reader *ByteReader) PeekUint64LE() (uint64, bool)

PeekUint64LE: read an unsigned 64 bit little endian integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) PeekUint8

func (reader *ByteReader) PeekUint8() (byte, bool)

PeekUint8: read an unsigned 8 bit integer into val but keep the current position.

The function returns the following values:

  • val: pointer to a #guint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Pos

func (reader *ByteReader) Pos() uint

Pos returns the current position of a ByteReader instance in bytes.

The function returns the following values:

  • guint: current position of reader in bytes.

func (*ByteReader) Remaining

func (reader *ByteReader) Remaining() uint

Remaining returns the remaining number of bytes of a ByteReader instance.

The function returns the following values:

  • guint: remaining number of bytes of reader instance.

func (*ByteReader) SetPos

func (reader *ByteReader) SetPos(pos uint) bool

SetPos sets the new position of a ByteReader instance to pos in bytes.

The function takes the following parameters:

  • pos: new position in bytes.

The function returns the following values:

  • ok: TRUE if the position could be set successfully, FALSE otherwise.

func (*ByteReader) Size

func (reader *ByteReader) Size() uint

Size returns the total number of bytes of a ByteReader instance.

The function returns the following values:

  • guint: total number of bytes of reader instance.

func (*ByteReader) Skip

func (reader *ByteReader) Skip(nbytes uint) bool

Skip skips nbytes bytes of the ByteReader instance.

The function takes the following parameters:

  • nbytes: number of bytes to skip.

The function returns the following values:

  • ok: TRUE if nbytes bytes could be skipped, FALSE otherwise.

func (*ByteReader) SkipStringUTF16

func (reader *ByteReader) SkipStringUTF16() bool

SkipStringUTF16 skips a NUL-terminated UTF-16 string in the ByteReader instance, advancing the current position to the byte after the string.

No input checking for valid UTF-16 is done.

This function will fail if no NUL-terminator was found in in the data.

The function returns the following values:

  • ok: TRUE if a string could be skipped, FALSE otherwise.

func (*ByteReader) SkipStringUTF32

func (reader *ByteReader) SkipStringUTF32() bool

SkipStringUTF32 skips a NUL-terminated UTF-32 string in the ByteReader instance, advancing the current position to the byte after the string.

No input checking for valid UTF-32 is done.

This function will fail if no NUL-terminator was found in in the data.

The function returns the following values:

  • ok: TRUE if a string could be skipped, FALSE otherwise.

func (*ByteReader) SkipStringUTF8

func (reader *ByteReader) SkipStringUTF8() bool

SkipStringUTF8 skips a NUL-terminated string in the ByteReader instance, advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.

This function will fail if no NUL-terminator was found in in the data.

The function returns the following values:

  • ok: TRUE if a string could be skipped, FALSE otherwise.

func (*ByteReader) Uint16Be

func (reader *ByteReader) Uint16Be() (uint16, bool)

Uint16Be: read an unsigned 16 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint16LE

func (reader *ByteReader) Uint16LE() (uint16, bool)

Uint16LE: read an unsigned 16 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint16 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint24Be

func (reader *ByteReader) Uint24Be() (uint32, bool)

Uint24Be: read an unsigned 24 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint24LE

func (reader *ByteReader) Uint24LE() (uint32, bool)

Uint24LE: read an unsigned 24 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint32Be

func (reader *ByteReader) Uint32Be() (uint32, bool)

Uint32Be: read an unsigned 32 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint32LE

func (reader *ByteReader) Uint32LE() (uint32, bool)

Uint32LE: read an unsigned 32 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint32 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint64Be

func (reader *ByteReader) Uint64Be() (uint64, bool)

Uint64Be: read an unsigned 64 bit big endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint64LE

func (reader *ByteReader) Uint64LE() (uint64, bool)

Uint64LE: read an unsigned 64 bit little endian integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint64 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

func (*ByteReader) Uint8

func (reader *ByteReader) Uint8() (byte, bool)

Uint8: read an unsigned 8 bit integer into val and update the current position.

The function returns the following values:

  • val: pointer to a #guint8 to store the result.
  • ok: TRUE if successful, FALSE otherwise.

type ByteWriter

type ByteWriter struct {
	// contains filtered or unexported fields
}

ByteWriter provides a byte writer and reader that can write/read different integer and floating point types to/from a memory buffer. It provides functions for writing/reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to write/read NUL-terminated strings in various character encodings.

An instance of this type is always passed by reference.

func (*ByteWriter) AllocSize

func (b *ByteWriter) AllocSize() uint

AllocSize: allocation size of the data.

func (*ByteWriter) EnsureFreeSpace

func (writer *ByteWriter) EnsureFreeSpace(size uint) bool

EnsureFreeSpace checks if enough free space from the current write cursor is available and reallocates if necessary.

The function takes the following parameters:

  • size: number of bytes that should be available.

The function returns the following values:

  • ok: TRUE if at least size bytes are still available.

func (*ByteWriter) Fill

func (writer *ByteWriter) Fill(value byte, size uint) bool

Fill writes size bytes containing value to writer.

The function takes the following parameters:

  • value: value to be written.
  • size: number of bytes to be written.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) Fixed

func (b *ByteWriter) Fixed() bool

Fixed: if TRUE no reallocations are allowed.

func (*ByteWriter) FreeAndGetBuffer

func (writer *ByteWriter) FreeAndGetBuffer() *gst.Buffer

FreeAndGetBuffer frees writer and all memory allocated by it except the current data, which is returned as Buffer.

Free-function: gst_buffer_unref.

The function returns the following values:

  • buffer: current data as buffer. gst_buffer_unref() after usage.

func (*ByteWriter) FreeAndGetData

func (writer *ByteWriter) FreeAndGetData() *byte

FreeAndGetData frees writer and all memory allocated by it except the current data, which is returned.

Free-function: g_free.

The function returns the following values:

  • guint8: current data. g_free() after usage.

func (*ByteWriter) Init

func (writer *ByteWriter) Init()

Init initializes writer to an empty instance.

func (*ByteWriter) InitWithData

func (writer *ByteWriter) InitWithData(data []byte, initialized bool)

InitWithData initializes writer with the given memory area. If initialized is TRUE it is possible to read size bytes from the ByteWriter from the beginning.

The function takes the following parameters:

  • data: memory area for writing.
  • initialized: if TRUE the complete data can be read from the beginning.

func (*ByteWriter) InitWithSize

func (writer *ByteWriter) InitWithSize(size uint, fixed bool)

InitWithSize initializes writer with the given initial data size.

The function takes the following parameters:

  • size: initial size of data.
  • fixed: if TRUE the data can't be reallocated.

func (*ByteWriter) Owned

func (b *ByteWriter) Owned() bool

Owned: if FALSE no reallocations are allowed and copies of data are returned.

func (*ByteWriter) Parent

func (b *ByteWriter) Parent() *ByteReader

Parent: ByteReader parent.

func (*ByteWriter) PutBuffer

func (writer *ByteWriter) PutBuffer(buffer *gst.Buffer, offset uint, size int) bool

PutBuffer writes size bytes of data to writer.

The function takes the following parameters:

  • buffer: source Buffer.
  • offset to copy from.
  • size: total size to copy. If -1, all data is copied.

The function returns the following values:

  • ok: TRUE if the data could be written.

func (*ByteWriter) PutData

func (writer *ByteWriter) PutData(data []byte) bool

PutData writes size bytes of data to writer.

The function takes the following parameters:

  • data: data to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutFloat32Be

func (writer *ByteWriter) PutFloat32Be(val float32) bool

PutFloat32Be writes a big endian 32 bit float to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutFloat32LE

func (writer *ByteWriter) PutFloat32LE(val float32) bool

PutFloat32LE writes a little endian 32 bit float to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutFloat64Be

func (writer *ByteWriter) PutFloat64Be(val float64) bool

PutFloat64Be writes a big endian 64 bit float to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutFloat64LE

func (writer *ByteWriter) PutFloat64LE(val float64) bool

PutFloat64LE writes a little endian 64 bit float to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt16Be

func (writer *ByteWriter) PutInt16Be(val int16) bool

PutInt16Be writes a signed big endian 16 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt16LE

func (writer *ByteWriter) PutInt16LE(val int16) bool

PutInt16LE writes a signed little endian 16 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt24Be

func (writer *ByteWriter) PutInt24Be(val int32) bool

PutInt24Be writes a signed big endian 24 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt24LE

func (writer *ByteWriter) PutInt24LE(val int32) bool

PutInt24LE writes a signed little endian 24 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt32Be

func (writer *ByteWriter) PutInt32Be(val int32) bool

PutInt32Be writes a signed big endian 32 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt32LE

func (writer *ByteWriter) PutInt32LE(val int32) bool

PutInt32LE writes a signed little endian 32 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt64Be

func (writer *ByteWriter) PutInt64Be(val int64) bool

PutInt64Be writes a signed big endian 64 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt64LE

func (writer *ByteWriter) PutInt64LE(val int64) bool

PutInt64LE writes a signed little endian 64 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutInt8

func (writer *ByteWriter) PutInt8(val int8) bool

PutInt8 writes a signed 8 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutStringUTF16

func (writer *ByteWriter) PutStringUTF16(data []uint16) bool

PutStringUTF16 writes a NUL-terminated UTF16 string to writer (including the terminator).

The function takes the following parameters:

  • data: UTF16 string to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutStringUTF32

func (writer *ByteWriter) PutStringUTF32(data []uint32) bool

PutStringUTF32 writes a NUL-terminated UTF32 string to writer (including the terminator).

The function takes the following parameters:

  • data: UTF32 string to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutStringUTF8

func (writer *ByteWriter) PutStringUTF8(data string) bool

PutStringUTF8 writes a NUL-terminated UTF8 string to writer (including the terminator).

The function takes the following parameters:

  • data: UTF8 string to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint16Be

func (writer *ByteWriter) PutUint16Be(val uint16) bool

PutUint16Be writes a unsigned big endian 16 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint16LE

func (writer *ByteWriter) PutUint16LE(val uint16) bool

PutUint16LE writes a unsigned little endian 16 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint24Be

func (writer *ByteWriter) PutUint24Be(val uint32) bool

PutUint24Be writes a unsigned big endian 24 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint24LE

func (writer *ByteWriter) PutUint24LE(val uint32) bool

PutUint24LE writes a unsigned little endian 24 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint32Be

func (writer *ByteWriter) PutUint32Be(val uint32) bool

PutUint32Be writes a unsigned big endian 32 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint32LE

func (writer *ByteWriter) PutUint32LE(val uint32) bool

PutUint32LE writes a unsigned little endian 32 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint64Be

func (writer *ByteWriter) PutUint64Be(val uint64) bool

PutUint64Be writes a unsigned big endian 64 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint64LE

func (writer *ByteWriter) PutUint64LE(val uint64) bool

PutUint64LE writes a unsigned little endian 64 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) PutUint8

func (writer *ByteWriter) PutUint8(val byte) bool

PutUint8 writes a unsigned 8 bit integer to writer.

The function takes the following parameters:

  • val: value to write.

The function returns the following values:

  • ok: TRUE if the value could be written.

func (*ByteWriter) Remaining

func (writer *ByteWriter) Remaining() uint

Remaining returns the remaining size of data that can still be written. If -1 is returned the remaining size is only limited by system resources.

The function returns the following values:

  • guint: remaining size of data that can still be written.

func (*ByteWriter) Reset

func (writer *ByteWriter) Reset()

Reset resets writer and frees the data if it's owned by writer.

func (*ByteWriter) ResetAndGetBuffer

func (writer *ByteWriter) ResetAndGetBuffer() *gst.Buffer

ResetAndGetBuffer resets writer and returns the current data as buffer.

Free-function: gst_buffer_unref.

The function returns the following values:

  • buffer: current data as buffer. gst_buffer_unref() after usage.

func (*ByteWriter) SetAllocSize

func (b *ByteWriter) SetAllocSize(allocSize uint)

AllocSize: allocation size of the data.

func (*ByteWriter) SetFixed

func (b *ByteWriter) SetFixed(fixed bool)

Fixed: if TRUE no reallocations are allowed.

func (*ByteWriter) SetOwned

func (b *ByteWriter) SetOwned(owned bool)

Owned: if FALSE no reallocations are allowed and copies of data are returned.

type CollectData

type CollectData struct {
	// contains filtered or unexported fields
}

CollectData: structure used by the collect_pads.

An instance of this type is always passed by reference.

func (*CollectData) Buffer

func (c *CollectData) Buffer() *gst.Buffer

Buffer: currently queued buffer.

func (*CollectData) Collect

func (c *CollectData) Collect() *CollectPads

Collect: owner CollectPads.

func (*CollectData) Pad

func (c *CollectData) Pad() *gst.Pad

Pad managed by this data.

func (*CollectData) Pos

func (c *CollectData) Pos() uint

Pos: position in the buffer.

func (*CollectData) Segment

func (c *CollectData) Segment() *gst.Segment

Segment: last segment received.

func (*CollectData) SetPos

func (c *CollectData) SetPos(pos uint)

Pos: position in the buffer.

type CollectPads

type CollectPads struct {
	gst.GstObject
	// contains filtered or unexported fields
}

CollectPads manages a set of pads that operate in collect mode. This means that control is given to the manager of this object when all pads have data.

  • Collectpads are created with gst_collect_pads_new(). A callback should then be installed with gst_collect_pads_set_function ().

  • Pads are added to the collection with gst_collect_pads_add_pad()/ gst_collect_pads_remove_pad(). The pad has to be a sinkpad. When added, the chain, event and query functions of the pad are overridden. The element_private of the pad is used to store private information for the collectpads.

  • For each pad, data is queued in the _chain function or by performing a pull_range.

  • When data is queued on all pads in waiting mode, the callback function is called.

  • Data can be dequeued from the pad with the gst_collect_pads_pop() method. One can peek at the data with the gst_collect_pads_peek() function. These functions will return NULL if the pad received an EOS event. When all pads return NULL from a gst_collect_pads_peek(), the element can emit an EOS event itself.

  • Data can also be dequeued in byte units using the gst_collect_pads_available(), gst_collect_pads_read_buffer() and gst_collect_pads_flush() calls.

  • Elements should call gst_collect_pads_start() and gst_collect_pads_stop() in their state change functions to start and stop the processing of the collectpads. The gst_collect_pads_stop() call should be called before calling the parent element state change function in the PAUSED_TO_READY state change to ensure no pad is blocked and the element can finish streaming.

  • gst_collect_pads_set_waiting() sets a pad to waiting or non-waiting mode. CollectPads element is not waiting for data to be collected on non-waiting pads. Thus these pads may but need not have data when the callback is called. All pads are in waiting mode by default.

func NewCollectPads

func NewCollectPads() *CollectPads

NewCollectPads: create a new instance of CollectPads.

MT safe.

The function returns the following values:

  • collectPads: new CollectPads, or NULL in case of an error.

func (*CollectPads) Available

func (pads *CollectPads) Available() uint

Available: query how much bytes can be read from each queued buffer. This means that the result of this call is the maximum number of bytes that can be read from each of the pads.

This function should be called with pads STREAM_LOCK held, such as in the callback.

MT safe.

The function returns the following values:

  • guint: maximum number of bytes queued on all pads. This function returns 0 if a pad has no queued buffer.

func (*CollectPads) ClipRunningTime

func (pads *CollectPads) ClipRunningTime(cdata *CollectData, buf *gst.Buffer, userData unsafe.Pointer) (*gst.Buffer, gst.FlowReturn)

ClipRunningTime: convenience clipping function that converts incoming buffer's timestamp to running time, or clips the buffer if outside configured segment.

Since 1.6, this clipping function also sets the DTS parameter of the GstCollectData structure. This version of the running time DTS can be negative. G_MININT64 is used to indicate invalid value.

The function takes the following parameters:

  • cdata: collect data of corresponding pad.
  • buf: buffer being clipped.
  • userData (optional): user data (unused).

The function returns the following values:

  • outbuf (optional): output buffer with running time, or NULL if clipped.
  • flowReturn

func (*CollectPads) EventDefault

func (pads *CollectPads) EventDefault(data *CollectData, event *gst.Event, discard bool) bool

EventDefault: default CollectPads event handling that elements should always chain up to to ensure proper operation. Element might however indicate event should not be forwarded downstream.

The function takes the following parameters:

  • data: collect data of corresponding pad.
  • event being processed.
  • discard process but do not send event downstream.

The function returns the following values:

func (*CollectPads) Flush

func (pads *CollectPads) Flush(data *CollectData, size uint) uint

Flush size bytes from the pad data.

This function should be called with pads STREAM_LOCK held, such as in the callback.

MT safe.

The function takes the following parameters:

  • data to use.
  • size: number of bytes to flush.

The function returns the following values:

  • guint: number of bytes flushed This can be less than size and is 0 if the pad was end-of-stream.

func (*CollectPads) Peek

func (pads *CollectPads) Peek(data *CollectData) *gst.Buffer

Peek at the buffer currently queued in data. This function should be called with the pads STREAM_LOCK held, such as in the callback handler.

MT safe.

The function takes the following parameters:

  • data to use.

The function returns the following values:

  • buffer (optional) in data or NULL if no buffer is queued. should unref the buffer after usage.

func (*CollectPads) Pop

func (pads *CollectPads) Pop(data *CollectData) *gst.Buffer

Pop the buffer currently queued in data. This function should be called with the pads STREAM_LOCK held, such as in the callback handler.

MT safe.

The function takes the following parameters:

  • data to use.

The function returns the following values:

  • buffer (optional) in data or NULL if no buffer was queued. You should unref the buffer after usage.

func (*CollectPads) QueryDefault

func (pads *CollectPads) QueryDefault(data *CollectData, query *gst.Query, discard bool) bool

QueryDefault: default CollectPads query handling that elements should always chain up to to ensure proper operation. Element might however indicate query should not be forwarded downstream.

The function takes the following parameters:

  • data: collect data of corresponding pad.
  • query being processed.
  • discard process but do not send event downstream.

The function returns the following values:

func (*CollectPads) ReadBuffer

func (pads *CollectPads) ReadBuffer(data *CollectData, size uint) *gst.Buffer

ReadBuffer: get a subbuffer of size bytes from the given pad data.

This function should be called with pads STREAM_LOCK held, such as in the callback.

MT safe.

The function takes the following parameters:

  • data to use.
  • size: number of bytes to read.

The function returns the following values:

  • buffer (optional): sub buffer. The size of the buffer can be less that requested. A return of NULL signals that the pad is end-of-stream. Unref the buffer after use.

func (*CollectPads) RemovePad

func (pads *CollectPads) RemovePad(pad *gst.Pad) bool

RemovePad: remove a pad from the collection of collect pads. This function will also free the CollectData and all the resources that were allocated with gst_collect_pads_add_pad().

The pad will be deactivated automatically when pads is stopped.

MT safe.

The function takes the following parameters:

  • pad to remove.

The function returns the following values:

  • ok: TRUE if the pad could be removed.

func (*CollectPads) SetBufferFunction

func (pads *CollectPads) SetBufferFunction(fn CollectPadsBufferFunction)

SetBufferFunction: set the callback function and user data that will be called with the oldest buffer when all pads have been collected, or NULL on EOS. If a buffer is passed, the callback owns a reference and must unref it.

MT safe.

The function takes the following parameters:

  • fn: function to set.

func (*CollectPads) SetClipFunction

func (pads *CollectPads) SetClipFunction(clipfunc CollectPadsClipFunction)

SetClipFunction: install a clipping function that is called right after a buffer is received on a pad managed by pads. See CollectPadsClipFunction for more info.

The function takes the following parameters:

  • clipfunc: clip function to install.

func (*CollectPads) SetCompareFunction

func (pads *CollectPads) SetCompareFunction(fn CollectPadsCompareFunction)

SetCompareFunction: set the timestamp comparison function.

MT safe.

The function takes the following parameters:

  • fn: function to set.

func (*CollectPads) SetEventFunction

func (pads *CollectPads) SetEventFunction(fn CollectPadsEventFunction)

SetEventFunction: set the event callback function and user data that will be called when collectpads has received an event originating from one of the collected pads. If the event being processed is a serialized one, this callback is called with pads STREAM_LOCK held, otherwise not. As this lock should be held when calling a number of CollectPads functions, it should be acquired if so (unusually) needed.

MT safe.

The function takes the following parameters:

  • fn: function to set.

func (*CollectPads) SetFlushFunction

func (pads *CollectPads) SetFlushFunction(fn CollectPadsFlushFunction)

SetFlushFunction: install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling. See CollectPadsFlushFunction for more info.

The function takes the following parameters:

  • fn: flush function to install.

func (*CollectPads) SetFlushing

func (pads *CollectPads) SetFlushing(flushing bool)

SetFlushing: change the flushing state of all the pads in the collection. No pad is able to accept anymore data when flushing is TRUE. Calling this function with flushing FALSE makes pads accept data again. Caller must ensure that downstream streaming (thread) is not blocked, e.g. by sending a FLUSH_START downstream.

MT safe.

The function takes the following parameters:

  • flushing: desired state of the pads.

func (*CollectPads) SetFunction

func (pads *CollectPads) SetFunction(fn CollectPadsFunction)

SetFunction collectPads provides a default collection algorithm that will determine the oldest buffer available on all of its pads, and then delegate to a configured callback. However, if circumstances are more complicated and/or more control is desired, this sets a callback that will be invoked instead when all the pads added to the collection have buffers queued. Evidently, this callback is not compatible with gst_collect_pads_set_buffer_function() callback. If this callback is set, the former will be unset.

MT safe.

The function takes the following parameters:

  • fn: function to set.

func (*CollectPads) SetQueryFunction

func (pads *CollectPads) SetQueryFunction(fn CollectPadsQueryFunction)

SetQueryFunction: set the query callback function and user data that will be called after collectpads has received a query originating from one of the collected pads. If the query being processed is a serialized one, this callback is called with pads STREAM_LOCK held, otherwise not. As this lock should be held when calling a number of CollectPads functions, it should be acquired if so (unusually) needed.

MT safe.

The function takes the following parameters:

  • fn: function to set.

func (*CollectPads) SetWaiting

func (pads *CollectPads) SetWaiting(data *CollectData, waiting bool)

SetWaiting sets a pad to waiting or non-waiting mode, if at least this pad has not been created with locked waiting state, in which case nothing happens.

This function should be called with pads STREAM_LOCK held, such as in the callback.

MT safe.

The function takes the following parameters:

  • data to use.
  • waiting: boolean indicating whether this pad should operate in waiting or non-waiting mode.

func (*CollectPads) SrcEventDefault

func (pads *CollectPads) SrcEventDefault(pad *gst.Pad, event *gst.Event) bool

SrcEventDefault: default CollectPads event handling for the src pad of elements. Elements can chain up to this to let flushing seek event handling be done by CollectPads.

The function takes the following parameters:

  • pad: src Pad that received the event.
  • event being processed.

The function returns the following values:

func (*CollectPads) Start

func (pads *CollectPads) Start()

Start starts the processing of data in the collect_pads.

MT safe.

func (*CollectPads) Stop

func (pads *CollectPads) Stop()

Stop stops the processing of data in the collect_pads. this function will also unblock any blocking operations.

MT safe.

func (*CollectPads) TakeBuffer

func (pads *CollectPads) TakeBuffer(data *CollectData, size uint) *gst.Buffer

TakeBuffer: get a subbuffer of size bytes from the given pad data. Flushes the amount of read bytes.

This function should be called with pads STREAM_LOCK held, such as in the callback.

MT safe.

The function takes the following parameters:

  • data to use.
  • size: number of bytes to read.

The function returns the following values:

  • buffer (optional): sub buffer. The size of the buffer can be less that requested. A return of NULL signals that the pad is end-of-stream. Unref the buffer after use.

type CollectPadsBufferFunction

type CollectPadsBufferFunction func(pads *CollectPads, data *CollectData, buffer *gst.Buffer) (flowReturn gst.FlowReturn)

CollectPadsBufferFunction: function that will be called when a (considered oldest) buffer can be muxed. If all pads have reached EOS, this function is called with NULL buffer and NULL data.

type CollectPadsClass

type CollectPadsClass struct {
	// contains filtered or unexported fields
}

CollectPadsClass: instance of this type is always passed by reference.

func (*CollectPadsClass) ParentClass

func (c *CollectPadsClass) ParentClass() *gst.ObjectClass

type CollectPadsClipFunction

type CollectPadsClipFunction func(pads *CollectPads, data *CollectData, inbuffer *gst.Buffer) (outbuffer *gst.Buffer, flowReturn gst.FlowReturn)

CollectPadsClipFunction: function that will be called when inbuffer is received on the pad managed by data in the collectpad object pads.

The function should use the segment of data and the negotiated media type on the pad to perform clipping of inbuffer.

This function takes ownership of inbuffer and should output a buffer in outbuffer or return NULL in outbuffer if the buffer should be dropped.

type CollectPadsCompareFunction

type CollectPadsCompareFunction func(pads *CollectPads, data1 *CollectData, timestamp1 gst.ClockTime, data2 *CollectData, timestamp2 gst.ClockTime) (gint int)

CollectPadsCompareFunction: function for comparing two timestamps of buffers or newsegments collected on one pad.

type CollectPadsEventFunction

type CollectPadsEventFunction func(pads *CollectPads, pad *CollectData, event *gst.Event) (ok bool)

CollectPadsEventFunction: function that will be called while processing an event. It takes ownership of the event and is responsible for chaining up (to gst_collect_pads_event_default()) or dropping events (such typical cases being handled by the default handler).

type CollectPadsFlushFunction

type CollectPadsFlushFunction func(pads *CollectPads)

CollectPadsFlushFunction: function that will be called while processing a flushing seek event.

The function should flush any internal state of the element and the state of all the pads. It should clear only the state not directly managed by the pads object. It is therefore not necessary to call gst_collect_pads_set_flushing nor gst_collect_pads_clear from this function.

type CollectPadsFunction

type CollectPadsFunction func(pads *CollectPads) (flowReturn gst.FlowReturn)

CollectPadsFunction: function that will be called when all pads have received data.

type CollectPadsOverrides

type CollectPadsOverrides struct {
}

CollectPadsOverrides contains methods that are overridable.

type CollectPadsQueryFunction

type CollectPadsQueryFunction func(pads *CollectPads, pad *CollectData, query *gst.Query) (ok bool)

CollectPadsQueryFunction: function that will be called while processing a query. It takes ownership of the query and is responsible for chaining up (to events downstream (with gst_pad_event_default()).

type CollectPadsStateFlags

type CollectPadsStateFlags C.guint
const (
	// CollectPadsStateEos: set if collectdata's pad is EOS.
	CollectPadsStateEos CollectPadsStateFlags = 0b1
	// CollectPadsStateFlushing: set if collectdata's pad is flushing.
	CollectPadsStateFlushing CollectPadsStateFlags = 0b10
	// CollectPadsStateNewSegment: set if collectdata's pad received a
	// new_segment event.
	CollectPadsStateNewSegment CollectPadsStateFlags = 0b100
	// CollectPadsStateWaiting: set if collectdata's pad must be waited for when
	// collecting.
	CollectPadsStateWaiting CollectPadsStateFlags = 0b1000
	// CollectPadsStateLocked: set collectdata's pad WAITING state must not be
	// changed. CollectPadsStateFlags indicate private state of a collectdata('s
	// pad).
	CollectPadsStateLocked CollectPadsStateFlags = 0b10000
)

func (CollectPadsStateFlags) Has

Has returns true if c contains other.

func (CollectPadsStateFlags) String

func (c CollectPadsStateFlags) String() string

String returns the names in string for CollectPadsStateFlags.

type DataQueue

type DataQueue struct {
	*coreglib.Object
	// contains filtered or unexported fields
}

DataQueue is an object that handles threadsafe queueing of objects. It also provides size-related functionality. This object should be used for any Element that wishes to provide some sort of queueing functionality.

func (*DataQueue) ConnectEmpty

func (v *DataQueue) ConnectEmpty(f func()) coreglib.SignalHandle

ConnectEmpty reports that the queue became empty (empty). A queue is empty if the total amount of visible items inside it (num-visible, time, size) is lower than the boundary values which can be set through the GObject properties.

func (*DataQueue) ConnectFull

func (v *DataQueue) ConnectFull(f func()) coreglib.SignalHandle

ConnectFull reports that the queue became full (full). A queue is full if the total amount of data inside it (num-visible, time, size) is higher than the boundary values which can be set through the GObject properties.

type DataQueueClass

type DataQueueClass struct {
	// contains filtered or unexported fields
}

DataQueueClass: instance of this type is always passed by reference.

func (*DataQueueClass) GstReserved

func (d *DataQueueClass) GstReserved() [4]unsafe.Pointer

type DataQueueOverrides

type DataQueueOverrides struct {
	Empty func()
	Full  func()
}

DataQueueOverrides contains methods that are overridable.

type FlowCombiner

type FlowCombiner struct {
	// contains filtered or unexported fields
}

FlowCombiner: utility struct to help handling FlowReturn combination. Useful for Element<!-- -->s that have multiple source pads and need to combine the different FlowReturn for those pads.

FlowCombiner works by using the last FlowReturn for all Pad it has in its list and computes the combined return value and provides it to the caller.

To add a new pad to the FlowCombiner use gst_flow_combiner_add_pad(). The new Pad is stored with a default value of GST_FLOW_OK.

In case you want a Pad to be removed, use gst_flow_combiner_remove_pad().

Please be aware that this struct isn't thread safe as its designed to be used by demuxers, those usually will have a single thread operating it.

These functions will take refs on the passed Pad<!-- -->s.

Aside from reducing the user's code size, the main advantage of using this helper struct is to follow the standard rules for FlowReturn combination. These rules are:

* GST_FLOW_EOS: only if all returns are EOS too * GST_FLOW_NOT_LINKED: only if all returns are NOT_LINKED too * GST_FLOW_ERROR or below: if at least one returns an error return * GST_FLOW_NOT_NEGOTIATED: if at least one returns a not-negotiated return * GST_FLOW_FLUSHING: if at least one returns flushing * GST_FLOW_OK: otherwise

GST_FLOW_ERROR or below, GST_FLOW_NOT_NEGOTIATED and GST_FLOW_FLUSHING are returned immediately from the gst_flow_combiner_update_flow() function.

An instance of this type is always passed by reference.

func NewFlowCombiner

func NewFlowCombiner() *FlowCombiner

NewFlowCombiner constructs a struct FlowCombiner.

func (*FlowCombiner) AddPad

func (combiner *FlowCombiner) AddPad(pad *gst.Pad)

AddPad adds a new Pad to the FlowCombiner.

The function takes the following parameters:

  • pad that is being added.

func (*FlowCombiner) Clear

func (combiner *FlowCombiner) Clear()

Clear removes all pads from a FlowCombiner and resets it to its initial state.

func (*FlowCombiner) RemovePad

func (combiner *FlowCombiner) RemovePad(pad *gst.Pad)

RemovePad removes a Pad from the FlowCombiner.

The function takes the following parameters:

  • pad to remove.

func (*FlowCombiner) Reset

func (combiner *FlowCombiner) Reset()

Reset flow combiner and all pads to their initial state without removing pads.

func (*FlowCombiner) UpdateFlow

func (combiner *FlowCombiner) UpdateFlow(fret gst.FlowReturn) gst.FlowReturn

UpdateFlow computes the combined flow return for the pads in it.

The FlowReturn parameter should be the last flow return update for a pad in this FlowCombiner. It will use this value to be able to shortcut some combinations and avoid looking over all pads again. e.g. The last combined return is the same as the latest obtained FlowReturn.

The function takes the following parameters:

  • fret: latest FlowReturn received for a pad in this FlowCombiner.

The function returns the following values:

  • flowReturn: combined FlowReturn.

func (*FlowCombiner) UpdatePadFlow

func (combiner *FlowCombiner) UpdatePadFlow(pad *gst.Pad, fret gst.FlowReturn) gst.FlowReturn

UpdatePadFlow sets the provided pad's last flow return to provided value and computes the combined flow return for the pads in it.

The FlowReturn parameter should be the last flow return update for a pad in this FlowCombiner. It will use this value to be able to shortcut some combinations and avoid looking over all pads again. e.g. The last combined return is the same as the latest obtained FlowReturn.

The function takes the following parameters:

  • pad whose FlowReturn to update.
  • fret: latest FlowReturn received for a pad in this FlowCombiner.

The function returns the following values:

  • flowReturn: combined FlowReturn.

type PushSrc

type PushSrc struct {
	BaseSrc
	// contains filtered or unexported fields
}

PushSrc: this class is mostly useful for elements that cannot do random access, or at least very slowly. The source usually prefers to push out a fixed size buffer.

Subclasses usually operate in a format that is different from the default GST_FORMAT_BYTES format of BaseSrc.

Classes extending this base class will usually be scheduled in a push based mode. If the peer accepts to operate without offsets and within the limits of the allowed block size, this class can operate in getrange based mode automatically. To make this possible, the subclass should implement and override the SCHEDULING query.

The subclass should extend the methods from the baseclass in addition to the ::create method.

Seeking, flushing, scheduling and sync is all handled by this base class.

type PushSrcClass

type PushSrcClass struct {
	// contains filtered or unexported fields
}

PushSrcClass subclasses can override any of the available virtual methods or not, as needed. At the minimum, the fill method should be overridden to produce buffers.

An instance of this type is always passed by reference.

func (*PushSrcClass) ParentClass

func (p *PushSrcClass) ParentClass() *BaseSrcClass

ParentClass: element parent class.

type PushSrcOverrides

type PushSrcOverrides struct {
	// Alloc: allocate memory for a buffer.
	//
	// The function returns the following values:
	//
	//    - buf
	//    - flowReturn
	//
	Alloc func() (*gst.Buffer, gst.FlowReturn)
	// The function takes the following parameters:
	//
	// The function returns the following values:
	//
	Fill func(buf *gst.Buffer) gst.FlowReturn
}

PushSrcOverrides contains methods that are overridable.

Jump to

Keyboard shortcuts

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