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

Caps (capabilities) are lightweight refcounted objects describing media types.
They are composed of an array of 'GI.Gst.Structs.Structure.Structure'.

Caps are exposed on 'GI.Gst.Objects.PadTemplate.PadTemplate' to describe all possible types a
given pad can handle. They are also stored in the 'GI.Gst.Objects.Registry.Registry' along with
a description of the 'GI.Gst.Objects.Element.Element'.

Caps are exposed on the element pads using the 'GI.Gst.Objects.Pad.padQueryCaps' pad
function. This function describes the possible types that the pad can
handle or produce at runtime.

A 'GI.Gst.Structs.Caps.Caps' can be constructed with the following code fragment:

=== /C code/
>
>  GstCaps *caps = gst_caps_new_simple ("video/x-raw",
>     "format", G_TYPE_STRING, "I420",
>     "framerate", GST_TYPE_FRACTION, 25, 1,
>     "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
>     "width", G_TYPE_INT, 320,
>     "height", G_TYPE_INT, 240,
>     NULL);


A 'GI.Gst.Structs.Caps.Caps' is fixed when it has no properties with ranges or lists. Use
'GI.Gst.Structs.Caps.capsIsFixed' to test for fixed caps. Fixed caps can be used in a
caps event to notify downstream elements of the current media type.

Various methods exist to work with the media types such as subtracting
or intersecting.

Be aware that the current 'GI.Gst.Structs.Caps.Caps' \/ 'GI.Gst.Structs.Structure.Structure' serialization into string
has limited support for nested 'GI.Gst.Structs.Caps.Caps' \/ 'GI.Gst.Structs.Structure.Structure' fields. It can only
support one level of nesting. Using more levels will lead to unexpected
behavior when using serialization features, such as 'GI.Gst.Structs.Caps.capsToString' or
'GI.Gst.Functions.valueSerialize' and their counterparts.
-}

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

module GI.Gst.Structs.Caps
    (

-- * Exported types
    Caps(..)                                ,
    newZeroCaps                             ,
    noCaps                                  ,


 -- * Methods
-- ** append #method:append#

#if ENABLE_OVERLOADING
    CapsAppendMethodInfo                    ,
#endif
    capsAppend                              ,


-- ** appendStructure #method:appendStructure#

#if ENABLE_OVERLOADING
    CapsAppendStructureMethodInfo           ,
#endif
    capsAppendStructure                     ,


-- ** appendStructureFull #method:appendStructureFull#

#if ENABLE_OVERLOADING
    CapsAppendStructureFullMethodInfo       ,
#endif
    capsAppendStructureFull                 ,


-- ** canIntersect #method:canIntersect#

#if ENABLE_OVERLOADING
    CapsCanIntersectMethodInfo              ,
#endif
    capsCanIntersect                        ,


-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    CapsCopyMethodInfo                      ,
#endif
    capsCopy                                ,


-- ** copyNth #method:copyNth#

#if ENABLE_OVERLOADING
    CapsCopyNthMethodInfo                   ,
#endif
    capsCopyNth                             ,


-- ** filterAndMapInPlace #method:filterAndMapInPlace#

#if ENABLE_OVERLOADING
    CapsFilterAndMapInPlaceMethodInfo       ,
#endif
    capsFilterAndMapInPlace                 ,


-- ** fixate #method:fixate#

#if ENABLE_OVERLOADING
    CapsFixateMethodInfo                    ,
#endif
    capsFixate                              ,


-- ** foreach #method:foreach#

#if ENABLE_OVERLOADING
    CapsForeachMethodInfo                   ,
#endif
    capsForeach                             ,


-- ** fromString #method:fromString#

    capsFromString                          ,


-- ** getFeatures #method:getFeatures#

#if ENABLE_OVERLOADING
    CapsGetFeaturesMethodInfo               ,
#endif
    capsGetFeatures                         ,


-- ** getSize #method:getSize#

#if ENABLE_OVERLOADING
    CapsGetSizeMethodInfo                   ,
#endif
    capsGetSize                             ,


-- ** getStructure #method:getStructure#

#if ENABLE_OVERLOADING
    CapsGetStructureMethodInfo              ,
#endif
    capsGetStructure                        ,


-- ** intersect #method:intersect#

#if ENABLE_OVERLOADING
    CapsIntersectMethodInfo                 ,
#endif
    capsIntersect                           ,


-- ** intersectFull #method:intersectFull#

#if ENABLE_OVERLOADING
    CapsIntersectFullMethodInfo             ,
#endif
    capsIntersectFull                       ,


-- ** isAlwaysCompatible #method:isAlwaysCompatible#

#if ENABLE_OVERLOADING
    CapsIsAlwaysCompatibleMethodInfo        ,
#endif
    capsIsAlwaysCompatible                  ,


-- ** isAny #method:isAny#

#if ENABLE_OVERLOADING
    CapsIsAnyMethodInfo                     ,
#endif
    capsIsAny                               ,


-- ** isEmpty #method:isEmpty#

#if ENABLE_OVERLOADING
    CapsIsEmptyMethodInfo                   ,
#endif
    capsIsEmpty                             ,


-- ** isEqual #method:isEqual#

#if ENABLE_OVERLOADING
    CapsIsEqualMethodInfo                   ,
#endif
    capsIsEqual                             ,


-- ** isEqualFixed #method:isEqualFixed#

#if ENABLE_OVERLOADING
    CapsIsEqualFixedMethodInfo              ,
#endif
    capsIsEqualFixed                        ,


-- ** isFixed #method:isFixed#

#if ENABLE_OVERLOADING
    CapsIsFixedMethodInfo                   ,
#endif
    capsIsFixed                             ,


-- ** isStrictlyEqual #method:isStrictlyEqual#

#if ENABLE_OVERLOADING
    CapsIsStrictlyEqualMethodInfo           ,
#endif
    capsIsStrictlyEqual                     ,


-- ** isSubset #method:isSubset#

#if ENABLE_OVERLOADING
    CapsIsSubsetMethodInfo                  ,
#endif
    capsIsSubset                            ,


-- ** isSubsetStructure #method:isSubsetStructure#

#if ENABLE_OVERLOADING
    CapsIsSubsetStructureMethodInfo         ,
#endif
    capsIsSubsetStructure                   ,


-- ** isSubsetStructureFull #method:isSubsetStructureFull#

#if ENABLE_OVERLOADING
    CapsIsSubsetStructureFullMethodInfo     ,
#endif
    capsIsSubsetStructureFull               ,


-- ** mapInPlace #method:mapInPlace#

#if ENABLE_OVERLOADING
    CapsMapInPlaceMethodInfo                ,
#endif
    capsMapInPlace                          ,


-- ** merge #method:merge#

#if ENABLE_OVERLOADING
    CapsMergeMethodInfo                     ,
#endif
    capsMerge                               ,


-- ** mergeStructure #method:mergeStructure#

#if ENABLE_OVERLOADING
    CapsMergeStructureMethodInfo            ,
#endif
    capsMergeStructure                      ,


-- ** mergeStructureFull #method:mergeStructureFull#

#if ENABLE_OVERLOADING
    CapsMergeStructureFullMethodInfo        ,
#endif
    capsMergeStructureFull                  ,


-- ** newAny #method:newAny#

    capsNewAny                              ,


-- ** newEmpty #method:newEmpty#

    capsNewEmpty                            ,


-- ** newEmptySimple #method:newEmptySimple#

    capsNewEmptySimple                      ,


-- ** normalize #method:normalize#

#if ENABLE_OVERLOADING
    CapsNormalizeMethodInfo                 ,
#endif
    capsNormalize                           ,


-- ** removeStructure #method:removeStructure#

#if ENABLE_OVERLOADING
    CapsRemoveStructureMethodInfo           ,
#endif
    capsRemoveStructure                     ,


-- ** setFeatures #method:setFeatures#

#if ENABLE_OVERLOADING
    CapsSetFeaturesMethodInfo               ,
#endif
    capsSetFeatures                         ,


-- ** setFeaturesSimple #method:setFeaturesSimple#

#if ENABLE_OVERLOADING
    CapsSetFeaturesSimpleMethodInfo         ,
#endif
    capsSetFeaturesSimple                   ,


-- ** setValue #method:setValue#

#if ENABLE_OVERLOADING
    CapsSetValueMethodInfo                  ,
#endif
    capsSetValue                            ,


-- ** simplify #method:simplify#

#if ENABLE_OVERLOADING
    CapsSimplifyMethodInfo                  ,
#endif
    capsSimplify                            ,


-- ** stealStructure #method:stealStructure#

#if ENABLE_OVERLOADING
    CapsStealStructureMethodInfo            ,
#endif
    capsStealStructure                      ,


-- ** subtract #method:subtract#

#if ENABLE_OVERLOADING
    CapsSubtractMethodInfo                  ,
#endif
    capsSubtract                            ,


-- ** toString #method:toString#

#if ENABLE_OVERLOADING
    CapsToStringMethodInfo                  ,
#endif
    capsToString                            ,


-- ** truncate #method:truncate#

#if ENABLE_OVERLOADING
    CapsTruncateMethodInfo                  ,
#endif
    capsTruncate                            ,




 -- * Properties
-- ** miniObject #attr:miniObject#
{- | the parent type
-}
#if ENABLE_OVERLOADING
    caps_miniObject                         ,
#endif
    getCapsMiniObject                       ,




    ) 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.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Structs.CapsFeatures as Gst.CapsFeatures
