packages feed

gi-gstvideo-0.1.6.13: GI/GstVideo/Structs/VideoInfo.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)

Information describing image properties. This information can be filled
in from GstCaps with gst_video_info_from_caps(). The information is also used
to store the specific video info when mapping a video frame with
gst_video_frame_map().

Use the provided macros to access the info in this structure.
-}

module GI.GstVideo.Structs.VideoInfo
    ( 

-- * Exported types
    VideoInfo(..)                           ,
    newZeroVideoInfo                        ,
    noVideoInfo                             ,


 -- * Methods
-- ** videoInfoAlign
    VideoInfoAlignMethodInfo                ,
    videoInfoAlign                          ,


-- ** videoInfoConvert
    VideoInfoConvertMethodInfo              ,
    videoInfoConvert                        ,


-- ** videoInfoCopy
    VideoInfoCopyMethodInfo                 ,
    videoInfoCopy                           ,


-- ** videoInfoFree
    VideoInfoFreeMethodInfo                 ,
    videoInfoFree                           ,


-- ** videoInfoFromCaps
    VideoInfoFromCapsMethodInfo             ,
    videoInfoFromCaps                       ,


-- ** videoInfoInit
    VideoInfoInitMethodInfo                 ,
    videoInfoInit                           ,


-- ** videoInfoIsEqual
    VideoInfoIsEqualMethodInfo              ,
    videoInfoIsEqual                        ,


-- ** videoInfoNew
    videoInfoNew                            ,


-- ** videoInfoSetFormat
    VideoInfoSetFormatMethodInfo            ,
    videoInfoSetFormat                      ,


-- ** videoInfoToCaps
    VideoInfoToCapsMethodInfo               ,
    videoInfoToCaps                         ,




 -- * Properties
-- ** ChromaSite
    videoInfoReadChromaSite                 ,


-- ** Colorimetry
    videoInfoReadColorimetry                ,


-- ** Finfo
    videoInfoReadFinfo                      ,


-- ** Flags
    videoInfoReadFlags                      ,


-- ** FpsD
    videoInfoReadFpsD                       ,


-- ** FpsN
    videoInfoReadFpsN                       ,


-- ** Height
    videoInfoReadHeight                     ,


-- ** InterlaceMode
    videoInfoReadInterlaceMode              ,


-- ** ParD
    videoInfoReadParD                       ,


-- ** ParN
    videoInfoReadParN                       ,


-- ** Size
    videoInfoReadSize                       ,


-- ** Views
    videoInfoReadViews                      ,


-- ** Width
    videoInfoReadWidth                      ,




    ) 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.GstVideo.Types
import GI.GstVideo.Callbacks
import qualified GI.Gst as Gst

newtype VideoInfo = VideoInfo (ForeignPtr VideoInfo)
foreign import ccall "gst_video_info_get_type" c_gst_video_info_get_type :: 
    IO GType

instance BoxedObject VideoInfo where
    boxedType _ = c_gst_video_info_get_type

-- | Construct a `VideoInfo` struct initialized to zero.
newZeroVideoInfo :: MonadIO m => m VideoInfo
newZeroVideoInfo = liftIO $ callocBoxedBytes 120 >>= wrapBoxed VideoInfo

noVideoInfo :: Maybe VideoInfo
noVideoInfo = Nothing

videoInfoReadFinfo :: VideoInfo -> IO VideoFormatInfo
videoInfoReadFinfo s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr VideoFormatInfo)
    val' <- (newPtr 232 VideoFormatInfo) val
    return val'

videoInfoReadInterlaceMode :: VideoInfo -> IO VideoInterlaceMode
videoInfoReadInterlaceMode s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CUInt
    let val' = (toEnum . fromIntegral) val
    return val'

videoInfoReadFlags :: VideoInfo -> IO [VideoFlags]
videoInfoReadFlags s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO CUInt
    let val' = wordToGFlags val
    return val'

videoInfoReadWidth :: VideoInfo -> IO Int32
videoInfoReadWidth s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO Int32
    return val

videoInfoReadHeight :: VideoInfo -> IO Int32
videoInfoReadHeight s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 20) :: IO Int32
    return val

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

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

videoInfoReadChromaSite :: VideoInfo -> IO [VideoChromaSite]
videoInfoReadChromaSite s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 36) :: IO CUInt
    let val' = wordToGFlags val
    return val'

