Bin is an element that can contain other Element , allowing them to be managed as a group.
Pads from the child elements can be ghosted to the bin, see GhostPad. This makes the bin look like any other elements and enables creation of higher-level abstraction elements.
An element can be retrieved from a bin with get_by_name, using the elements name. 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 iterate_elements . Various other iterators exist to retrieve the elements in a bin.
unref is used to drop your reference to the bin.
A Bin internally intercepts every Message posted by its children and implements the following default behaviour for each of them:
* 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.
* SEGMENT_START: Just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.
* SEGMENT_DONE: Is posted by Bin when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.
* 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 STREAM_START message, signaling the active start of a (new) stream.
* 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.
* 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 to the application but is forwarded to the parent of the bin.
* OTHERS: posted upwards.
A Bin implements the following default behaviour for answering to a Query:
* 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.
* POSITION: The query 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.
If all the elements return
true, the bin will also return
false is returned. If no elements
of the required type are in the bin, the event handler will return