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

GhostPads are useful when organizing pipelines with 'GI.Gst.Objects.Bin.Bin' like elements.
The idea here is to create hierarchical element graphs. The bin element
contains a sub-graph. Now one would like to treat the bin-element like any
other 'GI.Gst.Objects.Element.Element'. This is where GhostPads come into play. A GhostPad acts as
a proxy for another pad. Thus the bin can have sink and source ghost-pads
that are associated with sink and source pads of the child elements.

If the target pad is known at creation time, 'GI.Gst.Objects.GhostPad.ghostPadNew' is the
function to use to get a ghost-pad. Otherwise one can use 'GI.Gst.Objects.GhostPad.ghostPadNewNoTarget'
to create the ghost-pad and use 'GI.Gst.Objects.GhostPad.ghostPadSetTarget' to establish the
association later on.

Note that GhostPads add overhead to the data processing of a pipeline.
-}

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

module GI.Gst.Objects.GhostPad
    (

-- * Exported types
    GhostPad(..)                            ,
    IsGhostPad                              ,
    toGhostPad                              ,
    noGhostPad                              ,


 -- * Methods
-- ** activateModeDefault #method:activateModeDefault#

    ghostPadActivateModeDefault             ,


-- ** construct #method:construct#

#if ENABLE_OVERLOADING
    GhostPadConstructMethodInfo             ,
#endif
    ghostPadConstruct                       ,


-- ** getTarget #method:getTarget#

#if ENABLE_OVERLOADING
    GhostPadGetTargetMethodInfo             ,
#endif
    ghostPadGetTarget                       ,


-- ** internalActivateModeDefault #method:internalActivateModeDefault#

    ghostPadInternalActivateModeDefault     ,


-- ** new #method:new#

    ghostPadNew                             ,


-- ** newFromTemplate #method:newFromTemplate#

    ghostPadNewFromTemplate                 ,


-- ** newNoTarget #method:newNoTarget#

    ghostPadNewNoTarget                     ,


-- ** newNoTargetFromTemplate #method:newNoTargetFromTemplate#

    ghostPadNewNoTargetFromTemplate         ,


-- ** setTarget #method:setTarget#

#if ENABLE_OVERLOADING
    GhostPadSetTargetMethodInfo             ,
#endif
    ghostPadSetTarget                       ,




    ) where

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

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

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.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.ProxyPad as Gst.ProxyPad

-- | Memory-managed wrapper type.
newtype GhostPad = GhostPad (ManagedPtr GhostPad)
foreign import ccall "gst_ghost_pad_get_type"
    c_gst_ghost_pad_get_type :: IO GType

instance GObject GhostPad where
    gobjectType = c_gst_ghost_pad_get_type


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

instance O.HasParentTypes GhostPad
type instance O.ParentTypes GhostPad = '[Gst.ProxyPad.ProxyPad, Gst.Pad.Pad, Gst.Object.Object, GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `GhostPad`.
noGhostPad :: Maybe GhostPad
noGhostPad = Nothing

