{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

'GI.Gst.Objects.Bin.Bin' is an element that can contain other 'GI.Gst.Objects.Element.Element', allowing them to be
managed as a group.
Pads from the child elements can be ghosted to the bin, see 'GI.Gst.Objects.GhostPad.GhostPad'.
This makes the bin look like any other elements and enables creation of
higher-level abstraction elements.

A new 'GI.Gst.Objects.Bin.Bin' is created with 'GI.Gst.Objects.Bin.binNew'. Use a 'GI.Gst.Objects.Pipeline.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
'GI.Gst.Objects.Bin.binAdd'. You can remove elements with 'GI.Gst.Objects.Bin.binRemove'.

An element can be retrieved from a bin with 'GI.Gst.Objects.Bin.binGetByName', using the
elements name. 'GI.Gst.Objects.Bin.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
'GI.Gst.Objects.Bin.binIterateElements'. Various other iterators exist to retrieve the
elements in a bin.

'GI.Gst.Objects.Object.objectUnref' is used to drop your reference to the bin.

The 'GI.Gst.Objects.Bin.Bin'::@/element-added/@ signal is fired whenever a new element is added to
the bin. Likewise the 'GI.Gst.Objects.Bin.Bin'::@/element-removed/@ signal is fired whenever an
element is removed from the bin.

== Notes

A 'GI.Gst.Objects.Bin.Bin' internally intercepts every 'GI.Gst.Structs.Message.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 'GI.Gst.Objects.Bin.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 default bin behaviour is to clear any
cached duration values so that the next duration query will perform
a full duration recalculation. 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.

* 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 tot the application but is forwarded to
the parent of the bin.

* OTHERS: posted upwards.

A 'GI.Gst.Objects.Bin.Bin' implements the following default behaviour for answering to a
'GI.Gst.Structs.Query.Query':

* GST_QUERY_DURATION:If the query has been asked before with the same format
and the bin is a toplevel bin (ie. has no parent),
use the cached previous value. If no previous value was cached, the
query is sent to all sink elements in the bin and the MAXIMUM of all
values is returned. If the bin is a toplevel bin the value is cached.
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 'GI.Gst.Objects.Bin.Bin' will by default forward any event sent to it to all sink
(@/GST_EVENT_TYPE_DOWNSTREAM/@) or source (@/GST_EVENT_TYPE_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'.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gst.Objects.Bin
    (

-- * Exported types
    Bin(..)                                 ,
    IsBin                                   ,
    toBin                                   ,
    noBin                                   ,


 -- * Methods
-- ** add #method:add#

#if ENABLE_OVERLOADING
    BinAddMethodInfo                        ,
#endif
    binAdd                                  ,


-- ** findUnlinkedPad #method:findUnlinkedPad#

#if ENABLE_OVERLOADING
    BinFindUnlinkedPadMethodInfo            ,
#endif
    binFindUnlinkedPad                      ,


-- ** getByInterface #method:getByInterface#

#if ENABLE_OVERLOADING
    BinGetByInterfaceMethodInfo             ,
#endif
    binGetByInterface                       ,


-- ** getByName #method:getByName#

#if ENABLE_OVERLOADING
    BinGetByNameMethodInfo                  ,
#endif
    binGetByName                            ,


-- ** getByNameRecurseUp #method:getByNameRecurseUp#

#if ENABLE_OVERLOADING
    BinGetByNameRecurseUpMethodInfo         ,
#endif
    binGetByNameRecurseUp                   ,


-- ** getSuppressedFlags #method:getSuppressedFlags#

#if ENABLE_OVERLOADING
    BinGetSuppressedFlagsMethodInfo         ,
#endif
    binGetSuppressedFlags                   ,


-- ** iterateAllByInterface #method:iterateAllByInterface#

#if ENABLE_OVERLOADING
    BinIterateAllByInterfaceMethodInfo      ,
#endif
    binIterateAllByInterface                ,


-- ** iterateElements #method:iterateElements#

#if ENABLE_OVERLOADING
    BinIterateElementsMethodInfo            ,
#endif
    binIterateElements                      ,


-- ** iterateRecurse #method:iterateRecurse#

#if ENABLE_OVERLOADING
    BinIterateRecurseMethodInfo             ,
#endif
    binIterateRecurse                       ,


-- ** iterateSinks #method:iterateSinks#

#if ENABLE_OVERLOADING
    BinIterateSinksMethodInfo               ,
#endif
    binIterateSinks                         ,


-- ** iterateSorted #method:iterateSorted#

#if ENABLE_OVERLOADING
    BinIterateSortedMethodInfo              ,
#endif
    binIterateSorted                        ,


-- ** iterateSources #method:iterateSources#

#if ENABLE_OVERLOADING
    BinIterateSourcesMethodInfo             ,
#endif
    binIterateSources                       ,


-- ** new #method:new#

    binNew                                  ,


-- ** recalculateLatency #method:recalculateLatency#

#if ENABLE_OVERLOADING
    BinRecalculateLatencyMethodInfo         ,
#endif
    binRecalculateLatency                   ,


-- ** remove #method:remove#

#if ENABLE_OVERLOADING
    BinRemoveMethodInfo                     ,
#endif
    binRemove                               ,


-- ** setSuppressedFlags #method:setSuppressedFlags#

#if ENABLE_OVERLOADING
    BinSetSuppressedFlagsMethodInfo         ,
#endif
    binSetSuppressedFlags                   ,


-- ** syncChildrenStates #method:syncChildrenStates#

#if ENABLE_OVERLOADING
    BinSyncChildrenStatesMethodInfo         ,
#endif
    binSyncChildrenStates                   ,




 -- * Properties
-- ** asyncHandling #attr: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.
-}
#if ENABLE_OVERLOADING
    BinAsyncHandlingPropertyInfo            ,
#endif
#if ENABLE_OVERLOADING
    binAsyncHandling                        ,
#endif
    constructBinAsyncHandling               ,
    getBinAsyncHandling                     ,
    setBinAsyncHandling                     ,


-- ** messageForward #attr: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\' of type GST_TYPE_MESSAGE that contains the original
forwarded message.
-}
#if ENABLE_OVERLOADING
    BinMessageForwardPropertyInfo           ,
#endif
#if ENABLE_OVERLOADING
    binMessageForward                       ,
#endif
    constructBinMessageForward              ,
    getBinMessageForward                    ,
    setBinMessageForward                    ,




 -- * Signals
-- ** deepElementAdded #signal:deepElementAdded#

    BinDeepElementAddedCallback             ,
#if ENABLE_OVERLOADING
    BinDeepElementAddedSignalInfo           ,
#endif
    C_BinDeepElementAddedCallback           ,
    afterBinDeepElementAdded                ,
    genClosure_BinDeepElementAdded          ,
    mk_BinDeepElementAddedCallback          ,
    noBinDeepElementAddedCallback           ,
    onBinDeepElementAdded                   ,
    wrap_BinDeepElementAddedCallback        ,


-- ** deepElementRemoved #signal:deepElementRemoved#

    BinDeepElementRemovedCallback           ,
#if ENABLE_OVERLOADING
    BinDeepElementRemovedSignalInfo         ,
#endif
    C_BinDeepElementRemovedCallback         ,
    afterBinDeepElementRemoved              ,
    genClosure_BinDeepElementRemoved        ,
    mk_BinDeepElementRemovedCallback        ,
    noBinDeepElementRemovedCallback         ,
    onBinDeepElementRemoved                 ,
    wrap_BinDeepElementRemovedCallback      ,


-- ** doLatency #signal:doLatency#

    BinDoLatencyCallback                    ,
#if ENABLE_OVERLOADING
    BinDoLatencySignalInfo                  ,
#endif
    C_BinDoLatencyCallback                  ,
    afterBinDoLatency                       ,
    genClosure_BinDoLatency                 ,
    mk_BinDoLatencyCallback                 ,
    noBinDoLatencyCallback                  ,
    onBinDoLatency                          ,
    wrap_BinDoLatencyCallback               ,


-- ** elementAdded #signal:elementAdded#

    BinElementAddedCallback                 ,
#if ENABLE_OVERLOADING
    BinElementAddedSignalInfo               ,
#endif
    C_BinElementAddedCallback               ,
    afterBinElementAdded                    ,
    genClosure_BinElementAdded              ,
    mk_BinElementAddedCallback              ,
    noBinElementAddedCallback               ,
    onBinElementAdded                       ,
    wrap_BinElementAddedCallback            ,


-- ** elementRemoved #signal:elementRemoved#

    BinElementRemovedCallback               ,
#if ENABLE_OVERLOADING
    BinElementRemovedSignalInfo             ,
#endif
    C_BinElementRemovedCallback             ,
    afterBinElementRemoved                  ,
    genClosure_BinElementRemoved            ,
    mk_BinElementRemovedCallback            ,
    noBinElementRemovedCallback             ,
    onBinElementRemoved                     ,
    wrap_BinElementRemovedCallback          ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Flags as Gst.Flags
import {-# SOURCE #-} qualified GI.Gst.Interfaces.ChildProxy as Gst.ChildProxy
import {-# SOURCE #-} qualified GI.Gst.Objects.Element as Gst.Element
import {-# SOURCE #-} qualified GI.Gst.Objects.Object as Gst.Object
import {-# SOURCE #-} qualified GI.Gst.Objects.Pad as Gst.Pad
import {-# SOURCE #-} qualified GI.Gst.Structs.Iterator as Gst.Iterator

-- | Memory-managed wrapper type.
newtype Bin = Bin (ManagedPtr Bin)
foreign import ccall "gst_bin_get_type"
    c_gst_bin_get_type :: IO GType

instance GObject Bin where
    gobjectType = c_gst_bin_get_type


-- | Type class for types which can be safely cast to `Bin`, for instance with `toBin`.
class (GObject o, O.IsDescendantOf Bin o) => IsBin o
instance (GObject o, O.IsDescendantOf Bin o) => IsBin o

instance O.HasParentTypes Bin
type instance O.ParentTypes Bin = '[Gst.Element.Element, Gst.Object.Object, GObject.Object.Object, Gst.ChildProxy.ChildProxy]

-- | Cast to `Bin`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toBin :: (MonadIO m, IsBin o) => o -> m Bin
toBin = liftIO . unsafeCastTo Bin

-- | A convenience alias for `Nothing` :: `Maybe` `Bin`.
noBin :: Maybe Bin
noBin = Nothing

#if ENABLE_OVERLOADING
type family ResolveBinMethod (t :: Symbol) (o :: *) :: * where
    ResolveBinMethod "abortState" o = Gst.Element.ElementAbortStateMethodInfo
    ResolveBinMethod "add" o = BinAddMethodInfo
    ResolveBinMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolveBinMethod "addPad" o = Gst.Element.ElementAddPadMethodInfo
    ResolveBinMethod "addPropertyDeepNotifyWatch" o = Gst.Element.ElementAddPropertyDeepNotifyWatchMethodInfo
    ResolveBinMethod "addPropertyNotifyWatch" o = Gst.Element.ElementAddPropertyNotifyWatchMethodInfo
    ResolveBinMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveBinMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveBinMethod "callAsync" o = Gst.Element.ElementCallAsyncMethodInfo
    ResolveBinMethod "changeState" o = Gst.Element.ElementChangeStateMethodInfo
    ResolveBinMethod "childAdded" o = Gst.ChildProxy.ChildProxyChildAddedMethodInfo
    ResolveBinMethod "childRemoved" o = Gst.ChildProxy.ChildProxyChildRemovedMethodInfo
    ResolveBinMethod "continueState" o = Gst.Element.ElementContinueStateMethodInfo
    ResolveBinMethod "createAllPads" o = Gst.Element.ElementCreateAllPadsMethodInfo
    ResolveBinMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolveBinMethod "findUnlinkedPad" o = BinFindUnlinkedPadMethodInfo
    ResolveBinMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveBinMethod "foreachPad" o = Gst.Element.ElementForeachPadMethodInfo
    ResolveBinMethod "foreachSinkPad" o = Gst.Element.ElementForeachSinkPadMethodInfo
    ResolveBinMethod "foreachSrcPad" o = Gst.Element.ElementForeachSrcPadMethodInfo
    ResolveBinMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveBinMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveBinMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolveBinMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolveBinMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolveBinMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolveBinMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveBinMethod "isLockedState" o = Gst.Element.ElementIsLockedStateMethodInfo
    ResolveBinMethod "iterateAllByInterface" o = BinIterateAllByInterfaceMethodInfo
    ResolveBinMethod "iterateElements" o = BinIterateElementsMethodInfo
    ResolveBinMethod "iteratePads" o = Gst.Element.ElementIteratePadsMethodInfo
    ResolveBinMethod "iterateRecurse" o = BinIterateRecurseMethodInfo
    ResolveBinMethod "iterateSinkPads" o = Gst.Element.ElementIterateSinkPadsMethodInfo
    ResolveBinMethod "iterateSinks" o = BinIterateSinksMethodInfo
    ResolveBinMethod "iterateSorted" o = BinIterateSortedMethodInfo
    ResolveBinMethod "iterateSources" o = BinIterateSourcesMethodInfo
    ResolveBinMethod "iterateSrcPads" o = Gst.Element.ElementIterateSrcPadsMethodInfo
    ResolveBinMethod "link" o = Gst.Element.ElementLinkMethodInfo
    ResolveBinMethod "linkFiltered" o = Gst.Element.ElementLinkFilteredMethodInfo
    ResolveBinMethod "linkPads" o = Gst.Element.ElementLinkPadsMethodInfo
    ResolveBinMethod "linkPadsFiltered" o = Gst.Element.ElementLinkPadsFilteredMethodInfo
    ResolveBinMethod "linkPadsFull" o = Gst.Element.ElementLinkPadsFullMethodInfo
    ResolveBinMethod "lookup" o = Gst.ChildProxy.ChildProxyLookupMethodInfo
    ResolveBinMethod "lostState" o = Gst.Element.ElementLostStateMethodInfo
    ResolveBinMethod "messageFull" o = Gst.Element.ElementMessageFullMethodInfo
    ResolveBinMethod "messageFullWithDetails" o = Gst.Element.ElementMessageFullWithDetailsMethodInfo
    ResolveBinMethod "noMorePads" o = Gst.Element.ElementNoMorePadsMethodInfo
    ResolveBinMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveBinMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveBinMethod "postMessage" o = Gst.Element.ElementPostMessageMethodInfo
    ResolveBinMethod "provideClock" o = Gst.Element.ElementProvideClockMethodInfo
    ResolveBinMethod "query" o = Gst.Element.ElementQueryMethodInfo
    ResolveBinMethod "queryConvert" o = Gst.Element.ElementQueryConvertMethodInfo
    ResolveBinMethod "queryDuration" o = Gst.Element.ElementQueryDurationMethodInfo
    ResolveBinMethod "queryPosition" o = Gst.Element.ElementQueryPositionMethodInfo
    ResolveBinMethod "recalculateLatency" o = BinRecalculateLatencyMethodInfo
    ResolveBinMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolveBinMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveBinMethod "releaseRequestPad" o = Gst.Element.ElementReleaseRequestPadMethodInfo
    ResolveBinMethod "remove" o = BinRemoveMethodInfo
    ResolveBinMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolveBinMethod "removePad" o = Gst.Element.ElementRemovePadMethodInfo
    ResolveBinMethod "removePropertyNotifyWatch" o = Gst.Element.ElementRemovePropertyNotifyWatchMethodInfo
    ResolveBinMethod "requestPad" o = Gst.Element.ElementRequestPadMethodInfo
    ResolveBinMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveBinMethod "seek" o = Gst.Element.ElementSeekMethodInfo
    ResolveBinMethod "seekSimple" o = Gst.Element.ElementSeekSimpleMethodInfo
    ResolveBinMethod "sendEvent" o = Gst.Element.ElementSendEventMethodInfo
    ResolveBinMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveBinMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveBinMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolveBinMethod "syncChildrenStates" o = BinSyncChildrenStatesMethodInfo
    ResolveBinMethod "syncStateWithParent" o = Gst.Element.ElementSyncStateWithParentMethodInfo
    ResolveBinMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolveBinMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveBinMethod "unlink" o = Gst.Element.ElementUnlinkMethodInfo
    ResolveBinMethod "unlinkPads" o = Gst.Element.ElementUnlinkPadsMethodInfo
    ResolveBinMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolveBinMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolveBinMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveBinMethod "getBaseTime" o = Gst.Element.ElementGetBaseTimeMethodInfo
    ResolveBinMethod "getBus" o = Gst.Element.ElementGetBusMethodInfo
    ResolveBinMethod "getByInterface" o = BinGetByInterfaceMethodInfo
    ResolveBinMethod "getByName" o = BinGetByNameMethodInfo
    ResolveBinMethod "getByNameRecurseUp" o = BinGetByNameRecurseUpMethodInfo
    ResolveBinMethod "getChildByIndex" o = Gst.ChildProxy.ChildProxyGetChildByIndexMethodInfo
    ResolveBinMethod "getChildByName" o = Gst.ChildProxy.ChildProxyGetChildByNameMethodInfo
    ResolveBinMethod "getChildrenCount" o = Gst.ChildProxy.ChildProxyGetChildrenCountMethodInfo
    ResolveBinMethod "getClock" o = Gst.Element.ElementGetClockMethodInfo
    ResolveBinMethod "getCompatiblePad" o = Gst.Element.ElementGetCompatiblePadMethodInfo
    ResolveBinMethod "getCompatiblePadTemplate" o = Gst.Element.ElementGetCompatiblePadTemplateMethodInfo
    ResolveBinMethod "getContext" o = Gst.Element.ElementGetContextMethodInfo
    ResolveBinMethod "getContextUnlocked" o = Gst.Element.ElementGetContextUnlockedMethodInfo
    ResolveBinMethod "getContexts" o = Gst.Element.ElementGetContextsMethodInfo
    ResolveBinMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolveBinMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolveBinMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveBinMethod "getFactory" o = Gst.Element.ElementGetFactoryMethodInfo
    ResolveBinMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolveBinMethod "getMetadata" o = Gst.Element.ElementGetMetadataMethodInfo
    ResolveBinMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolveBinMethod "getPadTemplate" o = Gst.Element.ElementGetPadTemplateMethodInfo
    ResolveBinMethod "getPadTemplateList" o = Gst.Element.ElementGetPadTemplateListMethodInfo
    ResolveBinMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolveBinMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolveBinMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveBinMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveBinMethod "getRequestPad" o = Gst.Element.ElementGetRequestPadMethodInfo
    ResolveBinMethod "getStartTime" o = Gst.Element.ElementGetStartTimeMethodInfo
    ResolveBinMethod "getState" o = Gst.Element.ElementGetStateMethodInfo
    ResolveBinMethod "getStaticPad" o = Gst.Element.ElementGetStaticPadMethodInfo
    ResolveBinMethod "getSuppressedFlags" o = BinGetSuppressedFlagsMethodInfo
    ResolveBinMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolveBinMethod "setBaseTime" o = Gst.Element.ElementSetBaseTimeMethodInfo
    ResolveBinMethod "setBus" o = Gst.Element.ElementSetBusMethodInfo
    ResolveBinMethod "setClock" o = Gst.Element.ElementSetClockMethodInfo
    ResolveBinMethod "setContext" o = Gst.Element.ElementSetContextMethodInfo
    ResolveBinMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolveBinMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolveBinMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolveBinMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveBinMethod "setLockedState" o = Gst.Element.ElementSetLockedStateMethodInfo
    ResolveBinMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolveBinMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolveBinMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveBinMethod "setStartTime" o = Gst.Element.ElementSetStartTimeMethodInfo
    ResolveBinMethod "setState" o = Gst.Element.ElementSetStateMethodInfo
    ResolveBinMethod "setSuppressedFlags" o = BinSetSuppressedFlagsMethodInfo
    ResolveBinMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveBinMethod t Bin, O.MethodInfo info Bin p) => OL.IsLabel t (Bin -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- signal Bin::deep-element-added
{- |
Will be emitted after the element was added to sub_bin.

/Since: 1.10/
-}
type BinDeepElementAddedCallback =
    Bin
    {- ^ /@subBin@/: the 'GI.Gst.Objects.Bin.Bin' the element was added to -}
    -> Gst.Element.Element
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' that was added to /@subBin@/ -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `BinDeepElementAddedCallback`@.
noBinDeepElementAddedCallback :: Maybe BinDeepElementAddedCallback
noBinDeepElementAddedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_BinDeepElementAddedCallback =
    Ptr () ->                               -- object
    Ptr Bin ->
    Ptr Gst.Element.Element ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_BinDeepElementAddedCallback`.
foreign import ccall "wrapper"
    mk_BinDeepElementAddedCallback :: C_BinDeepElementAddedCallback -> IO (FunPtr C_BinDeepElementAddedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_BinDeepElementAdded :: MonadIO m => BinDeepElementAddedCallback -> m (GClosure C_BinDeepElementAddedCallback)
genClosure_BinDeepElementAdded cb = liftIO $ do
    let cb' = wrap_BinDeepElementAddedCallback cb
    mk_BinDeepElementAddedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `BinDeepElementAddedCallback` into a `C_BinDeepElementAddedCallback`.
wrap_BinDeepElementAddedCallback ::
    BinDeepElementAddedCallback ->
    C_BinDeepElementAddedCallback
wrap_BinDeepElementAddedCallback _cb _ subBin element _ = do
    subBin' <- (newObject Bin) subBin
    element' <- (newObject Gst.Element.Element) element
    _cb  subBin' element'


{- |
Connect a signal handler for the “@deep-element-added@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' bin #deepElementAdded callback
@
-}
onBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> BinDeepElementAddedCallback -> m SignalHandlerId
onBinDeepElementAdded obj cb = liftIO $ do
    let cb' = wrap_BinDeepElementAddedCallback cb
    cb'' <- mk_BinDeepElementAddedCallback cb'
    connectSignalFunPtr obj "deep-element-added" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@deep-element-added@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' bin #deepElementAdded callback
@
-}
afterBinDeepElementAdded :: (IsBin a, MonadIO m) => a -> BinDeepElementAddedCallback -> m SignalHandlerId
afterBinDeepElementAdded obj cb = liftIO $ do
    let cb' = wrap_BinDeepElementAddedCallback cb
    cb'' <- mk_BinDeepElementAddedCallback cb'
    connectSignalFunPtr obj "deep-element-added" cb'' SignalConnectAfter


-- signal Bin::deep-element-removed
{- |
Will be emitted after the element was removed from sub_bin.

/Since: 1.10/
-}
type BinDeepElementRemovedCallback =
    Bin
    {- ^ /@subBin@/: the 'GI.Gst.Objects.Bin.Bin' the element was removed from -}
    -> Gst.Element.Element
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' that was removed from /@subBin@/ -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `BinDeepElementRemovedCallback`@.
noBinDeepElementRemovedCallback :: Maybe BinDeepElementRemovedCallback
noBinDeepElementRemovedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_BinDeepElementRemovedCallback =
    Ptr () ->                               -- object
    Ptr Bin ->
    Ptr Gst.Element.Element ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_BinDeepElementRemovedCallback`.
foreign import ccall "wrapper"
    mk_BinDeepElementRemovedCallback :: C_BinDeepElementRemovedCallback -> IO (FunPtr C_BinDeepElementRemovedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_BinDeepElementRemoved :: MonadIO m => BinDeepElementRemovedCallback -> m (GClosure C_BinDeepElementRemovedCallback)
genClosure_BinDeepElementRemoved cb = liftIO $ do
    let cb' = wrap_BinDeepElementRemovedCallback cb
    mk_BinDeepElementRemovedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `BinDeepElementRemovedCallback` into a `C_BinDeepElementRemovedCallback`.
wrap_BinDeepElementRemovedCallback ::
    BinDeepElementRemovedCallback ->
    C_BinDeepElementRemovedCallback
wrap_BinDeepElementRemovedCallback _cb _ subBin element _ = do
    subBin' <- (newObject Bin) subBin
    element' <- (newObject Gst.Element.Element) element
    _cb  subBin' element'


{- |
Connect a signal handler for the “@deep-element-removed@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' bin #deepElementRemoved callback
@
-}
onBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> BinDeepElementRemovedCallback -> m SignalHandlerId
onBinDeepElementRemoved obj cb = liftIO $ do
    let cb' = wrap_BinDeepElementRemovedCallback cb
    cb'' <- mk_BinDeepElementRemovedCallback cb'
    connectSignalFunPtr obj "deep-element-removed" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@deep-element-removed@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' bin #deepElementRemoved callback
@
-}
afterBinDeepElementRemoved :: (IsBin a, MonadIO m) => a -> BinDeepElementRemovedCallback -> m SignalHandlerId
afterBinDeepElementRemoved obj cb = liftIO $ do
    let cb' = wrap_BinDeepElementRemovedCallback cb
    cb'' <- mk_BinDeepElementRemovedCallback cb'
    connectSignalFunPtr obj "deep-element-removed" cb'' SignalConnectAfter


-- signal 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.
-}
type BinDoLatencyCallback =
    IO Bool

-- | A convenience synonym for @`Nothing` :: `Maybe` `BinDoLatencyCallback`@.
noBinDoLatencyCallback :: Maybe BinDoLatencyCallback
noBinDoLatencyCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_BinDoLatencyCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO CInt

-- | Generate a function pointer callable from C code, from a `C_BinDoLatencyCallback`.
foreign import ccall "wrapper"
    mk_BinDoLatencyCallback :: C_BinDoLatencyCallback -> IO (FunPtr C_BinDoLatencyCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_BinDoLatency :: MonadIO m => BinDoLatencyCallback -> m (GClosure C_BinDoLatencyCallback)
genClosure_BinDoLatency cb = liftIO $ do
    let cb' = wrap_BinDoLatencyCallback cb
    mk_BinDoLatencyCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `BinDoLatencyCallback` into a `C_BinDoLatencyCallback`.
wrap_BinDoLatencyCallback ::
    BinDoLatencyCallback ->
    C_BinDoLatencyCallback
wrap_BinDoLatencyCallback _cb _ _ = do
    result <- _cb
    let result' = (fromIntegral . fromEnum) result
    return result'


{- |
Connect a signal handler for the “@do-latency@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' bin #doLatency callback
@
-}
onBinDoLatency :: (IsBin a, MonadIO m) => a -> BinDoLatencyCallback -> m SignalHandlerId
onBinDoLatency obj cb = liftIO $ do
    let cb' = wrap_BinDoLatencyCallback cb
    cb'' <- mk_BinDoLatencyCallback cb'
    connectSignalFunPtr obj "do-latency" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@do-latency@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' bin #doLatency callback
@
-}
afterBinDoLatency :: (IsBin a, MonadIO m) => a -> BinDoLatencyCallback -> m SignalHandlerId
afterBinDoLatency obj cb = liftIO $ do
    let cb' = wrap_BinDoLatencyCallback cb
    cb'' <- mk_BinDoLatencyCallback cb'
    connectSignalFunPtr obj "do-latency" cb'' SignalConnectAfter


-- signal Bin::element-added
{- |
Will be emitted after the element was added to the bin.
-}
type BinElementAddedCallback =
    Gst.Element.Element
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' that was added to the bin -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `BinElementAddedCallback`@.
noBinElementAddedCallback :: Maybe BinElementAddedCallback
noBinElementAddedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_BinElementAddedCallback =
    Ptr () ->                               -- object
    Ptr Gst.Element.Element ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_BinElementAddedCallback`.
foreign import ccall "wrapper"
    mk_BinElementAddedCallback :: C_BinElementAddedCallback -> IO (FunPtr C_BinElementAddedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_BinElementAdded :: MonadIO m => BinElementAddedCallback -> m (GClosure C_BinElementAddedCallback)
genClosure_BinElementAdded cb = liftIO $ do
    let cb' = wrap_BinElementAddedCallback cb
    mk_BinElementAddedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `BinElementAddedCallback` into a `C_BinElementAddedCallback`.
wrap_BinElementAddedCallback ::
    BinElementAddedCallback ->
    C_BinElementAddedCallback
wrap_BinElementAddedCallback _cb _ element _ = do
    element' <- (newObject Gst.Element.Element) element
    _cb  element'


{- |
Connect a signal handler for the “@element-added@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' bin #elementAdded callback
@
-}
onBinElementAdded :: (IsBin a, MonadIO m) => a -> BinElementAddedCallback -> m SignalHandlerId
onBinElementAdded obj cb = liftIO $ do
    let cb' = wrap_BinElementAddedCallback cb
    cb'' <- mk_BinElementAddedCallback cb'
    connectSignalFunPtr obj "element-added" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@element-added@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' bin #elementAdded callback
@
-}
afterBinElementAdded :: (IsBin a, MonadIO m) => a -> BinElementAddedCallback -> m SignalHandlerId
afterBinElementAdded obj cb = liftIO $ do
    let cb' = wrap_BinElementAddedCallback cb
    cb'' <- mk_BinElementAddedCallback cb'
    connectSignalFunPtr obj "element-added" cb'' SignalConnectAfter


-- signal Bin::element-removed
{- |
Will be emitted after the element was removed from the bin.
-}
type BinElementRemovedCallback =
    Gst.Element.Element
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' that was removed from the bin -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `BinElementRemovedCallback`@.
noBinElementRemovedCallback :: Maybe BinElementRemovedCallback
noBinElementRemovedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_BinElementRemovedCallback =
    Ptr () ->                               -- object
    Ptr Gst.Element.Element ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_BinElementRemovedCallback`.
foreign import ccall "wrapper"
    mk_BinElementRemovedCallback :: C_BinElementRemovedCallback -> IO (FunPtr C_BinElementRemovedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_BinElementRemoved :: MonadIO m => BinElementRemovedCallback -> m (GClosure C_BinElementRemovedCallback)
genClosure_BinElementRemoved cb = liftIO $ do
    let cb' = wrap_BinElementRemovedCallback cb
    mk_BinElementRemovedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `BinElementRemovedCallback` into a `C_BinElementRemovedCallback`.
wrap_BinElementRemovedCallback ::
    BinElementRemovedCallback ->
    C_BinElementRemovedCallback
wrap_BinElementRemovedCallback _cb _ element _ = do
    element' <- (newObject Gst.Element.Element) element
    _cb  element'


{- |
Connect a signal handler for the “@element-removed@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' bin #elementRemoved callback
@
-}
onBinElementRemoved :: (IsBin a, MonadIO m) => a -> BinElementRemovedCallback -> m SignalHandlerId
onBinElementRemoved obj cb = liftIO $ do
    let cb' = wrap_BinElementRemovedCallback cb
    cb'' <- mk_BinElementRemovedCallback cb'
    connectSignalFunPtr obj "element-removed" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@element-removed@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' bin #elementRemoved callback
@
-}
afterBinElementRemoved :: (IsBin a, MonadIO m) => a -> BinElementRemovedCallback -> m SignalHandlerId
afterBinElementRemoved obj cb = liftIO $ do
    let cb' = wrap_BinElementRemovedCallback cb
    cb'' <- mk_BinElementRemovedCallback cb'
    connectSignalFunPtr obj "element-removed" cb'' SignalConnectAfter


-- VVV Prop "async-handling"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@async-handling@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' bin #asyncHandling
@
-}
getBinAsyncHandling :: (MonadIO m, IsBin o) => o -> m Bool
getBinAsyncHandling obj = liftIO $ B.Properties.getObjectPropertyBool obj "async-handling"

{- |
Set the value of the “@async-handling@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' bin [ #asyncHandling 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBinAsyncHandling :: (MonadIO m, IsBin o) => o -> Bool -> m ()
setBinAsyncHandling obj val = liftIO $ B.Properties.setObjectPropertyBool obj "async-handling" val

{- |
Construct a `GValueConstruct` with valid value for the “@async-handling@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructBinAsyncHandling :: (IsBin o) => Bool -> IO (GValueConstruct o)
constructBinAsyncHandling val = B.Properties.constructObjectPropertyBool "async-handling" val

#if ENABLE_OVERLOADING
data BinAsyncHandlingPropertyInfo
instance AttrInfo BinAsyncHandlingPropertyInfo where
    type AttrAllowedOps BinAsyncHandlingPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BinAsyncHandlingPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint BinAsyncHandlingPropertyInfo = IsBin
    type AttrGetType BinAsyncHandlingPropertyInfo = Bool
    type AttrLabel BinAsyncHandlingPropertyInfo = "async-handling"
    type AttrOrigin BinAsyncHandlingPropertyInfo = Bin
    attrGet _ = getBinAsyncHandling
    attrSet _ = setBinAsyncHandling
    attrConstruct _ = constructBinAsyncHandling
    attrClear _ = undefined
#endif

-- VVV Prop "message-forward"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@message-forward@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' bin #messageForward
@
-}
getBinMessageForward :: (MonadIO m, IsBin o) => o -> m Bool
getBinMessageForward obj = liftIO $ B.Properties.getObjectPropertyBool obj "message-forward"

{- |
Set the value of the “@message-forward@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' bin [ #messageForward 'Data.GI.Base.Attributes.:=' value ]
@
-}
setBinMessageForward :: (MonadIO m, IsBin o) => o -> Bool -> m ()
setBinMessageForward obj val = liftIO $ B.Properties.setObjectPropertyBool obj "message-forward" val

{- |
Construct a `GValueConstruct` with valid value for the “@message-forward@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructBinMessageForward :: (IsBin o) => Bool -> IO (GValueConstruct o)
constructBinMessageForward val = B.Properties.constructObjectPropertyBool "message-forward" val

#if ENABLE_OVERLOADING
data BinMessageForwardPropertyInfo
instance AttrInfo BinMessageForwardPropertyInfo where
    type AttrAllowedOps BinMessageForwardPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BinMessageForwardPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint BinMessageForwardPropertyInfo = IsBin
    type AttrGetType BinMessageForwardPropertyInfo = Bool
    type AttrLabel BinMessageForwardPropertyInfo = "message-forward"
    type AttrOrigin BinMessageForwardPropertyInfo = Bin
    attrGet _ = getBinMessageForward
    attrSet _ = setBinMessageForward
    attrConstruct _ = constructBinMessageForward
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Bin
type instance O.AttributeList Bin = BinAttributeList
type BinAttributeList = ('[ '("asyncHandling", BinAsyncHandlingPropertyInfo), '("messageForward", BinMessageForwardPropertyInfo), '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
binAsyncHandling :: AttrLabelProxy "asyncHandling"
binAsyncHandling = AttrLabelProxy

binMessageForward :: AttrLabelProxy "messageForward"
binMessageForward = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
data BinDeepElementAddedSignalInfo
instance SignalInfo BinDeepElementAddedSignalInfo where
    type HaskellCallbackType BinDeepElementAddedSignalInfo = BinDeepElementAddedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_BinDeepElementAddedCallback cb
        cb'' <- mk_BinDeepElementAddedCallback cb'
        connectSignalFunPtr obj "deep-element-added" cb'' connectMode

data BinDeepElementRemovedSignalInfo
instance SignalInfo BinDeepElementRemovedSignalInfo where
    type HaskellCallbackType BinDeepElementRemovedSignalInfo = BinDeepElementRemovedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_BinDeepElementRemovedCallback cb
        cb'' <- mk_BinDeepElementRemovedCallback cb'
        connectSignalFunPtr obj "deep-element-removed" cb'' connectMode

data BinDoLatencySignalInfo
instance SignalInfo BinDoLatencySignalInfo where
    type HaskellCallbackType BinDoLatencySignalInfo = BinDoLatencyCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_BinDoLatencyCallback cb
        cb'' <- mk_BinDoLatencyCallback cb'
        connectSignalFunPtr obj "do-latency" cb'' connectMode

data BinElementAddedSignalInfo
instance SignalInfo BinElementAddedSignalInfo where
    type HaskellCallbackType BinElementAddedSignalInfo = BinElementAddedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_BinElementAddedCallback cb
        cb'' <- mk_BinElementAddedCallback cb'
        connectSignalFunPtr obj "element-added" cb'' connectMode

data BinElementRemovedSignalInfo
instance SignalInfo BinElementRemovedSignalInfo where
    type HaskellCallbackType BinElementRemovedSignalInfo = BinElementRemovedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_BinElementRemovedCallback cb
        cb'' <- mk_BinElementRemovedCallback cb'
        connectSignalFunPtr obj "element-removed" cb'' connectMode

type instance O.SignalList Bin = BinSignalList
type BinSignalList = ('[ '("childAdded", Gst.ChildProxy.ChildProxyChildAddedSignalInfo), '("childRemoved", Gst.ChildProxy.ChildProxyChildRemovedSignalInfo), '("deepElementAdded", BinDeepElementAddedSignalInfo), '("deepElementRemoved", BinDeepElementRemovedSignalInfo), '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("doLatency", BinDoLatencySignalInfo), '("elementAdded", BinElementAddedSignalInfo), '("elementRemoved", BinElementRemovedSignalInfo), '("noMorePads", Gst.Element.ElementNoMorePadsSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("padAdded", Gst.Element.ElementPadAddedSignalInfo), '("padRemoved", Gst.Element.ElementPadRemovedSignalInfo)] :: [(Symbol, *)])

#endif

-- method Bin::new
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the new bin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Bin"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_new" gst_bin_new ::
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Bin)

{- |
Creates a new bin with the given name.
-}
binNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@name@/: the name of the new bin -}
    -> m Bin
    {- ^ __Returns:__ a new 'GI.Gst.Objects.Bin.Bin' -}
binNew name = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    result <- gst_bin_new maybeName
    checkUnexpectedReturnNULL "binNew" result
    result' <- (newObject Bin) result
    freeMem maybeName
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Bin::add
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_add" gst_bin_add ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO CInt

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

MT safe.
-}
binAdd ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a, Gst.Element.IsElement b) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> b
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' to add -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the element could be added, 'False' if
the bin does not want to accept the element. -}
binAdd bin element = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_bin_add bin' element'
    let result' = (/= 0) result
    touchManagedPtr bin
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data BinAddMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsBin a, Gst.Element.IsElement b) => O.MethodInfo BinAddMethodInfo a signature where
    overloadedMethod _ = binAdd

