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

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

module GI.GstBase.Functions
    ( 

 -- * Methods


-- ** typeFindHelper #method:typeFindHelper#

    typeFindHelper                          ,


-- ** typeFindHelperForBuffer #method:typeFindHelperForBuffer#

    typeFindHelperForBuffer                 ,


-- ** typeFindHelperForBufferWithExtension #method:typeFindHelperForBufferWithExtension#

    typeFindHelperForBufferWithExtension    ,


-- ** typeFindHelperForData #method:typeFindHelperForData#

    typeFindHelperForData                   ,


-- ** typeFindHelperForDataWithExtension #method:typeFindHelperForDataWithExtension#

    typeFindHelperForDataWithExtension      ,


-- ** typeFindHelperForExtension #method:typeFindHelperForExtension#

    typeFindHelperForExtension              ,


-- ** typeFindHelperGetRange #method:typeFindHelperGetRange#

    typeFindHelperGetRange                  ,


-- ** typeFindHelperGetRangeFull #method:typeFindHelperGetRangeFull#

    typeFindHelperGetRangeFull              ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import qualified GI.Gst.Enums as Gst.Enums
import qualified GI.Gst.Objects.Object as Gst.Object
import qualified GI.Gst.Objects.Pad as Gst.Pad
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.Caps as Gst.Caps
import qualified GI.GstBase.Callbacks as GstBase.Callbacks

-- function type_find_helper_get_range_full
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "A #GstObject that will be passed as first argument to @func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "parent"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the parent of @obj or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "func"
--           , argType =
--               TInterface
--                 Name
--                   { namespace = "GstBase" , name = "TypeFindHelperGetRangeFunction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "A generic #GstTypeFindHelperGetRangeFunction that will\n       be used to access data at random offsets when doing the typefinding"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "size"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The length in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "extension of the media, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "caps"
--           , argType = TInterface Name { namespace = "Gst" , name = "Caps" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "returned caps" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "FlowReturn" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_get_range_full" gst_type_find_helper_get_range_full :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Gst.Object.Object ->                -- parent : TInterface (Name {namespace = "Gst", name = "Object"})
    FunPtr GstBase.Callbacks.C_TypeFindHelperGetRangeFunction -> -- func : TInterface (Name {namespace = "GstBase", name = "TypeFindHelperGetRangeFunction"})
    Word64 ->                               -- size : TBasicType TUInt64
    CString ->                              -- extension : TBasicType TUTF8
    Ptr (Ptr Gst.Caps.Caps) ->              -- caps : TInterface (Name {namespace = "Gst", name = "Caps"})
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO CInt

-- | Utility function to do pull-based typefinding. Unlike 'GI.GstBase.Functions.typeFindHelper'
-- however, this function will use the specified function /@func@/ to obtain the
-- data needed by the typefind functions, rather than operating on a given
-- source pad. This is useful mostly for elements like tag demuxers which
-- strip off data at the beginning and\/or end of a file and want to typefind
-- the stripped data stream before adding their own source pad (the specified
-- callback can then call the upstream peer pad with offsets adjusted for the
-- tag size, for example).
-- 
-- When /@extension@/ is not 'P.Nothing', this function will first try the typefind
-- functions for the given extension, which might speed up the typefinding
-- in many cases.
-- 
-- /Since: 1.14.3/
typeFindHelperGetRangeFull ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a, Gst.Object.IsObject b) =>
    a
    -- ^ /@obj@/: A t'GI.Gst.Objects.Object.Object' that will be passed as first argument to /@func@/
    -> Maybe (b)
    -- ^ /@parent@/: the parent of /@obj@/ or 'P.Nothing'
    -> GstBase.Callbacks.TypeFindHelperGetRangeFunction
    -- ^ /@func@/: A generic t'GI.GstBase.Callbacks.TypeFindHelperGetRangeFunction' that will
    --        be used to access data at random offsets when doing the typefinding
    -> Word64
    -- ^ /@size@/: The length in bytes
    -> Maybe (T.Text)
    -- ^ /@extension@/: extension of the media, or 'P.Nothing'
    -> m ((Gst.Enums.FlowReturn, Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the last @/GstFlowReturn/@ from pulling a buffer or 'GI.Gst.Enums.FlowReturnOk' if
    --          typefinding was successful.
typeFindHelperGetRangeFull :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsObject a, IsObject b) =>
a
-> Maybe b
-> TypeFindHelperGetRangeFunction
-> Word64
-> Maybe Text
-> m (FlowReturn, Caps, TypeFindProbability)
typeFindHelperGetRangeFull a
obj Maybe b
parent TypeFindHelperGetRangeFunction
func Word64
size Maybe Text
extension = IO (FlowReturn, Caps, TypeFindProbability)
-> m (FlowReturn, Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (FlowReturn, Caps, TypeFindProbability)
 -> m (FlowReturn, Caps, TypeFindProbability))
-> IO (FlowReturn, Caps, TypeFindProbability)
-> m (FlowReturn, Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
obj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
obj
    Ptr Object
maybeParent <- case Maybe b
parent of
        Maybe b
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just b
jParent -> do
            Ptr Object
jParent' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jParent
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jParent'
    FunPtr C_TypeFindHelperGetRangeFunction
func' <- C_TypeFindHelperGetRangeFunction
-> IO (FunPtr C_TypeFindHelperGetRangeFunction)
GstBase.Callbacks.mk_TypeFindHelperGetRangeFunction (Maybe (Ptr (FunPtr C_TypeFindHelperGetRangeFunction))
-> TypeFindHelperGetRangeFunction
-> C_TypeFindHelperGetRangeFunction
GstBase.Callbacks.wrap_TypeFindHelperGetRangeFunction Maybe (Ptr (FunPtr C_TypeFindHelperGetRangeFunction))
forall a. Maybe a
Nothing TypeFindHelperGetRangeFunction
func)
    Ptr CChar
maybeExtension <- case Maybe Text
extension of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jExtension -> do
            Ptr CChar
jExtension' <- Text -> IO (Ptr CChar)
textToCString Text
jExtension
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jExtension'
    Ptr (Ptr Caps)
caps <- IO (Ptr (Ptr Caps))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr Gst.Caps.Caps))
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    CInt
result <- Ptr Object
-> Ptr Object
-> FunPtr C_TypeFindHelperGetRangeFunction
-> Word64
-> Ptr CChar
-> Ptr (Ptr Caps)
-> Ptr CUInt
-> IO CInt
gst_type_find_helper_get_range_full Ptr Object
obj' Ptr Object
maybeParent FunPtr C_TypeFindHelperGetRangeFunction
func' Word64
size Ptr CChar
maybeExtension Ptr (Ptr Caps)
caps Ptr CUInt
prob
    let result' :: FlowReturn
result' = (Int -> FlowReturn
forall a. Enum a => Int -> a
toEnum (Int -> FlowReturn) -> (CInt -> Int) -> CInt -> FlowReturn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Ptr Caps
caps' <- Ptr (Ptr Caps) -> IO (Ptr Caps)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Caps)
caps
    Caps
caps'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
caps'
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_TypeFindHelperGetRangeFunction -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TypeFindHelperGetRangeFunction
func'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
obj
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
parent b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeExtension
    Ptr (Ptr Caps) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Caps)
caps
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (FlowReturn, Caps, TypeFindProbability)
-> IO (FlowReturn, Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (FlowReturn
result', Caps
caps'', TypeFindProbability
prob'')


-- function type_find_helper_get_range
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "A #GstObject that will be passed as first argument to @func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "parent"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the parent of @obj or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "func"
--           , argType =
--               TInterface
--                 Name
--                   { namespace = "GstBase" , name = "TypeFindHelperGetRangeFunction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "A generic #GstTypeFindHelperGetRangeFunction that will\n       be used to access data at random offsets when doing the typefinding"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "size"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The length in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "extension of the media, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_get_range" gst_type_find_helper_get_range :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Gst.Object.Object ->                -- parent : TInterface (Name {namespace = "Gst", name = "Object"})
    FunPtr GstBase.Callbacks.C_TypeFindHelperGetRangeFunction -> -- func : TInterface (Name {namespace = "GstBase", name = "TypeFindHelperGetRangeFunction"})
    Word64 ->                               -- size : TBasicType TUInt64
    CString ->                              -- extension : TBasicType TUTF8
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO (Ptr Gst.Caps.Caps)

-- | Utility function to do pull-based typefinding. Unlike 'GI.GstBase.Functions.typeFindHelper'
-- however, this function will use the specified function /@func@/ to obtain the
-- data needed by the typefind functions, rather than operating on a given
-- source pad. This is useful mostly for elements like tag demuxers which
-- strip off data at the beginning and\/or end of a file and want to typefind
-- the stripped data stream before adding their own source pad (the specified
-- callback can then call the upstream peer pad with offsets adjusted for the
-- tag size, for example).
-- 
-- When /@extension@/ is not 'P.Nothing', this function will first try the typefind
-- functions for the given extension, which might speed up the typefinding
-- in many cases.
-- 
-- Free-function: gst_caps_unref
typeFindHelperGetRange ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a, Gst.Object.IsObject b) =>
    a
    -- ^ /@obj@/: A t'GI.Gst.Objects.Object.Object' that will be passed as first argument to /@func@/
    -> Maybe (b)
    -- ^ /@parent@/: the parent of /@obj@/ or 'P.Nothing'
    -> GstBase.Callbacks.TypeFindHelperGetRangeFunction
    -- ^ /@func@/: A generic t'GI.GstBase.Callbacks.TypeFindHelperGetRangeFunction' that will
    --        be used to access data at random offsets when doing the typefinding
    -> Word64
    -- ^ /@size@/: The length in bytes
    -> Maybe (T.Text)
    -- ^ /@extension@/: extension of the media, or 'P.Nothing'
    -> m ((Maybe Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data
    --     stream.  Returns 'P.Nothing' if no t'GI.Gst.Structs.Caps.Caps' matches the data stream.
typeFindHelperGetRange :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsObject a, IsObject b) =>
a
-> Maybe b
-> TypeFindHelperGetRangeFunction
-> Word64
-> Maybe Text
-> m (Maybe Caps, TypeFindProbability)
typeFindHelperGetRange a
obj Maybe b
parent TypeFindHelperGetRangeFunction
func Word64
size Maybe Text
extension = IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps, TypeFindProbability)
 -> m (Maybe Caps, TypeFindProbability))
-> IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
obj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
obj
    Ptr Object
maybeParent <- case Maybe b
parent of
        Maybe b
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just b
jParent -> do
            Ptr Object
jParent' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jParent
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jParent'
    FunPtr C_TypeFindHelperGetRangeFunction
func' <- C_TypeFindHelperGetRangeFunction
-> IO (FunPtr C_TypeFindHelperGetRangeFunction)
GstBase.Callbacks.mk_TypeFindHelperGetRangeFunction (Maybe (Ptr (FunPtr C_TypeFindHelperGetRangeFunction))
-> TypeFindHelperGetRangeFunction
-> C_TypeFindHelperGetRangeFunction
GstBase.Callbacks.wrap_TypeFindHelperGetRangeFunction Maybe (Ptr (FunPtr C_TypeFindHelperGetRangeFunction))
forall a. Maybe a
Nothing TypeFindHelperGetRangeFunction
func)
    Ptr CChar
maybeExtension <- case Maybe Text
extension of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jExtension -> do
            Ptr CChar
jExtension' <- Text -> IO (Ptr CChar)
textToCString Text
jExtension
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jExtension'
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Caps
result <- Ptr Object
-> Ptr Object
-> FunPtr C_TypeFindHelperGetRangeFunction
-> Word64
-> Ptr CChar
-> Ptr CUInt
-> IO (Ptr Caps)
gst_type_find_helper_get_range Ptr Object
obj' Ptr Object
maybeParent FunPtr C_TypeFindHelperGetRangeFunction
func' Word64
size Ptr CChar
maybeExtension Ptr CUInt
prob
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_TypeFindHelperGetRangeFunction -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TypeFindHelperGetRangeFunction
func'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
obj
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
parent b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeExtension
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (Maybe Caps, TypeFindProbability)
-> IO (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Caps
maybeResult, TypeFindProbability
prob'')


-- function type_find_helper_for_extension
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "object doing the typefinding, or %NULL (used for logging)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an extension" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_for_extension" gst_type_find_helper_for_extension :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    CString ->                              -- extension : TBasicType TUTF8
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find the best t'GI.Gst.Structs.Caps.Caps' associated with /@extension@/.
-- 
-- All available typefinders will be checked against the extension in order
-- of rank. The caps of the first typefinder that can handle /@extension@/ will be
-- returned.
-- 
-- Free-function: gst_caps_unref
typeFindHelperForExtension ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@obj@/: object doing the typefinding, or 'P.Nothing' (used for logging)
    -> T.Text
    -- ^ /@extension@/: an extension
    -> m (Maybe Gst.Caps.Caps)
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to
    --     /@extension@/, or 'P.Nothing' if no type could be found. The caller should free
    --     the caps returned with @/gst_caps_unref()/@.
typeFindHelperForExtension :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsObject a) =>
Maybe a -> Text -> m (Maybe Caps)
typeFindHelperForExtension Maybe a
obj Text
extension = IO (Maybe Caps) -> m (Maybe Caps)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps) -> m (Maybe Caps))
-> IO (Maybe Caps) -> m (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
maybeObj <- case Maybe a
obj of
        Maybe a
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just a
jObj -> do
            Ptr Object
jObj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObj
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jObj'
    Ptr CChar
extension' <- Text -> IO (Ptr CChar)
textToCString Text
extension
    Ptr Caps
result <- Ptr Object -> Ptr CChar -> IO (Ptr Caps)
gst_type_find_helper_for_extension Ptr Object
maybeObj Ptr CChar
extension'
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
obj a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
extension'
    Maybe Caps -> IO (Maybe Caps)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Caps
maybeResult


-- function type_find_helper_for_data_with_extension
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "object doing the typefinding, or %NULL (used for logging)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TCArray False (-1) 2 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "* a pointer with data to typefind"
--                 , 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 "the size of @data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "extension of the media, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "size"
--              , argType = TBasicType TUInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the size of @data" , sinceVersion = Nothing }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_for_data_with_extension" gst_type_find_helper_for_data_with_extension :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    CString ->                              -- extension : TBasicType TUTF8
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find what type of data is contained in the given /@data@/, the
-- assumption being that the data represents the beginning of the stream or
-- file.
-- 
-- All available typefinders will be called on the data in order of rank. If
-- a typefinding function returns a probability of 'GI.Gst.Enums.TypeFindProbabilityMaximum',
-- typefinding is stopped immediately and the found caps will be returned
-- right away. Otherwise, all available typefind functions will the tried,
-- and the caps with the highest probability will be returned, or 'P.Nothing' if
-- the content of /@data@/ could not be identified.
-- 
-- When /@extension@/ is not 'P.Nothing', this function will first try the typefind
-- functions for the given extension, which might speed up the typefinding
-- in many cases.
-- 
-- Free-function: gst_caps_unref
-- 
-- /Since: 1.16/
typeFindHelperForDataWithExtension ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@obj@/: object doing the typefinding, or 'P.Nothing' (used for logging)
    -> ByteString
    -- ^ /@data@/: * a pointer with data to typefind
    -> Maybe (T.Text)
    -- ^ /@extension@/: extension of the media, or 'P.Nothing'
    -> m ((Maybe Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data,
    --     or 'P.Nothing' if no type could be found. The caller should free the caps
    --     returned with @/gst_caps_unref()/@.
typeFindHelperForDataWithExtension :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsObject a) =>
Maybe a
-> ByteString -> Maybe Text -> m (Maybe Caps, TypeFindProbability)
typeFindHelperForDataWithExtension Maybe a
obj ByteString
data_ Maybe Text
extension = IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps, TypeFindProbability)
 -> m (Maybe Caps, TypeFindProbability))
-> IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    let size :: Word64
size = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
    Ptr Object
maybeObj <- case Maybe a
obj of
        Maybe a
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just a
jObj -> do
            Ptr Object
jObj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObj
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jObj'
    Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
    Ptr CChar
maybeExtension <- case Maybe Text
extension of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jExtension -> do
            Ptr CChar
jExtension' <- Text -> IO (Ptr CChar)
textToCString Text
jExtension
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jExtension'
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Caps
result <- Ptr Object
-> Ptr Word8 -> Word64 -> Ptr CChar -> Ptr CUInt -> IO (Ptr Caps)
gst_type_find_helper_for_data_with_extension Ptr Object
maybeObj Ptr Word8
data_' Word64
size Ptr CChar
maybeExtension Ptr CUInt
prob
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
obj a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeExtension
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (Maybe Caps, TypeFindProbability)
-> IO (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Caps
maybeResult, TypeFindProbability
prob'')


-- function type_find_helper_for_data
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "object doing the typefinding, or %NULL (used for logging)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TCArray False (-1) 2 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "* a pointer with data to typefind"
--                 , 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 "the size of @data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "size"
--              , argType = TBasicType TUInt64
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the size of @data" , sinceVersion = Nothing }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_for_data" gst_type_find_helper_for_data :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find what type of data is contained in the given /@data@/, the
-- assumption being that the data represents the beginning of the stream or
-- file.
-- 
-- All available typefinders will be called on the data in order of rank. If
-- a typefinding function returns a probability of 'GI.Gst.Enums.TypeFindProbabilityMaximum',
-- typefinding is stopped immediately and the found caps will be returned
-- right away. Otherwise, all available typefind functions will the tried,
-- and the caps with the highest probability will be returned, or 'P.Nothing' if
-- the content of /@data@/ could not be identified.
-- 
-- Free-function: gst_caps_unref
typeFindHelperForData ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@obj@/: object doing the typefinding, or 'P.Nothing' (used for logging)
    -> ByteString
    -- ^ /@data@/: * a pointer with data to typefind
    -> m ((Maybe Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data,
    --     or 'P.Nothing' if no type could be found. The caller should free the caps
    --     returned with @/gst_caps_unref()/@.
typeFindHelperForData :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsObject a) =>
Maybe a -> ByteString -> m (Maybe Caps, TypeFindProbability)
typeFindHelperForData Maybe a
obj ByteString
data_ = IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps, TypeFindProbability)
 -> m (Maybe Caps, TypeFindProbability))
-> IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    let size :: Word64
size = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
    Ptr Object
maybeObj <- case Maybe a
obj of
        Maybe a
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just a
jObj -> do
            Ptr Object
jObj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObj
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jObj'
    Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Caps
result <- Ptr Object -> Ptr Word8 -> Word64 -> Ptr CUInt -> IO (Ptr Caps)
gst_type_find_helper_for_data Ptr Object
maybeObj Ptr Word8
data_' Word64
size Ptr CUInt
prob
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
obj a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (Maybe Caps, TypeFindProbability)
-> IO (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Caps
maybeResult, TypeFindProbability
prob'')


-- function type_find_helper_for_buffer_with_extension
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "object doing the typefinding, or %NULL (used for logging)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "buf"
--           , argType = TInterface Name { namespace = "Gst" , name = "Buffer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstBuffer with data to typefind"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "extension"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "extension of the media, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_for_buffer_with_extension" gst_type_find_helper_for_buffer_with_extension :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Gst.Buffer.Buffer ->                -- buf : TInterface (Name {namespace = "Gst", name = "Buffer"})
    CString ->                              -- extension : TBasicType TUTF8
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find what type of data is contained in the given t'GI.Gst.Structs.Buffer.Buffer', the
-- assumption being that the buffer represents the beginning of the stream or
-- file.
-- 
-- All available typefinders will be called on the data in order of rank. If
-- a typefinding function returns a probability of 'GI.Gst.Enums.TypeFindProbabilityMaximum',
-- typefinding is stopped immediately and the found caps will be returned
-- right away. Otherwise, all available typefind functions will the tried,
-- and the caps with the highest probability will be returned, or 'P.Nothing' if
-- the content of the buffer could not be identified.
-- 
-- When /@extension@/ is not 'P.Nothing', this function will first try the typefind
-- functions for the given extension, which might speed up the typefinding
-- in many cases.
-- 
-- Free-function: gst_caps_unref
-- 
-- /Since: 1.16/
typeFindHelperForBufferWithExtension ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@obj@/: object doing the typefinding, or 'P.Nothing' (used for logging)
    -> Gst.Buffer.Buffer
    -- ^ /@buf@/: a t'GI.Gst.Structs.Buffer.Buffer' with data to typefind
    -> Maybe (T.Text)
    -- ^ /@extension@/: extension of the media, or 'P.Nothing'
    -> m ((Maybe Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data,
    --     or 'P.Nothing' if no type could be found. The caller should free the caps
    --     returned with @/gst_caps_unref()/@.
typeFindHelperForBufferWithExtension :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsObject a) =>
Maybe a
-> Buffer -> Maybe Text -> m (Maybe Caps, TypeFindProbability)
typeFindHelperForBufferWithExtension Maybe a
obj Buffer
buf Maybe Text
extension = IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps, TypeFindProbability)
 -> m (Maybe Caps, TypeFindProbability))
-> IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
maybeObj <- case Maybe a
obj of
        Maybe a
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just a
jObj -> do
            Ptr Object
jObj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObj
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jObj'
    Ptr Buffer
buf' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buf
    Ptr CChar
maybeExtension <- case Maybe Text
extension of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jExtension -> do
            Ptr CChar
jExtension' <- Text -> IO (Ptr CChar)
textToCString Text
jExtension
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jExtension'
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Caps
result <- Ptr Object -> Ptr Buffer -> Ptr CChar -> Ptr CUInt -> IO (Ptr Caps)
gst_type_find_helper_for_buffer_with_extension Ptr Object
maybeObj Ptr Buffer
buf' Ptr CChar
maybeExtension Ptr CUInt
prob
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
obj a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buf
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeExtension
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (Maybe Caps, TypeFindProbability)
-> IO (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Caps
maybeResult, TypeFindProbability
prob'')


-- function type_find_helper_for_buffer
-- Args: [ Arg
--           { argCName = "obj"
--           , argType = TInterface Name { namespace = "Gst" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "object doing the typefinding, or %NULL (used for logging)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "buf"
--           , argType = TInterface Name { namespace = "Gst" , name = "Buffer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstBuffer with data to typefind"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prob"
--           , argType =
--               TInterface
--                 Name { namespace = "Gst" , name = "TypeFindProbability" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to store the probability of the found\n    caps, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper_for_buffer" gst_type_find_helper_for_buffer :: 
    Ptr Gst.Object.Object ->                -- obj : TInterface (Name {namespace = "Gst", name = "Object"})
    Ptr Gst.Buffer.Buffer ->                -- buf : TInterface (Name {namespace = "Gst", name = "Buffer"})
    Ptr CUInt ->                            -- prob : TInterface (Name {namespace = "Gst", name = "TypeFindProbability"})
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find what type of data is contained in the given t'GI.Gst.Structs.Buffer.Buffer', the
-- assumption being that the buffer represents the beginning of the stream or
-- file.
-- 
-- All available typefinders will be called on the data in order of rank. If
-- a typefinding function returns a probability of 'GI.Gst.Enums.TypeFindProbabilityMaximum',
-- typefinding is stopped immediately and the found caps will be returned
-- right away. Otherwise, all available typefind functions will the tried,
-- and the caps with the highest probability will be returned, or 'P.Nothing' if
-- the content of the buffer could not be identified.
-- 
-- Free-function: gst_caps_unref
typeFindHelperForBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@obj@/: object doing the typefinding, or 'P.Nothing' (used for logging)
    -> Gst.Buffer.Buffer
    -- ^ /@buf@/: a t'GI.Gst.Structs.Buffer.Buffer' with data to typefind
    -> m ((Maybe Gst.Caps.Caps, Gst.Enums.TypeFindProbability))
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data,
    --     or 'P.Nothing' if no type could be found. The caller should free the caps
    --     returned with @/gst_caps_unref()/@.
typeFindHelperForBuffer :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsObject a) =>
Maybe a -> Buffer -> m (Maybe Caps, TypeFindProbability)
typeFindHelperForBuffer Maybe a
obj Buffer
buf = IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps, TypeFindProbability)
 -> m (Maybe Caps, TypeFindProbability))
-> IO (Maybe Caps, TypeFindProbability)
-> m (Maybe Caps, TypeFindProbability)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
maybeObj <- case Maybe a
obj of
        Maybe a
Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just a
jObj -> do
            Ptr Object
jObj' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObj
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jObj'
    Ptr Buffer
buf' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buf
    Ptr CUInt
prob <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Caps
result <- Ptr Object -> Ptr Buffer -> Ptr CUInt -> IO (Ptr Caps)
gst_type_find_helper_for_buffer Ptr Object
maybeObj Ptr Buffer
buf' Ptr CUInt
prob
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    CUInt
prob' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
prob
    let prob'' :: TypeFindProbability
prob'' = (Int -> TypeFindProbability
forall a. Enum a => Int -> a
toEnum (Int -> TypeFindProbability)
-> (CUInt -> Int) -> CUInt -> TypeFindProbability
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
prob'
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
obj a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buf
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
prob
    (Maybe Caps, TypeFindProbability)
-> IO (Maybe Caps, TypeFindProbability)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Caps
maybeResult, TypeFindProbability
prob'')


-- function type_find_helper
-- Args: [ Arg
--           { argCName = "src"
--           , argType = TInterface Name { namespace = "Gst" , name = "Pad" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A source #GstPad" , 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 "The length in bytes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Caps" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_type_find_helper" gst_type_find_helper :: 
    Ptr Gst.Pad.Pad ->                      -- src : TInterface (Name {namespace = "Gst", name = "Pad"})
    Word64 ->                               -- size : TBasicType TUInt64
    IO (Ptr Gst.Caps.Caps)

-- | Tries to find what type of data is flowing from the given source t'GI.Gst.Objects.Pad.Pad'.
-- 
-- Free-function: gst_caps_unref
typeFindHelper ::
    (B.CallStack.HasCallStack, MonadIO m, Gst.Pad.IsPad a) =>
    a
    -- ^ /@src@/: A source t'GI.Gst.Objects.Pad.Pad'
    -> Word64
    -- ^ /@size@/: The length in bytes
    -> m (Maybe Gst.Caps.Caps)
    -- ^ __Returns:__ the t'GI.Gst.Structs.Caps.Caps' corresponding to the data
    --     stream.  Returns 'P.Nothing' if no t'GI.Gst.Structs.Caps.Caps' matches the data stream.
typeFindHelper :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsPad a) =>
a -> Word64 -> m (Maybe Caps)
typeFindHelper a
src Word64
size = IO (Maybe Caps) -> m (Maybe Caps)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Caps) -> m (Maybe Caps))
-> IO (Maybe Caps) -> m (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Pad
src' <- a -> IO (Ptr Pad)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
src
    Ptr Caps
result <- Ptr Pad -> Word64 -> IO (Ptr Caps)
gst_type_find_helper Ptr Pad
src' Word64
size
    Maybe Caps
maybeResult <- Ptr Caps -> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Caps
result ((Ptr Caps -> IO Caps) -> IO (Maybe Caps))
-> (Ptr Caps -> IO Caps) -> IO (Maybe Caps)
forall a b. (a -> b) -> a -> b
$ \Ptr Caps
result' -> do
        Caps
result'' <- ((ManagedPtr Caps -> Caps) -> Ptr Caps -> IO Caps
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Caps -> Caps
Gst.Caps.Caps) Ptr Caps
result'
        Caps -> IO Caps
forall (m :: * -> *) a. Monad m => a -> m a
return Caps
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
src
    Maybe Caps -> IO (Maybe Caps)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Caps
maybeResult