#if ENABLE_OVERLOADING
type family ResolveGhostPadMethod (t :: Symbol) (o :: *) :: * where
    ResolveGhostPadMethod "activateMode" o = Gst.Pad.PadActivateModeMethodInfo
    ResolveGhostPadMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolveGhostPadMethod "addProbe" o = Gst.Pad.PadAddProbeMethodInfo
    ResolveGhostPadMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveGhostPadMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveGhostPadMethod "canLink" o = Gst.Pad.PadCanLinkMethodInfo
    ResolveGhostPadMethod "chain" o = Gst.Pad.PadChainMethodInfo
    ResolveGhostPadMethod "chainList" o = Gst.Pad.PadChainListMethodInfo
    ResolveGhostPadMethod "checkReconfigure" o = Gst.Pad.PadCheckReconfigureMethodInfo
    ResolveGhostPadMethod "construct" o = GhostPadConstructMethodInfo
    ResolveGhostPadMethod "createStreamId" o = Gst.Pad.PadCreateStreamIdMethodInfo
    ResolveGhostPadMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolveGhostPadMethod "eventDefault" o = Gst.Pad.PadEventDefaultMethodInfo
    ResolveGhostPadMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveGhostPadMethod "forward" o = Gst.Pad.PadForwardMethodInfo
    ResolveGhostPadMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveGhostPadMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveGhostPadMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolveGhostPadMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolveGhostPadMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolveGhostPadMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolveGhostPadMethod "hasCurrentCaps" o = Gst.Pad.PadHasCurrentCapsMethodInfo
    ResolveGhostPadMethod "isActive" o = Gst.Pad.PadIsActiveMethodInfo
    ResolveGhostPadMethod "isBlocked" o = Gst.Pad.PadIsBlockedMethodInfo
    ResolveGhostPadMethod "isBlocking" o = Gst.Pad.PadIsBlockingMethodInfo
    ResolveGhostPadMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveGhostPadMethod "isLinked" o = Gst.Pad.PadIsLinkedMethodInfo
    ResolveGhostPadMethod "iterateInternalLinks" o = Gst.Pad.PadIterateInternalLinksMethodInfo
    ResolveGhostPadMethod "link" o = Gst.Pad.PadLinkMethodInfo
    ResolveGhostPadMethod "linkFull" o = Gst.Pad.PadLinkFullMethodInfo
    ResolveGhostPadMethod "linkMaybeGhosting" o = Gst.Pad.PadLinkMaybeGhostingMethodInfo
    ResolveGhostPadMethod "linkMaybeGhostingFull" o = Gst.Pad.PadLinkMaybeGhostingFullMethodInfo
    ResolveGhostPadMethod "markReconfigure" o = Gst.Pad.PadMarkReconfigureMethodInfo
    ResolveGhostPadMethod "needsReconfigure" o = Gst.Pad.PadNeedsReconfigureMethodInfo
    ResolveGhostPadMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveGhostPadMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveGhostPadMethod "pauseTask" o = Gst.Pad.PadPauseTaskMethodInfo
    ResolveGhostPadMethod "peerQuery" o = Gst.Pad.PadPeerQueryMethodInfo
    ResolveGhostPadMethod "peerQueryAcceptCaps" o = Gst.Pad.PadPeerQueryAcceptCapsMethodInfo
    ResolveGhostPadMethod "peerQueryCaps" o = Gst.Pad.PadPeerQueryCapsMethodInfo
    ResolveGhostPadMethod "peerQueryConvert" o = Gst.Pad.PadPeerQueryConvertMethodInfo
    ResolveGhostPadMethod "peerQueryDuration" o = Gst.Pad.PadPeerQueryDurationMethodInfo
    ResolveGhostPadMethod "peerQueryPosition" o = Gst.Pad.PadPeerQueryPositionMethodInfo
    ResolveGhostPadMethod "proxyQueryAcceptCaps" o = Gst.Pad.PadProxyQueryAcceptCapsMethodInfo
    ResolveGhostPadMethod "proxyQueryCaps" o = Gst.Pad.PadProxyQueryCapsMethodInfo
    ResolveGhostPadMethod "pullRange" o = Gst.Pad.PadPullRangeMethodInfo
    ResolveGhostPadMethod "push" o = Gst.Pad.PadPushMethodInfo
    ResolveGhostPadMethod "pushEvent" o = Gst.Pad.PadPushEventMethodInfo
    ResolveGhostPadMethod "pushList" o = Gst.Pad.PadPushListMethodInfo
    ResolveGhostPadMethod "query" o = Gst.Pad.PadQueryMethodInfo
    ResolveGhostPadMethod "queryAcceptCaps" o = Gst.Pad.PadQueryAcceptCapsMethodInfo
    ResolveGhostPadMethod "queryCaps" o = Gst.Pad.PadQueryCapsMethodInfo
    ResolveGhostPadMethod "queryConvert" o = Gst.Pad.PadQueryConvertMethodInfo
    ResolveGhostPadMethod "queryDefault" o = Gst.Pad.PadQueryDefaultMethodInfo
    ResolveGhostPadMethod "queryDuration" o = Gst.Pad.PadQueryDurationMethodInfo
    ResolveGhostPadMethod "queryPosition" o = Gst.Pad.PadQueryPositionMethodInfo
    ResolveGhostPadMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolveGhostPadMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveGhostPadMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolveGhostPadMethod "removeProbe" o = Gst.Pad.PadRemoveProbeMethodInfo
    ResolveGhostPadMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveGhostPadMethod "sendEvent" o = Gst.Pad.PadSendEventMethodInfo
    ResolveGhostPadMethod "startTask" o = Gst.Pad.PadStartTaskMethodInfo
    ResolveGhostPadMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveGhostPadMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveGhostPadMethod "stickyEventsForeach" o = Gst.Pad.PadStickyEventsForeachMethodInfo
    ResolveGhostPadMethod "stopTask" o = Gst.Pad.PadStopTaskMethodInfo
    ResolveGhostPadMethod "storeStickyEvent" o = Gst.Pad.PadStoreStickyEventMethodInfo
    ResolveGhostPadMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolveGhostPadMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolveGhostPadMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveGhostPadMethod "unlink" o = Gst.Pad.PadUnlinkMethodInfo
    ResolveGhostPadMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolveGhostPadMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolveGhostPadMethod "useFixedCaps" o = Gst.Pad.PadUseFixedCapsMethodInfo
    ResolveGhostPadMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveGhostPadMethod "getAllowedCaps" o = Gst.Pad.PadGetAllowedCapsMethodInfo
    ResolveGhostPadMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolveGhostPadMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolveGhostPadMethod "getCurrentCaps" o = Gst.Pad.PadGetCurrentCapsMethodInfo
    ResolveGhostPadMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveGhostPadMethod "getDirection" o = Gst.Pad.PadGetDirectionMethodInfo
    ResolveGhostPadMethod "getElementPrivate" o = Gst.Pad.PadGetElementPrivateMethodInfo
    ResolveGhostPadMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolveGhostPadMethod "getInternal" o = Gst.ProxyPad.ProxyPadGetInternalMethodInfo
    ResolveGhostPadMethod "getLastFlowReturn" o = Gst.Pad.PadGetLastFlowReturnMethodInfo
    ResolveGhostPadMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolveGhostPadMethod "getOffset" o = Gst.Pad.PadGetOffsetMethodInfo
    ResolveGhostPadMethod "getPadTemplate" o = Gst.Pad.PadGetPadTemplateMethodInfo
    ResolveGhostPadMethod "getPadTemplateCaps" o = Gst.Pad.PadGetPadTemplateCapsMethodInfo
    ResolveGhostPadMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolveGhostPadMethod "getParentElement" o = Gst.Pad.PadGetParentElementMethodInfo
    ResolveGhostPadMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolveGhostPadMethod "getPeer" o = Gst.Pad.PadGetPeerMethodInfo
    ResolveGhostPadMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveGhostPadMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveGhostPadMethod "getRange" o = Gst.Pad.PadGetRangeMethodInfo
    ResolveGhostPadMethod "getStickyEvent" o = Gst.Pad.PadGetStickyEventMethodInfo
    ResolveGhostPadMethod "getStream" o = Gst.Pad.PadGetStreamMethodInfo
    ResolveGhostPadMethod "getStreamId" o = Gst.Pad.PadGetStreamIdMethodInfo
    ResolveGhostPadMethod "getTarget" o = GhostPadGetTargetMethodInfo
    ResolveGhostPadMethod "getTaskState" o = Gst.Pad.PadGetTaskStateMethodInfo
    ResolveGhostPadMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolveGhostPadMethod "setActivateFunctionFull" o = Gst.Pad.PadSetActivateFunctionFullMethodInfo
    ResolveGhostPadMethod "setActivatemodeFunctionFull" o = Gst.Pad.PadSetActivatemodeFunctionFullMethodInfo
    ResolveGhostPadMethod "setActive" o = Gst.Pad.PadSetActiveMethodInfo
    ResolveGhostPadMethod "setChainFunctionFull" o = Gst.Pad.PadSetChainFunctionFullMethodInfo
    ResolveGhostPadMethod "setChainListFunctionFull" o = Gst.Pad.PadSetChainListFunctionFullMethodInfo
    ResolveGhostPadMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolveGhostPadMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolveGhostPadMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolveGhostPadMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveGhostPadMethod "setElementPrivate" o = Gst.Pad.PadSetElementPrivateMethodInfo
    ResolveGhostPadMethod "setEventFullFunctionFull" o = Gst.Pad.PadSetEventFullFunctionFullMethodInfo
    ResolveGhostPadMethod "setEventFunctionFull" o = Gst.Pad.PadSetEventFunctionFullMethodInfo
    ResolveGhostPadMethod "setGetrangeFunctionFull" o = Gst.Pad.PadSetGetrangeFunctionFullMethodInfo
    ResolveGhostPadMethod "setIterateInternalLinksFunctionFull" o = Gst.Pad.PadSetIterateInternalLinksFunctionFullMethodInfo
    ResolveGhostPadMethod "setLinkFunctionFull" o = Gst.Pad.PadSetLinkFunctionFullMethodInfo
    ResolveGhostPadMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolveGhostPadMethod "setOffset" o = Gst.Pad.PadSetOffsetMethodInfo
    ResolveGhostPadMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolveGhostPadMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveGhostPadMethod "setQueryFunctionFull" o = Gst.Pad.PadSetQueryFunctionFullMethodInfo
    ResolveGhostPadMethod "setTarget" o = GhostPadSetTargetMethodInfo
    ResolveGhostPadMethod "setUnlinkFunctionFull" o = Gst.Pad.PadSetUnlinkFunctionFullMethodInfo
    ResolveGhostPadMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveGhostPadMethod t GhostPad, O.MethodInfo info GhostPad p) => OL.IsLabel t (GhostPad -> 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

#if ENABLE_OVERLOADING
instance O.HasAttributeList GhostPad
type instance O.AttributeList GhostPad = GhostPadAttributeList
type GhostPadAttributeList = ('[ '("caps", Gst.Pad.PadCapsPropertyInfo), '("direction", Gst.Pad.PadDirectionPropertyInfo), '("name", Gst.Object.ObjectNamePropertyInfo), '("offset", Gst.Pad.PadOffsetPropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo), '("template", Gst.Pad.PadTemplatePropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList GhostPad = GhostPadSignalList
type GhostPadSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("linked", Gst.Pad.PadLinkedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("unlinked", Gst.Pad.PadUnlinkedSignalInfo)] :: [(Symbol, *)])

#endif

-- method GhostPad::new
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the new pad, or %NULL to assign a default name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the pad to ghost.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "GhostPad"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_ghost_pad_new" gst_ghost_pad_new ::
    CString ->                              -- name : TBasicType TUTF8
    Ptr Gst.Pad.Pad ->                      -- target : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO (Ptr GhostPad)

{- |
Create a new ghostpad with /@target@/ as the target. The direction will be taken
from the target pad. /@target@/ must be unlinked.

Will ref the target.
-}
ghostPadNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Pad.IsPad a) =>
    Maybe (T.Text)
    {- ^ /@name@/: the name of the new pad, or 'Nothing' to assign a default name -}
    -> a
    {- ^ /@target@/: the pad to ghost. -}
    -> m (Maybe GhostPad)
    {- ^ __Returns:__ a new 'GI.Gst.Objects.Pad.Pad', or 'Nothing' in
case of an error. -}
ghostPadNew name target = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    target' <- unsafeManagedPtrCastPtr target
    result <- gst_ghost_pad_new maybeName target'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GhostPad) result'
        return result''
    touchManagedPtr target
    freeMem maybeName
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method GhostPad::new_from_template
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the new pad, or %NULL to assign a default name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the pad to ghost.", 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 "the #GstPadTemplate to use on the ghostpad.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "GhostPad"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_ghost_pad_new_from_template" gst_ghost_pad_new_from_template ::
    CString ->                              -- name : TBasicType TUTF8
    Ptr Gst.Pad.Pad ->                      -- target : TInterface (Name {namespace = "Gst", name = "Pad"})
    Ptr Gst.PadTemplate.PadTemplate ->      -- templ : TInterface (Name {namespace = "Gst", name = "PadTemplate"})
    IO (Ptr GhostPad)

{- |
Create a new ghostpad with /@target@/ as the target. The direction will be taken
from the target pad. The template used on the ghostpad will be /@template@/.

Will ref the target.
-}
ghostPadNewFromTemplate ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Pad.IsPad a, Gst.PadTemplate.IsPadTemplate b) =>
    Maybe (T.Text)
    {- ^ /@name@/: the name of the new pad, or 'Nothing' to assign a default name. -}
    -> a
    {- ^ /@target@/: the pad to ghost. -}
    -> b
    {- ^ /@templ@/: the 'GI.Gst.Objects.PadTemplate.PadTemplate' to use on the ghostpad. -}
    -> m (Maybe GhostPad)
    {- ^ __Returns:__ a new 'GI.Gst.Objects.Pad.Pad', or 'Nothing' in
case of an error. -}
ghostPadNewFromTemplate name target templ = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    target' <- unsafeManagedPtrCastPtr target
    templ' <- unsafeManagedPtrCastPtr templ
    result <- gst_ghost_pad_new_from_template maybeName target' templ'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GhostPad) result'
        return result''
    touchManagedPtr target
    touchManagedPtr templ
    freeMem maybeName
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method GhostPad::new_no_target
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the new pad, or %NULL to assign a default name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dir", argType = TInterface (Name {namespace = "Gst", name = "PadDirection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the direction of the ghostpad", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "GhostPad"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_ghost_pad_new_no_target" gst_ghost_pad_new_no_target ::
    CString ->                              -- name : TBasicType TUTF8
    CUInt ->                                -- dir : TInterface (Name {namespace = "Gst", name = "PadDirection"})
    IO (Ptr GhostPad)

