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

GstElement is the abstract base class needed to construct an element that
can be used in a GStreamer pipeline. Please refer to the plugin writers
guide for more information on creating 'GI.Gst.Objects.Element.Element' subclasses.

The name of a 'GI.Gst.Objects.Element.Element' can be get with @/gst_element_get_name()/@ and set with
@/gst_element_set_name()/@.  For speed, @/GST_ELEMENT_NAME()/@ can be used in the
core when using the appropriate locking. Do not use this in plug-ins or
applications in order to retain ABI compatibility.

Elements can have pads (of the type 'GI.Gst.Objects.Pad.Pad').  These pads link to pads on
other elements.  'GI.Gst.Structs.Buffer.Buffer' flow between these linked pads.
A 'GI.Gst.Objects.Element.Element' has a 'GI.GLib.Structs.List.List' of 'GI.Gst.Objects.Pad.Pad' structures for all their input (or sink)
and output (or source) pads.
Core and plug-in writers can add and remove pads with 'GI.Gst.Objects.Element.elementAddPad'
and 'GI.Gst.Objects.Element.elementRemovePad'.

An existing pad of an element can be retrieved by name with
'GI.Gst.Objects.Element.elementGetStaticPad'. A new dynamic pad can be created using
'GI.Gst.Objects.Element.elementRequestPad' with a 'GI.Gst.Objects.PadTemplate.PadTemplate'.
An iterator of all pads can be retrieved with 'GI.Gst.Objects.Element.elementIteratePads'.

Elements can be linked through their pads.
If the link is straightforward, use the 'GI.Gst.Objects.Element.elementLink'
convenience function to link two elements, or @/gst_element_link_many()/@
for more elements in a row.
Use 'GI.Gst.Objects.Element.elementLinkFiltered' to link two elements constrained by
a specified set of 'GI.Gst.Structs.Caps.Caps'.
For finer control, use 'GI.Gst.Objects.Element.elementLinkPads' and
'GI.Gst.Objects.Element.elementLinkPadsFiltered' to specify the pads to link on
each element by name.

Each element has a state (see 'GI.Gst.Enums.State').  You can get and set the state
of an element with 'GI.Gst.Objects.Element.elementGetState' and 'GI.Gst.Objects.Element.elementSetState'.
Setting a state triggers a 'GI.Gst.Enums.StateChange'. To get a string representation
of a 'GI.Gst.Enums.State', use 'GI.Gst.Objects.Element.elementStateGetName'.

You can get and set a 'GI.Gst.Objects.Clock.Clock' on an element using 'GI.Gst.Objects.Element.elementGetClock'
and 'GI.Gst.Objects.Element.elementSetClock'.
Some elements can provide a clock for the pipeline if
the @/GST_ELEMENT_FLAG_PROVIDE_CLOCK/@ flag is set. With the
'GI.Gst.Objects.Element.elementProvideClock' method one can retrieve the clock provided by
such an element.
Not all elements require a clock to operate correctly. If the
@/GST_ELEMENT_FLAG_REQUIRE_CLOCK/@() flag is set, a clock should be set on the
element with 'GI.Gst.Objects.Element.elementSetClock'.

Note that clock selection and distribution is normally handled by the
toplevel 'GI.Gst.Objects.Pipeline.Pipeline' so the clock functions are only to be used in very
specific situations.
-}

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

module GI.Gst.Objects.Element
    (

-- * Exported types
    Element(..)                             ,
    IsElement                               ,
    toElement                               ,
    noElement                               ,


 -- * Methods
-- ** abortState #method:abortState#

#if ENABLE_OVERLOADING
    ElementAbortStateMethodInfo             ,
#endif
    elementAbortState                       ,


-- ** addPad #method:addPad#

#if ENABLE_OVERLOADING
    ElementAddPadMethodInfo                 ,
#endif
    elementAddPad                           ,


-- ** addPropertyDeepNotifyWatch #method:addPropertyDeepNotifyWatch#

#if ENABLE_OVERLOADING
    ElementAddPropertyDeepNotifyWatchMethodInfo,
#endif
    elementAddPropertyDeepNotifyWatch       ,


-- ** addPropertyNotifyWatch #method:addPropertyNotifyWatch#

#if ENABLE_OVERLOADING
    ElementAddPropertyNotifyWatchMethodInfo ,
#endif
    elementAddPropertyNotifyWatch           ,


-- ** callAsync #method:callAsync#

#if ENABLE_OVERLOADING
    ElementCallAsyncMethodInfo              ,
#endif
    elementCallAsync                        ,


-- ** changeState #method:changeState#

#if ENABLE_OVERLOADING
    ElementChangeStateMethodInfo            ,
#endif
    elementChangeState                      ,


-- ** continueState #method:continueState#

#if ENABLE_OVERLOADING
    ElementContinueStateMethodInfo          ,
#endif
    elementContinueState                    ,


-- ** createAllPads #method:createAllPads#

#if ENABLE_OVERLOADING
    ElementCreateAllPadsMethodInfo          ,
#endif
    elementCreateAllPads                    ,


-- ** foreachPad #method:foreachPad#

#if ENABLE_OVERLOADING
    ElementForeachPadMethodInfo             ,
#endif
    elementForeachPad                       ,


-- ** foreachSinkPad #method:foreachSinkPad#

#if ENABLE_OVERLOADING
    ElementForeachSinkPadMethodInfo         ,
#endif
    elementForeachSinkPad                   ,


-- ** foreachSrcPad #method:foreachSrcPad#

#if ENABLE_OVERLOADING
    ElementForeachSrcPadMethodInfo          ,
#endif
    elementForeachSrcPad                    ,


-- ** getBaseTime #method:getBaseTime#

#if ENABLE_OVERLOADING
    ElementGetBaseTimeMethodInfo            ,
#endif
    elementGetBaseTime                      ,


-- ** getBus #method:getBus#

#if ENABLE_OVERLOADING
    ElementGetBusMethodInfo                 ,
#endif
    elementGetBus                           ,


-- ** getClock #method:getClock#

#if ENABLE_OVERLOADING
    ElementGetClockMethodInfo               ,
#endif
    elementGetClock                         ,


-- ** getCompatiblePad #method:getCompatiblePad#

#if ENABLE_OVERLOADING
    ElementGetCompatiblePadMethodInfo       ,
#endif
    elementGetCompatiblePad                 ,


-- ** getCompatiblePadTemplate #method:getCompatiblePadTemplate#

#if ENABLE_OVERLOADING
    ElementGetCompatiblePadTemplateMethodInfo,
#endif
    elementGetCompatiblePadTemplate         ,


-- ** getContext #method:getContext#

#if ENABLE_OVERLOADING
    ElementGetContextMethodInfo             ,
#endif
    elementGetContext                       ,


-- ** getContextUnlocked #method:getContextUnlocked#

#if ENABLE_OVERLOADING
    ElementGetContextUnlockedMethodInfo     ,
#endif
    elementGetContextUnlocked               ,


-- ** getContexts #method:getContexts#

#if ENABLE_OVERLOADING
    ElementGetContextsMethodInfo            ,
#endif
    elementGetContexts                      ,


-- ** getFactory #method:getFactory#

#if ENABLE_OVERLOADING
    ElementGetFactoryMethodInfo             ,
#endif
    elementGetFactory                       ,


-- ** getMetadata #method:getMetadata#

#if ENABLE_OVERLOADING
    ElementGetMetadataMethodInfo            ,
#endif
    elementGetMetadata                      ,


-- ** getPadTemplate #method:getPadTemplate#

#if ENABLE_OVERLOADING
    ElementGetPadTemplateMethodInfo         ,
#endif
    elementGetPadTemplate                   ,


-- ** getPadTemplateList #method:getPadTemplateList#

#if ENABLE_OVERLOADING
    ElementGetPadTemplateListMethodInfo     ,
#endif
    elementGetPadTemplateList               ,


-- ** getRequestPad #method:getRequestPad#

#if ENABLE_OVERLOADING
    ElementGetRequestPadMethodInfo          ,
#endif
    elementGetRequestPad                    ,


-- ** getStartTime #method:getStartTime#

#if ENABLE_OVERLOADING
    ElementGetStartTimeMethodInfo           ,
#endif
    elementGetStartTime                     ,


-- ** getState #method:getState#

#if ENABLE_OVERLOADING
    ElementGetStateMethodInfo               ,
#endif
    elementGetState                         ,


-- ** getStaticPad #method:getStaticPad#

#if ENABLE_OVERLOADING
    ElementGetStaticPadMethodInfo           ,
#endif
    elementGetStaticPad                     ,


-- ** isLockedState #method:isLockedState#

#if ENABLE_OVERLOADING
    ElementIsLockedStateMethodInfo          ,
#endif
    elementIsLockedState                    ,


-- ** iteratePads #method:iteratePads#

#if ENABLE_OVERLOADING
    ElementIteratePadsMethodInfo            ,
#endif
    elementIteratePads                      ,


-- ** iterateSinkPads #method:iterateSinkPads#

#if ENABLE_OVERLOADING
    ElementIterateSinkPadsMethodInfo        ,
#endif
    elementIterateSinkPads                  ,


-- ** iterateSrcPads #method:iterateSrcPads#

#if ENABLE_OVERLOADING
    ElementIterateSrcPadsMethodInfo         ,
#endif
    elementIterateSrcPads                   ,


-- ** link #method:link#

#if ENABLE_OVERLOADING
    ElementLinkMethodInfo                   ,
#endif
    elementLink                             ,


-- ** linkFiltered #method:linkFiltered#

#if ENABLE_OVERLOADING
    ElementLinkFilteredMethodInfo           ,
#endif
    elementLinkFiltered                     ,


-- ** linkPads #method:linkPads#

#if ENABLE_OVERLOADING
    ElementLinkPadsMethodInfo               ,
#endif
    elementLinkPads                         ,


-- ** linkPadsFiltered #method:linkPadsFiltered#

#if ENABLE_OVERLOADING
    ElementLinkPadsFilteredMethodInfo       ,
#endif
    elementLinkPadsFiltered                 ,


-- ** linkPadsFull #method:linkPadsFull#

#if ENABLE_OVERLOADING
    ElementLinkPadsFullMethodInfo           ,
#endif
    elementLinkPadsFull                     ,


-- ** lostState #method:lostState#

#if ENABLE_OVERLOADING
    ElementLostStateMethodInfo              ,
#endif
    elementLostState                        ,


-- ** makeFromUri #method:makeFromUri#

    elementMakeFromUri                      ,


-- ** messageFull #method:messageFull#

#if ENABLE_OVERLOADING
    ElementMessageFullMethodInfo            ,
#endif
    elementMessageFull                      ,


-- ** messageFullWithDetails #method:messageFullWithDetails#

#if ENABLE_OVERLOADING
    ElementMessageFullWithDetailsMethodInfo ,
#endif
    elementMessageFullWithDetails           ,


-- ** noMorePads #method:noMorePads#

#if ENABLE_OVERLOADING
    ElementNoMorePadsMethodInfo             ,
#endif
    elementNoMorePads                       ,


-- ** postMessage #method:postMessage#

#if ENABLE_OVERLOADING
    ElementPostMessageMethodInfo            ,
#endif
    elementPostMessage                      ,


-- ** provideClock #method:provideClock#

#if ENABLE_OVERLOADING
    ElementProvideClockMethodInfo           ,
#endif
    elementProvideClock                     ,


-- ** query #method:query#

#if ENABLE_OVERLOADING
    ElementQueryMethodInfo                  ,
#endif
    elementQuery                            ,


-- ** queryConvert #method:queryConvert#

#if ENABLE_OVERLOADING
    ElementQueryConvertMethodInfo           ,
#endif
    elementQueryConvert                     ,


-- ** queryDuration #method:queryDuration#

#if ENABLE_OVERLOADING
    ElementQueryDurationMethodInfo          ,
#endif
    elementQueryDuration                    ,


-- ** queryPosition #method:queryPosition#

#if ENABLE_OVERLOADING
    ElementQueryPositionMethodInfo          ,
#endif
    elementQueryPosition                    ,


-- ** register #method:register#

    elementRegister                         ,


-- ** releaseRequestPad #method:releaseRequestPad#

#if ENABLE_OVERLOADING
    ElementReleaseRequestPadMethodInfo      ,
#endif
    elementReleaseRequestPad                ,


-- ** removePad #method:removePad#

#if ENABLE_OVERLOADING
    ElementRemovePadMethodInfo              ,
#endif
    elementRemovePad                        ,


-- ** removePropertyNotifyWatch #method:removePropertyNotifyWatch#

#if ENABLE_OVERLOADING
    ElementRemovePropertyNotifyWatchMethodInfo,
#endif
    elementRemovePropertyNotifyWatch        ,


-- ** requestPad #method:requestPad#

#if ENABLE_OVERLOADING
    ElementRequestPadMethodInfo             ,
#endif
    elementRequestPad                       ,


-- ** seek #method:seek#

#if ENABLE_OVERLOADING
    ElementSeekMethodInfo                   ,
#endif
    elementSeek                             ,


-- ** seekSimple #method:seekSimple#

#if ENABLE_OVERLOADING
    ElementSeekSimpleMethodInfo             ,
#endif
    elementSeekSimple                       ,


-- ** sendEvent #method:sendEvent#

#if ENABLE_OVERLOADING
    ElementSendEventMethodInfo              ,
#endif
    elementSendEvent                        ,


-- ** setBaseTime #method:setBaseTime#

#if ENABLE_OVERLOADING
    ElementSetBaseTimeMethodInfo            ,
#endif
    elementSetBaseTime                      ,


-- ** setBus #method:setBus#

#if ENABLE_OVERLOADING
    ElementSetBusMethodInfo                 ,
#endif
    elementSetBus                           ,


-- ** setClock #method:setClock#

#if ENABLE_OVERLOADING
    ElementSetClockMethodInfo               ,
#endif
    elementSetClock                         ,


-- ** setContext #method:setContext#

#if ENABLE_OVERLOADING
    ElementSetContextMethodInfo             ,
#endif
    elementSetContext                       ,


-- ** setLockedState #method:setLockedState#

#if ENABLE_OVERLOADING
    ElementSetLockedStateMethodInfo         ,
#endif
    elementSetLockedState                   ,


-- ** setStartTime #method:setStartTime#

#if ENABLE_OVERLOADING
    ElementSetStartTimeMethodInfo           ,
#endif
    elementSetStartTime                     ,


-- ** setState #method:setState#

#if ENABLE_OVERLOADING
    ElementSetStateMethodInfo               ,
#endif
    elementSetState                         ,


-- ** stateChangeReturnGetName #method:stateChangeReturnGetName#

    elementStateChangeReturnGetName         ,


-- ** stateGetName #method:stateGetName#

    elementStateGetName                     ,


-- ** syncStateWithParent #method:syncStateWithParent#

#if ENABLE_OVERLOADING
    ElementSyncStateWithParentMethodInfo    ,
#endif
    elementSyncStateWithParent              ,


-- ** unlink #method:unlink#

#if ENABLE_OVERLOADING
    ElementUnlinkMethodInfo                 ,
#endif
    elementUnlink                           ,


-- ** unlinkPads #method:unlinkPads#

#if ENABLE_OVERLOADING
    ElementUnlinkPadsMethodInfo             ,
#endif
    elementUnlinkPads                       ,




 -- * Signals
-- ** noMorePads #signal:noMorePads#

    C_ElementNoMorePadsCallback             ,
    ElementNoMorePadsCallback               ,
#if ENABLE_OVERLOADING
    ElementNoMorePadsSignalInfo             ,
#endif
    afterElementNoMorePads                  ,
    genClosure_ElementNoMorePads            ,
    mk_ElementNoMorePadsCallback            ,
    noElementNoMorePadsCallback             ,
    onElementNoMorePads                     ,
    wrap_ElementNoMorePadsCallback          ,


-- ** padAdded #signal:padAdded#

    C_ElementPadAddedCallback               ,
    ElementPadAddedCallback                 ,
#if ENABLE_OVERLOADING
    ElementPadAddedSignalInfo               ,
#endif
    afterElementPadAdded                    ,
    genClosure_ElementPadAdded              ,
    mk_ElementPadAddedCallback              ,
    noElementPadAddedCallback               ,
    onElementPadAdded                       ,
    wrap_ElementPadAddedCallback            ,


-- ** padRemoved #signal:padRemoved#

    C_ElementPadRemovedCallback             ,
    ElementPadRemovedCallback               ,
#if ENABLE_OVERLOADING
    ElementPadRemovedSignalInfo             ,
#endif
    afterElementPadRemoved                  ,
    genClosure_ElementPadRemoved            ,
    mk_ElementPadRemovedCallback            ,
    noElementPadRemovedCallback             ,
    onElementPadRemoved                     ,
    wrap_ElementPadRemovedCallback          ,




    ) 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.GLib.Callbacks as GLib.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Flags as Gst.Flags
