Bin

#GstBin is an element that can contain other #GstElement, allowing them to be managed as a group. Pads from the child elements can be ghosted to the bin, see #GstGhostPad. This makes the bin look like any other elements and enables creation of higher-level abstraction elements.

A new #GstBin is created with gst.bin.Bin.new_. Use a #GstPipeline 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 gst.bin.Bin.add. You can remove elements with gst.bin.Bin.remove.

An element can be retrieved from a bin with gst.bin.Bin.getByName, using the elements name. gst.bin.Bin.getByNameRecurseUp 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.Bin.iterateElements. Various other iterators exist to retrieve the elements in a bin.

gst.object.ObjectGst.unref is used to drop your reference to the bin.

The #GstBin::element-added signal is fired whenever a new element is added to the bin. Likewise the #GstBin::element-removed signal is fired whenever an element is removed from the bin.

A #GstBin internally intercepts every #GstMessage posted by its children and implements the following default behaviour for each of them:

state. If all sinks posted the EOS message, this bin will post and EOS message upwards.

  • gst.types.MessageType.SegmentStart: Just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.
  • gst.types.MessageType.SegmentDone: Is posted by #GstBin when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.
  • gst.types.MessageType.DurationChanged: 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.types.MessageType.StreamStart message, signaling the active start of a (new) stream.

  • gst.types.MessageType.ClockLost: 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.types.MessageType.ClockProvide: 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 #GstBin implements the following default behaviour for answering to a #GstQuery:

  • gst.types.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.types.QueryType.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 #GstBin will by default forward any event sent to it to all sink ( gst.types.EventTypeFlags.Upstream ) or source ( gst.types.EventTypeFlags.Downstream ) 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.

Constructors

this
this(string name)

Creates a new bin with the given name.

Members

Functions

add
bool add(gst.element.Element element)

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.

connectDeepElementAdded
ulong connectDeepElementAdded(T callback, Flag!"After" after)

Connect to DeepElementAdded signal.

connectDeepElementRemoved
ulong connectDeepElementRemoved(T callback, Flag!"After" after)

Connect to DeepElementRemoved signal.

connectDoLatency
ulong connectDoLatency(T callback, Flag!"After" after)

Connect to DoLatency signal.

connectElementAdded
ulong connectElementAdded(T callback, Flag!"After" after)

Connect to ElementAdded signal.

connectElementRemoved
ulong connectElementRemoved(T callback, Flag!"After" after)

Connect to ElementRemoved signal.

findUnlinkedPad
gst.pad.Pad findUnlinkedPad(gst.types.PadDirection direction)

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 null otherwise. If a pad is found, the caller owns a reference to it and should use gst.object.ObjectGst.unref on the pad when it is not needed any longer.

getByInterface
gst.element.Element getByInterface(gobject.types.GType iface)

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.Bin.iterateAllByInterface. This function recurses into child bins.

getByName
gst.element.Element getByName(string name)

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

getByNameRecurseUp
gst.element.Element getByNameRecurseUp(string name)

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

getSuppressedFlags
gst.types.ElementFlags getSuppressedFlags()
iterateAllByElementFactoryName
gst.iterator.Iterator iterateAllByElementFactoryName(string factoryName)

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

iterateAllByInterface
gst.iterator.Iterator iterateAllByInterface(gobject.types.GType iface)

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

iterateElements
gst.iterator.Iterator iterateElements()

Gets an iterator for the elements in this bin.

iterateRecurse
gst.iterator.Iterator iterateRecurse()

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

iterateSinks
gst.iterator.Iterator iterateSinks()

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

iterateSorted
gst.iterator.Iterator iterateSorted()

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.

iterateSources
gst.iterator.Iterator iterateSources()

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

recalculateLatency
bool recalculateLatency()

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

remove
bool remove(gst.element.Element element)

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.ObjectGst.ref_ before removing it from the bin.

setSuppressedFlags
void setSuppressedFlags(gst.types.ElementFlags flags)

Suppresses the given flags on the bin. #GstElementFlags 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.

syncChildrenStates
bool syncChildrenStates()

Synchronizes the state of every child of bin with the state of bin. See also gst.element.Element.syncStateWithParent.

Mixed In Members

From mixin ChildProxyT!()

childAdded
void childAdded(gobject.object.ObjectG child, string name)

Emits the #GstChildProxy::child-added signal.

childRemoved
void childRemoved(gobject.object.ObjectG child, string name)

Emits the #GstChildProxy::child-removed signal.

getChildByIndex
gobject.object.ObjectG getChildByIndex(uint index)

Fetches a child by its number.

