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

'GI.Gst.Structs.Toc.Toc' functions are used to create\/free 'GI.Gst.Structs.Toc.Toc' and 'GI.Gst.Structs.TocEntry.TocEntry' structures.
Also they are used to convert 'GI.Gst.Structs.Toc.Toc' into 'GI.Gst.Structs.Structure.Structure' and vice versa.

'GI.Gst.Structs.Toc.Toc' lets you to inform other elements in pipeline or application that playing
source has some kind of table of contents (TOC). These may be chapters, editions,
angles or other types. For example: DVD chapters, Matroska chapters or cue sheet
TOC. Such TOC will be useful for applications to display instead of just a
playlist.

Using TOC is very easy. Firstly, create 'GI.Gst.Structs.Toc.Toc' structure which represents root
contents of the source. You can also attach TOC-specific tags to it. Then fill
it with 'GI.Gst.Structs.TocEntry.TocEntry' entries by appending them to the 'GI.Gst.Structs.Toc.Toc' using
'GI.Gst.Structs.Toc.tocAppendEntry', and appending subentries to a 'GI.Gst.Structs.TocEntry.TocEntry' using
'GI.Gst.Structs.TocEntry.tocEntryAppendSubEntry'.

Note that root level of the TOC can contain only either editions or chapters. You
should not mix them together at the same level. Otherwise you will get serialization
\/deserialization errors. Make sure that no one of the entries has negative start and
 stop values.

Use 'GI.Gst.Structs.Event.eventNewToc' to create a new TOC 'GI.Gst.Structs.Event.Event', and 'GI.Gst.Structs.Event.eventParseToc' to
parse received TOC event. Use 'GI.Gst.Structs.Event.eventNewTocSelect' to create a new TOC select 'GI.Gst.Structs.Event.Event',
and 'GI.Gst.Structs.Event.eventParseTocSelect' to parse received TOC select event. The same rule for
the 'GI.Gst.Structs.Message.Message': 'GI.Gst.Structs.Message.messageNewToc' to create new TOC 'GI.Gst.Structs.Message.Message', and
'GI.Gst.Structs.Message.messageParseToc' to parse received TOC message.

TOCs can have global scope or current scope. Global scope TOCs contain
all entries that can possibly be selected using a toc select event, and
are what an application is usually interested in. TOCs with current scope
only contain the parts of the TOC relevant to the currently selected\/playing
stream; the current scope TOC is used by downstream elements such as muxers
to write correct TOC entries when transcoding files, for example. When
playing a DVD, the global TOC would contain a hierarchy of all titles,
chapters and angles, for example, while the current TOC would only contain
the chapters for the currently playing title if playback of a specific
title was requested.

Applications and plugins should not rely on TOCs having a certain kind of
structure, but should allow for different alternatives. For example, a
simple CUE sheet embedded in a file may be presented as a flat list of
track entries, or could have a top-level edition node (or some other
alternative type entry) with track entries underneath that node; or even
multiple top-level edition nodes (or some other alternative type entries)
each with track entries underneath, in case the source file has extracted
a track listing from different sources).
-}

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

module GI.Gst.Structs.Toc
    (

-- * Exported types
    Toc(..)                                 ,
    noToc                                   ,


 -- * Methods
-- ** appendEntry #method:appendEntry#

#if ENABLE_OVERLOADING
    TocAppendEntryMethodInfo                ,
#endif
    tocAppendEntry                          ,


-- ** dump #method:dump#

#if ENABLE_OVERLOADING
    TocDumpMethodInfo                       ,
#endif
    tocDump                                 ,


-- ** findEntry #method:findEntry#

#if ENABLE_OVERLOADING
    TocFindEntryMethodInfo                  ,
#endif
    tocFindEntry                            ,


-- ** getEntries #method:getEntries#

#if ENABLE_OVERLOADING
    TocGetEntriesMethodInfo                 ,
#endif
    tocGetEntries                           ,


-- ** getScope #method:getScope#

#if ENABLE_OVERLOADING
    TocGetScopeMethodInfo                   ,
#endif
    tocGetScope                             ,


-- ** getTags #method:getTags#

#if ENABLE_OVERLOADING
    TocGetTagsMethodInfo                    ,
#endif
    tocGetTags                              ,


-- ** mergeTags #method:mergeTags#

#if ENABLE_OVERLOADING
    TocMergeTagsMethodInfo                  ,
#endif
    tocMergeTags                            ,


-- ** new #method:new#

    tocNew                                  ,


-- ** setTags #method:setTags#

#if ENABLE_OVERLOADING
    TocSetTagsMethodInfo                    ,
#endif
    tocSetTags                              ,




    ) where

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

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