import {-# SOURCE #-} qualified GI.Gst.Objects.Bus as Gst.Bus
import {-# SOURCE #-} qualified GI.Gst.Objects.Clock as Gst.Clock
import {-# SOURCE #-} qualified GI.Gst.Objects.ElementFactory as Gst.ElementFactory
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.Objects.PadTemplate as Gst.PadTemplate
import {-# SOURCE #-} qualified GI.Gst.Objects.Plugin as Gst.Plugin
import {-# SOURCE #-} qualified GI.Gst.Structs.Caps as Gst.Caps
import {-# SOURCE #-} qualified GI.Gst.Structs.Context as Gst.Context
import {-# SOURCE #-} qualified GI.Gst.Structs.Event as Gst.Event
import {-# SOURCE #-} qualified GI.Gst.Structs.Iterator as Gst.Iterator
import {-# SOURCE #-} qualified GI.Gst.Structs.Message as Gst.Message
import {-# SOURCE #-} qualified GI.Gst.Structs.Query as Gst.Query
import {-# SOURCE #-} qualified GI.Gst.Structs.Structure as Gst.Structure

-- | Memory-managed wrapper type.
newtype Element = Element (ManagedPtr Element)
foreign import ccall "gst_element_get_type"
    c_gst_element_get_type :: IO GType

instance GObject Element where
    gobjectType = c_gst_element_get_type


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

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

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

-- | A convenience alias for `Nothing` :: `Maybe` `Element`.
noElement :: Maybe Element
noElement = Nothing

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

instance (info ~ ResolveElementMethod t Element, O.MethodInfo info Element p) => OL.IsLabel t (Element -> 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 Element::no-more-pads
{- |
This signals that the element will not generate more dynamic pads.
Note that this signal will usually be emitted from the context of
the streaming thread.
-}
type ElementNoMorePadsCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ElementNoMorePadsCallback`@.
noElementNoMorePadsCallback :: Maybe ElementNoMorePadsCallback
noElementNoMorePadsCallback = Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_ElementNoMorePads :: MonadIO m => ElementNoMorePadsCallback -> m (GClosure C_ElementNoMorePadsCallback)
genClosure_ElementNoMorePads cb = liftIO $ do
    let cb' = wrap_ElementNoMorePadsCallback cb
    mk_ElementNoMorePadsCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ElementNoMorePadsCallback` into a `C_ElementNoMorePadsCallback`.
wrap_ElementNoMorePadsCallback ::
    ElementNoMorePadsCallback ->
    C_ElementNoMorePadsCallback
wrap_ElementNoMorePadsCallback _cb _ _ = do
    _cb


{- |
Connect a signal handler for the “@no-more-pads@” 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' element #noMorePads callback
@
-}
onElementNoMorePads :: (IsElement a, MonadIO m) => a -> ElementNoMorePadsCallback -> m SignalHandlerId
onElementNoMorePads obj cb = liftIO $ do
    let cb' = wrap_ElementNoMorePadsCallback cb
    cb'' <- mk_ElementNoMorePadsCallback cb'
    connectSignalFunPtr obj "no-more-pads" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@no-more-pads@” 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' element #noMorePads callback
@
-}
afterElementNoMorePads :: (IsElement a, MonadIO m) => a -> ElementNoMorePadsCallback -> m SignalHandlerId
afterElementNoMorePads obj cb = liftIO $ do
    let cb' = wrap_ElementNoMorePadsCallback cb
    cb'' <- mk_ElementNoMorePadsCallback cb'
    connectSignalFunPtr obj "no-more-pads" cb'' SignalConnectAfter


-- signal Element::pad-added
{- |
a new 'GI.Gst.Objects.Pad.Pad' has been added to the element. Note that this signal will
usually be emitted from the context of the streaming thread. Also keep in
mind that if you add new elements to the pipeline in the signal handler
you will need to set them to the desired target state with
'GI.Gst.Objects.Element.elementSetState' or 'GI.Gst.Objects.Element.elementSyncStateWithParent'.
-}
type ElementPadAddedCallback =
    Gst.Pad.Pad
    {- ^ /@newPad@/: the pad that has been added -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ElementPadAddedCallback`@.
noElementPadAddedCallback :: Maybe ElementPadAddedCallback
noElementPadAddedCallback = Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_ElementPadAdded :: MonadIO m => ElementPadAddedCallback -> m (GClosure C_ElementPadAddedCallback)
genClosure_ElementPadAdded cb = liftIO $ do
    let cb' = wrap_ElementPadAddedCallback cb
    mk_ElementPadAddedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ElementPadAddedCallback` into a `C_ElementPadAddedCallback`.
wrap_ElementPadAddedCallback ::
    ElementPadAddedCallback ->
    C_ElementPadAddedCallback
wrap_ElementPadAddedCallback _cb _ newPad _ = do
    newPad' <- (newObject Gst.Pad.Pad) newPad
    _cb  newPad'


{- |
Connect a signal handler for the “@pad-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' element #padAdded callback
@
-}
onElementPadAdded :: (IsElement a, MonadIO m) => a -> ElementPadAddedCallback -> m SignalHandlerId
onElementPadAdded obj cb = liftIO $ do
    let cb' = wrap_ElementPadAddedCallback cb
    cb'' <- mk_ElementPadAddedCallback cb'
    connectSignalFunPtr obj "pad-added" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@pad-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' element #padAdded callback
@
-}
afterElementPadAdded :: (IsElement a, MonadIO m) => a -> ElementPadAddedCallback -> m SignalHandlerId
afterElementPadAdded obj cb = liftIO $ do
    let cb' = wrap_ElementPadAddedCallback cb
    cb'' <- mk_ElementPadAddedCallback cb'
    connectSignalFunPtr obj "pad-added" cb'' SignalConnectAfter


-- signal Element::pad-removed
{- |
a 'GI.Gst.Objects.Pad.Pad' has been removed from the element
-}
type ElementPadRemovedCallback =
    Gst.Pad.Pad
    {- ^ /@oldPad@/: the pad that has been removed -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ElementPadRemovedCallback`@.
noElementPadRemovedCallback :: Maybe ElementPadRemovedCallback
noElementPadRemovedCallback = Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_ElementPadRemoved :: MonadIO m => ElementPadRemovedCallback -> m (GClosure C_ElementPadRemovedCallback)
genClosure_ElementPadRemoved cb = liftIO $ do
    let cb' = wrap_ElementPadRemovedCallback cb
    mk_ElementPadRemovedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ElementPadRemovedCallback` into a `C_ElementPadRemovedCallback`.
wrap_ElementPadRemovedCallback ::
    ElementPadRemovedCallback ->
    C_ElementPadRemovedCallback
wrap_ElementPadRemovedCallback _cb _ oldPad _ = do
    oldPad' <- (newObject Gst.Pad.Pad) oldPad
    _cb  oldPad'


{- |
Connect a signal handler for the “@pad-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' element #padRemoved callback
@
-}
onElementPadRemoved :: (IsElement a, MonadIO m) => a -> ElementPadRemovedCallback -> m SignalHandlerId
onElementPadRemoved obj cb = liftIO $ do
    let cb' = wrap_ElementPadRemovedCallback cb
    cb'' <- mk_ElementPadRemovedCallback cb'
    connectSignalFunPtr obj "pad-removed" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@pad-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' element #padRemoved callback
@
-}
afterElementPadRemoved :: (IsElement a, MonadIO m) => a -> ElementPadRemovedCallback -> m SignalHandlerId
afterElementPadRemoved obj cb = liftIO $ do
    let cb' = wrap_ElementPadRemovedCallback cb
    cb'' <- mk_ElementPadRemovedCallback cb'
    connectSignalFunPtr obj "pad-removed" cb'' SignalConnectAfter


#if ENABLE_OVERLOADING
instance O.HasAttributeList Element
type instance O.AttributeList Element = ElementAttributeList
type ElementAttributeList = ('[ '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
data ElementNoMorePadsSignalInfo
instance SignalInfo ElementNoMorePadsSignalInfo where
    type HaskellCallbackType ElementNoMorePadsSignalInfo = ElementNoMorePadsCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ElementNoMorePadsCallback cb
        cb'' <- mk_ElementNoMorePadsCallback cb'
        connectSignalFunPtr obj "no-more-pads" cb'' connectMode

data ElementPadAddedSignalInfo
instance SignalInfo ElementPadAddedSignalInfo where
    type HaskellCallbackType ElementPadAddedSignalInfo = ElementPadAddedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ElementPadAddedCallback cb
        cb'' <- mk_ElementPadAddedCallback cb'
        connectSignalFunPtr obj "pad-added" cb'' connectMode

data ElementPadRemovedSignalInfo
instance SignalInfo ElementPadRemovedSignalInfo where
    type HaskellCallbackType ElementPadRemovedSignalInfo = ElementPadRemovedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ElementPadRemovedCallback cb
        cb'' <- mk_ElementPadRemovedCallback cb'
        connectSignalFunPtr obj "pad-removed" cb'' connectMode

type instance O.SignalList Element = ElementSignalList
type ElementSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("noMorePads", ElementNoMorePadsSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("padAdded", ElementPadAddedSignalInfo), '("padRemoved", ElementPadRemovedSignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "gst_element_abort_state" gst_element_abort_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO ()

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

This function should be called with the STATE_LOCK held.

MT safe.
-}
elementAbortState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to abort the state of. -}
    -> m ()
elementAbortState element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_abort_state element'
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementAbortStateMethodInfo
instance (signature ~ (m ()), MonadIO m, IsElement a) => O.MethodInfo ElementAbortStateMethodInfo a signature where
    overloadedMethod _ = elementAbortState

#endif

-- method Element::add_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to add the pad to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to add to the element.", 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_element_add_pad" gst_element_add_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO CInt

{- |
Adds a pad (link point) to /@element@/. /@pad@/\'s parent will be set to /@element@/;
see 'GI.Gst.Objects.Object.objectSetParent' for refcounting information.

Pads are automatically activated when added in the PAUSED or PLAYING
state.

The pad and the element should be unlocked when calling this function.

This function will emit the 'GI.Gst.Objects.Element.Element'::@/pad-added/@ signal on the element.
-}
elementAddPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to add the pad to. -}
    -> b
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to add to the element. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pad could be added. This function can fail when
a pad with the same name already existed or the pad already had another
parent.

MT safe. -}
elementAddPad element pad = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    pad' <- unsafeManagedPtrCastPtr pad
    result <- gst_element_add_pad element' pad'
    let result' = (/= 0) result
    touchManagedPtr element
    touchManagedPtr pad
    return result'

#if ENABLE_OVERLOADING
data ElementAddPadMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsElement a, Gst.Pad.IsPad b) => O.MethodInfo ElementAddPadMethodInfo a signature where
    overloadedMethod _ = elementAddPad

#endif

-- method Element::add_property_deep_notify_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to watch (recursively) for property changes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "name of property to watch for changes, or\n    NULL to watch all properties", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "include_value", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to include the new property value in the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TULong)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_add_property_deep_notify_watch" gst_element_add_property_deep_notify_watch ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- property_name : TBasicType TUTF8
    CInt ->                                 -- include_value : TBasicType TBoolean
    IO CULong

{- |
/No description available in the introspection data./

/Since: 1.10/
-}
elementAddPropertyDeepNotifyWatch ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to watch (recursively) for property changes -}
    -> Maybe (T.Text)
    {- ^ /@propertyName@/: name of property to watch for changes, or
    NULL to watch all properties -}
    -> Bool
    {- ^ /@includeValue@/: whether to include the new property value in the message -}
    -> m CULong
    {- ^ __Returns:__ a watch id, which can be used in connection with
    'GI.Gst.Objects.Element.elementRemovePropertyNotifyWatch' to remove the watch again. -}
elementAddPropertyDeepNotifyWatch element propertyName includeValue = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    maybePropertyName <- case propertyName of
        Nothing -> return nullPtr
        Just jPropertyName -> do
            jPropertyName' <- textToCString jPropertyName
            return jPropertyName'
    let includeValue' = (fromIntegral . fromEnum) includeValue
    result <- gst_element_add_property_deep_notify_watch element' maybePropertyName includeValue'
    touchManagedPtr element
    freeMem maybePropertyName
    return result

#if ENABLE_OVERLOADING
data ElementAddPropertyDeepNotifyWatchMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> m CULong), MonadIO m, IsElement a) => O.MethodInfo ElementAddPropertyDeepNotifyWatchMethodInfo a signature where
    overloadedMethod _ = elementAddPropertyDeepNotifyWatch

#endif

-- method Element::add_property_notify_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to watch for property changes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "name of property to watch for changes, or\n    NULL to watch all properties", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "include_value", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to include the new property value in the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TULong)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_add_property_notify_watch" gst_element_add_property_notify_watch ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- property_name : TBasicType TUTF8
    CInt ->                                 -- include_value : TBasicType TBoolean
    IO CULong

{- |
/No description available in the introspection data./

/Since: 1.10/
-}
elementAddPropertyNotifyWatch ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to watch for property changes -}
    -> Maybe (T.Text)
    {- ^ /@propertyName@/: name of property to watch for changes, or
    NULL to watch all properties -}
    -> Bool
    {- ^ /@includeValue@/: whether to include the new property value in the message -}
    -> m CULong
    {- ^ __Returns:__ a watch id, which can be used in connection with
    'GI.Gst.Objects.Element.elementRemovePropertyNotifyWatch' to remove the watch again. -}
elementAddPropertyNotifyWatch element propertyName includeValue = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    maybePropertyName <- case propertyName of
        Nothing -> return nullPtr
        Just jPropertyName -> do
            jPropertyName' <- textToCString jPropertyName
            return jPropertyName'
    let includeValue' = (fromIntegral . fromEnum) includeValue
    result <- gst_element_add_property_notify_watch element' maybePropertyName includeValue'
    touchManagedPtr element
    freeMem maybePropertyName
    return result

#if ENABLE_OVERLOADING
data ElementAddPropertyNotifyWatchMethodInfo
instance (signature ~ (Maybe (T.Text) -> Bool -> m CULong), MonadIO m, IsElement a) => O.MethodInfo ElementAddPropertyNotifyWatchMethodInfo a signature where
    overloadedMethod _ = elementAddPropertyNotifyWatch

#endif

-- method Element::call_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "ElementCallAsyncFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Function to call asynchronously from another thread", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Data to pass to @func", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GDestroyNotify for @user_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_call_async" gst_element_call_async ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    FunPtr Gst.Callbacks.C_ElementCallAsyncFunc -> -- func : TInterface (Name {namespace = "Gst", name = "ElementCallAsyncFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Calls /@func@/ from another thread and passes /@userData@/ to it. This is to be
used for cases when a state change has to be performed from a streaming
thread, directly via 'GI.Gst.Objects.Element.elementSetState' or indirectly e.g. via SEEK
events.

Calling those functions directly from the streaming thread will cause
deadlocks in many situations, as they might involve waiting for the
streaming thread to shut down from this very streaming thread.

MT safe.

/Since: 1.10/
-}
elementCallAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' -}
    -> Gst.Callbacks.ElementCallAsyncFunc
    {- ^ /@func@/: Function to call asynchronously from another thread -}
    -> m ()
elementCallAsync element func = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    func' <- Gst.Callbacks.mk_ElementCallAsyncFunc (Gst.Callbacks.wrap_ElementCallAsyncFunc Nothing (Gst.Callbacks.drop_closures_ElementCallAsyncFunc func))
    let userData = castFunPtrToPtr func'
    let destroyNotify = safeFreeFunPtrPtr
    gst_element_call_async element' func' userData destroyNotify
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementCallAsyncMethodInfo
instance (signature ~ (Gst.Callbacks.ElementCallAsyncFunc -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementCallAsyncMethodInfo a signature where
    overloadedMethod _ = elementCallAsync

#endif

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

foreign import ccall "gst_element_change_state" gst_element_change_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- transition : TInterface (Name {namespace = "Gst", name = "StateChange"})
    IO CUInt

{- |
Perform /@transition@/ on /@element@/.

This function must be called with STATE_LOCK held and is mainly used
internally.
-}
elementChangeState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' -}
    -> Gst.Enums.StateChange
    {- ^ /@transition@/: the requested transition -}
    -> m Gst.Enums.StateChangeReturn
    {- ^ __Returns:__ the 'GI.Gst.Enums.StateChangeReturn' of the state transition. -}
elementChangeState element transition = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let transition' = (fromIntegral . fromEnum) transition
    result <- gst_element_change_state element' transition'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementChangeStateMethodInfo
instance (signature ~ (Gst.Enums.StateChange -> m Gst.Enums.StateChangeReturn), MonadIO m, IsElement a) => O.MethodInfo ElementChangeStateMethodInfo a signature where
    overloadedMethod _ = elementChangeState

#endif

-- method Element::continue_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to continue the state change of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ret", argType = TInterface (Name {namespace = "Gst", name = "StateChangeReturn"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The previous state return value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "StateChangeReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_continue_state" gst_element_continue_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- ret : TInterface (Name {namespace = "Gst", name = "StateChangeReturn"})
    IO CUInt

{- |
Commit the state change of the element and proceed to the next
pending state if any. This function is used
by elements that do asynchronous state changes.
The core will normally call this method automatically when an
element returned 'GI.Gst.Enums.StateChangeReturnSuccess' from the state change function.

If after calling this method the element still has not reached
the pending state, the next state change is performed.

This method is used internally and should normally not be called by plugins
or applications.

This function must be called with STATE_LOCK held.
-}
elementContinueState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to continue the state change of. -}
    -> Gst.Enums.StateChangeReturn
    {- ^ /@ret@/: The previous state return value -}
    -> m Gst.Enums.StateChangeReturn
    {- ^ __Returns:__ The result of the commit state change.

MT safe. -}
elementContinueState element ret = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let ret' = (fromIntegral . fromEnum) ret
    result <- gst_element_continue_state element' ret'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementContinueStateMethodInfo
instance (signature ~ (Gst.Enums.StateChangeReturn -> m Gst.Enums.StateChangeReturn), MonadIO m, IsElement a) => O.MethodInfo ElementContinueStateMethodInfo a signature where
    overloadedMethod _ = elementContinueState

#endif

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

foreign import ccall "gst_element_create_all_pads" gst_element_create_all_pads ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO ()

{- |
Creates a pad for each pad template that is always available.
This function is only useful during object initialization of
subclasses of 'GI.Gst.Objects.Element.Element'.
-}
elementCreateAllPads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to create pads for -}
    -> m ()
elementCreateAllPads element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_create_all_pads element'
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementCreateAllPadsMethodInfo
instance (signature ~ (m ()), MonadIO m, IsElement a) => O.MethodInfo ElementCreateAllPadsMethodInfo a signature where
    overloadedMethod _ = elementCreateAllPads

#endif

-- method Element::foreach_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to iterate pads of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call for each pad", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @func", 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_element_foreach_pad" gst_element_foreach_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    FunPtr Gst.Callbacks.C_ElementForeachPadFunc -> -- func : TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

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

/Since: 1.14/
-}
elementForeachPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to iterate pads of -}
    -> Gst.Callbacks.ElementForeachPadFunc
    {- ^ /@func@/: function to call for each pad -}
    -> m Bool
    {- ^ __Returns:__ 'False' if /@element@/ had no pads or if one of the calls to /@func@/
  returned 'False'. -}
elementForeachPad element func = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    func' <- Gst.Callbacks.mk_ElementForeachPadFunc (Gst.Callbacks.wrap_ElementForeachPadFunc Nothing (Gst.Callbacks.drop_closures_ElementForeachPadFunc func))
    let userData = nullPtr
    result <- gst_element_foreach_pad element' func' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementForeachPadMethodInfo
instance (signature ~ (Gst.Callbacks.ElementForeachPadFunc -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementForeachPadMethodInfo a signature where
    overloadedMethod _ = elementForeachPad

#endif

-- method Element::foreach_sink_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to iterate sink pads of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call for each sink pad", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @func", 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_element_foreach_sink_pad" gst_element_foreach_sink_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    FunPtr Gst.Callbacks.C_ElementForeachPadFunc -> -- func : TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

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

/Since: 1.14/
-}
elementForeachSinkPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to iterate sink pads of -}
    -> Gst.Callbacks.ElementForeachPadFunc
    {- ^ /@func@/: function to call for each sink pad -}
    -> m Bool
    {- ^ __Returns:__ 'False' if /@element@/ had no sink pads or if one of the calls to /@func@/
  returned 'False'. -}
elementForeachSinkPad element func = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    func' <- Gst.Callbacks.mk_ElementForeachPadFunc (Gst.Callbacks.wrap_ElementForeachPadFunc Nothing (Gst.Callbacks.drop_closures_ElementForeachPadFunc func))
    let userData = nullPtr
    result <- gst_element_foreach_sink_pad element' func' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementForeachSinkPadMethodInfo
instance (signature ~ (Gst.Callbacks.ElementForeachPadFunc -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementForeachSinkPadMethodInfo a signature where
    overloadedMethod _ = elementForeachSinkPad

#endif

-- method Element::foreach_src_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to iterate source pads of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call for each source pad", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @func", 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_element_foreach_src_pad" gst_element_foreach_src_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    FunPtr Gst.Callbacks.C_ElementForeachPadFunc -> -- func : TInterface (Name {namespace = "Gst", name = "ElementForeachPadFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

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

/Since: 1.14/
-}
elementForeachSrcPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to iterate source pads of -}
    -> Gst.Callbacks.ElementForeachPadFunc
    {- ^ /@func@/: function to call for each source pad -}
    -> m Bool
    {- ^ __Returns:__ 'False' if /@element@/ had no source pads or if one of the calls
  to /@func@/ returned 'False'. -}
elementForeachSrcPad element func = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    func' <- Gst.Callbacks.mk_ElementForeachPadFunc (Gst.Callbacks.wrap_ElementForeachPadFunc Nothing (Gst.Callbacks.drop_closures_ElementForeachPadFunc func))
    let userData = nullPtr
    result <- gst_element_foreach_src_pad element' func' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementForeachSrcPadMethodInfo
instance (signature ~ (Gst.Callbacks.ElementForeachPadFunc -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementForeachSrcPadMethodInfo a signature where
    overloadedMethod _ = elementForeachSrcPad

#endif

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

foreign import ccall "gst_element_get_base_time" gst_element_get_base_time ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO Word64

{- |
Returns the base time of the element. The base time is the
absolute time of the clock when this element was last put to
PLAYING. Subtracting the base time from the clock time gives
the running time of the element.
-}
elementGetBaseTime ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Word64
    {- ^ __Returns:__ the base time of the element.

MT safe. -}
elementGetBaseTime element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_base_time element'
    touchManagedPtr element
    return result

#if ENABLE_OVERLOADING
data ElementGetBaseTimeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsElement a) => O.MethodInfo ElementGetBaseTimeMethodInfo a signature where
    overloadedMethod _ = elementGetBaseTime

#endif

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

foreign import ccall "gst_element_get_bus" gst_element_get_bus ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Bus.Bus)

{- |
Returns the bus of the element. Note that only a 'GI.Gst.Objects.Pipeline.Pipeline' will provide a
bus for the application.
-}
elementGetBus ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the bus of. -}
    -> m (Maybe Gst.Bus.Bus)
    {- ^ __Returns:__ the element\'s 'GI.Gst.Objects.Bus.Bus'. unref after
usage.

MT safe. -}
elementGetBus element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_bus element'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Bus.Bus) result'
        return result''
    touchManagedPtr element
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetBusMethodInfo
instance (signature ~ (m (Maybe Gst.Bus.Bus)), MonadIO m, IsElement a) => O.MethodInfo ElementGetBusMethodInfo a signature where
    overloadedMethod _ = elementGetBus

