Struct gstreamer::Bin

source ·
#[repr(transparent)]
pub struct Bin { /* private fields */ }
Expand description

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.

A new Bin is created with new(). Use a Pipeline instead 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 GstBinExt::add(). You can remove elements with GstBinExt::remove().

An element can be retrieved from a bin with GstBinExt::by_name(), using the elements name. GstBinExt::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 GstBinExtManual::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 element-added signal is fired whenever a new element is added to the bin. Likewise the element-removed signal is fired whenever an element is removed from the bin.

A Bin internally intercepts every Message posted by its children and implements the following default behaviour for each of them:

  • GST_MESSAGE_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_MESSAGE_SEGMENT_START: Just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.

  • GST_MESSAGE_SEGMENT_DONE: Is posted by Bin when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.

  • GST_MESSAGE_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_MESSAGE_STREAM_START message, signaling the active start of a (new) stream.

  • GST_MESSAGE_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_MESSAGE_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:

  • GST_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.

  • GST_QUERY_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.

A Bin will by default forward any event sent to it to all sink ( EventTypeFlags::DOWNSTREAM ) or source ( EventTypeFlags::UPSTREAM ) elements depending on the event type.

If all the elements return true, the bin will also return true, else false is returned. If no elements of the required type are in the bin, the event handler will return true.

Properties

async-handling

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.

Readable | Writeable

message-forward

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.

Readable | Writeable

Object

name

Readable | Writeable | Construct

parent

The parent of the object. Please note, that when changing the ‘parent’ property, we don’t emit notify and deep-notify signals due to locking issues. In some cases one can use element-added or element-removed signals on the parent to achieve a similar effect.

Readable | Writeable

Signals

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

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.

Element

no-more-pads

This signals that the element will not generate more dynamic pads. Note that this signal will usually be emitted from the context of the streaming thread.

pad-added

a new Pad has been added to the element. Note that this signal will usually be emitted from the context of the streaming thread. Also keep in mind that if you add new elements to the pipeline in the signal handler you will need to set them to the desired target state with ElementExt::set_state() or ElementExt::sync_state_with_parent().

pad-removed

a Pad has been removed from the element

Object

deep-notify

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

Detailed

ChildProxy

child-added

Will be emitted after the object was added to the child_proxy.

child-removed

Will be emitted after the object was removed from the child_proxy.

Implements

GstBinExt, ElementExt, GstObjectExt, glib::ObjectExt, ChildProxyExt, ElementExtManual, ChildProxyExtManual

Implementations§

Creates a new bin with the given name.

name

the name of the new bin

Returns

a new Bin

Creates a new builder-pattern struct instance to construct Bin objects.

This method returns an instance of BinBuilder which can be used to create Bin objects.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Preferred value to be used as setter for the associated ParamSpec.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Override the virtual methods of this class for the given subclass and do other class initialization. Read more
Instance specific initialization. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Returns the type identifier of Self.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T. Read more
Upcasts an object to a reference of its superclass or interface T. Read more
Tries to downcast to a subclass or interface implementor T. Read more
Tries to downcast to a reference of its subclass or interface implementor T. Read more
Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Casts to T unconditionally. Read more
Casts to &T unconditionally. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures.
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Runs the dispose mechanism of the object. Read more
Ensures that the type has been registered with the type system.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Returns a SendValue clone of self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.