import {-# SOURCE #-} qualified GI.Gst.Structs.MiniObject as Gst.MiniObject
import {-# SOURCE #-} qualified GI.Gst.Structs.Structure as Gst.Structure

-- | Memory-managed wrapper type.
newtype Caps = Caps (ManagedPtr Caps)
foreign import ccall "gst_caps_get_type" c_gst_caps_get_type ::
    IO GType

instance BoxedObject Caps where
    boxedType _ = c_gst_caps_get_type

-- | Construct a `Caps` struct initialized to zero.
newZeroCaps :: MonadIO m => m Caps
newZeroCaps = liftIO $ callocBoxedBytes 64 >>= wrapBoxed Caps

instance tag ~ 'AttrSet => Constructible Caps tag where
    new _ attrs = do
        o <- newZeroCaps
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `Caps`.
noCaps :: Maybe Caps
noCaps = Nothing

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

@
'Data.GI.Base.Attributes.get' caps #miniObject
@
-}
getCapsMiniObject :: MonadIO m => Caps -> m Gst.MiniObject.MiniObject
getCapsMiniObject s = liftIO $ withManagedPtr s $ \ptr -> do
    let val = ptr `plusPtr` 0 :: (Ptr Gst.MiniObject.MiniObject)
    val' <- (newPtr Gst.MiniObject.MiniObject) val
    return val'

#if ENABLE_OVERLOADING
data CapsMiniObjectFieldInfo
instance AttrInfo CapsMiniObjectFieldInfo where
    type AttrAllowedOps CapsMiniObjectFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint CapsMiniObjectFieldInfo = (~) (Ptr Gst.MiniObject.MiniObject)
    type AttrBaseTypeConstraint CapsMiniObjectFieldInfo = (~) Caps
    type AttrGetType CapsMiniObjectFieldInfo = Gst.MiniObject.MiniObject
    type AttrLabel CapsMiniObjectFieldInfo = "mini_object"
    type AttrOrigin CapsMiniObjectFieldInfo = Caps
    attrGet _ = getCapsMiniObject
    attrSet _ = undefined
    attrConstruct = undefined
    attrClear _ = undefined

caps_miniObject :: AttrLabelProxy "miniObject"
caps_miniObject = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList Caps
type instance O.AttributeList Caps = CapsAttributeList
type CapsAttributeList = ('[ '("miniObject", CapsMiniObjectFieldInfo)] :: [(Symbol, *)])
#endif

-- method Caps::new_any
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_new_any" gst_caps_new_any ::
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' that indicates that it is compatible with
any media format.
-}
capsNewAny ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsNewAny  = liftIO $ do
    result <- gst_caps_new_any
    checkUnexpectedReturnNULL "capsNewAny" result
    result' <- (wrapBoxed Caps) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Caps::new_empty
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_new_empty" gst_caps_new_empty ::
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' that is empty.  That is, the returned
'GI.Gst.Structs.Caps.Caps' contains no media formats.
The 'GI.Gst.Structs.Caps.Caps' is guaranteed to be writable.
Caller is responsible for unreffing the returned caps.
-}
capsNewEmpty ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsNewEmpty  = liftIO $ do
    result <- gst_caps_new_empty
    checkUnexpectedReturnNULL "capsNewEmpty" result
    result' <- (wrapBoxed Caps) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Caps::new_empty_simple
-- method type : Constructor
-- Args : [Arg {argCName = "media_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the media type of the structure", 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_caps_new_empty_simple" gst_caps_new_empty_simple ::
    CString ->                              -- media_type : TBasicType TUTF8
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' that contains one 'GI.Gst.Structs.Structure.Structure' with name
/@mediaType@/.
Caller is responsible for unreffing the returned caps.
-}
capsNewEmptySimple ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@mediaType@/: the media type of the structure -}
    -> m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsNewEmptySimple mediaType = liftIO $ do
    mediaType' <- textToCString mediaType
    result <- gst_caps_new_empty_simple mediaType'
    checkUnexpectedReturnNULL "capsNewEmptySimple" result
    result' <- (wrapBoxed Caps) result
    freeMem mediaType'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Caps::append
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps that will be appended to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_append" gst_caps_append ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO ()

{- |
Appends the structures contained in /@caps2@/ to /@caps1@/. The structures in
/@caps2@/ are not copied -- they are transferred to /@caps1@/, and then /@caps2@/ is
freed. If either caps is ANY, the resulting caps will be ANY.
-}
capsAppend ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: the 'GI.Gst.Structs.Caps.Caps' that will be appended to -}
    -> Caps
    {- ^ /@caps2@/: the 'GI.Gst.Structs.Caps.Caps' to append -}
    -> m ()
capsAppend caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- B.ManagedPtr.disownBoxed caps2
    gst_caps_append caps1' caps2'
    touchManagedPtr caps1
    touchManagedPtr caps2
    return ()

#if ENABLE_OVERLOADING
data CapsAppendMethodInfo
instance (signature ~ (Caps -> m ()), MonadIO m) => O.MethodInfo CapsAppendMethodInfo Caps signature where
    overloadedMethod _ = capsAppend

#endif

