Gst.Bin¶
| Subclasses: | Gst.Pipeline | 
|---|
Methods¶
| Inherited: | Gst.Element (79), Gst.Object (27), GObject.Object (37), Gst.ChildProxy (8) | 
|---|---|
| Structs: | Gst.ElementClass (10), GObject.ObjectClass (5) | 
| class | new(name) | 
| add(element) | |
| find_unlinked_pad(direction) | |
| get_by_interface(iface) | |
| get_by_name(name) | |
| get_by_name_recurse_up(name) | |
| get_suppressed_flags() | |
| iterate_all_by_element_factory_name(factory_name) | |
| iterate_all_by_interface(iface) | |
| iterate_elements() | |
| iterate_recurse() | |
| iterate_sinks() | |
| iterate_sorted() | |
| iterate_sources() | |
| recalculate_latency() | |
| remove(element) | |
| set_suppressed_flags(flags) | |
| sync_children_states() | 
Virtual Methods¶
| Inherited: | Gst.Element (16), Gst.Object (1), GObject.Object (7), Gst.ChildProxy (5) | 
|---|
| do_add_element(element) | |
| do_deep_element_added(sub_bin, child) | |
| do_deep_element_removed(sub_bin, child) | |
| do_do_latency() | |
| do_element_added(child) | |
| do_element_removed(child) | |
| do_handle_message(message) | |
| do_remove_element(element) | 
Properties¶
| Inherited: | Gst.Object (2) | 
|---|
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| async-handling | bool | r/w | The bin will handle Asynchronous state changes | 
| message-forward | bool | r/w | Forwards all children messages | 
Signals¶
| Inherited: | Gst.Element (3), Gst.Object (1), GObject.Object (1), Gst.ChildProxy (2) | 
|---|
| Name | Short Description | 
|---|---|
| deep-element-added | Will be emitted after the element was added to sub_bin. | 
| deep-element-removed | Will be emitted after the element was removed from sub_bin. | 
| do-latency | Will be emitted when the bin needs to perform latency calculations. | 
| element-added | Will be emitted after the element was added to the bin. | 
| element-removed | Will be emitted after the element was removed from the bin. | 
Fields¶
| Inherited: | Gst.Element (3), Gst.Object (1), GObject.Object (1), Gst.ChildProxy (2) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| child_bus | Gst.Bus | r | internal bus for handling child messages | 
| children | [ Gst.Element] | r | the list of children in this bin | 
| children_cookie | int | r | updated whenever children changes | 
| clock_dirty | bool | r | the bin needs to select a new clock | 
| clock_provider | Gst.Element | r | the element that provided provided_clock | 
| element | Gst.Element | r | |
| messages | [ Gst.Message] | r | queued and cached messages | 
| numchildren | int | r | the number of children in this bin | 
| polling | bool | r | the bin is currently calculating its state | 
| provided_clock | Gst.Clock | r | the last clock selected | 
| state_dirty | bool | r | the bin needs to recalculate its state (deprecated) | 
Class Details¶
- 
class Gst.Bin(**kwargs)¶
- Bases: - Gst.Element,- Gst.ChildProxy- Abstract: - No - Structure: - Gst.BinClass- Gst.Binis an element that can contain other- Gst.Element, allowing them to be managed as a group. Pads from the child elements can be ghosted to the bin, see- Gst.GhostPad. This makes the bin look like any other elements and enables creation of higher-level abstraction elements.- A new - Gst.Binis created with- Gst.Bin.new(). Use a- Gst.Pipelineinstead if you want to create a toplevel bin because a normal bin doesn’t have a bus or handle clock distribution of its own.- After the bin has been created you will typically add elements to it with - Gst.Bin.add(). You can remove elements with- Gst.Bin.remove().- An element can be retrieved from a bin with - Gst.Bin.get_by_name(), using the elements name.- Gst.Bin.get_by_name_recurse_up() is mainly used for internal purposes and will query the parent bins when the element is not found in the current bin.- An iterator of elements in a bin can be retrieved with - Gst.Bin.iterate_elements(). Various other iterators exist to retrieve the elements in a bin.- Gst.Object.unref() is used to drop your reference to the bin.- The - Gst.Bin- ::element-addedsignal is fired whenever a new element is added to the bin. Likewise the- Gst.Bin- ::element-removedsignal is fired whenever an element is removed from the bin.- Notes
 - A - Gst.Bininternally intercepts every- Gst.Messageposted by its children and implements the following default behaviour for each of them:- Gst.MessageType.EOS: This message is only posted by sinks in the PLAYING state. If all sinks posted the EOS message, this bin will post and EOS message upwards.