#endif

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

foreign import ccall "gst_element_get_clock" gst_element_get_clock ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Clock.Clock)

{- |
Gets the currently configured clock of the element. This is the clock as was
last set with 'GI.Gst.Objects.Element.elementSetClock'.

Elements in a pipeline will only have their clock set when the
pipeline is in the PLAYING state.
-}
elementGetClock ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the clock of. -}
    -> m (Maybe Gst.Clock.Clock)
    {- ^ __Returns:__ the 'GI.Gst.Objects.Clock.Clock' of the element. unref after usage.

MT safe. -}
elementGetClock element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_clock element'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Clock.Clock) result'
        return result''
    touchManagedPtr element
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetClockMethodInfo
instance (signature ~ (m (Maybe Gst.Clock.Clock)), MonadIO m, IsElement a) => O.MethodInfo ElementGetClockMethodInfo a signature where
    overloadedMethod _ = elementGetClock

#endif

-- method Element::get_compatible_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement in which the pad should be found.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to find a compatible one for.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCaps to use as a filter.", 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_element_get_compatible_pad" gst_element_get_compatible_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Gst.Pad.Pad)

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

This function will first attempt to find a compatible unlinked ALWAYS pad,
and if none can be found, it will request a compatible REQUEST pad by looking
at the templates of /@element@/.
-}
elementGetCompatiblePad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' in which the pad should be found. -}
    -> b
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to find a compatible one for. -}
    -> Maybe (Gst.Caps.Caps)
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to use as a filter. -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ the 'GI.Gst.Objects.Pad.Pad' to which a link
  can be made, or 'Nothing' if one cannot be found. 'GI.Gst.Objects.Object.objectUnref'
  after usage. -}
elementGetCompatiblePad element pad caps = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    pad' <- unsafeManagedPtrCastPtr pad
    maybeCaps <- case caps of
        Nothing -> return nullPtr
        Just jCaps -> do
            jCaps' <- unsafeManagedPtrGetPtr jCaps
            return jCaps'
    result <- gst_element_get_compatible_pad element' pad' maybeCaps
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr element
    touchManagedPtr pad
    whenJust caps touchManagedPtr
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetCompatiblePadMethodInfo
instance (signature ~ (b -> Maybe (Gst.Caps.Caps) -> m (Maybe Gst.Pad.Pad)), MonadIO m, IsElement a, Gst.Pad.IsPad b) => O.MethodInfo ElementGetCompatiblePadMethodInfo a signature where
    overloadedMethod _ = elementGetCompatiblePad