-- method Caps::append_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps that will be appended to", 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 "the #GstStructure to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_append_structure" gst_caps_append_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO ()

{- |
Appends /@structure@/ to /@caps@/.  The structure is not copied; /@caps@/
becomes the owner of /@structure@/.
-}
capsAppendStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' that will be appended to -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: the 'GI.Gst.Structs.Structure.Structure' to append -}
    -> m ()
capsAppendStructure caps structure = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    structure' <- B.ManagedPtr.disownBoxed structure
    gst_caps_append_structure caps' structure'
    touchManagedPtr caps
    touchManagedPtr structure
    return ()

#if ENABLE_OVERLOADING
data CapsAppendStructureMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m ()), MonadIO m) => O.MethodInfo CapsAppendStructureMethodInfo Caps signature where
    overloadedMethod _ = capsAppendStructure

#endif

-- method Caps::append_structure_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps that will be appended to", 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 "the #GstStructure to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "features", argType = TInterface (Name {namespace = "Gst", name = "CapsFeatures"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCapsFeatures to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_append_structure_full" gst_caps_append_structure_full ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    Ptr Gst.CapsFeatures.CapsFeatures ->    -- features : TInterface (Name {namespace = "Gst", name = "CapsFeatures"})
    IO ()

{- |
Appends /@structure@/ with /@features@/ to /@caps@/.  The structure is not copied; /@caps@/
becomes the owner of /@structure@/.

/Since: 1.2/
-}
capsAppendStructureFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' that will be appended to -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: the 'GI.Gst.Structs.Structure.Structure' to append -}
    -> Maybe (Gst.CapsFeatures.CapsFeatures)
    {- ^ /@features@/: the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' to append -}
    -> m ()
capsAppendStructureFull caps structure features = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    structure' <- B.ManagedPtr.disownBoxed structure
    maybeFeatures <- case features of
        Nothing -> return nullPtr
        Just jFeatures -> do
            jFeatures' <- B.ManagedPtr.disownBoxed jFeatures
            return jFeatures'
    gst_caps_append_structure_full caps' structure' maybeFeatures
    touchManagedPtr caps
    touchManagedPtr structure
    whenJust features touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data CapsAppendStructureFullMethodInfo
instance (signature ~ (Gst.Structure.Structure -> Maybe (Gst.CapsFeatures.CapsFeatures) -> m ()), MonadIO m) => O.MethodInfo CapsAppendStructureFullMethodInfo Caps signature where
    overloadedMethod _ = capsAppendStructureFull

#endif

-- method Caps::can_intersect
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", 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_caps_can_intersect" gst_caps_can_intersect ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Tries intersecting /@caps1@/ and /@caps2@/ and reports whether the result would not
be empty
-}
capsCanIntersect ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> Caps
    {- ^ /@caps2@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> m Bool
    {- ^ __Returns:__ 'True' if intersection would be not empty -}
capsCanIntersect caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_can_intersect caps1' caps2'
    let result' = (/= 0) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsCanIntersectMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsCanIntersectMethodInfo Caps signature where
    overloadedMethod _ = capsCanIntersect

#endif

-- method Caps::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps.", 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_caps_copy" gst_caps_copy ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' as a copy of the old /@caps@/. The new caps will have a
refcount of 1, owned by the caller. The structures are copied as well.

Note that this function is the semantic equivalent of a @/gst_caps_ref()/@
followed by a @/gst_caps_make_writable()/@. If you only want to hold on to a
reference to the data, you should use @/gst_caps_ref()/@.

When you are finished with the caps, call @/gst_caps_unref()/@ on it.
-}
capsCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps'. -}
    -> m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsCopy caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_copy caps'
    checkUnexpectedReturnNULL "capsCopy" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsCopyMethodInfo
instance (signature ~ (m Caps), MonadIO m) => O.MethodInfo CapsCopyMethodInfo Caps signature where
    overloadedMethod _ = capsCopy

#endif

-- method Caps::copy_nth
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nth", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nth structure to copy", 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_caps_copy_nth" gst_caps_copy_nth ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- nth : TBasicType TUInt
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' and appends a copy of the nth structure
contained in /@caps@/.
-}
capsCopyNth ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to copy -}
    -> Word32
    {- ^ /@nth@/: the nth structure to copy -}
    -> m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsCopyNth caps nth = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_copy_nth caps' nth
    checkUnexpectedReturnNULL "capsCopyNth" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsCopyNthMethodInfo
instance (signature ~ (Word32 -> m Caps), MonadIO m) => O.MethodInfo CapsCopyNthMethodInfo Caps signature where
    overloadedMethod _ = capsCopyNth

#endif

-- method Caps::filter_and_map_in_place
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "CapsFilterMapFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call for each field", 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 "private data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_filter_and_map_in_place" gst_caps_filter_and_map_in_place ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    FunPtr Gst.Callbacks.C_CapsFilterMapFunc -> -- func : TInterface (Name {namespace = "Gst", name = "CapsFilterMapFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Calls the provided function once for each structure and caps feature in the
'GI.Gst.Structs.Caps.Caps'. In contrast to 'GI.Gst.Structs.Caps.capsForeach', the function may modify the
structure and features. In contrast to 'GI.Gst.Structs.Caps.capsFilterAndMapInPlace',
the structure and features are removed from the caps if 'False' is returned
from the function.
The caps must be mutable.

/Since: 1.6/
-}
capsFilterAndMapInPlace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Gst.Callbacks.CapsFilterMapFunc
    {- ^ /@func@/: a function to call for each field -}
    -> m ()
capsFilterAndMapInPlace caps func = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    func' <- Gst.Callbacks.mk_CapsFilterMapFunc (Gst.Callbacks.wrap_CapsFilterMapFunc Nothing (Gst.Callbacks.drop_closures_CapsFilterMapFunc func))
    let userData = nullPtr
    gst_caps_filter_and_map_in_place caps' func' userData
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr caps
    return ()

#if ENABLE_OVERLOADING
data CapsFilterAndMapInPlaceMethodInfo
instance (signature ~ (Gst.Callbacks.CapsFilterMapFunc -> m ()), MonadIO m) => O.MethodInfo CapsFilterAndMapInPlaceMethodInfo Caps signature where
    overloadedMethod _ = capsFilterAndMapInPlace

#endif

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

foreign import ccall "gst_caps_fixate" gst_caps_fixate ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Modifies the given /@caps@/ into a representation with only fixed
values. First the caps will be truncated and then the first structure will be
fixated with 'GI.Gst.Structs.Structure.structureFixate'.

This function takes ownership of /@caps@/ and will call @/gst_caps_make_writable()/@
on it so you must not use /@caps@/ afterwards unless you keep an additional
reference to it with @/gst_caps_ref()/@.
-}
capsFixate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' to fixate -}
    -> m Caps
    {- ^ __Returns:__ the fixated caps -}
capsFixate caps = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    result <- gst_caps_fixate caps'
    checkUnexpectedReturnNULL "capsFixate" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsFixateMethodInfo
instance (signature ~ (m Caps), MonadIO m) => O.MethodInfo CapsFixateMethodInfo Caps signature where
    overloadedMethod _ = capsFixate

#endif

-- method Caps::foreach
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "CapsForeachFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call for each field", 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 "private data", 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_caps_foreach" gst_caps_foreach ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    FunPtr Gst.Callbacks.C_CapsForeachFunc -> -- func : TInterface (Name {namespace = "Gst", name = "CapsForeachFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

{- |
Calls the provided function once for each structure and caps feature in the
'GI.Gst.Structs.Caps.Caps'. The function must not modify the fields.
Also see 'GI.Gst.Structs.Caps.capsMapInPlace' and 'GI.Gst.Structs.Caps.capsFilterAndMapInPlace'.

/Since: 1.6/
-}
capsForeach ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Gst.Callbacks.CapsForeachFunc
    {- ^ /@func@/: a function to call for each field -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the supplied function returns 'True' for each call,
'False' otherwise. -}
capsForeach caps func = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    func' <- Gst.Callbacks.mk_CapsForeachFunc (Gst.Callbacks.wrap_CapsForeachFunc Nothing (Gst.Callbacks.drop_closures_CapsForeachFunc func))
    let userData = nullPtr
    result <- gst_caps_foreach caps' func' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsForeachMethodInfo
instance (signature ~ (Gst.Callbacks.CapsForeachFunc -> m Bool), MonadIO m) => O.MethodInfo CapsForeachMethodInfo Caps signature where
    overloadedMethod _ = capsForeach

#endif

-- method Caps::get_features
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "CapsFeatures"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_get_features" gst_caps_get_features ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- index : TBasicType TUInt
    IO (Ptr Gst.CapsFeatures.CapsFeatures)

{- |
Finds the features in /@caps@/ that has the index /@index@/, and
returns it.

WARNING: This function takes a const GstCaps *, but returns a
non-const GstCapsFeatures *.  This is for programming convenience --
the caller should be aware that structures inside a constant
'GI.Gst.Structs.Caps.Caps' should not be modified. However, if you know the caps
are writable, either because you have just copied them or made
them writable with @/gst_caps_make_writable()/@, you may modify the
features returned in the usual way, e.g. with functions like
'GI.Gst.Structs.CapsFeatures.capsFeaturesAdd'.

You do not need to free or unref the structure returned, it
belongs to the 'GI.Gst.Structs.Caps.Caps'.

/Since: 1.2/
-}
capsGetFeatures ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Word32
    {- ^ /@index@/: the index of the structure -}
    -> m (Maybe Gst.CapsFeatures.CapsFeatures)
    {- ^ __Returns:__ a pointer to the 'GI.Gst.Structs.CapsFeatures.CapsFeatures'
    corresponding to /@index@/ -}
capsGetFeatures caps index = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_get_features caps' index
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Gst.CapsFeatures.CapsFeatures) result'
        return result''
    touchManagedPtr caps
    return maybeResult

#if ENABLE_OVERLOADING
data CapsGetFeaturesMethodInfo
instance (signature ~ (Word32 -> m (Maybe Gst.CapsFeatures.CapsFeatures)), MonadIO m) => O.MethodInfo CapsGetFeaturesMethodInfo Caps signature where
    overloadedMethod _ = capsGetFeatures

#endif

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

foreign import ccall "gst_caps_get_size" gst_caps_get_size ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO Word32

{- |
Gets the number of structures contained in /@caps@/.
-}
capsGetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> m Word32
    {- ^ __Returns:__ the number of structures that /@caps@/ contains -}
capsGetSize caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_get_size caps'
    touchManagedPtr caps
    return result

#if ENABLE_OVERLOADING
data CapsGetSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo CapsGetSizeMethodInfo Caps signature where
    overloadedMethod _ = capsGetSize

#endif

-- method Caps::get_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Structure"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_get_structure" gst_caps_get_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- index : TBasicType TUInt
    IO (Ptr Gst.Structure.Structure)

{- |
Finds the structure in /@caps@/ that has the index /@index@/, and
returns it.

WARNING: This function takes a const GstCaps *, but returns a
non-const GstStructure *.  This is for programming convenience --
the caller should be aware that structures inside a constant
'GI.Gst.Structs.Caps.Caps' should not be modified. However, if you know the caps
are writable, either because you have just copied them or made
them writable with @/gst_caps_make_writable()/@, you may modify the
structure returned in the usual way, e.g. with functions like
@/gst_structure_set()/@.

You do not need to free or unref the structure returned, it
belongs to the 'GI.Gst.Structs.Caps.Caps'.
-}
capsGetStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Word32
    {- ^ /@index@/: the index of the structure -}
    -> m Gst.Structure.Structure
    {- ^ __Returns:__ a pointer to the 'GI.Gst.Structs.Structure.Structure' corresponding
    to /@index@/ -}
capsGetStructure caps index = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_get_structure caps' index
    checkUnexpectedReturnNULL "capsGetStructure" result
    result' <- (newBoxed Gst.Structure.Structure) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsGetStructureMethodInfo
instance (signature ~ (Word32 -> m Gst.Structure.Structure), MonadIO m) => O.MethodInfo CapsGetStructureMethodInfo Caps signature where
    overloadedMethod _ = capsGetStructure

#endif

-- method Caps::intersect
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", 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_caps_intersect" gst_caps_intersect ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' that contains all the formats that are common
to both /@caps1@/ and /@caps2@/. Defaults to 'GI.Gst.Enums.CapsIntersectModeZigZag' mode.
-}
capsIntersect ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> Caps
    {- ^ /@caps2@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsIntersect caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_intersect caps1' caps2'
    checkUnexpectedReturnNULL "capsIntersect" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIntersectMethodInfo
instance (signature ~ (Caps -> m Caps), MonadIO m) => O.MethodInfo CapsIntersectMethodInfo Caps signature where
    overloadedMethod _ = capsIntersect

#endif

-- method Caps::intersect_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps to intersect", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "Gst", name = "CapsIntersectMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The intersection algorithm/mode to use", 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_caps_intersect_full" gst_caps_intersect_full ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    CUInt ->                                -- mode : TInterface (Name {namespace = "Gst", name = "CapsIntersectMode"})
    IO (Ptr Caps)

{- |
Creates a new 'GI.Gst.Structs.Caps.Caps' that contains all the formats that are common
to both /@caps1@/ and /@caps2@/, the order is defined by the 'GI.Gst.Enums.CapsIntersectMode'
used.
-}
capsIntersectFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> Caps
    {- ^ /@caps2@/: a 'GI.Gst.Structs.Caps.Caps' to intersect -}
    -> Gst.Enums.CapsIntersectMode
    {- ^ /@mode@/: The intersection algorithm\/mode to use -}
    -> m Caps
    {- ^ __Returns:__ the new 'GI.Gst.Structs.Caps.Caps' -}
capsIntersectFull caps1 caps2 mode = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    let mode' = (fromIntegral . fromEnum) mode
    result <- gst_caps_intersect_full caps1' caps2' mode'
    checkUnexpectedReturnNULL "capsIntersectFull" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIntersectFullMethodInfo
instance (signature ~ (Caps -> Gst.Enums.CapsIntersectMode -> m Caps), MonadIO m) => O.MethodInfo CapsIntersectFullMethodInfo Caps signature where
    overloadedMethod _ = capsIntersectFull

#endif

-- method Caps::is_always_compatible
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", 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_caps_is_always_compatible" gst_caps_is_always_compatible ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
A given 'GI.Gst.Structs.Caps.Caps' structure is always compatible with another if
every media format that is in the first is also contained in the
second.  That is, /@caps1@/ is a subset of /@caps2@/.
-}
capsIsAlwaysCompatible ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> Caps
    {- ^ /@caps2@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@caps1@/ is a subset of /@caps2@/. -}