- Gst.MessageType.SEGMENT_START: Just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.
- Gst.MessageType.SEGMENT_DONE: Is posted by- Gst.Binwhen all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.
- Gst.MessageType.DURATION_CHANGED: Is posted by an element that detected a change in the stream duration. The duration change is posted to the application so that it can refetch the new duration with a duration query. Note that these messages can be posted before the bin is prerolled, in which case the duration query might fail. Note also that there might be a discrepancy (due to internal buffering/queueing) between the stream being currently displayed and the returned duration query. Applications might want to also query for duration (and changes) by listening to the- Gst.MessageType.STREAM_STARTmessage, signaling the active start of a (new) stream.
- Gst.MessageType.CLOCK_LOST: This message is posted by an element when it can no longer provide a clock. The default bin behaviour is to check if the lost clock was the one provided by the bin. If so and the bin is currently in the PLAYING state, the message is forwarded to the bin parent. This message is also generated when a clock provider is removed from the bin. If this message is received by the application, it should PAUSE the pipeline and set it back to PLAYING to force a new clock distribution.
- Gst.MessageType.CLOCK_PROVIDE: This message is generated when an element can provide a clock. This mostly happens when a new clock provider is added to the bin. The default behaviour of the bin is to mark the currently selected clock as dirty, which will perform a clock recalculation the next time the bin is asked to provide a clock. This message is never sent tot the application but is forwarded to the parent of the bin.
- OTHERS: posted upwards.
 - A - Gst.Binimplements the following default behaviour for answering to a- Gst.Query:- Gst.QueryType.DURATION: The bin will forward the query to all sink elements contained within and will return the maximum value. If no sinks are available in the bin, the query fails.
- Gst.QueryType.POSITION- :Thequery is sent to all sink elements in the bin and the MAXIMUM of all values is returned. If no sinks are available in the bin, the query fails.
- OTHERS:the query is forwarded to all sink elements, the result of the first sink that answers the query successfully is returned. If no sink is in the bin, the query fails.
 - A - Gst.Binwill by default forward any event sent to it to all sink (- Gst.EventTypeFlags.DOWNSTREAM) or source (- Gst.EventTypeFlags.UPSTREAM) elements depending on the event type. If all the elements return- True, the bin will also return- True, else- Falseis returned. If no elements of the required type are in the bin, the event handler will return- True.- 
classmethod new(name)[source]¶
- Parameters: - name ( - stror- None) – the name of the new bin- Returns: - a new - Gst.Bin- Return type: - Gst.Element- Creates a new bin with the given name. 
 - 
add(element)[source]¶
- Parameters: - element ( - Gst.Element) – the- Gst.Elementto add- Returns: - Trueif the element could be added,- Falseif the bin does not want to accept the element.- Return type: - 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 - Gst.Element.set_state(), or use- Gst.Element.sync_state_with_parent(). The bin or pipeline will not take care of this for you.- MT safe. 
 - 
find_unlinked_pad(direction)[source]¶
- Parameters: - direction ( - Gst.PadDirection) – whether to look for an unlinked source or sink pad- Returns: - unlinked pad of the given direction, - None.- Return type: - Gst.Pador- 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 - Noneotherwise. If a pad is found, the caller owns a reference to it and should use- Gst.Object.unref() on the pad when it is not needed any longer.
 - 
