packages feed

gi-gstbase-0.1.6.13: GI/GstBase/Structs/BaseParseFrame.hs


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

Frame (context) data passed to each frame parsing virtual methods.  In
addition to providing the data to be checked for a valid frame or an already
identified frame, it conveys additional metadata or control information
from and to the subclass w.r.t. the particular frame in question (rather
than global parameters).  Some of these may apply to each parsing stage, others
only to some a particular one.  These parameters are effectively zeroed at start
of each frame's processing, i.e. parsing virtual method invocation sequence.
-}

module GI.GstBase.Structs.BaseParseFrame
    ( 

-- * Exported types
    BaseParseFrame(..)                      ,
    newZeroBaseParseFrame                   ,
    noBaseParseFrame                        ,


 -- * Methods
-- ** baseParseFrameFree
    BaseParseFrameFreeMethodInfo            ,
    baseParseFrameFree                      ,


-- ** baseParseFrameInit
    BaseParseFrameInitMethodInfo            ,
    baseParseFrameInit                      ,


-- ** baseParseFrameNew
    baseParseFrameNew                       ,




 -- * Properties
-- ** Buffer
    baseParseFrameReadBuffer                ,


-- ** Flags
    baseParseFrameReadFlags                 ,


-- ** Offset
    baseParseFrameReadOffset                ,


-- ** OutBuffer
    baseParseFrameReadOutBuffer             ,


-- ** Overhead
    baseParseFrameReadOverhead              ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.GstBase.Types
import GI.GstBase.Callbacks
import qualified GI.Gst as Gst

newtype BaseParseFrame = BaseParseFrame (ForeignPtr BaseParseFrame)
foreign import ccall "gst_base_parse_frame_get_type" c_gst_base_parse_frame_get_type :: 
    IO GType

instance BoxedObject BaseParseFrame where
    boxedType _ = c_gst_base_parse_frame_get_type

-- | Construct a `BaseParseFrame` struct initialized to zero.
newZeroBaseParseFrame :: MonadIO m => m BaseParseFrame
newZeroBaseParseFrame = liftIO $ callocBoxedBytes 72 >>= wrapBoxed BaseParseFrame

noBaseParseFrame :: Maybe BaseParseFrame
noBaseParseFrame = Nothing

baseParseFrameReadBuffer :: BaseParseFrame -> IO Gst.Buffer
baseParseFrameReadBuffer s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr Gst.Buffer)
    val' <- (newBoxed Gst.Buffer) val
    return val'

baseParseFrameReadOutBuffer :: BaseParseFrame -> IO Gst.Buffer
baseParseFrameReadOutBuffer s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (Ptr Gst.Buffer)
    val' <- (newBoxed Gst.Buffer) val
    return val'

baseParseFrameReadFlags :: BaseParseFrame -> IO Word32
baseParseFrameReadFlags s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Word32
    return val

baseParseFrameReadOffset :: BaseParseFrame -> IO Word64
baseParseFrameReadOffset s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO Word64
    return val

baseParseFrameReadOverhead :: BaseParseFrame -> IO Int32
baseParseFrameReadOverhead s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO Int32
    return val

-- method BaseParseFrame::new
-- method type : Constructor
-- Args : [Arg {argCName = "buffer", argType = TInterface "Gst" "Buffer", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface "GstBase" "BaseParseFrameFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "overhead", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TInterface "GstBase" "BaseParseFrame"
-- throws : False
-- Skip return : False

foreign import ccall "gst_base_parse_frame_new" gst_base_parse_frame_new :: 
    Ptr Gst.Buffer ->                       -- buffer : TInterface "Gst" "Buffer"
    CUInt ->                                -- flags : TInterface "GstBase" "BaseParseFrameFlags"
    Int32 ->                                -- overhead : TBasicType TInt32
    IO (Ptr BaseParseFrame)


baseParseFrameNew ::
    (MonadIO m) =>
    Gst.Buffer                              -- buffer
    -> [BaseParseFrameFlags]                -- flags
    -> Int32                                -- overhead
    -> m BaseParseFrame                     -- result
baseParseFrameNew buffer flags overhead = liftIO $ do
    let buffer' = unsafeManagedPtrGetPtr buffer
    let flags' = gflagsToWord flags
    result <- gst_base_parse_frame_new buffer' flags' overhead
    checkUnexpectedReturnNULL "gst_base_parse_frame_new" result
    result' <- (wrapBoxed BaseParseFrame) result
    touchManagedPtr buffer
    return result'

-- method BaseParseFrame::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstBase" "BaseParseFrame", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gst_base_parse_frame_free" gst_base_parse_frame_free :: 
    Ptr BaseParseFrame ->                   -- _obj : TInterface "GstBase" "BaseParseFrame"
    IO ()


baseParseFrameFree ::
    (MonadIO m) =>
    BaseParseFrame                          -- _obj
    -> m ()                                 -- result
baseParseFrameFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gst_base_parse_frame_free _obj'
    touchManagedPtr _obj
    return ()

data BaseParseFrameFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo BaseParseFrameFreeMethodInfo BaseParseFrame signature where
    overloadedMethod _ = baseParseFrameFree

-- method BaseParseFrame::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstBase" "BaseParseFrame", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gst_base_parse_frame_init" gst_base_parse_frame_init :: 
    Ptr BaseParseFrame ->                   -- _obj : TInterface "GstBase" "BaseParseFrame"
    IO ()


baseParseFrameInit ::
    (MonadIO m) =>
    BaseParseFrame                          -- _obj
    -> m ()                                 -- result
baseParseFrameInit _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gst_base_parse_frame_init _obj'
    touchManagedPtr _obj
    return ()

data BaseParseFrameInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo BaseParseFrameInitMethodInfo BaseParseFrame signature where
    overloadedMethod _ = baseParseFrameInit

type family ResolveBaseParseFrameMethod (t :: Symbol) (o :: *) :: * where
    ResolveBaseParseFrameMethod "free" o = BaseParseFrameFreeMethodInfo
    ResolveBaseParseFrameMethod "init" o = BaseParseFrameInitMethodInfo
    ResolveBaseParseFrameMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveBaseParseFrameMethod t BaseParseFrame, MethodInfo info BaseParseFrame p) => IsLabelProxy t (BaseParseFrame -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBaseParseFrameMethod t BaseParseFrame, MethodInfo info BaseParseFrame p) => IsLabel t (BaseParseFrame -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif