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

GStreamer is extensible, so 'GI.Gst.Objects.Element.Element' instances can be loaded at runtime.
A plugin system can provide one or more of the basic
\<application>GStreamer\<\/application> 'GI.Gst.Objects.PluginFeature.PluginFeature' subclasses.

A plugin should export a symbol \<symbol>gst_plugin_desc\<\/symbol> that is a
struct of type 'GI.Gst.Structs.PluginDesc.PluginDesc'.
the plugin loader will check the version of the core library the plugin was
linked against and will create a new 'GI.Gst.Objects.Plugin.Plugin'. It will then call the
'GI.Gst.Callbacks.PluginInitFunc' function that was provided in the
\<symbol>gst_plugin_desc\<\/symbol>.

Once you have a handle to a 'GI.Gst.Objects.Plugin.Plugin' (e.g. from the 'GI.Gst.Objects.Registry.Registry'), you
can add any object that subclasses 'GI.Gst.Objects.PluginFeature.PluginFeature'.

Usually plugins are always automatically loaded so you don\'t need to call
'GI.Gst.Objects.Plugin.pluginLoad' explicitly to bring it into memory. There are options to
statically link plugins to an app or even use GStreamer without a plugin
repository in which case 'GI.Gst.Objects.Plugin.pluginLoad' can be needed to bring the plugin
into memory.
-}

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

