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

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

module GI.GstPbutils.Functions
    (

 -- * Methods
-- ** codecUtilsAacCapsSetLevelAndProfile #method:codecUtilsAacCapsSetLevelAndProfile#

    codecUtilsAacCapsSetLevelAndProfile     ,


-- ** codecUtilsAacGetChannels #method:codecUtilsAacGetChannels#

    codecUtilsAacGetChannels                ,


-- ** codecUtilsAacGetIndexFromSampleRate #method:codecUtilsAacGetIndexFromSampleRate#

    codecUtilsAacGetIndexFromSampleRate     ,


-- ** codecUtilsAacGetLevel #method:codecUtilsAacGetLevel#

    codecUtilsAacGetLevel                   ,


-- ** codecUtilsAacGetProfile #method:codecUtilsAacGetProfile#

    codecUtilsAacGetProfile                 ,


-- ** codecUtilsAacGetSampleRate #method:codecUtilsAacGetSampleRate#

    codecUtilsAacGetSampleRate              ,


-- ** codecUtilsAacGetSampleRateFromIndex #method:codecUtilsAacGetSampleRateFromIndex#

    codecUtilsAacGetSampleRateFromIndex     ,


-- ** codecUtilsH264CapsSetLevelAndProfile #method:codecUtilsH264CapsSetLevelAndProfile#

    codecUtilsH264CapsSetLevelAndProfile    ,


-- ** codecUtilsH264GetLevel #method:codecUtilsH264GetLevel#

    codecUtilsH264GetLevel                  ,


-- ** codecUtilsH264GetLevelIdc #method:codecUtilsH264GetLevelIdc#

    codecUtilsH264GetLevelIdc               ,


-- ** codecUtilsH264GetProfile #method:codecUtilsH264GetProfile#

    codecUtilsH264GetProfile                ,


-- ** codecUtilsH265CapsSetLevelTierAndProfile #method:codecUtilsH265CapsSetLevelTierAndProfile#

    codecUtilsH265CapsSetLevelTierAndProfile,


-- ** codecUtilsH265GetLevel #method:codecUtilsH265GetLevel#

    codecUtilsH265GetLevel                  ,


-- ** codecUtilsH265GetLevelIdc #method:codecUtilsH265GetLevelIdc#

    codecUtilsH265GetLevelIdc               ,


-- ** codecUtilsH265GetProfile #method:codecUtilsH265GetProfile#

    codecUtilsH265GetProfile                ,


-- ** codecUtilsH265GetTier #method:codecUtilsH265GetTier#

    codecUtilsH265GetTier                   ,


-- ** codecUtilsMpeg4videoCapsSetLevelAndProfile #method:codecUtilsMpeg4videoCapsSetLevelAndProfile#

    codecUtilsMpeg4videoCapsSetLevelAndProfile,


-- ** codecUtilsMpeg4videoGetLevel #method:codecUtilsMpeg4videoGetLevel#

    codecUtilsMpeg4videoGetLevel            ,


-- ** codecUtilsMpeg4videoGetProfile #method:codecUtilsMpeg4videoGetProfile#

    codecUtilsMpeg4videoGetProfile          ,


-- ** codecUtilsOpusCreateCaps #method:codecUtilsOpusCreateCaps#

    codecUtilsOpusCreateCaps                ,


-- ** codecUtilsOpusCreateCapsFromHeader #method:codecUtilsOpusCreateCapsFromHeader#

    codecUtilsOpusCreateCapsFromHeader      ,


-- ** codecUtilsOpusCreateHeader #method:codecUtilsOpusCreateHeader#

    codecUtilsOpusCreateHeader              ,


-- ** codecUtilsOpusParseCaps #method:codecUtilsOpusParseCaps#

    codecUtilsOpusParseCaps                 ,


-- ** codecUtilsOpusParseHeader #method:codecUtilsOpusParseHeader#

    codecUtilsOpusParseHeader               ,


-- ** encodingListAllTargets #method:encodingListAllTargets#

    encodingListAllTargets                  ,


-- ** encodingListAvailableCategories #method:encodingListAvailableCategories#

    encodingListAvailableCategories         ,


-- ** installPluginsAsync #method:installPluginsAsync#

    installPluginsAsync                     ,


-- ** installPluginsInstallationInProgress #method:installPluginsInstallationInProgress#

    installPluginsInstallationInProgress    ,


-- ** installPluginsSupported #method:installPluginsSupported#

    installPluginsSupported                 ,


-- ** installPluginsSync #method:installPluginsSync#

    installPluginsSync                      ,


-- ** isMissingPluginMessage #method:isMissingPluginMessage#

    isMissingPluginMessage                  ,


-- ** missingDecoderInstallerDetailNew #method:missingDecoderInstallerDetailNew#

    missingDecoderInstallerDetailNew        ,


-- ** missingDecoderMessageNew #method:missingDecoderMessageNew#

    missingDecoderMessageNew                ,


-- ** missingElementInstallerDetailNew #method:missingElementInstallerDetailNew#

    missingElementInstallerDetailNew        ,


-- ** missingElementMessageNew #method:missingElementMessageNew#

    missingElementMessageNew                ,


-- ** missingEncoderInstallerDetailNew #method:missingEncoderInstallerDetailNew#

    missingEncoderInstallerDetailNew        ,


-- ** missingEncoderMessageNew #method:missingEncoderMessageNew#

    missingEncoderMessageNew                ,


-- ** missingPluginMessageGetDescription #method:missingPluginMessageGetDescription#

    missingPluginMessageGetDescription      ,


-- ** missingPluginMessageGetInstallerDetail #method:missingPluginMessageGetInstallerDetail#

    missingPluginMessageGetInstallerDetail  ,


-- ** missingUriSinkInstallerDetailNew #method:missingUriSinkInstallerDetailNew#

    missingUriSinkInstallerDetailNew        ,


-- ** missingUriSinkMessageNew #method:missingUriSinkMessageNew#

    missingUriSinkMessageNew                ,


-- ** missingUriSourceInstallerDetailNew #method:missingUriSourceInstallerDetailNew#

    missingUriSourceInstallerDetailNew      ,


-- ** missingUriSourceMessageNew #method:missingUriSourceMessageNew#

    missingUriSourceMessageNew              ,


-- ** pbUtilsAddCodecDescriptionToTagList #method:pbUtilsAddCodecDescriptionToTagList#

    pbUtilsAddCodecDescriptionToTagList     ,


-- ** pbUtilsGetCodecDescription #method:pbUtilsGetCodecDescription#

    pbUtilsGetCodecDescription              ,


-- ** pbUtilsGetDecoderDescription #method:pbUtilsGetDecoderDescription#

    pbUtilsGetDecoderDescription            ,


-- ** pbUtilsGetElementDescription #method:pbUtilsGetElementDescription#

    pbUtilsGetElementDescription            ,


-- ** pbUtilsGetEncoderDescription #method:pbUtilsGetEncoderDescription#

    pbUtilsGetEncoderDescription            ,


-- ** pbUtilsGetSinkDescription #method:pbUtilsGetSinkDescription#

    pbUtilsGetSinkDescription               ,


-- ** pbUtilsGetSourceDescription #method:pbUtilsGetSourceDescription#

    pbUtilsGetSourceDescription             ,


-- ** pbUtilsInit #method:pbUtilsInit#

    pbUtilsInit                             ,


-- ** pluginsBaseVersion #method:pluginsBaseVersion#

    pluginsBaseVersion                      ,


-- ** pluginsBaseVersionString #method:pluginsBaseVersionString#

    pluginsBaseVersionString                ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import 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.Message as Gst.Message
import qualified GI.Gst.Structs.TagList as Gst.TagList
import qualified GI.GstPbutils.Callbacks as GstPbutils.Callbacks
import {-# SOURCE #-} qualified GI.GstPbutils.Enums as GstPbutils.Enums
import {-# SOURCE #-} qualified GI.GstPbutils.Objects.EncodingTarget as GstPbutils.EncodingTarget
import {-# SOURCE #-} qualified GI.GstPbutils.Structs.InstallPluginsContext as GstPbutils.InstallPluginsContext

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

foreign import ccall "gst_plugins_base_version_string" gst_plugins_base_version_string ::
    IO CString

{- |
This function returns a string that is useful for describing this version
of GStreamer\'s gst-plugins-base libraries to the outside world: user agent
strings, logging, about dialogs ...
-}
pluginsBaseVersionString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    {- ^ __Returns:__ a newly allocated string describing this version of gst-plugins-base -}
pluginsBaseVersionString  = liftIO $ do
    result <- gst_plugins_base_version_string
    checkUnexpectedReturnNULL "pluginsBaseVersionString" result
    result' <- cstringToText result
    freeMem result
    return result'


-- function gst_plugins_base_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, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = 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, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = 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, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = 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, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_plugins_base_version" gst_plugins_base_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 Plugins Base libraries.
-}
pluginsBaseVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ((Word32, Word32, Word32, Word32))
pluginsBaseVersion  = liftIO $ do
    major <- allocMem :: IO (Ptr Word32)
    minor <- allocMem :: IO (Ptr Word32)
    micro <- allocMem :: IO (Ptr Word32)
    nano <- allocMem :: IO (Ptr Word32)
    gst_plugins_base_version major minor micro nano
    major' <- peek major
    minor' <- peek minor
    micro' <- peek micro
    nano' <- peek nano
    freeMem major
    freeMem minor
    freeMem micro
    freeMem nano
    return (major', minor', micro', nano')


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

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

{- |
Initialises the base utils support library. This function is not
thread-safe. Applications should call it after calling 'GI.Gst.Functions.init',
plugins should call it from their plugin_init function.

This function may be called multiple times. It will do nothing if the
library has already been initialised.
-}
pbUtilsInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
pbUtilsInit  = liftIO $ do
    gst_pb_utils_init
    return ()


-- function gst_pb_utils_get_source_description
-- Args : [Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the protocol the source element needs to handle, e.g. \"http\"", 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_pb_utils_get_source_description" gst_pb_utils_get_source_description ::
    CString ->                              -- protocol : TBasicType TUTF8
    IO CString

{- |
Returns a localised string describing a source element handling the protocol
specified in /@protocol@/, for use in error dialogs or other messages to be
seen by the user. Should never return NULL unless /@protocol@/ is invalid.

This function is mainly for internal use, applications would typically
use 'GI.GstPbutils.Functions.missingPluginMessageGetDescription' to get a description of
a missing feature from a missing-plugin message.
-}
pbUtilsGetSourceDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@protocol@/: the protocol the source element needs to handle, e.g. \"http\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetSourceDescription protocol = liftIO $ do
    protocol' <- textToCString protocol
    result <- gst_pb_utils_get_source_description protocol'
    checkUnexpectedReturnNULL "pbUtilsGetSourceDescription" result
    result' <- cstringToText result
    freeMem result
    freeMem protocol'
    return result'


-- function gst_pb_utils_get_sink_description
-- Args : [Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the protocol the sink element needs to handle, e.g. \"http\"", 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_pb_utils_get_sink_description" gst_pb_utils_get_sink_description ::
    CString ->                              -- protocol : TBasicType TUTF8
    IO CString

{- |
Returns a localised string describing a sink element handling the protocol
specified in /@protocol@/, for use in error dialogs or other messages to be
seen by the user. Should never return NULL unless /@protocol@/ is invalid.

This function is mainly for internal use, applications would typically
use 'GI.GstPbutils.Functions.missingPluginMessageGetDescription' to get a description of
a missing feature from a missing-plugin message.
-}
pbUtilsGetSinkDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@protocol@/: the protocol the sink element needs to handle, e.g. \"http\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetSinkDescription protocol = liftIO $ do
    protocol' <- textToCString protocol
    result <- gst_pb_utils_get_sink_description protocol'
    checkUnexpectedReturnNULL "pbUtilsGetSinkDescription" result
    result' <- cstringToText result
    freeMem result
    freeMem protocol'
    return result'


-- function gst_pb_utils_get_encoder_description
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) #GstCaps for which an encoder description is needed", 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_pb_utils_get_encoder_description" gst_pb_utils_get_encoder_description ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Returns a localised string describing an encoder for the format specified
in /@caps@/, for use in error dialogs or other messages to be seen by the user.
Should never return NULL unless /@factoryName@/ or /@caps@/ are invalid.

This function is mainly for internal use, applications would typically
use 'GI.GstPbutils.Functions.missingPluginMessageGetDescription' to get a description of
a missing feature from a missing-plugin message.
-}
pbUtilsGetEncoderDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the (fixed) 'GI.Gst.Structs.Caps.Caps' for which an encoder description is needed -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetEncoderDescription caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_pb_utils_get_encoder_description caps'
    checkUnexpectedReturnNULL "pbUtilsGetEncoderDescription" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr caps
    return result'


-- function gst_pb_utils_get_element_description
-- Args : [Arg {argCName = "factory_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the element, e.g. \"giosrc\"", 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_pb_utils_get_element_description" gst_pb_utils_get_element_description ::
    CString ->                              -- factory_name : TBasicType TUTF8
    IO CString

{- |
Returns a localised string describing the given element, for use in
error dialogs or other messages to be seen by the user. Should never
return NULL unless /@factoryName@/ is invalid.

This function is mainly for internal use, applications would typically
use 'GI.GstPbutils.Functions.missingPluginMessageGetDescription' to get a description of
a missing feature from a missing-plugin message.
-}
pbUtilsGetElementDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@factoryName@/: the name of the element, e.g. \"giosrc\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetElementDescription factoryName = liftIO $ do
    factoryName' <- textToCString factoryName
    result <- gst_pb_utils_get_element_description factoryName'
    checkUnexpectedReturnNULL "pbUtilsGetElementDescription" result
    result' <- cstringToText result
    freeMem result
    freeMem factoryName'
    return result'


-- function gst_pb_utils_get_decoder_description
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) #GstCaps for which an decoder description is needed", 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_pb_utils_get_decoder_description" gst_pb_utils_get_decoder_description ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Returns a localised string describing an decoder for the format specified
in /@caps@/, for use in error dialogs or other messages to be seen by the user.
Should never return NULL unless /@factoryName@/ or /@caps@/ are invalid.

This function is mainly for internal use, applications would typically
use 'GI.GstPbutils.Functions.missingPluginMessageGetDescription' to get a description of
a missing feature from a missing-plugin message.
-}
pbUtilsGetDecoderDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the (fixed) 'GI.Gst.Structs.Caps.Caps' for which an decoder description is needed -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetDecoderDescription caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_pb_utils_get_decoder_description caps'
    checkUnexpectedReturnNULL "pbUtilsGetDecoderDescription" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr caps
    return result'


-- function gst_pb_utils_get_codec_description
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) #GstCaps for which an format description is needed", 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_pb_utils_get_codec_description" gst_pb_utils_get_codec_description ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Returns a localised (as far as this is possible) string describing the
media format specified in /@caps@/, for use in error dialogs or other messages
to be seen by the user. Should never return NULL unless /@caps@/ is invalid.

Also see the convenience function
'GI.GstPbutils.Functions.pbUtilsAddCodecDescriptionToTagList'.
-}
pbUtilsGetCodecDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the (fixed) 'GI.Gst.Structs.Caps.Caps' for which an format description is needed -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
pbUtilsGetCodecDescription caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_pb_utils_get_codec_description caps'
    checkUnexpectedReturnNULL "pbUtilsGetCodecDescription" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr caps
    return result'


-- function gst_pb_utils_add_codec_description_to_tag_list
-- Args : [Arg {argCName = "taglist", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstTagList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "codec_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC,\n            #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC. If none is specified,\n            the function will attempt to detect the appropriate category.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) #GstCaps for which a codec tag should be added.", 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_pb_utils_add_codec_description_to_tag_list" gst_pb_utils_add_codec_description_to_tag_list ::
    Ptr Gst.TagList.TagList ->              -- taglist : TInterface (Name {namespace = "Gst", name = "TagList"})
    CString ->                              -- codec_tag : TBasicType TUTF8
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CInt

{- |
Adds a codec tag describing the format specified by /@caps@/ to /@taglist@/.
-}
pbUtilsAddCodecDescriptionToTagList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@taglist@/: a 'GI.Gst.Structs.TagList.TagList' -}
    -> Maybe (T.Text)
    {- ^ /@codecTag@/: a GStreamer codec tag such as 'GI.Gst.Constants.TAG_AUDIO_CODEC',
            'GI.Gst.Constants.TAG_VIDEO_CODEC' or 'GI.Gst.Constants.TAG_CODEC'. If none is specified,
            the function will attempt to detect the appropriate category. -}
    -> Gst.Caps.Caps
    {- ^ /@caps@/: the (fixed) 'GI.Gst.Structs.Caps.Caps' for which a codec tag should be added. -}
    -> m Bool
    {- ^ __Returns:__ TRUE if a codec tag was added, FALSE otherwise. -}
pbUtilsAddCodecDescriptionToTagList taglist codecTag caps = liftIO $ do
    taglist' <- unsafeManagedPtrGetPtr taglist
    maybeCodecTag <- case codecTag of
        Nothing -> return nullPtr
        Just jCodecTag -> do
            jCodecTag' <- textToCString jCodecTag
            return jCodecTag'
    caps' <- unsafeManagedPtrGetPtr caps
    result <- gst_pb_utils_add_codec_description_to_tag_list taglist' maybeCodecTag caps'
    let result' = (/= 0) result
    touchManagedPtr taglist
    touchManagedPtr caps
    freeMem maybeCodecTag
    return result'


-- function gst_missing_uri_source_message_new
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement posting the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI protocol the missing source needs to implement,\n           e.g. \"http\" or \"mms\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_missing_uri_source_message_new" gst_missing_uri_source_message_new ::
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- protocol : TBasicType TUTF8
    IO (Ptr Gst.Message.Message)

{- |
Creates a missing-plugin message for /@element@/ to notify the application
that a source element for a particular URI protocol is missing. This
function is mainly for use in plugins.
-}
missingUriSourceMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' posting the message -}
    -> T.Text
    {- ^ /@protocol@/: the URI protocol the missing source needs to implement,
           e.g. \"http\" or \"mms\" -}
    -> m Gst.Message.Message
    {- ^ __Returns:__ a new 'GI.Gst.Structs.Message.Message', or NULL on error -}
missingUriSourceMessageNew element protocol = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    protocol' <- textToCString protocol
    result <- gst_missing_uri_source_message_new element' protocol'
    checkUnexpectedReturnNULL "missingUriSourceMessageNew" result
    result' <- (wrapBoxed Gst.Message.Message) result
    touchManagedPtr element
    freeMem protocol'
    return result'


-- function gst_missing_uri_source_installer_detail_new
-- Args : [Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI protocol the missing source needs to implement,\n           e.g. \"http\" or \"mms\"", 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_missing_uri_source_installer_detail_new" gst_missing_uri_source_installer_detail_new ::
    CString ->                              -- protocol : TBasicType TUTF8
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions in
the case where the application knows exactly what kind of plugin it is
missing.
-}
missingUriSourceInstallerDetailNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@protocol@/: the URI protocol the missing source needs to implement,
           e.g. \"http\" or \"mms\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingUriSourceInstallerDetailNew protocol = liftIO $ do
    protocol' <- textToCString protocol
    result <- gst_missing_uri_source_installer_detail_new protocol'
    checkUnexpectedReturnNULL "missingUriSourceInstallerDetailNew" result
    result' <- cstringToText result
    freeMem result
    freeMem protocol'
    return result'


-- function gst_missing_uri_sink_message_new
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement posting the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI protocol the missing sink needs to implement,\n           e.g. \"http\" or \"smb\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_missing_uri_sink_message_new" gst_missing_uri_sink_message_new ::
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- protocol : TBasicType TUTF8
    IO (Ptr Gst.Message.Message)

{- |
Creates a missing-plugin message for /@element@/ to notify the application
that a sink element for a particular URI protocol is missing. This
function is mainly for use in plugins.
-}
missingUriSinkMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' posting the message -}
    -> T.Text
    {- ^ /@protocol@/: the URI protocol the missing sink needs to implement,
           e.g. \"http\" or \"smb\" -}
    -> m Gst.Message.Message
    {- ^ __Returns:__ a new 'GI.Gst.Structs.Message.Message', or NULL on error -}
missingUriSinkMessageNew element protocol = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    protocol' <- textToCString protocol
    result <- gst_missing_uri_sink_message_new element' protocol'
    checkUnexpectedReturnNULL "missingUriSinkMessageNew" result
    result' <- (wrapBoxed Gst.Message.Message) result
    touchManagedPtr element
    freeMem protocol'
    return result'


-- function gst_missing_uri_sink_installer_detail_new
-- Args : [Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI protocol the missing source needs to implement,\n           e.g. \"http\" or \"mms\"", 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_missing_uri_sink_installer_detail_new" gst_missing_uri_sink_installer_detail_new ::
    CString ->                              -- protocol : TBasicType TUTF8
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions in
the case where the application knows exactly what kind of plugin it is
missing.
-}
missingUriSinkInstallerDetailNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@protocol@/: the URI protocol the missing source needs to implement,
           e.g. \"http\" or \"mms\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingUriSinkInstallerDetailNew protocol = liftIO $ do
    protocol' <- textToCString protocol
    result <- gst_missing_uri_sink_installer_detail_new protocol'
    checkUnexpectedReturnNULL "missingUriSinkInstallerDetailNew" result
    result' <- cstringToText result
    freeMem result
    freeMem protocol'
    return result'


-- function gst_missing_plugin_message_get_installer_detail
-- Args : [Arg {argCName = "msg", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT", 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_missing_plugin_message_get_installer_detail" gst_missing_plugin_message_get_installer_detail ::
    Ptr Gst.Message.Message ->              -- msg : TInterface (Name {namespace = "Gst", name = "Message"})
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions.
-}
missingPluginMessageGetInstallerDetail ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Message.Message
    {- ^ /@msg@/: a missing-plugin 'GI.Gst.Structs.Message.Message' of type @/GST_MESSAGE_ELEMENT/@ -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingPluginMessageGetInstallerDetail msg = liftIO $ do
    msg' <- unsafeManagedPtrGetPtr msg
    result <- gst_missing_plugin_message_get_installer_detail msg'
    checkUnexpectedReturnNULL "missingPluginMessageGetInstallerDetail" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr msg
    return result'


-- function gst_missing_plugin_message_get_description
-- Args : [Arg {argCName = "msg", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT", 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_missing_plugin_message_get_description" gst_missing_plugin_message_get_description ::
    Ptr Gst.Message.Message ->              -- msg : TInterface (Name {namespace = "Gst", name = "Message"})
    IO CString

{- |
Returns a localised string describing the missing feature, for use in
error dialogs and the like. Should never return NULL unless /@msg@/ is not
a valid missing-plugin message.

This function is mainly for applications that need a human-readable string
describing a missing plugin, given a previously collected missing-plugin
message
-}
missingPluginMessageGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Message.Message
    {- ^ /@msg@/: a missing-plugin 'GI.Gst.Structs.Message.Message' of type @/GST_MESSAGE_ELEMENT/@ -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated description string, or NULL on error. Free
         string with 'GI.GLib.Functions.free' when not needed any longer. -}
missingPluginMessageGetDescription msg = liftIO $ do
    msg' <- unsafeManagedPtrGetPtr msg
    result <- gst_missing_plugin_message_get_description msg'
    checkUnexpectedReturnNULL "missingPluginMessageGetDescription" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr msg
    return result'


-- function gst_missing_encoder_message_new
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement posting the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "encode_caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) caps for which an encoder element is needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_missing_encoder_message_new" gst_missing_encoder_message_new ::
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Caps.Caps ->                    -- encode_caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Gst.Message.Message)

{- |
Creates a missing-plugin message for /@element@/ to notify the application
that an encoder element for a particular set of (fixed) caps is missing.
This function is mainly for use in plugins.
-}
missingEncoderMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' posting the message -}
    -> Gst.Caps.Caps
    {- ^ /@encodeCaps@/: the (fixed) caps for which an encoder element is needed -}
    -> m Gst.Message.Message
    {- ^ __Returns:__ a new 'GI.Gst.Structs.Message.Message', or NULL on error -}
missingEncoderMessageNew element encodeCaps = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    encodeCaps' <- unsafeManagedPtrGetPtr encodeCaps
    result <- gst_missing_encoder_message_new element' encodeCaps'
    checkUnexpectedReturnNULL "missingEncoderMessageNew" result
    result' <- (wrapBoxed Gst.Message.Message) result
    touchManagedPtr element
    touchManagedPtr encodeCaps
    return result'


-- function gst_missing_encoder_installer_detail_new
-- Args : [Arg {argCName = "encode_caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) caps for which an encoder element is needed", 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_missing_encoder_installer_detail_new" gst_missing_encoder_installer_detail_new ::
    Ptr Gst.Caps.Caps ->                    -- encode_caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions in
the case where the application knows exactly what kind of plugin it is
missing.
-}
missingEncoderInstallerDetailNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@encodeCaps@/: the (fixed) caps for which an encoder element is needed -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingEncoderInstallerDetailNew encodeCaps = liftIO $ do
    encodeCaps' <- unsafeManagedPtrGetPtr encodeCaps
    result <- gst_missing_encoder_installer_detail_new encodeCaps'
    checkUnexpectedReturnNULL "missingEncoderInstallerDetailNew" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr encodeCaps
    return result'


-- function gst_missing_element_message_new
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement posting the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "factory_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the missing element (element factory),\n           e.g. \"videoscale\" or \"cdparanoiasrc\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_missing_element_message_new" gst_missing_element_message_new ::
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    CString ->                              -- factory_name : TBasicType TUTF8
    IO (Ptr Gst.Message.Message)

{- |
Creates a missing-plugin message for /@element@/ to notify the application
that a certain required element is missing. This function is mainly for
use in plugins.
-}
missingElementMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' posting the message -}
    -> T.Text
    {- ^ /@factoryName@/: the name of the missing element (element factory),
           e.g. \"videoscale\" or \"cdparanoiasrc\" -}
    -> m Gst.Message.Message
    {- ^ __Returns:__ a new 'GI.Gst.Structs.Message.Message', or NULL on error -}
missingElementMessageNew element factoryName = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    factoryName' <- textToCString factoryName
    result <- gst_missing_element_message_new element' factoryName'
    checkUnexpectedReturnNULL "missingElementMessageNew" result
    result' <- (wrapBoxed Gst.Message.Message) result
    touchManagedPtr element
    freeMem factoryName'
    return result'


-- function gst_missing_element_installer_detail_new
-- Args : [Arg {argCName = "factory_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the missing element (element factory),\n           e.g. \"videoscale\" or \"cdparanoiasrc\"", 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_missing_element_installer_detail_new" gst_missing_element_installer_detail_new ::
    CString ->                              -- factory_name : TBasicType TUTF8
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions in
the case where the application knows exactly what kind of plugin it is
missing.
-}
missingElementInstallerDetailNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@factoryName@/: the name of the missing element (element factory),
           e.g. \"videoscale\" or \"cdparanoiasrc\" -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingElementInstallerDetailNew factoryName = liftIO $ do
    factoryName' <- textToCString factoryName
    result <- gst_missing_element_installer_detail_new factoryName'
    checkUnexpectedReturnNULL "missingElementInstallerDetailNew" result
    result' <- cstringToText result
    freeMem result
    freeMem factoryName'
    return result'


-- function gst_missing_decoder_message_new
-- Args : [Arg {argCName = "element", argType = TInterface (Name {namespace = "Gst", name = "Element"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstElement posting the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "decode_caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) caps for which a decoder element is needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Message"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_missing_decoder_message_new" gst_missing_decoder_message_new ::
    Ptr Gst.Element.Element ->              -- element : TInterface (Name {namespace = "Gst", name = "Element"})
    Ptr Gst.Caps.Caps ->                    -- decode_caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO (Ptr Gst.Message.Message)

{- |
Creates a missing-plugin message for /@element@/ to notify the application
that a decoder element for a particular set of (fixed) caps is missing.
This function is mainly for use in plugins.
-}
missingDecoderMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Element.IsElement a) =>
    a
    {- ^ /@element@/: the 'GI.Gst.Objects.Element.Element' posting the message -}
    -> Gst.Caps.Caps
    {- ^ /@decodeCaps@/: the (fixed) caps for which a decoder element is needed -}
    -> m Gst.Message.Message
    {- ^ __Returns:__ a new 'GI.Gst.Structs.Message.Message', or NULL on error -}
missingDecoderMessageNew element decodeCaps = liftIO $ do
    element' <- unsafeManagedPtrCastPtr element
    decodeCaps' <- unsafeManagedPtrGetPtr decodeCaps
    result <- gst_missing_decoder_message_new element' decodeCaps'
    checkUnexpectedReturnNULL "missingDecoderMessageNew" result
    result' <- (wrapBoxed Gst.Message.Message) result
    touchManagedPtr element
    touchManagedPtr decodeCaps
    return result'


-- function gst_missing_decoder_installer_detail_new
-- Args : [Arg {argCName = "decode_caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (fixed) caps for which a decoder element is needed", 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_missing_decoder_installer_detail_new" gst_missing_decoder_installer_detail_new ::
    Ptr Gst.Caps.Caps ->                    -- decode_caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    IO CString

{- |
Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via
'GI.GstPbutils.Functions.installPluginsAsync' or 'GI.GstPbutils.Functions.installPluginsSync'.

This function is mainly for applications that call external plugin
installation mechanisms using one of the two above-mentioned functions in
the case where the application knows exactly what kind of plugin it is
missing.
-}
missingDecoderInstallerDetailNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@decodeCaps@/: the (fixed) caps for which a decoder element is needed -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated detail string, or NULL on error. Free string
         with 'GI.GLib.Functions.free' when not needed any longer. -}
missingDecoderInstallerDetailNew decodeCaps = liftIO $ do
    decodeCaps' <- unsafeManagedPtrGetPtr decodeCaps
    result <- gst_missing_decoder_installer_detail_new decodeCaps'
    checkUnexpectedReturnNULL "missingDecoderInstallerDetailNew" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr decodeCaps
    return result'


-- function gst_is_missing_plugin_message
-- Args : [Arg {argCName = "msg", argType = TInterface (Name {namespace = "Gst", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstMessage", 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_is_missing_plugin_message" gst_is_missing_plugin_message ::
    Ptr Gst.Message.Message ->              -- msg : TInterface (Name {namespace = "Gst", name = "Message"})
    IO CInt

{- |
Checks whether /@msg@/ is a missing plugins message.
-}
isMissingPluginMessage ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Message.Message
    {- ^ /@msg@/: a 'GI.Gst.Structs.Message.Message' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@msg@/ is a missing-plugins message, otherwise 'False'. -}
isMissingPluginMessage msg = liftIO $ do
    msg' <- unsafeManagedPtrGetPtr msg
    result <- gst_is_missing_plugin_message msg'
    let result' = (/= 0) result
    touchManagedPtr msg
    return result'


-- function gst_install_plugins_sync
-- Args : [Arg {argCName = "details", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "NULL-terminated array\n    of installer string details", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_sync" gst_install_plugins_sync ::
    Ptr CString ->                          -- details : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr GstPbutils.InstallPluginsContext.InstallPluginsContext -> -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    IO CUInt

{- |
Requests plugin installation and block until the plugins have been
installed or installation has failed.

This function should almost never be used, it only exists for cases where
a non-GLib main loop is running and the user wants to run it in a separate
thread and marshal the result back asynchronously into the main thread
using the other non-GLib main loop. You should almost always use
'GI.GstPbutils.Functions.installPluginsAsync' instead of this function.
-}
installPluginsSync ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [T.Text]
    {- ^ /@details@/: NULL-terminated array
    of installer string details -}
    -> Maybe (GstPbutils.InstallPluginsContext.InstallPluginsContext)
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext', or NULL -}
    -> m GstPbutils.Enums.InstallPluginsReturn
    {- ^ __Returns:__ the result of the installation. -}
installPluginsSync details ctx = liftIO $ do
    details' <- packZeroTerminatedUTF8CArray details
    maybeCtx <- case ctx of
        Nothing -> return nullPtr
        Just jCtx -> do
            jCtx' <- unsafeManagedPtrGetPtr jCtx
            return jCtx'
    result <- gst_install_plugins_sync details' maybeCtx
    let result' = (toEnum . fromIntegral) result
    whenJust ctx touchManagedPtr
    mapZeroTerminatedCArray freeMem details'
    freeMem details'
    return result'


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

foreign import ccall "gst_install_plugins_supported" gst_install_plugins_supported ::
    IO CInt

{- |
Checks whether plugin installation is likely to be supported by the
current environment. This currently only checks whether the helper script
that is to be provided by the distribution or operating system vendor
exists.
-}
installPluginsSupported ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ TRUE if plugin installation is likely to be supported. -}
installPluginsSupported  = liftIO $ do
    result <- gst_install_plugins_supported
    let result' = (/= 0) result
    return result'


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

foreign import ccall "gst_install_plugins_installation_in_progress" gst_install_plugins_installation_in_progress ::
    IO CInt

{- |
Checks whether plugin installation (initiated by this application only)
is currently in progress.
-}
installPluginsInstallationInProgress ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ TRUE if plugin installation is in progress, otherwise FALSE -}
installPluginsInstallationInProgress  = liftIO $ do
    result <- gst_install_plugins_installation_in_progress
    let result' = (/= 0) result
    return result'


-- function gst_install_plugins_async
-- Args : [Arg {argCName = "details", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "NULL-terminated array\n    of installer string details (see below)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsResultFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call when the installer program returns", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the user data to pass to @func when called, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsReturn"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_async" gst_install_plugins_async ::
    Ptr CString ->                          -- details : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr GstPbutils.InstallPluginsContext.InstallPluginsContext -> -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    FunPtr GstPbutils.Callbacks.C_InstallPluginsResultFunc -> -- func : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsResultFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CUInt

{- |
Requests plugin installation without blocking. Once the plugins have been
installed or installation has failed, /@func@/ will be called with the result
of the installation and your provided /@userData@/ pointer.

This function requires a running GLib\/Gtk main loop. If you are not
running a GLib\/Gtk main loop, make sure to regularly call
g_main_context_iteration(NULL,FALSE).

The installer strings that make up /@detail@/ are typically obtained by
calling 'GI.GstPbutils.Functions.missingPluginMessageGetInstallerDetail' on missing-plugin
messages that have been caught on a pipeline\'s bus or created by the
application via the provided API, such as 'GI.GstPbutils.Functions.missingElementMessageNew'.

It is possible to request the installation of multiple missing plugins in
one go (as might be required if there is a demuxer for a certain format
installed but no suitable video decoder and no suitable audio decoder).
-}
installPluginsAsync ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [T.Text]
    {- ^ /@details@/: NULL-terminated array
    of installer string details (see below) -}
    -> Maybe (GstPbutils.InstallPluginsContext.InstallPluginsContext)
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext', or NULL -}
    -> GstPbutils.Callbacks.InstallPluginsResultFunc
    {- ^ /@func@/: the function to call when the installer program returns -}
    -> m GstPbutils.Enums.InstallPluginsReturn
    {- ^ __Returns:__ result code whether an external installer could be started -}
installPluginsAsync details ctx func = liftIO $ do
    details' <- packZeroTerminatedUTF8CArray details
    maybeCtx <- case ctx of
        Nothing -> return nullPtr
        Just jCtx -> do
            jCtx' <- unsafeManagedPtrGetPtr jCtx
            return jCtx'
    ptrfunc <- callocMem :: IO (Ptr (FunPtr GstPbutils.Callbacks.C_InstallPluginsResultFunc))
    func' <- GstPbutils.Callbacks.mk_InstallPluginsResultFunc (GstPbutils.Callbacks.wrap_InstallPluginsResultFunc (Just ptrfunc) (GstPbutils.Callbacks.drop_closures_InstallPluginsResultFunc func))
    poke ptrfunc func'
    let userData = nullPtr
    result <- gst_install_plugins_async details' maybeCtx func' userData
    let result' = (toEnum . fromIntegral) result
    whenJust ctx touchManagedPtr
    mapZeroTerminatedCArray freeMem details'
    freeMem details'
    return result'


-- function gst_encoding_list_available_categories
-- Args : []
-- Lengths : []
-- returnType : Just (TGList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_encoding_list_available_categories" gst_encoding_list_available_categories ::
    IO (Ptr (GList CString))

{- |
Lists all 'GI.GstPbutils.Objects.EncodingTarget.EncodingTarget' categories present on disk.
-}
encodingListAvailableCategories ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m [T.Text]
    {- ^ __Returns:__ A list
of 'GI.GstPbutils.Objects.EncodingTarget.EncodingTarget' categories. -}
encodingListAvailableCategories  = liftIO $ do
    result <- gst_encoding_list_available_categories
    result' <- unpackGList result
    result'' <- mapM cstringToText result'
    mapGList freeMem result
    g_list_free result
    return result''


-- function gst_encoding_list_all_targets
-- Args : [Arg {argCName = "categoryname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The category, for ex: #GST_ENCODING_CATEGORY_DEVICE.\nCan be %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "GstPbutils", name = "EncodingTarget"})))
-- throws : False
-- Skip return : False

foreign import ccall "gst_encoding_list_all_targets" gst_encoding_list_all_targets ::
    CString ->                              -- categoryname : TBasicType TUTF8
    IO (Ptr (GList (Ptr GstPbutils.EncodingTarget.EncodingTarget)))

{- |
List all available 'GI.GstPbutils.Objects.EncodingTarget.EncodingTarget' for the specified category, or all categories
if /@categoryname@/ is 'Nothing'.
-}
encodingListAllTargets ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@categoryname@/: The category, for ex: 'GI.GstPbutils.Constants.ENCODING_CATEGORY_DEVICE'.
Can be 'Nothing'. -}
    -> m [GstPbutils.EncodingTarget.EncodingTarget]
    {- ^ __Returns:__ The list of 'GI.GstPbutils.Objects.EncodingTarget.EncodingTarget' -}
encodingListAllTargets categoryname = liftIO $ do
    maybeCategoryname <- case categoryname of
        Nothing -> return nullPtr
        Just jCategoryname -> do
            jCategoryname' <- textToCString jCategoryname
            return jCategoryname'
    result <- gst_encoding_list_all_targets maybeCategoryname
    result' <- unpackGList result
    result'' <- mapM (wrapObject GstPbutils.EncodingTarget.EncodingTarget) result'
    g_list_free result
    freeMem maybeCategoryname
    return result''


-- function gst_codec_utils_opus_parse_header
-- Args : [Arg {argCName = "header", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the OpusHead #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rate", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channels", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channel_mapping_family", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel mapping family", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stream_count", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of independent streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "coupled_count", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of stereo streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channel_mapping", argType = TCArray False 256 (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the mapping between the streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "pre_skip", argType = TBasicType TUInt16, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pre-skip in 48kHz samples or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "output_gain", argType = TBasicType TInt16, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Output gain or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_opus_parse_header" gst_codec_utils_opus_parse_header ::
    Ptr Gst.Buffer.Buffer ->                -- header : TInterface (Name {namespace = "Gst", name = "Buffer"})
    Ptr Word32 ->                           -- rate : TBasicType TUInt32
    Ptr Word8 ->                            -- channels : TBasicType TUInt8
    Ptr Word8 ->                            -- channel_mapping_family : TBasicType TUInt8
    Ptr Word8 ->                            -- stream_count : TBasicType TUInt8
    Ptr Word8 ->                            -- coupled_count : TBasicType TUInt8
    Ptr (Ptr Word8) ->                      -- channel_mapping : TCArray False 256 (-1) (TBasicType TUInt8)
    Ptr Word16 ->                           -- pre_skip : TBasicType TUInt16
    Ptr Int16 ->                            -- output_gain : TBasicType TInt16
    IO CInt

{- |
Parses the OpusHead header.

/Since: 1.8/
-}
codecUtilsOpusParseHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@header@/: the OpusHead 'GI.Gst.Structs.Buffer.Buffer' -}
    -> m ((Bool, Word32, Word8, Word8, Word8, Word8, ByteString, Word16, Int16))
    {- ^ __Returns:__ 'True' if parsing was successful, 'False' otherwise. -}
codecUtilsOpusParseHeader header = liftIO $ do
    header' <- unsafeManagedPtrGetPtr header
    rate <- allocMem :: IO (Ptr Word32)
    channels <- allocMem :: IO (Ptr Word8)
    channelMappingFamily <- allocMem :: IO (Ptr Word8)
    streamCount <- allocMem :: IO (Ptr Word8)
    coupledCount <- allocMem :: IO (Ptr Word8)
    channelMapping <- allocMem :: IO (Ptr (Ptr Word8))
    preSkip <- allocMem :: IO (Ptr Word16)
    outputGain <- allocMem :: IO (Ptr Int16)
    result <- gst_codec_utils_opus_parse_header header' rate channels channelMappingFamily streamCount coupledCount channelMapping preSkip outputGain
    let result' = (/= 0) result
    rate' <- peek rate
    channels' <- peek channels
    channelMappingFamily' <- peek channelMappingFamily
    streamCount' <- peek streamCount
    coupledCount' <- peek coupledCount
    channelMapping' <- peek channelMapping
    channelMapping'' <- (unpackByteStringWithLength 256) channelMapping'
    freeMem channelMapping'
    preSkip' <- peek preSkip
    outputGain' <- peek outputGain
    touchManagedPtr header
    freeMem rate
    freeMem channels
    freeMem channelMappingFamily
    freeMem streamCount
    freeMem coupledCount
    freeMem channelMapping
    freeMem preSkip
    freeMem outputGain
    return (result', rate', channels', channelMappingFamily', streamCount', coupledCount', channelMapping'', preSkip', outputGain')


-- function gst_codec_utils_opus_parse_caps
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to parse the data from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rate", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channels", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channel_mapping_family", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel mapping family", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stream_count", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of independent streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "coupled_count", argType = TBasicType TUInt8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of stereo streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "channel_mapping", argType = TCArray False 256 (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the mapping between the streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_opus_parse_caps" gst_codec_utils_opus_parse_caps ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Word32 ->                           -- rate : TBasicType TUInt32
    Ptr Word8 ->                            -- channels : TBasicType TUInt8
    Ptr Word8 ->                            -- channel_mapping_family : TBasicType TUInt8
    Ptr Word8 ->                            -- stream_count : TBasicType TUInt8
    Ptr Word8 ->                            -- coupled_count : TBasicType TUInt8
    Ptr (Ptr Word8) ->                      -- channel_mapping : TCArray False 256 (-1) (TBasicType TUInt8)
    IO CInt

{- |
Parses Opus caps and fills the different fields with defaults if possible.

/Since: 1.8/
-}
codecUtilsOpusParseCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to parse the data from -}
    -> m ((Bool, Word32, Word8, Word8, Word8, Word8, ByteString))
    {- ^ __Returns:__ 'True' if parsing was successful, 'False' otherwise. -}
codecUtilsOpusParseCaps caps = liftIO $ do
    caps' <- unsafeManagedPtrGetPtr caps
    rate <- allocMem :: IO (Ptr Word32)
    channels <- allocMem :: IO (Ptr Word8)
    channelMappingFamily <- allocMem :: IO (Ptr Word8)
    streamCount <- allocMem :: IO (Ptr Word8)
    coupledCount <- allocMem :: IO (Ptr Word8)
    channelMapping <- allocMem :: IO (Ptr (Ptr Word8))
    result <- gst_codec_utils_opus_parse_caps caps' rate channels channelMappingFamily streamCount coupledCount channelMapping
    let result' = (/= 0) result
    rate' <- peek rate
    channels' <- peek channels
    channelMappingFamily' <- peek channelMappingFamily
    streamCount' <- peek streamCount
    coupledCount' <- peek coupledCount
    channelMapping' <- peek channelMapping
    channelMapping'' <- (unpackByteStringWithLength 256) channelMapping'
    freeMem channelMapping'
    touchManagedPtr caps
    freeMem rate
    freeMem channels
    freeMem channelMappingFamily
    freeMem streamCount
    freeMem coupledCount
    freeMem channelMapping
    return (result', rate', channels', channelMappingFamily', streamCount', coupledCount', channelMapping'')


-- function gst_codec_utils_opus_create_header
-- Args : [Arg {argCName = "rate", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mapping_family", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel mapping family", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stream_count", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of independent streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coupled_count", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of stereo streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mapping", argType = TCArray False (-1) (-1) (TBasicType TUInt8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the mapping between the streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pre_skip", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pre-skip in 48kHz samples or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "output_gain", argType = TBasicType TInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Output gain or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Buffer"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_opus_create_header" gst_codec_utils_opus_create_header ::
    Word32 ->                               -- rate : TBasicType TUInt32
    Word8 ->                                -- channels : TBasicType TUInt8
    Word8 ->                                -- channel_mapping_family : TBasicType TUInt8
    Word8 ->                                -- stream_count : TBasicType TUInt8
    Word8 ->                                -- coupled_count : TBasicType TUInt8
    Ptr Word8 ->                            -- channel_mapping : TCArray False (-1) (-1) (TBasicType TUInt8)
    Word16 ->                               -- pre_skip : TBasicType TUInt16
    Int16 ->                                -- output_gain : TBasicType TInt16
    IO (Ptr Gst.Buffer.Buffer)

{- |
Creates OpusHead header from the given parameters.

/Since: 1.8/
-}
codecUtilsOpusCreateHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@rate@/: the sample rate -}
    -> Word8
    {- ^ /@channels@/: the number of channels -}
    -> Word8
    {- ^ /@channelMappingFamily@/: the channel mapping family -}
    -> Word8
    {- ^ /@streamCount@/: the number of independent streams -}
    -> Word8
    {- ^ /@coupledCount@/: the number of stereo streams -}
    -> Maybe (Ptr Word8)
    {- ^ /@channelMapping@/: the mapping between the streams -}
    -> Word16
    {- ^ /@preSkip@/: Pre-skip in 48kHz samples or 0 -}
    -> Int16
    {- ^ /@outputGain@/: Output gain or 0 -}
    -> m Gst.Buffer.Buffer
    {- ^ __Returns:__ The 'GI.Gst.Structs.Buffer.Buffer' containing the OpusHead. -}
codecUtilsOpusCreateHeader rate channels channelMappingFamily streamCount coupledCount channelMapping preSkip outputGain = liftIO $ do
    maybeChannelMapping <- case channelMapping of
        Nothing -> return nullPtr
        Just jChannelMapping -> do
            return jChannelMapping
    result <- gst_codec_utils_opus_create_header rate channels channelMappingFamily streamCount coupledCount maybeChannelMapping preSkip outputGain
    checkUnexpectedReturnNULL "codecUtilsOpusCreateHeader" result
    result' <- (wrapBoxed Gst.Buffer.Buffer) result
    return result'


-- function gst_codec_utils_opus_create_caps_from_header
-- Args : [Arg {argCName = "header", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "OpusHead header", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "comments", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Comment header or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_opus_create_caps_from_header" gst_codec_utils_opus_create_caps_from_header ::
    Ptr Gst.Buffer.Buffer ->                -- header : TInterface (Name {namespace = "Gst", name = "Buffer"})
    Ptr Gst.Buffer.Buffer ->                -- comments : TInterface (Name {namespace = "Gst", name = "Buffer"})
    IO (Ptr Gst.Caps.Caps)

{- |
Creates Opus caps from the given OpusHead /@header@/ and comment header
/@comments@/.

/Since: 1.8/
-}
codecUtilsOpusCreateCapsFromHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@header@/: OpusHead header -}
    -> Maybe (Gst.Buffer.Buffer)
    {- ^ /@comments@/: Comment header or NULL -}
    -> m Gst.Caps.Caps
    {- ^ __Returns:__ The 'GI.Gst.Structs.Caps.Caps'. -}
codecUtilsOpusCreateCapsFromHeader header comments = liftIO $ do
    header' <- unsafeManagedPtrGetPtr header
    maybeComments <- case comments of
        Nothing -> return nullPtr
        Just jComments -> do
            jComments' <- unsafeManagedPtrGetPtr jComments
            return jComments'
    result <- gst_codec_utils_opus_create_caps_from_header header' maybeComments
    checkUnexpectedReturnNULL "codecUtilsOpusCreateCapsFromHeader" result
    result' <- (wrapBoxed Gst.Caps.Caps) result
    touchManagedPtr header
    whenJust comments touchManagedPtr
    return result'


-- function gst_codec_utils_opus_create_caps
-- Args : [Arg {argCName = "rate", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the sample rate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mapping_family", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel mapping family", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stream_count", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of independent streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coupled_count", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of stereo streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mapping", argType = TCArray False (-1) (-1) (TBasicType TUInt8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the mapping between the streams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Caps"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_opus_create_caps" gst_codec_utils_opus_create_caps ::
    Word32 ->                               -- rate : TBasicType TUInt32
    Word8 ->                                -- channels : TBasicType TUInt8
    Word8 ->                                -- channel_mapping_family : TBasicType TUInt8
    Word8 ->                                -- stream_count : TBasicType TUInt8
    Word8 ->                                -- coupled_count : TBasicType TUInt8
    Ptr Word8 ->                            -- channel_mapping : TCArray False (-1) (-1) (TBasicType TUInt8)
    IO (Ptr Gst.Caps.Caps)

{- |
Creates Opus caps from the given parameters.

/Since: 1.8/
-}
codecUtilsOpusCreateCaps ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@rate@/: the sample rate -}
    -> Word8
    {- ^ /@channels@/: the number of channels -}
    -> Word8
    {- ^ /@channelMappingFamily@/: the channel mapping family -}
    -> Word8
    {- ^ /@streamCount@/: the number of independent streams -}
    -> Word8
    {- ^ /@coupledCount@/: the number of stereo streams -}
    -> Maybe (Ptr Word8)
    {- ^ /@channelMapping@/: the mapping between the streams -}
    -> m Gst.Caps.Caps
    {- ^ __Returns:__ The 'GI.Gst.Structs.Caps.Caps', or 'Nothing' if the parameters would lead to
invalid Opus caps. -}
codecUtilsOpusCreateCaps rate channels channelMappingFamily streamCount coupledCount channelMapping = liftIO $ do
    maybeChannelMapping <- case channelMapping of
        Nothing -> return nullPtr
        Just jChannelMapping -> do
            return jChannelMapping
    result <- gst_codec_utils_opus_create_caps rate channels channelMappingFamily streamCount coupledCount maybeChannelMapping
    checkUnexpectedReturnNULL "codecUtilsOpusCreateCaps" result
    result' <- (wrapBoxed Gst.Caps.Caps) result
    return result'


-- function gst_codec_utils_mpeg4video_get_profile
-- Args : [Arg {argCName = "vis_obj_seq", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the visual object\n  sequence for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_mpeg4video_get_profile" gst_codec_utils_mpeg4video_get_profile ::
    Ptr Word8 ->                            -- vis_obj_seq : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the profile indication in the stream\'s visual object sequence into
a string. /@visObjSeq@/ is expected to be the data following the visual
object sequence start code. Only the first byte
(profile_and_level_indication) is used.
-}
codecUtilsMpeg4videoGetProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@visObjSeq@/: Pointer to the visual object
  sequence for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The profile as a const string, or NULL if there is an error. -}
codecUtilsMpeg4videoGetProfile visObjSeq = liftIO $ do
    let len = fromIntegral $ B.length visObjSeq
    visObjSeq' <- packByteString visObjSeq
    result <- gst_codec_utils_mpeg4video_get_profile visObjSeq' len
    checkUnexpectedReturnNULL "codecUtilsMpeg4videoGetProfile" result
    result' <- cstringToText result
    freeMem visObjSeq'
    return result'


-- function gst_codec_utils_mpeg4video_get_level
-- Args : [Arg {argCName = "vis_obj_seq", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the visual object\n  sequence for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_mpeg4video_get_level" gst_codec_utils_mpeg4video_get_level ::
    Ptr Word8 ->                            -- vis_obj_seq : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the level indication in the stream\'s visual object sequence into
a string. /@visObjSeq@/ is expected to be the data following the visual
object sequence start code. Only the first byte
(profile_and_level_indication) is used.
-}
codecUtilsMpeg4videoGetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@visObjSeq@/: Pointer to the visual object
  sequence for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The level as a const string, or NULL if there is an error. -}
codecUtilsMpeg4videoGetLevel visObjSeq = liftIO $ do
    let len = fromIntegral $ B.length visObjSeq
    visObjSeq' <- packByteString visObjSeq
    result <- gst_codec_utils_mpeg4video_get_level visObjSeq' len
    checkUnexpectedReturnNULL "codecUtilsMpeg4videoGetLevel" result
    result' <- cstringToText result
    freeMem visObjSeq'
    return result'


-- function gst_codec_utils_mpeg4video_caps_set_level_and_profile
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to which the level and profile are to be added", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vis_obj_seq", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the visual object\n  sequence for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_mpeg4video_caps_set_level_and_profile" gst_codec_utils_mpeg4video_caps_set_level_and_profile ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Word8 ->                            -- vis_obj_seq : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CInt

{- |
Sets the level and profile in /@caps@/ if it can be determined from
/@visObjSeq@/. See 'GI.GstPbutils.Functions.codecUtilsMpeg4videoGetLevel' and
'GI.GstPbutils.Functions.codecUtilsMpeg4videoGetProfile' for more details on the
parameters.
-}
codecUtilsMpeg4videoCapsSetLevelAndProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to which the level and profile are to be added -}
    -> ByteString
    {- ^ /@visObjSeq@/: Pointer to the visual object
  sequence for the stream. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the level and profile could be set, 'False' otherwise. -}
codecUtilsMpeg4videoCapsSetLevelAndProfile caps visObjSeq = liftIO $ do
    let len = fromIntegral $ B.length visObjSeq
    caps' <- unsafeManagedPtrGetPtr caps
    visObjSeq' <- packByteString visObjSeq
    result <- gst_codec_utils_mpeg4video_caps_set_level_and_profile caps' visObjSeq' len
    let result' = (/= 0) result
    touchManagedPtr caps
    freeMem visObjSeq'
    return result'


-- function gst_codec_utils_h265_get_tier
-- Args : [Arg {argCName = "profile_tier_level", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the profile_tier_level\n  for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h265_get_tier" gst_codec_utils_h265_get_tier ::
    Ptr Word8 ->                            -- profile_tier_level : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the tier indication (general_tier_flag) in the stream\'s
profile_tier_level structure into a string. The profile_tier_level
is expected to have the same format as for 'GI.GstPbutils.Functions.codecUtilsH264GetProfile'.
-}
codecUtilsH265GetTier ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@profileTierLevel@/: Pointer to the profile_tier_level
  for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The tier as a const string, or 'Nothing' if there is an error.

Since 1.4 -}
codecUtilsH265GetTier profileTierLevel = liftIO $ do
    let len = fromIntegral $ B.length profileTierLevel
    profileTierLevel' <- packByteString profileTierLevel
    result <- gst_codec_utils_h265_get_tier profileTierLevel' len
    checkUnexpectedReturnNULL "codecUtilsH265GetTier" result
    result' <- cstringToText result
    freeMem profileTierLevel'
    return result'


-- function gst_codec_utils_h265_get_profile
-- Args : [Arg {argCName = "profile_tier_level", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the profile_tier_level\n  structure for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h265_get_profile" gst_codec_utils_h265_get_profile ::
    Ptr Word8 ->                            -- profile_tier_level : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the profile indication (general_profile_idc) in the stream\'s
profile_level_tier structure into a string. The profile_tier_level is
expected to have the following format, as defined in the H.265
specification. The profile_tier_level is viewed as a bitstream here,
with bit 0 being the most significant bit of the first byte.

* Bit 0:1   - general_profile_space
* Bit 2     - general_tier_flag
* Bit 3:7   - general_profile_idc
* Bit 8:39  - gernal_profile_compatibility_flags
* Bit 40    - general_progressive_source_flag
* Bit 41    - general_interlaced_source_flag
* Bit 42    - general_non_packed_constraint_flag
* Bit 43    - general_frame_only_constraint_flag
* Bit 44:87 - general_reserved_zero_44bits
* Bit 88:95 - general_level_idc
-}
codecUtilsH265GetProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@profileTierLevel@/: Pointer to the profile_tier_level
  structure for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The profile as a const string, or 'Nothing' if there is an error.

Since 1.4 -}
codecUtilsH265GetProfile profileTierLevel = liftIO $ do
    let len = fromIntegral $ B.length profileTierLevel
    profileTierLevel' <- packByteString profileTierLevel
    result <- gst_codec_utils_h265_get_profile profileTierLevel' len
    checkUnexpectedReturnNULL "codecUtilsH265GetProfile" result
    result' <- cstringToText result
    freeMem profileTierLevel'
    return result'


-- function gst_codec_utils_h265_get_level_idc
-- Args : [Arg {argCName = "level", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A level string from caps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h265_get_level_idc" gst_codec_utils_h265_get_level_idc ::
    CString ->                              -- level : TBasicType TUTF8
    IO Word8

{- |
Transform a level string from the caps into the level_idc
-}
codecUtilsH265GetLevelIdc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@level@/: A level string from caps -}
    -> m Word8
    {- ^ __Returns:__ the level_idc or 0 if the level is unknown

Since 1.4 -}
codecUtilsH265GetLevelIdc level = liftIO $ do
    level' <- textToCString level
    result <- gst_codec_utils_h265_get_level_idc level'
    freeMem level'
    return result


-- function gst_codec_utils_h265_get_level
-- Args : [Arg {argCName = "profile_tier_level", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the profile_tier_level\n  for the stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h265_get_level" gst_codec_utils_h265_get_level ::
    Ptr Word8 ->                            -- profile_tier_level : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the level indication (general_level_idc) in the stream\'s
profile_tier_level structure into a string. The profiel_tier_level is
expected to have the same format as for 'GI.GstPbutils.Functions.codecUtilsH264GetProfile'.
-}
codecUtilsH265GetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@profileTierLevel@/: Pointer to the profile_tier_level
  for the stream -}
    -> m T.Text
    {- ^ __Returns:__ The level as a const string, or 'Nothing' if there is an error.

Since 1.4 -}
codecUtilsH265GetLevel profileTierLevel = liftIO $ do
    let len = fromIntegral $ B.length profileTierLevel
    profileTierLevel' <- packByteString profileTierLevel
    result <- gst_codec_utils_h265_get_level profileTierLevel' len
    checkUnexpectedReturnNULL "codecUtilsH265GetLevel" result
    result' <- cstringToText result
    freeMem profileTierLevel'
    return result'


-- function gst_codec_utils_h265_caps_set_level_tier_and_profile
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to which the level, tier and profile are to be added", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "profile_tier_level", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the profile_tier_level\n  struct", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @profile_tier_level.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h265_caps_set_level_tier_and_profile" gst_codec_utils_h265_caps_set_level_tier_and_profile ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Word8 ->                            -- profile_tier_level : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CInt

{- |
Sets the level, tier and profile in /@caps@/ if it can be determined from
/@profileTierLevel@/. See 'GI.GstPbutils.Functions.codecUtilsH265GetLevel',
'GI.GstPbutils.Functions.codecUtilsH265GetTier' and 'GI.GstPbutils.Functions.codecUtilsH265GetProfile'
for more details on the parameters.
-}
codecUtilsH265CapsSetLevelTierAndProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to which the level, tier and profile are to be added -}
    -> ByteString
    {- ^ /@profileTierLevel@/: Pointer to the profile_tier_level
  struct -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the level, tier, profile could be set, 'False' otherwise.

Since 1.4 -}
codecUtilsH265CapsSetLevelTierAndProfile caps profileTierLevel = liftIO $ do
    let len = fromIntegral $ B.length profileTierLevel
    caps' <- unsafeManagedPtrGetPtr caps
    profileTierLevel' <- packByteString profileTierLevel
    result <- gst_codec_utils_h265_caps_set_level_tier_and_profile caps' profileTierLevel' len
    let result' = (/= 0) result
    touchManagedPtr caps
    freeMem profileTierLevel'
    return result'


-- function gst_codec_utils_h264_get_profile
-- Args : [Arg {argCName = "sps", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the sequence parameter set for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h264_get_profile" gst_codec_utils_h264_get_profile ::
    Ptr Word8 ->                            -- sps : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the profile indication (profile_idc) in the stream\'s
sequence parameter set into a string. The SPS is expected to have the
following format, as defined in the H.264 specification. The SPS is viewed
as a bitstream here, with bit 0 being the most significant bit of the first
byte.

* Bit 0:7   - Profile indication
* Bit 8     - constraint_set0_flag
* Bit 9     - constraint_set1_flag
* Bit 10    - constraint_set2_flag
* Bit 11    - constraint_set3_flag
* Bit 12    - constraint_set3_flag
* Bit 13:15 - Reserved
* Bit 16:24 - Level indication
-}
codecUtilsH264GetProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@sps@/: Pointer to the sequence parameter set for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The profile as a const string, or 'Nothing' if there is an error. -}
codecUtilsH264GetProfile sps = liftIO $ do
    let len = fromIntegral $ B.length sps
    sps' <- packByteString sps
    result <- gst_codec_utils_h264_get_profile sps' len
    checkUnexpectedReturnNULL "codecUtilsH264GetProfile" result
    result' <- cstringToText result
    freeMem sps'
    return result'


-- function gst_codec_utils_h264_get_level_idc
-- Args : [Arg {argCName = "level", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A level string from caps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h264_get_level_idc" gst_codec_utils_h264_get_level_idc ::
    CString ->                              -- level : TBasicType TUTF8
    IO Word8

{- |
Transform a level string from the caps into the level_idc
-}
codecUtilsH264GetLevelIdc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@level@/: A level string from caps -}
    -> m Word8
    {- ^ __Returns:__ the level_idc or 0 if the level is unknown -}
codecUtilsH264GetLevelIdc level = liftIO $ do
    level' <- textToCString level
    result <- gst_codec_utils_h264_get_level_idc level'
    freeMem level'
    return result


-- function gst_codec_utils_h264_get_level
-- Args : [Arg {argCName = "sps", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the sequence parameter set for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h264_get_level" gst_codec_utils_h264_get_level ::
    Ptr Word8 ->                            -- sps : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Converts the level indication (level_idc) in the stream\'s
sequence parameter set into a string. The SPS is expected to have the
same format as for 'GI.GstPbutils.Functions.codecUtilsH264GetProfile'.
-}
codecUtilsH264GetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@sps@/: Pointer to the sequence parameter set for the stream. -}
    -> m T.Text
    {- ^ __Returns:__ The level as a const string, or 'Nothing' if there is an error. -}
codecUtilsH264GetLevel sps = liftIO $ do
    let len = fromIntegral $ B.length sps
    sps' <- packByteString sps
    result <- gst_codec_utils_h264_get_level sps' len
    checkUnexpectedReturnNULL "codecUtilsH264GetLevel" result
    result' <- cstringToText result
    freeMem sps'
    return result'


-- function gst_codec_utils_h264_caps_set_level_and_profile
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to which the level and profile are to be added", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sps", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the sequence parameter set for the stream.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of the data available in @sps.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_h264_caps_set_level_and_profile" gst_codec_utils_h264_caps_set_level_and_profile ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Word8 ->                            -- sps : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CInt

{- |
Sets the level and profile in /@caps@/ if it can be determined from /@sps@/. See
'GI.GstPbutils.Functions.codecUtilsH264GetLevel' and 'GI.GstPbutils.Functions.codecUtilsH264GetProfile'
for more details on the parameters.
-}
codecUtilsH264CapsSetLevelAndProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to which the level and profile are to be added -}
    -> ByteString
    {- ^ /@sps@/: Pointer to the sequence parameter set for the stream. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the level and profile could be set, 'False' otherwise. -}
codecUtilsH264CapsSetLevelAndProfile caps sps = liftIO $ do
    let len = fromIntegral $ B.length sps
    caps' <- unsafeManagedPtrGetPtr caps
    sps' <- packByteString sps
    result <- gst_codec_utils_h264_caps_set_level_and_profile caps' sps' len
    let result' = (/= 0) result
    touchManagedPtr caps
    freeMem sps'
    return result'


-- function gst_codec_utils_aac_get_sample_rate_from_index
-- Args : [Arg {argCName = "sr_idx", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Sample rate index as from the AudioSpecificConfig (MPEG-4\n         container) or ADTS frame header", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_get_sample_rate_from_index" gst_codec_utils_aac_get_sample_rate_from_index ::
    Word32 ->                               -- sr_idx : TBasicType TUInt
    IO Word32

{- |
Translates the sample rate index found in AAC headers to the actual sample
rate.
-}
codecUtilsAacGetSampleRateFromIndex ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@srIdx@/: Sample rate index as from the AudioSpecificConfig (MPEG-4
         container) or ADTS frame header -}
    -> m Word32
    {- ^ __Returns:__ The sample rate if /@srIdx@/ is valid, 0 otherwise. -}
codecUtilsAacGetSampleRateFromIndex srIdx = liftIO $ do
    result <- gst_codec_utils_aac_get_sample_rate_from_index srIdx
    return result


-- function gst_codec_utils_aac_get_sample_rate
-- Args : [Arg {argCName = "audio_config", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the AudioSpecificConfig\n               as specified in the Elementary Stream Descriptor (esds)\n               in ISO/IEC 14496-1.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_get_sample_rate" gst_codec_utils_aac_get_sample_rate ::
    Ptr Word8 ->                            -- audio_config : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO Word32

{- |
Translates the sample rate index found in AAC headers to the actual sample
rate.
-}
codecUtilsAacGetSampleRate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@audioConfig@/: a pointer to the AudioSpecificConfig
               as specified in the Elementary Stream Descriptor (esds)
               in ISO\/IEC 14496-1. -}
    -> m Word32
    {- ^ __Returns:__ The sample rate if sr_idx is valid, 0 otherwise.

Since 1.10 -}
codecUtilsAacGetSampleRate audioConfig = liftIO $ do
    let len = fromIntegral $ B.length audioConfig
    audioConfig' <- packByteString audioConfig
    result <- gst_codec_utils_aac_get_sample_rate audioConfig' len
    freeMem audioConfig'
    return result


-- function gst_codec_utils_aac_get_profile
-- Args : [Arg {argCName = "audio_config", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the AudioSpecificConfig\n               as specified in the Elementary Stream Descriptor (esds)\n               in ISO/IEC 14496-1.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_get_profile" gst_codec_utils_aac_get_profile ::
    Ptr Word8 ->                            -- audio_config : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Returns the profile of the given AAC stream as a string. The profile is
determined using the AudioObjectType field which is in the first 5 bits of
/@audioConfig@/.

> HE-AAC support has not yet been implemented.
-}
codecUtilsAacGetProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@audioConfig@/: a pointer to the AudioSpecificConfig
               as specified in the Elementary Stream Descriptor (esds)
               in ISO\/IEC 14496-1. -}
    -> m T.Text
    {- ^ __Returns:__ The profile as a const string and 'Nothing' if the profile could not be
determined. -}
codecUtilsAacGetProfile audioConfig = liftIO $ do
    let len = fromIntegral $ B.length audioConfig
    audioConfig' <- packByteString audioConfig
    result <- gst_codec_utils_aac_get_profile audioConfig' len
    checkUnexpectedReturnNULL "codecUtilsAacGetProfile" result
    result' <- cstringToText result
    freeMem audioConfig'
    return result'


-- function gst_codec_utils_aac_get_level
-- Args : [Arg {argCName = "audio_config", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the AudioSpecificConfig\n               as specified in the Elementary Stream Descriptor (esds)\n               in ISO/IEC 14496-1.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_get_level" gst_codec_utils_aac_get_level ::
    Ptr Word8 ->                            -- audio_config : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CString

{- |
Determines the level of a stream as defined in ISO\/IEC 14496-3. For AAC LC
streams, the constraints from the AAC audio profile are applied. For AAC
Main, LTP, SSR and others, the Main profile is used.

The /@audioConfig@/ parameter follows the following format, starting from the
most significant bit of the first byte:

  * Bit 0:4 contains the AudioObjectType
  * Bit 5:8 contains the sample frequency index (if this is 0xf, then the
    next 24 bits define the actual sample frequency, and subsequent
    fields are appropriately shifted).
  * Bit 9:12 contains the channel configuration

> HE-AAC support has not yet been implemented.
-}
codecUtilsAacGetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@audioConfig@/: a pointer to the AudioSpecificConfig
               as specified in the Elementary Stream Descriptor (esds)
               in ISO\/IEC 14496-1. -}
    -> m T.Text
    {- ^ __Returns:__ The level as a const string and 'Nothing' if the level could not be
determined. -}
codecUtilsAacGetLevel audioConfig = liftIO $ do
    let len = fromIntegral $ B.length audioConfig
    audioConfig' <- packByteString audioConfig
    result <- gst_codec_utils_aac_get_level audioConfig' len
    checkUnexpectedReturnNULL "codecUtilsAacGetLevel" result
    result' <- cstringToText result
    freeMem audioConfig'
    return result'


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

foreign import ccall "gst_codec_utils_aac_get_index_from_sample_rate" gst_codec_utils_aac_get_index_from_sample_rate ::
    Word32 ->                               -- rate : TBasicType TUInt
    IO Int32

{- |
Translates the sample rate to the index corresponding to it in AAC spec.
-}
codecUtilsAacGetIndexFromSampleRate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@rate@/: Sample rate -}
    -> m Int32
    {- ^ __Returns:__ The AAC index for this sample rate, -1 if the rate is not a
valid AAC sample rate. -}
codecUtilsAacGetIndexFromSampleRate rate = liftIO $ do
    result <- gst_codec_utils_aac_get_index_from_sample_rate rate
    return result


-- function gst_codec_utils_aac_get_channels
-- Args : [Arg {argCName = "audio_config", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the AudioSpecificConfig\n               as specified in the Elementary Stream Descriptor (esds)\n               in ISO/IEC 14496-1.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_get_channels" gst_codec_utils_aac_get_channels ::
    Ptr Word8 ->                            -- audio_config : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO Word32

{- |
Returns the channels of the given AAC stream.
-}
codecUtilsAacGetChannels ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@audioConfig@/: a pointer to the AudioSpecificConfig
               as specified in the Elementary Stream Descriptor (esds)
               in ISO\/IEC 14496-1. -}
    -> m Word32
    {- ^ __Returns:__ The channels or 0 if the channel could not be determined.

Since 1.10 -}
codecUtilsAacGetChannels audioConfig = liftIO $ do
    let len = fromIntegral $ B.length audioConfig
    audioConfig' <- packByteString audioConfig
    result <- gst_codec_utils_aac_get_channels audioConfig' len
    freeMem audioConfig'
    return result


-- function gst_codec_utils_aac_caps_set_level_and_profile
-- Args : [Arg {argCName = "caps", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps to which level and profile fields are to be added", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "audio_config", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the AudioSpecificConfig\n               as specified in the Elementary Stream Descriptor (esds)\n               in ISO/IEC 14496-1. (See below for more details)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of @audio_config in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_codec_utils_aac_caps_set_level_and_profile" gst_codec_utils_aac_caps_set_level_and_profile ::
    Ptr Gst.Caps.Caps ->                    -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr Word8 ->                            -- audio_config : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- len : TBasicType TUInt
    IO CInt

{- |
Sets the level and profile on /@caps@/ if it can be determined from
/@audioConfig@/. See 'GI.GstPbutils.Functions.codecUtilsAacGetLevel' and
'GI.GstPbutils.Functions.codecUtilsAacGetProfile' for more details on the parameters.
/@caps@/ must be audio\/mpeg caps with an \"mpegversion\" field of either 2 or 4.
If mpegversion is 4, the \"base-profile\" field is also set in /@caps@/.
-}
codecUtilsAacCapsSetLevelAndProfile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@caps@/: the 'GI.Gst.Structs.Caps.Caps' to which level and profile fields are to be added -}
    -> ByteString
    {- ^ /@audioConfig@/: a pointer to the AudioSpecificConfig
               as specified in the Elementary Stream Descriptor (esds)
               in ISO\/IEC 14496-1. (See below for more details) -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the level and profile could be set, 'False' otherwise. -}
codecUtilsAacCapsSetLevelAndProfile caps audioConfig = liftIO $ do
    let len = fromIntegral $ B.length audioConfig
    caps' <- unsafeManagedPtrGetPtr caps
    audioConfig' <- packByteString audioConfig
    result <- gst_codec_utils_aac_caps_set_level_and_profile caps' audioConfig' len
    let result' = (/= 0) result
    touchManagedPtr caps
    freeMem audioConfig'
    return result'