#endif

-- method Element::get_compatible_pad_template
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get a compatible pad template for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "compattempl", argType = TInterface (Name {namespace = "Gst", name = "PadTemplate"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPadTemplate to find a compatible\n    template for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "PadTemplate"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_get_compatible_pad_template" gst_element_get_compatible_pad_template ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.PadTemplate.PadTemplate ->      -- compattempl : TInterface (Name {namespace = "Gst", name = "PadTemplate"})
    IO (Ptr Gst.PadTemplate.PadTemplate)

{- |
Retrieves a pad template from /@element@/ that is compatible with /@compattempl@/.
Pads from compatible templates can be linked together.
-}
elementGetCompatiblePadTemplate ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.PadTemplate.IsPadTemplate b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get a compatible pad template for -}
    -> b
    {- ^ /@compattempl@/: the 'GI.Gst.Objects.PadTemplate.PadTemplate' to find a compatible
    template for -}
    -> m (Maybe Gst.PadTemplate.PadTemplate)
    {- ^ __Returns:__ a compatible 'GI.Gst.Objects.PadTemplate.PadTemplate',
  or 'Nothing' if none was found. No unreferencing is necessary. -}
elementGetCompatiblePadTemplate element compattempl = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    compattempl' <- unsafeManagedPtrCastPtr compattempl
    result <- gst_element_get_compatible_pad_template element' compattempl'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gst.PadTemplate.PadTemplate) result'
        return result''
    touchManagedPtr element
    touchManagedPtr compattempl
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetCompatiblePadTemplateMethodInfo
instance (signature ~ (b -> m (Maybe Gst.PadTemplate.PadTemplate)), MonadIO m, IsElement a, Gst.PadTemplate.IsPadTemplate b) => O.MethodInfo ElementGetCompatiblePadTemplateMethodInfo a signature where
    overloadedMethod _ = elementGetCompatiblePadTemplate

#endif

-- method Element::get_context
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get the context of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "context_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a name of a context to retrieve", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Context"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_get_context" gst_element_get_context ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- context_type : TBasicType TUTF8
    IO (Ptr Gst.Context.Context)

{- |
Gets the context with /@contextType@/ set on the element or NULL.

MT safe.

/Since: 1.8/
-}
elementGetContext ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the context of. -}
    -> T.Text
    {- ^ /@contextType@/: a name of a context to retrieve -}
    -> m Gst.Context.Context
    {- ^ __Returns:__ A 'GI.Gst.Structs.Context.Context' or NULL -}
elementGetContext element contextType = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    contextType' <- textToCString contextType
    result <- gst_element_get_context element' contextType'
    checkUnexpectedReturnNULL "elementGetContext" result
    result' <- (wrapBoxed Gst.Context.Context) result
    touchManagedPtr element
    freeMem contextType'
    return result'

#if ENABLE_OVERLOADING
data ElementGetContextMethodInfo
instance (signature ~ (T.Text -> m Gst.Context.Context), MonadIO m, IsElement a) => O.MethodInfo ElementGetContextMethodInfo a signature where
    overloadedMethod _ = elementGetContext

#endif

-- method Element::get_context_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get the context of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "context_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a name of a context to retrieve", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Context"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_get_context_unlocked" gst_element_get_context_unlocked ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- context_type : TBasicType TUTF8
    IO (Ptr Gst.Context.Context)

{- |
Gets the context with /@contextType@/ set on the element or NULL.

/Since: 1.8/
-}
elementGetContextUnlocked ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the context of. -}
    -> T.Text
    {- ^ /@contextType@/: a name of a context to retrieve -}
    -> m (Maybe Gst.Context.Context)
    {- ^ __Returns:__ A 'GI.Gst.Structs.Context.Context' or NULL -}
elementGetContextUnlocked element contextType = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    contextType' <- textToCString contextType
    result <- gst_element_get_context_unlocked element' contextType'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Context.Context) result'
        return result''
    touchManagedPtr element
    freeMem contextType'
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetContextUnlockedMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.Context.Context)), MonadIO m, IsElement a) => O.MethodInfo ElementGetContextUnlockedMethodInfo a signature where
    overloadedMethod _ = elementGetContextUnlocked

#endif

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

foreign import ccall "gst_element_get_contexts" gst_element_get_contexts ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr (GList (Ptr Gst.Context.Context)))

{- |
Gets the contexts set on the element.

MT safe.

/Since: 1.8/
-}
elementGetContexts ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to set the context of. -}
    -> m [Gst.Context.Context]
    {- ^ __Returns:__ List of 'GI.Gst.Structs.Context.Context' -}
elementGetContexts element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_contexts element'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Gst.Context.Context) result'
    g_list_free result
    touchManagedPtr element
    return result''

#if ENABLE_OVERLOADING
data ElementGetContextsMethodInfo
instance (signature ~ (m [Gst.Context.Context]), MonadIO m, IsElement a) => O.MethodInfo ElementGetContextsMethodInfo a signature where
    overloadedMethod _ = elementGetContexts

#endif

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

foreign import ccall "gst_element_get_factory" gst_element_get_factory ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.ElementFactory.ElementFactory)

{- |
Retrieves the factory that was used to create this element.
-}
elementGetFactory ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to request the element factory of. -}
    -> m (Maybe Gst.ElementFactory.ElementFactory)
    {- ^ __Returns:__ the 'GI.Gst.Objects.ElementFactory.ElementFactory' used for creating this
    element or 'Nothing' if element has not been registered (static element). no refcounting is needed. -}
elementGetFactory element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_factory element'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gst.ElementFactory.ElementFactory) result'
        return result''
    touchManagedPtr element
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetFactoryMethodInfo
instance (signature ~ (m (Maybe Gst.ElementFactory.ElementFactory)), MonadIO m, IsElement a) => O.MethodInfo ElementGetFactoryMethodInfo a signature where
    overloadedMethod _ = elementGetFactory

#endif

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

foreign import ccall "gst_element_get_metadata" gst_element_get_metadata ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- key : TBasicType TUTF8
    IO CString

{- |
Get metadata with /@key@/ in /@klass@/.

/Since: 1.14/
-}
elementGetMetadata ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: class to get metadata for -}
    -> T.Text
    {- ^ /@key@/: the key to get -}
    -> m T.Text
    {- ^ __Returns:__ the metadata for /@key@/. -}
elementGetMetadata element key = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    key' <- textToCString key
    result <- gst_element_get_metadata element' key'
    checkUnexpectedReturnNULL "elementGetMetadata" result
    result' <- cstringToText result
    touchManagedPtr element
    freeMem key'
    return result'

#if ENABLE_OVERLOADING
data ElementGetMetadataMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsElement a) => O.MethodInfo ElementGetMetadataMethodInfo a signature where
    overloadedMethod _ = elementGetMetadata

#endif

-- method Element::get_pad_template
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get the pad template of.", 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 name of the #GstPadTemplate to get.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "PadTemplate"}))
-- throws : False
-- Skip return : False

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

{- |
Retrieves a padtemplate from /@element@/ with the given name.

/Since: 1.14/
-}
elementGetPadTemplate ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the pad template of. -}
    -> T.Text
    {- ^ /@name@/: the name of the 'GI.Gst.Objects.PadTemplate.PadTemplate' to get. -}
    -> m (Maybe Gst.PadTemplate.PadTemplate)
    {- ^ __Returns:__ the 'GI.Gst.Objects.PadTemplate.PadTemplate' with the
    given name, or 'Nothing' if none was found. No unreferencing is
    necessary. -}
elementGetPadTemplate element name = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    name' <- textToCString name
    result <- gst_element_get_pad_template element' name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gst.PadTemplate.PadTemplate) result'
        return result''
    touchManagedPtr element
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetPadTemplateMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.PadTemplate.PadTemplate)), MonadIO m, IsElement a) => O.MethodInfo ElementGetPadTemplateMethodInfo a signature where
    overloadedMethod _ = elementGetPadTemplate

#endif

-- method Element::get_pad_template_list
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get pad templates of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gst", name = "PadTemplate"})))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_get_pad_template_list" gst_element_get_pad_template_list ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr (GList (Ptr Gst.PadTemplate.PadTemplate)))

{- |
Retrieves a list of the pad templates associated with /@element@/. The
list must not be modified by the calling code.

/Since: 1.14/
-}
elementGetPadTemplateList ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get pad templates of. -}
    -> m [Gst.PadTemplate.PadTemplate]
    {- ^ __Returns:__ the 'GI.GLib.Structs.List.List' of
    pad templates. -}
elementGetPadTemplateList element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_pad_template_list element'
    result' <- unpackGList result
    result'' <- mapM (newObject Gst.PadTemplate.PadTemplate) result'
    touchManagedPtr element
    return result''

#if ENABLE_OVERLOADING
data ElementGetPadTemplateListMethodInfo
instance (signature ~ (m [Gst.PadTemplate.PadTemplate]), MonadIO m, IsElement a) => O.MethodInfo ElementGetPadTemplateListMethodInfo a signature where
    overloadedMethod _ = elementGetPadTemplateList

#endif

-- method Element::get_request_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to find a request pad of.", 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 name of the request #GstPad to retrieve.", 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_element_get_request_pad" gst_element_get_request_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Gst.Pad.Pad)

{- |
Retrieves a pad from the element by name (e.g. \"src_%d\"). This version only
retrieves request pads. The pad should be released with
'GI.Gst.Objects.Element.elementReleaseRequestPad'.

This method is slower than manually getting the pad template and calling
'GI.Gst.Objects.Element.elementRequestPad' if the pads should have a specific name (e.g.
/@name@/ is \"src_1\" instead of \"src_%u\").
-}
elementGetRequestPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to find a request pad of. -}
    -> T.Text
    {- ^ /@name@/: the name of the request 'GI.Gst.Objects.Pad.Pad' to retrieve. -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ requested 'GI.Gst.Objects.Pad.Pad' if found,
    otherwise 'Nothing'.  Release after usage. -}
elementGetRequestPad element name = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    name' <- textToCString name
    result <- gst_element_get_request_pad element' name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr element
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetRequestPadMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.Pad.Pad)), MonadIO m, IsElement a) => O.MethodInfo ElementGetRequestPadMethodInfo a signature where
    overloadedMethod _ = elementGetRequestPad

#endif

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

foreign import ccall "gst_element_get_start_time" gst_element_get_start_time ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO Word64

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

Usually the start_time is managed by a toplevel element such as
'GI.Gst.Objects.Pipeline.Pipeline'.

MT safe.
-}
elementGetStartTime ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Word64
    {- ^ __Returns:__ the start time of the element. -}
elementGetStartTime element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_get_start_time element'
    touchManagedPtr element
    return result

#if ENABLE_OVERLOADING
data ElementGetStartTimeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsElement a) => O.MethodInfo ElementGetStartTimeMethodInfo a signature where
    overloadedMethod _ = elementGetStartTime

#endif

-- method Element::get_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to get the state of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "state", argType = TInterface (Name {namespace = "Gst", name = "State"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to #GstState to hold the state.\n    Can be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "pending", argType = TInterface (Name {namespace = "Gst", name = "State"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to #GstState to hold the pending\n    state. Can be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstClockTime to specify the timeout for an async\n          state change or %GST_CLOCK_TIME_NONE for infinite timeout.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "StateChangeReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_get_state" gst_element_get_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr CUInt ->                            -- state : TInterface (Name {namespace = "Gst", name = "State"})
    Ptr CUInt ->                            -- pending : TInterface (Name {namespace = "Gst", name = "State"})
    Word64 ->                               -- timeout : TBasicType TUInt64
    IO CUInt

{- |
Gets the state of the element.

For elements that performed an ASYNC state change, as reported by
'GI.Gst.Objects.Element.elementSetState', this function will block up to the
specified timeout value for the state change to complete.
If the element completes the state change or goes into
an error, this function returns immediately with a return value of
'GI.Gst.Enums.StateChangeReturnSuccess' or 'GI.Gst.Enums.StateChangeReturnFailure' respectively.

For elements that did not return 'GI.Gst.Enums.StateChangeReturnAsync', this function
returns the current and pending state immediately.

This function returns 'GI.Gst.Enums.StateChangeReturnNoPreroll' if the element
successfully changed its state but is not able to provide data yet.
This mostly happens for live sources that only produce data in
'GI.Gst.Enums.StatePlaying'. While the state change return is equivalent to
'GI.Gst.Enums.StateChangeReturnSuccess', it is returned to the application to signal that
some sink elements might not be able to complete their state change because
an element is not producing data to complete the preroll. When setting the
element to playing, the preroll will complete and playback will start.
-}
elementGetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to get the state of. -}
    -> Word64
    {- ^ /@timeout@/: a @/GstClockTime/@ to specify the timeout for an async
          state change or 'GI.Gst.Constants.CLOCK_TIME_NONE' for infinite timeout. -}
    -> m ((Gst.Enums.StateChangeReturn, Gst.Enums.State, Gst.Enums.State))
    {- ^ __Returns:__ 'GI.Gst.Enums.StateChangeReturnSuccess' if the element has no more pending state
         and the last state change succeeded, 'GI.Gst.Enums.StateChangeReturnAsync' if the
         element is still performing a state change or
         'GI.Gst.Enums.StateChangeReturnFailure' if the last state change failed.

MT safe. -}
elementGetState element timeout = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    state <- allocMem :: IO (Ptr CUInt)
    pending <- allocMem :: IO (Ptr CUInt)
    result <- gst_element_get_state element' state pending timeout
    let result' = (toEnum . fromIntegral) result
    state' <- peek state
    let state'' = (toEnum . fromIntegral) state'
    pending' <- peek pending
    let pending'' = (toEnum . fromIntegral) pending'
    touchManagedPtr element
    freeMem state
    freeMem pending
    return (result', state'', pending'')

#if ENABLE_OVERLOADING
data ElementGetStateMethodInfo
instance (signature ~ (Word64 -> m ((Gst.Enums.StateChangeReturn, Gst.Enums.State, Gst.Enums.State))), MonadIO m, IsElement a) => O.MethodInfo ElementGetStateMethodInfo a signature where
    overloadedMethod _ = elementGetState

#endif

-- method Element::get_static_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to find a static pad of.", 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 name of the static #GstPad to retrieve.", 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_element_get_static_pad" gst_element_get_static_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Gst.Pad.Pad)

{- |
Retrieves a pad from /@element@/ by name. This version only retrieves
already-existing (i.e. \'static\') pads.
-}
elementGetStaticPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to find a static pad of. -}
    -> T.Text
    {- ^ /@name@/: the name of the static 'GI.Gst.Objects.Pad.Pad' to retrieve. -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ the requested 'GI.Gst.Objects.Pad.Pad' if
    found, otherwise 'Nothing'.  unref after usage.

MT safe. -}
elementGetStaticPad element name = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    name' <- textToCString name
    result <- gst_element_get_static_pad element' name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr element
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
data ElementGetStaticPadMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.Pad.Pad)), MonadIO m, IsElement a) => O.MethodInfo ElementGetStaticPadMethodInfo a signature where
    overloadedMethod _ = elementGetStaticPad