#endif

-- method Bin::find_unlinked_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bin in which to look for elements with unlinked pads", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "direction", argType = TInterface (Name {namespace = "Gst", name = "PadDirection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to look for an unlinked source or sink pad", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Pad"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_find_unlinked_pad" gst_bin_find_unlinked_pad ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CUInt ->                                -- direction : TInterface (Name {namespace = "Gst", name = "PadDirection"})
    IO (Ptr Gst.Pad.Pad)

{- |
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 'GI.Gst.Objects.Object.objectUnref' on the
pad when it is not needed any longer.
-}
binFindUnlinkedPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: bin in which to look for elements with unlinked pads -}
    -> Gst.Enums.PadDirection
    {- ^ /@direction@/: whether to look for an unlinked source or sink pad -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ unlinked pad of the given
direction, 'Nothing'. -}
binFindUnlinkedPad bin direction = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    let direction' = (fromIntegral . fromEnum) direction
    result <- gst_bin_find_unlinked_pad bin' direction'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinFindUnlinkedPadMethodInfo
instance (signature ~ (Gst.Enums.PadDirection -> m (Maybe Gst.Pad.Pad)), MonadIO m, IsBin a) => O.MethodInfo BinFindUnlinkedPadMethodInfo a signature where
    overloadedMethod _ = binFindUnlinkedPad

