GstBase.CollectPads

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GstBase.CollectPads GstBase.CollectPads Gst.Object->GstBase.CollectPads

Subclasses:

None

Methods

Inherited:

Gst.Object (27), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_pad (pad, size, destroy_notify, lock)

available ()

clip_running_time (cdata, buf, user_data)

event_default (data, event, discard)

flush (data, size)

peek (data)

pop (data)

query_default (data, query, discard)

read_buffer (data, size)

remove_pad (pad)

set_buffer_function (func, *user_data)

set_clip_function (clipfunc, *user_data)

set_compare_function (func, *user_data)

set_event_function (func, *user_data)

set_flush_function (func, *user_data)

set_flushing (flushing)

set_function (func, *user_data)

set_query_function (func, *user_data)

set_waiting (data, waiting)

src_event_default (pad, event)

start ()

stop ()

take_buffer (data, size)

Virtual Methods

Inherited:

Gst.Object (1), GObject.Object (7)

Properties

Inherited:

Gst.Object (2)

Signals

Inherited:

Gst.Object (1), GObject.Object (1)

Fields

Inherited:

Gst.Object (1), GObject.Object (1)

Name

Type

Access

Description

data

[GstBase.CollectData]

r

GLib.List of GstBase.CollectData managed by this GstBase.CollectPads.

object

Gst.Object

r

stream_lock

GLib.RecMutex

r

Class Details

class GstBase.CollectPads(**kwargs)
Bases:

Gst.Object

Abstract:

No

Structure:

GstBase.CollectPadsClass

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.

classmethod new()
Returns:

a new GstBase.CollectPads, or None in case of an error.

Return type:

GstBase.CollectPads

Create a new instance of GstBase.CollectPads.

MT safe.

add_pad(pad, size, destroy_notify, lock)
Parameters:
Returns:

a new GstBase.CollectData to identify the new pad. Or None if wrong parameters are supplied.

Return type:

GstBase.CollectData or None

Add a pad to the collection of collect pads. The pad has to be a sinkpad. The refcount of the pad is incremented. Use GstBase.CollectPads.remove_pad() to remove the pad from the collection again.

You specify a size for the returned GstBase.CollectData structure so that you can use it to store additional information.

You can also specify a GstBase.CollectDataDestroyNotify that will be called just before the GstBase.CollectData structure is freed. It is passed the pointer to the structure and should free any custom memory and resources allocated for it.

Keeping a pad locked in waiting state is only relevant when using the default collection algorithm (providing the oldest buffer). It ensures a buffer must be available on this pad for a collection to take place. This is of typical use to a muxer element where non-subtitle streams should always be in waiting state, e.g. to assure that caps information is available on all these streams when initial headers have to be written.

The pad will be automatically activated in push mode when self is started.

MT safe.

available()
Returns:

The maximum number of bytes queued on all pads. This function returns 0 if a pad has no queued buffer.

Return type:

int

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 self STREAM_LOCK held, such as in the callback.

MT safe.

clip_running_time(cdata, buf, user_data)
Parameters:
Returns:

outbuf:

output buffer with running time, or None if clipped

Return type:

(Gst.FlowReturn, outbuf: Gst.Buffer)

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 GstBase.CollectData structure. This version of the running time DTS can be negative. GObject.G_MININT64 is used to indicate invalid value.

event_default(data, event, discard)
Parameters:
  • data (GstBase.CollectData) – collect data of corresponding pad

  • event (Gst.Event) – event being processed

  • discard (bool) – process but do not send event downstream

Return type:

bool

Default GstBase.CollectPads event handling that elements should always chain up to to ensure proper operation. Element might however indicate event should not be forwarded downstream.

flush(data, size)
Parameters:
Returns:

The number of bytes flushed This can be less than size and is 0 if the pad was end-of-stream.

Return type:

int

Flush size bytes from the pad data.

This function should be called with self STREAM_LOCK held, such as in the callback.

MT safe.

