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

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

module GI.GstPbutils.Callbacks
    (

 -- * Signals
-- ** AudioVisualizerShaderFunc #signal:AudioVisualizerShaderFunc#

    AudioVisualizerShaderFunc               ,
    C_AudioVisualizerShaderFunc             ,
    dynamic_AudioVisualizerShaderFunc       ,
    genClosure_AudioVisualizerShaderFunc    ,
    mk_AudioVisualizerShaderFunc            ,
    noAudioVisualizerShaderFunc             ,
    wrap_AudioVisualizerShaderFunc          ,


-- ** InstallPluginsResultFunc #signal:InstallPluginsResultFunc#

    C_InstallPluginsResultFunc              ,
    InstallPluginsResultFunc                ,
    InstallPluginsResultFunc_WithClosures   ,
    drop_closures_InstallPluginsResultFunc  ,
    dynamic_InstallPluginsResultFunc        ,
    genClosure_InstallPluginsResultFunc     ,
    mk_InstallPluginsResultFunc             ,
    noInstallPluginsResultFunc              ,
    noInstallPluginsResultFunc_WithClosures ,
    wrap_InstallPluginsResultFunc           ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.GstPbutils.Enums as GstPbutils.Enums
import {-# SOURCE #-} qualified GI.GstPbutils.Objects.AudioVisualizer as GstPbutils.AudioVisualizer
import qualified GI.GstVideo.Structs.VideoFrame as GstVideo.VideoFrame

-- callback InstallPluginsResultFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "result", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsReturn"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the installation of the requested plugins succeeded or not", 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 "the user data passed to gst_install_plugins_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The prototype of the callback function that will be called once the\nexternal plugin installer program has returned. You only need to provide\na callback function if you are using the asynchronous interface.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_InstallPluginsResultFunc =
    CUInt ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "result", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsReturn"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the installation of the requested plugins succeeded or not", 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 "the user data passed to gst_install_plugins_async()", 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_InstallPluginsResultFunc :: FunPtr C_InstallPluginsResultFunc -> C_InstallPluginsResultFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_InstallPluginsResultFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_InstallPluginsResultFunc
    -> GstPbutils.Enums.InstallPluginsReturn
    {- ^ /@result@/: whether the installation of the requested plugins succeeded or not -}
    -> Ptr ()
    {- ^ /@userData@/: the user data passed to 'GI.GstPbutils.Functions.installPluginsAsync' -}
    -> m ()
dynamic_InstallPluginsResultFunc __funPtr result_ userData = liftIO $ do
    let result_' = (fromIntegral . fromEnum) result_
    (__dynamic_C_InstallPluginsResultFunc __funPtr) result_' userData
    return ()

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

{- |
The prototype of the callback function that will be called once the
external plugin installer program has returned. You only need to provide
a callback function if you are using the asynchronous interface.
-}
type InstallPluginsResultFunc =
    GstPbutils.Enums.InstallPluginsReturn
    {- ^ /@result@/: whether the installation of the requested plugins succeeded or not -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `InstallPluginsResultFunc`@.
noInstallPluginsResultFunc :: Maybe InstallPluginsResultFunc
noInstallPluginsResultFunc = Nothing

{- |
The prototype of the callback function that will be called once the
external plugin installer program has returned. You only need to provide
a callback function if you are using the asynchronous interface.
-}
type InstallPluginsResultFunc_WithClosures =
    GstPbutils.Enums.InstallPluginsReturn
    {- ^ /@result@/: whether the installation of the requested plugins succeeded or not -}
    -> Ptr ()
    {- ^ /@userData@/: the user data passed to 'GI.GstPbutils.Functions.installPluginsAsync' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `InstallPluginsResultFunc_WithClosures`@.
noInstallPluginsResultFunc_WithClosures :: Maybe InstallPluginsResultFunc_WithClosures
noInstallPluginsResultFunc_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_InstallPluginsResultFunc :: InstallPluginsResultFunc -> InstallPluginsResultFunc_WithClosures
drop_closures_InstallPluginsResultFunc _f result_ _ = _f result_

-- | Wrap the callback into a `Closure`.
genClosure_InstallPluginsResultFunc :: InstallPluginsResultFunc -> IO Closure
genClosure_InstallPluginsResultFunc cb = do
    let cb' = drop_closures_InstallPluginsResultFunc cb
    let cb'' = wrap_InstallPluginsResultFunc Nothing cb'
    mk_InstallPluginsResultFunc cb'' >>= newCClosure


-- | Wrap a `InstallPluginsResultFunc` into a `C_InstallPluginsResultFunc`.
wrap_InstallPluginsResultFunc ::
    Maybe (Ptr (FunPtr C_InstallPluginsResultFunc)) ->
    InstallPluginsResultFunc_WithClosures ->
    C_InstallPluginsResultFunc
wrap_InstallPluginsResultFunc funptrptr _cb result_ userData = do
    let result_' = (toEnum . fromIntegral) result_
    _cb  result_' userData
    maybeReleaseFunPtr funptrptr


-- callback AudioVisualizerShaderFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "scope", argType = TInterface (Name {namespace = "GstPbutils", name = "AudioVisualizer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "d", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, 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_AudioVisualizerShaderFunc =
    Ptr GstPbutils.AudioVisualizer.AudioVisualizer ->
    Ptr GstVideo.VideoFrame.VideoFrame ->
    Ptr GstVideo.VideoFrame.VideoFrame ->
    IO ()

-- Args : [Arg {argCName = "scope", argType = TInterface (Name {namespace = "GstPbutils", name = "AudioVisualizer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "d", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, 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_AudioVisualizerShaderFunc :: FunPtr C_AudioVisualizerShaderFunc -> C_AudioVisualizerShaderFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_AudioVisualizerShaderFunc ::
    (B.CallStack.HasCallStack, MonadIO m, GstPbutils.AudioVisualizer.IsAudioVisualizer a) =>
    FunPtr C_AudioVisualizerShaderFunc
    -> a
    -> GstVideo.VideoFrame.VideoFrame
    -> GstVideo.VideoFrame.VideoFrame
    -> m ()
dynamic_AudioVisualizerShaderFunc __funPtr scope s d = liftIO $ do
    scope' <- unsafeManagedPtrCastPtr scope
    s' <- unsafeManagedPtrGetPtr s
    d' <- unsafeManagedPtrGetPtr d
    (__dynamic_C_AudioVisualizerShaderFunc __funPtr) scope' s' d'
    touchManagedPtr scope
    touchManagedPtr s
    touchManagedPtr d
    return ()

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

{- |
/No description available in the introspection data./
-}
type AudioVisualizerShaderFunc =
    GstPbutils.AudioVisualizer.AudioVisualizer
    -> GstVideo.VideoFrame.VideoFrame
    -> GstVideo.VideoFrame.VideoFrame
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `AudioVisualizerShaderFunc`@.
noAudioVisualizerShaderFunc :: Maybe AudioVisualizerShaderFunc
noAudioVisualizerShaderFunc = Nothing

-- | Wrap the callback into a `Closure`.
genClosure_AudioVisualizerShaderFunc :: AudioVisualizerShaderFunc -> IO Closure
genClosure_AudioVisualizerShaderFunc cb = do
    let cb' = wrap_AudioVisualizerShaderFunc Nothing cb
    mk_AudioVisualizerShaderFunc cb' >>= newCClosure


-- | Wrap a `AudioVisualizerShaderFunc` into a `C_AudioVisualizerShaderFunc`.
wrap_AudioVisualizerShaderFunc ::
    Maybe (Ptr (FunPtr C_AudioVisualizerShaderFunc)) ->
    AudioVisualizerShaderFunc ->
    C_AudioVisualizerShaderFunc
wrap_AudioVisualizerShaderFunc funptrptr _cb scope s d = do
    scope' <- (newObject GstPbutils.AudioVisualizer.AudioVisualizer) scope
    s' <- (newPtr GstVideo.VideoFrame.VideoFrame) s
    d' <- (newPtr GstVideo.VideoFrame.VideoFrame) d
    _cb  scope' s' d'
    maybeReleaseFunPtr funptrptr