{- |
Create a new ghostpad without a target with the given direction.
A target can be set on the ghostpad later with the
'GI.Gst.Objects.GhostPad.ghostPadSetTarget' function.

The created ghostpad will not have a padtemplate.
-}
ghostPadNewNoTarget ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@name@/: the name of the new pad, or 'Nothing' to assign a default name. -}
    -> Gst.Enums.PadDirection
    {- ^ /@dir@/: the direction of the ghostpad -}
    -> m (Maybe GhostPad)
    {- ^ __Returns:__ a new 'GI.Gst.Objects.Pad.Pad', or 'Nothing' in
case of an error. -}
ghostPadNewNoTarget name dir = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    let dir' = (fromIntegral . fromEnum) dir
    result <- gst_ghost_pad_new_no_target maybeName dir'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GhostPad) result'
        return result''
    freeMem maybeName
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method GhostPad::new_no_target_from_template
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the name of the new pad, or %NULL to assign a default name", 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 "the #GstPadTemplate to create the ghostpad from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "GhostPad"}))
-- throws : False
-- Skip return : False

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

{- |
Create a new ghostpad based on /@templ@/, without setting a target. The
direction will be taken from the /@templ@/.
-}
ghostPadNewNoTargetFromTemplate ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.PadTemplate.IsPadTemplate a) =>
    Maybe (T.Text)
    {- ^ /@name@/: the name of the new pad, or 'Nothing' to assign a default name -}
    -> a
    {- ^ /@templ@/: the 'GI.Gst.Objects.PadTemplate.PadTemplate' to create the ghostpad from. -}
    -> m (Maybe GhostPad)
    {- ^ __Returns:__ a new 'GI.Gst.Objects.Pad.Pad', or 'Nothing' in
case of an error. -}
ghostPadNewNoTargetFromTemplate name templ = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    templ' <- unsafeManagedPtrCastPtr templ
    result <- gst_ghost_pad_new_no_target_from_template maybeName templ'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GhostPad) result'
        return result''
    touchManagedPtr templ
    freeMem maybeName
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method GhostPad::construct
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gpad", argType = TInterface (Name {namespace = "Gst", name = "GhostPad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the newly allocated ghost 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_ghost_pad_construct" gst_ghost_pad_construct ::
    Ptr GhostPad ->                         -- gpad : TInterface (Name {namespace = "Gst", name = "GhostPad"})
    IO CInt