get_by_interface(iface)[source]¶
- Parameters: - iface ( - GObject.GType) – the- GObject.GTypeof an interface- Returns: - A - Gst.Elementinside the bin implementing the interface- Return type: - Gst.Elementor- 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 - Gst.Bin.iterate_all_by_interface(). This function recurses into child bins.- MT safe. Caller owns returned reference. 
 - 
get_by_name(name)[source]¶
- Parameters: - name ( - str) – the element name to search for- Returns: - the - Gst.Elementwith the given name, or- None- Return type: - Gst.Elementor- None- Gets the element with the given name from a bin. This function recurses into child bins. - Returns - Noneif no element with the given name is found in the bin.- MT safe. Caller owns returned reference. 
 - 
get_by_name_recurse_up(name)[source]¶
- Parameters: - name ( - str) – the element name to search for- Returns: - the - Gst.Elementwith the given name, or- None- Return type: - Gst.Elementor- 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. - Returns - Noneif:- no element with the given name is found in the bin
 - MT safe. Caller owns returned reference. 
 - 
get_suppressed_flags()[source]¶
- Returns: - the bin’s suppressed - Gst.ElementFlags.- Return type: - Gst.ElementFlags- Return the suppressed flags of the bin. - MT safe. - New in version 1.10. 
 - 
iterate_all_by_element_factory_name(factory_name)[source]¶
- Parameters: - factory_name ( - str) – the name of the- Gst.ElementFactory- Returns: - a - Gst.Iteratorof- Gst.Elementfor all elements in the bin with the given element factory name, or- None.- Return type: - Gst.Iteratoror- 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 - Gst.Elementthat should be unreffed after use.- MT safe. Caller owns returned value. - New in version 1.18. 
 - 
iterate_all_by_interface(iface)[source]¶
- Parameters: - iface ( - GObject.GType) – the- GObject.GTypeof an interface- Returns: - a - Gst.Iteratorof- Gst.Elementfor all elements in the bin implementing the given interface, or- None- Return type: - Gst.Iteratoror- 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 - Gst.Elementthat should be unreffed after use.- MT safe. Caller owns returned value. 
 - 
iterate_elements()[source]¶
- Returns: - a - Gst.Iteratorof- Gst.Element, or- None- Return type: - Gst.Iteratoror- None- Gets an iterator for the elements in this bin. - MT safe. Caller owns returned value. 
 - 
iterate_recurse()[source]¶
- Returns: - a - Gst.Iteratorof- Gst.Element, or- None- Return type: - Gst.Iteratoror- None- Gets an iterator for the elements in this bin. This iterator recurses into - Gst.Binchildren.- MT safe. Caller owns returned value. 
 - 
iterate_sinks()[source]¶
- Returns: - a - Gst.Iteratorof- Gst.Element, or- None- Return type: - Gst.Iteratoror- None- Gets an iterator for all elements in the bin that have the - Gst.ElementFlags.SINKflag set.- MT safe. Caller owns returned value. 
 - 
iterate_sorted()[source]¶
- Returns: - a - Gst.Iteratorof- Gst.Element, or- None- Return type: - Gst.Iteratoror- 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. - MT safe. Caller owns returned value. 
 - 
iterate_sources()[source]¶
- Returns: - a - Gst.Iteratorof- Gst.Element, or- None- Return type: - Gst.Iteratoror- None- Gets an iterator for all elements in the bin that have the - Gst.ElementFlags.SOURCEflag set.- MT safe. Caller owns returned value. 
 - 
recalculate_latency()[source]¶
- Returns: - Trueif the latency could be queried and reconfigured.- Return type: - bool- Query self for the current latency using and reconfigures this latency to all the elements with a LATENCY event. - This method is typically called on the pipeline when a - Gst.MessageType.LATENCYis posted on the bus.- This function simply emits the ‘do-latency’ signal so any custom latency calculations will be performed. 
 - 