capsIsAlwaysCompatible caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_is_always_compatible caps1' caps2'
    let result' = (/= 0) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIsAlwaysCompatibleMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsIsAlwaysCompatibleMethodInfo Caps signature where
    overloadedMethod _ = capsIsAlwaysCompatible

#endif

-- method Caps::is_any
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", 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_caps_is_any" gst_caps_is_any ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Determines if /@caps@/ represents any media format.
-}
capsIsAny ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@caps@/ represents any format. -}
capsIsAny caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_is_any caps'
    let result' = (/= 0) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsIsAnyMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo CapsIsAnyMethodInfo Caps signature where
    overloadedMethod _ = capsIsAny

#endif

-- method Caps::is_empty
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", 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_caps_is_empty" gst_caps_is_empty ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Determines if /@caps@/ represents no media formats.
-}
capsIsEmpty ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@caps@/ represents no formats. -}
capsIsEmpty caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_is_empty caps'
    let result' = (/= 0) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsIsEmptyMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo CapsIsEmptyMethodInfo Caps signature where
    overloadedMethod _ = capsIsEmpty

#endif

-- method Caps::is_equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #GstCaps", 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_caps_is_equal" gst_caps_is_equal ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Checks if the given caps represent the same set of caps.
-}
capsIsEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Caps
    {- ^ /@caps2@/: another 'GI.Gst.Structs.Caps.Caps' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if both caps are equal. -}
capsIsEqual caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_is_equal caps1' caps2'
    let result' = (/= 0) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIsEqualMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsIsEqualMethodInfo Caps signature where
    overloadedMethod _ = capsIsEqual

#endif

-- method Caps::is_equal_fixed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", 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_caps_is_equal_fixed" gst_caps_is_equal_fixed ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Tests if two 'GI.Gst.Structs.Caps.Caps' are equal.  This function only works on fixed
'GI.Gst.Structs.Caps.Caps'.
-}
capsIsEqualFixed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> Caps
    {- ^ /@caps2@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the arguments represent the same format -}
capsIsEqualFixed caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_is_equal_fixed caps1' caps2'
    let result' = (/= 0) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIsEqualFixedMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsIsEqualFixedMethodInfo Caps signature where
    overloadedMethod _ = capsIsEqualFixed

#endif

-- method Caps::is_fixed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to test", 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_caps_is_fixed" gst_caps_is_fixed ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Fixed 'GI.Gst.Structs.Caps.Caps' describe exactly one format, that is, they have exactly
one structure, and each field in the structure describes a fixed type.
Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
-}
capsIsFixed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to test -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@caps@/ is fixed -}
capsIsFixed caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_is_fixed caps'
    let result' = (/= 0) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsIsFixedMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo CapsIsFixedMethodInfo Caps signature where
    overloadedMethod _ = capsIsFixed

#endif

-- method Caps::is_strictly_equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #GstCaps", 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_caps_is_strictly_equal" gst_caps_is_strictly_equal ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Checks if the given caps are exactly the same set of caps.
-}
capsIsStrictlyEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Caps
    {- ^ /@caps2@/: another 'GI.Gst.Structs.Caps.Caps' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if both caps are strictly equal. -}
capsIsStrictlyEqual caps1 caps2 = liftIO $ do
    caps1' <- unsafeManagedPtrGetPtr caps1
    caps2' <- unsafeManagedPtrGetPtr caps2
    result <- gst_caps_is_strictly_equal caps1' caps2'
    let result' = (/= 0) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsIsStrictlyEqualMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsIsStrictlyEqualMethodInfo Caps signature where
    overloadedMethod _ = capsIsStrictlyEqual

#endif

-- method Caps::is_subset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subset", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "superset", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a potentially greater #GstCaps", 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_caps_is_subset" gst_caps_is_subset ::
    Ptr Caps ->                             -- subset : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- superset : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Checks if all caps represented by /@subset@/ are also represented by /@superset@/.
-}
capsIsSubset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@subset@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Caps
    {- ^ /@superset@/: a potentially greater 'GI.Gst.Structs.Caps.Caps' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@subset@/ is a subset of /@superset@/ -}
capsIsSubset subset superset = liftIO $ do
    subset' <- unsafeManagedPtrGetPtr subset
    superset' <- unsafeManagedPtrGetPtr superset
    result <- gst_caps_is_subset subset' superset'
    let result' = (/= 0) result
    touchManagedPtr subset
    touchManagedPtr superset
    return result'

#if ENABLE_OVERLOADING
data CapsIsSubsetMethodInfo
instance (signature ~ (Caps -> m Bool), MonadIO m) => O.MethodInfo CapsIsSubsetMethodInfo Caps signature where
    overloadedMethod _ = capsIsSubset

#endif

-- method Caps::is_subset_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", 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 "a potential #GstStructure subset of @caps", 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_caps_is_subset_structure" gst_caps_is_subset_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO CInt

{- |
Checks if /@structure@/ is a subset of /@caps@/. See 'GI.Gst.Structs.Caps.capsIsSubset'
for more information.
-}
capsIsSubsetStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: a potential 'GI.Gst.Structs.Structure.Structure' subset of /@caps@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@structure@/ is a subset of /@caps@/ -}
capsIsSubsetStructure caps structure = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    structure' <- unsafeManagedPtrGetPtr structure
    result <- gst_caps_is_subset_structure caps' structure'
    let result' = (/= 0) result
    touchManagedPtr caps
    touchManagedPtr structure
    return result'

#if ENABLE_OVERLOADING
data CapsIsSubsetStructureMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m Bool), MonadIO m) => O.MethodInfo CapsIsSubsetStructureMethodInfo Caps signature where
    overloadedMethod _ = capsIsSubsetStructure

#endif

-- method Caps::is_subset_structure_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", 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 "a potential #GstStructure subset of @caps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "features", argType = TInterface (Name {namespace = "Gst", name = "CapsFeatures"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GstCapsFeatures for @structure", 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_caps_is_subset_structure_full" gst_caps_is_subset_structure_full ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    Ptr Gst.CapsFeatures.CapsFeatures ->    -- features : TInterface (Name {namespace = "Gst", name = "CapsFeatures"})
    IO CInt

{- |
Checks if /@structure@/ is a subset of /@caps@/. See 'GI.Gst.Structs.Caps.capsIsSubset'
for more information.

/Since: 1.2/
-}
capsIsSubsetStructureFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: a potential 'GI.Gst.Structs.Structure.Structure' subset of /@caps@/ -}
    -> Maybe (Gst.CapsFeatures.CapsFeatures)
    {- ^ /@features@/: a 'GI.Gst.Structs.CapsFeatures.CapsFeatures' for /@structure@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@structure@/ is a subset of /@caps@/ -}
capsIsSubsetStructureFull caps structure features = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    structure' <- unsafeManagedPtrGetPtr structure
    maybeFeatures <- case features of
        Nothing -> return nullPtr
        Just jFeatures -> do
            jFeatures' <- unsafeManagedPtrGetPtr jFeatures
            return jFeatures'
    result <- gst_caps_is_subset_structure_full caps' structure' maybeFeatures
    let result' = (/= 0) result
    touchManagedPtr caps
    touchManagedPtr structure
    whenJust features touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data CapsIsSubsetStructureFullMethodInfo
