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

/No description available in the introspection data./
-}

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

module GI.GstVideo.Structs.VideoConverter
    (

-- * Exported types
    VideoConverter(..)                      ,
    noVideoConverter                        ,


 -- * Methods
-- ** frame #method:frame#

#if ENABLE_OVERLOADING
    VideoConverterFrameMethodInfo           ,
#endif
    videoConverterFrame                     ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    VideoConverterFreeMethodInfo            ,
#endif
    videoConverterFree                      ,


-- ** getConfig #method:getConfig#

#if ENABLE_OVERLOADING
    VideoConverterGetConfigMethodInfo       ,
#endif
    videoConverterGetConfig                 ,


-- ** setConfig #method:setConfig#

#if ENABLE_OVERLOADING
    VideoConverterSetConfigMethodInfo       ,
#endif
    videoConverterSetConfig                 ,




    ) where

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

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

import qualified GI.Gst.Structs.Structure as Gst.Structure
import {-# SOURCE #-} qualified GI.GstVideo.Structs.VideoFrame as GstVideo.VideoFrame

-- | Memory-managed wrapper type.
newtype VideoConverter = VideoConverter (ManagedPtr VideoConverter)
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr VideoConverter where
    wrappedPtrCalloc = return nullPtr
    wrappedPtrCopy = return
    wrappedPtrFree = Nothing

-- | A convenience alias for `Nothing` :: `Maybe` `VideoConverter`.
noVideoConverter :: Maybe VideoConverter
noVideoConverter = Nothing


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

-- method VideoConverter::frame
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstVideo", name = "VideoConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoFrame", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "GstVideo", name = "VideoFrame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoFrame", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_converter_frame" gst_video_converter_frame ::
    Ptr VideoConverter ->                   -- convert : TInterface (Name {namespace = "GstVideo", name = "VideoConverter"})
    Ptr GstVideo.VideoFrame.VideoFrame ->   -- src : TInterface (Name {namespace = "GstVideo", name = "VideoFrame"})
    Ptr GstVideo.VideoFrame.VideoFrame ->   -- dest : TInterface (Name {namespace = "GstVideo", name = "VideoFrame"})
    IO ()

{- |
Convert the pixels of /@src@/ into /@dest@/ using /@convert@/.

/Since: 1.6/
-}
videoConverterFrame ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    VideoConverter
    {- ^ /@convert@/: a 'GI.GstVideo.Structs.VideoConverter.VideoConverter' -}
    -> GstVideo.VideoFrame.VideoFrame
    {- ^ /@src@/: a 'GI.GstVideo.Structs.VideoFrame.VideoFrame' -}
    -> GstVideo.VideoFrame.VideoFrame
    {- ^ /@dest@/: a 'GI.GstVideo.Structs.VideoFrame.VideoFrame' -}
    -> m ()
videoConverterFrame convert src dest = liftIO $ do
    convert' <- unsafeManagedPtrGetPtr convert
    src' <- unsafeManagedPtrGetPtr src
    dest' <- unsafeManagedPtrGetPtr dest
    gst_video_converter_frame convert' src' dest'
    touchManagedPtr convert
    touchManagedPtr src
    touchManagedPtr dest
    return ()

#if ENABLE_OVERLOADING
data VideoConverterFrameMethodInfo
instance (signature ~ (GstVideo.VideoFrame.VideoFrame -> GstVideo.VideoFrame.VideoFrame -> m ()), MonadIO m) => O.MethodInfo VideoConverterFrameMethodInfo VideoConverter signature where
    overloadedMethod _ = videoConverterFrame

#endif

-- method VideoConverter::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstVideo", name = "VideoConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_converter_free" gst_video_converter_free ::
    Ptr VideoConverter ->                   -- convert : TInterface (Name {namespace = "GstVideo", name = "VideoConverter"})
    IO ()

{- |
Free /@convert@/

/Since: 1.6/
-}
videoConverterFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    VideoConverter
    {- ^ /@convert@/: a 'GI.GstVideo.Structs.VideoConverter.VideoConverter' -}
    -> m ()
videoConverterFree convert = liftIO $ do
    convert' <- unsafeManagedPtrGetPtr convert
    gst_video_converter_free convert'
    touchManagedPtr convert
    return ()

#if ENABLE_OVERLOADING
data VideoConverterFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VideoConverterFreeMethodInfo VideoConverter signature where
    overloadedMethod _ = videoConverterFree

#endif

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

foreign import ccall "gst_video_converter_get_config" gst_video_converter_get_config ::
    Ptr VideoConverter ->                   -- convert : TInterface (Name {namespace = "GstVideo", name = "VideoConverter"})
    IO (Ptr Gst.Structure.Structure)

{- |
Get the current configuration of /@convert@/.
-}
videoConverterGetConfig ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    VideoConverter
    {- ^ /@convert@/: a 'GI.GstVideo.Structs.VideoConverter.VideoConverter' -}
    -> m Gst.Structure.Structure
    {- ^ __Returns:__ a 'GI.Gst.Structs.Structure.Structure' that remains valid for as long as /@convert@/ is valid
  or until 'GI.GstVideo.Structs.VideoConverter.videoConverterSetConfig' is called. -}
videoConverterGetConfig convert = liftIO $ do
    convert' <- unsafeManagedPtrGetPtr convert
    result <- gst_video_converter_get_config convert'
    checkUnexpectedReturnNULL "videoConverterGetConfig" result
    result' <- (newBoxed Gst.Structure.Structure) result
    touchManagedPtr convert
    return result'

#if ENABLE_OVERLOADING
data VideoConverterGetConfigMethodInfo
instance (signature ~ (m Gst.Structure.Structure), MonadIO m) => O.MethodInfo VideoConverterGetConfigMethodInfo VideoConverter signature where
    overloadedMethod _ = videoConverterGetConfig

#endif

-- method VideoConverter::set_config
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "convert", argType = TInterface (Name {namespace = "GstVideo", name = "VideoConverter"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstVideoConverter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "config", argType = TInterface (Name {namespace = "Gst", name = "Structure"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstStructure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_video_converter_set_config" gst_video_converter_set_config ::
    Ptr VideoConverter ->                   -- convert : TInterface (Name {namespace = "GstVideo", name = "VideoConverter"})
    Ptr Gst.Structure.Structure ->          -- config : TInterface (Name {namespace = "Gst", name = "Structure"})
    IO CInt

{- |
Set /@config@/ as extra configuraion for /@convert@/.

If the parameters in /@config@/ can not be set exactly, this function returns
'False' and will try to update as much state as possible. The new state can
then be retrieved and refined with 'GI.GstVideo.Structs.VideoConverter.videoConverterGetConfig'.

Look at the @/GST_VIDEO_CONVERTER_OPT_/@* fields to check valid configuration
option and values.

/Since: 1.6/
-}
videoConverterSetConfig ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    VideoConverter
    {- ^ /@convert@/: a 'GI.GstVideo.Structs.VideoConverter.VideoConverter' -}
    -> Gst.Structure.Structure
    {- ^ /@config@/: a 'GI.Gst.Structs.Structure.Structure' -}
    -> m Bool
    {- ^ __Returns:__ 'True' when /@config@/ could be set. -}
videoConverterSetConfig convert config = liftIO $ do
    convert' <- unsafeManagedPtrGetPtr convert
    config' <- B.ManagedPtr.disownBoxed config
    result <- gst_video_converter_set_config convert' config'
    let result' = (/= 0) result
    touchManagedPtr convert
    touchManagedPtr config
    return result'

#if ENABLE_OVERLOADING
data VideoConverterSetConfigMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m Bool), MonadIO m) => O.MethodInfo VideoConverterSetConfigMethodInfo VideoConverter signature where
    overloadedMethod _ = videoConverterSetConfig

#endif

#if ENABLE_OVERLOADING
type family ResolveVideoConverterMethod (t :: Symbol) (o :: *) :: * where
    ResolveVideoConverterMethod "frame" o = VideoConverterFrameMethodInfo
    ResolveVideoConverterMethod "free" o = VideoConverterFreeMethodInfo
    ResolveVideoConverterMethod "getConfig" o = VideoConverterGetConfigMethodInfo
    ResolveVideoConverterMethod "setConfig" o = VideoConverterSetConfigMethodInfo
    ResolveVideoConverterMethod l o = O.MethodResolutionFailed l o

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

#endif