module GI.Gst.Objects.Plugin
    (

-- * Exported types
    Plugin(..)                              ,
    IsPlugin                                ,
    toPlugin                                ,
    noPlugin                                ,


 -- * Methods
-- ** addDependency #method:addDependency#

#if ENABLE_OVERLOADING
    PluginAddDependencyMethodInfo           ,
#endif
    pluginAddDependency                     ,


-- ** addDependencySimple #method:addDependencySimple#

#if ENABLE_OVERLOADING
    PluginAddDependencySimpleMethodInfo     ,
#endif
    pluginAddDependencySimple               ,


-- ** getCacheData #method:getCacheData#

#if ENABLE_OVERLOADING
    PluginGetCacheDataMethodInfo            ,
#endif
    pluginGetCacheData                      ,


-- ** getDescription #method:getDescription#

#if ENABLE_OVERLOADING
    PluginGetDescriptionMethodInfo          ,
#endif
    pluginGetDescription                    ,


-- ** getFilename #method:getFilename#

#if ENABLE_OVERLOADING
    PluginGetFilenameMethodInfo             ,
#endif
    pluginGetFilename                       ,


-- ** getLicense #method:getLicense#

#if ENABLE_OVERLOADING
    PluginGetLicenseMethodInfo              ,
#endif
    pluginGetLicense                        ,


-- ** getName #method:getName#

#if ENABLE_OVERLOADING
    PluginGetNameMethodInfo                 ,
#endif
    pluginGetName                           ,


-- ** getOrigin #method:getOrigin#

#if ENABLE_OVERLOADING
    PluginGetOriginMethodInfo               ,
#endif
    pluginGetOrigin                         ,


-- ** getPackage #method:getPackage#

#if ENABLE_OVERLOADING
    PluginGetPackageMethodInfo              ,
#endif
    pluginGetPackage                        ,


-- ** getReleaseDateString #method:getReleaseDateString#

#if ENABLE_OVERLOADING
    PluginGetReleaseDateStringMethodInfo    ,
#endif
    pluginGetReleaseDateString              ,


-- ** getSource #method:getSource#

#if ENABLE_OVERLOADING
    PluginGetSourceMethodInfo               ,
#endif
    pluginGetSource                         ,


-- ** getVersion #method:getVersion#

#if ENABLE_OVERLOADING
    PluginGetVersionMethodInfo              ,
#endif
    pluginGetVersion                        ,


-- ** isLoaded #method:isLoaded#

#if ENABLE_OVERLOADING
    PluginIsLoadedMethodInfo                ,
#endif
    pluginIsLoaded                          ,


-- ** listFree #method:listFree#

    pluginListFree                          ,


-- ** load #method:load#

#if ENABLE_OVERLOADING
    PluginLoadMethodInfo                    ,
#endif
    pluginLoad                              ,


-- ** loadByName #method:loadByName#

    pluginLoadByName                        ,


-- ** loadFile #method:loadFile#

    pluginLoadFile                          ,


-- ** registerStatic #method:registerStatic#

    pluginRegisterStatic                    ,


-- ** registerStaticFull #method:registerStaticFull#

    pluginRegisterStaticFull                ,


-- ** setCacheData #method:setCacheData#

#if ENABLE_OVERLOADING
    PluginSetCacheDataMethodInfo            ,
#endif
    pluginSetCacheData                      ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Flags as Gst.Flags
import {-# SOURCE #-} qualified GI.Gst.Objects.Object as Gst.Object
import {-# SOURCE #-} qualified GI.Gst.Structs.Structure as Gst.Structure

-- | Memory-managed wrapper type.
newtype Plugin = Plugin (ManagedPtr Plugin)
foreign import ccall "gst_plugin_get_type"
    c_gst_plugin_get_type :: IO GType

instance GObject Plugin where
    gobjectType = c_gst_plugin_get_type


-- | Type class for types which can be safely cast to `Plugin`, for instance with `toPlugin`.
class (GObject o, O.IsDescendantOf Plugin o) => IsPlugin o
instance (GObject o, O.IsDescendantOf Plugin o) => IsPlugin o

instance O.HasParentTypes Plugin
type instance O.ParentTypes Plugin = '[Gst.Object.Object, GObject.Object.Object]

-- | Cast to `Plugin`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toPlugin :: (MonadIO m, IsPlugin o) => o -> m Plugin
toPlugin = liftIO . unsafeCastTo Plugin

-- | A convenience alias for `Nothing` :: `Maybe` `Plugin`.
noPlugin :: Maybe Plugin
noPlugin = Nothing

#if ENABLE_OVERLOADING
type family ResolvePluginMethod (t :: Symbol) (o :: *) :: * where
    ResolvePluginMethod "addControlBinding" o = Gst.Object.ObjectAddControlBindingMethodInfo
    ResolvePluginMethod "addDependency" o = PluginAddDependencyMethodInfo
    ResolvePluginMethod "addDependencySimple" o = PluginAddDependencySimpleMethodInfo
    ResolvePluginMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePluginMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePluginMethod "defaultError" o = Gst.Object.ObjectDefaultErrorMethodInfo
    ResolvePluginMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePluginMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePluginMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolvePluginMethod "hasActiveControlBindings" o = Gst.Object.ObjectHasActiveControlBindingsMethodInfo
    ResolvePluginMethod "hasAncestor" o = Gst.Object.ObjectHasAncestorMethodInfo
    ResolvePluginMethod "hasAsAncestor" o = Gst.Object.ObjectHasAsAncestorMethodInfo
    ResolvePluginMethod "hasAsParent" o = Gst.Object.ObjectHasAsParentMethodInfo
    ResolvePluginMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePluginMethod "isLoaded" o = PluginIsLoadedMethodInfo
    ResolvePluginMethod "load" o = PluginLoadMethodInfo
    ResolvePluginMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePluginMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePluginMethod "ref" o = Gst.Object.ObjectRefMethodInfo
    ResolvePluginMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePluginMethod "removeControlBinding" o = Gst.Object.ObjectRemoveControlBindingMethodInfo
    ResolvePluginMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePluginMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePluginMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePluginMethod "suggestNextSync" o = Gst.Object.ObjectSuggestNextSyncMethodInfo
    ResolvePluginMethod "syncValues" o = Gst.Object.ObjectSyncValuesMethodInfo
    ResolvePluginMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePluginMethod "unparent" o = Gst.Object.ObjectUnparentMethodInfo
    ResolvePluginMethod "unref" o = Gst.Object.ObjectUnrefMethodInfo
    ResolvePluginMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePluginMethod "getCacheData" o = PluginGetCacheDataMethodInfo
    ResolvePluginMethod "getControlBinding" o = Gst.Object.ObjectGetControlBindingMethodInfo
    ResolvePluginMethod "getControlRate" o = Gst.Object.ObjectGetControlRateMethodInfo
    ResolvePluginMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePluginMethod "getDescription" o = PluginGetDescriptionMethodInfo
    ResolvePluginMethod "getFilename" o = PluginGetFilenameMethodInfo
    ResolvePluginMethod "getGValueArray" o = Gst.Object.ObjectGetGValueArrayMethodInfo
    ResolvePluginMethod "getLicense" o = PluginGetLicenseMethodInfo
    ResolvePluginMethod "getName" o = PluginGetNameMethodInfo
    ResolvePluginMethod "getOrigin" o = PluginGetOriginMethodInfo
    ResolvePluginMethod "getPackage" o = PluginGetPackageMethodInfo
    ResolvePluginMethod "getParent" o = Gst.Object.ObjectGetParentMethodInfo
    ResolvePluginMethod "getPathString" o = Gst.Object.ObjectGetPathStringMethodInfo
    ResolvePluginMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePluginMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePluginMethod "getReleaseDateString" o = PluginGetReleaseDateStringMethodInfo
    ResolvePluginMethod "getSource" o = PluginGetSourceMethodInfo
    ResolvePluginMethod "getValue" o = Gst.Object.ObjectGetValueMethodInfo
    ResolvePluginMethod "getVersion" o = PluginGetVersionMethodInfo
    ResolvePluginMethod "setCacheData" o = PluginSetCacheDataMethodInfo
    ResolvePluginMethod "setControlBindingDisabled" o = Gst.Object.ObjectSetControlBindingDisabledMethodInfo
    ResolvePluginMethod "setControlBindingsDisabled" o = Gst.Object.ObjectSetControlBindingsDisabledMethodInfo
    ResolvePluginMethod "setControlRate" o = Gst.Object.ObjectSetControlRateMethodInfo
    ResolvePluginMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePluginMethod "setName" o = Gst.Object.ObjectSetNameMethodInfo
    ResolvePluginMethod "setParent" o = Gst.Object.ObjectSetParentMethodInfo
    ResolvePluginMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePluginMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePluginMethod t Plugin, O.MethodInfo info Plugin p) => OL.IsLabel t (Plugin -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Plugin
type instance O.AttributeList Plugin = PluginAttributeList
type PluginAttributeList = ('[ '("name", Gst.Object.ObjectNamePropertyInfo), '("parent", Gst.Object.ObjectParentPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Plugin = PluginSignalList
type PluginSignalList = ('[ '("deepNotify", Gst.Object.ObjectDeepNotifySignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Plugin::add_dependency
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstPlugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "env_vars", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "%NULL-terminated array of environment variables affecting the\n    feature set of the plugin (e.g. an environment variable containing\n    paths where to look for additional modules/plugins of a library),\n    or %NULL. Environment variable names may be followed by a path component\n     which will be added to the content of the environment variable, e.g.\n     \"HOME/.mystuff/plugins\".", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "paths", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "%NULL-terminated array of directories/paths where dependent files\n    may be, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "names", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "%NULL-terminated array of file names (or file name suffixes,\n    depending on @flags) to be used in combination with the paths from\n    @paths and/or the paths extracted from the environment variables in\n    @env_vars, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gst", name = "PluginDependencyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "optional flags, or #GST_PLUGIN_DEPENDENCY_FLAG_NONE", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_add_dependency" gst_plugin_add_dependency ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    Ptr CString ->                          -- env_vars : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr CString ->                          -- paths : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr CString ->                          -- names : TCArray True (-1) (-1) (TBasicType TUTF8)
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gst", name = "PluginDependencyFlags"})
    IO ()

{- |
Make GStreamer aware of external dependencies which affect the feature
set of this plugin (ie. the elements or typefinders associated with it).

GStreamer will re-inspect plugins with external dependencies whenever any
of the external dependencies change. This is useful for plugins which wrap
other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
library and makes visualisations available as GStreamer elements, or a
codec loader which exposes elements and\/or caps dependent on what external
codec libraries are currently installed.
-}
pluginAddDependency ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.Gst.Objects.Plugin.Plugin' -}
    -> Maybe ([T.Text])
    {- ^ /@envVars@/: 'Nothing'-terminated array of environment variables affecting the
    feature set of the plugin (e.g. an environment variable containing
    paths where to look for additional modules\/plugins of a library),
    or 'Nothing'. Environment variable names may be followed by a path component
     which will be added to the content of the environment variable, e.g.
     \"HOME\/.mystuff\/plugins\". -}
    -> Maybe ([T.Text])
    {- ^ /@paths@/: 'Nothing'-terminated array of directories\/paths where dependent files
    may be, or 'Nothing'. -}
    -> Maybe ([T.Text])
    {- ^ /@names@/: 'Nothing'-terminated array of file names (or file name suffixes,
    depending on /@flags@/) to be used in combination with the paths from
    /@paths@/ and\/or the paths extracted from the environment variables in
    /@envVars@/, or 'Nothing'. -}
    -> [Gst.Flags.PluginDependencyFlags]
    {- ^ /@flags@/: optional flags, or @/GST_PLUGIN_DEPENDENCY_FLAG_NONE/@ -}
    -> m ()
pluginAddDependency plugin envVars paths names flags = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    maybeEnvVars <- case envVars of
        Nothing -> return nullPtr
        Just jEnvVars -> do
            jEnvVars' <- packZeroTerminatedUTF8CArray jEnvVars
            return jEnvVars'
    maybePaths <- case paths of
        Nothing -> return nullPtr
        Just jPaths -> do
            jPaths' <- packZeroTerminatedUTF8CArray jPaths
            return jPaths'
    maybeNames <- case names of
        Nothing -> return nullPtr
        Just jNames -> do
            jNames' <- packZeroTerminatedUTF8CArray jNames
            return jNames'
    let flags' = gflagsToWord flags
    gst_plugin_add_dependency plugin' maybeEnvVars maybePaths maybeNames flags'
    touchManagedPtr plugin
    mapZeroTerminatedCArray freeMem maybeEnvVars
    freeMem maybeEnvVars
    mapZeroTerminatedCArray freeMem maybePaths
    freeMem maybePaths
    mapZeroTerminatedCArray freeMem maybeNames
    freeMem maybeNames
    return ()

#if ENABLE_OVERLOADING
data PluginAddDependencyMethodInfo
instance (signature ~ (Maybe ([T.Text]) -> Maybe ([T.Text]) -> Maybe ([T.Text]) -> [Gst.Flags.PluginDependencyFlags] -> m ()), MonadIO m, IsPlugin a) => O.MethodInfo PluginAddDependencyMethodInfo a signature where
    overloadedMethod _ = pluginAddDependency

#endif

-- method Plugin::add_dependency_simple
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstPlugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "env_vars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "one or more environment variables (separated by ':', ';' or ','),\n     or %NULL. Environment variable names may be followed by a path component\n     which will be added to the content of the environment variable, e.g.\n     \"HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "paths", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "one ore more directory paths (separated by ':' or ';' or ','),\n     or %NULL. Example: \"/usr/lib/mystuff/plugins\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "names", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "one or more file names or file name suffixes (separated by commas),\n     or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gst", name = "PluginDependencyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "optional flags, or #GST_PLUGIN_DEPENDENCY_FLAG_NONE", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_add_dependency_simple" gst_plugin_add_dependency_simple ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    CString ->                              -- env_vars : TBasicType TUTF8
    CString ->                              -- paths : TBasicType TUTF8
    CString ->                              -- names : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gst", name = "PluginDependencyFlags"})
    IO ()

{- |
Make GStreamer aware of external dependencies which affect the feature
set of this plugin (ie. the elements or typefinders associated with it).

GStreamer will re-inspect plugins with external dependencies whenever any
of the external dependencies change. This is useful for plugins which wrap
other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
library and makes visualisations available as GStreamer elements, or a
codec loader which exposes elements and\/or caps dependent on what external
codec libraries are currently installed.

Convenience wrapper function for 'GI.Gst.Objects.Plugin.pluginAddDependency' which
takes simple strings as arguments instead of string arrays, with multiple
arguments separated by predefined delimiters (see above).
-}
pluginAddDependencySimple ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: the 'GI.Gst.Objects.Plugin.Plugin' -}
    -> Maybe (T.Text)
    {- ^ /@envVars@/: one or more environment variables (separated by \':\', \';\' or \',\'),
     or 'Nothing'. Environment variable names may be followed by a path component
     which will be added to the content of the environment variable, e.g.
     \"HOME\/.mystuff\/plugins:MYSTUFF_PLUGINS_PATH\" -}
    -> Maybe (T.Text)
    {- ^ /@paths@/: one ore more directory paths (separated by \':\' or \';\' or \',\'),
     or 'Nothing'. Example: \"\/usr\/lib\/mystuff\/plugins\" -}
    -> Maybe (T.Text)
    {- ^ /@names@/: one or more file names or file name suffixes (separated by commas),
     or 'Nothing' -}
    -> [Gst.Flags.PluginDependencyFlags]
    {- ^ /@flags@/: optional flags, or @/GST_PLUGIN_DEPENDENCY_FLAG_NONE/@ -}
    -> m ()
pluginAddDependencySimple plugin envVars paths names flags = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    maybeEnvVars <- case envVars of
        Nothing -> return nullPtr
        Just jEnvVars -> do
            jEnvVars' <- textToCString jEnvVars
            return jEnvVars'
    maybePaths <- case paths of
        Nothing -> return nullPtr
        Just jPaths -> do
            jPaths' <- textToCString jPaths
            return jPaths'
    maybeNames <- case names of
        Nothing -> return nullPtr
        Just jNames -> do
            jNames' <- textToCString jNames
            return jNames'
    let flags' = gflagsToWord flags
    gst_plugin_add_dependency_simple plugin' maybeEnvVars maybePaths maybeNames flags'
    touchManagedPtr plugin
    freeMem maybeEnvVars
    freeMem maybePaths
    freeMem maybeNames
    return ()

#if ENABLE_OVERLOADING
data PluginAddDependencySimpleMethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (T.Text) -> Maybe (T.Text) -> [Gst.Flags.PluginDependencyFlags] -> m ()), MonadIO m, IsPlugin a) => O.MethodInfo PluginAddDependencySimpleMethodInfo a signature where
    overloadedMethod _ = pluginAddDependencySimple

#endif

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

foreign import ccall "gst_plugin_get_cache_data" gst_plugin_get_cache_data ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO (Ptr Gst.Structure.Structure)

{- |
Gets the plugin specific data cache. If it is 'Nothing' there is no cached data
stored. This is the case when the registry is getting rebuilt.
-}
pluginGetCacheData ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: a plugin -}
    -> m (Maybe Gst.Structure.Structure)
    {- ^ __Returns:__ The cached data as a
'GI.Gst.Structs.Structure.Structure' or 'Nothing'. -}
pluginGetCacheData plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_cache_data plugin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Gst.Structure.Structure) result'
        return result''
    touchManagedPtr plugin
    return maybeResult

#if ENABLE_OVERLOADING
data PluginGetCacheDataMethodInfo
instance (signature ~ (m (Maybe Gst.Structure.Structure)), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetCacheDataMethodInfo a signature where
    overloadedMethod _ = pluginGetCacheData

#endif

-- method Plugin::get_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get long name of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_description" gst_plugin_get_description ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
Get the long descriptive name of the plugin
-}
pluginGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get long name of -}
    -> m T.Text
    {- ^ __Returns:__ the long name of the plugin -}
pluginGetDescription plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_description plugin'
    checkUnexpectedReturnNULL "pluginGetDescription" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetDescriptionMethodInfo a signature where
    overloadedMethod _ = pluginGetDescription

#endif

-- method Plugin::get_filename
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the filename of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_filename" gst_plugin_get_filename ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the filename of the plugin
-}
pluginGetFilename ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the filename of -}
    -> m [Char]
    {- ^ __Returns:__ the filename of the plugin -}
pluginGetFilename plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_filename plugin'
    checkUnexpectedReturnNULL "pluginGetFilename" result
    result' <- cstringToString result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetFilenameMethodInfo
instance (signature ~ (m [Char]), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetFilenameMethodInfo a signature where
    overloadedMethod _ = pluginGetFilename

#endif

-- method Plugin::get_license
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the license of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_license" gst_plugin_get_license ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the license of the plugin
-}
pluginGetLicense ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the license of -}
    -> m T.Text
    {- ^ __Returns:__ the license of the plugin -}
pluginGetLicense plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_license plugin'
    checkUnexpectedReturnNULL "pluginGetLicense" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetLicenseMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetLicenseMethodInfo a signature where
    overloadedMethod _ = pluginGetLicense

#endif

-- method Plugin::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the name of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_name" gst_plugin_get_name ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
Get the short name of the plugin
-}
pluginGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the name of -}
    -> m T.Text
    {- ^ __Returns:__ the name of the plugin -}