#endif

-- method Element::is_locked_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement.", 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_element_is_locked_state" gst_element_is_locked_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO CInt

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

MT safe.
-}
elementIsLockedState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Bool
    {- ^ __Returns:__ 'True', if the element\'s state is locked. -}
elementIsLockedState element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_is_locked_state element'
    let result' = (/= 0) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementIsLockedStateMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementIsLockedStateMethodInfo a signature where
    overloadedMethod _ = elementIsLockedState

#endif

-- method Element::iterate_pads
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to iterate pads of.", 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_element_iterate_pads" gst_element_iterate_pads ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Retrieves an iterator of /@element@/\'s pads. The iterator should
be freed after usage. Also more specialized iterators exists such as
'GI.Gst.Objects.Element.elementIterateSrcPads' or 'GI.Gst.Objects.Element.elementIterateSinkPads'.

The order of pads returned by the iterator will be the order in which
the pads were added to the element.
-}
elementIteratePads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to iterate pads of. -}
    -> m Gst.Iterator.Iterator
    {- ^ __Returns:__ the 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Pad.Pad'.

MT safe. -}
elementIteratePads element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_iterate_pads element'
    checkUnexpectedReturnNULL "elementIteratePads" result
    result' <- (wrapBoxed Gst.Iterator.Iterator) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementIteratePadsMethodInfo
instance (signature ~ (m Gst.Iterator.Iterator), MonadIO m, IsElement a) => O.MethodInfo ElementIteratePadsMethodInfo a signature where
    overloadedMethod _ = elementIteratePads

#endif

-- method Element::iterate_sink_pads
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement.", 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_element_iterate_sink_pads" gst_element_iterate_sink_pads ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Retrieves an iterator of /@element@/\'s sink pads.

The order of pads returned by the iterator will be the order in which
the pads were added to the element.
-}
elementIterateSinkPads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Gst.Iterator.Iterator
    {- ^ __Returns:__ the 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Pad.Pad'.

MT safe. -}
elementIterateSinkPads element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_iterate_sink_pads element'
    checkUnexpectedReturnNULL "elementIterateSinkPads" result
    result' <- (wrapBoxed Gst.Iterator.Iterator) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementIterateSinkPadsMethodInfo
instance (signature ~ (m Gst.Iterator.Iterator), MonadIO m, IsElement a) => O.MethodInfo ElementIterateSinkPadsMethodInfo a signature where
    overloadedMethod _ = elementIterateSinkPads

#endif

-- method Element::iterate_src_pads
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement.", 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_element_iterate_src_pads" gst_element_iterate_src_pads ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Iterator.Iterator)

{- |
Retrieves an iterator of /@element@/\'s source pads.

The order of pads returned by the iterator will be the order in which
the pads were added to the element.
-}
elementIterateSrcPads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Gst.Iterator.Iterator
    {- ^ __Returns:__ the 'GI.Gst.Structs.Iterator.Iterator' of 'GI.Gst.Objects.Pad.Pad'.

MT safe. -}
elementIterateSrcPads element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_iterate_src_pads element'
    checkUnexpectedReturnNULL "elementIterateSrcPads" result
    result' <- (wrapBoxed Gst.Iterator.Iterator) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementIterateSrcPadsMethodInfo
instance (signature ~ (m Gst.Iterator.Iterator), MonadIO m, IsElement a) => O.MethodInfo ElementIterateSrcPadsMethodInfo a signature where
    overloadedMethod _ = elementIterateSrcPads

#endif

-- method Element::link
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement containing the destination pad.", 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_element_link" gst_element_link ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    IO CInt

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

Make sure you have added your elements to a bin or pipeline with
'GI.Gst.Objects.Bin.binAdd' before trying to link them.
-}
elementLink ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> b
    {- ^ /@dest@/: the 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the elements could be linked, 'False' otherwise. -}
elementLink src dest = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    dest' <- unsafeManagedPtrCastPtr dest
    result <- gst_element_link src' dest'
    let result' = (/= 0) result
    touchManagedPtr src
    touchManagedPtr dest
    return result'

#if ENABLE_OVERLOADING
data ElementLinkMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementLinkMethodInfo a signature where
    overloadedMethod _ = elementLink

#endif

-- method Element::link_filtered
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement containing the destination pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "filter", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCaps to filter the link,\n    or %NULL for no filter.", 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_element_link_filtered" gst_element_link_filtered ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Caps.Caps ->                    -- filter : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

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

Make sure you have added your elements to a bin or pipeline with
'GI.Gst.Objects.Bin.binAdd' before trying to link them.
-}
elementLinkFiltered ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> b
    {- ^ /@dest@/: the 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> Maybe (Gst.Caps.Caps)
    {- ^ /@filter@/: the 'GI.Gst.Structs.Caps.Caps' to filter the link,
    or 'Nothing' for no filter. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pads could be linked, 'False' otherwise. -}
elementLinkFiltered src dest filter = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    dest' <- unsafeManagedPtrCastPtr dest
    maybeFilter <- case filter of
        Nothing -> return nullPtr
        Just jFilter -> do
            jFilter' <- unsafeManagedPtrGetPtr jFilter
            return jFilter'
    result <- gst_element_link_filtered src' dest' maybeFilter
    let result' = (/= 0) result
    touchManagedPtr src
    touchManagedPtr dest
    whenJust filter touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data ElementLinkFilteredMethodInfo
instance (signature ~ (b -> Maybe (Gst.Caps.Caps) -> m Bool), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementLinkFilteredMethodInfo a signature where
    overloadedMethod _ = elementLinkFiltered

#endif

-- method Element::link_pads
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "srcpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in source element\n    or %NULL for any pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement containing the destination pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in destination element,\nor %NULL for any pad.", 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_element_link_pads" gst_element_link_pads ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- srcpadname : TBasicType TUTF8
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- destpadname : TBasicType TUTF8
    IO CInt

{- |
Links the two named pads of the source and destination elements.
Side effect is that if one of the pads has no parent, it becomes a
child of the parent of the other element.  If they have different
parents, the link fails.
-}
elementLinkPads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> Maybe (T.Text)
    {- ^ /@srcpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in source element
    or 'Nothing' for any pad. -}
    -> b
    {- ^ /@dest@/: the 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> Maybe (T.Text)
    {- ^ /@destpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in destination element,
or 'Nothing' for any pad. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pads could be linked, 'False' otherwise. -}
elementLinkPads src srcpadname dest destpadname = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    maybeSrcpadname <- case srcpadname of
        Nothing -> return nullPtr
        Just jSrcpadname -> do
            jSrcpadname' <- textToCString jSrcpadname
            return jSrcpadname'
    dest' <- unsafeManagedPtrCastPtr dest
    maybeDestpadname <- case destpadname of
        Nothing -> return nullPtr
        Just jDestpadname -> do
            jDestpadname' <- textToCString jDestpadname
            return jDestpadname'
    result <- gst_element_link_pads src' maybeSrcpadname dest' maybeDestpadname
    let result' = (/= 0) result
    touchManagedPtr src
    touchManagedPtr dest
    freeMem maybeSrcpadname
    freeMem maybeDestpadname
    return result'

#if ENABLE_OVERLOADING
data ElementLinkPadsMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> Maybe (T.Text) -> m Bool), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementLinkPadsMethodInfo a signature where
    overloadedMethod _ = elementLinkPads

#endif

-- method Element::link_pads_filtered
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "srcpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in source element\n    or %NULL for any pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement containing the destination pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in destination element\n    or %NULL for any pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "filter", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCaps to filter the link,\n    or %NULL for no filter.", 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_element_link_pads_filtered" gst_element_link_pads_filtered ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- srcpadname : TBasicType TUTF8
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- destpadname : TBasicType TUTF8
    Ptr Gst.Caps.Caps ->                    -- filter : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Links the two named pads of the source and destination elements. Side effect
is that if one of the pads has no parent, it becomes a child of the parent of
the other element. If they have different parents, the link fails. If /@caps@/
is not 'Nothing', makes sure that the caps of the link is a subset of /@caps@/.
-}
elementLinkPadsFiltered ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> Maybe (T.Text)
    {- ^ /@srcpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in source element
    or 'Nothing' for any pad. -}
    -> b
    {- ^ /@dest@/: the 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> Maybe (T.Text)
    {- ^ /@destpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in destination element
    or 'Nothing' for any pad. -}
    -> Maybe (Gst.Caps.Caps)
    {- ^ /@filter@/: the 'GI.Gst.Structs.Caps.Caps' to filter the link,
    or 'Nothing' for no filter. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pads could be linked, 'False' otherwise. -}
elementLinkPadsFiltered src srcpadname dest destpadname filter = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    maybeSrcpadname <- case srcpadname of
        Nothing -> return nullPtr
        Just jSrcpadname -> do
            jSrcpadname' <- textToCString jSrcpadname
            return jSrcpadname'
    dest' <- unsafeManagedPtrCastPtr dest
    maybeDestpadname <- case destpadname of
        Nothing -> return nullPtr
        Just jDestpadname -> do
            jDestpadname' <- textToCString jDestpadname
            return jDestpadname'
    maybeFilter <- case filter of
        Nothing -> return nullPtr
        Just jFilter -> do
            jFilter' <- unsafeManagedPtrGetPtr jFilter
            return jFilter'
    result <- gst_element_link_pads_filtered src' maybeSrcpadname dest' maybeDestpadname maybeFilter
    let result' = (/= 0) result
    touchManagedPtr src
    touchManagedPtr dest
    whenJust filter touchManagedPtr
    freeMem maybeSrcpadname
    freeMem maybeDestpadname
    return result'

#if ENABLE_OVERLOADING
data ElementLinkPadsFilteredMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> Maybe (T.Text) -> Maybe (Gst.Caps.Caps) -> m Bool), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementLinkPadsFilteredMethodInfo a signature where
    overloadedMethod _ = elementLinkPadsFiltered

#endif

-- method Element::link_pads_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "srcpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in source element\n    or %NULL for any pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement containing the destination pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in destination element,\nor %NULL for any pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gst", name = "PadLinkCheck"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPadLinkCheck to be performed when linking pads.", 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_element_link_pads_full" gst_element_link_pads_full ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- srcpadname : TBasicType TUTF8
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- destpadname : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gst", name = "PadLinkCheck"})
    IO CInt

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

Calling 'GI.Gst.Objects.Element.elementLinkPadsFull' with /@flags@/ == 'GI.Gst.Flags.PadLinkCheckDefault'
is the same as calling 'GI.Gst.Objects.Element.elementLinkPads' and the recommended way of
linking pads with safety checks applied.

This is a convenience function for 'GI.Gst.Objects.Pad.padLinkFull'.
-}
elementLinkPadsFull ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> Maybe (T.Text)
    {- ^ /@srcpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in source element
    or 'Nothing' for any pad. -}
    -> b
    {- ^ /@dest@/: the 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> Maybe (T.Text)
    {- ^ /@destpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in destination element,
or 'Nothing' for any pad. -}
    -> [Gst.Flags.PadLinkCheck]
    {- ^ /@flags@/: the 'GI.Gst.Flags.PadLinkCheck' to be performed when linking pads. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pads could be linked, 'False' otherwise. -}
elementLinkPadsFull src srcpadname dest destpadname flags = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    maybeSrcpadname <- case srcpadname of
        Nothing -> return nullPtr
        Just jSrcpadname -> do
            jSrcpadname' <- textToCString jSrcpadname
            return jSrcpadname'
    dest' <- unsafeManagedPtrCastPtr dest
    maybeDestpadname <- case destpadname of
        Nothing -> return nullPtr
        Just jDestpadname -> do
            jDestpadname' <- textToCString jDestpadname
            return jDestpadname'
    let flags' = gflagsToWord flags
    result <- gst_element_link_pads_full src' maybeSrcpadname dest' maybeDestpadname flags'
    let result' = (/= 0) result
    touchManagedPtr src
    touchManagedPtr dest
    freeMem maybeSrcpadname
    freeMem maybeDestpadname
    return result'

#if ENABLE_OVERLOADING
data ElementLinkPadsFullMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> Maybe (T.Text) -> [Gst.Flags.PadLinkCheck] -> m Bool), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementLinkPadsFullMethodInfo a signature where
    overloadedMethod _ = elementLinkPadsFull

#endif

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

foreign import ccall "gst_element_lost_state" gst_element_lost_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO ()

{- |
Brings the element to the lost state. The current state of the
element is copied to the pending state so that any call to
'GI.Gst.Objects.Element.elementGetState' will return 'GI.Gst.Enums.StateChangeReturnAsync'.

An ASYNC_START message is posted. If the element was PLAYING, it will
go to PAUSED. The element will be restored to its PLAYING state by
the parent pipeline when it prerolls again.

This is mostly used for elements that lost their preroll buffer
in the 'GI.Gst.Enums.StatePaused' or 'GI.Gst.Enums.StatePlaying' state after a flush,
they will go to their pending state again when a new preroll buffer is
queued. This function can only be called when the element is currently
not in error or an async state change.

This function is used internally and should normally not be called from
plugins or applications.
-}
elementLostState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' the state is lost of -}
    -> m ()
elementLostState element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_lost_state element'
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementLostStateMethodInfo
instance (signature ~ (m ()), MonadIO m, IsElement a) => O.MethodInfo ElementLostStateMethodInfo a signature where
    overloadedMethod _ = elementLostState