instance (signature ~ (Gst.Structure.Structure -> Maybe (Gst.CapsFeatures.CapsFeatures) -> m Bool), MonadIO m) => O.MethodInfo CapsIsSubsetStructureFullMethodInfo Caps signature where
    overloadedMethod _ = capsIsSubsetStructureFull

#endif

-- method Caps::map_in_place
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Gst", name = "CapsMapFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call for each field", 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 "private data", 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_caps_map_in_place" gst_caps_map_in_place ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    FunPtr Gst.Callbacks.C_CapsMapFunc ->   -- func : TInterface (Name {namespace = "Gst", name = "CapsMapFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

{- |
Calls the provided function once for each structure and caps feature in the
'GI.Gst.Structs.Caps.Caps'. In contrast to 'GI.Gst.Structs.Caps.capsForeach', the function may modify but not
delete the structures and features. The caps must be mutable.

/Since: 1.6/
-}
capsMapInPlace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Gst.Callbacks.CapsMapFunc
    {- ^ /@func@/: a function to call for each field -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the supplied function returns 'True' for each call,
'False' otherwise. -}
capsMapInPlace caps func = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    func' <- Gst.Callbacks.mk_CapsMapFunc (Gst.Callbacks.wrap_CapsMapFunc Nothing (Gst.Callbacks.drop_closures_CapsMapFunc func))
    let userData = nullPtr
    result <- gst_caps_map_in_place caps' func' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr func'
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsMapInPlaceMethodInfo
instance (signature ~ (Gst.Callbacks.CapsMapFunc -> m Bool), MonadIO m) => O.MethodInfo CapsMapInPlaceMethodInfo Caps signature where
    overloadedMethod _ = capsMapInPlace

#endif

-- method Caps::merge
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps1", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps that will take the new entries", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "caps2", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to merge in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_merge" gst_caps_merge ::
    Ptr Caps ->                             -- caps1 : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- caps2 : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Appends the structures contained in /@caps2@/ to /@caps1@/ if they are not yet
expressed by /@caps1@/. The structures in /@caps2@/ are not copied -- they are
transferred to a writable copy of /@caps1@/, and then /@caps2@/ is freed.
If either caps is ANY, the resulting caps will be ANY.
-}
capsMerge ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps1@/: the 'GI.Gst.Structs.Caps.Caps' that will take the new entries -}
    -> Caps
    {- ^ /@caps2@/: the 'GI.Gst.Structs.Caps.Caps' to merge in -}
    -> m Caps
    {- ^ __Returns:__ the merged caps. -}
capsMerge caps1 caps2 = liftIO $ do
    caps1' <- B.ManagedPtr.disownBoxed caps1
    caps2' <- B.ManagedPtr.disownBoxed caps2
    result <- gst_caps_merge caps1' caps2'
    checkUnexpectedReturnNULL "capsMerge" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps1
    touchManagedPtr caps2
    return result'

#if ENABLE_OVERLOADING
data CapsMergeMethodInfo
instance (signature ~ (Caps -> m Caps), MonadIO m) => O.MethodInfo CapsMergeMethodInfo Caps signature where
    overloadedMethod _ = capsMerge

#endif

-- method Caps::merge_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to merge into", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "structure", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstStructure to merge", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_merge_structure" gst_caps_merge_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO (Ptr Caps)

{- |
Appends /@structure@/ to /@caps@/ if its not already expressed by /@caps@/.
-}
capsMergeStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to merge into -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: the 'GI.Gst.Structs.Structure.Structure' to merge -}
    -> m Caps
    {- ^ __Returns:__ the merged caps. -}
capsMergeStructure caps structure = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    structure' <- B.ManagedPtr.disownBoxed structure
    result <- gst_caps_merge_structure caps' structure'
    checkUnexpectedReturnNULL "capsMergeStructure" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    touchManagedPtr structure
    return result'

#if ENABLE_OVERLOADING
data CapsMergeStructureMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m Caps), MonadIO m) => O.MethodInfo CapsMergeStructureMethodInfo Caps signature where
    overloadedMethod _ = capsMergeStructure

#endif

-- method Caps::merge_structure_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to merge into", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "structure", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstStructure to merge", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "features", argType = TInterface (Name {namespace = "Gst", name = "CapsFeatures"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCapsFeatures to merge", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_merge_structure_full" gst_caps_merge_structure_full ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.Structure.Structure ->          -- structure : TInterface (Name {namespace = "Gst", name = "Structure"})
    Ptr Gst.CapsFeatures.CapsFeatures ->    -- features : TInterface (Name {namespace = "Gst", name = "CapsFeatures"})
    IO (Ptr Caps)

{- |
Appends /@structure@/ with /@features@/ to /@caps@/ if its not already expressed by /@caps@/.

/Since: 1.2/
-}
capsMergeStructureFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to merge into -}
    -> Gst.Structure.Structure
    {- ^ /@structure@/: the 'GI.Gst.Structs.Structure.Structure' to merge -}
    -> Maybe (Gst.CapsFeatures.CapsFeatures)
    {- ^ /@features@/: the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' to merge -}
    -> m Caps
    {- ^ __Returns:__ the merged caps. -}
capsMergeStructureFull caps structure features = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    structure' <- B.ManagedPtr.disownBoxed structure
    maybeFeatures <- case features of
        Nothing -> return nullPtr
        Just jFeatures -> do
            jFeatures' <- B.ManagedPtr.disownBoxed jFeatures
            return jFeatures'
    result <- gst_caps_merge_structure_full caps' structure' maybeFeatures
    checkUnexpectedReturnNULL "capsMergeStructureFull" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    touchManagedPtr structure
    whenJust features touchManagedPtr
    return result'

#if ENABLE_OVERLOADING
data CapsMergeStructureFullMethodInfo
instance (signature ~ (Gst.Structure.Structure -> Maybe (Gst.CapsFeatures.CapsFeatures) -> m Caps), MonadIO m) => O.MethodInfo CapsMergeStructureFullMethodInfo Caps signature where
    overloadedMethod _ = capsMergeStructureFull

#endif

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

foreign import ccall "gst_caps_normalize" gst_caps_normalize ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Returns a 'GI.Gst.Structs.Caps.Caps' that represents the same set of formats as
/@caps@/, but contains no lists.  Each list is expanded into separate
/@gstStructures@/.

This function takes ownership of /@caps@/ and will call @/gst_caps_make_writable()/@
on it so you must not use /@caps@/ afterwards unless you keep an additional
reference to it with @/gst_caps_ref()/@.
-}
capsNormalize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' to normalize -}
    -> m Caps
    {- ^ __Returns:__ the normalized 'GI.Gst.Structs.Caps.Caps' -}
capsNormalize caps = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    result <- gst_caps_normalize caps'
    checkUnexpectedReturnNULL "capsNormalize" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsNormalizeMethodInfo
instance (signature ~ (m Caps), MonadIO m) => O.MethodInfo CapsNormalizeMethodInfo Caps signature where
    overloadedMethod _ = capsNormalize

#endif

-- method Caps::remove_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to remove from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "idx", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Index of the structure 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_caps_remove_structure" gst_caps_remove_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- idx : TBasicType TUInt
    IO ()

{- |
removes the structure with the given index from the list of structures
contained in /@caps@/.
-}
capsRemoveStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to remove from -}
    -> Word32
    {- ^ /@idx@/: Index of the structure to remove -}
    -> m ()