import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Structs.TagList as Gst.TagList
import {-# SOURCE #-} qualified GI.Gst.Structs.TocEntry as Gst.TocEntry

-- | Memory-managed wrapper type.
newtype Toc = Toc (ManagedPtr Toc)
foreign import ccall "gst_toc_get_type" c_gst_toc_get_type ::
    IO GType

instance BoxedObject Toc where
    boxedType _ = c_gst_toc_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `Toc`.
noToc :: Maybe Toc
noToc = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList Toc
type instance O.AttributeList Toc = TocAttributeList
type TocAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method Toc::new
-- method type : Constructor
-- Args : [Arg {argCName = "scope", argType = TInterface (Name {namespace = "Gst", name = "TocScope"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "scope of this TOC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "Toc"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_toc_new" gst_toc_new ::
    CUInt ->                                -- scope : TInterface (Name {namespace = "Gst", name = "TocScope"})
    IO (Ptr Toc)

{- |
Create a new 'GI.Gst.Structs.Toc.Toc' structure.
-}
tocNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Enums.TocScope
    {- ^ /@scope@/: scope of this TOC -}
    -> m Toc
    {- ^ __Returns:__ newly allocated 'GI.Gst.Structs.Toc.Toc' structure, free it
    with @/gst_toc_unref()/@. -}
tocNew scope = liftIO $ do
    let scope' = (fromIntegral . fromEnum) scope
    result <- gst_toc_new scope'
    checkUnexpectedReturnNULL "tocNew" result
    result' <- (wrapBoxed Toc) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Toc::append_entry
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstToc instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "entry", argType = TInterface (Name {namespace = "Gst", name = "TocEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstTocEntry", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_toc_append_entry" gst_toc_append_entry ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    Ptr Gst.TocEntry.TocEntry ->            -- entry : TInterface (Name {namespace = "Gst", name = "TocEntry"})
    IO ()

{- |
Appends the 'GI.Gst.Structs.TocEntry.TocEntry' /@entry@/ to /@toc@/.
-}
tocAppendEntry ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: A 'GI.Gst.Structs.Toc.Toc' instance -}
    -> Gst.TocEntry.TocEntry
    {- ^ /@entry@/: A 'GI.Gst.Structs.TocEntry.TocEntry' -}
    -> m ()
tocAppendEntry toc entry = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    entry' <- B.ManagedPtr.disownBoxed entry
    gst_toc_append_entry toc' entry'
    touchManagedPtr toc
    touchManagedPtr entry
    return ()

#if ENABLE_OVERLOADING
data TocAppendEntryMethodInfo
instance (signature ~ (Gst.TocEntry.TocEntry -> m ()), MonadIO m) => O.MethodInfo TocAppendEntryMethodInfo Toc signature where
    overloadedMethod _ = tocAppendEntry

#endif

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

foreign import ccall "gst_toc_dump" gst_toc_dump ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    IO ()

{- |
/No description available in the introspection data./
-}
tocDump ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    -> m ()
tocDump toc = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    gst_toc_dump toc'
    touchManagedPtr toc
    return ()

#if ENABLE_OVERLOADING
data TocDumpMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TocDumpMethodInfo Toc signature where
    overloadedMethod _ = tocDump

#endif

-- method Toc::find_entry
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstToc to search in.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "UID to find #GstTocEntry with.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "TocEntry"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_toc_find_entry" gst_toc_find_entry ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    CString ->                              -- uid : TBasicType TUTF8
    IO (Ptr Gst.TocEntry.TocEntry)

{- |
Find 'GI.Gst.Structs.TocEntry.TocEntry' with given /@uid@/ in the /@toc@/.
-}
tocFindEntry ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: 'GI.Gst.Structs.Toc.Toc' to search in. -}
    -> T.Text
    {- ^ /@uid@/: UID to find 'GI.Gst.Structs.TocEntry.TocEntry' with. -}
    -> m (Maybe Gst.TocEntry.TocEntry)
    {- ^ __Returns:__ 'GI.Gst.Structs.TocEntry.TocEntry' with specified
/@uid@/ from the /@toc@/, or 'Nothing' if not found. -}
tocFindEntry toc uid = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    uid' <- textToCString uid
    result <- gst_toc_find_entry toc' uid'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Gst.TocEntry.TocEntry) result'
        return result''
    touchManagedPtr toc
    freeMem uid'
    return maybeResult

#if ENABLE_OVERLOADING
data TocFindEntryMethodInfo
instance (signature ~ (T.Text -> m (Maybe Gst.TocEntry.TocEntry)), MonadIO m) => O.MethodInfo TocFindEntryMethodInfo Toc signature where
    overloadedMethod _ = tocFindEntry

#endif

-- method Toc::get_entries
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstToc instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gst", name = "TocEntry"})))
-- throws : False
-- Skip return : False

foreign import ccall "gst_toc_get_entries" gst_toc_get_entries ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    IO (Ptr (GList (Ptr Gst.TocEntry.TocEntry)))

{- |
Gets the list of 'GI.Gst.Structs.TocEntry.TocEntry' of /@toc@/.
-}
tocGetEntries ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: A 'GI.Gst.Structs.Toc.Toc' instance -}
    -> m [Gst.TocEntry.TocEntry]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Gst.Structs.TocEntry.TocEntry' for /@entry@/ -}
tocGetEntries toc = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    result <- gst_toc_get_entries toc'
    result' <- unpackGList result
    result'' <- mapM (newBoxed Gst.TocEntry.TocEntry) result'
    touchManagedPtr toc
    return result''

#if ENABLE_OVERLOADING
data TocGetEntriesMethodInfo
instance (signature ~ (m [Gst.TocEntry.TocEntry]), MonadIO m) => O.MethodInfo TocGetEntriesMethodInfo Toc signature where
    overloadedMethod _ = tocGetEntries

#endif

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

foreign import ccall "gst_toc_get_scope" gst_toc_get_scope ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    IO CUInt

{- |
/No description available in the introspection data./
-}
tocGetScope ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: a 'GI.Gst.Structs.Toc.Toc' instance -}
    -> m Gst.Enums.TocScope
    {- ^ __Returns:__ scope of /@toc@/ -}
tocGetScope toc = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    result <- gst_toc_get_scope toc'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr toc
    return result'

#if ENABLE_OVERLOADING
data TocGetScopeMethodInfo
instance (signature ~ (m Gst.Enums.TocScope), MonadIO m) => O.MethodInfo TocGetScopeMethodInfo Toc signature where
    overloadedMethod _ = tocGetScope

#endif

-- method Toc::get_tags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstToc instance", 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_toc_get_tags" gst_toc_get_tags ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    IO (Ptr Gst.TagList.TagList)

{- |
Gets the tags for /@toc@/.
-}
tocGetTags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: A 'GI.Gst.Structs.Toc.Toc' instance -}
    -> m Gst.TagList.TagList
    {- ^ __Returns:__ A 'GI.Gst.Structs.TagList.TagList' for /@entry@/ -}
tocGetTags toc = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    result <- gst_toc_get_tags toc'
    checkUnexpectedReturnNULL "tocGetTags" result
    result' <- (newBoxed Gst.TagList.TagList) result
    touchManagedPtr toc
    return result'

#if ENABLE_OVERLOADING
data TocGetTagsMethodInfo
instance (signature ~ (m Gst.TagList.TagList), MonadIO m) => O.MethodInfo TocGetTagsMethodInfo Toc signature where
    overloadedMethod _ = tocGetTags

#endif

-- method Toc::merge_tags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstToc instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tags", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GstTagList or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "Gst", name = "TagMergeMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstTagMergeMode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_toc_merge_tags" gst_toc_merge_tags ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    Ptr Gst.TagList.TagList ->              -- tags : TInterface (Name {namespace = "Gst", name = "TagList"})
    CUInt ->                                -- mode : TInterface (Name {namespace = "Gst", name = "TagMergeMode"})
    IO ()

{- |
Merge /@tags@/ into the existing tags of /@toc@/ using /@mode@/.
-}
tocMergeTags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: A 'GI.Gst.Structs.Toc.Toc' instance -}
    -> Maybe (Gst.TagList.TagList)
    {- ^ /@tags@/: A 'GI.Gst.Structs.TagList.TagList' or 'Nothing' -}
    -> Gst.Enums.TagMergeMode
    {- ^ /@mode@/: A 'GI.Gst.Enums.TagMergeMode' -}
    -> m ()