remove(element)[source]¶
- Parameters: - element ( - Gst.Element) – the- Gst.Elementto remove- Returns: - Trueif the element could be removed,- Falseif the bin does not want to remove the element.- Return type: - 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 - 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. - MT safe. 
 - 
set_suppressed_flags(flags)[source]¶
- Parameters: - flags ( - Gst.ElementFlags) – the- Gst.ElementFlagsto suppress- Suppress the given flags on the bin. - Gst.ElementFlagsof 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.- MT safe. - New in version 1.10. 
 - 
sync_children_states()[source]¶
- Returns: - Trueif syncing the state was successful for all children, otherwise- False.- Return type: - bool- Synchronizes the state of every child of self with the state of self. See also - Gst.Element.sync_state_with_parent().- New in version 1.6. 
 - 
do_add_element(element) virtual¶
- Parameters: - element ( - Gst.Element) –- Return type: - bool
 - 
do_deep_element_added(sub_bin, child) virtual¶
- Parameters: - sub_bin (Gst.Bin) –
- child (Gst.Element) –
 
- sub_bin (
 - 
do_deep_element_removed(sub_bin, child) virtual¶
- Parameters: - sub_bin (Gst.Bin) –
- child (Gst.Element) –
 
- sub_bin (
 - 
do_element_added(child) virtual¶
- Parameters: - child ( - Gst.Element) –
 - 
do_element_removed(child) virtual¶
- Parameters: - child ( - Gst.Element) –
 - 
do_handle_message(message) virtual¶
- Parameters: - message ( - Gst.Message) –
 - 
do_remove_element(element) virtual¶
- Parameters: - element ( - Gst.Element) –- Return type: - bool
 
Signal Details¶
- 
Gst.Bin.signals.deep_element_added(bin, sub_bin, element)¶
- Signal Name: - deep-element-added- Flags: - Parameters: - bin (Gst.Bin) – The object which received the signal
- sub_bin (Gst.Bin) – theGst.Binthe element was added to
- element (Gst.Element) – theGst.Elementthat was added to sub_bin
 - Will be emitted after the element was added to sub_bin. - New in version 1.10. 
- bin (
- 
Gst.Bin.signals.deep_element_removed(bin, sub_bin, element)¶
- Signal Name: - deep-element-removed- Flags: - Parameters: - bin (Gst.Bin) – The object which received the signal
- sub_bin (Gst.Bin) – theGst.Binthe element was removed from
- element (Gst.Element) – theGst.Elementthat was removed from sub_bin
 - Will be emitted after the element was removed from sub_bin. - New in version 1.10. 
- bin (
- 
Gst.Bin.signals.do_latency(bin)¶
- Signal Name: - do-latency- Flags: - RUN_LAST- Parameters: - bin ( - Gst.Bin) – The object which received the signal- Return type: - bool- Will be emitted when the bin needs to perform latency calculations. This signal is only emitted for toplevel bins or when 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. 
- 
Gst.Bin.signals.element_added(bin, element)¶
- Signal Name: - element-added- Flags: - Parameters: - bin (Gst.Bin) – The object which received the signal
- element (Gst.Element) – theGst.Elementthat was added to the bin
 - Will be emitted after the element was added to the bin. 
- bin (
- 
Gst.Bin.signals.element_removed(bin, element)¶
- Signal Name: - element-removed- Flags: - Parameters: - bin (Gst.Bin) – The object which received the signal
- element (Gst.Element) – theGst.Elementthat was removed from the bin
 - Will be emitted after the element was removed from the bin. 
- bin (
Property Details¶
- 
Gst.Bin.props.async_handling¶
- Name: - async-handling- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- 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.
- 
Gst.Bin.props.message_forward¶
- Name: - message-forward- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE- 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’ of type GST_TYPE_MESSAGE that contains the original forwarded message.