pluginGetName plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_name plugin'
    checkUnexpectedReturnNULL "pluginGetName" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetNameMethodInfo a signature where
    overloadedMethod _ = pluginGetName

#endif

-- method Plugin::get_origin
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the origin of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_origin" gst_plugin_get_origin ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the URL where the plugin comes from
-}
pluginGetOrigin ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the origin of -}
    -> m T.Text
    {- ^ __Returns:__ the origin of the plugin -}
pluginGetOrigin plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_origin plugin'
    checkUnexpectedReturnNULL "pluginGetOrigin" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetOriginMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetOriginMethodInfo a signature where
    overloadedMethod _ = pluginGetOrigin

#endif

-- method Plugin::get_package
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the package of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_package" gst_plugin_get_package ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the package the plugin belongs to.
-}
pluginGetPackage ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the package of -}
    -> m T.Text
    {- ^ __Returns:__ the package of the plugin -}
pluginGetPackage plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_package plugin'
    checkUnexpectedReturnNULL "pluginGetPackage" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetPackageMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetPackageMethodInfo a signature where
    overloadedMethod _ = pluginGetPackage

#endif

-- method Plugin::get_release_date_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the release date of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_release_date_string" gst_plugin_get_release_date_string ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
Get the release date (and possibly time) in form of a string, if available.

For normal GStreamer plugin releases this will usually just be a date in
the form of \"YYYY-MM-DD\", while pre-releases and builds from git may contain
a time component after the date as well, in which case the string will be
formatted like \"YYYY-MM-DDTHH:MMZ\" (e.g. \"2012-04-30T09:30Z\").

There may be plugins that do not have a valid release date set on them.
-}
pluginGetReleaseDateString ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the release date of -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the date string of the plugin, or 'Nothing' if not
available. -}
pluginGetReleaseDateString plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_release_date_string plugin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr plugin
    return maybeResult

#if ENABLE_OVERLOADING
data PluginGetReleaseDateStringMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetReleaseDateStringMethodInfo a signature where
    overloadedMethod _ = pluginGetReleaseDateString

#endif

-- method Plugin::get_source
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the source of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_source" gst_plugin_get_source ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the source module the plugin belongs to.
-}
pluginGetSource ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the source of -}
    -> m T.Text
    {- ^ __Returns:__ the source of the plugin -}
pluginGetSource plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_source plugin'
    checkUnexpectedReturnNULL "pluginGetSource" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetSourceMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetSourceMethodInfo a signature where
    overloadedMethod _ = pluginGetSource

#endif

-- method Plugin::get_version
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to get the version of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_get_version" gst_plugin_get_version ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CString

