packages feed

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

#GstVideoResampler is a structure which holds the information
required to perform various kinds of resampling filtering.
-}

module GI.GstVideo.Structs.VideoResampler
    ( 

-- * Exported types
    VideoResampler(..)                      ,
    newZeroVideoResampler                   ,
    noVideoResampler                        ,


 -- * Methods
-- ** videoResamplerClear
    VideoResamplerClearMethodInfo           ,
    videoResamplerClear                     ,


-- ** videoResamplerInit
    VideoResamplerInitMethodInfo            ,
    videoResamplerInit                      ,




 -- * Properties
-- ** InSize
    videoResamplerReadInSize                ,


-- ** MaxTaps
    videoResamplerReadMaxTaps               ,


-- ** NPhases
    videoResamplerReadNPhases               ,


-- ** NTaps
    videoResamplerReadNTaps                 ,


-- ** Offset
    videoResamplerReadOffset                ,


-- ** OutSize
    videoResamplerReadOutSize               ,


-- ** Phase
    videoResamplerReadPhase                 ,


-- ** Taps
    videoResamplerReadTaps                  ,




    ) 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 VideoResampler = VideoResampler (ForeignPtr VideoResampler)
-- | Construct a `VideoResampler` struct initialized to zero.
newZeroVideoResampler :: MonadIO m => m VideoResampler
newZeroVideoResampler = liftIO $ callocBytes 80 >>= wrapPtr VideoResampler

noVideoResampler :: Maybe VideoResampler
noVideoResampler = Nothing

videoResamplerReadInSize :: VideoResampler -> IO Int32
videoResamplerReadInSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

videoResamplerReadOutSize :: VideoResampler -> IO Int32
videoResamplerReadOutSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return val

videoResamplerReadMaxTaps :: VideoResampler -> IO Word32
videoResamplerReadMaxTaps s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

videoResamplerReadNPhases :: VideoResampler -> IO Word32
videoResamplerReadNPhases s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Word32
    return val

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

videoResamplerReadPhase :: VideoResampler -> IO Word32
videoResamplerReadPhase s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO Word32
    return val

videoResamplerReadNTaps :: VideoResampler -> IO Word32
videoResamplerReadNTaps s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO Word32
    return val

videoResamplerReadTaps :: VideoResampler -> IO Double
videoResamplerReadTaps s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO CDouble
    let val' = realToFrac val
    return val'

-- method VideoResampler::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoResampler", 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_resampler_clear" gst_video_resampler_clear :: 
    Ptr VideoResampler ->                   -- _obj : TInterface "GstVideo" "VideoResampler"
    IO ()


videoResamplerClear ::
    (MonadIO m) =>
    VideoResampler                          -- _obj
    -> m ()                                 -- result
videoResamplerClear _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    gst_video_resampler_clear _obj'
    touchManagedPtr _obj
    return ()

data VideoResamplerClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo VideoResamplerClearMethodInfo VideoResampler signature where
    overloadedMethod _ = videoResamplerClear

-- method VideoResampler::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GstVideo" "VideoResampler", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "method", argType = TInterface "GstVideo" "VideoResamplerMethod", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface "GstVideo" "VideoResamplerFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_phases", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_taps", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "shift", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in_size", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_size", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface "Gst" "Structure", 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_resampler_init" gst_video_resampler_init :: 
    Ptr VideoResampler ->                   -- _obj : TInterface "GstVideo" "VideoResampler"
    CUInt ->                                -- method : TInterface "GstVideo" "VideoResamplerMethod"
    CUInt ->                                -- flags : TInterface "GstVideo" "VideoResamplerFlags"
    Word32 ->                               -- n_phases : TBasicType TUInt32
    Word32 ->                               -- n_taps : TBasicType TUInt32
    CDouble ->                              -- shift : TBasicType TDouble
    Word32 ->                               -- in_size : TBasicType TUInt32
    Word32 ->                               -- out_size : TBasicType TUInt32
    Ptr Gst.Structure ->                    -- options : TInterface "Gst" "Structure"
    IO CInt


videoResamplerInit ::
    (MonadIO m) =>
    VideoResampler                          -- _obj
    -> VideoResamplerMethod                 -- method
    -> VideoResamplerFlags                  -- flags
    -> Word32                               -- nPhases
    -> Word32                               -- nTaps
    -> Double                               -- shift
    -> Word32                               -- inSize
    -> Word32                               -- outSize
    -> Gst.Structure                        -- options
    -> m Bool                               -- result
videoResamplerInit _obj method flags nPhases nTaps shift inSize outSize options = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let method' = (fromIntegral . fromEnum) method
    let flags' = (fromIntegral . fromEnum) flags
    let shift' = realToFrac shift
    let options' = unsafeManagedPtrGetPtr options
    result <- gst_video_resampler_init _obj' method' flags' nPhases nTaps shift' inSize outSize options'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr options
    return result'

data VideoResamplerInitMethodInfo
instance (signature ~ (VideoResamplerMethod -> VideoResamplerFlags -> Word32 -> Word32 -> Double -> Word32 -> Word32 -> Gst.Structure -> m Bool), MonadIO m) => MethodInfo VideoResamplerInitMethodInfo VideoResampler signature where
    overloadedMethod _ = videoResamplerInit

type family ResolveVideoResamplerMethod (t :: Symbol) (o :: *) :: * where
    ResolveVideoResamplerMethod "clear" o = VideoResamplerClearMethodInfo
    ResolveVideoResamplerMethod "init" o = VideoResamplerInitMethodInfo
    ResolveVideoResamplerMethod l o = MethodResolutionFailed l o

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

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