#endif

-- method Element::message_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to send message from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Gst", name = "MessageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstMessageType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "domain", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GStreamer GError domain this message belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "code", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GError code belonging to the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an allocated text string to be used\n           as a replacement for the default message connected to code,\n           or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "debug", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an allocated debug message to be\n           used as a replacement for the default debugging information,\n           or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code file where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code function where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code line where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_message_full" gst_element_message_full ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Gst", name = "MessageType"})
    Word32 ->                               -- domain : TBasicType TUInt32
    Int32 ->                                -- code : TBasicType TInt
    CString ->                              -- text : TBasicType TUTF8
    CString ->                              -- debug : TBasicType TUTF8
    CString ->                              -- file : TBasicType TUTF8
    CString ->                              -- function : TBasicType TUTF8
    Int32 ->                                -- line : TBasicType TInt
    IO ()

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

/@type@/ must be of @/GST_MESSAGE_ERROR/@, @/GST_MESSAGE_WARNING/@ or
@/GST_MESSAGE_INFO/@.

MT safe.
-}
elementMessageFull ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to send message from -}
    -> [Gst.Flags.MessageType]
    {- ^ /@type@/: the 'GI.Gst.Flags.MessageType' -}
    -> Word32
    {- ^ /@domain@/: the GStreamer GError domain this message belongs to -}
    -> Int32
    {- ^ /@code@/: the GError code belonging to the domain -}
    -> Maybe (T.Text)
    {- ^ /@text@/: an allocated text string to be used
           as a replacement for the default message connected to code,
           or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@debug@/: an allocated debug message to be
           used as a replacement for the default debugging information,
           or 'Nothing' -}
    -> T.Text
    {- ^ /@file@/: the source code file where the error was generated -}
    -> T.Text
    {- ^ /@function@/: the source code function where the error was generated -}
    -> Int32
    {- ^ /@line@/: the source code line where the error was generated -}
    -> m ()
elementMessageFull element type_ domain code text debug file function line = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let type_' = gflagsToWord type_
    maybeText <- case text of
        Nothing -> return nullPtr
        Just jText -> do
            jText' <- textToCString jText
            return jText'
    maybeDebug <- case debug of
        Nothing -> return nullPtr
        Just jDebug -> do
            jDebug' <- textToCString jDebug
            return jDebug'
    file' <- textToCString file
    function' <- textToCString function
    gst_element_message_full element' type_' domain code maybeText maybeDebug file' function' line
    touchManagedPtr element
    freeMem file'
    freeMem function'
    return ()

#if ENABLE_OVERLOADING
data ElementMessageFullMethodInfo
instance (signature ~ ([Gst.Flags.MessageType] -> Word32 -> Int32 -> Maybe (T.Text) -> Maybe (T.Text) -> T.Text -> T.Text -> Int32 -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementMessageFullMethodInfo a signature where
    overloadedMethod _ = elementMessageFull

#endif

-- method Element::message_full_with_details
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to send message from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Gst", name = "MessageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstMessageType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "domain", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GStreamer GError domain this message belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "code", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the GError code belonging to the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an allocated text string to be used\n           as a replacement for the default message connected to code,\n           or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "debug", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an allocated debug message to be\n           used as a replacement for the default debugging information,\n           or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code file where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code function where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source code line where the error was generated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "structure", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "optional details structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_message_full_with_details" gst_element_message_full_with_details ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Gst", name = "MessageType"})
    Word32 ->                               -- domain : TBasicType TUInt32
    Int32 ->                                -- code : TBasicType TInt
    CString ->                              -- text : TBasicType TUTF8
    CString ->                              -- debug : TBasicType TUTF8
    CString ->                              -- file : TBasicType TUTF8
    CString ->                              -- function : TBasicType TUTF8
    Int32 ->                                -- line : TBasicType TInt
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO ()

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

/@type@/ must be of @/GST_MESSAGE_ERROR/@, @/GST_MESSAGE_WARNING/@ or
@/GST_MESSAGE_INFO/@.

/Since: 1.10/
-}
elementMessageFullWithDetails ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to send message from -}
    -> [Gst.Flags.MessageType]
    {- ^ /@type@/: the 'GI.Gst.Flags.MessageType' -}
    -> Word32
    {- ^ /@domain@/: the GStreamer GError domain this message belongs to -}
    -> Int32
    {- ^ /@code@/: the GError code belonging to the domain -}
    -> Maybe (T.Text)
    {- ^ /@text@/: an allocated text string to be used
           as a replacement for the default message connected to code,
           or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@debug@/: an allocated debug message to be
           used as a replacement for the default debugging information,
           or 'Nothing' -}
    -> T.Text
    {- ^ /@file@/: the source code file where the error was generated -}
    -> T.Text
    {- ^ /@function@/: the source code function where the error was generated -}
    -> Int32
    {- ^ /@line@/: the source code line where the error was generated -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: optional details structure -}
    -> m ()
elementMessageFullWithDetails element type_ domain code text debug file function line structure = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let type_' = gflagsToWord type_
    maybeText <- case text of
        Nothing -> return nullPtr
        Just jText -> do
            jText' <- textToCString jText
            return jText'
    maybeDebug <- case debug of
        Nothing -> return nullPtr
        Just jDebug -> do
            jDebug' <- textToCString jDebug
            return jDebug'
    file' <- textToCString file
    function' <- textToCString function
    structure' <- B.ManagedPtr.disownBoxed structure
    gst_element_message_full_with_details element' type_' domain code maybeText maybeDebug file' function' line structure'
    touchManagedPtr element
    touchManagedPtr structure
    freeMem file'
    freeMem function'
    return ()

#if ENABLE_OVERLOADING
data ElementMessageFullWithDetailsMethodInfo
instance (signature ~ ([Gst.Flags.MessageType] -> Word32 -> Int32 -> Maybe (T.Text) -> Maybe (T.Text) -> T.Text -> T.Text -> Int32 -> Gst.Structure.Structure -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementMessageFullWithDetailsMethodInfo a signature where
    overloadedMethod _ = elementMessageFullWithDetails

#endif

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

foreign import ccall "gst_element_no_more_pads" gst_element_no_more_pads ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO ()

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

This function emits the 'GI.Gst.Objects.Element.Element'::@/no-more-pads/@ signal.

MT safe.
-}
elementNoMorePads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' -}
    -> m ()
elementNoMorePads element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_no_more_pads element'
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementNoMorePadsMethodInfo
instance (signature ~ (m ()), MonadIO m, IsElement a) => O.MethodInfo ElementNoMorePadsMethodInfo a signature where
    overloadedMethod _ = elementNoMorePads

#endif

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

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

{- |
Post a message on the element\'s 'GI.Gst.Objects.Bus.Bus'. This function takes ownership of the
message; if you want to access the message after this call, you should add an
additional reference before calling.
-}
elementPostMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' posting the message -}
    -> Gst.Message.Message
    {- ^ /@message@/: a 'GI.Gst.Structs.Message.Message' to post -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the message was successfully posted. The function returns
'False' if the element did not have a bus.

MT safe. -}
elementPostMessage element message = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    message' <- B.ManagedPtr.disownBoxed message
    result <- gst_element_post_message element' message'
    let result' = (/= 0) result
    touchManagedPtr element
    touchManagedPtr message
    return result'

#if ENABLE_OVERLOADING
data ElementPostMessageMethodInfo
instance (signature ~ (Gst.Message.Message -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementPostMessageMethodInfo a signature where
    overloadedMethod _ = elementPostMessage

#endif

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

foreign import ccall "gst_element_provide_clock" gst_element_provide_clock ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO (Ptr Gst.Clock.Clock)

{- |
Get the clock provided by the given element.
> An element is only required to provide a clock in the PAUSED
> state. Some elements can provide a clock in other states.
-}
elementProvideClock ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to query -}
    -> m (Maybe Gst.Clock.Clock)
    {- ^ __Returns:__ the GstClock provided by the
element or 'Nothing' if no clock could be provided.  Unref after usage.

MT safe. -}
elementProvideClock element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_provide_clock element'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Clock.Clock) result'
        return result''
    touchManagedPtr element
    return maybeResult

#if ENABLE_OVERLOADING
data ElementProvideClockMethodInfo
instance (signature ~ (m (Maybe Gst.Clock.Clock)), MonadIO m, IsElement a) => O.MethodInfo ElementProvideClockMethodInfo a signature where
    overloadedMethod _ = elementProvideClock

#endif

-- method Element::query
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to perform the query on.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "query", argType = TInterface (Name {namespace = "Gst", name = "Query"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstQuery.", 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_element_query" gst_element_query ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Query.Query ->                  -- query : TInterface (Name {namespace = "Gst", name = "Query"})
    IO CInt

{- |
Performs a query on the given element.

For elements that don\'t implement a query handler, this function
forwards the query to a random srcpad or to the peer of a
random linked sinkpad of this element.

Please note that some queries might need a running pipeline to work.
-}
elementQuery ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to perform the query on. -}
    -> Gst.Query.Query
    {- ^ /@query@/: the 'GI.Gst.Structs.Query.Query'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the query could be performed.

MT safe. -}
elementQuery element query = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    query' <- unsafeManagedPtrGetPtr query
    result <- gst_element_query element' query'
    let result' = (/= 0) result
    touchManagedPtr element
    touchManagedPtr query
    return result'

#if ENABLE_OVERLOADING
data ElementQueryMethodInfo
instance (signature ~ (Gst.Query.Query -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementQueryMethodInfo a signature where
    overloadedMethod _ = elementQuery

#endif

-- method Element::query_convert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to invoke the convert query on.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstFormat to convert from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_val", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a value to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstFormat to convert to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_val", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the result.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_query_convert" gst_element_query_convert ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- src_format : TInterface (Name {namespace = "Gst", name = "Format"})
    Int64 ->                                -- src_val : TBasicType TInt64
    CUInt ->                                -- dest_format : TInterface (Name {namespace = "Gst", name = "Format"})
    Ptr Int64 ->                            -- dest_val : TBasicType TInt64
    IO CInt

{- |
Queries an element to convert /@srcVal@/ in /@srcFormat@/ to /@destFormat@/.
-}
elementQueryConvert ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to invoke the convert query on. -}
    -> Gst.Enums.Format
    {- ^ /@srcFormat@/: a 'GI.Gst.Enums.Format' to convert from. -}
    -> Int64
    {- ^ /@srcVal@/: a value to convert. -}
    -> Gst.Enums.Format
    {- ^ /@destFormat@/: the 'GI.Gst.Enums.Format' to convert to. -}
    -> m ((Bool, Int64))
    {- ^ __Returns:__ 'True' if the query could be performed. -}
elementQueryConvert element srcFormat srcVal destFormat = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let srcFormat' = (fromIntegral . fromEnum) srcFormat
    let destFormat' = (fromIntegral . fromEnum) destFormat
    destVal <- allocMem :: IO (Ptr Int64)
    result <- gst_element_query_convert element' srcFormat' srcVal destFormat' destVal
    let result' = (/= 0) result
    destVal' <- peek destVal
    touchManagedPtr element
    freeMem destVal
    return (result', destVal')

#if ENABLE_OVERLOADING
data ElementQueryConvertMethodInfo
instance (signature ~ (Gst.Enums.Format -> Int64 -> Gst.Enums.Format -> m ((Bool, Int64))), MonadIO m, IsElement a) => O.MethodInfo ElementQueryConvertMethodInfo a signature where
    overloadedMethod _ = elementQueryConvert

#endif

-- method Element::query_duration
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to invoke the duration query on.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstFormat requested", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "duration", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A location in which to store the total duration, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_query_duration" gst_element_query_duration ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- format : TInterface (Name {namespace = "Gst", name = "Format"})
    Ptr Int64 ->                            -- duration : TBasicType TInt64
    IO CInt

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

If the duration changes for some reason, you will get a DURATION_CHANGED
message on the pipeline bus, in which case you should re-query the duration
using this function.
-}
elementQueryDuration ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to invoke the duration query on. -}
    -> Gst.Enums.Format
    {- ^ /@format@/: the 'GI.Gst.Enums.Format' requested -}
    -> m ((Bool, Int64))
    {- ^ __Returns:__ 'True' if the query could be performed. -}
elementQueryDuration element format = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let format' = (fromIntegral . fromEnum) format
    duration <- allocMem :: IO (Ptr Int64)
    result <- gst_element_query_duration element' format' duration
    let result' = (/= 0) result
    duration' <- peek duration
    touchManagedPtr element
    freeMem duration
    return (result', duration')

#if ENABLE_OVERLOADING
data ElementQueryDurationMethodInfo
instance (signature ~ (Gst.Enums.Format -> m ((Bool, Int64))), MonadIO m, IsElement a) => O.MethodInfo ElementQueryDurationMethodInfo a signature where
    overloadedMethod _ = elementQueryDuration

#endif

-- method Element::query_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to invoke the position query on.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstFormat requested", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cur", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a location in which to store the current\n    position, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_query_position" gst_element_query_position ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- format : TInterface (Name {namespace = "Gst", name = "Format"})
    Ptr Int64 ->                            -- cur : TBasicType TInt64
    IO CInt

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

If one repeatedly calls this function one can also create a query and reuse
it in 'GI.Gst.Objects.Element.elementQuery'.
-}
elementQueryPosition ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to invoke the position query on. -}
    -> Gst.Enums.Format
    {- ^ /@format@/: the 'GI.Gst.Enums.Format' requested -}
    -> m ((Bool, Int64))
    {- ^ __Returns:__ 'True' if the query could be performed. -}
elementQueryPosition element format = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let format' = (fromIntegral . fromEnum) format
    cur <- allocMem :: IO (Ptr Int64)
    result <- gst_element_query_position element' format' cur
    let result' = (/= 0) result
    cur' <- peek cur
    touchManagedPtr element
    freeMem cur
    return (result', cur')

#if ENABLE_OVERLOADING
data ElementQueryPositionMethodInfo
instance (signature ~ (Gst.Enums.Format -> m ((Bool, Int64))), MonadIO m, IsElement a) => O.MethodInfo ElementQueryPositionMethodInfo a signature where
    overloadedMethod _ = elementQueryPosition

#endif

-- method Element::release_request_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to release the request pad of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to release.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_release_request_pad" gst_element_release_request_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO ()

