Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 binNew
. 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
binAdd
. You can remove elements with binRemove
.
An element can be retrieved from a bin with binGetByName
, using the
elements name. binGetByNameRecurseUp
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
binIterateElements
. Various other iterators exist to retrieve the
elements in a bin.
objectUnref
is used to drop your reference to the bin.
The Bin::elementAdded signal is fired whenever a new element is added to the bin. Likewise the Bin::elementRemoved 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:
MessageTypeEos
: 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.MessageTypeSegmentStart
: Just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.MessageTypeSegmentDone
: Is posted byBin
when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.MessageTypeDurationChanged
: 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 MessageTypeStreamStart
message, signaling the active start
of a (new) stream.
MessageTypeClockLost
: 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.
MessageTypeClockProvide
: 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
:
QueryTypeDuration
: 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.QueryTypePosition
: 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
( EventTypeFlagsDownstream
) or source ( EventTypeFlagsUpstream
) 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
.
Synopsis
- newtype Bin = Bin (ManagedPtr Bin)
- class (GObject o, IsDescendantOf Bin o) => IsBin o
- toBin :: (MonadIO m, IsBin o) => o -> m Bin
- binAdd :: (HasCallStack, MonadIO m, IsBin a, IsElement b) => a -> b -> m Bool
- binFindUnlinkedPad :: (HasCallStack, MonadIO m, IsBin a) => a -> PadDirection -> m (Maybe Pad)
- binGetByInterface :: (HasCallStack, MonadIO m, IsBin a) => a -> GType -> m (Maybe Element)
- binGetByName :: (HasCallStack, MonadIO m, IsBin a) => a -> Text -> m (Maybe Element)
- binGetByNameRecurseUp :: (HasCallStack, MonadIO m, IsBin a) => a -> Text -> m (Maybe Element)
- binGetSuppressedFlags :: (HasCallStack, MonadIO m, IsBin a) => a -> m [ElementFlags]
- binIterateAllByElementFactoryName :: (HasCallStack, MonadIO m, IsBin a) => a -> Text -> m (Maybe Iterator)
- binIterateAllByInterface :: (HasCallStack, MonadIO m, IsBin a) => a -> GType -> m (Maybe Iterator)
- binIterateElements :: (HasCallStack, MonadIO m, IsBin a) => a -> m (Maybe Iterator)
- binIterateRecurse :: (HasCallStack, MonadIO m, IsBin a) => a -> m (Maybe Iterator)
- binIterateSinks :: (HasCallStack, MonadIO m, IsBin a) => a -> m (Maybe Iterator)
- binIterateSorted :: (HasCallStack, MonadIO m, IsBin a) => a -> m (Maybe Iterator)
- binIterateSources :: (HasCallStack, MonadIO m, IsBin a) => a -> m (Maybe Iterator)
- binNew :: (HasCallStack, MonadIO m) => Maybe Text -> m Bin
- binRecalculateLatency :: (HasCallStack, MonadIO m, IsBin a) => a -> m Bool
- binRemove :: (HasCallStack, MonadIO m, IsBin a, IsElement b) => a -> b -> m Bool
- binSetSuppressedFlags :: (HasCallStack, MonadIO m, IsBin a) => a -> [ElementFlags] -> m ()
- binSyncChildrenStates :: (HasCallStack, MonadIO m, IsBin a) => a -> m Bool
- constructBinAsyncHandling :: (IsBin o, MonadIO m) => Bool -> m (GValueConstruct o)
- getBinAsyncHandling :: (MonadIO m, IsBin o) => o -> m Bool
- setBinAsyncHandling :: (MonadIO m, IsBin o) => o -> Bool -> m ()
- constructBinMessageForward :: (IsBin o, MonadIO m) => Bool -> m (GValueConstruct o)
- getBinMessageForward :: (MonadIO m, IsBin o) => o -> m Bool
- setBinMessageForward :: (MonadIO m, IsBin o) => o -> Bool -> m ()
- type BinDeepElementAddedCallback = Bin -> Element -> IO ()
- afterBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementAddedCallback) -> m SignalHandlerId
- onBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementAddedCallback) -> m SignalHandlerId
- type BinDeepElementRemovedCallback = Bin -> Element -> IO ()
- afterBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementRemovedCallback) -> m SignalHandlerId
- onBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementRemovedCallback) -> m SignalHandlerId
- type BinDoLatencyCallback = IO Bool
- afterBinDoLatency :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDoLatencyCallback) -> m SignalHandlerId
- onBinDoLatency :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDoLatencyCallback) -> m SignalHandlerId
- type BinElementAddedCallback = Element -> IO ()
- afterBinElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementAddedCallback) -> m SignalHandlerId
- onBinElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementAddedCallback) -> m SignalHandlerId
- type BinElementRemovedCallback = Element -> IO ()
- afterBinElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementRemovedCallback) -> m SignalHandlerId
- onBinElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementRemovedCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq Bin Source # | |
GObject Bin Source # | |
Defined in GI.Gst.Objects.Bin | |
ManagedPtrNewtype Bin Source # | |
Defined in GI.Gst.Objects.Bin toManagedPtr :: Bin -> ManagedPtr Bin | |
TypedObject Bin Source # | |
Defined in GI.Gst.Objects.Bin | |
HasParentTypes Bin Source # | |
Defined in GI.Gst.Objects.Bin | |
IsGValue (Maybe Bin) Source # | Convert |
Defined in GI.Gst.Objects.Bin gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Bin -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Bin) | |
type ParentTypes Bin Source # | |
Defined in GI.Gst.Objects.Bin |
class (GObject o, IsDescendantOf Bin o) => IsBin o Source #
Instances
(GObject o, IsDescendantOf Bin o) => IsBin o Source # | |
Defined in GI.Gst.Objects.Bin |
Methods
Click to display all available methods, including inherited ones
Methods
abortState, add, addControlBinding, addPad, addPropertyDeepNotifyWatch, addPropertyNotifyWatch, bindProperty, bindPropertyFull, callAsync, changeState, childAdded, childRemoved, continueState, createAllPads, defaultError, findUnlinkedPad, forceFloating, foreachPad, foreachSinkPad, foreachSrcPad, freezeNotify, getv, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, isFloating, isLockedState, iterateAllByElementFactoryName, iterateAllByInterface, iterateElements, iteratePads, iterateRecurse, iterateSinkPads, iterateSinks, iterateSorted, iterateSources, iterateSrcPads, link, linkFiltered, linkPads, linkPadsFiltered, linkPadsFull, lookup, lostState, messageFull, messageFullWithDetails, noMorePads, notify, notifyByPspec, postMessage, provideClock, query, queryConvert, queryDuration, queryPosition, recalculateLatency, ref, refSink, releaseRequestPad, remove, removeControlBinding, removePad, removePropertyNotifyWatch, requestPad, requestPadSimple, runDispose, seek, seekSimple, sendEvent, stealData, stealQdata, suggestNextSync, syncChildrenStates, syncStateWithParent, syncValues, thawNotify, unlink, unlinkPads, unparent, unref, watchClosure.
Getters
getBaseTime, getBus, getByInterface, getByName, getByNameRecurseUp, getChildByIndex, getChildByName, getChildByNameRecurse, getChildrenCount, getClock, getCompatiblePad, getCompatiblePadTemplate, getContext, getContextUnlocked, getContexts, getControlBinding, getControlRate, getCurrentClockTime, getCurrentRunningTime, getData, getFactory, getGValueArray, getMetadata, getName, getPadTemplate, getPadTemplateList, getParent, getPathString, getProperty, getQdata, getRequestPad, getStartTime, getState, getStaticPad, getSuppressedFlags, getValue.
Setters
setBaseTime, setBus, setClock, setContext, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setData, setDataFull, setLockedState, setName, setParent, setProperty, setStartTime, setState, setSuppressedFlags.
add
:: (HasCallStack, MonadIO m, IsBin a, IsElement b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
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 'GI.Gst.Objects.Element.elementSetState', or use 'GI.Gst.Objects.Element.elementSyncStateWithParent'. The bin or pipeline will not take care of this for you.
findUnlinkedPad
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> PadDirection |
|
-> m (Maybe Pad) | Returns: unlinked pad of the given 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 Nothing
otherwise. If a pad is found, the caller
owns a reference to it and should use objectUnref
on the
pad when it is not needed any longer.
getByInterface
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> GType |
|
-> m (Maybe Element) | Returns: A |
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
binIterateAllByInterface
. This function recurses into child bins.
getByName
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> Text |
|
-> m (Maybe Element) | Returns: the |
Gets the element with the given name from a bin. This function recurses into child bins.
getByNameRecurseUp
binGetByNameRecurseUp Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> Text |
|
-> m (Maybe Element) | Returns: the |
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
binGetSuppressedFlags Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> m [ElementFlags] | Returns: the bin's suppressed |
No description available in the introspection data.
Since: 1.10
iterateAllByElementFactoryName
binIterateAllByElementFactoryName Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> Text |
|
-> m (Maybe Iterator) | Returns: a |
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
Element
.
Since: 1.18
iterateAllByInterface
binIterateAllByInterface Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> GType |
|
-> m (Maybe Iterator) | Returns: a |
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 Element
.
iterateElements
Gets an iterator for the elements in this bin.
iterateRecurse
Gets an iterator for the elements in this bin. This iterator recurses into GstBin children.
iterateSinks
Gets an iterator for all elements in the bin that have the
GST_ELEMENT_FLAG_SINK
flag set.
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.
This function is used internally to perform the state changes of the bin elements and for clock selection.
iterateSources
Gets an iterator for all elements in the bin that have the
GST_ELEMENT_FLAG_SOURCE
flag set.
new
Creates a new bin with the given name.
recalculateLatency
binRecalculateLatency Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> m Bool | Returns: |
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 Bin::doLatency signal so any custom latency calculations will be performed.
remove
:: (HasCallStack, MonadIO m, IsBin a, IsElement b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
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
objectRef
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.
setSuppressedFlags
binSetSuppressedFlags Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> [ElementFlags] |
|
-> m () |
Suppresses the given flags on the bin. 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.
Since: 1.10
syncChildrenStates
binSyncChildrenStates Source #
:: (HasCallStack, MonadIO m, IsBin a) | |
=> a |
|
-> m Bool | Returns: |
Synchronizes the state of every child of bin
with the state
of bin
. See also elementSyncStateWithParent
.
Since: 1.6
Properties
asyncHandling
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.
constructBinAsyncHandling :: (IsBin o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “async-handling
” property. This is rarely needed directly, but it is used by new
.
getBinAsyncHandling :: (MonadIO m, IsBin o) => o -> m Bool Source #
Get the value of the “async-handling
” property.
When overloading is enabled, this is equivalent to
get
bin #asyncHandling
setBinAsyncHandling :: (MonadIO m, IsBin o) => o -> Bool -> m () Source #
Set the value of the “async-handling
” property.
When overloading is enabled, this is equivalent to
set
bin [ #asyncHandling:=
value ]
messageForward
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
.
constructBinMessageForward :: (IsBin o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “message-forward
” property. This is rarely needed directly, but it is used by new
.
getBinMessageForward :: (MonadIO m, IsBin o) => o -> m Bool Source #
Get the value of the “message-forward
” property.
When overloading is enabled, this is equivalent to
get
bin #messageForward
setBinMessageForward :: (MonadIO m, IsBin o) => o -> Bool -> m () Source #
Set the value of the “message-forward
” property.
When overloading is enabled, this is equivalent to
set
bin [ #messageForward:=
value ]
Signals
deepElementAdded
type BinDeepElementAddedCallback Source #
= Bin |
|
-> Element |
|
-> IO () |
Will be emitted after the element was added to subBin
.
Since: 1.10
afterBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deepElementAdded signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
bin #deepElementAdded callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deepElementAdded signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
bin #deepElementAdded callback
deepElementRemoved
type BinDeepElementRemovedCallback Source #
= Bin |
|
-> Element |
|
-> IO () |
Will be emitted after the element was removed from subBin
.
Since: 1.10
afterBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deepElementRemoved signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
bin #deepElementRemoved callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDeepElementRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deepElementRemoved signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
bin #deepElementRemoved callback
doLatency
type BinDoLatencyCallback = IO Bool Source #
Will be emitted when the bin needs to perform latency calculations. This signal is only emitted for toplevel bins or when Bin:asyncHandling 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.
afterBinDoLatency :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDoLatencyCallback) -> m SignalHandlerId Source #
Connect a signal handler for the doLatency signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
bin #doLatency callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onBinDoLatency :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinDoLatencyCallback) -> m SignalHandlerId Source #
Connect a signal handler for the doLatency signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
bin #doLatency callback
elementAdded
type BinElementAddedCallback Source #
Will be emitted after the element was added to the bin.
afterBinElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the elementAdded signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
bin #elementAdded callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onBinElementAdded :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementAddedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the elementAdded signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
bin #elementAdded callback
elementRemoved
type BinElementRemovedCallback Source #
Will be emitted after the element was removed from the bin.
afterBinElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the elementRemoved signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
bin #elementRemoved callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onBinElementRemoved :: (IsBin a, MonadIO m) => a -> ((?self :: a) => BinElementRemovedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the elementRemoved signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
bin #elementRemoved callback