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

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

module GI.GstBase.Callbacks
    (

 -- * Signals
-- ** CollectDataDestroyNotify #signal:CollectDataDestroyNotify#

    C_CollectDataDestroyNotify              ,
    CollectDataDestroyNotify                ,
    dynamic_CollectDataDestroyNotify        ,
    genClosure_CollectDataDestroyNotify     ,
    mk_CollectDataDestroyNotify             ,
    noCollectDataDestroyNotify              ,
    wrap_CollectDataDestroyNotify           ,


-- ** CollectPadsBufferFunction #signal:CollectPadsBufferFunction#

    C_CollectPadsBufferFunction             ,
    CollectPadsBufferFunction               ,
    CollectPadsBufferFunction_WithClosures  ,
    drop_closures_CollectPadsBufferFunction ,
    dynamic_CollectPadsBufferFunction       ,
    genClosure_CollectPadsBufferFunction    ,
    mk_CollectPadsBufferFunction            ,
    noCollectPadsBufferFunction             ,
    noCollectPadsBufferFunction_WithClosures,
    wrap_CollectPadsBufferFunction          ,


-- ** CollectPadsClipFunction #signal:CollectPadsClipFunction#

    C_CollectPadsClipFunction               ,
    CollectPadsClipFunction                 ,
    CollectPadsClipFunction_WithClosures    ,
    drop_closures_CollectPadsClipFunction   ,
    dynamic_CollectPadsClipFunction         ,
    genClosure_CollectPadsClipFunction      ,
    mk_CollectPadsClipFunction              ,
    noCollectPadsClipFunction               ,
    noCollectPadsClipFunction_WithClosures  ,
    wrap_CollectPadsClipFunction            ,


-- ** CollectPadsCompareFunction #signal:CollectPadsCompareFunction#

    C_CollectPadsCompareFunction            ,
    CollectPadsCompareFunction              ,
    CollectPadsCompareFunction_WithClosures ,
    drop_closures_CollectPadsCompareFunction,
    dynamic_CollectPadsCompareFunction      ,
    genClosure_CollectPadsCompareFunction   ,
    mk_CollectPadsCompareFunction           ,
    noCollectPadsCompareFunction            ,
    noCollectPadsCompareFunction_WithClosures,
    wrap_CollectPadsCompareFunction         ,


-- ** CollectPadsEventFunction #signal:CollectPadsEventFunction#

    C_CollectPadsEventFunction              ,
    CollectPadsEventFunction                ,
    CollectPadsEventFunction_WithClosures   ,
    drop_closures_CollectPadsEventFunction  ,
    dynamic_CollectPadsEventFunction        ,
    genClosure_CollectPadsEventFunction     ,
    mk_CollectPadsEventFunction             ,
    noCollectPadsEventFunction              ,
    noCollectPadsEventFunction_WithClosures ,
    wrap_CollectPadsEventFunction           ,


-- ** CollectPadsFlushFunction #signal:CollectPadsFlushFunction#

    C_CollectPadsFlushFunction              ,
    CollectPadsFlushFunction                ,
    CollectPadsFlushFunction_WithClosures   ,
    drop_closures_CollectPadsFlushFunction  ,
    dynamic_CollectPadsFlushFunction        ,
    genClosure_CollectPadsFlushFunction     ,
    mk_CollectPadsFlushFunction             ,
    noCollectPadsFlushFunction              ,
    noCollectPadsFlushFunction_WithClosures ,
    wrap_CollectPadsFlushFunction           ,


-- ** CollectPadsFunction #signal:CollectPadsFunction#

    C_CollectPadsFunction                   ,
    CollectPadsFunction                     ,
    CollectPadsFunction_WithClosures        ,
    drop_closures_CollectPadsFunction       ,
    dynamic_CollectPadsFunction             ,
    genClosure_CollectPadsFunction          ,
    mk_CollectPadsFunction                  ,
    noCollectPadsFunction                   ,
    noCollectPadsFunction_WithClosures      ,
    wrap_CollectPadsFunction                ,


-- ** CollectPadsQueryFunction #signal:CollectPadsQueryFunction#

    C_CollectPadsQueryFunction              ,
    CollectPadsQueryFunction                ,
    CollectPadsQueryFunction_WithClosures   ,
    drop_closures_CollectPadsQueryFunction  ,
    dynamic_CollectPadsQueryFunction        ,
    genClosure_CollectPadsQueryFunction     ,
    mk_CollectPadsQueryFunction             ,
    noCollectPadsQueryFunction              ,
    noCollectPadsQueryFunction_WithClosures ,
    wrap_CollectPadsQueryFunction           ,


-- ** DataQueueEmptyCallback #signal:DataQueueEmptyCallback#

    C_DataQueueEmptyCallback                ,
    DataQueueEmptyCallback                  ,
    dynamic_DataQueueEmptyCallback          ,
    genClosure_DataQueueEmptyCallback       ,
    mk_DataQueueEmptyCallback               ,
    noDataQueueEmptyCallback                ,
    wrap_DataQueueEmptyCallback             ,


-- ** DataQueueFullCallback #signal:DataQueueFullCallback#

    C_DataQueueFullCallback                 ,
    DataQueueFullCallback                   ,
    dynamic_DataQueueFullCallback           ,
    genClosure_DataQueueFullCallback        ,
    mk_DataQueueFullCallback                ,
    noDataQueueFullCallback                 ,
    wrap_DataQueueFullCallback              ,


-- ** TypeFindHelperGetRangeFunction #signal:TypeFindHelperGetRangeFunction#

    C_TypeFindHelperGetRangeFunction        ,
    TypeFindHelperGetRangeFunction          ,
    dynamic_TypeFindHelperGetRangeFunction  ,
    genClosure_TypeFindHelperGetRangeFunction,
    mk_TypeFindHelperGetRangeFunction       ,
    noTypeFindHelperGetRangeFunction        ,
    wrap_TypeFindHelperGetRangeFunction     ,




    ) 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.Enums as Gst.Enums