{- |
Finish initialization of a newly allocated ghost pad.

This function is most useful in language bindings and when subclassing
'GI.Gst.Objects.GhostPad.GhostPad'; plugin and application developers normally will not call this
function. Call this function directly after a call to g_object_new
(GST_TYPE_GHOST_PAD, \"direction\", /@dir@/, ..., NULL).
-}
ghostPadConstruct ::
    (B.CallStack.HasCallStack, MonadIO m, IsGhostPad a) =>
    a
    {- ^ /@gpad@/: the newly allocated ghost pad -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the construction succeeds, 'False' otherwise. -}
ghostPadConstruct gpad = liftIO $ do
    gpad' <- unsafeManagedPtrCastPtr gpad
    result <- gst_ghost_pad_construct gpad'
    let result' = (/= 0) result
    touchManagedPtr gpad
    return result'

#if ENABLE_OVERLOADING
data GhostPadConstructMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGhostPad a) => O.MethodInfo GhostPadConstructMethodInfo a signature where
    overloadedMethod _ = ghostPadConstruct

#endif

-- method GhostPad::get_target
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gpad", argType = TInterface (Name {namespace = "Gst", name = "GhostPad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstGhostPad", 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_ghost_pad_get_target" gst_ghost_pad_get_target ::
    Ptr GhostPad ->                         -- gpad : TInterface (Name {namespace = "Gst", name = "GhostPad"})
    IO (Ptr Gst.Pad.Pad)