capsRemoveStructure caps idx = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    gst_caps_remove_structure caps' idx
    touchManagedPtr caps
    return ()

#if ENABLE_OVERLOADING
data CapsRemoveStructureMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m) => O.MethodInfo CapsRemoveStructureMethodInfo Caps signature where
    overloadedMethod _ = capsRemoveStructure

#endif

-- method Caps::set_features
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the structure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "features", argType = TInterface (Name {namespace = "Gst", name = "CapsFeatures"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCapsFeatures to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_set_features" gst_caps_set_features ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- index : TBasicType TUInt
    Ptr Gst.CapsFeatures.CapsFeatures ->    -- features : TInterface (Name {namespace = "Gst", name = "CapsFeatures"})
    IO ()

{- |
Sets the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' /@features@/ for the structure at /@index@/.

/Since: 1.2/
-}
capsSetFeatures ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Word32
    {- ^ /@index@/: the index of the structure -}
    -> Maybe (Gst.CapsFeatures.CapsFeatures)
    {- ^ /@features@/: the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' to set -}
    -> m ()
capsSetFeatures caps index features = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    maybeFeatures <- case features of
        Nothing -> return nullPtr
        Just jFeatures -> do
            jFeatures' <- B.ManagedPtr.disownBoxed jFeatures
            return jFeatures'
    gst_caps_set_features caps' index maybeFeatures
    touchManagedPtr caps
    whenJust features touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data CapsSetFeaturesMethodInfo
instance (signature ~ (Word32 -> Maybe (Gst.CapsFeatures.CapsFeatures) -> m ()), MonadIO m) => O.MethodInfo CapsSetFeaturesMethodInfo Caps signature where
    overloadedMethod _ = capsSetFeatures

#endif

-- method Caps::set_features_simple
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "features", argType = TInterface (Name {namespace = "Gst", name = "CapsFeatures"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCapsFeatures to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_set_features_simple" gst_caps_set_features_simple ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Gst.CapsFeatures.CapsFeatures ->    -- features : TInterface (Name {namespace = "Gst", name = "CapsFeatures"})
    IO ()

{- |
Sets the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' /@features@/ for all the structures of /@caps@/.

/Since: 1.16/
-}
capsSetFeaturesSimple ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> Maybe (Gst.CapsFeatures.CapsFeatures)
    {- ^ /@features@/: the 'GI.Gst.Structs.CapsFeatures.CapsFeatures' to set -}
    -> m ()
capsSetFeaturesSimple caps features = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    maybeFeatures <- case features of
        Nothing -> return nullPtr
        Just jFeatures -> do
            jFeatures' <- B.ManagedPtr.disownBoxed jFeatures
            return jFeatures'
    gst_caps_set_features_simple caps' maybeFeatures
    touchManagedPtr caps
    whenJust features touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data CapsSetFeaturesSimpleMethodInfo
instance (signature ~ (Maybe (Gst.CapsFeatures.CapsFeatures) -> m ()), MonadIO m) => O.MethodInfo CapsSetFeaturesSimpleMethodInfo Caps signature where
    overloadedMethod _ = capsSetFeaturesSimple

#endif

-- method Caps::set_value
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a writable caps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "field", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of the field to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TInterface (Name {namespace = "GObject", name = "Value"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "value to set the field to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_set_value" gst_caps_set_value ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    CString ->                              -- field : TBasicType TUTF8
    Ptr GValue ->                           -- value : TInterface (Name {namespace = "GObject", name = "Value"})
    IO ()

{- |
Sets the given /@field@/ on all structures of /@caps@/ to the given /@value@/.
This is a convenience function for calling 'GI.Gst.Structs.Structure.structureSetValue' on
all structures of /@caps@/.
-}
capsSetValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a writable caps -}
    -> T.Text
    {- ^ /@field@/: name of the field to set -}
    -> GValue
    {- ^ /@value@/: value to set the field to -}
    -> m ()
capsSetValue caps field value = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    field' <- textToCString field
    value' <- unsafeManagedPtrGetPtr value
    gst_caps_set_value caps' field' value'
    touchManagedPtr caps
    touchManagedPtr value
    freeMem field'
    return ()

#if ENABLE_OVERLOADING
data CapsSetValueMethodInfo
instance (signature ~ (T.Text -> GValue -> m ()), MonadIO m) => O.MethodInfo CapsSetValueMethodInfo Caps signature where
    overloadedMethod _ = capsSetValue

#endif

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

foreign import ccall "gst_caps_simplify" gst_caps_simplify ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Converts the given /@caps@/ into a representation that represents the
same set of formats, but in a simpler form.  Component structures that are
identical are merged.  Component structures that have values that can be
merged are also merged.

This function takes ownership of /@caps@/ and will call @/gst_caps_make_writable()/@
on it if necessary, so you must not use /@caps@/ afterwards unless you keep an
additional reference to it with @/gst_caps_ref()/@.

This method does not preserve the original order of /@caps@/.
-}
capsSimplify ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' to simplify -}
    -> m Caps
    {- ^ __Returns:__ The simplified caps. -}
capsSimplify caps = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    result <- gst_caps_simplify caps'
    checkUnexpectedReturnNULL "capsSimplify" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsSimplifyMethodInfo
instance (signature ~ (m Caps), MonadIO m) => O.MethodInfo CapsSimplifyMethodInfo Caps signature where
    overloadedMethod _ = capsSimplify

#endif

-- method Caps::steal_structure
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to retrieve from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Index of the structure to retrieve", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Structure"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_steal_structure" gst_caps_steal_structure ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- index : TBasicType TUInt
    IO (Ptr Gst.Structure.Structure)

{- |
Retrieves the structure with the given index from the list of structures
contained in /@caps@/. The caller becomes the owner of the returned structure.
-}
capsStealStructure ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to retrieve from -}
    -> Word32
    {- ^ /@index@/: Index of the structure to retrieve -}
    -> m (Maybe Gst.Structure.Structure)
    {- ^ __Returns:__ a pointer to the 'GI.Gst.Structs.Structure.Structure'
    corresponding to /@index@/. -}
capsStealStructure caps index = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_steal_structure caps' index
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gst.Structure.Structure) result'
        return result''
    touchManagedPtr caps
    return maybeResult

#if ENABLE_OVERLOADING
data CapsStealStructureMethodInfo
instance (signature ~ (Word32 -> m (Maybe Gst.Structure.Structure)), MonadIO m) => O.MethodInfo CapsStealStructureMethodInfo Caps signature where
    overloadedMethod _ = capsStealStructure

#endif

-- method Caps::subtract
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "minuend", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstCaps to subtract from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "subtrahend", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstCaps to subtract", 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_caps_subtract" gst_caps_subtract ::
    Ptr Caps ->                             -- minuend : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Caps ->                             -- subtrahend : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Subtracts the /@subtrahend@/ from the /@minuend@/.
> This function does not work reliably if optional properties for caps
> are included on one caps and omitted on the other.
-}
capsSubtract ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@minuend@/: 'GI.Gst.Structs.Caps.Caps' to subtract from -}
    -> Caps
    {- ^ /@subtrahend@/: 'GI.Gst.Structs.Caps.Caps' to subtract -}
    -> m Caps
    {- ^ __Returns:__ the resulting caps -}
capsSubtract minuend subtrahend = liftIO $ do
    minuend' <- unsafeManagedPtrGetPtr minuend
    subtrahend' <- unsafeManagedPtrGetPtr subtrahend
    result <- gst_caps_subtract minuend' subtrahend'
    checkUnexpectedReturnNULL "capsSubtract" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr minuend
    touchManagedPtr subtrahend
    return result'

#if ENABLE_OVERLOADING
data CapsSubtractMethodInfo
instance (signature ~ (Caps -> m Caps), MonadIO m) => O.MethodInfo CapsSubtractMethodInfo Caps signature where
    overloadedMethod _ = capsSubtract

#endif

-- method Caps::to_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCaps", 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_caps_to_string" gst_caps_to_string ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Converts /@caps@/ to a string representation.  This string representation
can be converted back to a 'GI.Gst.Structs.Caps.Caps' by 'GI.Gst.Functions.capsFromString'.

For debugging purposes its easier to do something like this:

=== /C code/
>
>GST_LOG ("caps are %" GST_PTR_FORMAT, caps);

This prints the caps in human readable form.

The current implementation of serialization will lead to unexpected results
when there are nested 'GI.Gst.Structs.Caps.Caps' \/ 'GI.Gst.Structs.Structure.Structure' deeper than one level.
-}
capsToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: a 'GI.Gst.Structs.Caps.Caps' -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string representing /@caps@/. -}
capsToString caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_caps_to_string caps'
    checkUnexpectedReturnNULL "capsToString" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsToStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo CapsToStringMethodInfo Caps signature where
    overloadedMethod _ = capsToString