{- |
Makes the element free the previously requested pad as obtained
with 'GI.Gst.Objects.Element.elementRequestPad'.

This does not unref the pad. If the pad was created by using
'GI.Gst.Objects.Element.elementRequestPad', 'GI.Gst.Objects.Element.elementReleaseRequestPad' needs to be
followed by 'GI.Gst.Objects.Object.objectUnref' to free the /@pad@/.

MT safe.
-}
elementReleaseRequestPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to release the request pad of. -}
    -> b
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to release. -}
    -> m ()
elementReleaseRequestPad element pad = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    pad' <- unsafeManagedPtrCastPtr pad
    gst_element_release_request_pad element' pad'
    touchManagedPtr element
    touchManagedPtr pad
    return ()

#if ENABLE_OVERLOADING
data ElementReleaseRequestPadMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsElement a, Gst.Pad.IsPad b) => O.MethodInfo ElementReleaseRequestPadMethodInfo a signature where
    overloadedMethod _ = elementReleaseRequestPad

#endif

-- method Element::remove_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to remove pad from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to remove from the element.", 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_element_remove_pad" gst_element_remove_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO CInt

{- |
Removes /@pad@/ from /@element@/. /@pad@/ will be destroyed if it has not been
referenced elsewhere using 'GI.Gst.Objects.Object.objectUnparent'.

This function is used by plugin developers and should not be used
by applications. Pads that were dynamically requested from elements
with 'GI.Gst.Objects.Element.elementRequestPad' should be released with the
'GI.Gst.Objects.Element.elementReleaseRequestPad' function instead.

Pads are not automatically deactivated so elements should perform the needed
steps to deactivate the pad in case this pad is removed in the PAUSED or
PLAYING state. See 'GI.Gst.Objects.Pad.padSetActive' for more information about
deactivating pads.

The pad and the element should be unlocked when calling this function.

This function will emit the 'GI.Gst.Objects.Element.Element'::@/pad-removed/@ signal on the element.
-}
elementRemovePad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to remove pad from. -}
    -> b
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to remove from the element. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pad could be removed. Can return 'False' if the
pad does not belong to the provided element.

MT safe. -}
elementRemovePad element pad = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    pad' <- unsafeManagedPtrCastPtr pad
    result <- gst_element_remove_pad element' pad'
    let result' = (/= 0) result
    touchManagedPtr element
    touchManagedPtr pad
    return result'

#if ENABLE_OVERLOADING
data ElementRemovePadMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsElement a, Gst.Pad.IsPad b) => O.MethodInfo ElementRemovePadMethodInfo a signature where
    overloadedMethod _ = elementRemovePad

#endif

-- method Element::remove_property_notify_watch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement being watched for property changes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "watch_id", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "watch id to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_remove_property_notify_watch" gst_element_remove_property_notify_watch ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CULong ->                               -- watch_id : TBasicType TULong
    IO ()

{- |
/No description available in the introspection data./

/Since: 1.10/
-}
elementRemovePropertyNotifyWatch ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' being watched for property changes -}
    -> CULong
    {- ^ /@watchId@/: watch id to remove -}
    -> m ()
elementRemovePropertyNotifyWatch element watchId = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_remove_property_notify_watch element' watchId
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementRemovePropertyNotifyWatchMethodInfo
instance (signature ~ (CULong -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementRemovePropertyNotifyWatchMethodInfo a signature where
    overloadedMethod _ = elementRemovePropertyNotifyWatch

#endif

-- method Element::request_pad
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to find a request pad of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "templ", argType = TInterface (Name {namespace = "Gst", name = "PadTemplate"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPadTemplate of which we want a pad of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the request #GstPad\nto retrieve. Can be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the caps of the pad we want to\nrequest. Can be %NULL.", 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_element_request_pad" gst_element_request_pad ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.PadTemplate.PadTemplate ->      -- templ : TInterface (Name {namespace = "Gst", name = "PadTemplate"})
    CString ->                              -- name : TBasicType TUTF8
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Gst.Pad.Pad)

{- |
Retrieves a request pad from the element according to the provided template.
Pad templates can be looked up using
'GI.Gst.Objects.ElementFactory.elementFactoryGetStaticPadTemplates'.

The pad should be released with 'GI.Gst.Objects.Element.elementReleaseRequestPad'.
-}
elementRequestPad ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.PadTemplate.IsPadTemplate b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to find a request pad of. -}
    -> b
    {- ^ /@templ@/: a 'GI.Gst.Objects.PadTemplate.PadTemplate' of which we want a pad of. -}
    -> Maybe (T.Text)
    {- ^ /@name@/: the name of the request 'GI.Gst.Objects.Pad.Pad'
to retrieve. Can be 'Nothing'. -}
    -> Maybe (Gst.Caps.Caps)
    {- ^ /@caps@/: the caps of the pad we want to
request. Can be 'Nothing'. -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ requested 'GI.Gst.Objects.Pad.Pad' if found,
    otherwise 'Nothing'.  Release after usage. -}
elementRequestPad element templ name caps = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    templ' <- unsafeManagedPtrCastPtr templ
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    maybeCaps <- case caps of
        Nothing -> return nullPtr
        Just jCaps -> do
            jCaps' <- unsafeManagedPtrGetPtr jCaps
            return jCaps'
    result <- gst_element_request_pad element' templ' maybeName maybeCaps
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr element
    touchManagedPtr templ
    whenJust caps touchManagedPtr
    freeMem maybeName
    return maybeResult

#if ENABLE_OVERLOADING
data ElementRequestPadMethodInfo
instance (signature ~ (b -> Maybe (T.Text) -> Maybe (Gst.Caps.Caps) -> m (Maybe Gst.Pad.Pad)), MonadIO m, IsElement a, Gst.PadTemplate.IsPadTemplate b) => O.MethodInfo ElementRequestPadMethodInfo a signature where
    overloadedMethod _ = elementRequestPad

#endif

-- method Element::seek
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to send the event to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rate", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The new playback rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The format of the seek values", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gst", name = "SeekFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The optional seek flags.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_type", argType = TInterface (Name {namespace = "Gst", name = "SeekType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The type and flags for the new start position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The value of the new start position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop_type", argType = TInterface (Name {namespace = "Gst", name = "SeekType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The type and flags for the new stop position", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stop", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The value of the new stop position", 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_element_seek" gst_element_seek ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CDouble ->                              -- rate : TBasicType TDouble
    CUInt ->                                -- format : TInterface (Name {namespace = "Gst", name = "Format"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gst", name = "SeekFlags"})
    CUInt ->                                -- start_type : TInterface (Name {namespace = "Gst", name = "SeekType"})
    Int64 ->                                -- start : TBasicType TInt64
    CUInt ->                                -- stop_type : TInterface (Name {namespace = "Gst", name = "SeekType"})
    Int64 ->                                -- stop : TBasicType TInt64
    IO CInt

{- |
Sends a seek event to an element. See 'GI.Gst.Structs.Event.eventNewSeek' for the details of
the parameters. The seek event is sent to the element using
'GI.Gst.Objects.Element.elementSendEvent'.

MT safe.
-}
elementSeek ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to send the event to. -}
    -> Double
    {- ^ /@rate@/: The new playback rate -}
    -> Gst.Enums.Format
    {- ^ /@format@/: The format of the seek values -}
    -> [Gst.Flags.SeekFlags]
    {- ^ /@flags@/: The optional seek flags. -}
    -> Gst.Enums.SeekType
    {- ^ /@startType@/: The type and flags for the new start position -}
    -> Int64
    {- ^ /@start@/: The value of the new start position -}
    -> Gst.Enums.SeekType
    {- ^ /@stopType@/: The type and flags for the new stop position -}
    -> Int64
    {- ^ /@stop@/: The value of the new stop position -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the event was handled. Flushing seeks will trigger a
preroll, which will emit 'GI.Gst.Flags.MessageTypeAsyncDone'. -}
elementSeek element rate format flags startType start stopType stop = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let rate' = realToFrac rate
    let format' = (fromIntegral . fromEnum) format
    let flags' = gflagsToWord flags
    let startType' = (fromIntegral . fromEnum) startType
    let stopType' = (fromIntegral . fromEnum) stopType
    result <- gst_element_seek element' rate' format' flags' startType' start stopType' stop
    let result' = (/= 0) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementSeekMethodInfo
instance (signature ~ (Double -> Gst.Enums.Format -> [Gst.Flags.SeekFlags] -> Gst.Enums.SeekType -> Int64 -> Gst.Enums.SeekType -> Int64 -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementSeekMethodInfo a signature where
    overloadedMethod _ = elementSeek

#endif

-- method Element::seek_simple
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to seek on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstFormat to execute the seek in, such as #GST_FORMAT_TIME", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "seek_flags", argType = TInterface (Name {namespace = "Gst", name = "SeekFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "seek options; playback applications will usually want to use\n           GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "seek_pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "position to seek to (relative to the start); if you are doing\n           a seek in #GST_FORMAT_TIME this value is in nanoseconds -\n           multiply with #GST_SECOND to convert seconds to nanoseconds or\n           with #GST_MSECOND to convert milliseconds to nanoseconds.", 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_element_seek_simple" gst_element_seek_simple ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- format : TInterface (Name {namespace = "Gst", name = "Format"})
    CUInt ->                                -- seek_flags : TInterface (Name {namespace = "Gst", name = "SeekFlags"})
    Int64 ->                                -- seek_pos : TBasicType TInt64
    IO CInt

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

In a completely prerolled PAUSED or PLAYING pipeline, seeking is always
guaranteed to return 'True' on a seekable media type or 'False' when the media
type is certainly not seekable (such as a live stream).

Some elements allow for seeking in the READY state, in this
case they will store the seek event and execute it when they are put to
PAUSED. If the element supports seek in READY, it will always return 'True' when
it receives the event in the READY state.
-}
elementSeekSimple ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to seek on -}
    -> Gst.Enums.Format
    {- ^ /@format@/: a 'GI.Gst.Enums.Format' to execute the seek in, such as @/GST_FORMAT_TIME/@ -}
    -> [Gst.Flags.SeekFlags]
    {- ^ /@seekFlags@/: seek options; playback applications will usually want to use
           GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here -}
    -> Int64
    {- ^ /@seekPos@/: position to seek to (relative to the start); if you are doing
           a seek in @/GST_FORMAT_TIME/@ this value is in nanoseconds -
           multiply with 'GI.Gst.Constants.SECOND' to convert seconds to nanoseconds or
           with 'GI.Gst.Constants.MSECOND' to convert milliseconds to nanoseconds. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the seek operation succeeded. Flushing seeks will trigger a
preroll, which will emit 'GI.Gst.Flags.MessageTypeAsyncDone'. -}
elementSeekSimple element format seekFlags seekPos = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let format' = (fromIntegral . fromEnum) format
    let seekFlags' = gflagsToWord seekFlags
    result <- gst_element_seek_simple element' format' seekFlags' seekPos
    let result' = (/= 0) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementSeekSimpleMethodInfo
instance (signature ~ (Gst.Enums.Format -> [Gst.Flags.SeekFlags] -> Int64 -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementSeekSimpleMethodInfo a signature where
    overloadedMethod _ = elementSeekSimple

#endif

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

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

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

This function takes ownership of the provided event so you should
@/gst_event_ref()/@ it if you want to reuse the event after this call.

MT safe.
-}
elementSendEvent ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to send the event to. -}
    -> Gst.Event.Event
    {- ^ /@event@/: the 'GI.Gst.Structs.Event.Event' to send to the element. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the event was handled. Events that trigger a preroll (such
as flushing seeks and steps) will emit 'GI.Gst.Flags.MessageTypeAsyncDone'. -}
elementSendEvent element event = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    event' <- B.ManagedPtr.disownBoxed event
    result <- gst_element_send_event element' event'
    let result' = (/= 0) result
    touchManagedPtr element
    touchManagedPtr event
    return result'

#if ENABLE_OVERLOADING
data ElementSendEventMethodInfo
instance (signature ~ (Gst.Event.Event -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementSendEventMethodInfo a signature where
    overloadedMethod _ = elementSendEvent

#endif

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

foreign import ccall "gst_element_set_base_time" gst_element_set_base_time ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Word64 ->                               -- time : TBasicType TUInt64
    IO ()

{- |
Set the base time of an element. See 'GI.Gst.Objects.Element.elementGetBaseTime'.

MT safe.
-}
elementSetBaseTime ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> Word64
    {- ^ /@time@/: the base time to set. -}
    -> m ()
elementSetBaseTime element time = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_set_base_time element' time
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementSetBaseTimeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementSetBaseTimeMethodInfo a signature where
    overloadedMethod _ = elementSetBaseTime

#endif

-- method Element::set_bus
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to set the bus of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bus", argType = TInterface (Name {namespace = "Gst", name = "Bus"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstBus to set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_set_bus" gst_element_set_bus ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Bus.Bus ->                      -- bus : TInterface (Name {namespace = "Gst", name = "Bus"})
    IO ()

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

MT safe.
-}
elementSetBus ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Bus.IsBus b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to set the bus of. -}
    -> Maybe (b)
    {- ^ /@bus@/: the 'GI.Gst.Objects.Bus.Bus' to set. -}
    -> m ()
elementSetBus element bus = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    maybeBus <- case bus of
        Nothing -> return nullPtr
        Just jBus -> do
            jBus' <- unsafeManagedPtrCastPtr jBus
            return jBus'
    gst_element_set_bus element' maybeBus
    touchManagedPtr element
    whenJust bus touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data ElementSetBusMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsElement a, Gst.Bus.IsBus b) => O.MethodInfo ElementSetBusMethodInfo a signature where
    overloadedMethod _ = elementSetBus

#endif

-- method Element::set_clock
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to set the clock for.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "clock", argType = TInterface (Name {namespace = "Gst", name = "Clock"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstClock to set for the element.", 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_element_set_clock" gst_element_set_clock ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Clock.Clock ->                  -- clock : TInterface (Name {namespace = "Gst", name = "Clock"})
    IO CInt

{- |
Sets the clock for the element. This function increases the
refcount on the clock. Any previously set clock on the object
is unreffed.
-}
elementSetClock ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, Gst.Clock.IsClock b) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to set the clock for. -}
    -> Maybe (b)
    {- ^ /@clock@/: the 'GI.Gst.Objects.Clock.Clock' to set for the element. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the element accepted the clock. An element can refuse a
clock when it, for example, is not able to slave its internal clock to the
/@clock@/ or when it requires a specific clock to operate.

MT safe. -}
elementSetClock element clock = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    maybeClock <- case clock of
        Nothing -> return nullPtr
        Just jClock -> do
            jClock' <- unsafeManagedPtrCastPtr jClock
            return jClock'
    result <- gst_element_set_clock element' maybeClock
    let result' = (/= 0) result
    touchManagedPtr element
    whenJust clock touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data ElementSetClockMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsElement a, Gst.Clock.IsClock b) => O.MethodInfo ElementSetClockMethodInfo a signature where
    overloadedMethod _ = elementSetClock

#endif

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

foreign import ccall "gst_element_set_context" gst_element_set_context ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Context.Context ->              -- context : TInterface (Name {namespace = "Gst", name = "Context"})
    IO ()

{- |
Sets the context of the element. Increases the refcount of the context.

MT safe.
-}
elementSetContext ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to set the context of. -}
    -> Gst.Context.Context
    {- ^ /@context@/: the 'GI.Gst.Structs.Context.Context' to set. -}
    -> m ()