{- |
Get the target pad of /@gpad@/. Unref target pad after usage.
-}
ghostPadGetTarget ::
    (B.CallStack.HasCallStack, MonadIO m, IsGhostPad a) =>
    a
    {- ^ /@gpad@/: the 'GI.Gst.Objects.GhostPad.GhostPad' -}
    -> m (Maybe Gst.Pad.Pad)
    {- ^ __Returns:__ the target 'GI.Gst.Objects.Pad.Pad', can be
'Nothing' if the ghostpad has no target set. Unref target pad after
usage. -}
ghostPadGetTarget gpad = liftIO $ do
    gpad' <- unsafeManagedPtrCastPtr gpad
    result <- gst_ghost_pad_get_target gpad'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gst.Pad.Pad) result'
        return result''
    touchManagedPtr gpad
    return maybeResult

#if ENABLE_OVERLOADING
data GhostPadGetTargetMethodInfo
instance (signature ~ (m (Maybe Gst.Pad.Pad)), MonadIO m, IsGhostPad a) => O.MethodInfo GhostPadGetTargetMethodInfo a signature where
    overloadedMethod _ = ghostPadGetTarget

#endif

-- method GhostPad::set_target
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "gpad", argType = TInterface (Name {namespace = "Gst", name = "GhostPad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstGhostPad", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newtarget", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the new pad target", 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_ghost_pad_set_target" gst_ghost_pad_set_target ::
    Ptr GhostPad ->                         -- gpad : TInterface (Name {namespace = "Gst", name = "GhostPad"})
    Ptr Gst.Pad.Pad ->                      -- newtarget : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO CInt

{- |
Set the new target of the ghostpad /@gpad@/. Any existing target
is unlinked and links to the new target are established. if /@newtarget@/ is
'Nothing' the target will be cleared.
-}
ghostPadSetTarget ::
    (B.CallStack.HasCallStack, MonadIO m, IsGhostPad a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@gpad@/: the 'GI.Gst.Objects.GhostPad.GhostPad' -}
    -> Maybe (b)
    {- ^ /@newtarget@/: the new pad target -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the new target could be set. This function
    can return 'False' when the internal pads could not be linked. -}
ghostPadSetTarget gpad newtarget = liftIO $ do
    gpad' <- unsafeManagedPtrCastPtr gpad
    maybeNewtarget <- case newtarget of
        Nothing -> return nullPtr
        Just jNewtarget -> do
            jNewtarget' <- unsafeManagedPtrCastPtr jNewtarget
            return jNewtarget'
    result <- gst_ghost_pad_set_target gpad' maybeNewtarget
    let result' = (/= 0) result
    touchManagedPtr gpad
    whenJust newtarget touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data GhostPadSetTargetMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsGhostPad a, Gst.Pad.IsPad b) => O.MethodInfo GhostPadSetTargetMethodInfo a signature where
    overloadedMethod _ = ghostPadSetTarget

#endif

-- method GhostPad::activate_mode_default
-- method type : MemberFunction
-- Args : [Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to activate or deactivate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parent of @pad or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "Gst", name = "PadMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the requested activation mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the pad should be active or not.", 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_ghost_pad_activate_mode_default" gst_ghost_pad_activate_mode_default ::
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    Ptr Gst.Object.Object ->                -- parent : TInterface (Name {namespace = "Gst", name = "Object"})
    CUInt ->                                -- mode : TInterface (Name {namespace = "Gst", name = "PadMode"})
    CInt ->                                 -- active : TBasicType TBoolean
    IO CInt

{- |
Invoke the default activate mode function of a ghost pad.
-}
ghostPadActivateModeDefault ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Pad.IsPad a, Gst.Object.IsObject b) =>
    a
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to activate or deactivate. -}
    -> Maybe (b)
    {- ^ /@parent@/: the parent of /@pad@/ or 'Nothing' -}
    -> Gst.Enums.PadMode
    {- ^ /@mode@/: the requested activation mode -}
    -> Bool
    {- ^ /@active@/: whether the pad should be active or not. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the operation was successful. -}