peek(data)
Parameters:

data (GstBase.CollectData) – the data to use

Returns:

The buffer in data or None if no buffer is queued. should unref the buffer after usage.

Return type:

Gst.Buffer or None

Peek at the buffer currently queued in data. This function should be called with the self STREAM_LOCK held, such as in the callback handler.

MT safe.

pop(data)
Parameters:

data (GstBase.CollectData) – the data to use

Returns:

The buffer in data or None if no buffer was queued. You should unref the buffer after usage.

Return type:

Gst.Buffer or None

Pop the buffer currently queued in data. This function should be called with the self STREAM_LOCK held, such as in the callback handler.

MT safe.

query_default(data, query, discard)
Parameters:
  • data (GstBase.CollectData) – collect data of corresponding pad

  • query (Gst.Query) – query being processed

  • discard (bool) – process but do not send event downstream

Return type:

bool

Default GstBase.CollectPads query handling that elements should always chain up to to ensure proper operation. Element might however indicate query should not be forwarded downstream.

read_buffer(data, size)
Parameters:
Returns:

A sub buffer. The size of the buffer can be less that requested. A return of None signals that the pad is end-of-stream. Unref the buffer after use.

Return type:

Gst.Buffer or None

Get a subbuffer of size bytes from the given pad data.

This function should be called with self STREAM_LOCK held, such as in the callback.

MT safe.

remove_pad(pad)
Parameters:

pad (Gst.Pad) – the pad to remove

Returns:

True if the pad could be removed.

Return type:

bool

Remove a pad from the collection of collect pads. This function will also free the GstBase.CollectData and all the resources that were allocated with GstBase.CollectPads.add_pad().

The pad will be deactivated automatically when self is stopped.

MT safe.

set_buffer_function(func, *user_data)
Parameters:

Set the callback function and user data that will be called with the oldest buffer when all pads have been collected, or None on EOS. If a buffer is passed, the callback owns a reference and must unref it.

MT safe.

set_clip_function(clipfunc, *user_data)
Parameters:

Install a clipping function that is called right after a buffer is received on a pad managed by self. See GstBase.CollectPadsClipFunction for more info.

set_compare_function(func, *user_data)
Parameters:

Set the timestamp comparison function.

MT safe.

set_event_function(func, *user_data)
Parameters:

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 self 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.

set_flush_function(func, *user_data)
Parameters:

Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling. See GstBase.CollectPadsFlushFunction for more info.

New in version 1.4.

set_flushing(flushing)
Parameters:

flushing (bool) – desired state of the pads

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 self accept data again. Caller must ensure that downstream streaming (thread) is not blocked, e.g. by sending a FLUSH_START downstream.

MT safe.

set_function(func, *user_data)
Parameters:

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 GstBase.CollectPads.set_buffer_function() callback. If this callback is set, the former will be unset.

MT safe.

set_query_function(func, *user_data)
Parameters:

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 self 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.

set_waiting(data, waiting)
Parameters:
  • data (GstBase.CollectData) – the data to use

  • waiting (bool) – boolean indicating whether this pad should operate in waiting or non-waiting mode

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 self STREAM_LOCK held, such as in the callback.

MT safe.

src_event_default(pad, event)
Parameters:
Return type:

bool

Default GstBase.CollectPads event handling for the src pad of elements. Elements can chain up to this to let flushing seek event handling be done by GstBase.CollectPads.

New in version 1.4.

start()

Starts the processing of data in the collect_pads.

MT safe.

stop()

Stops the processing of data in the collect_pads. this function will also unblock any blocking operations.

MT safe.

take_buffer(data, size)
Parameters:
Returns:

A sub buffer. The size of the buffer can be less that requested. A return of None signals that the pad is end-of-stream. Unref the buffer after use.

Return type:

Gst.Buffer or None

Get a subbuffer of size bytes from the given pad data. Flushes the amount of read bytes.

This function should be called with self STREAM_LOCK held, such as in the callback.

MT safe.