{- |
get the version of the plugin
-}
pluginGetVersion ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to get the version of -}
    -> m T.Text
    {- ^ __Returns:__ the version of the plugin -}
pluginGetVersion plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_get_version plugin'
    checkUnexpectedReturnNULL "pluginGetVersion" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginGetVersionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPlugin a) => O.MethodInfo PluginGetVersionMethodInfo a signature where
    overloadedMethod _ = pluginGetVersion

#endif

-- method Plugin::is_loaded
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plugin to query", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_is_loaded" gst_plugin_is_loaded ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO CInt

{- |
queries if the plugin is loaded into memory
-}
pluginIsLoaded ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to query -}
    -> m Bool
    {- ^ __Returns:__ 'True' is loaded, 'False' otherwise -}
pluginIsLoaded plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_is_loaded plugin'
    let result' = (/= 0) result
    touchManagedPtr plugin
    return result'

#if ENABLE_OVERLOADING
data PluginIsLoadedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPlugin a) => O.MethodInfo PluginIsLoadedMethodInfo a signature where
    overloadedMethod _ = pluginIsLoaded

#endif

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

foreign import ccall "gst_plugin_load" gst_plugin_load ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    IO (Ptr Plugin)

{- |
Loads /@plugin@/. Note that the *return value* is the loaded plugin; /@plugin@/ is
untouched. The normal use pattern of this function goes like this:

>
>GstPlugin *loaded_plugin;
>loaded_plugin = gst_plugin_load (plugin);
>// presumably, we're no longer interested in the potentially-unloaded plugin
>gst_object_unref (plugin);
>plugin = loaded_plugin;
-}
pluginLoad ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: plugin to load -}
    -> m (Maybe Plugin)
    {- ^ __Returns:__ a reference to a loaded plugin, or
'Nothing' on error. -}
pluginLoad plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- gst_plugin_load plugin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Plugin) result'
        return result''
    touchManagedPtr plugin
    return maybeResult