import qualified GI.Gst.Objects.Object as Gst.Object
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.Event as Gst.Event
import qualified GI.Gst.Structs.Query as Gst.Query
import {-# SOURCE #-} qualified GI.GstBase.Objects.CollectPads as GstBase.CollectPads
import {-# SOURCE #-} qualified GI.GstBase.Objects.DataQueue as GstBase.DataQueue
import {-# SOURCE #-} qualified GI.GstBase.Structs.CollectData as GstBase.CollectData

-- callback TypeFindHelperGetRangeFunction
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "GST_FLOW_OK for success", sinceVersion = Nothing}, args = [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstObject that will handle the getrange request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parent of @obj or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the offset of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a memory location to hold the result buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "This function will be called by gst_type_find_helper_get_range() when\ntypefinding functions request to peek at the data of a stream at certain\noffsets. If this function returns GST_FLOW_OK, the result buffer will be\nstored in @buffer. The  contents of @buffer is invalid for any other\nreturn value.\n\nThis function is supposed to behave exactly like a #GstPadGetRangeFunction.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_TypeFindHelperGetRangeFunction =
    Ptr Gst.Object.Object ->
    Ptr Gst.Object.Object ->
    Word64 ->
    Word32 ->
    Ptr (Ptr Gst.Buffer.Buffer) ->
    IO CInt

-- Args : [Arg {argCName = "obj", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstObject that will handle the getrange request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gst", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parent of @obj or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the offset of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a memory location to hold the result buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_TypeFindHelperGetRangeFunction :: FunPtr C_TypeFindHelperGetRangeFunction -> C_TypeFindHelperGetRangeFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_TypeFindHelperGetRangeFunction ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a, Gst.Object.IsObject b) =>
    FunPtr C_TypeFindHelperGetRangeFunction
    -> a
    {- ^ /@obj@/: a 'GI.Gst.Objects.Object.Object' that will handle the getrange request -}
    -> Maybe (b)
    {- ^ /@parent@/: the parent of /@obj@/ or 'Nothing' -}
    -> Word64
    {- ^ /@offset@/: the offset of the range -}
    -> Word32
    {- ^ /@length@/: the length of the range -}
    -> m ((Gst.Enums.FlowReturn, Gst.Buffer.Buffer))
    {- ^ __Returns:__ GST_FLOW_OK for success -}
dynamic_TypeFindHelperGetRangeFunction __funPtr obj parent offset length_ = liftIO $ do
    obj' <- unsafeManagedPtrCastPtr obj
    maybeParent <- case parent of
        Nothing -> return nullPtr
        Just jParent -> do
            jParent' <- unsafeManagedPtrCastPtr jParent
            return jParent'
    buffer <- allocMem :: IO (Ptr (Ptr Gst.Buffer.Buffer))
    result <- (__dynamic_C_TypeFindHelperGetRangeFunction __funPtr) obj' maybeParent offset length_ buffer
    let result' = (toEnum . fromIntegral) result
    buffer' <- peek buffer
    buffer'' <- (wrapBoxed Gst.Buffer.Buffer) buffer'
    touchManagedPtr obj
    whenJust parent touchManagedPtr
    freeMem buffer
    return (result', buffer'')

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

{- |
This function will be called by 'GI.GstBase.Functions.typeFindHelperGetRange' when
typefinding functions request to peek at the data of a stream at certain
offsets. If this function returns GST_FLOW_OK, the result buffer will be
stored in /@buffer@/. The  contents of /@buffer@/ is invalid for any other
return value.

This function is supposed to behave exactly like a 'GI.Gst.Callbacks.PadGetRangeFunction'.
-}
type TypeFindHelperGetRangeFunction =
    Gst.Object.Object
    {- ^ /@obj@/: a 'GI.Gst.Objects.Object.Object' that will handle the getrange request -}
    -> Maybe Gst.Object.Object
    {- ^ /@parent@/: the parent of /@obj@/ or 'Nothing' -}
    -> Word64
    {- ^ /@offset@/: the offset of the range -}
    -> Word32
    {- ^ /@length@/: the length of the range -}
    -> IO ((Gst.Enums.FlowReturn, Gst.Buffer.Buffer))
    {- ^ __Returns:__ GST_FLOW_OK for success -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TypeFindHelperGetRangeFunction`@.
noTypeFindHelperGetRangeFunction :: Maybe TypeFindHelperGetRangeFunction
noTypeFindHelperGetRangeFunction = Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_TypeFindHelperGetRangeFunction :: MonadIO m => TypeFindHelperGetRangeFunction -> m (GClosure C_TypeFindHelperGetRangeFunction)
genClosure_TypeFindHelperGetRangeFunction cb = liftIO $ do
    let cb' = wrap_TypeFindHelperGetRangeFunction Nothing cb
    mk_TypeFindHelperGetRangeFunction cb' >>= B.GClosure.newGClosure


-- | Wrap a `TypeFindHelperGetRangeFunction` into a `C_TypeFindHelperGetRangeFunction`.
wrap_TypeFindHelperGetRangeFunction ::
    Maybe (Ptr (FunPtr C_TypeFindHelperGetRangeFunction)) ->
    TypeFindHelperGetRangeFunction ->
    C_TypeFindHelperGetRangeFunction
wrap_TypeFindHelperGetRangeFunction funptrptr _cb obj parent offset length_ buffer = do
    obj' <- (newObject Gst.Object.Object) obj
    maybeParent <-
        if parent == nullPtr
        then return Nothing
        else do
            parent' <- (newObject Gst.Object.Object) parent
            return $ Just parent'
    (result, outbuffer) <- _cb  obj' maybeParent offset length_
    outbuffer' <- B.ManagedPtr.disownBoxed outbuffer
    poke buffer outbuffer'
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback DataQueueFullCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "queue", argType = TInterface (Name {namespace = "GstBase", name = "DataQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "checkdata", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DataQueueFullCallback =
    Ptr GstBase.DataQueue.DataQueue ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "GstBase", name = "DataQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "checkdata", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DataQueueFullCallback :: FunPtr C_DataQueueFullCallback -> C_DataQueueFullCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DataQueueFullCallback ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.DataQueue.IsDataQueue a) =>
    FunPtr C_DataQueueFullCallback
    -> a
    -> Ptr ()
    -> m ()
dynamic_DataQueueFullCallback __funPtr queue checkdata = liftIO $ do
    queue' <- unsafeManagedPtrCastPtr queue
    (__dynamic_C_DataQueueFullCallback __funPtr) queue' checkdata
    touchManagedPtr queue
    return ()

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

{- |
/No description available in the introspection data./
-}
type DataQueueFullCallback =
    GstBase.DataQueue.DataQueue
    -> Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DataQueueFullCallback`@.
noDataQueueFullCallback :: Maybe DataQueueFullCallback
noDataQueueFullCallback = Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_DataQueueFullCallback :: MonadIO m => DataQueueFullCallback -> m (GClosure C_DataQueueFullCallback)
genClosure_DataQueueFullCallback cb = liftIO $ do
    let cb' = wrap_DataQueueFullCallback Nothing cb
    mk_DataQueueFullCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `DataQueueFullCallback` into a `C_DataQueueFullCallback`.
wrap_DataQueueFullCallback ::
    Maybe (Ptr (FunPtr C_DataQueueFullCallback)) ->
    DataQueueFullCallback ->
    C_DataQueueFullCallback
wrap_DataQueueFullCallback funptrptr _cb queue checkdata = do
    queue' <- (newObject GstBase.DataQueue.DataQueue) queue
    _cb  queue' checkdata
    maybeReleaseFunPtr funptrptr


-- callback DataQueueEmptyCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "queue", argType = TInterface (Name {namespace = "GstBase", name = "DataQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "checkdata", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DataQueueEmptyCallback =
    Ptr GstBase.DataQueue.DataQueue ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "GstBase", name = "DataQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "checkdata", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DataQueueEmptyCallback :: FunPtr C_DataQueueEmptyCallback -> C_DataQueueEmptyCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DataQueueEmptyCallback ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.DataQueue.IsDataQueue a) =>
    FunPtr C_DataQueueEmptyCallback
    -> a
    -> Ptr ()
    -> m ()
dynamic_DataQueueEmptyCallback __funPtr queue checkdata = liftIO $ do
    queue' <- unsafeManagedPtrCastPtr queue
    (__dynamic_C_DataQueueEmptyCallback __funPtr) queue' checkdata
    touchManagedPtr queue
    return ()

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

{- |
/No description available in the introspection data./
-}
type DataQueueEmptyCallback =
    GstBase.DataQueue.DataQueue
    -> Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DataQueueEmptyCallback`@.
noDataQueueEmptyCallback :: Maybe DataQueueEmptyCallback
noDataQueueEmptyCallback = Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_DataQueueEmptyCallback :: MonadIO m => DataQueueEmptyCallback -> m (GClosure C_DataQueueEmptyCallback)
genClosure_DataQueueEmptyCallback cb = liftIO $ do
    let cb' = wrap_DataQueueEmptyCallback Nothing cb
    mk_DataQueueEmptyCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `DataQueueEmptyCallback` into a `C_DataQueueEmptyCallback`.
wrap_DataQueueEmptyCallback ::
    Maybe (Ptr (FunPtr C_DataQueueEmptyCallback)) ->
    DataQueueEmptyCallback ->
    C_DataQueueEmptyCallback
wrap_DataQueueEmptyCallback funptrptr _cb queue checkdata = do
    queue' <- (newObject GstBase.DataQueue.DataQueue) queue
    _cb  queue' checkdata
    maybeReleaseFunPtr funptrptr


-- callback CollectPadsQueryFunction
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE if the pad could handle the event", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad that received an event", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "query", argType = TInterface (Name {namespace = "Gst", name = "Query"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstEvent received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_query_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called while processing a query. It takes\nownership of the query and is responsible for chaining up (to\nevents downstream (with gst_pad_event_default()).", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsQueryFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr GstBase.CollectData.CollectData ->
    Ptr Gst.Query.Query ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad that received an event", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "query", argType = TInterface (Name {namespace = "Gst", name = "Query"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstEvent received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_query_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsQueryFunction :: FunPtr C_CollectPadsQueryFunction -> C_CollectPadsQueryFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsQueryFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsQueryFunction
    -> a
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Query.Query
    {- ^ /@query@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetQueryFunction' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}
dynamic_CollectPadsQueryFunction __funPtr pads pad query userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    pad' <- unsafeManagedPtrGetPtr pad
    query' <- unsafeManagedPtrGetPtr query
    result <- (__dynamic_C_CollectPadsQueryFunction __funPtr) pads' pad' query' userData
    let result' = (/= 0) result
    touchManagedPtr pads
    touchManagedPtr pad
    touchManagedPtr query
    return result'

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

{- |
A function that will be called while processing a query. It takes
ownership of the query and is responsible for chaining up (to
events downstream (with 'GI.Gst.Objects.Pad.padEventDefault').
-}
type CollectPadsQueryFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Query.Query
    {- ^ /@query@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsQueryFunction`@.
noCollectPadsQueryFunction :: Maybe CollectPadsQueryFunction
noCollectPadsQueryFunction = Nothing

{- |
A function that will be called while processing a query. It takes
ownership of the query and is responsible for chaining up (to
events downstream (with 'GI.Gst.Objects.Pad.padEventDefault').
-}
type CollectPadsQueryFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Query.Query
    {- ^ /@query@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetQueryFunction' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsQueryFunction_WithClosures`@.
noCollectPadsQueryFunction_WithClosures :: Maybe CollectPadsQueryFunction_WithClosures
noCollectPadsQueryFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsQueryFunction :: CollectPadsQueryFunction -> CollectPadsQueryFunction_WithClosures
drop_closures_CollectPadsQueryFunction _f pads pad query _ = _f pads pad query

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsQueryFunction :: MonadIO m => CollectPadsQueryFunction -> m (GClosure C_CollectPadsQueryFunction)
genClosure_CollectPadsQueryFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsQueryFunction cb
    let cb'' = wrap_CollectPadsQueryFunction Nothing cb'
    mk_CollectPadsQueryFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsQueryFunction` into a `C_CollectPadsQueryFunction`.
wrap_CollectPadsQueryFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsQueryFunction)) ->
    CollectPadsQueryFunction_WithClosures ->
    C_CollectPadsQueryFunction
wrap_CollectPadsQueryFunction funptrptr _cb pads pad query userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    pad' <- (newPtr GstBase.CollectData.CollectData) pad
    B.ManagedPtr.withTransient Gst.Query.Query query $ \query' -> do
        result <- _cb  pads' pad' query' userData
        maybeReleaseFunPtr funptrptr
        let result' = (fromIntegral . fromEnum) result
        return result'


-- callback CollectPadsFunction
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%GST_FLOW_OK for success", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called when all pads have received data.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsFunction :: FunPtr C_CollectPadsFunction -> C_CollectPadsFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsFunction
    -> a
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetFunction' -}
    -> m Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}
dynamic_CollectPadsFunction __funPtr pads userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    result <- (__dynamic_C_CollectPadsFunction __funPtr) pads' userData
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr pads
    return result'

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

{- |
A function that will be called when all pads have received data.
-}
type CollectPadsFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> IO Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsFunction`@.
noCollectPadsFunction :: Maybe CollectPadsFunction
noCollectPadsFunction = Nothing

{- |
A function that will be called when all pads have received data.
-}
type CollectPadsFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetFunction' -}
    -> IO Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsFunction_WithClosures`@.
noCollectPadsFunction_WithClosures :: Maybe CollectPadsFunction_WithClosures
noCollectPadsFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsFunction :: CollectPadsFunction -> CollectPadsFunction_WithClosures
drop_closures_CollectPadsFunction _f pads _ = _f pads

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsFunction :: MonadIO m => CollectPadsFunction -> m (GClosure C_CollectPadsFunction)
genClosure_CollectPadsFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsFunction cb
    let cb'' = wrap_CollectPadsFunction Nothing cb'
    mk_CollectPadsFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsFunction` into a `C_CollectPadsFunction`.
wrap_CollectPadsFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsFunction)) ->
    CollectPadsFunction_WithClosures ->
    C_CollectPadsFunction
wrap_CollectPadsFunction funptrptr _cb pads userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    result <- _cb  pads' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback CollectPadsFlushFunction
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectPads", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called while processing a flushing seek event.\n\nThe function should flush any internal state of the element and the state of\nall the pads. It should clear only the state not directly managed by the\n@pads object. It is therefore not necessary to call\ngst_collect_pads_set_flushing nor gst_collect_pads_clear from this function.", sinceVersion = Just "1.4"}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsFlushFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectPads", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsFlushFunction :: FunPtr C_CollectPadsFlushFunction -> C_CollectPadsFlushFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsFlushFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsFlushFunction
    -> a
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> Ptr ()
    {- ^ /@userData@/: user data -}
    -> m ()
dynamic_CollectPadsFlushFunction __funPtr pads userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    (__dynamic_C_CollectPadsFlushFunction __funPtr) pads' userData
    touchManagedPtr pads
    return ()

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

{- |
A function that will be called while processing a flushing seek event.

The function should flush any internal state of the element and the state of
all the pads. It should clear only the state not directly managed by the
/@pads@/ object. It is therefore not necessary to call
gst_collect_pads_set_flushing nor gst_collect_pads_clear from this function.

/Since: 1.4/
-}
type CollectPadsFlushFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsFlushFunction`@.
noCollectPadsFlushFunction :: Maybe CollectPadsFlushFunction
noCollectPadsFlushFunction = Nothing

{- |
A function that will be called while processing a flushing seek event.

The function should flush any internal state of the element and the state of
all the pads. It should clear only the state not directly managed by the
/@pads@/ object. It is therefore not necessary to call
gst_collect_pads_set_flushing nor gst_collect_pads_clear from this function.

/Since: 1.4/
-}
type CollectPadsFlushFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> Ptr ()
    {- ^ /@userData@/: user data -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsFlushFunction_WithClosures`@.
noCollectPadsFlushFunction_WithClosures :: Maybe CollectPadsFlushFunction_WithClosures
noCollectPadsFlushFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsFlushFunction :: CollectPadsFlushFunction -> CollectPadsFlushFunction_WithClosures
drop_closures_CollectPadsFlushFunction _f pads _ = _f pads

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsFlushFunction :: MonadIO m => CollectPadsFlushFunction -> m (GClosure C_CollectPadsFlushFunction)
genClosure_CollectPadsFlushFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsFlushFunction cb
    let cb'' = wrap_CollectPadsFlushFunction Nothing cb'
    mk_CollectPadsFlushFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsFlushFunction` into a `C_CollectPadsFlushFunction`.
wrap_CollectPadsFlushFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsFlushFunction)) ->
    CollectPadsFlushFunction_WithClosures ->
    C_CollectPadsFlushFunction
wrap_CollectPadsFlushFunction funptrptr _cb pads userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    _cb  pads' userData
    maybeReleaseFunPtr funptrptr


-- callback CollectPadsEventFunction
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE if the pad could handle the event", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad that received an event", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gst", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstEvent received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_event_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called while processing an event. It takes\nownership of the event and is responsible for chaining up (to\ngst_collect_pads_event_default()) or dropping events (such typical cases\nbeing handled by the default handler).", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsEventFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr GstBase.CollectData.CollectData ->
    Ptr Gst.Event.Event ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pad", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPad that received an event", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gst", name = "Event"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstEvent received", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_event_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsEventFunction :: FunPtr C_CollectPadsEventFunction -> C_CollectPadsEventFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsEventFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsEventFunction
    -> a
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Event.Event
    {- ^ /@event@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetEventFunction' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}
dynamic_CollectPadsEventFunction __funPtr pads pad event userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    pad' <- unsafeManagedPtrGetPtr pad
    event' <- unsafeManagedPtrGetPtr event
    result <- (__dynamic_C_CollectPadsEventFunction __funPtr) pads' pad' event' userData
    let result' = (/= 0) result
    touchManagedPtr pads
    touchManagedPtr pad
    touchManagedPtr event
    return result'

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

{- |
A function that will be called while processing an event. It takes
ownership of the event and is responsible for chaining up (to
'GI.GstBase.Objects.CollectPads.collectPadsEventDefault') or dropping events (such typical cases
being handled by the default handler).
-}
type CollectPadsEventFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Event.Event
    {- ^ /@event@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsEventFunction`@.
noCollectPadsEventFunction :: Maybe CollectPadsEventFunction
noCollectPadsEventFunction = Nothing

{- |
A function that will be called while processing an event. It takes
ownership of the event and is responsible for chaining up (to
'GI.GstBase.Objects.CollectPads.collectPadsEventDefault') or dropping events (such typical cases
being handled by the default handler).
-}
type CollectPadsEventFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@pad@/: the 'GI.Gst.Objects.Pad.Pad' that received an event -}
    -> Gst.Event.Event
    {- ^ /@event@/: the 'GI.Gst.Structs.Event.Event' received -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetEventFunction' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if the pad could handle the event -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsEventFunction_WithClosures`@.
noCollectPadsEventFunction_WithClosures :: Maybe CollectPadsEventFunction_WithClosures
noCollectPadsEventFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsEventFunction :: CollectPadsEventFunction -> CollectPadsEventFunction_WithClosures
drop_closures_CollectPadsEventFunction _f pads pad event _ = _f pads pad event

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsEventFunction :: MonadIO m => CollectPadsEventFunction -> m (GClosure C_CollectPadsEventFunction)
genClosure_CollectPadsEventFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsEventFunction cb
    let cb'' = wrap_CollectPadsEventFunction Nothing cb'
    mk_CollectPadsEventFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsEventFunction` into a `C_CollectPadsEventFunction`.
wrap_CollectPadsEventFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsEventFunction)) ->
    CollectPadsEventFunction_WithClosures ->
    C_CollectPadsEventFunction
wrap_CollectPadsEventFunction funptrptr _cb pads pad event userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    pad' <- (newPtr GstBase.CollectData.CollectData) pad
    B.ManagedPtr.withTransient Gst.Event.Event event $ \event' -> do
        result <- _cb  pads' pad' event' userData
        maybeReleaseFunPtr funptrptr
        let result' = (fromIntegral . fromEnum) result
        return result'


-- callback CollectPadsCompareFunction
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "Integer less than zero when first timestamp is deemed older than the second one.\n         Zero if the timestamps are deemed equally old.\n         Integer greater than zero when second timestamp is deemed older than the first one.", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that is comparing the timestamps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data1", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp1", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first timestamp", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data2", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp2", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second timestamp", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_compare_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function for comparing two timestamps of buffers or newsegments collected on one pad.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsCompareFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr GstBase.CollectData.CollectData ->
    Word64 ->
    Ptr GstBase.CollectData.CollectData ->
    Word64 ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that is comparing the timestamps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data1", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp1", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first timestamp", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data2", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timestamp2", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second timestamp", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_compare_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsCompareFunction :: FunPtr C_CollectPadsCompareFunction -> C_CollectPadsCompareFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsCompareFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsCompareFunction
    -> a
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that is comparing the timestamps -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data1@/: the first 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp1@/: the first timestamp -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data2@/: the second 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp2@/: the second timestamp -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetCompareFunction' -}
    -> m Int32
    {- ^ __Returns:__ Integer less than zero when first timestamp is deemed older than the second one.
         Zero if the timestamps are deemed equally old.
         Integer greater than zero when second timestamp is deemed older than the first one. -}
dynamic_CollectPadsCompareFunction __funPtr pads data1 timestamp1 data2 timestamp2 userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    data1' <- unsafeManagedPtrGetPtr data1
    data2' <- unsafeManagedPtrGetPtr data2
    result <- (__dynamic_C_CollectPadsCompareFunction __funPtr) pads' data1' timestamp1 data2' timestamp2 userData
    touchManagedPtr pads
    touchManagedPtr data1
    touchManagedPtr data2
    return result

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

{- |
A function for comparing two timestamps of buffers or newsegments collected on one pad.
-}
type CollectPadsCompareFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that is comparing the timestamps -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data1@/: the first 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp1@/: the first timestamp -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data2@/: the second 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp2@/: the second timestamp -}
    -> IO Int32
    {- ^ __Returns:__ Integer less than zero when first timestamp is deemed older than the second one.
         Zero if the timestamps are deemed equally old.
         Integer greater than zero when second timestamp is deemed older than the first one. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsCompareFunction`@.
noCollectPadsCompareFunction :: Maybe CollectPadsCompareFunction
noCollectPadsCompareFunction = Nothing

{- |
A function for comparing two timestamps of buffers or newsegments collected on one pad.
-}
type CollectPadsCompareFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that is comparing the timestamps -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data1@/: the first 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp1@/: the first timestamp -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data2@/: the second 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Word64
    {- ^ /@timestamp2@/: the second timestamp -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetCompareFunction' -}
    -> IO Int32
    {- ^ __Returns:__ Integer less than zero when first timestamp is deemed older than the second one.
         Zero if the timestamps are deemed equally old.
         Integer greater than zero when second timestamp is deemed older than the first one. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsCompareFunction_WithClosures`@.
noCollectPadsCompareFunction_WithClosures :: Maybe CollectPadsCompareFunction_WithClosures
noCollectPadsCompareFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsCompareFunction :: CollectPadsCompareFunction -> CollectPadsCompareFunction_WithClosures
drop_closures_CollectPadsCompareFunction _f pads data1 timestamp1 data2 timestamp2 _ = _f pads data1 timestamp1 data2 timestamp2

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsCompareFunction :: MonadIO m => CollectPadsCompareFunction -> m (GClosure C_CollectPadsCompareFunction)
genClosure_CollectPadsCompareFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsCompareFunction cb
    let cb'' = wrap_CollectPadsCompareFunction Nothing cb'
    mk_CollectPadsCompareFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsCompareFunction` into a `C_CollectPadsCompareFunction`.
wrap_CollectPadsCompareFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsCompareFunction)) ->
    CollectPadsCompareFunction_WithClosures ->
    C_CollectPadsCompareFunction
wrap_CollectPadsCompareFunction funptrptr _cb pads data1 timestamp1 data2 timestamp2 userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    data1' <- (newPtr GstBase.CollectData.CollectData) data1
    data2' <- (newPtr GstBase.CollectData.CollectData) data2
    result <- _cb  pads' data1' timestamp1 data2' timestamp2 userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback CollectPadsClipFunction
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "a #GstFlowReturn that corresponds to the result of clipping.", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectPads", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "inbuffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the input #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "outbuffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the output #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called when @inbuffer is received on the pad managed\nby @data in the collectpad object @pads.\n\nThe function should use the segment of @data and the negotiated media type on\nthe pad to perform clipping of @inbuffer.\n\nThis function takes ownership of @inbuffer and should output a buffer in\n@outbuffer or return %NULL in @outbuffer if the buffer should be dropped.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsClipFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr GstBase.CollectData.CollectData ->
    Ptr Gst.Buffer.Buffer ->
    Ptr (Ptr Gst.Buffer.Buffer) ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectPads", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstCollectData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "inbuffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the input #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "outbuffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the output #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsClipFunction :: FunPtr C_CollectPadsClipFunction -> C_CollectPadsClipFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsClipFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsClipFunction
    -> a
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: a 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Gst.Buffer.Buffer
    {- ^ /@inbuffer@/: the input 'GI.Gst.Structs.Buffer.Buffer' -}
    -> Ptr ()
    {- ^ /@userData@/: user data -}
    -> m ((Gst.Enums.FlowReturn, Gst.Buffer.Buffer))
    {- ^ __Returns:__ a 'GI.Gst.Enums.FlowReturn' that corresponds to the result of clipping. -}
dynamic_CollectPadsClipFunction __funPtr pads data_ inbuffer userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    data_' <- unsafeManagedPtrGetPtr data_
    inbuffer' <- B.ManagedPtr.disownBoxed inbuffer
    outbuffer <- allocMem :: IO (Ptr (Ptr Gst.Buffer.Buffer))
    result <- (__dynamic_C_CollectPadsClipFunction __funPtr) pads' data_' inbuffer' outbuffer userData
    let result' = (toEnum . fromIntegral) result
    outbuffer' <- peek outbuffer
    outbuffer'' <- (wrapBoxed Gst.Buffer.Buffer) outbuffer'
    touchManagedPtr pads
    touchManagedPtr data_
    touchManagedPtr inbuffer
    freeMem outbuffer
    return (result', outbuffer'')

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

{- |
A function that will be called when /@inbuffer@/ is received on the pad managed
by /@data@/ in the collectpad object /@pads@/.

The function should use the segment of /@data@/ and the negotiated media type on
the pad to perform clipping of /@inbuffer@/.

This function takes ownership of /@inbuffer@/ and should output a buffer in
/@outbuffer@/ or return 'Nothing' in /@outbuffer@/ if the buffer should be dropped.
-}
type CollectPadsClipFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: a 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Gst.Buffer.Buffer
    {- ^ /@inbuffer@/: the input 'GI.Gst.Structs.Buffer.Buffer' -}
    -> IO ((Gst.Enums.FlowReturn, Gst.Buffer.Buffer))
    {- ^ __Returns:__ a 'GI.Gst.Enums.FlowReturn' that corresponds to the result of clipping. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsClipFunction`@.
noCollectPadsClipFunction :: Maybe CollectPadsClipFunction
noCollectPadsClipFunction = Nothing

{- |
A function that will be called when /@inbuffer@/ is received on the pad managed
by /@data@/ in the collectpad object /@pads@/.

The function should use the segment of /@data@/ and the negotiated media type on
the pad to perform clipping of /@inbuffer@/.

This function takes ownership of /@inbuffer@/ and should output a buffer in
/@outbuffer@/ or return 'Nothing' in /@outbuffer@/ if the buffer should be dropped.
-}
type CollectPadsClipFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: a 'GI.GstBase.Objects.CollectPads.CollectPads' -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: a 'GI.GstBase.Structs.CollectData.CollectData' -}
    -> Gst.Buffer.Buffer
    {- ^ /@inbuffer@/: the input 'GI.Gst.Structs.Buffer.Buffer' -}
    -> Ptr ()
    {- ^ /@userData@/: user data -}
    -> IO ((Gst.Enums.FlowReturn, Gst.Buffer.Buffer))
    {- ^ __Returns:__ a 'GI.Gst.Enums.FlowReturn' that corresponds to the result of clipping. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsClipFunction_WithClosures`@.
noCollectPadsClipFunction_WithClosures :: Maybe CollectPadsClipFunction_WithClosures
noCollectPadsClipFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsClipFunction :: CollectPadsClipFunction -> CollectPadsClipFunction_WithClosures
drop_closures_CollectPadsClipFunction _f pads data_ inbuffer _ = _f pads data_ inbuffer

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsClipFunction :: MonadIO m => CollectPadsClipFunction -> m (GClosure C_CollectPadsClipFunction)
genClosure_CollectPadsClipFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsClipFunction cb
    let cb'' = wrap_CollectPadsClipFunction Nothing cb'
    mk_CollectPadsClipFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsClipFunction` into a `C_CollectPadsClipFunction`.
wrap_CollectPadsClipFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsClipFunction)) ->
    CollectPadsClipFunction_WithClosures ->
    C_CollectPadsClipFunction
wrap_CollectPadsClipFunction funptrptr _cb pads data_ inbuffer outbuffer userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    data_' <- (newPtr GstBase.CollectData.CollectData) data_
    inbuffer' <- (wrapBoxed Gst.Buffer.Buffer) inbuffer
    (result, outoutbuffer) <- _cb  pads' data_' inbuffer' userData
    outoutbuffer' <- B.ManagedPtr.disownBoxed outoutbuffer
    poke outbuffer outoutbuffer'
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback CollectPadsBufferFunction
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%GST_FLOW_OK for success", sinceVersion = Nothing}, args = [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectData of pad that has received the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_buffer_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called when a (considered oldest) buffer can be muxed.\nIf all pads have reached EOS, this function is called with %NULL @buffer\nand %NULL @data.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectPadsBufferFunction =
    Ptr GstBase.CollectPads.CollectPads ->
    Ptr GstBase.CollectData.CollectData ->
    Ptr Gst.Buffer.Buffer ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "pads", argType = TInterface (Name {namespace = "GstBase", name = "CollectPads"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectPads that triggered the callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectData of pad that has received the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to gst_collect_pads_set_buffer_function()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "FlowReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectPadsBufferFunction :: FunPtr C_CollectPadsBufferFunction -> C_CollectPadsBufferFunction

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectPadsBufferFunction ::
    (B.CallStack.HasCallStack, MonadIO m, GstBase.CollectPads.IsCollectPads a) =>
    FunPtr C_CollectPadsBufferFunction
    -> a
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: the 'GI.GstBase.Structs.CollectData.CollectData' of pad that has received the buffer -}
    -> Gst.Buffer.Buffer
    {- ^ /@buffer@/: the 'GI.Gst.Structs.Buffer.Buffer' -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetBufferFunction' -}
    -> m Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}
dynamic_CollectPadsBufferFunction __funPtr pads data_ buffer userData = liftIO $ do
    pads' <- unsafeManagedPtrCastPtr pads
    data_' <- unsafeManagedPtrGetPtr data_
    buffer' <- B.ManagedPtr.disownBoxed buffer
    result <- (__dynamic_C_CollectPadsBufferFunction __funPtr) pads' data_' buffer' userData
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr pads
    touchManagedPtr data_
    touchManagedPtr buffer
    return result'

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

{- |
A function that will be called when a (considered oldest) buffer can be muxed.
If all pads have reached EOS, this function is called with 'Nothing' /@buffer@/
and 'Nothing' /@data@/.
-}
type CollectPadsBufferFunction =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: the 'GI.GstBase.Structs.CollectData.CollectData' of pad that has received the buffer -}
    -> Gst.Buffer.Buffer
    {- ^ /@buffer@/: the 'GI.Gst.Structs.Buffer.Buffer' -}
    -> IO Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsBufferFunction`@.
noCollectPadsBufferFunction :: Maybe CollectPadsBufferFunction
noCollectPadsBufferFunction = Nothing

{- |
A function that will be called when a (considered oldest) buffer can be muxed.
If all pads have reached EOS, this function is called with 'Nothing' /@buffer@/
and 'Nothing' /@data@/.
-}
type CollectPadsBufferFunction_WithClosures =
    GstBase.CollectPads.CollectPads
    {- ^ /@pads@/: the 'GI.GstBase.Objects.CollectPads.CollectPads' that triggered the callback -}
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: the 'GI.GstBase.Structs.CollectData.CollectData' of pad that has received the buffer -}
    -> Gst.Buffer.Buffer
    {- ^ /@buffer@/: the 'GI.Gst.Structs.Buffer.Buffer' -}
    -> Ptr ()
    {- ^ /@userData@/: user data passed to 'GI.GstBase.Objects.CollectPads.collectPadsSetBufferFunction' -}
    -> IO Gst.Enums.FlowReturn
    {- ^ __Returns:__ 'GI.Gst.Enums.FlowReturnOk' for success -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectPadsBufferFunction_WithClosures`@.
noCollectPadsBufferFunction_WithClosures :: Maybe CollectPadsBufferFunction_WithClosures
noCollectPadsBufferFunction_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CollectPadsBufferFunction :: CollectPadsBufferFunction -> CollectPadsBufferFunction_WithClosures
drop_closures_CollectPadsBufferFunction _f pads data_ buffer _ = _f pads data_ buffer

-- | Wrap the callback into a `GClosure`.
genClosure_CollectPadsBufferFunction :: MonadIO m => CollectPadsBufferFunction -> m (GClosure C_CollectPadsBufferFunction)
genClosure_CollectPadsBufferFunction cb = liftIO $ do
    let cb' = drop_closures_CollectPadsBufferFunction cb
    let cb'' = wrap_CollectPadsBufferFunction Nothing cb'
    mk_CollectPadsBufferFunction cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CollectPadsBufferFunction` into a `C_CollectPadsBufferFunction`.
wrap_CollectPadsBufferFunction ::
    Maybe (Ptr (FunPtr C_CollectPadsBufferFunction)) ->
    CollectPadsBufferFunction_WithClosures ->
    C_CollectPadsBufferFunction
wrap_CollectPadsBufferFunction funptrptr _cb pads data_ buffer userData = do
    pads' <- (newObject GstBase.CollectPads.CollectPads) pads
    data_' <- (newPtr GstBase.CollectData.CollectData) data_
    buffer' <- (wrapBoxed Gst.Buffer.Buffer) buffer
    result <- _cb  pads' data_' buffer' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback CollectDataDestroyNotify
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectData that will be freed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A function that will be called when the #GstCollectData will be freed.\nIt is passed the pointer to the structure and should free any custom\nmemory and resources allocated for it.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CollectDataDestroyNotify =
    Ptr GstBase.CollectData.CollectData ->
    IO ()

-- Args : [Arg {argCName = "data", argType = TInterface (Name {namespace = "GstBase", name = "CollectData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCollectData that will be freed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CollectDataDestroyNotify :: FunPtr C_CollectDataDestroyNotify -> C_CollectDataDestroyNotify

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CollectDataDestroyNotify ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_CollectDataDestroyNotify
    -> GstBase.CollectData.CollectData
    {- ^ /@data@/: the 'GI.GstBase.Structs.CollectData.CollectData' that will be freed -}
    -> m ()
dynamic_CollectDataDestroyNotify __funPtr data_ = liftIO $ do
    data_' <- unsafeManagedPtrGetPtr data_
    (__dynamic_C_CollectDataDestroyNotify __funPtr) data_'
    touchManagedPtr data_
    return ()

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

{- |
A function that will be called when the 'GI.GstBase.Structs.CollectData.CollectData' will be freed.
It is passed the pointer to the structure and should free any custom
memory and resources allocated for it.
-}
type CollectDataDestroyNotify =
    GstBase.CollectData.CollectData
    {- ^ /@data@/: the 'GI.GstBase.Structs.CollectData.CollectData' that will be freed -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `CollectDataDestroyNotify`@.
noCollectDataDestroyNotify :: Maybe CollectDataDestroyNotify
noCollectDataDestroyNotify = Nothing

-- | Wrap the callback into a `GClosure`.
genClosure_CollectDataDestroyNotify :: MonadIO m => CollectDataDestroyNotify -> m (GClosure C_CollectDataDestroyNotify)
genClosure_CollectDataDestroyNotify cb = liftIO $ do
    let cb' = wrap_CollectDataDestroyNotify Nothing cb
    mk_CollectDataDestroyNotify cb' >>= B.GClosure.newGClosure


-- | Wrap a `CollectDataDestroyNotify` into a `C_CollectDataDestroyNotify`.
wrap_CollectDataDestroyNotify ::
    Maybe (Ptr (FunPtr C_CollectDataDestroyNotify)) ->
    CollectDataDestroyNotify ->
    C_CollectDataDestroyNotify
wrap_CollectDataDestroyNotify funptrptr _cb data_ = do
    data_' <- (newPtr GstBase.CollectData.CollectData) data_
    _cb  data_'
    maybeReleaseFunPtr funptrptr