getChildByName
gobject.object.ObjectG getChildByName(string name)

Looks up a child element by the given name.

getChildByNameRecurse
gobject.object.ObjectG getChildByNameRecurse(string name)

Looks up a child element by the given full-path name.

getChildrenCount
uint getChildrenCount()

Gets the number of child objects this parent contains.

getChildProxyProperty
void getChildProxyProperty(string name, gobject.value.Value value)

Gets a single property using the GstChildProxy mechanism. You are responsible for freeing it by calling gobject.value.Value.unset

lookup
bool lookup(string name, gobject.object.ObjectG target, gobject.param_spec.ParamSpec pspec)

Looks up which object and #GParamSpec would be effected by the given name.

setProperty
void setProperty(string name, gobject.value.Value value)

Sets a single property using the GstChildProxy mechanism.

connectChildAdded
ulong connectChildAdded(T callback, Flag!"After" after)

Connect to ChildAdded signal.

connectChildRemoved
ulong connectChildRemoved(T callback, Flag!"After" after)

Connect to ChildRemoved signal.

Inherited Members

From Element

makeFromUri
gst.element.Element makeFromUri(gst.types.URIType type, string uri, string elementname)

Creates an element for handling the given URI.

register
bool register(gst.plugin.Plugin plugin, string name, uint rank, gobject.types.GType type)

Create a new elementfactory capable of instantiating objects of the type and add the factory to plugin.

stateChangeReturnGetName
string stateChangeReturnGetName(gst.types.StateChangeReturn stateRet)

Gets a string representing the given state change result.

stateGetName
string stateGetName(gst.types.State state)

Gets a string representing the given state.

typeSetSkipDocumentation
void typeSetSkipDocumentation(gobject.types.GType type)

Marks type as "documentation should be skipped". Can be useful for dynamically registered element to be excluded from plugin documentation system.

abortState
void abortState()

Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong.

addPad
bool addPad(gst.pad.Pad pad)

Adds a pad (link point) to element. pad's parent will be set to element; see gst.object.ObjectGst.setParent for refcounting information.

addPropertyDeepNotifyWatch
gulong addPropertyDeepNotifyWatch(string propertyName, bool includeValue)
addPropertyNotifyWatch
gulong addPropertyNotifyWatch(string propertyName, bool includeValue)
callAsync
void callAsync(gst.types.ElementCallAsyncFunc func)

Calls func from another thread and passes user_data to it. This is to be used for cases when a state change has to be performed from a streaming thread, directly via gst.element.Element.setState or indirectly e.g. via SEEK events.

changeState
gst.types.StateChangeReturn changeState(gst.types.StateChange transition)

Perform transition on element.

continueState
gst.types.StateChangeReturn continueState(gst.types.StateChangeReturn ret)

Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned gst.types.StateChangeReturn.Success from the state change function.

createAllPads
void createAllPads()

Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of #GstElement.

decorateStreamId
string decorateStreamId(string streamId)

Creates a stream-id for element by combining the upstream information with the stream_id.

foreachPad
bool foreachPad(gst.types.ElementForeachPadFunc func)

Call func with user_data for each of element's pads. func will be called exactly once for each pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new pads are added or pads are removed while pads are being iterated, this will not be taken into account until next time this function is used.

foreachSinkPad
bool foreachSinkPad(gst.types.ElementForeachPadFunc func)

Call func with user_data for each of element's sink pads. func will be called exactly once for each sink pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new sink pads are added or sink pads are removed while the sink pads are being iterated, this will not be taken into account until next time this function is used.

foreachSrcPad
bool foreachSrcPad(gst.types.ElementForeachPadFunc func)

Call func with user_data for each of element's source pads. func will be called exactly once for each source pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new source pads are added or source pads are removed while the source pads are being iterated, this will not be taken into account until next time this function is used.

getBaseTime
gst.types.ClockTime getBaseTime()

Returns the base time of the element. The base time is the absolute time of the clock when this element was last put to PLAYING. Subtracting the base time from the clock time gives the running time of the element.

getBus
gst.bus.Bus getBus()

Returns the bus of the element. Note that only a #GstPipeline will provide a bus for the application.

getClock
gst.clock.Clock getClock()

Gets the currently configured clock of the element. This is the clock as was last set with gst.element.Element.setClock.

getCompatiblePad
gst.pad.Pad getCompatiblePad(gst.pad.Pad pad, gst.caps.Caps caps)

Looks for an unlinked pad to which the given pad can link. It is not guaranteed that linking the pads will work, though it should work in most cases.