#endif

-- method Bin::get_by_interface
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iface", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GType of an interface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Element"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_get_by_interface" gst_bin_get_by_interface ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CGType ->                               -- iface : TBasicType TGType
    IO (Ptr Gst.Element.Element)

{- |
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
'GI.Gst.Objects.Bin.binIterateAllByInterface'. This function recurses into child bins.

MT safe.  Caller owns returned reference.
-}
binGetByInterface ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> GType
    {- ^ /@iface@/: the 'GType' of an interface -}
    -> m (Maybe Gst.Element.Element)
    {- ^ __Returns:__ A 'GI.Gst.Objects.Element.Element' inside the bin
implementing the interface -}
binGetByInterface bin iface = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    let iface' = gtypeToCGType iface
    result <- gst_bin_get_by_interface bin' iface'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Element.Element) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinGetByInterfaceMethodInfo
instance (signature ~ (GType -> m (Maybe Gst.Element.Element)), MonadIO m, IsBin a) => O.MethodInfo BinGetByInterfaceMethodInfo a signature where
    overloadedMethod _ = binGetByInterface

#endif

-- method Bin::get_by_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the element name to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Element"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_get_by_name" gst_bin_get_by_name ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Gst.Element.Element)

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

Returns 'Nothing' if no element with the given name is found in the bin.