videoInfoReadColorimetry :: VideoInfo -> IO VideoColorimetry
videoInfoReadColorimetry s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO (Ptr VideoColorimetry)
    val' <- (newPtr 16 VideoColorimetry) val
    return val'

videoInfoReadParN :: VideoInfo -> IO Int32
videoInfoReadParN s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 56) :: IO Int32
    return val

videoInfoReadParD :: VideoInfo -> IO Int32
videoInfoReadParD s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 60) :: IO Int32
    return val

videoInfoReadFpsN :: VideoInfo -> IO Int32
videoInfoReadFpsN s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 64) :: IO Int32
    return val

videoInfoReadFpsD :: VideoInfo -> IO Int32
videoInfoReadFpsD s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 68) :: IO Int32
    return val

-- XXX Skipped getter for "VideoInfo:offset" :: Not implemented: "Don't know how to unpack C array of type TCArray False 4 (-1) (TBasicType TUInt64)"

-- XXX Skipped getter for "VideoInfo:stride" :: Not implemented: "Don't know how to unpack C array of type TCArray False 4 (-1) (TBasicType TInt32)"

-- method VideoInfo::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : TInterface "GstVideo" "VideoInfo"
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_info_new" gst_video_info_new :: 
    IO (Ptr VideoInfo)


videoInfoNew ::
    (MonadIO m) =>
    m VideoInfo                             -- result
videoInfoNew  = liftIO $ do
    result <- gst_video_info_new
    checkUnexpectedReturnNULL "gst_video_info_new" result
    result' <- (wrapBoxed VideoInfo) result
    return result'

-- method VideoInfo::align
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "align", argType = TInterface "GstVideo" "VideoAlignment", 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_video_info_align" gst_video_info_align :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    Ptr VideoAlignment ->                   -- align : TInterface "GstVideo" "VideoAlignment"
    IO ()


videoInfoAlign ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> VideoAlignment                       -- align
    -> m ()                                 -- result
videoInfoAlign _obj align = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let align' = unsafeManagedPtrGetPtr align
    gst_video_info_align _obj' align'
    touchManagedPtr _obj
    touchManagedPtr align
    return ()

data VideoInfoAlignMethodInfo
instance (signature ~ (VideoAlignment -> m ()), MonadIO m) => MethodInfo VideoInfoAlignMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoAlign

-- method VideoInfo::convert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_format", argType = TInterface "Gst" "Format", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_value", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_format", argType = TInterface "Gst" "Format", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_value", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_info_convert" gst_video_info_convert :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    CUInt ->                                -- src_format : TInterface "Gst" "Format"
    Int64 ->                                -- src_value : TBasicType TInt64
    CUInt ->                                -- dest_format : TInterface "Gst" "Format"
    Int64 ->                                -- dest_value : TBasicType TInt64
    IO CInt


videoInfoConvert ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> Gst.Format                           -- srcFormat
    -> Int64                                -- srcValue
    -> Gst.Format                           -- destFormat
    -> Int64                                -- destValue
    -> m Bool                               -- result
videoInfoConvert _obj srcFormat srcValue destFormat destValue = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let srcFormat' = (fromIntegral . fromEnum) srcFormat
    let destFormat' = (fromIntegral . fromEnum) destFormat
    result <- gst_video_info_convert _obj' srcFormat' srcValue destFormat' destValue
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

data VideoInfoConvertMethodInfo
instance (signature ~ (Gst.Format -> Int64 -> Gst.Format -> Int64 -> m Bool), MonadIO m) => MethodInfo VideoInfoConvertMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoConvert

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

foreign import ccall "gst_video_info_copy" gst_video_info_copy :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    IO (Ptr VideoInfo)


videoInfoCopy ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> m VideoInfo                          -- result
videoInfoCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- gst_video_info_copy _obj'
    checkUnexpectedReturnNULL "gst_video_info_copy" result
    result' <- (wrapBoxed VideoInfo) result
    touchManagedPtr _obj
    return result'

data VideoInfoCopyMethodInfo
instance (signature ~ (m VideoInfo), MonadIO m) => MethodInfo VideoInfoCopyMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoCopy

-- method VideoInfo::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", 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_video_info_free" gst_video_info_free :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    IO ()


videoInfoFree ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> m ()                                 -- result
videoInfoFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gst_video_info_free _obj'
    touchManagedPtr _obj
    return ()

data VideoInfoFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo VideoInfoFreeMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoFree

-- method VideoInfo::from_caps
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "caps", argType = TInterface "Gst" "Caps", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_info_from_caps" gst_video_info_from_caps :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    Ptr Gst.Caps ->                         -- caps : TInterface "Gst" "Caps"
    IO CInt


videoInfoFromCaps ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> Gst.Caps                             -- caps
    -> m Bool                               -- result
videoInfoFromCaps _obj caps = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let caps' = unsafeManagedPtrGetPtr caps
    result <- gst_video_info_from_caps _obj' caps'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr caps
    return result'

data VideoInfoFromCapsMethodInfo
instance (signature ~ (Gst.Caps -> m Bool), MonadIO m) => MethodInfo VideoInfoFromCapsMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoFromCaps

-- method VideoInfo::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", 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_video_info_init" gst_video_info_init :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    IO ()


videoInfoInit ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> m ()                                 -- result
videoInfoInit _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gst_video_info_init _obj'
    touchManagedPtr _obj
    return ()

data VideoInfoInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo VideoInfoInitMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoInit

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

foreign import ccall "gst_video_info_is_equal" gst_video_info_is_equal :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    Ptr VideoInfo ->                        -- other : TInterface "GstVideo" "VideoInfo"
    IO CInt


videoInfoIsEqual ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> VideoInfo                            -- other
    -> m Bool                               -- result
videoInfoIsEqual _obj other = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let other' = unsafeManagedPtrGetPtr other
    result <- gst_video_info_is_equal _obj' other'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr other
    return result'

data VideoInfoIsEqualMethodInfo
instance (signature ~ (VideoInfo -> m Bool), MonadIO m) => MethodInfo VideoInfoIsEqualMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoIsEqual

-- method VideoInfo::set_format
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface "GstVideo" "VideoFormat", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TUInt32, 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_video_info_set_format" gst_video_info_set_format :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    CUInt ->                                -- format : TInterface "GstVideo" "VideoFormat"
    Word32 ->                               -- width : TBasicType TUInt32
    Word32 ->                               -- height : TBasicType TUInt32
    IO ()


videoInfoSetFormat ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> VideoFormat                          -- format
    -> Word32                               -- width
    -> Word32                               -- height
    -> m ()                                 -- result
videoInfoSetFormat _obj format width height = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let format' = (fromIntegral . fromEnum) format
    gst_video_info_set_format _obj' format' width height
    touchManagedPtr _obj
    return ()

data VideoInfoSetFormatMethodInfo
instance (signature ~ (VideoFormat -> Word32 -> Word32 -> m ()), MonadIO m) => MethodInfo VideoInfoSetFormatMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoSetFormat

-- method VideoInfo::to_caps
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TInterface "Gst" "Caps"
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_info_to_caps" gst_video_info_to_caps :: 
    Ptr VideoInfo ->                        -- _obj : TInterface "GstVideo" "VideoInfo"
    IO (Ptr Gst.Caps)


videoInfoToCaps ::
    (MonadIO m) =>
    VideoInfo                               -- _obj
    -> m Gst.Caps                           -- result
videoInfoToCaps _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- gst_video_info_to_caps _obj'
    checkUnexpectedReturnNULL "gst_video_info_to_caps" result
    result' <- (wrapBoxed Gst.Caps) result
    touchManagedPtr _obj
    return result'

data VideoInfoToCapsMethodInfo
instance (signature ~ (m Gst.Caps), MonadIO m) => MethodInfo VideoInfoToCapsMethodInfo VideoInfo signature where
    overloadedMethod _ = videoInfoToCaps

type family ResolveVideoInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveVideoInfoMethod "align" o = VideoInfoAlignMethodInfo
    ResolveVideoInfoMethod "convert" o = VideoInfoConvertMethodInfo
    ResolveVideoInfoMethod "copy" o = VideoInfoCopyMethodInfo
    ResolveVideoInfoMethod "free" o = VideoInfoFreeMethodInfo
    ResolveVideoInfoMethod "fromCaps" o = VideoInfoFromCapsMethodInfo
    ResolveVideoInfoMethod "init" o = VideoInfoInitMethodInfo
    ResolveVideoInfoMethod "isEqual" o = VideoInfoIsEqualMethodInfo
    ResolveVideoInfoMethod "toCaps" o = VideoInfoToCapsMethodInfo
    ResolveVideoInfoMethod "setFormat" o = VideoInfoSetFormatMethodInfo
    ResolveVideoInfoMethod l o = MethodResolutionFailed l o

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

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