-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

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

module GI.GES.Functions
    ( 

 -- * Methods


-- ** addMissingUriRelocationUri #method:addMissingUriRelocationUri#

    addMissingUriRelocationUri              ,


-- ** bufferAddFrameCompositionMeta #method:bufferAddFrameCompositionMeta#

    bufferAddFrameCompositionMeta           ,


-- ** deinit #method:deinit#

    deinit                                  ,


-- ** findFormatterForUri #method:findFormatterForUri#

    findFormatterForUri                     ,


-- ** frameCompositionMetaApiGetType #method:frameCompositionMetaApiGetType#

    frameCompositionMetaApiGetType          ,


-- ** init #method:init#

    init                                    ,


-- ** initCheck #method:initCheck#

    initCheck                               ,


-- ** isInitialized #method:isInitialized#

    isInitialized                           ,


-- ** listAssets #method:listAssets#

    listAssets                              ,


-- ** playSinkConvertFrame #method:playSinkConvertFrame#

    playSinkConvertFrame                    ,


-- ** pspecEqual #method:pspecEqual#

    pspecEqual                              ,


-- ** pspecHash #method:pspecHash#

    pspecHash                               ,


-- ** validateRegisterActionTypes #method:validateRegisterActionTypes#

    validateRegisterActionTypes             ,


-- ** version #method:version#

    version                                 ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GES.Callbacks as GES.Callbacks
import {-# SOURCE #-} qualified GI.GES.Flags as GES.Flags
import {-# SOURCE #-} qualified GI.GES.Interfaces.Extractable as GES.Extractable
import {-# SOURCE #-} qualified GI.GES.Interfaces.MetaContainer as GES.MetaContainer
import {-# SOURCE #-} qualified GI.GES.Objects.Asset as GES.Asset
import {-# SOURCE #-} qualified GI.GES.Objects.Marker as GES.Marker
import {-# SOURCE #-} qualified GI.GES.Objects.MarkerList as GES.MarkerList
import {-# SOURCE #-} qualified GI.GES.Structs.FrameCompositionMeta as GES.FrameCompositionMeta
import qualified GI.GLib.Structs.Date as GLib.Date
import qualified GI.GObject.Objects.InitiallyUnowned as GObject.InitiallyUnowned
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncInitable as Gio.AsyncInitable
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gst.Objects.Element as Gst.Element
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.Caps as Gst.Caps
import qualified GI.Gst.Structs.DateTime as Gst.DateTime
import qualified GI.Gst.Structs.Meta as Gst.Meta
import qualified GI.Gst.Structs.Sample as Gst.Sample

#else
import {-# SOURCE #-} qualified GI.GES.Objects.Asset as GES.Asset
import {-# SOURCE #-} qualified GI.GES.Structs.FrameCompositionMeta as GES.FrameCompositionMeta
import qualified GI.Gst.Objects.Element as Gst.Element
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.Caps as Gst.Caps
import qualified GI.Gst.Structs.Sample as Gst.Sample

#endif

-- function version
-- Args: [ Arg
--           { argCName = "major"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a guint to store the major version number"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "minor"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a guint to store the minor version number"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "micro"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a guint to store the micro version number"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "nano"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a guint to store the nano version number"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ges_version" ges_version :: 
    Ptr Word32 ->                           -- major : TBasicType TUInt
    Ptr Word32 ->                           -- minor : TBasicType TUInt
    Ptr Word32 ->                           -- micro : TBasicType TUInt
    Ptr Word32 ->                           -- nano : TBasicType TUInt
    IO ()

-- | Gets the version number of the GStreamer Editing Services library.
version ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ((Word32, Word32, Word32, Word32))
version :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
m (Word32, Word32, Word32, Word32)
version  = IO (Word32, Word32, Word32, Word32)
-> m (Word32, Word32, Word32, Word32)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word32, Word32, Word32, Word32)
 -> m (Word32, Word32, Word32, Word32))
-> IO (Word32, Word32, Word32, Word32)
-> m (Word32, Word32, Word32, Word32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Word32
major <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr Word32
minor <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr Word32
micro <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr Word32
nano <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr Word32 -> Ptr Word32 -> Ptr Word32 -> Ptr Word32 -> IO ()
ges_version Ptr Word32
major Ptr Word32
minor Ptr Word32
micro Ptr Word32
nano
    Word32
major' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
major
    Word32
minor' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
minor
    Word32
micro' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
micro
    Word32
nano' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
nano
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
major
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
minor
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
micro
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
nano
    (Word32, Word32, Word32, Word32)
-> IO (Word32, Word32, Word32, Word32)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Word32
major', Word32
minor', Word32
micro', Word32
nano')


-- function validate_register_action_types
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ges_validate_register_action_types" ges_validate_register_action_types :: 
    IO CInt

-- | /No description available in the introspection data./
validateRegisterActionTypes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
validateRegisterActionTypes :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Bool
validateRegisterActionTypes  = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
ges_validate_register_action_types
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function pspec_hash
-- Args: [ Arg
--           { argCName = "key_spec"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ges_pspec_hash" ges_pspec_hash :: 
    Ptr () ->                               -- key_spec : TBasicType TPtr
    IO Word32

-- | /No description available in the introspection data./
pspecHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -> m Word32
pspecHash :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> m Word32
pspecHash Ptr ()
keySpec = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
ges_pspec_hash Ptr ()
keySpec
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function pspec_equal
-- Args: [ Arg
--           { argCName = "key_spec_1"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key_spec_2"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ges_pspec_equal" ges_pspec_equal :: 
    Ptr () ->                               -- key_spec_1 : TBasicType TPtr
    Ptr () ->                               -- key_spec_2 : TBasicType TPtr
    IO CInt

-- | /No description available in the introspection data./
pspecEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -> Ptr ()
    -> m Bool
pspecEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> Ptr () -> m Bool
pspecEqual Ptr ()
keySpec1 Ptr ()
keySpec2 = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> Ptr () -> IO CInt
ges_pspec_equal Ptr ()
keySpec1 Ptr ()
keySpec2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function play_sink_convert_frame
-- Args: [ Arg
--           { argCName = "playsink"
--           , argType =
--               TInterface Name { namespace = "Gst" , name = "Element" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The playsink to get last frame from"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "caps"
--           , argType = TInterface Name { namespace = "Gst" , name = "Caps" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "The caps defining the format the return value will have"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Sample" })
-- throws : False
-- Skip return : False

foreign import ccall "ges_play_sink_convert_frame" ges_play_sink_convert_frame :: 
    Ptr Gst.Element.Element ->              -- playsink : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Gst.Sample.Sample)

{-# DEPRECATED playSinkConvertFrame ["(Since version 1.18)","Use the \\\"convert-sample\\\" action signal of","@/playsink/@ instead."] #-}
-- | Get the last buffer /@playsink@/ showed
playSinkConvertFrame ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    -- ^ /@playsink@/: The playsink to get last frame from
    -> Gst.Caps.Caps
    -- ^ /@caps@/: The caps defining the format the return value will have
    -> m (Maybe Gst.Sample.Sample)
    -- ^ __Returns:__ A t'GI.Gst.Structs.Sample.Sample' containing the last frame from
    -- /@playsink@/ in the format defined by the /@caps@/
playSinkConvertFrame :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsElement a) =>
a -> Caps -> m (Maybe Sample)
playSinkConvertFrame a
playsink Caps
caps = IO (Maybe Sample) -> m (Maybe Sample)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Sample) -> m (Maybe Sample))
-> IO (Maybe Sample) -> m (Maybe Sample)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Element
playsink' <- a -> IO (Ptr Element)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
playsink
    Ptr Caps
caps' <- Caps -> IO (Ptr Caps)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Caps
caps
    Ptr Sample
result <- Ptr Element -> Ptr Caps -> IO (Ptr Sample)
ges_play_sink_convert_frame Ptr Element
playsink' Ptr Caps
caps'
    Maybe Sample
maybeResult <- Ptr Sample -> (Ptr Sample -> IO Sample) -> IO (Maybe Sample)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Sample
result ((Ptr Sample -> IO Sample) -> IO (Maybe Sample))
-> (Ptr Sample -> IO Sample) -> IO (Maybe Sample)
forall a b. (a -> b) -> a -> b
$ \Ptr Sample
result' -> do
        Sample
result'' <- ((ManagedPtr Sample -> Sample) -> Ptr Sample -> IO Sample
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Sample -> Sample
Gst.Sample.Sample) Ptr Sample
result'
        Sample -> IO Sample
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Sample
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
playsink
    Caps -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Caps
caps
    Maybe Sample -> IO (Maybe Sample)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Sample
maybeResult


-- function list_assets
-- Args: [ Arg
--           { argCName = "filter"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "The type of object that can be extracted from the asset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList (TInterface Name { namespace = "GES" , name = "Asset" }))
-- throws : False
-- Skip return : False

foreign import ccall "ges_list_assets" ges_list_assets :: 
    CGType ->                               -- filter : TBasicType TGType
    IO (Ptr (GList (Ptr GES.Asset.Asset)))

-- | List all the assets in the current cache whose
-- [Asset:extractableType]("GI.GES.Objects.Asset#g:attr:extractableType") are of the given type (including
-- subclasses).
-- 
-- Note that, since only a t'GI.GES.Interfaces.Extractable.Extractable' can be extracted from an asset,
-- using @GES_TYPE_EXTRACTABLE@ as /@filter@/ will return all the assets in
-- the current cache.
listAssets ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@filter@/: The type of object that can be extracted from the asset
    -> m [GES.Asset.Asset]
    -- ^ __Returns:__ A list of all
    -- t'GI.GES.Objects.Asset.Asset'-s currently in the cache whose [Asset:extractableType]("GI.GES.Objects.Asset#g:attr:extractableType") is
    -- of the /@filter@/ type.
listAssets :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> m [Asset]
listAssets GType
filter = IO [Asset] -> m [Asset]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Asset] -> m [Asset]) -> IO [Asset] -> m [Asset]
forall a b. (a -> b) -> a -> b
$ do
    let filter' :: CGType
filter' = GType -> CGType
gtypeToCGType GType
filter
    Ptr (GList (Ptr Asset))
result <- CGType -> IO (Ptr (GList (Ptr Asset)))
ges_list_assets CGType
filter'
    [Ptr Asset]
result' <- Ptr (GList (Ptr Asset)) -> IO [Ptr Asset]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Asset))
result
    [Asset]
result'' <- (Ptr Asset -> IO Asset) -> [Ptr Asset] -> IO [Asset]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr Asset -> Asset) -> Ptr Asset -> IO Asset
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Asset -> Asset
GES.Asset.Asset) [Ptr Asset]
result'
    Ptr (GList (Ptr Asset)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Asset))
result
    [Asset] -> IO [Asset]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Asset]
result''


-- function is_initialized
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ges_is_initialized" ges_is_initialized :: 
    IO CInt

-- | Use this function to check if GES has been initialized with 'GI.GES.Functions.init'
-- or 'GI.GES.Functions.initCheck'.
-- 
-- /Since: 1.16/
isInitialized ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    -- ^ __Returns:__ 'P.True' if initialization has been done, 'P.False' otherwise.
isInitialized :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Bool
isInitialized  = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
ges_is_initialized
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function init_check
-- Args: [ Arg
--           { argCName = "argc"
--           , argType = TBasicType TInt
--           , direction = DirectionInout
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to application's argc"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "argv"
--           , argType = TCArray False (-1) 0 (TBasicType TUTF8)
--           , direction = DirectionInout
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to application's argv"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "argc"
--              , argType = TBasicType TInt
--              , direction = DirectionInout
--              , mayBeNull = True
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "pointer to application's argc"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ges_init_check" ges_init_check :: 
    Ptr Int32 ->                            -- argc : TBasicType TInt
    Ptr (Ptr CString) ->                    -- argv : TCArray False (-1) 0 (TBasicType TUTF8)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Initializes the GStreamer Editing Services library, setting up internal path lists,
-- and loading evrything needed.
-- 
-- This function will return 'P.False' if GES could not be initialized
-- for some reason.
initCheck ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe ([T.Text])
    -- ^ /@argv@/: pointer to application\'s argv
    -> m ((Maybe [T.Text]))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
initCheck :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe [Text] -> m (Maybe [Text])
initCheck Maybe [Text]
argv = IO (Maybe [Text]) -> m (Maybe [Text])
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Text]) -> m (Maybe [Text]))
-> IO (Maybe [Text]) -> m (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ do
    let argc :: Int32
argc = case Maybe [Text]
argv of
            Maybe [Text]
Nothing -> Int32
0
            Just [Text]
jArgv -> Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> Int -> Int32
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Text]
jArgv
    Ptr Int32
argc' <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int32
argc' Int32
argc
    Ptr CString
maybeArgv <- case Maybe [Text]
argv of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jArgv -> do
            Ptr CString
jArgv' <- [Text] -> IO (Ptr CString)
packUTF8CArray [Text]
jArgv
            Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jArgv'
    Ptr (Ptr CString)
maybeArgv' <- IO (Ptr (Ptr CString))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
    Ptr (Ptr CString) -> Ptr CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr CString)
maybeArgv' Ptr CString
maybeArgv
    IO (Maybe [Text]) -> IO () -> IO (Maybe [Text])
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Int32 -> Ptr (Ptr CString) -> Ptr (Ptr GError) -> IO CInt
ges_init_check Ptr Int32
argc' Ptr (Ptr CString)
maybeArgv'
        Int32
argc'' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
argc'
        Ptr CString
maybeArgv'' <- Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CString)
maybeArgv'
        Maybe [Text]
maybeMaybeArgv'' <- Ptr CString -> (Ptr CString -> IO [Text]) -> IO (Maybe [Text])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr CString
maybeArgv'' ((Ptr CString -> IO [Text]) -> IO (Maybe [Text]))
-> (Ptr CString -> IO [Text]) -> IO (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ \Ptr CString
maybeArgv''' -> do
            [Text]
maybeArgv'''' <- (Int32 -> Ptr CString -> IO [Text]
forall a.
(HasCallStack, Integral a) =>
a -> Ptr CString -> IO [Text]
unpackUTF8CArrayWithLength Int32
argc'') Ptr CString
maybeArgv'''
            (Int32 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int32
argc'') CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeArgv'''
            Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeArgv'''
            [Text] -> IO [Text]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
maybeArgv''''
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
        Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
maybeArgv'
        Maybe [Text] -> IO (Maybe [Text])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Text]
maybeMaybeArgv''
     ) (do
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc'
        Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
maybeArgv'
     )


-- function init
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ges_init" ges_init :: 
    IO CInt

-- | Initialize the GStreamer Editing Service. Call this before any usage of
-- GES. You should take care of initilizing GStreamer before calling this
-- function.
-- 
-- MT safety.
-- GStreamer Editing Services do not guarantee MT safety.
-- An application is required to use GES APIs (including 'GI.GES.Functions.deinit')
-- in the thread where 'GI.GES.Functions.init' was called.
init ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
init :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Bool
init  = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
ges_init
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function frame_composition_meta_api_get_type
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "ges_frame_composition_meta_api_get_type" ges_frame_composition_meta_api_get_type :: 
    IO CGType

-- | /No description available in the introspection data./
frameCompositionMetaApiGetType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GType
frameCompositionMetaApiGetType :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m GType
frameCompositionMetaApiGetType  = IO GType -> m GType
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- IO CGType
ges_frame_composition_meta_api_get_type
    let result' :: GType
result' = CGType -> GType
GType CGType
result
    GType -> IO GType
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GType
result'


-- function find_formatter_for_uri
-- Args: [ Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GES" , name = "Asset" })
-- throws : False
-- Skip return : False

foreign import ccall "ges_find_formatter_for_uri" ges_find_formatter_for_uri :: 
    CString ->                              -- uri : TBasicType TUTF8
    IO (Ptr GES.Asset.Asset)

-- | Get the best formatter for /@uri@/. It tries to find a formatter
-- compatible with /@uri@/ extension, if none is found, it returns the default
-- formatter asset.
-- 
-- /Since: 1.18/
findFormatterForUri ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> m GES.Asset.Asset
    -- ^ __Returns:__ The t'GI.GES.Objects.Asset.Asset' for the best formatter to save to /@uri@/
findFormatterForUri :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Asset
findFormatterForUri Text
uri = IO Asset -> m Asset
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Asset -> m Asset) -> IO Asset -> m Asset
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    Ptr Asset
result <- CString -> IO (Ptr Asset)
ges_find_formatter_for_uri CString
uri'
    Text -> Ptr Asset -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"findFormatterForUri" Ptr Asset
result
    Asset
result' <- ((ManagedPtr Asset -> Asset) -> Ptr Asset -> IO Asset
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Asset -> Asset
GES.Asset.Asset) Ptr Asset
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Asset -> IO Asset
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Asset
result'


-- function deinit
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ges_deinit" ges_deinit :: 
    IO ()

-- | Clean up any resources created by GES in 'GI.GES.Functions.init'.
-- 
-- It is normally not needed to call this function in a normal application as the
-- resources will automatically be freed when the program terminates.
-- This function is therefore mostly used by testsuites and other memory profiling tools.
-- This function should be called from the thread where 'GI.GES.Functions.init' was called.
-- 
-- After this call GES should not be used until another 'GI.GES.Functions.init' call.
deinit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
deinit :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
deinit  = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
ges_deinit
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function buffer_add_frame_composition_meta
-- Args: [ Arg
--           { argCName = "buffer"
--           , argType = TInterface Name { namespace = "Gst" , name = "Buffer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "#GstBuffer to which protection metadata should be added."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "GES" , name = "FrameCompositionMeta" })
-- throws : False
-- Skip return : False

foreign import ccall "ges_buffer_add_frame_composition_meta" ges_buffer_add_frame_composition_meta :: 
    Ptr Gst.Buffer.Buffer ->                -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
    IO (Ptr GES.FrameCompositionMeta.FrameCompositionMeta)

-- | Attaches positioning metadata to a t'GI.Gst.Structs.Buffer.Buffer'.
-- 
-- /Since: 1.24/
bufferAddFrameCompositionMeta ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    -- ^ /@buffer@/: t'GI.Gst.Structs.Buffer.Buffer' to which protection metadata should be added.
    -> m GES.FrameCompositionMeta.FrameCompositionMeta
    -- ^ __Returns:__ a pointer to the added t'GI.GES.Structs.FrameCompositionMeta.FrameCompositionMeta'.
bufferAddFrameCompositionMeta :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Buffer -> m FrameCompositionMeta
bufferAddFrameCompositionMeta Buffer
buffer = IO FrameCompositionMeta -> m FrameCompositionMeta
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FrameCompositionMeta -> m FrameCompositionMeta)
-> IO FrameCompositionMeta -> m FrameCompositionMeta
forall a b. (a -> b) -> a -> b
$ do
    Ptr Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
    Ptr FrameCompositionMeta
result <- Ptr Buffer -> IO (Ptr FrameCompositionMeta)
ges_buffer_add_frame_composition_meta Ptr Buffer
buffer'
    Text -> Ptr FrameCompositionMeta -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferAddFrameCompositionMeta" Ptr FrameCompositionMeta
result
    FrameCompositionMeta
result' <- ((ManagedPtr FrameCompositionMeta -> FrameCompositionMeta)
-> Ptr FrameCompositionMeta -> IO FrameCompositionMeta
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr FrameCompositionMeta -> FrameCompositionMeta
GES.FrameCompositionMeta.FrameCompositionMeta) Ptr FrameCompositionMeta
result
    Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
    FrameCompositionMeta -> IO FrameCompositionMeta
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FrameCompositionMeta
result'


-- function add_missing_uri_relocation_uri
-- Args: [ Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "recurse"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ges_add_missing_uri_relocation_uri" ges_add_missing_uri_relocation_uri :: 
    CString ->                              -- uri : TBasicType TUTF8
    CInt ->                                 -- recurse : TBasicType TBoolean
    IO CInt

-- | /No description available in the introspection data./
addMissingUriRelocationUri ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> Bool
    -> m Bool
addMissingUriRelocationUri :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Bool -> m Bool
addMissingUriRelocationUri Text
uri Bool
recurse = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    let recurse' :: CInt
recurse' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
recurse
    CInt
result <- CString -> CInt -> IO CInt
ges_add_missing_uri_relocation_uri CString
uri' CInt
recurse'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'