MT safe.  Caller owns returned reference.
-}
binGetByName ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> T.Text
    {- ^ /@name@/: the element name to search for -}
    -> m (Maybe Gst.Element.Element)
    {- ^ __Returns:__ the 'GI.Gst.Objects.Element.Element' with the given
name, or 'Nothing' -}
binGetByName bin name = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    name' <- textToCString name
    result <- gst_bin_get_by_name bin' name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Element.Element) result'
        return result''
    touchManagedPtr bin
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
data BinGetByNameMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.Element.Element)), MonadIO m, IsBin a) => O.MethodInfo BinGetByNameMethodInfo a signature where
    overloadedMethod _ = binGetByName

#endif

-- method Bin::get_by_name_recurse_up
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the element name to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Element"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_get_by_name_recurse_up" gst_bin_get_by_name_recurse_up ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Gst.Element.Element)

{- |
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 'Nothing' if:

* no element with the given name is found in the bin


MT safe.  Caller owns returned reference.
-}
binGetByNameRecurseUp ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> T.Text
    {- ^ /@name@/: the element name to search for -}
    -> m (Maybe Gst.Element.Element)
    {- ^ __Returns:__ the 'GI.Gst.Objects.Element.Element' with the given
name, or 'Nothing' -}
binGetByNameRecurseUp bin name = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    name' <- textToCString name
    result <- gst_bin_get_by_name_recurse_up bin' name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Element.Element) result'
        return result''
    touchManagedPtr bin
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
data BinGetByNameRecurseUpMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.Element.Element)), MonadIO m, IsBin a) => O.MethodInfo BinGetByNameRecurseUpMethodInfo a signature where
    overloadedMethod _ = binGetByNameRecurseUp

