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

Padtemplates describe the possible media types a pad or an elementfactory can
handle. This allows for both inspection of handled types before loading the
element plugin as well as identifying pads on elements that are not yet
created (request or sometimes pads).

Pad and PadTemplates have 'GI.Gst.Structs.Caps.Caps' attached to it to describe the media type
they are capable of dealing with. 'GI.Gst.Objects.PadTemplate.padTemplateGetCaps' or
@/GST_PAD_TEMPLATE_CAPS()/@ are used to get the caps of a padtemplate. It\'s not
possible to modify the caps of a padtemplate after creation.

PadTemplates have a 'GI.Gst.Enums.PadPresence' property which identifies the lifetime
of the pad and that can be retrieved with @/GST_PAD_TEMPLATE_PRESENCE()/@. Also
the direction of the pad can be retrieved from the 'GI.Gst.Objects.PadTemplate.PadTemplate' with
@/GST_PAD_TEMPLATE_DIRECTION()/@.

The GST_PAD_TEMPLATE_NAME_TEMPLATE () is important for GST_PAD_REQUEST pads
because it has to be used as the name in the 'GI.Gst.Objects.Element.elementGetRequestPad'
call to instantiate a pad from this template.

Padtemplates can be created with 'GI.Gst.Objects.PadTemplate.padTemplateNew' or with
gst_static_pad_template_get (), which creates a 'GI.Gst.Objects.PadTemplate.PadTemplate' from a
'GI.Gst.Structs.StaticPadTemplate.StaticPadTemplate' that can be filled with the
convenient @/GST_STATIC_PAD_TEMPLATE()/@ macro.

A padtemplate can be used to create a pad (see 'GI.Gst.Objects.Pad.padNewFromTemplate'
or gst_pad_new_from_static_template ()) or to add to an element class
(see gst_element_class_add_static_pad_template ()).

The following code example shows the code to create a pad from a padtemplate.

=== /C code/
>
>  GstStaticPadTemplate my_template =
>  GST_STATIC_PAD_TEMPLATE (
>    "sink",          // the name of the pad
>    GST_PAD_SINK,    // the direction of the pad
>    GST_PAD_ALWAYS,  // when this pad will be present
>    GST_STATIC_CAPS (        // the capabilities of the padtemplate
>      "audio/x-raw, "
>        "channels = (int) [ 1, 6 ]"
>    )
>  );
>  void
>  my_method (void)
>  {
>    GstPad *pad;
>    pad = gst_pad_new_from_static_template (&my_template, "sink");
>    ...
>  }


The following example shows you how to add the padtemplate to an
element class, this is usually done in the class_init of the class:

=== /C code/
>
>  static void
>  my_element_class_init (GstMyElementClass *klass)
>  {
>    GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
>
>    gst_element_class_add_static_pad_template (gstelement_class, &my_template);
>  }

-}

module GI.Gst.Objects.PadTemplate
    ( 

-- * Exported types
    PadTemplate(..)                         ,
    IsPadTemplate                           ,
    toPadTemplate                           ,
    noPadTemplate                           ,


 -- * Methods
-- ** getCaps #method:getCaps#
    PadTemplateGetCapsMethodInfo            ,
    padTemplateGetCaps                      ,


-- ** new #method:new#
    padTemplateNew                          ,


-- ** padCreated #method:padCreated#
    PadTemplatePadCreatedMethodInfo         ,
    padTemplatePadCreated                   ,




 -- * Properties
-- ** caps #attr:caps#
    PadTemplateCapsPropertyInfo             ,
    constructPadTemplateCaps                ,
    getPadTemplateCaps                      ,
    padTemplateCaps                         ,


-- ** direction #attr:direction#
    PadTemplateDirectionPropertyInfo        ,
    constructPadTemplateDirection           ,
    getPadTemplateDirection                 ,
    padTemplateDirection                    ,


-- ** nameTemplate #attr:nameTemplate#
    PadTemplateNameTemplatePropertyInfo     ,
    constructPadTemplateNameTemplate        ,
    getPadTemplateNameTemplate              ,
    padTemplateNameTemplate                 ,


-- ** presence #attr:presence#
    PadTemplatePresencePropertyInfo         ,
    constructPadTemplatePresence            ,
    getPadTemplatePresence                  ,
    padTemplatePresence                     ,




 -- * Signals
-- ** padCreated #signal:padCreated#
    C_PadTemplatePadCreatedCallback         ,
    PadTemplatePadCreatedCallback           ,
    PadTemplatePadCreatedSignalInfo         ,
    afterPadTemplatePadCreated              ,
    genClosure_PadTemplatePadCreated        ,
    mk_PadTemplatePadCreatedCallback        ,
    noPadTemplatePadCreatedCallback         ,
    onPadTemplatePadCreated                 ,
    wrap_PadTemplatePadCreatedCallback      ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 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.Structs.Caps as Gst.Caps

newtype PadTemplate = PadTemplate (ManagedPtr PadTemplate)
foreign import ccall "gst_pad_template_get_type"
    c_gst_pad_template_get_type :: IO GType

instance GObject PadTemplate where
    gobjectType _ = c_gst_pad_template_get_type
    

class GObject o => IsPadTemplate o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError PadTemplate a) =>
    IsPadTemplate a