getCompatiblePadTemplate
gst.pad_template.PadTemplate getCompatiblePadTemplate(gst.pad_template.PadTemplate compattempl)

Retrieves a pad template from element that is compatible with compattempl. Pads from compatible templates can be linked together.

getContext
gst.context.Context getContext(string contextType)

Gets the context with context_type set on the element or NULL.

getContextUnlocked
gst.context.Context getContextUnlocked(string contextType)

Gets the context with context_type set on the element or NULL.

getContexts
gst.context.Context[] getContexts()

Gets the contexts set on the element.

getCurrentClockTime
gst.types.ClockTime getCurrentClockTime()

Returns the current clock time of the element, as in, the time of the element's clock, or GST_CLOCK_TIME_NONE if there is no clock.

getCurrentRunningTime
gst.types.ClockTime getCurrentRunningTime()

Returns the running time of the element. The running time is the element's clock time minus its base time. Will return GST_CLOCK_TIME_NONE if the element has no clock, or if its base time has not been set.

getFactory
gst.element_factory.ElementFactory getFactory()

Retrieves the factory that was used to create this element.

getMetadata
string getMetadata(string key)

Get metadata with key in klass.

getPadTemplate
gst.pad_template.PadTemplate getPadTemplate(string name)

Retrieves a padtemplate from element with the given name.

getPadTemplateList
gst.pad_template.PadTemplate[] getPadTemplateList()

Retrieves a list of the pad templates associated with element. The list must not be modified by the calling code.

getRequestPad
gst.pad.Pad getRequestPad(string name)

The name of this function is confusing to people learning GStreamer. gst.element.Element.requestPadSimple aims at making it more explicit it is a simplified gst.element.Element.requestPad.

getStartTime
gst.types.ClockTime getStartTime()

Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED.

getState
gst.types.StateChangeReturn getState(gst.types.State state, gst.types.State pending, gst.types.ClockTime timeout)

Gets the state of the element.

getStaticPad
gst.pad.Pad getStaticPad(string name)

Retrieves a pad from element by name. This version only retrieves already-existing (i.e. 'static') pads.

isLockedState
bool isLockedState()

Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from #GST_STATE_NULL.

iteratePads
gst.iterator.Iterator iteratePads()

Retrieves an iterator of element's pads. The iterator should be freed after usage. Also more specialized iterators exists such as gst.element.Element.iterateSrcPads or gst.element.Element.iterateSinkPads.

iterateSinkPads
gst.iterator.Iterator iterateSinkPads()

Retrieves an iterator of element's sink pads.

iterateSrcPads
gst.iterator.Iterator iterateSrcPads()

Retrieves an iterator of element's source pads.

link
bool link(gst.element.Element dest)

Links src to dest. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.

linkFiltered
bool linkFiltered(gst.element.Element dest, gst.caps.Caps filter)

Links src to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.

linkPads
bool linkPads(string srcpadname, gst.element.Element dest, string destpadname)

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

linkPadsFiltered
bool linkPadsFiltered(string srcpadname, gst.element.Element dest, string destpadname, gst.caps.Caps filter)

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If caps is not null, makes sure that the caps of the link is a subset of caps.

linkPadsFull
bool linkPadsFull(string srcpadname, gst.element.Element dest, string destpadname, gst.types.PadLinkCheck flags)

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

lostState
void lostState()

Brings the element to the lost state. The current state of the element is copied to the pending state so that any call to gst.element.Element.getState will return gst.types.StateChangeReturn.Async.

messageFull
void messageFull(gst.types.MessageType type, glib.types.Quark domain, int code, string text, string debug_, string file, string function_, int line)

Post an error, warning or info message on the bus from inside an element.

messageFullWithDetails
void messageFullWithDetails(gst.types.MessageType type, glib.types.Quark domain, int code, string text, string debug_, string file, string function_, int line, gst.structure.Structure structure)

Post an error, warning or info message on the bus from inside an element.

noMorePads
void noMorePads()

Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with #GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.

postMessage
bool postMessage(gst.message.Message message)

Post a message on the element's #GstBus. This function takes ownership of the message; if you want to access the message after this call, you should add an additional reference before calling.

provideClock
gst.clock.Clock provideClock()

Get the clock provided by the given element. > An element is only required to provide a clock in the PAUSED > state. Some elements can provide a clock in other states.

query
bool query(gst.query.Query query)

Performs a query on the given element.

queryConvert
bool queryConvert(gst.types.Format srcFormat, long srcVal, gst.types.Format destFormat, long destVal)

Queries an element to convert src_val in src_format to dest_format.