#endif

-- method Bin::get_suppressed_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "ElementFlags"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_get_suppressed_flags" gst_bin_get_suppressed_flags ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO CUInt

{- |
Return the suppressed flags of the bin.

MT safe.

/Since: 1.10/
-}
binGetSuppressedFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m [Gst.Flags.ElementFlags]
    {- ^ __Returns:__ the bin\'s suppressed 'GI.Gst.Flags.ElementFlags'. -}
binGetSuppressedFlags bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_get_suppressed_flags bin'
    let result' = wordToGFlags result
    touchManagedPtr bin
    return result'

#if ENABLE_OVERLOADING
data BinGetSuppressedFlagsMethodInfo
instance (signature ~ (m [Gst.Flags.ElementFlags]), MonadIO m, IsBin a) => O.MethodInfo BinGetSuppressedFlagsMethodInfo a signature where
    overloadedMethod _ = binGetSuppressedFlags

#endif

-- method Bin::iterate_all_by_interface
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "iface", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GType of an interface", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_all_by_interface" gst_bin_iterate_all_by_interface ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CGType ->                               -- iface : TBasicType TGType
    IO (Ptr Gst.Iterator.Iterator)

{- |
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 'GI.Gst.Objects.Element.Element' that should be unreffed after use.

MT safe.  Caller owns returned value.
-}
binIterateAllByInterface ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> GType
    {- ^ /@iface@/: the 'GType' of an interface -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element'
    for all elements in the bin implementing the given interface,
    or 'Nothing' -}
binIterateAllByInterface bin iface = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    let iface' = gtypeToCGType iface
    result <- gst_bin_iterate_all_by_interface bin' iface'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateAllByInterfaceMethodInfo
instance (signature ~ (GType -> m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateAllByInterfaceMethodInfo a signature where
    overloadedMethod _ = binIterateAllByInterface

#endif

-- method Bin::iterate_elements
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_elements" gst_bin_iterate_elements ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Gets an iterator for the elements in this bin.

MT safe.  Caller owns returned value.
-}
binIterateElements ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element',
or 'Nothing' -}
binIterateElements bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_iterate_elements bin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateElementsMethodInfo
instance (signature ~ (m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateElementsMethodInfo a signature where
    overloadedMethod _ = binIterateElements

#endif

-- method Bin::iterate_recurse
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_recurse" gst_bin_iterate_recurse ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO (Ptr Gst.Iterator.Iterator)

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

MT safe.  Caller owns returned value.
-}
binIterateRecurse ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element',
or 'Nothing' -}
binIterateRecurse bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_iterate_recurse bin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateRecurseMethodInfo
instance (signature ~ (m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateRecurseMethodInfo a signature where
    overloadedMethod _ = binIterateRecurse

#endif

-- method Bin::iterate_sinks
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_sinks" gst_bin_iterate_sinks ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Gets an iterator for all elements in the bin that have the
@/GST_ELEMENT_FLAG_SINK/@ flag set.

MT safe.  Caller owns returned value.
-}
binIterateSinks ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element',
or 'Nothing' -}
binIterateSinks bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_iterate_sinks bin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateSinksMethodInfo
instance (signature ~ (m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateSinksMethodInfo a signature where
    overloadedMethod _ = binIterateSinks

#endif

-- method Bin::iterate_sorted
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_sorted" gst_bin_iterate_sorted ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
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.
-}
binIterateSorted ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element',
or 'Nothing' -}
binIterateSorted bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_iterate_sorted bin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateSortedMethodInfo
instance (signature ~ (m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateSortedMethodInfo a signature where
    overloadedMethod _ = binIterateSorted

#endif

-- method Bin::iterate_sources
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Iterator"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_iterate_sources" gst_bin_iterate_sources ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Gets an iterator for all elements in the bin that have the
@/GST_ELEMENT_FLAG_SOURCE/@ flag set.

MT safe.  Caller owns returned value.
-}
binIterateSources ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m (Maybe Gst.Iterator.Iterator)
    {- ^ __Returns:__ a 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Element.Element',
or 'Nothing' -}
binIterateSources bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_iterate_sources bin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Iterator.Iterator) result'
        return result''
    touchManagedPtr bin
    return maybeResult

#if ENABLE_OVERLOADING
data BinIterateSourcesMethodInfo
instance (signature ~ (m (Maybe Gst.Iterator.Iterator)), MonadIO m, IsBin a) => O.MethodInfo BinIterateSourcesMethodInfo a signature where
    overloadedMethod _ = binIterateSources

#endif

-- method Bin::recalculate_latency
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_recalculate_latency" gst_bin_recalculate_latency ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO CInt

{- |
Query /@bin@/ 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_MESSAGE_LATENCY/@
is posted on the bus.

This function simply emits the \'do-latency\' signal so any custom latency
calculations will be performed.
-}
binRecalculateLatency ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the latency could be queried and reconfigured. -}
binRecalculateLatency bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_recalculate_latency bin'
    let result' = (/= 0) result
    touchManagedPtr bin
    return result'