elementSetContext element context = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    context' <- unsafeManagedPtrGetPtr context
    gst_element_set_context element' context'
    touchManagedPtr element
    touchManagedPtr context
    return ()

#if ENABLE_OVERLOADING
data ElementSetContextMethodInfo
instance (signature ~ (Gst.Context.Context -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementSetContextMethodInfo a signature where
    overloadedMethod _ = elementSetContext

#endif

-- method Element::set_locked_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "locked_state", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to lock the element's state", 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_element_set_locked_state" gst_element_set_locked_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CInt ->                                 -- locked_state : TBasicType TBoolean
    IO CInt

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

Note that this is racy if the state lock of the parent bin is not taken.
The parent bin might\'ve just checked the flag in another thread and as the
next step proceed to change the child element\'s state.

MT safe.
-}
elementSetLockedState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' -}
    -> Bool
    {- ^ /@lockedState@/: 'True' to lock the element\'s state -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the state was changed, 'False' if bad parameters were given
or the elements state-locking needed no change. -}
elementSetLockedState element lockedState = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let lockedState' = (fromIntegral . fromEnum) lockedState
    result <- gst_element_set_locked_state element' lockedState'
    let result' = (/= 0) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementSetLockedStateMethodInfo
instance (signature ~ (Bool -> m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementSetLockedStateMethodInfo a signature where
    overloadedMethod _ = elementSetLockedState

#endif

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

foreign import ccall "gst_element_set_start_time" gst_element_set_start_time ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Word64 ->                               -- time : TBasicType TUInt64
    IO ()

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

Toplevel elements like 'GI.Gst.Objects.Pipeline.Pipeline' will manage the start_time and
base_time on its children. Setting the start_time to 'GI.Gst.Constants.CLOCK_TIME_NONE'
on such a toplevel element will disable the distribution of the base_time to
the children and can be useful if the application manages the base_time
itself, for example if you want to synchronize capture from multiple
pipelines, and you can also ensure that the pipelines have the same clock.

MT safe.
-}
elementSetStartTime ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> Word64
    {- ^ /@time@/: the base time to set. -}
    -> m ()
elementSetStartTime element time = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    gst_element_set_start_time element' time
    touchManagedPtr element
    return ()

#if ENABLE_OVERLOADING
data ElementSetStartTimeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsElement a) => O.MethodInfo ElementSetStartTimeMethodInfo a signature where
    overloadedMethod _ = elementSetStartTime

#endif

-- method Element::set_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement to change state of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "state", argType = TInterface (Name {namespace = "Gst", name = "State"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the element's new #GstState.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "StateChangeReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_set_state" gst_element_set_state ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CUInt ->                                -- state : TInterface (Name {namespace = "Gst", name = "State"})
    IO CUInt

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

This function can return @/GST_STATE_CHANGE_ASYNC/@, in which case the
element will perform the remainder of the state change asynchronously in
another thread.
An application can use 'GI.Gst.Objects.Element.elementGetState' to wait for the completion
of the state change or it can wait for a 'GI.Gst.Flags.MessageTypeAsyncDone' or
'GI.Gst.Flags.MessageTypeStateChanged' on the bus.

State changes to 'GI.Gst.Enums.StateReady' or 'GI.Gst.Enums.StateNull' never return
@/GST_STATE_CHANGE_ASYNC/@.
-}
elementSetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element' to change state of. -}
    -> Gst.Enums.State
    {- ^ /@state@/: the element\'s new 'GI.Gst.Enums.State'. -}
    -> m Gst.Enums.StateChangeReturn
    {- ^ __Returns:__ Result of the state change using 'GI.Gst.Enums.StateChangeReturn'.

MT safe. -}
elementSetState element state = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    let state' = (fromIntegral . fromEnum) state
    result <- gst_element_set_state element' state'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementSetStateMethodInfo
instance (signature ~ (Gst.Enums.State -> m Gst.Enums.StateChangeReturn), MonadIO m, IsElement a) => O.MethodInfo ElementSetStateMethodInfo a signature where
    overloadedMethod _ = elementSetState

#endif

-- method Element::sync_state_with_parent
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement.", 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_element_sync_state_with_parent" gst_element_sync_state_with_parent ::
    Ptr Element ->                          -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    IO CInt

{- |
Tries to change the state of the element to the same as its parent.
If this function returns 'False', the state of element is undefined.
-}
elementSyncStateWithParent ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a) =>
    a
    {- ^ /@element@/: a 'GI.Gst.Objects.Element.Element'. -}
    -> m Bool
    {- ^ __Returns:__ 'True', if the element\'s state could be synced to the parent\'s state.

MT safe. -}
elementSyncStateWithParent element = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    result <- gst_element_sync_state_with_parent element'
    let result' = (/= 0) result
    touchManagedPtr element
    return result'

#if ENABLE_OVERLOADING
data ElementSyncStateWithParentMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsElement a) => O.MethodInfo ElementSyncStateWithParentMethodInfo a signature where
    overloadedMethod _ = elementSyncStateWithParent

#endif

-- method Element::unlink
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source #GstElement to unlink.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sink #GstElement to unlink.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_unlink" gst_element_unlink ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    IO ()

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

If the link has been made using 'GI.Gst.Objects.Element.elementLink', it could have created an
requestpad, which has to be released using 'GI.Gst.Objects.Element.elementReleaseRequestPad'.
-}
elementUnlink ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: the source 'GI.Gst.Objects.Element.Element' to unlink. -}
    -> b
    {- ^ /@dest@/: the sink 'GI.Gst.Objects.Element.Element' to unlink. -}
    -> m ()
elementUnlink src dest = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    dest' <- unsafeManagedPtrCastPtr dest
    gst_element_unlink src' dest'
    touchManagedPtr src
    touchManagedPtr dest
    return ()

#if ENABLE_OVERLOADING
data ElementUnlinkMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementUnlinkMethodInfo a signature where
    overloadedMethod _ = elementUnlink

#endif

-- method Element::unlink_pads
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "src", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a (transfer none): #GstElement containing the source pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "srcpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in source element.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstElement containing the destination pad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destpadname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the #GstPad in destination element.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_unlink_pads" gst_element_unlink_pads ::
    Ptr Element ->                          -- src : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- srcpadname : TBasicType TUTF8
    Ptr Element ->                          -- dest : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- destpadname : TBasicType TUTF8
    IO ()

{- |
Unlinks the two named pads of the source and destination elements.

This is a convenience function for 'GI.Gst.Objects.Pad.padUnlink'.
-}
elementUnlinkPads ::
    (B.CallStack.HasCallStack, MonadIO m, IsElement a, IsElement b) =>
    a
    {- ^ /@src@/: a (transfer none): 'GI.Gst.Objects.Element.Element' containing the source pad. -}
    -> T.Text
    {- ^ /@srcpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in source element. -}
    -> b
    {- ^ /@dest@/: a 'GI.Gst.Objects.Element.Element' containing the destination pad. -}
    -> T.Text
    {- ^ /@destpadname@/: the name of the 'GI.Gst.Objects.Pad.Pad' in destination element. -}
    -> m ()
elementUnlinkPads src srcpadname dest destpadname = liftIO $ do
    src' <- unsafeManagedPtrCastPtr src
    srcpadname' <- textToCString srcpadname
    dest' <- unsafeManagedPtrCastPtr dest
    destpadname' <- textToCString destpadname
    gst_element_unlink_pads src' srcpadname' dest' destpadname'
    touchManagedPtr src
    touchManagedPtr dest
    freeMem srcpadname'
    freeMem destpadname'
    return ()

#if ENABLE_OVERLOADING
data ElementUnlinkPadsMethodInfo
instance (signature ~ (T.Text -> b -> T.Text -> m ()), MonadIO m, IsElement a, IsElement b) => O.MethodInfo ElementUnlinkPadsMethodInfo a signature where
    overloadedMethod _ = elementUnlinkPads

#endif

-- method Element::make_from_uri
-- method type : MemberFunction
-- Args : [Arg {argCName = "type", argType = TInterface (Name {namespace = "Gst", name = "URIType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether to create a source or a sink", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "URI to create an element for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "elementname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Name of created element, can be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Element"}))
-- throws : True
-- Skip return : False

foreign import ccall "gst_element_make_from_uri" gst_element_make_from_uri ::
    CUInt ->                                -- type : TInterface (Name {namespace = "Gst", name = "URIType"})
    CString ->                              -- uri : TBasicType TUTF8
    CString ->                              -- elementname : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Element)

{- |
Creates an element for handling the given URI.
-}
elementMakeFromUri ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Enums.URIType
    {- ^ /@type@/: Whether to create a source or a sink -}
    -> T.Text
    {- ^ /@uri@/: URI to create an element for -}
    -> Maybe (T.Text)
    {- ^ /@elementname@/: Name of created element, can be 'Nothing'. -}
    -> m (Maybe Element)
    {- ^ __Returns:__ a new element or 'Nothing' if none
could be created /(Can throw 'Data.GI.Base.GError.GError')/ -}
elementMakeFromUri type_ uri elementname = liftIO $ do
    let type_' = (fromIntegral . fromEnum) type_
    uri' <- textToCString uri
    maybeElementname <- case elementname of
        Nothing -> return nullPtr
        Just jElementname -> do
            jElementname' <- textToCString jElementname
            return jElementname'
    onException (do
        result <- propagateGError $ gst_element_make_from_uri type_' uri' maybeElementname
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (newObject Element) result'
            return result''
        freeMem uri'
        freeMem maybeElementname
        return maybeResult
     ) (do
        freeMem uri'
        freeMem maybeElementname
     )

#if ENABLE_OVERLOADING
#endif

-- method Element::register
-- method type : MemberFunction
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "#GstPlugin to register the element with, or %NULL for\n    a static element.", 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 "name of elements of this type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rank", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "rank of element (higher rank means more importance when autoplugging)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GType of element to register", 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_element_register" gst_element_register ::
    Ptr Gst.Plugin.Plugin ->                -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    CString ->                              -- name : TBasicType TUTF8
    Word32 ->                               -- rank : TBasicType TUInt
    CGType ->                               -- type : TBasicType TGType
    IO CInt

{- |
Create a new elementfactory capable of instantiating objects of the
/@type@/ and add the factory to /@plugin@/.
-}
elementRegister ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Plugin.IsPlugin a) =>
    Maybe (a)
    {- ^ /@plugin@/: 'GI.Gst.Objects.Plugin.Plugin' to register the element with, or 'Nothing' for
    a static element. -}
    -> T.Text
    {- ^ /@name@/: name of elements of this type -}
    -> Word32
    {- ^ /@rank@/: rank of element (higher rank means more importance when autoplugging) -}
    -> GType
    {- ^ /@type@/: GType of element to register -}
    -> m Bool
    {- ^ __Returns:__ 'True', if the registering succeeded, 'False' on error -}
elementRegister plugin name rank type_ = liftIO $ do
    maybePlugin <- case plugin of
        Nothing -> return nullPtr
        Just jPlugin -> do
            jPlugin' <- unsafeManagedPtrCastPtr jPlugin
            return jPlugin'
    name' <- textToCString name
    let type_' = gtypeToCGType type_
    result <- gst_element_register maybePlugin name' rank type_'
    let result' = (/= 0) result
    whenJust plugin touchManagedPtr
    freeMem name'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Element::state_change_return_get_name
-- method type : MemberFunction
-- Args : [Arg {argCName = "state_ret", argType = TInterface (Name {namespace = "Gst", name = "StateChangeReturn"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstStateChangeReturn to get the name of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_state_change_return_get_name" gst_element_state_change_return_get_name ::
    CUInt ->                                -- state_ret : TInterface (Name {namespace = "Gst", name = "StateChangeReturn"})
    IO CString

{- |
Gets a string representing the given state change result.
-}
elementStateChangeReturnGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Enums.StateChangeReturn
    {- ^ /@stateRet@/: a 'GI.Gst.Enums.StateChangeReturn' to get the name of. -}
    -> m T.Text
    {- ^ __Returns:__ a string with the name of the state
   result. -}
elementStateChangeReturnGetName stateRet = liftIO $ do
    let stateRet' = (fromIntegral . fromEnum) stateRet
    result <- gst_element_state_change_return_get_name stateRet'
    checkUnexpectedReturnNULL "elementStateChangeReturnGetName" result
    result' <- cstringToText result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Element::state_get_name
-- method type : MemberFunction
-- Args : [Arg {argCName = "state", argType = TInterface (Name {namespace = "Gst", name = "State"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstState to get the name of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_element_state_get_name" gst_element_state_get_name ::
    CUInt ->                                -- state : TInterface (Name {namespace = "Gst", name = "State"})
    IO CString

{- |
Gets a string representing the given state.
-}
elementStateGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Enums.State
    {- ^ /@state@/: a 'GI.Gst.Enums.State' to get the name of. -}
    -> m T.Text
    {- ^ __Returns:__ a string with the name of the state. -}
elementStateGetName state = liftIO $ do
    let state' = (fromIntegral . fromEnum) state
    result <- gst_element_state_get_name state'
    checkUnexpectedReturnNULL "elementStateGetName" result
    result' <- cstringToText result
    return result'

#if ENABLE_OVERLOADING
#endif