:right-sidebar: True Bin =================================================================== .. currentmodule:: gi.repository.Gst .. class:: Bin(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gst.Element`, :class:`~gi.repository.Gst.Object`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gst.Pipeline` Implemented Interfaces: :class:`~gi.repository.Gst.ChildProxy` :Constructors: :: Bin(**properties) new(name:str=None) -> Gst.Element Constructors ------------ .. rst-class:: interim-class .. class:: Bin :no-index: .. classmethod:: new(name: str | None = None) -> ~gi.repository.Gst.Element Creates a new bin with the given name. :param name: the name of the new bin Methods ------- .. rst-class:: interim-class .. class:: Bin :no-index: .. method:: add(element: ~gi.repository.Gst.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 :func:`~gi.repository.Gst.Element.set_state`, or use :func:`~gi.repository.Gst.Element.sync_state_with_parent`. > The bin or pipeline will not take care of this for you. :param element: the :obj:`~gi.repository.Gst.Element` to add .. method:: find_unlinked_pad(direction: ~gi.repository.Gst.PadDirection) -> ~gi.repository.Gst.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 :const:`None` otherwise. If a pad is found, the caller owns a reference to it and should use :func:`~gi.repository.Gst.Object.unref` on the pad when it is not needed any longer. :param direction: whether to look for an unlinked source or sink pad .. method:: get_by_interface(iface: type) -> ~gi.repository.Gst.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 :func:`~gi.repository.Gst.Bin.iterate_all_by_interface`. This function recurses into child bins. :param iface: the :obj:`~gi.repository.GObject.Type` of an interface .. method:: get_by_name(name: str) -> ~gi.repository.Gst.Element | None Gets the element with the given name from a bin. This function recurses into child bins. :param name: the element name to search for .. method:: get_by_name_recurse_up(name: str) -> ~gi.repository.Gst.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. :param name: the element name to search for .. method:: get_suppressed_flags() -> ~gi.repository.Gst.ElementFlags .. versionadded:: 1.10 .. method:: iterate_all_by_element_factory_name(factory_name: str) -> ~gi.repository.Gst.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 :obj:`~gi.repository.Gst.Element`. .. versionadded:: 1.18 :param factory_name: the name of the :obj:`~gi.repository.Gst.ElementFactory` .. method:: iterate_all_by_interface(iface: type) -> ~gi.repository.Gst.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 :obj:`~gi.repository.Gst.Element`. :param iface: the :obj:`~gi.repository.GObject.Type` of an interface .. method:: iterate_elements() -> ~gi.repository.Gst.Iterator | None Gets an iterator for the elements in this bin. .. method:: iterate_recurse() -> ~gi.repository.Gst.Iterator | None Gets an iterator for the elements in this bin. This iterator recurses into GstBin children. .. method:: iterate_sinks() -> ~gi.repository.Gst.Iterator | None Gets an iterator for all elements in the bin that have the ``GST_ELEMENT_FLAG_SINK`` flag set. .. method:: iterate_sorted() -> ~gi.repository.Gst.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. .. method:: iterate_sources() -> ~gi.repository.Gst.Iterator | None Gets an iterator for all elements in the bin that have the ``GST_ELEMENT_FLAG_SOURCE`` flag set. .. method:: 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 :obj:`~gi.repository.Gst.Bin`::do-latency signal so any custom latency calculations will be performed. .. method:: remove(element: ~gi.repository.Gst.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 :func:`~gi.repository.Gst.Object.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. :param element: the :obj:`~gi.repository.Gst.Element` to remove .. method:: set_suppressed_flags(flags: ~gi.repository.Gst.ElementFlags) -> None Suppresses the given flags on the bin. :obj:`~gi.repository.Gst.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. .. versionadded:: 1.10 :param flags: the :obj:`~gi.repository.Gst.ElementFlags` to suppress .. method:: sync_children_states() -> bool Synchronizes the state of every child of ``bin`` with the state of ``bin``. See also :func:`~gi.repository.Gst.Element.sync_state_with_parent`. .. versionadded:: 1.6 Properties ---------- .. rst-class:: interim-class .. class:: Bin :no-index: .. attribute:: props.async_handling :type: bool If set to :const:`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. .. attribute:: props.message_forward :type: 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 :obj:`~gi.repository.Gst.Message`. Signals ------- .. rst-class:: interim-class .. class:: Bin.signals :no-index: .. method:: deep_element_added(sub_bin: ~gi.repository.Gst.Bin, element: ~gi.repository.Gst.Element) -> None Will be emitted after the element was added to ``sub_bin``. .. versionadded:: 1.10 :param sub_bin: the :obj:`~gi.repository.Gst.Bin` the element was added to :param element: the :obj:`~gi.repository.Gst.Element` that was added to ``sub_bin`` .. method:: deep_element_removed(sub_bin: ~gi.repository.Gst.Bin, element: ~gi.repository.Gst.Element) -> None Will be emitted after the element was removed from ``sub_bin``. .. versionadded:: 1.10 :param sub_bin: the :obj:`~gi.repository.Gst.Bin` the element was removed from :param element: the :obj:`~gi.repository.Gst.Element` that was removed from ``sub_bin`` .. method:: do_latency() -> bool Will be emitted when the bin needs to perform latency calculations. This signal is only emitted for toplevel bins or when :obj:`~gi.repository.Gst.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. .. method:: element_added(element: ~gi.repository.Gst.Element) -> None Will be emitted after the element was added to the bin. :param element: the :obj:`~gi.repository.Gst.Element` that was added to the bin .. method:: element_removed(element: ~gi.repository.Gst.Element) -> None Will be emitted after the element was removed from the bin. :param element: the :obj:`~gi.repository.Gst.Element` that was removed from the bin Virtual Methods --------------- .. rst-class:: interim-class .. class:: Bin :no-index: .. method:: do_add_element(element: ~gi.repository.Gst.Element) -> bool Method to add an element to the bin. :param element: the element to be added .. method:: do_deep_element_added(sub_bin: ~gi.repository.Gst.Bin, child: ~gi.repository.Gst.Element) -> None Method called when an element was added somewhere in the bin hierarchy. :param sub_bin: the :obj:`~gi.repository.Gst.Bin` to which the element was added :param child: the element that was added .. method:: do_deep_element_removed(sub_bin: ~gi.repository.Gst.Bin, child: ~gi.repository.Gst.Element) -> None Method called when an element was removed somewhere in the bin hierarchy. :param sub_bin: the :obj:`~gi.repository.Gst.Bin` from which the element was removed :param child: the element that was removed .. method:: do_do_latency() -> bool .. method:: do_element_added(child: ~gi.repository.Gst.Element) -> None Method called when an element was added to the bin. :param child: the element that was added .. method:: do_element_removed(child: ~gi.repository.Gst.Element) -> None Method called when an element was removed from the bin. :param child: the element that was removed .. method:: do_handle_message(message: ~gi.repository.Gst.Message) -> None Method to handle a message from the children. :param message: the message to be handled .. method:: do_remove_element(element: ~gi.repository.Gst.Element) -> bool Method to remove an element from the bin. :param element: the element to be removed Fields ------ .. rst-class:: interim-class .. class:: Bin :no-index: .. attribute:: child_bus Internal bus for handling child messages .. attribute:: children The list of children in this bin .. attribute:: children_cookie Updated whenever ``children`` changes .. attribute:: clock_dirty The bin needs to select a new clock .. attribute:: clock_provider The element that provided ``provided_clock`` .. attribute:: element .. attribute:: messages Queued and cached messages .. attribute:: numchildren The number of children in this bin .. attribute:: polling The bin is currently calculating its state .. attribute:: priv .. attribute:: provided_clock The last clock selected .. attribute:: state_dirty The bin needs to recalculate its state (deprecated)