#if ENABLE_OVERLOADING
data PluginLoadMethodInfo
instance (signature ~ (m (Maybe Plugin)), MonadIO m, IsPlugin a) => O.MethodInfo PluginLoadMethodInfo a signature where
    overloadedMethod _ = pluginLoad

#endif

-- method Plugin::set_cache_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "Gst", name = "Plugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cache_data", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a structure containing the data to cache", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_set_cache_data" gst_plugin_set_cache_data ::
    Ptr Plugin ->                           -- plugin : TInterface (Name {namespace = "Gst", name = "Plugin"})
    Ptr Gst.Structure.Structure ->          -- cache_data : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO ()

{- |
Adds plugin specific data to cache. Passes the ownership of the structure to
the /@plugin@/.

The cache is flushed every time the registry is rebuilt.
-}
pluginSetCacheData ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    a
    {- ^ /@plugin@/: a plugin -}
    -> Gst.Structure.Structure
    {- ^ /@cacheData@/: a structure containing the data to cache -}
    -> m ()
pluginSetCacheData plugin cacheData = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    cacheData' <- B.ManagedPtr.disownBoxed cacheData
    gst_plugin_set_cache_data plugin' cacheData'
    touchManagedPtr plugin
    touchManagedPtr cacheData
    return ()

#if ENABLE_OVERLOADING
data PluginSetCacheDataMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m ()), MonadIO m, IsPlugin a) => O.MethodInfo PluginSetCacheDataMethodInfo a signature where
    overloadedMethod _ = pluginSetCacheData

#endif

-- method Plugin::list_free
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Gst", name = "Plugin"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "list of #GstPlugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_list_free" gst_plugin_list_free ::
    Ptr (GList (Ptr Plugin)) ->             -- list : TGList (TInterface (Name {namespace = "Gst", name = "Plugin"}))
    IO ()

{- |
Unrefs each member of /@list@/, then frees the list.
-}
pluginListFree ::
    (B.CallStack.HasCallStack, MonadIO m, IsPlugin a) =>
    [a]
    {- ^ /@list@/: list of 'GI.Gst.Objects.Plugin.Plugin' -}
    -> m ()
pluginListFree list = liftIO $ do
    list' <- mapM B.ManagedPtr.disownObject list
    list'' <- packGList list'
    gst_plugin_list_free list''
    mapM_ touchManagedPtr list
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Plugin::load_by_name
-- method type : MemberFunction
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of plugin to load", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Plugin"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_load_by_name" gst_plugin_load_by_name ::
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Plugin)

{- |
Load the named plugin. Refs the plugin.
-}
pluginLoadByName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@name@/: name of plugin to load -}
    -> m (Maybe Plugin)
    {- ^ __Returns:__ a reference to a loaded plugin, or
'Nothing' on error. -}
pluginLoadByName name = liftIO $ do
    name' <- textToCString name
    result <- gst_plugin_load_by_name name'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Plugin) result'
        return result''
    freeMem name'
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method Plugin::load_file
-- method type : MemberFunction
-- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the plugin filename to load", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Plugin"}))
-- throws : True
-- Skip return : False

