Bin

class Bin(**properties: Any)

Superclasses: Element, Object, InitiallyUnowned, Object

Subclasses: Pipeline

Implemented Interfaces: ChildProxy

Constructors:

Bin(**properties)
new(name:str=None) -> Gst.Element

Constructors

class Bin
classmethod new(name: str | None = None) Element

Creates a new bin with the given name.

Parameters:

name – the name of the new bin

Methods

class Bin
add(element: Element) bool

Adds the given element to the bin. Sets the element’s parent, and thus takes ownership of the element. An element can only be added to one bin.

If the element’s pads are linked to other pads, the pads will be unlinked before the element is added to the bin.

> When you add an element to an already-running pipeline, you will have to > take care to set the state of the newly-added element to the desired > state (usually PLAYING or PAUSED, same you set the pipeline to originally) > with set_state(), or use sync_state_with_parent(). > The bin or pipeline will not take care of this for you.

Parameters:

element – the Element to add

find_unlinked_pad(direction: PadDirection) Pad | None

Recursively looks for elements with an unlinked pad of the given direction within the specified bin and returns an unlinked pad if one is found, or None otherwise. If a pad is found, the caller owns a reference to it and should use unref() on the pad when it is not needed any longer.

Parameters:

direction – whether to look for an unlinked source or sink pad

get_by_interface(iface: type) Element | None

Looks for an element inside the bin that implements the given interface. If such an element is found, it returns the element. You can cast this element to the given interface afterwards. If you want all elements that implement the interface, use iterate_all_by_interface(). This function recurses into child bins.

Parameters:

iface – the Type of an interface

get_by_name(name: str) Element | None

Gets the element with the given name from a bin. This function recurses into child bins.

Parameters:

name – the element name to search for

get_by_name_recurse_up(name: str) Element | None

Gets the element with the given name from this bin. If the element is not found, a recursion is performed on the parent bin.

Parameters:

name – the element name to search for

get_suppressed_flags() ElementFlags

Added in version 1.10.

iterate_all_by_element_factory_name(factory_name: str) Iterator | None

Looks for all elements inside the bin with the given element factory name. The function recurses inside child bins. The iterator will yield a series of Element.

Added in version 1.18.

Parameters:

factory_name – the name of the ElementFactory

iterate_all_by_interface(iface: type) Iterator | None

Looks for all elements inside the bin that implements the given interface. You can safely cast all returned elements to the given interface. The function recurses inside child bins. The iterator will yield a series of Element.

Parameters:

iface – the Type of an interface

iterate_elements() Iterator | None

Gets an iterator for the elements in this bin.

iterate_recurse() Iterator | None

Gets an iterator for the elements in this bin. This iterator recurses into GstBin children.

iterate_sinks() Iterator | None

Gets an iterator for all elements in the bin that have the GST_ELEMENT_FLAG_SINK flag set.

iterate_sorted() Iterator | None

Gets an iterator for the elements in this bin in topologically sorted order. This means that the elements are returned from the most downstream elements (sinks) to the sources.

This function is used internally to perform the state changes of the bin elements and for clock selection.

iterate_sources() Iterator | None

Gets an iterator for all elements in the bin that have the GST_ELEMENT_FLAG_SOURCE flag set.

recalculate_latency() bool

Queries bin for the current latency and reconfigures this latency on all the elements using a LATENCY event.

This method is typically called on the pipeline when a GST_MESSAGE_LATENCY is posted on the bus.

This function simply emits the Bin::do-latency signal so any custom latency calculations will be performed.

remove(element: Element) bool

Removes the element from the bin, unparenting it as well. Unparenting the element means that the element will be dereferenced, so if the bin holds the only reference to the element, the element will be freed in the process of removing it from the bin. If you want the element to still exist after removing, you need to call ref() before removing it from the bin.

If the element’s pads are linked to other pads, the pads will be unlinked before the element is removed from the bin.

Parameters:

element – the Element to remove

set_suppressed_flags(flags: ElementFlags) None

Suppresses the given flags on the bin. ElementFlags of a child element are propagated when it is added to the bin. When suppressed flags are set, those specified flags will not be propagated to the bin.

Added in version 1.10.

Parameters:

flags – the ElementFlags to suppress

sync_children_states() bool

Synchronizes the state of every child of bin with the state of bin. See also sync_state_with_parent().

Added in version 1.6.

Properties

class Bin
props.async_handling: bool

If set to True, the bin will handle asynchronous state changes. This should be used only if the bin subclass is modifying the state of its children on its own.

props.message_forward: bool

Forward all children messages, even those that would normally be filtered by the bin. This can be interesting when one wants to be notified of the EOS state of individual elements, for example.

The messages are converted to an ELEMENT message with the bin as the source. The structure of the message is named GstBinForwarded and contains a field named message that contains the original forwarded Message.

Signals

class Bin.signals
deep_element_added(sub_bin: Bin, element: Element) None

Will be emitted after the element was added to sub_bin.

Added in version 1.10.

Parameters:
  • sub_bin – the Bin the element was added to

  • element – the Element that was added to sub_bin

deep_element_removed(sub_bin: Bin, element: Element) None

Will be emitted after the element was removed from sub_bin.

Added in version 1.10.

Parameters:
  • sub_bin – the Bin the element was removed from

  • element – the Element that was removed from sub_bin

do_latency() bool

Will be emitted when the bin needs to perform latency calculations. This signal is only emitted for toplevel bins or when Bin:async-handling is enabled.

Only one signal handler is invoked. If no signals are connected, the default handler is invoked, which will query and distribute the lowest possible latency to all sinks.

Connect to this signal if the default latency calculations are not sufficient, like when you need different latencies for different sinks in the same pipeline.

element_added(element: Element) None

Will be emitted after the element was added to the bin.

Parameters:

element – the Element that was added to the bin

element_removed(element: Element) None

Will be emitted after the element was removed from the bin.

Parameters:

element – the Element that was removed from the bin

Virtual Methods

class Bin
do_add_element(element: Element) bool

Method to add an element to the bin.

Parameters:

element – the element to be added

do_deep_element_added(sub_bin: Bin, child: Element) None

Method called when an element was added somewhere in the bin hierarchy.

Parameters:
  • sub_bin – the Bin to which the element was added

  • child – the element that was added

do_deep_element_removed(sub_bin: Bin, child: Element) None

Method called when an element was removed somewhere in the bin hierarchy.

Parameters:
  • sub_bin – the Bin from which the element was removed

  • child – the element that was removed

do_do_latency() bool
do_element_added(child: Element) None

Method called when an element was added to the bin.

Parameters:

child – the element that was added

do_element_removed(child: Element) None

Method called when an element was removed from the bin.

Parameters:

child – the element that was removed

do_handle_message(message: Message) None

Method to handle a message from the children.

Parameters:

message – the message to be handled

do_remove_element(element: Element) bool

Method to remove an element from the bin.

Parameters:

element – the element to be removed

Fields

class Bin
child_bus

Internal bus for handling child messages

children

The list of children in this bin

Updated whenever children changes

clock_dirty

The bin needs to select a new clock

clock_provider

The element that provided provided_clock

element
messages

Queued and cached messages

numchildren

The number of children in this bin

polling

The bin is currently calculating its state

priv
provided_clock

The last clock selected

state_dirty

The bin needs to recalculate its state (deprecated)