{- |
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.GstTag.Functions
    (

 -- * Methods
-- ** tagCheckLanguageCode #method:tagCheckLanguageCode#

    tagCheckLanguageCode                    ,


-- ** tagFreeformStringToUtf8 #method:tagFreeformStringToUtf8#

    tagFreeformStringToUtf8                 ,


-- ** tagFromId3Tag #method:tagFromId3Tag#

    tagFromId3Tag                           ,


-- ** tagFromId3UserTag #method:tagFromId3UserTag#

    tagFromId3UserTag                       ,


-- ** tagFromVorbisTag #method:tagFromVorbisTag#

    tagFromVorbisTag                        ,


-- ** tagGetId3v2TagSize #method:tagGetId3v2TagSize#

    tagGetId3v2TagSize                      ,


-- ** tagGetLanguageCodeIso6391 #method:tagGetLanguageCodeIso6391#

    tagGetLanguageCodeIso6391               ,


-- ** tagGetLanguageCodeIso6392B #method:tagGetLanguageCodeIso6392B#

    tagGetLanguageCodeIso6392B              ,


-- ** tagGetLanguageCodeIso6392T #method:tagGetLanguageCodeIso6392T#

    tagGetLanguageCodeIso6392T              ,


-- ** tagGetLanguageCodes #method:tagGetLanguageCodes#

    tagGetLanguageCodes                     ,


-- ** tagGetLanguageName #method:tagGetLanguageName#

    tagGetLanguageName                      ,


-- ** tagGetLicenseDescription #method:tagGetLicenseDescription#

    tagGetLicenseDescription                ,


-- ** tagGetLicenseFlags #method:tagGetLicenseFlags#

    tagGetLicenseFlags                      ,


-- ** tagGetLicenseJurisdiction #method:tagGetLicenseJurisdiction#

    tagGetLicenseJurisdiction               ,


-- ** tagGetLicenseNick #method:tagGetLicenseNick#

    tagGetLicenseNick                       ,


-- ** tagGetLicenseTitle #method:tagGetLicenseTitle#

    tagGetLicenseTitle                      ,


-- ** tagGetLicenseVersion #method:tagGetLicenseVersion#

    tagGetLicenseVersion                    ,


-- ** tagGetLicenses #method:tagGetLicenses#

    tagGetLicenses                          ,


-- ** tagId3GenreCount #method:tagId3GenreCount#

    tagId3GenreCount                        ,


-- ** tagId3GenreGet #method:tagId3GenreGet#

    tagId3GenreGet                          ,


-- ** tagImageDataToImageSample #method:tagImageDataToImageSample#

    tagImageDataToImageSample               ,


-- ** tagListAddId3Image #method:tagListAddId3Image#

    tagListAddId3Image                      ,


-- ** tagListFromExifBuffer #method:tagListFromExifBuffer#

    tagListFromExifBuffer                   ,


-- ** tagListFromExifBufferWithTiffHeader #method:tagListFromExifBufferWithTiffHeader#

    tagListFromExifBufferWithTiffHeader     ,


-- ** tagListFromId3v2Tag #method:tagListFromId3v2Tag#

    tagListFromId3v2Tag                     ,


-- ** tagListFromVorbiscomment #method:tagListFromVorbiscomment#

    tagListFromVorbiscomment                ,


-- ** tagListFromVorbiscommentBuffer #method:tagListFromVorbiscommentBuffer#

    tagListFromVorbiscommentBuffer          ,


-- ** tagListFromXmpBuffer #method:tagListFromXmpBuffer#

    tagListFromXmpBuffer                    ,


-- ** tagListNewFromId3v1 #method:tagListNewFromId3v1#

    tagListNewFromId3v1                     ,


-- ** tagListToExifBuffer #method:tagListToExifBuffer#

    tagListToExifBuffer                     ,


-- ** tagListToExifBufferWithTiffHeader #method:tagListToExifBufferWithTiffHeader#

    tagListToExifBufferWithTiffHeader       ,


-- ** tagListToVorbiscommentBuffer #method:tagListToVorbiscommentBuffer#

    tagListToVorbiscommentBuffer            ,


-- ** tagListToXmpBuffer #method:tagListToXmpBuffer#

    tagListToXmpBuffer                      ,


-- ** tagParseExtendedComment #method:tagParseExtendedComment#

    tagParseExtendedComment                 ,


-- ** tagRegisterMusicbrainzTags #method:tagRegisterMusicbrainzTags#

    tagRegisterMusicbrainzTags              ,


-- ** tagToId3Tag #method:tagToId3Tag#

    tagToId3Tag                             ,


-- ** tagToVorbisComments #method:tagToVorbisComments#

    tagToVorbisComments                     ,


-- ** tagToVorbisTag #method:tagToVorbisTag#

    tagToVorbisTag                          ,


-- ** tagXmpListSchemas #method:tagXmpListSchemas#

    tagXmpListSchemas                       ,


-- ** vorbisTagAdd #method:vorbisTagAdd#

    vorbisTagAdd                            ,




    ) 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.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.Sample as Gst.Sample
import qualified GI.Gst.Structs.TagList as Gst.TagList
import {-# SOURCE #-} qualified GI.GstTag.Enums as GstTag.Enums
import {-# SOURCE #-} qualified GI.GstTag.Flags as GstTag.Flags

-- function gst_vorbis_tag_add
-- Args : [Arg {argCName = "list", 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 = "tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a vorbiscomment tag string (key in key=value), must be valid UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a vorbiscomment value string (value in key=value), must be valid UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_vorbis_tag_add" gst_vorbis_tag_add ::
    Ptr Gst.TagList.TagList ->              -- list : TInterface (Name {namespace = "Gst", name = "TagList"})
    CString ->                              -- tag : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

{- |
Convenience function using 'GI.GstTag.Functions.tagFromVorbisTag', parsing
a vorbis comment string into the right type and adding it to the
given taglist /@list@/.

Unknown vorbiscomment tags will be added to the tag list in form
of a 'GI.Gst.Constants.TAG_EXTENDED_COMMENT'.
-}
vorbisTagAdd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@list@/: a 'GI.Gst.Structs.TagList.TagList' -}
    -> T.Text
    {- ^ /@tag@/: a vorbiscomment tag string (key in key=value), must be valid UTF-8 -}
    -> T.Text
    {- ^ /@value@/: a vorbiscomment value string (value in key=value), must be valid UTF-8 -}
    -> m ()
vorbisTagAdd list tag value = liftIO $ do
    list' <- unsafeManagedPtrGetPtr list
    tag' <- textToCString tag
    value' <- textToCString value
    gst_vorbis_tag_add list' tag' value'
    touchManagedPtr list
    freeMem tag'
    freeMem value'
    return ()


-- function gst_tag_xmp_list_schemas
-- Args : []
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_xmp_list_schemas" gst_tag_xmp_list_schemas ::
    IO (Ptr CString)

{- |
Gets the list of supported schemas in the xmp lib
-}
tagXmpListSchemas ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m [T.Text]
    {- ^ __Returns:__ a 'Nothing' terminated array of strings with the
    schema names -}
tagXmpListSchemas  = liftIO $ do
    result <- gst_tag_xmp_list_schemas
    checkUnexpectedReturnNULL "tagXmpListSchemas" result
    result' <- unpackZeroTerminatedUTF8CArray result
    return result'


-- function gst_tag_to_vorbis_tag
-- Args : [Arg {argCName = "gst_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GStreamer tag to convert to vorbiscomment tag", 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_tag_to_vorbis_tag" gst_tag_to_vorbis_tag ::
    CString ->                              -- gst_tag : TBasicType TUTF8
    IO CString

{- |
Looks up the vorbiscomment tag for a GStreamer tag.
-}
tagToVorbisTag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@gstTag@/: GStreamer tag to convert to vorbiscomment tag -}
    -> m T.Text
    {- ^ __Returns:__ The corresponding vorbiscomment tag or NULL if none exists. -}
tagToVorbisTag gstTag = liftIO $ do
    gstTag' <- textToCString gstTag
    result <- gst_tag_to_vorbis_tag gstTag'
    checkUnexpectedReturnNULL "tagToVorbisTag" result
    result' <- cstringToText result
    freeMem gstTag'
    return result'


-- function gst_tag_to_vorbis_comments
-- Args : [Arg {argCName = "list", 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 = "tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a GStreamer tag identifier, such as #GST_TAG_ARTIST", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_to_vorbis_comments" gst_tag_to_vorbis_comments ::
    Ptr Gst.TagList.TagList ->              -- list : TInterface (Name {namespace = "Gst", name = "TagList"})
    CString ->                              -- tag : TBasicType TUTF8
    IO (Ptr (GList CString))

{- |
Creates a new tag list that contains the information parsed out of a
vorbiscomment packet.
-}
tagToVorbisComments ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@list@/: a 'GI.Gst.Structs.TagList.TagList' -}
    -> T.Text
    {- ^ /@tag@/: a GStreamer tag identifier, such as 'GI.Gst.Constants.TAG_ARTIST' -}
    -> m [T.Text]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of newly-allocated
    key=value strings. Free with g_list_foreach (list, (GFunc) g_free, NULL)
    plus g_list_free (list) -}
tagToVorbisComments list tag = liftIO $ do
    list' <- unsafeManagedPtrGetPtr list
    tag' <- textToCString tag
    result <- gst_tag_to_vorbis_comments list' tag'
    result' <- unpackGList result
    result'' <- mapM cstringToText result'
    mapGList freeMem result
    g_list_free result
    touchManagedPtr list
    freeMem tag'
    return result''


-- function gst_tag_to_id3_tag
-- Args : [Arg {argCName = "gst_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GStreamer tag to convert to vorbiscomment tag", 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_tag_to_id3_tag" gst_tag_to_id3_tag ::
    CString ->                              -- gst_tag : TBasicType TUTF8
    IO CString

{- |
Looks up the ID3v2 tag for a GStreamer tag.
-}
tagToId3Tag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@gstTag@/: GStreamer tag to convert to vorbiscomment tag -}
    -> m T.Text
    {- ^ __Returns:__ The corresponding ID3v2 tag or NULL if none exists. -}
tagToId3Tag gstTag = liftIO $ do
    gstTag' <- textToCString gstTag
    result <- gst_tag_to_id3_tag gstTag'
    checkUnexpectedReturnNULL "tagToId3Tag" result
    result' <- cstringToText result
    freeMem gstTag'
    return result'


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

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

{- |
Registers additional musicbrainz-specific tags with the GStreamer tag
system. Plugins and applications that use these tags should call this
function before using them. Can be called multiple times.
-}
tagRegisterMusicbrainzTags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
tagRegisterMusicbrainzTags  = liftIO $ do
    gst_tag_register_musicbrainz_tags
    return ()


-- function gst_tag_parse_extended_comment
-- Args : [Arg {argCName = "ext_comment", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an extended comment string, see #GST_TAG_EXTENDED_COMMENT", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n    return location for the comment description key, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "lang", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n    return location for the comment ISO-639 language code, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the actual comment string, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "fail_if_no_key", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to fail if strings are not in key=value form", 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_tag_parse_extended_comment" gst_tag_parse_extended_comment ::
    CString ->                              -- ext_comment : TBasicType TUTF8
    Ptr CString ->                          -- key : TBasicType TUTF8
    Ptr CString ->                          -- lang : TBasicType TUTF8
    Ptr CString ->                          -- value : TBasicType TUTF8
    CInt ->                                 -- fail_if_no_key : TBasicType TBoolean
    IO CInt

{- |
Convenience function to parse a GST_TAG_EXTENDED_COMMENT string and
separate it into its components.

If successful, /@key@/, /@lang@/ and\/or /@value@/ will be set to newly allocated
strings that you need to free with 'GI.GLib.Functions.free' when done. /@key@/ and /@lang@/
may also be set to NULL by this function if there is no key or no language
code in the extended comment string.
-}
tagParseExtendedComment ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@extComment@/: an extended comment string, see 'GI.Gst.Constants.TAG_EXTENDED_COMMENT' -}
    -> Bool
    {- ^ /@failIfNoKey@/: whether to fail if strings are not in key=value form -}
    -> m ((Bool, Maybe T.Text, Maybe T.Text, T.Text))
    {- ^ __Returns:__ TRUE if the string could be parsed, otherwise FALSE -}
tagParseExtendedComment extComment failIfNoKey = liftIO $ do
    extComment' <- textToCString extComment
    key <- allocMem :: IO (Ptr CString)
    lang <- allocMem :: IO (Ptr CString)
    value <- allocMem :: IO (Ptr CString)
    let failIfNoKey' = (fromIntegral . fromEnum) failIfNoKey
    result <- gst_tag_parse_extended_comment extComment' key lang value failIfNoKey'
    let result' = (/= 0) result
    key' <- peek key
    maybeKey' <- convertIfNonNull key' $ \key'' -> do
        key''' <- cstringToText key''
        return key'''
    freeMem key'
    lang' <- peek lang
    maybeLang' <- convertIfNonNull lang' $ \lang'' -> do
        lang''' <- cstringToText lang''
        return lang'''
    freeMem lang'
    value' <- peek value
    value'' <- cstringToText value'
    freeMem value'
    freeMem extComment'
    freeMem key
    freeMem lang
    freeMem value
    return (result', maybeKey', maybeLang', value'')


-- function gst_tag_list_to_xmp_buffer
-- Args : [Arg {argCName = "list", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "tags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "read_only", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "does the container forbid inplace editing", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "schemas", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n    %NULL terminated array of schemas to be used on serialization", 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_tag_list_to_xmp_buffer" gst_tag_list_to_xmp_buffer ::
    Ptr Gst.TagList.TagList ->              -- list : TInterface (Name {namespace = "Gst", name = "TagList"})
    CInt ->                                 -- read_only : TBasicType TBoolean
    Ptr CString ->                          -- schemas : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO (Ptr Gst.Buffer.Buffer)

{- |
Formats a taglist as a xmp packet using only the selected
schemas. An empty list ('Nothing') means that all schemas should
be used
-}
tagListToXmpBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@list@/: tags -}
    -> Bool
    {- ^ /@readOnly@/: does the container forbid inplace editing -}
    -> [T.Text]
    {- ^ /@schemas@/: 
    'Nothing' terminated array of schemas to be used on serialization -}
    -> m Gst.Buffer.Buffer
    {- ^ __Returns:__ new buffer or 'Nothing', unref the buffer when done -}
tagListToXmpBuffer list readOnly schemas = liftIO $ do
    list' <- unsafeManagedPtrGetPtr list
    let readOnly' = (fromIntegral . fromEnum) readOnly
    schemas' <- packZeroTerminatedUTF8CArray schemas
    result <- gst_tag_list_to_xmp_buffer list' readOnly' schemas'
    checkUnexpectedReturnNULL "tagListToXmpBuffer" result
    result' <- (wrapBoxed Gst.Buffer.Buffer) result
    touchManagedPtr list
    mapZeroTerminatedCArray freeMem schemas'
    freeMem schemas'
    return result'


-- function gst_tag_list_to_vorbiscomment_buffer
-- Args : [Arg {argCName = "list", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "tag list to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "identification data at start of stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data, may be 0 if @id_data is NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vendor_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "string that describes the vendor string or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data, may be 0 if @id_data is NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Buffer"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_list_to_vorbiscomment_buffer" gst_tag_list_to_vorbiscomment_buffer ::
    Ptr Gst.TagList.TagList ->              -- list : TInterface (Name {namespace = "Gst", name = "TagList"})
    Ptr Word8 ->                            -- id_data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- id_data_length : TBasicType TUInt
    CString ->                              -- vendor_string : TBasicType TUTF8
    IO (Ptr Gst.Buffer.Buffer)

{- |
Creates a new vorbiscomment buffer from a tag list.
-}
tagListToVorbiscommentBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@list@/: tag list to convert -}
    -> ByteString
    {- ^ /@idData@/: identification data at start of stream -}
    -> Maybe (T.Text)
    {- ^ /@vendorString@/: string that describes the vendor string or NULL -}
    -> m Gst.Buffer.Buffer
    {- ^ __Returns:__ A new 'GI.Gst.Structs.Buffer.Buffer' containing a vorbiscomment buffer with all tags
         that could be converted from the given tag list. -}
tagListToVorbiscommentBuffer list idData vendorString = liftIO $ do
    let idDataLength = fromIntegral $ B.length idData
    list' <- unsafeManagedPtrGetPtr list
    idData' <- packByteString idData
    maybeVendorString <- case vendorString of
        Nothing -> return nullPtr
        Just jVendorString -> do
            jVendorString' <- textToCString jVendorString
            return jVendorString'
    result <- gst_tag_list_to_vorbiscomment_buffer list' idData' idDataLength maybeVendorString
    checkUnexpectedReturnNULL "tagListToVorbiscommentBuffer" result
    result' <- (wrapBoxed Gst.Buffer.Buffer) result
    touchManagedPtr list
    freeMem idData'
    freeMem maybeVendorString
    return result'


-- function gst_tag_list_to_exif_buffer_with_tiff_header
-- Args : [Arg {argCName = "taglist", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The taglist", 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_tag_list_to_exif_buffer_with_tiff_header" gst_tag_list_to_exif_buffer_with_tiff_header ::
    Ptr Gst.TagList.TagList ->              -- taglist : TInterface (Name {namespace = "Gst", name = "TagList"})
    IO (Ptr Gst.Buffer.Buffer)

{- |
Formats the tags in taglist into exif structure, a tiff header
is put in the beginning of the buffer.
-}
tagListToExifBufferWithTiffHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@taglist@/: The taglist -}
    -> m Gst.Buffer.Buffer
    {- ^ __Returns:__ A GstBuffer containing the data -}
tagListToExifBufferWithTiffHeader taglist = liftIO $ do
    taglist' <- unsafeManagedPtrGetPtr taglist
    result <- gst_tag_list_to_exif_buffer_with_tiff_header taglist'
    checkUnexpectedReturnNULL "tagListToExifBufferWithTiffHeader" result
    result' <- (wrapBoxed Gst.Buffer.Buffer) result
    touchManagedPtr taglist
    return result'


-- function gst_tag_list_to_exif_buffer
-- Args : [Arg {argCName = "taglist", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The taglist", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "byte_order", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "byte order used in writing (G_LITTLE_ENDIAN or G_BIG_ENDIAN)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base_offset", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Offset from the tiff header first byte", 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_tag_list_to_exif_buffer" gst_tag_list_to_exif_buffer ::
    Ptr Gst.TagList.TagList ->              -- taglist : TInterface (Name {namespace = "Gst", name = "TagList"})
    Int32 ->                                -- byte_order : TBasicType TInt
    Word32 ->                               -- base_offset : TBasicType TUInt32
    IO (Ptr Gst.Buffer.Buffer)

{- |
Formats the tags in taglist on exif format. The resulting buffer contains
the tags IFD and is followed by the data pointed by the tag entries.
-}
tagListToExifBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@taglist@/: The taglist -}
    -> Int32
    {- ^ /@byteOrder@/: byte order used in writing (G_LITTLE_ENDIAN or G_BIG_ENDIAN) -}
    -> Word32
    {- ^ /@baseOffset@/: Offset from the tiff header first byte -}
    -> m Gst.Buffer.Buffer
    {- ^ __Returns:__ A GstBuffer containing the tag entries followed by the tag data -}
tagListToExifBuffer taglist byteOrder baseOffset = liftIO $ do
    taglist' <- unsafeManagedPtrGetPtr taglist
    result <- gst_tag_list_to_exif_buffer taglist' byteOrder baseOffset
    checkUnexpectedReturnNULL "tagListToExifBuffer" result
    result' <- (wrapBoxed Gst.Buffer.Buffer) result
    touchManagedPtr taglist
    return result'


-- function gst_tag_list_new_from_id3v1
-- Args : [Arg {argCName = "data", argType = TCArray False 128 (-1) (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "128 bytes of data containing the ID3v1 tag", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_list_new_from_id3v1" gst_tag_list_new_from_id3v1 ::
    Ptr Word8 ->                            -- data : TCArray False 128 (-1) (TBasicType TUInt8)
    IO (Ptr Gst.TagList.TagList)

{- |
Parses the data containing an ID3v1 tag and returns a 'GI.Gst.Structs.TagList.TagList' from the
parsed data.
-}
tagListNewFromId3v1 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@data@/: 128 bytes of data containing the ID3v1 tag -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ A new tag list or NULL if the data was not an ID3v1 tag. -}
tagListNewFromId3v1 data_ = liftIO $ do
    data_' <- packByteString data_
    result <- gst_tag_list_new_from_id3v1 data_'
    checkUnexpectedReturnNULL "tagListNewFromId3v1" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    freeMem data_'
    return result'


-- function gst_tag_list_from_xmp_buffer
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

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

{- |
Parse a xmp packet into a taglist.
-}
tagListFromXmpBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: buffer -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ new taglist or 'Nothing', free the list when done -}
tagListFromXmpBuffer buffer = liftIO $ do
    buffer' <- unsafeManagedPtrGetPtr buffer
    result <- gst_tag_list_from_xmp_buffer buffer'
    checkUnexpectedReturnNULL "tagListFromXmpBuffer" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    touchManagedPtr buffer
    return result'


-- function gst_tag_list_from_vorbiscomment_buffer
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "identification data at start of stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vendor_string", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a string that should take the\n    vendor string of this vorbis comment or NULL if you don't need it.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_list_from_vorbiscomment_buffer" gst_tag_list_from_vorbiscomment_buffer ::
    Ptr Gst.Buffer.Buffer ->                -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
    Ptr Word8 ->                            -- id_data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- id_data_length : TBasicType TUInt
    Ptr CString ->                          -- vendor_string : TBasicType TUTF8
    IO (Ptr Gst.TagList.TagList)

{- |
Creates a new tag list that contains the information parsed out of a
vorbiscomment packet.
-}
tagListFromVorbiscommentBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: buffer to convert -}
    -> ByteString
    {- ^ /@idData@/: identification data at start of stream -}
    -> m ((Gst.TagList.TagList, T.Text))
    {- ^ __Returns:__ A new 'GI.Gst.Structs.TagList.TagList' with all tags that could be extracted from the
         given vorbiscomment buffer or NULL on error. -}
tagListFromVorbiscommentBuffer buffer idData = liftIO $ do
    let idDataLength = fromIntegral $ B.length idData
    buffer' <- unsafeManagedPtrGetPtr buffer
    idData' <- packByteString idData
    vendorString <- allocMem :: IO (Ptr CString)
    result <- gst_tag_list_from_vorbiscomment_buffer buffer' idData' idDataLength vendorString
    checkUnexpectedReturnNULL "tagListFromVorbiscommentBuffer" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    vendorString' <- peek vendorString
    vendorString'' <- cstringToText vendorString'
    freeMem vendorString'
    touchManagedPtr buffer
    freeMem idData'
    freeMem vendorString
    return (result', vendorString'')


-- function gst_tag_list_from_vorbiscomment
-- Args : [Arg {argCName = "data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "data to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "identification data at start of stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "vendor_string", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a string that should take the\n    vendor string of this vorbis comment or NULL if you don't need it.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "id_data_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of identification data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_list_from_vorbiscomment" gst_tag_list_from_vorbiscomment ::
    Ptr Word8 ->                            -- data : TCArray False (-1) 1 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Word8 ->                            -- id_data : TCArray False (-1) 3 (TBasicType TUInt8)
    Word32 ->                               -- id_data_length : TBasicType TUInt
    Ptr CString ->                          -- vendor_string : TBasicType TUTF8
    IO (Ptr Gst.TagList.TagList)

{- |
Creates a new tag list that contains the information parsed out of a
vorbiscomment packet.
-}
tagListFromVorbiscomment ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@data@/: data to convert -}
    -> ByteString
    {- ^ /@idData@/: identification data at start of stream -}
    -> m ((Gst.TagList.TagList, T.Text))
    {- ^ __Returns:__ A new 'GI.Gst.Structs.TagList.TagList' with all tags that could be extracted from the
         given vorbiscomment buffer or NULL on error. -}
tagListFromVorbiscomment data_ idData = liftIO $ do
    let idDataLength = fromIntegral $ B.length idData
    let size = fromIntegral $ B.length data_
    data_' <- packByteString data_
    idData' <- packByteString idData
    vendorString <- allocMem :: IO (Ptr CString)
    result <- gst_tag_list_from_vorbiscomment data_' size idData' idDataLength vendorString
    checkUnexpectedReturnNULL "tagListFromVorbiscomment" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    vendorString' <- peek vendorString
    vendorString'' <- cstringToText vendorString'
    freeMem vendorString'
    freeMem data_'
    freeMem idData'
    freeMem vendorString
    return (result', vendorString'')


-- function gst_tag_list_from_id3v2_tag
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

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

{- |
Creates a new tag list that contains the information parsed out of a
ID3 tag.
-}
tagListFromId3v2Tag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: buffer to convert -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ A new 'GI.Gst.Structs.TagList.TagList' with all tags that could be extracted from the
         given vorbiscomment buffer or NULL on error. -}
tagListFromId3v2Tag buffer = liftIO $ do
    buffer' <- unsafeManagedPtrGetPtr buffer
    result <- gst_tag_list_from_id3v2_tag buffer'
    checkUnexpectedReturnNULL "tagListFromId3v2Tag" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    touchManagedPtr buffer
    return result'


-- function gst_tag_list_from_exif_buffer_with_tiff_header
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The exif buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

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

{- |
Parses the exif tags starting with a tiff header structure.
-}
tagListFromExifBufferWithTiffHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: The exif buffer -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ The taglist -}
tagListFromExifBufferWithTiffHeader buffer = liftIO $ do
    buffer' <- unsafeManagedPtrGetPtr buffer
    result <- gst_tag_list_from_exif_buffer_with_tiff_header buffer'
    checkUnexpectedReturnNULL "tagListFromExifBufferWithTiffHeader" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    touchManagedPtr buffer
    return result'


-- function gst_tag_list_from_exif_buffer
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The exif buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "byte_order", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "byte order of the data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base_offset", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Offset from the tiff header to this buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TagList"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_list_from_exif_buffer" gst_tag_list_from_exif_buffer ::
    Ptr Gst.Buffer.Buffer ->                -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
    Int32 ->                                -- byte_order : TBasicType TInt
    Word32 ->                               -- base_offset : TBasicType TUInt32
    IO (Ptr Gst.TagList.TagList)

{- |
Parses the IFD and IFD tags data contained in the buffer and puts it
on a taglist. The base_offset is used to subtract from the offset in
the tag entries and be able to get the offset relative to the buffer
start
-}
tagListFromExifBuffer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: The exif buffer -}
    -> Int32
    {- ^ /@byteOrder@/: byte order of the data -}
    -> Word32
    {- ^ /@baseOffset@/: Offset from the tiff header to this buffer -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ The parsed taglist -}
tagListFromExifBuffer buffer byteOrder baseOffset = liftIO $ do
    buffer' <- unsafeManagedPtrGetPtr buffer
    result <- gst_tag_list_from_exif_buffer buffer' byteOrder baseOffset
    checkUnexpectedReturnNULL "tagListFromExifBuffer" result
    result' <- (wrapBoxed Gst.TagList.TagList) result
    touchManagedPtr buffer
    return result'


-- function gst_tag_list_add_id3_image
-- Args : [Arg {argCName = "tag_list", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a tag list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "image_data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (encoded) image", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "image_data_len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the encoded image data at @image_data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id3_picture_type", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "picture type as per the ID3 (v2.4.0) specification for\n   the APIC frame (0 = unknown/other)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "image_data_len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the encoded image data at @image_data", 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_tag_list_add_id3_image" gst_tag_list_add_id3_image ::
    Ptr Gst.TagList.TagList ->              -- tag_list : TInterface (Name {namespace = "Gst", name = "TagList"})
    Ptr Word8 ->                            -- image_data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word32 ->                               -- image_data_len : TBasicType TUInt
    Word32 ->                               -- id3_picture_type : TBasicType TUInt
    IO CInt

{- |
Adds an image from an ID3 APIC frame (or similar, such as used in FLAC)
to the given tag list. Also see 'GI.GstTag.Functions.tagImageDataToImageSample' for
more information on image tags in GStreamer.
-}
tagListAddId3Image ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.TagList.TagList
    {- ^ /@tagList@/: a tag list -}
    -> ByteString
    {- ^ /@imageData@/: the (encoded) image -}
    -> Word32
    {- ^ /@id3PictureType@/: picture type as per the ID3 (v2.4.0) specification for
   the APIC frame (0 = unknown\/other) -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the image was processed, otherwise 'False' -}
tagListAddId3Image tagList imageData id3PictureType = liftIO $ do
    let imageDataLen = fromIntegral $ B.length imageData
    tagList' <- unsafeManagedPtrGetPtr tagList
    imageData' <- packByteString imageData
    result <- gst_tag_list_add_id3_image tagList' imageData' imageDataLen id3PictureType
    let result' = (/= 0) result
    touchManagedPtr tagList
    freeMem imageData'
    return result'


-- function gst_tag_image_data_to_image_sample
-- Args : [Arg {argCName = "image_data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the (encoded) image", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "image_data_len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the encoded image data at @image_data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "image_type", argType = TInterface (Name {namespace = "GstTag", name = "TagImageType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "type of the image, or #GST_TAG_IMAGE_TYPE_UNDEFINED. Pass\n    #GST_TAG_IMAGE_TYPE_NONE if no image type should be set at all (e.g.\n    for preview images)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "image_data_len", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the encoded image data at @image_data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Sample"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_image_data_to_image_sample" gst_tag_image_data_to_image_sample ::
    Ptr Word8 ->                            -- image_data : TCArray False (-1) 1 (TBasicType TUInt8)
    Word32 ->                               -- image_data_len : TBasicType TUInt
    CUInt ->                                -- image_type : TInterface (Name {namespace = "GstTag", name = "TagImageType"})
    IO (Ptr Gst.Sample.Sample)

{- |
Helper function for tag-reading plugins to create a 'GI.Gst.Structs.Sample.Sample' suitable to
add to a 'GI.Gst.Structs.TagList.TagList' as an image tag (such as 'GI.Gst.Constants.TAG_IMAGE' or
'GI.Gst.Constants.TAG_PREVIEW_IMAGE') from the encoded image data and an (optional) image
type.

Background: cover art and other images in tags are usually stored as a
blob of binary image data, often accompanied by a MIME type or some other
content type string (e.g. \'png\', \'jpeg\', \'jpg\'). Sometimes there is also an
\'image type\' to indicate what kind of image this is (e.g. front cover,
back cover, artist, etc.). The image data may also be an URI to the image
rather than the image itself.

In GStreamer, image tags are 'GI.Gst.Structs.Sample.Sample'\<!-- -->s containing the raw image
data, with the sample caps describing the content type of the image
(e.g. image\/jpeg, image\/png, text\/uri-list). The sample info may contain
an additional \'image-type\' field of @/GST_TYPE_TAG_IMAGE_TYPE/@ to describe
the type of image (front cover, back cover etc.). 'GI.Gst.Constants.TAG_PREVIEW_IMAGE'
tags should not carry an image type, their type is already indicated via
the special tag name.

This function will do various checks and typefind the encoded image
data (we can\'t trust the declared mime type).
-}
tagImageDataToImageSample ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@imageData@/: the (encoded) image -}
    -> GstTag.Enums.TagImageType
    {- ^ /@imageType@/: type of the image, or @/GST_TAG_IMAGE_TYPE_UNDEFINED/@. Pass
    @/GST_TAG_IMAGE_TYPE_NONE/@ if no image type should be set at all (e.g.
    for preview images) -}
    -> m Gst.Sample.Sample
    {- ^ __Returns:__ a newly-allocated image sample for use in tag lists, or NULL -}
tagImageDataToImageSample imageData imageType = liftIO $ do
    let imageDataLen = fromIntegral $ B.length imageData
    imageData' <- packByteString imageData
    let imageType' = (fromIntegral . fromEnum) imageType
    result <- gst_tag_image_data_to_image_sample imageData' imageDataLen imageType'
    checkUnexpectedReturnNULL "tagImageDataToImageSample" result
    result' <- (wrapBoxed Gst.Sample.Sample) result
    freeMem imageData'
    return result'


-- function gst_tag_id3_genre_get
-- Args : [Arg {argCName = "id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ID of genre to query", 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_tag_id3_genre_get" gst_tag_id3_genre_get ::
    Word32 ->                               -- id : TBasicType TUInt
    IO CString

{- |
Gets the ID3v1 genre name for a given ID.
-}
tagId3GenreGet ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@id@/: ID of genre to query -}
    -> m T.Text
    {- ^ __Returns:__ the genre or NULL if no genre is associated with that ID. -}
tagId3GenreGet id = liftIO $ do
    result <- gst_tag_id3_genre_get id
    checkUnexpectedReturnNULL "tagId3GenreGet" result
    result' <- cstringToText result
    return result'


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

foreign import ccall "gst_tag_id3_genre_count" gst_tag_id3_genre_count ::
    IO Word32

{- |
Gets the number of ID3v1 genres that can be identified. Winamp genres are
included.
-}
tagId3GenreCount ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    {- ^ __Returns:__ the number of ID3v1 genres that can be identified -}
tagId3GenreCount  = liftIO $ do
    result <- gst_tag_id3_genre_count
    return result


-- function gst_tag_get_licenses
-- Args : []
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_get_licenses" gst_tag_get_licenses ::
    IO (Ptr CString)

{- |
Returns a list of known license references (in form of URIs). This is
useful for UIs to build a list of available licenses for tagging purposes
(e.g. to tag an audio track appropriately in a video or audio editor, or
an image in a camera application).
-}
tagGetLicenses ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m [T.Text]
    {- ^ __Returns:__ NULL-terminated array of license strings. Free
    with 'GI.GLib.Functions.strfreev' when no longer needed. -}
tagGetLicenses  = liftIO $ do
    result <- gst_tag_get_licenses
    checkUnexpectedReturnNULL "tagGetLicenses" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    return result'


-- function gst_tag_get_license_version
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", 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_tag_get_license_version" gst_tag_get_license_version ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CString

{- |
Get the version of a license.
-}
tagGetLicenseVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m T.Text
    {- ^ __Returns:__ the version of the license, or NULL if the license is not known or
   has no version -}
tagGetLicenseVersion licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_version licenseRef'
    checkUnexpectedReturnNULL "tagGetLicenseVersion" result
    result' <- cstringToText result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_license_title
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", 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_tag_get_license_title" gst_tag_get_license_title ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CString

{- |
Get the title of a license, which is a short translated description
of the license\'s features (generally not very pretty though).
-}
tagGetLicenseTitle ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m T.Text
    {- ^ __Returns:__ the title of the license, or NULL if the license is unknown or
   no title is available. -}
tagGetLicenseTitle licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_title licenseRef'
    checkUnexpectedReturnNULL "tagGetLicenseTitle" result
    result' <- cstringToText result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_license_nick
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", 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_tag_get_license_nick" gst_tag_get_license_nick ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CString

{- |
Get the nick name of a license, which is a short (untranslated) string
such as e.g. \"CC BY-NC-ND 2.0 UK\".
-}
tagGetLicenseNick ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m T.Text
    {- ^ __Returns:__ the nick name of the license, or NULL if the license is unknown -}
tagGetLicenseNick licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_nick licenseRef'
    checkUnexpectedReturnNULL "tagGetLicenseNick" result
    result' <- cstringToText result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_license_jurisdiction
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", 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_tag_get_license_jurisdiction" gst_tag_get_license_jurisdiction ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CString

{- |
Get the jurisdiction code of a license. This is usually a two-letter
ISO 3166-1 alpha-2 code, but there is also the special case of Scotland,
for which no code exists and which is thus represented as \"scotland\".

Known jurisdictions: ar, at, au, be, bg, br, ca, ch, cl, cn, co, de,
dk, es, fi, fr, hr, hu, il, in, it, jp, kr, mk, mt, mx, my, nl, pe, pl,
pt, scotland, se, si, tw, uk, us, za.
-}
tagGetLicenseJurisdiction ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m T.Text
    {- ^ __Returns:__ the jurisdiction code of the license, or NULL if the license is
   unknown or is not specific to a particular jurisdiction. -}
tagGetLicenseJurisdiction licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_jurisdiction licenseRef'
    checkUnexpectedReturnNULL "tagGetLicenseJurisdiction" result
    result' <- cstringToText result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_license_flags
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstTag", name = "TagLicenseFlags"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_get_license_flags" gst_tag_get_license_flags ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CUInt

{- |
Get the flags of a license, which describe most of the features of
a license in their most general form.
-}
tagGetLicenseFlags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m [GstTag.Flags.TagLicenseFlags]
    {- ^ __Returns:__ the flags of the license, or 0 if the license is unknown -}
tagGetLicenseFlags licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_flags licenseRef'
    let result' = wordToGFlags result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_license_description
-- Args : [Arg {argCName = "license_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a license reference string in form of a URI,\n    e.g. \"http://creativecommons.org/licenses/by-nc-nd/2.0/\"", 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_tag_get_license_description" gst_tag_get_license_description ::
    CString ->                              -- license_ref : TBasicType TUTF8
    IO CString

{- |
Get the description of a license, which is a translated description
of the license\'s main features.
-}
tagGetLicenseDescription ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@licenseRef@/: a license reference string in form of a URI,
    e.g. \"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/\" -}
    -> m T.Text
    {- ^ __Returns:__ the description of the license, or NULL if the license is unknown
   or a description is not available. -}
tagGetLicenseDescription licenseRef = liftIO $ do
    licenseRef' <- textToCString licenseRef
    result <- gst_tag_get_license_description licenseRef'
    checkUnexpectedReturnNULL "tagGetLicenseDescription" result
    result' <- cstringToText result
    freeMem licenseRef'
    return result'


-- function gst_tag_get_language_name
-- Args : [Arg {argCName = "language_code", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "two or three-letter ISO-639 language code", 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_tag_get_language_name" gst_tag_get_language_name ::
    CString ->                              -- language_code : TBasicType TUTF8
    IO CString

{- |
Returns the name of the language given an ISO-639 language code as
found in a GST_TAG_LANGUAGE_CODE tag. The name will be translated
according to the current locale (if the library was built against the
iso-codes package, otherwise the English name will be returned).

Language codes are case-sensitive and expected to be lower case.
-}
tagGetLanguageName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@languageCode@/: two or three-letter ISO-639 language code -}
    -> m T.Text
    {- ^ __Returns:__ language name in UTF-8 format, or NULL if /@languageCode@/ could
    not be mapped to a language name. The returned string must not be
    modified and does not need to freed; it will stay valid until the
    application is terminated. -}
tagGetLanguageName languageCode = liftIO $ do
    languageCode' <- textToCString languageCode
    result <- gst_tag_get_language_name languageCode'
    checkUnexpectedReturnNULL "tagGetLanguageName" result
    result' <- cstringToText result
    freeMem languageCode'
    return result'


-- function gst_tag_get_language_codes
-- Args : []
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_tag_get_language_codes" gst_tag_get_language_codes ::
    IO (Ptr CString)

{- |
Returns a list of known language codes (in form of two-letter ISO-639-1
codes). This is useful for UIs to build a list of available languages for
tagging purposes (e.g. to tag an audio track appropriately in a video or
audio editor).
-}
tagGetLanguageCodes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m [T.Text]
    {- ^ __Returns:__ NULL-terminated string array with two-letter
    language codes. Free with 'GI.GLib.Functions.strfreev' when no longer needed. -}
tagGetLanguageCodes  = liftIO $ do
    result <- gst_tag_get_language_codes
    checkUnexpectedReturnNULL "tagGetLanguageCodes" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    return result'


-- function gst_tag_get_language_code_iso_639_2T
-- Args : [Arg {argCName = "lang_code", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\")", 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_tag_get_language_code_iso_639_2T" gst_tag_get_language_code_iso_639_2T ::
    CString ->                              -- lang_code : TBasicType TUTF8
    IO CString

{- |
Returns three-letter ISO-639-2 \"terminological\" language code given a
two-letter ISO-639-1 language code or a three-letter ISO-639-2 language
code (both are accepted for convenience).

The \"terminological\" code is derived from the local name of the language
(e.g. \"deu\" for German instead of \"ger\"). In most scenarios, the
\"terminological\" codes are prefered over the \"bibliographic\" ones.

Language codes are case-sensitive and expected to be lower case.
-}
tagGetLanguageCodeIso6392T ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@langCode@/: ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\") -}
    -> m T.Text
    {- ^ __Returns:__ three-letter ISO-639-2 language code string that maps to /@langCode@/,
    or NULL if no mapping is known. The returned string must not be
    modified or freed. -}
tagGetLanguageCodeIso6392T langCode = liftIO $ do
    langCode' <- textToCString langCode
    result <- gst_tag_get_language_code_iso_639_2T langCode'
    checkUnexpectedReturnNULL "tagGetLanguageCodeIso6392T" result
    result' <- cstringToText result
    freeMem langCode'
    return result'


-- function gst_tag_get_language_code_iso_639_2B
-- Args : [Arg {argCName = "lang_code", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\")", 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_tag_get_language_code_iso_639_2B" gst_tag_get_language_code_iso_639_2B ::
    CString ->                              -- lang_code : TBasicType TUTF8
    IO CString

{- |
Returns three-letter ISO-639-2 \"bibliographic\" language code given a
two-letter ISO-639-1 language code or a three-letter ISO-639-2 language
code (both are accepted for convenience).

The \"bibliographic\" code is derived from the English name of the language
(e.g. \"ger\" for German instead of \"de\" or \"deu\"). In most scenarios, the
\"terminological\" codes are prefered.

Language codes are case-sensitive and expected to be lower case.
-}
tagGetLanguageCodeIso6392B ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@langCode@/: ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\") -}
    -> m T.Text
    {- ^ __Returns:__ three-letter ISO-639-2 language code string that maps to /@langCode@/,
    or NULL if no mapping is known. The returned string must not be
    modified or freed. -}
tagGetLanguageCodeIso6392B langCode = liftIO $ do
    langCode' <- textToCString langCode
    result <- gst_tag_get_language_code_iso_639_2B langCode'
    checkUnexpectedReturnNULL "tagGetLanguageCodeIso6392B" result
    result' <- cstringToText result
    freeMem langCode'
    return result'


-- function gst_tag_get_language_code_iso_639_1
-- Args : [Arg {argCName = "lang_code", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\")", 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_tag_get_language_code_iso_639_1" gst_tag_get_language_code_iso_639_1 ::
    CString ->                              -- lang_code : TBasicType TUTF8
    IO CString

{- |
Returns two-letter ISO-639-1 language code given a three-letter ISO-639-2
language code or two-letter ISO-639-1 language code (both are accepted for
convenience).

Language codes are case-sensitive and expected to be lower case.
-}
tagGetLanguageCodeIso6391 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@langCode@/: ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\") -}
    -> m T.Text
    {- ^ __Returns:__ two-letter ISO-639-1 language code string that maps to /@langCode@/,
    or NULL if no mapping is known. The returned string must not be
    modified or freed. -}
tagGetLanguageCodeIso6391 langCode = liftIO $ do
    langCode' <- textToCString langCode
    result <- gst_tag_get_language_code_iso_639_1 langCode'
    checkUnexpectedReturnNULL "tagGetLanguageCodeIso6391" result
    result' <- cstringToText result
    freeMem langCode'
    return result'


-- function gst_tag_get_id3v2_tag_size
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer holding ID3v2 tag (or at least the start of one)", 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_tag_get_id3v2_tag_size" gst_tag_get_id3v2_tag_size ::
    Ptr Gst.Buffer.Buffer ->                -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
    IO Word32

{- |
Determines size of an ID3v2 tag on buffer containing at least ID3v2 header,
i.e. at least 'GI.GstTag.Constants.TAG_ID3V2_HEADER_SIZE' (10) bytes;
-}
tagGetId3v2TagSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Buffer.Buffer
    {- ^ /@buffer@/: buffer holding ID3v2 tag (or at least the start of one) -}
    -> m Word32
    {- ^ __Returns:__ Size of tag, or 0 if header is invalid or too small. -}
tagGetId3v2TagSize buffer = liftIO $ do
    buffer' <- unsafeManagedPtrGetPtr buffer
    result <- gst_tag_get_id3v2_tag_size buffer'
    touchManagedPtr buffer
    return result


-- function gst_tag_from_vorbis_tag
-- Args : [Arg {argCName = "vorbis_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "vorbiscomment tag to convert to GStreamer tag", 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_tag_from_vorbis_tag" gst_tag_from_vorbis_tag ::
    CString ->                              -- vorbis_tag : TBasicType TUTF8
    IO CString

{- |
Looks up the GStreamer tag for a vorbiscomment tag.
-}
tagFromVorbisTag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@vorbisTag@/: vorbiscomment tag to convert to GStreamer tag -}
    -> m T.Text
    {- ^ __Returns:__ The corresponding GStreamer tag or NULL if none exists. -}
tagFromVorbisTag vorbisTag = liftIO $ do
    vorbisTag' <- textToCString vorbisTag
    result <- gst_tag_from_vorbis_tag vorbisTag'
    checkUnexpectedReturnNULL "tagFromVorbisTag" result
    result' <- cstringToText result
    freeMem vorbisTag'
    return result'


-- function gst_tag_from_id3_user_tag
-- Args : [Arg {argCName = "type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of ID3v2 user tag (e.g. \"TXXX\" or \"UDIF\")", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "id3_user_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ID3v2 user tag to convert to GStreamer tag", 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_tag_from_id3_user_tag" gst_tag_from_id3_user_tag ::
    CString ->                              -- type : TBasicType TUTF8
    CString ->                              -- id3_user_tag : TBasicType TUTF8
    IO CString

{- |
Looks up the GStreamer tag for an ID3v2 user tag (e.g. description in
TXXX frame or owner in UFID frame).
-}
tagFromId3UserTag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@type@/: the type of ID3v2 user tag (e.g. \"TXXX\" or \"UDIF\") -}
    -> T.Text
    {- ^ /@id3UserTag@/: ID3v2 user tag to convert to GStreamer tag -}
    -> m T.Text
    {- ^ __Returns:__ The corresponding GStreamer tag or NULL if none exists. -}
tagFromId3UserTag type_ id3UserTag = liftIO $ do
    type_' <- textToCString type_
    id3UserTag' <- textToCString id3UserTag
    result <- gst_tag_from_id3_user_tag type_' id3UserTag'
    checkUnexpectedReturnNULL "tagFromId3UserTag" result
    result' <- cstringToText result
    freeMem type_'
    freeMem id3UserTag'
    return result'


-- function gst_tag_from_id3_tag
-- Args : [Arg {argCName = "id3_tag", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ID3v2 tag to convert to GStreamer tag", 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_tag_from_id3_tag" gst_tag_from_id3_tag ::
    CString ->                              -- id3_tag : TBasicType TUTF8
    IO CString

{- |
Looks up the GStreamer tag for a ID3v2 tag.
-}
tagFromId3Tag ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@id3Tag@/: ID3v2 tag to convert to GStreamer tag -}
    -> m T.Text
    {- ^ __Returns:__ The corresponding GStreamer tag or NULL if none exists. -}
tagFromId3Tag id3Tag = liftIO $ do
    id3Tag' <- textToCString id3Tag
    result <- gst_tag_from_id3_tag id3Tag'
    checkUnexpectedReturnNULL "tagFromId3Tag" result
    result' <- cstringToText result
    freeMem id3Tag'
    return result'


-- function gst_tag_freeform_string_to_utf8
-- Args : [Arg {argCName = "data", argType = TCArray False (-1) 1 (TBasicType TInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of string data, or -1 if the string is NUL-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "env_vars", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n   a NULL-terminated string array of environment variable names, or NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "size", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of string data, or -1 if the string is NUL-terminated", 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_tag_freeform_string_to_utf8" gst_tag_freeform_string_to_utf8 ::
    Ptr Int8 ->                             -- data : TCArray False (-1) 1 (TBasicType TInt8)
    Int32 ->                                -- size : TBasicType TInt
    Ptr CString ->                          -- env_vars : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO CString

{- |
Convenience function to read a string with unknown character encoding. If
the string is already in UTF-8 encoding, it will be returned right away.
If not it tries to detect byte-order-mark for UTF-16\/32 cases and use that.
Otherwise, the environment will be searched for a number of environment
variables (whose names are specified in the NULL-terminated string array
/@envVars@/) containing a list of character encodings to try\/use. If none
are specified, the current locale will be tried. If that also doesn\'t work,
WINDOWS-1252\/ISO-8859-1 is assumed (which will almost always succeed).
-}
tagFreeformStringToUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Int8]
    {- ^ /@data@/: string data -}
    -> [T.Text]
    {- ^ /@envVars@/: 
   a NULL-terminated string array of environment variable names, or NULL -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated string in UTF-8 encoding, or NULL -}
tagFreeformStringToUtf8 data_ envVars = liftIO $ do
    let size = fromIntegral $ length data_
    data_' <- packStorableArray data_
    envVars' <- packZeroTerminatedUTF8CArray envVars
    result <- gst_tag_freeform_string_to_utf8 data_' size envVars'
    checkUnexpectedReturnNULL "tagFreeformStringToUtf8" result
    result' <- cstringToText result
    freeMem result
    freeMem data_'
    mapZeroTerminatedCArray freeMem envVars'
    freeMem envVars'
    return result'


-- function gst_tag_check_language_code
-- Args : [Arg {argCName = "lang_code", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\")", 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_tag_check_language_code" gst_tag_check_language_code ::
    CString ->                              -- lang_code : TBasicType TUTF8
    IO CInt

{- |
Check if a given string contains a known ISO 639 language code.

This is useful in situations where it\'s not clear whether a given
string is a language code (which should be put into a 'GI.Gst.Constants.TAG_LANGUAGE_CODE'
tag) or a free-form language name descriptor (which should be put into a
'GI.Gst.Constants.TAG_LANGUAGE_NAME' tag instead).
-}
tagCheckLanguageCode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@langCode@/: ISO-639 language code (e.g. \"deu\" or \"ger\" or \"de\") -}
    -> m Bool
    {- ^ __Returns:__ TRUE if the two- or three-letter language code in /@langCode@/
    is a valid ISO-639 language code. -}
tagCheckLanguageCode langCode = liftIO $ do
    langCode' <- textToCString langCode
    result <- gst_tag_check_language_code langCode'
    let result' = (/= 0) result
    freeMem langCode'
    return result'