#if ENABLE_OVERLOADING
data BinRecalculateLatencyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsBin a) => O.MethodInfo BinRecalculateLatencyMethodInfo a signature where
    overloadedMethod _ = binRecalculateLatency

#endif

-- method Bin::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_remove" gst_bin_remove ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO CInt

{- |
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
'GI.Gst.Objects.Object.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.

MT safe.
-}
binRemove ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a, Gst.Element.IsElement b) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> b
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' to remove -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the element could be removed, 'False' if
the bin does not want to remove the element. -}
binRemove bin element = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_bin_remove bin' element'
    let result' = (/= 0) result
    touchManagedPtr bin
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data BinRemoveMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsBin a, Gst.Element.IsElement b) => O.MethodInfo BinRemoveMethodInfo a signature where
    overloadedMethod _ = binRemove

#endif

-- method Bin::set_suppressed_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gst", name = "ElementFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElementFlags to suppress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_set_suppressed_flags" gst_bin_set_suppressed_flags ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gst", name = "ElementFlags"})
    IO ()

{- |
Suppress the given flags on the bin. 'GI.Gst.Flags.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.

MT safe.

/Since: 1.10/
-}
binSetSuppressedFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> [Gst.Flags.ElementFlags]
    {- ^ /@flags@/: the 'GI.Gst.Flags.ElementFlags' to suppress -}
    -> m ()