queryDuration
bool queryDuration(gst.types.Format format, long duration)

Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. This query will only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

queryPosition
bool queryPosition(gst.types.Format format, long cur)

Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. This will be a value between 0 and the stream duration (if the stream duration is known). This query will usually only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

releaseRequestPad
void releaseRequestPad(gst.pad.Pad pad)

Makes the element free the previously requested pad as obtained with gst.element.Element.requestPad.

removePad
bool removePad(gst.pad.Pad pad)

Removes pad from element. pad will be destroyed if it has not been referenced elsewhere using gst.object.ObjectGst.unparent.

removePropertyNotifyWatch
void removePropertyNotifyWatch(gulong watchId)
requestPad
gst.pad.Pad requestPad(gst.pad_template.PadTemplate templ, string name, gst.caps.Caps caps)

Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using gst.element_factory.ElementFactory.getStaticPadTemplates.

requestPadSimple
gst.pad.Pad requestPadSimple(string name)

Retrieves a pad from the element by name (e.g. "src_\d"). This version only retrieves request pads. The pad should be released with gst.element.Element.releaseRequestPad.

seek
bool seek(double rate, gst.types.Format format, gst.types.SeekFlags flags, gst.types.SeekType startType, long start, gst.types.SeekType stopType, long stop)

Sends a seek event to an element. See gst.event.Event.newSeek for the details of the parameters. The seek event is sent to the element using gst.element.Element.sendEvent.

seekSimple
bool seekSimple(gst.types.Format format, gst.types.SeekFlags seekFlags, long seekPos)

Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst.element.Element.seek.

sendEvent
bool sendEvent(gst.event.Event event)

Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for downstream events or a random linked source pad for upstream events.

setBaseTime
void setBaseTime(gst.types.ClockTime time)

Set the base time of an element. See gst.element.Element.getBaseTime.

setBus
void setBus(gst.bus.Bus bus)

Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements.

setClock
bool setClock(gst.clock.Clock clock)

Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.

setContext
void setContext(gst.context.Context context)

Sets the context of the element. Increases the refcount of the context.

setLockedState
bool setLockedState(bool lockedState)

Locks the state of an element, so state changes of the parent don't affect this element anymore.

setStartTime
void setStartTime(gst.types.ClockTime time)

Set the start time of an element. The start time of the element is the running time of the element when it last went to the PAUSED state. In READY or after a flushing seek, it is set to 0.

setState
gst.types.StateChangeReturn setState(gst.types.State state)

Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each.

syncStateWithParent
bool syncStateWithParent()

Tries to change the state of the element to the same as its parent. If this function returns false, the state of element is undefined.

unlink
void unlink(gst.element.Element dest)

Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.

unlinkPads
void unlinkPads(string srcpadname, gst.element.Element dest, string destpadname)

Unlinks the two named pads of the source and destination elements.

connectNoMorePads
ulong connectNoMorePads(T callback, Flag!"After" after)

Connect to NoMorePads signal.

connectPadAdded
ulong connectPadAdded(T callback, Flag!"After" after)

Connect to PadAdded signal.

connectPadRemoved
ulong connectPadRemoved(T callback, Flag!"After" after)

Connect to PadRemoved signal.

From ChildProxy

childAdded
void childAdded(gobject.object.ObjectG child, string name)

Emits the #GstChildProxy::child-added signal.

childRemoved
void childRemoved(gobject.object.ObjectG child, string name)

Emits the #GstChildProxy::child-removed signal.

getChildByIndex
gobject.object.ObjectG getChildByIndex(uint index)

Fetches a child by its number.

getChildByName
gobject.object.ObjectG getChildByName(string name)

Looks up a child element by the given name.

getChildByNameRecurse
gobject.object.ObjectG getChildByNameRecurse(string name)

Looks up a child element by the given full-path name.

getChildrenCount
uint getChildrenCount()

Gets the number of child objects this parent contains.

getChildProxyProperty
void getChildProxyProperty(string name, gobject.value.Value value)

Gets a single property using the GstChildProxy mechanism. You are responsible for freeing it by calling gobject.value.Value.unset

lookup
bool lookup(string name, gobject.object.ObjectG target, gobject.param_spec.ParamSpec pspec)

Looks up which object and #GParamSpec would be effected by the given name.

setProperty
void setProperty(string name, gobject.value.Value value)

Sets a single property using the GstChildProxy mechanism.

connectChildAdded
ulong connectChildAdded(T callback, Flag!"After" after)

Connect to ChildAdded signal.

connectChildRemoved
ulong connectChildRemoved(T callback, Flag!"After" after)

Connect to ChildRemoved signal.