#endif
instance IsPadTemplate PadTemplate
instance Gst.Object.IsObject PadTemplate
instance GObject.Object.IsObject PadTemplate

toPadTemplate :: IsPadTemplate o => o -> IO PadTemplate
toPadTemplate = unsafeCastTo PadTemplate

noPadTemplate :: Maybe PadTemplate
noPadTemplate = Nothing

type family ResolvePadTemplateMethod (t :: Symbol) (o :: *) :: * where
    ResolvePadTemplateMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolvePadTemplateMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePadTemplateMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePadTemplateMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolvePadTemplateMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePadTemplateMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePadTemplateMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolvePadTemplateMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolvePadTemplateMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolvePadTemplateMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolvePadTemplateMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePadTemplateMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePadTemplateMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePadTemplateMethod "padCreated" o = PadTemplatePadCreatedMethodInfo
    ResolvePadTemplateMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolvePadTemplateMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePadTemplateMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolvePadTemplateMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolvePadTemplateMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolvePadTemplateMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePadTemplateMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePadTemplateMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePadTemplateMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolvePadTemplateMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolvePadTemplateMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePadTemplateMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolvePadTemplateMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolvePadTemplateMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePadTemplateMethod "getCaps" o = PadTemplateGetCapsMethodInfo
    ResolvePadTemplateMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolvePadTemplateMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolvePadTemplateMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePadTemplateMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolvePadTemplateMethod "getName" o = Gst.Object.ObjectGetNameMethodInfo
    ResolvePadTemplateMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolvePadTemplateMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolvePadTemplateMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePadTemplateMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePadTemplateMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolvePadTemplateMethod "getValueArray" o = Gst.Object.ObjectGetValueArrayMethodInfo
    ResolvePadTemplateMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolvePadTemplateMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolvePadTemplateMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolvePadTemplateMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePadTemplateMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolvePadTemplateMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolvePadTemplateMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePadTemplateMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePadTemplateMethod t PadTemplate, O.MethodInfo info PadTemplate p) => O.IsLabelProxy t (PadTemplate -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePadTemplateMethod t PadTemplate, O.MethodInfo info PadTemplate p) => O.IsLabel t (PadTemplate -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal PadTemplate::pad-created
type PadTemplatePadCreatedCallback =
    Gst.Pad.Pad ->
    IO ()

noPadTemplatePadCreatedCallback :: Maybe PadTemplatePadCreatedCallback
noPadTemplatePadCreatedCallback = Nothing

type C_PadTemplatePadCreatedCallback =
    Ptr () ->                               -- object
    Ptr Gst.Pad.Pad ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_PadTemplatePadCreatedCallback :: C_PadTemplatePadCreatedCallback -> IO (FunPtr C_PadTemplatePadCreatedCallback)

genClosure_PadTemplatePadCreated :: PadTemplatePadCreatedCallback -> IO Closure
genClosure_PadTemplatePadCreated cb = do
    let cb' = wrap_PadTemplatePadCreatedCallback cb
    mk_PadTemplatePadCreatedCallback cb' >>= newCClosure


wrap_PadTemplatePadCreatedCallback ::
    PadTemplatePadCreatedCallback ->
    Ptr () ->
    Ptr Gst.Pad.Pad ->
    Ptr () ->
    IO ()
wrap_PadTemplatePadCreatedCallback _cb _ pad _ = do
    pad' <- (newObject Gst.Pad.Pad) pad
    _cb  pad'


onPadTemplatePadCreated :: (IsPadTemplate a, MonadIO m) => a -> PadTemplatePadCreatedCallback -> m SignalHandlerId
onPadTemplatePadCreated obj cb = liftIO $ do
    let cb' = wrap_PadTemplatePadCreatedCallback cb
    cb'' <- mk_PadTemplatePadCreatedCallback cb'
    connectSignalFunPtr obj "pad-created" cb'' SignalConnectBefore

afterPadTemplatePadCreated :: (IsPadTemplate a, MonadIO m) => a -> PadTemplatePadCreatedCallback -> m SignalHandlerId
afterPadTemplatePadCreated obj cb = liftIO $ do
    let cb' = wrap_PadTemplatePadCreatedCallback cb
    cb'' <- mk_PadTemplatePadCreatedCallback cb'
    connectSignalFunPtr obj "pad-created" cb'' SignalConnectAfter


-- VVV Prop "caps"
   -- Type: TInterface (Name {namespace = "Gst", name = "Caps"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getPadTemplateCaps :: (MonadIO m, IsPadTemplate o) => o -> m (Maybe Gst.Caps.Caps)
getPadTemplateCaps obj = liftIO $ getObjectPropertyBoxed obj "caps" Gst.Caps.Caps

constructPadTemplateCaps :: (IsPadTemplate o) => Gst.Caps.Caps -> IO (GValueConstruct o)
constructPadTemplateCaps val = constructObjectPropertyBoxed "caps" (Just val)

data PadTemplateCapsPropertyInfo
instance AttrInfo PadTemplateCapsPropertyInfo where
    type AttrAllowedOps PadTemplateCapsPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint PadTemplateCapsPropertyInfo = (~) Gst.Caps.Caps
    type AttrBaseTypeConstraint PadTemplateCapsPropertyInfo = IsPadTemplate
    type AttrGetType PadTemplateCapsPropertyInfo = (Maybe Gst.Caps.Caps)
    type AttrLabel PadTemplateCapsPropertyInfo = "caps"
    type AttrOrigin PadTemplateCapsPropertyInfo = PadTemplate
    attrGet _ = getPadTemplateCaps
    attrSet _ = undefined
    attrConstruct _ = constructPadTemplateCaps
    attrClear _ = undefined

-- VVV Prop "direction"
   -- Type: TInterface (Name {namespace = "Gst", name = "PadDirection"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getPadTemplateDirection :: (MonadIO m, IsPadTemplate o) => o -> m Gst.Enums.PadDirection
getPadTemplateDirection obj = liftIO $ getObjectPropertyEnum obj "direction"

constructPadTemplateDirection :: (IsPadTemplate o) => Gst.Enums.PadDirection -> IO (GValueConstruct o)
constructPadTemplateDirection val = constructObjectPropertyEnum "direction" val

data PadTemplateDirectionPropertyInfo
instance AttrInfo PadTemplateDirectionPropertyInfo where
    type AttrAllowedOps PadTemplateDirectionPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PadTemplateDirectionPropertyInfo = (~) Gst.Enums.PadDirection
    type AttrBaseTypeConstraint PadTemplateDirectionPropertyInfo = IsPadTemplate
    type AttrGetType PadTemplateDirectionPropertyInfo = Gst.Enums.PadDirection
    type AttrLabel PadTemplateDirectionPropertyInfo = "direction"
    type AttrOrigin PadTemplateDirectionPropertyInfo = PadTemplate
    attrGet _ = getPadTemplateDirection
    attrSet _ = undefined
    attrConstruct _ = constructPadTemplateDirection
    attrClear _ = undefined

-- VVV Prop "name-template"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getPadTemplateNameTemplate :: (MonadIO m, IsPadTemplate o) => o -> m (Maybe T.Text)
getPadTemplateNameTemplate obj = liftIO $ getObjectPropertyString obj "name-template"

constructPadTemplateNameTemplate :: (IsPadTemplate o) => T.Text -> IO (GValueConstruct o)
constructPadTemplateNameTemplate val = constructObjectPropertyString "name-template" (Just val)

data PadTemplateNameTemplatePropertyInfo
instance AttrInfo PadTemplateNameTemplatePropertyInfo where
    type AttrAllowedOps PadTemplateNameTemplatePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint PadTemplateNameTemplatePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint PadTemplateNameTemplatePropertyInfo = IsPadTemplate
    type AttrGetType PadTemplateNameTemplatePropertyInfo = (Maybe T.Text)
    type AttrLabel PadTemplateNameTemplatePropertyInfo = "name-template"
    type AttrOrigin PadTemplateNameTemplatePropertyInfo = PadTemplate
    attrGet _ = getPadTemplateNameTemplate
    attrSet _ = undefined
    attrConstruct _ = constructPadTemplateNameTemplate
    attrClear _ = undefined

-- VVV Prop "presence"
   -- Type: TInterface (Name {namespace = "Gst", name = "PadPresence"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getPadTemplatePresence :: (MonadIO m, IsPadTemplate o) => o -> m Gst.Enums.PadPresence
getPadTemplatePresence obj = liftIO $ getObjectPropertyEnum obj "presence"

constructPadTemplatePresence :: (IsPadTemplate o) => Gst.Enums.PadPresence -> IO (GValueConstruct o)
constructPadTemplatePresence val = constructObjectPropertyEnum "presence" val

data PadTemplatePresencePropertyInfo
instance AttrInfo PadTemplatePresencePropertyInfo where
    type AttrAllowedOps PadTemplatePresencePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PadTemplatePresencePropertyInfo = (~) Gst.Enums.PadPresence
    type AttrBaseTypeConstraint PadTemplatePresencePropertyInfo = IsPadTemplate
    type AttrGetType PadTemplatePresencePropertyInfo = Gst.Enums.PadPresence
    type AttrLabel PadTemplatePresencePropertyInfo = "presence"
    type AttrOrigin PadTemplatePresencePropertyInfo = PadTemplate
    attrGet _ = getPadTemplatePresence
    attrSet _ = undefined
    attrConstruct _ = constructPadTemplatePresence
    attrClear _ = undefined

instance O.HasAttributeList PadTemplate
type instance O.AttributeList PadTemplate = PadTemplateAttributeList
type PadTemplateAttributeList = ('[ '("caps", PadTemplateCapsPropertyInfo), '("direction", PadTemplateDirectionPropertyInfo), '("name", Gst.Object.ObjectNamePropertyInfo), '("nameTemplate", PadTemplateNameTemplatePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo), '("presence", PadTemplatePresencePropertyInfo)] :: [(Symbol, *)])

padTemplateCaps :: AttrLabelProxy "caps"
padTemplateCaps = AttrLabelProxy

padTemplateDirection :: AttrLabelProxy "direction"
padTemplateDirection = AttrLabelProxy

padTemplateNameTemplate :: AttrLabelProxy "nameTemplate"
padTemplateNameTemplate = AttrLabelProxy

padTemplatePresence :: AttrLabelProxy "presence"
padTemplatePresence = AttrLabelProxy

data PadTemplatePadCreatedSignalInfo
instance SignalInfo PadTemplatePadCreatedSignalInfo where
    type HaskellCallbackType PadTemplatePadCreatedSignalInfo = PadTemplatePadCreatedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_PadTemplatePadCreatedCallback cb
        cb'' <- mk_PadTemplatePadCreatedCallback cb'
        connectSignalFunPtr obj "pad-created" cb'' connectMode

type instance O.SignalList PadTemplate = PadTemplateSignalList
type PadTemplateSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("padCreated", PadTemplatePadCreatedSignalInfo)] :: [(Symbol, *)])

-- method PadTemplate::new
-- method type : Constructor
-- Args : [Arg {argCName = "name_template", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name template.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "direction", argType = TInterface (Name {namespace = "Gst", name = "PadDirection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPadDirection of the template.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "presence", argType = TInterface (Name {namespace = "Gst", name = "PadPresence"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPadPresence of the pad.", 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 = False, argDoc = Documentation {rawDocText = Just "a #GstCaps set for the template.", 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_pad_template_new" gst_pad_template_new :: 
    CString ->                              -- name_template : TBasicType TUTF8
    CUInt ->                                -- direction : TInterface (Name {namespace = "Gst", name = "PadDirection"})
    CUInt ->                                -- presence : TInterface (Name {namespace = "Gst", name = "PadPresence"})
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr PadTemplate)

{- |
Creates a new pad template with a name according to the given template
and with the given arguments.
-}
padTemplateNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@nameTemplate@/: the name template. -}
    -> Gst.Enums.PadDirection
    {- ^ /@direction@/: the 'GI.Gst.Enums.PadDirection' of the template. -}
    -> Gst.Enums.PadPresence
    {- ^ /@presence@/: the 'GI.Gst.Enums.PadPresence' of the pad. -}
    -> Gst.Caps.Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' set for the template. -}
    -> m PadTemplate
    {- ^ __Returns:__ a new 'GI.Gst.Objects.PadTemplate.PadTemplate'. -}
padTemplateNew nameTemplate direction presence caps = liftIO $ do
    nameTemplate' <- textToCString nameTemplate
    let direction' = (fromIntegral . fromEnum) direction
    let presence' = (fromIntegral . fromEnum) presence
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_pad_template_new nameTemplate' direction' presence' caps'
    checkUnexpectedReturnNULL "padTemplateNew" result
    result' <- (newObject PadTemplate) result
    touchManagedPtr caps
    freeMem nameTemplate'
    return result'

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

foreign import ccall "gst_pad_template_get_caps" gst_pad_template_get_caps :: 
    Ptr PadTemplate ->                      -- templ : TInterface (Name {namespace = "Gst", name = "PadTemplate"})
    IO (Ptr Gst.Caps.Caps)

{- |
Gets the capabilities of the pad template.
-}
padTemplateGetCaps ::
    (B.CallStack.HasCallStack, MonadIO m, IsPadTemplate a) =>
    a
    {- ^ /@templ@/: a 'GI.Gst.Objects.PadTemplate.PadTemplate' to get capabilities of. -}
    -> m Gst.Caps.Caps
    {- ^ __Returns:__ the 'GI.Gst.Structs.Caps.Caps' of the pad template.
Unref after usage. -}
padTemplateGetCaps templ = liftIO $ do
    templ' <- unsafeManagedPtrCastPtr templ
    result <- gst_pad_template_get_caps templ'
    checkUnexpectedReturnNULL "padTemplateGetCaps" result
    result' <- (wrapBoxed Gst.Caps.Caps) result
    touchManagedPtr templ
    return result'

data PadTemplateGetCapsMethodInfo
instance (signature ~ (m Gst.Caps.Caps), MonadIO m, IsPadTemplate a) => O.MethodInfo PadTemplateGetCapsMethodInfo a signature where
    overloadedMethod _ = padTemplateGetCaps

-- method PadTemplate::pad_created
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "templ", argType = TInterface (Name {namespace = "Gst", name = "PadTemplate"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPadTemplate that has been created", 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 that created it", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_pad_template_pad_created" gst_pad_template_pad_created :: 
    Ptr PadTemplate ->                      -- templ : TInterface (Name {namespace = "Gst", name = "PadTemplate"})
    Ptr Gst.Pad.Pad ->                      -- pad : TInterface (Name {namespace = "Gst", name = "Pad"})
    IO ()

{- |
Emit the pad-created signal for this template when created by this pad.
-}
padTemplatePadCreated ::
    (B.CallStack.HasCallStack, MonadIO m, IsPadTemplate a, Gst.Pad.IsPad b) =>
    a
    {- ^ /@templ@/: a 'GI.Gst.Objects.PadTemplate.PadTemplate' that has been created -}
    -> b
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that created it -}
    -> m ()
padTemplatePadCreated templ pad = liftIO $ do
    templ' <- unsafeManagedPtrCastPtr templ
    pad' <- unsafeManagedPtrCastPtr pad
    gst_pad_template_pad_created templ' pad'
    touchManagedPtr templ
    touchManagedPtr pad
    return ()

data PadTemplatePadCreatedMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPadTemplate a, Gst.Pad.IsPad b) => O.MethodInfo PadTemplatePadCreatedMethodInfo a signature where
    overloadedMethod _ = padTemplatePadCreated