foreign import ccall "gst_plugin_load_file" gst_plugin_load_file ::
    CString ->                              -- filename : TBasicType TFileName
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Plugin)

{- |
Loads the given plugin and refs it.  Caller needs to unref after use.
-}
pluginLoadFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Char]
    {- ^ /@filename@/: the plugin filename to load -}
    -> m Plugin
    {- ^ __Returns:__ a reference to the existing loaded GstPlugin, a
reference to the newly-loaded GstPlugin, or 'Nothing' if an error occurred. /(Can throw 'Data.GI.Base.GError.GError')/ -}
pluginLoadFile filename = liftIO $ do
    filename' <- stringToCString filename
    onException (do
        result <- propagateGError $ gst_plugin_load_file filename'
        checkUnexpectedReturnNULL "pluginLoadFile" result
        result' <- (wrapObject Plugin) result
        freeMem filename'
        return result'
     ) (do
        freeMem filename'
     )

#if ENABLE_OVERLOADING
#endif

-- method Plugin::register_static
-- method type : MemberFunction
-- Args : [Arg {argCName = "major_version", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the major version number of the GStreamer core that the\n    plugin was compiled for, you can just use GST_VERSION_MAJOR here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "minor_version", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minor version number of the GStreamer core that the\n    plugin was compiled for, you can just use GST_VERSION_MINOR here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a unique name of the plugin (ideally prefixed with an application- or\n    library-specific namespace prefix in order to avoid name conflicts in\n    case a similar plugin with the same name ever gets added to GStreamer)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "description of the plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "init_func", argType = TInterface (Name {namespace = "Gst", name = "PluginInitFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the init function of this plugin.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "version", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "version string of the plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "license", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "effective license of plugin. Must be one of the approved licenses\n    (see #GstPluginDesc above) or the plugin will not be registered.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source module plugin belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "package", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "shipped package plugin belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "URL to provider of plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_register_static" gst_plugin_register_static ::
    Int32 ->                                -- major_version : TBasicType TInt
    Int32 ->                                -- minor_version : TBasicType TInt
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- description : TBasicType TUTF8
    FunPtr Gst.Callbacks.C_PluginInitFunc -> -- init_func : TInterface (Name {namespace = "Gst", name = "PluginInitFunc"})
    CString ->                              -- version : TBasicType TUTF8
    CString ->                              -- license : TBasicType TUTF8
    CString ->                              -- source : TBasicType TUTF8
    CString ->                              -- package : TBasicType TUTF8
    CString ->                              -- origin : TBasicType TUTF8
    IO CInt

{- |
Registers a static plugin, ie. a plugin which is private to an application
or library and contained within the application or library (as opposed to
being shipped as a separate module file).

You must make sure that GStreamer has been initialised (with 'GI.Gst.Functions.init' or
via @/gst_init_get_option_group()/@) before calling this function.
-}
pluginRegisterStatic ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@majorVersion@/: the major version number of the GStreamer core that the
    plugin was compiled for, you can just use GST_VERSION_MAJOR here -}
    -> Int32
    {- ^ /@minorVersion@/: the minor version number of the GStreamer core that the
    plugin was compiled for, you can just use GST_VERSION_MINOR here -}
    -> T.Text
    {- ^ /@name@/: a unique name of the plugin (ideally prefixed with an application- or
    library-specific namespace prefix in order to avoid name conflicts in
    case a similar plugin with the same name ever gets added to GStreamer) -}
    -> T.Text
    {- ^ /@description@/: description of the plugin -}
    -> Gst.Callbacks.PluginInitFunc
    {- ^ /@initFunc@/: pointer to the init function of this plugin. -}
    -> T.Text
    {- ^ /@version@/: version string of the plugin -}
    -> T.Text
    {- ^ /@license@/: effective license of plugin. Must be one of the approved licenses
    (see 'GI.Gst.Structs.PluginDesc.PluginDesc' above) or the plugin will not be registered. -}
    -> T.Text
    {- ^ /@source@/: source module plugin belongs to -}
    -> T.Text
    {- ^ /@package@/: shipped package plugin belongs to -}
    -> T.Text
    {- ^ /@origin@/: URL to provider of plugin -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the plugin was registered correctly, otherwise 'False'. -}
pluginRegisterStatic majorVersion minorVersion name description initFunc version license source package origin = liftIO $ do
    name' <- textToCString name
    description' <- textToCString description
    initFunc' <- Gst.Callbacks.mk_PluginInitFunc (Gst.Callbacks.wrap_PluginInitFunc Nothing initFunc)
    version' <- textToCString version
    license' <- textToCString license
    source' <- textToCString source
    package' <- textToCString package
    origin' <- textToCString origin
    result <- gst_plugin_register_static majorVersion minorVersion name' description' initFunc' version' license' source' package' origin'
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr initFunc'
    freeMem name'
    freeMem description'
    freeMem version'
    freeMem license'
    freeMem source'
    freeMem package'
    freeMem origin'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Plugin::register_static_full
-- method type : MemberFunction
-- Args : [Arg {argCName = "major_version", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the major version number of the GStreamer core that the\n    plugin was compiled for, you can just use GST_VERSION_MAJOR here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "minor_version", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minor version number of the GStreamer core that the\n    plugin was compiled for, you can just use GST_VERSION_MINOR here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a unique name of the plugin (ideally prefixed with an application- or\n    library-specific namespace prefix in order to avoid name conflicts in\n    case a similar plugin with the same name ever gets added to GStreamer)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "description of the plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "init_full_func", argType = TInterface (Name {namespace = "Gst", name = "PluginInitFullFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the init function with user data\n    of this plugin.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 10, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "version", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "version string of the plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "license", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "effective license of plugin. Must be one of the approved licenses\n    (see #GstPluginDesc above) or the plugin will not be registered.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source module plugin belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "package", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "shipped package plugin belongs to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "URL to provider of plugin", 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 "gpointer to user data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugin_register_static_full" gst_plugin_register_static_full ::
    Int32 ->                                -- major_version : TBasicType TInt
    Int32 ->                                -- minor_version : TBasicType TInt
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- description : TBasicType TUTF8
    FunPtr Gst.Callbacks.C_PluginInitFullFunc -> -- init_full_func : TInterface (Name {namespace = "Gst", name = "PluginInitFullFunc"})
    CString ->                              -- version : TBasicType TUTF8
    CString ->                              -- license : TBasicType TUTF8
    CString ->                              -- source : TBasicType TUTF8
    CString ->                              -- package : TBasicType TUTF8
    CString ->                              -- origin : TBasicType TUTF8
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CInt

{- |
Registers a static plugin, ie. a plugin which is private to an application
or library and contained within the application or library (as opposed to
being shipped as a separate module file) with a 'GI.Gst.Callbacks.PluginInitFullFunc'
which allows user data to be passed to the callback function (useful
for bindings).

You must make sure that GStreamer has been initialised (with 'GI.Gst.Functions.init' or
via @/gst_init_get_option_group()/@) before calling this function.
-}
pluginRegisterStaticFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@majorVersion@/: the major version number of the GStreamer core that the
    plugin was compiled for, you can just use GST_VERSION_MAJOR here -}
    -> Int32
    {- ^ /@minorVersion@/: the minor version number of the GStreamer core that the
    plugin was compiled for, you can just use GST_VERSION_MINOR here -}
    -> T.Text
    {- ^ /@name@/: a unique name of the plugin (ideally prefixed with an application- or
    library-specific namespace prefix in order to avoid name conflicts in
    case a similar plugin with the same name ever gets added to GStreamer) -}
    -> T.Text
    {- ^ /@description@/: description of the plugin -}
    -> Gst.Callbacks.PluginInitFullFunc
    {- ^ /@initFullFunc@/: pointer to the init function with user data
    of this plugin. -}
    -> T.Text
    {- ^ /@version@/: version string of the plugin -}
    -> T.Text
    {- ^ /@license@/: effective license of plugin. Must be one of the approved licenses
    (see 'GI.Gst.Structs.PluginDesc.PluginDesc' above) or the plugin will not be registered. -}
    -> T.Text
    {- ^ /@source@/: source module plugin belongs to -}
    -> T.Text
    {- ^ /@package@/: shipped package plugin belongs to -}
    -> T.Text
    {- ^ /@origin@/: URL to provider of plugin -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the plugin was registered correctly, otherwise 'False'. -}
pluginRegisterStaticFull majorVersion minorVersion name description initFullFunc version license source package origin = liftIO $ do
    name' <- textToCString name
    description' <- textToCString description
    initFullFunc' <- Gst.Callbacks.mk_PluginInitFullFunc (Gst.Callbacks.wrap_PluginInitFullFunc Nothing (Gst.Callbacks.drop_closures_PluginInitFullFunc initFullFunc))
    version' <- textToCString version
    license' <- textToCString license
    source' <- textToCString source
    package' <- textToCString package
    origin' <- textToCString origin
    let userData = nullPtr
    result <- gst_plugin_register_static_full majorVersion minorVersion name' description' initFullFunc' version' license' source' package' origin' userData
    let result' = (/= 0) result
    safeFreeFunPtr $ castFunPtrToPtr initFullFunc'
    freeMem name'
    freeMem description'
    freeMem version'
    freeMem license'
    freeMem source'
    freeMem package'
    freeMem origin'
    return result'

#if ENABLE_OVERLOADING
#endif