#endif

-- method Caps::truncate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to truncate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_caps_truncate" gst_caps_truncate ::
    Ptr Caps ->                             -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Caps)

{- |
Discard all but the first structure from /@caps@/. Useful when
fixating.

This function takes ownership of /@caps@/ and will call @/gst_caps_make_writable()/@
on it if necessary, so you must not use /@caps@/ afterwards unless you keep an
additional reference to it with @/gst_caps_ref()/@.
-}
capsTruncate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to truncate -}
    -> m Caps
    {- ^ __Returns:__ truncated caps -}
capsTruncate caps = liftIO $ do
    caps' <- B.ManagedPtr.disownBoxed caps
    result <- gst_caps_truncate caps'
    checkUnexpectedReturnNULL "capsTruncate" result
    result' <- (wrapBoxed Caps) result
    touchManagedPtr caps
    return result'

#if ENABLE_OVERLOADING
data CapsTruncateMethodInfo
instance (signature ~ (m Caps), MonadIO m) => O.MethodInfo CapsTruncateMethodInfo Caps signature where
    overloadedMethod _ = capsTruncate

#endif

-- method Caps::from_string
-- method type : MemberFunction
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to convert to #GstCaps", 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_caps_from_string" gst_caps_from_string ::
    CString ->                              -- string : TBasicType TUTF8
    IO (Ptr Caps)

{- |
Converts /@caps@/ from a string representation.

The current implementation of serialization will lead to unexpected results
when there are nested 'GI.Gst.Structs.Caps.Caps' \/ 'GI.Gst.Structs.Structure.Structure' deeper than one level.
-}
capsFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: a string to convert to 'GI.Gst.Structs.Caps.Caps' -}
    -> m (Maybe Caps)
    {- ^ __Returns:__ a newly allocated 'GI.Gst.Structs.Caps.Caps' -}
capsFromString string = liftIO $ do
    string' <- textToCString string
    result <- gst_caps_from_string string'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Caps) result'
        return result''
    freeMem string'
    return maybeResult

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type family ResolveCapsMethod (t :: Symbol) (o :: *) :: * where
    ResolveCapsMethod "append" o = CapsAppendMethodInfo
    ResolveCapsMethod "appendStructure" o = CapsAppendStructureMethodInfo
    ResolveCapsMethod "appendStructureFull" o = CapsAppendStructureFullMethodInfo
    ResolveCapsMethod "canIntersect" o = CapsCanIntersectMethodInfo
    ResolveCapsMethod "copy" o = CapsCopyMethodInfo
    ResolveCapsMethod "copyNth" o = CapsCopyNthMethodInfo
    ResolveCapsMethod "filterAndMapInPlace" o = CapsFilterAndMapInPlaceMethodInfo
    ResolveCapsMethod "fixate" o = CapsFixateMethodInfo
    ResolveCapsMethod "foreach" o = CapsForeachMethodInfo
    ResolveCapsMethod "intersect" o = CapsIntersectMethodInfo
    ResolveCapsMethod "intersectFull" o = CapsIntersectFullMethodInfo
    ResolveCapsMethod "isAlwaysCompatible" o = CapsIsAlwaysCompatibleMethodInfo
    ResolveCapsMethod "isAny" o = CapsIsAnyMethodInfo
    ResolveCapsMethod "isEmpty" o = CapsIsEmptyMethodInfo
    ResolveCapsMethod "isEqual" o = CapsIsEqualMethodInfo
    ResolveCapsMethod "isEqualFixed" o = CapsIsEqualFixedMethodInfo
    ResolveCapsMethod "isFixed" o = CapsIsFixedMethodInfo
    ResolveCapsMethod "isStrictlyEqual" o = CapsIsStrictlyEqualMethodInfo
    ResolveCapsMethod "isSubset" o = CapsIsSubsetMethodInfo
    ResolveCapsMethod "isSubsetStructure" o = CapsIsSubsetStructureMethodInfo
    ResolveCapsMethod "isSubsetStructureFull" o = CapsIsSubsetStructureFullMethodInfo
    ResolveCapsMethod "mapInPlace" o = CapsMapInPlaceMethodInfo
    ResolveCapsMethod "merge" o = CapsMergeMethodInfo
    ResolveCapsMethod "mergeStructure" o = CapsMergeStructureMethodInfo
    ResolveCapsMethod "mergeStructureFull" o = CapsMergeStructureFullMethodInfo
    ResolveCapsMethod "normalize" o = CapsNormalizeMethodInfo
    ResolveCapsMethod "removeStructure" o = CapsRemoveStructureMethodInfo
    ResolveCapsMethod "simplify" o = CapsSimplifyMethodInfo
    ResolveCapsMethod "stealStructure" o = CapsStealStructureMethodInfo
    ResolveCapsMethod "subtract" o = CapsSubtractMethodInfo
    ResolveCapsMethod "toString" o = CapsToStringMethodInfo
    ResolveCapsMethod "truncate" o = CapsTruncateMethodInfo
    ResolveCapsMethod "getFeatures" o = CapsGetFeaturesMethodInfo
    ResolveCapsMethod "getSize" o = CapsGetSizeMethodInfo
    ResolveCapsMethod "getStructure" o = CapsGetStructureMethodInfo
    ResolveCapsMethod "setFeatures" o = CapsSetFeaturesMethodInfo
    ResolveCapsMethod "setFeaturesSimple" o = CapsSetFeaturesSimpleMethodInfo
    ResolveCapsMethod "setValue" o = CapsSetValueMethodInfo
    ResolveCapsMethod l o = O.MethodResolutionFailed l o

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