binSetSuppressedFlags bin flags = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    let flags' = gflagsToWord flags
    gst_bin_set_suppressed_flags bin' flags'
    touchManagedPtr bin
    return ()

#if ENABLE_OVERLOADING
data BinSetSuppressedFlagsMethodInfo
instance (signature ~ ([Gst.Flags.ElementFlags] -> m ()), MonadIO m, IsBin a) => O.MethodInfo BinSetSuppressedFlagsMethodInfo a signature where
    overloadedMethod _ = binSetSuppressedFlags

#endif

-- method Bin::sync_children_states
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "bin", argType = TInterface (Name {namespace = "Gst", name = "Bin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_bin_sync_children_states" gst_bin_sync_children_states ::
    Ptr Bin ->                              -- bin : TInterface (Name {namespace = "Gst", name = "Bin"})
    IO CInt

{- |
Synchronizes the state of every child of /@bin@/ with the state
of /@bin@/. See also 'GI.Gst.Objects.Element.elementSyncStateWithParent'.

/Since: 1.6/
-}
binSyncChildrenStates ::
    (B.CallStack.HasCallStack, MonadIO m, IsBin a) =>
    a
    {- ^ /@bin@/: a 'GI.Gst.Objects.Bin.Bin' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if syncing the state was successful for all children,
 otherwise 'False'. -}
binSyncChildrenStates bin = liftIO $ do
    bin' <- unsafeManagedPtrCastPtr bin
    result <- gst_bin_sync_children_states bin'
    let result' = (/= 0) result
    touchManagedPtr bin
    return result'

#if ENABLE_OVERLOADING
data BinSyncChildrenStatesMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsBin a) => O.MethodInfo BinSyncChildrenStatesMethodInfo a signature where
    overloadedMethod _ = binSyncChildrenStates

#endif