tocMergeTags toc tags mode = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    maybeTags <- case tags of
        Nothing -> return nullPtr
        Just jTags -> do
            jTags' <- unsafeManagedPtrGetPtr jTags
            return jTags'
    let mode' = (fromIntegral . fromEnum) mode
    gst_toc_merge_tags toc' maybeTags mode'
    touchManagedPtr toc
    whenJust tags touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data TocMergeTagsMethodInfo
instance (signature ~ (Maybe (Gst.TagList.TagList) -> Gst.Enums.TagMergeMode -> m ()), MonadIO m) => O.MethodInfo TocMergeTagsMethodInfo Toc signature where
    overloadedMethod _ = tocMergeTags

#endif

-- method Toc::set_tags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "toc", argType = TInterface (Name {namespace = "Gst", name = "Toc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GstToc instance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tags", argType = TInterface (Name {namespace = "Gst", name = "TagList"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GstTagList 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_toc_set_tags" gst_toc_set_tags ::
    Ptr Toc ->                              -- toc : TInterface (Name {namespace = "Gst", name = "Toc"})
    Ptr Gst.TagList.TagList ->              -- tags : TInterface (Name {namespace = "Gst", name = "TagList"})
    IO ()

{- |
Set a 'GI.Gst.Structs.TagList.TagList' with tags for the complete /@toc@/.
-}
tocSetTags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Toc
    {- ^ /@toc@/: A 'GI.Gst.Structs.Toc.Toc' instance -}
    -> Maybe (Gst.TagList.TagList)
    {- ^ /@tags@/: A 'GI.Gst.Structs.TagList.TagList' or 'Nothing' -}
    -> m ()
tocSetTags toc tags = liftIO $ do
    toc' <- unsafeManagedPtrGetPtr toc
    maybeTags <- case tags of
        Nothing -> return nullPtr
        Just jTags -> do
            jTags' <- B.ManagedPtr.disownBoxed jTags
            return jTags'
    gst_toc_set_tags toc' maybeTags
    touchManagedPtr toc
    whenJust tags touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data TocSetTagsMethodInfo
instance (signature ~ (Maybe (Gst.TagList.TagList) -> m ()), MonadIO m) => O.MethodInfo TocSetTagsMethodInfo Toc signature where
    overloadedMethod _ = tocSetTags

#endif

#if ENABLE_OVERLOADING
type family ResolveTocMethod (t :: Symbol) (o :: *) :: * where
    ResolveTocMethod "appendEntry" o = TocAppendEntryMethodInfo
    ResolveTocMethod "dump" o = TocDumpMethodInfo
    ResolveTocMethod "findEntry" o = TocFindEntryMethodInfo
    ResolveTocMethod "mergeTags" o = TocMergeTagsMethodInfo
    ResolveTocMethod "getEntries" o = TocGetEntriesMethodInfo
    ResolveTocMethod "getScope" o = TocGetScopeMethodInfo
    ResolveTocMethod "getTags" o = TocGetTagsMethodInfo
    ResolveTocMethod "setTags" o = TocSetTagsMethodInfo
    ResolveTocMethod l o = O.MethodResolutionFailed l o

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

#endif