ghostPadActivateModeDefault pad parent mode active = liftIO $ do
    pad' <- unsafeManagedPtrCastPtr pad
    maybeParent <- case parent of
        Nothing -> return nullPtr
        Just jParent -> do
            jParent' <- unsafeManagedPtrCastPtr jParent
            return jParent'
    let mode' = (fromIntegral . fromEnum) mode
    let active' = (fromIntegral . fromEnum) active
    result <- gst_ghost_pad_activate_mode_default pad' maybeParent mode' active'
    let result' = (/= 0) result
    touchManagedPtr pad
    whenJust parent touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
#endif

-- method GhostPad::internal_activate_mode_default
-- method type : MemberFunction
-- Args : [Arg {argCName = "pad", argType = TInterface (Name {namespace = "Gst", name = "Pad"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad to activate or deactivate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parent of @pad or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "Gst", name = "PadMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the requested activation mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the pad should be active or not.", 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_ghost_pad_internal_activate_mode_default" gst_ghost_pad_internal_activate_mode_default ::
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    Ptr Gst.Object.Object ->                -- parent : TInterface (Name {namespace = "Gst", name = "Object"})
    CUInt ->                                -- mode : TInterface (Name {namespace = "Gst", name = "PadMode"})
    CInt ->                                 -- active : TBasicType TBoolean
    IO CInt

{- |
Invoke the default activate mode function of a proxy pad that is
owned by a ghost pad.
-}
ghostPadInternalActivateModeDefault ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Pad.IsPad a, Gst.Object.IsObject b) =>
    a
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' to activate or deactivate. -}
    -> Maybe (b)
    {- ^ /@parent@/: the parent of /@pad@/ or 'Nothing' -}
    -> Gst.Enums.PadMode
    {- ^ /@mode@/: the requested activation mode -}
    -> Bool
    {- ^ /@active@/: whether the pad should be active or not. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the operation was successful. -}
ghostPadInternalActivateModeDefault pad parent mode active = liftIO $ do
    pad' <- unsafeManagedPtrCastPtr pad
    maybeParent <- case parent of
        Nothing -> return nullPtr
        Just jParent -> do
            jParent' <- unsafeManagedPtrCastPtr jParent
            return jParent'
    let mode' = (fromIntegral . fromEnum) mode
    let active' = (fromIntegral . fromEnum) active
    result <- gst_ghost_pad_internal_activate_mode_default pad' maybeParent mode' active'
    let result' = (/= 0) result
    touchManagedPtr pad
    whenJust parent touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
#endif