{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- This class is for elements that receive buffers in an undesired size.
-- While for example raw video contains one image per buffer, the same is not
-- true for a lot of other formats, especially those that come directly from
-- a file. So if you have undefined buffer sizes and require a specific size,
-- this object is for you.
-- 
-- An adapter is created with 'GI.GstBase.Objects.Adapter.adapterNew'. It can be freed again with
-- 'GI.GObject.Objects.Object.objectUnref'.
-- 
-- The theory of operation is like this: All buffers received are put
-- into the adapter using 'GI.GstBase.Objects.Adapter.adapterPush' and the data is then read back
-- in chunks of the desired size using 'GI.GstBase.Objects.Adapter.adapterMap'\/'GI.GstBase.Objects.Adapter.adapterUnmap'
-- and\/or @/gst_adapter_copy()/@. After the data has been processed, it is freed
-- using 'GI.GstBase.Objects.Adapter.adapterUnmap'.
-- 
-- Other methods such as 'GI.GstBase.Objects.Adapter.adapterTake' and 'GI.GstBase.Objects.Adapter.adapterTakeBuffer'
-- combine 'GI.GstBase.Objects.Adapter.adapterMap' and 'GI.GstBase.Objects.Adapter.adapterUnmap' in one method and are
-- potentially more convenient for some use cases.
-- 
-- For example, a sink pad\'s chain function that needs to pass data to a library
-- in 512-byte chunks could be implemented like this:
-- 
-- === /C code/
-- >
-- >static GstFlowReturn
-- >sink_pad_chain (GstPad *pad, GstObject *parent, GstBuffer *buffer)
-- >{
-- >  MyElement *this;
-- >  GstAdapter *adapter;
-- >  GstFlowReturn ret = GST_FLOW_OK;
-- >
-- >  this = MY_ELEMENT (parent);
-- >
-- >  adapter = this->adapter;
-- >
-- >  // put buffer into adapter
-- >  gst_adapter_push (adapter, buffer);
-- >
-- >  // while we can read out 512 bytes, process them
-- >  while (gst_adapter_available (adapter) >= 512 && ret == GST_FLOW_OK) {
-- >    const guint8 *data = gst_adapter_map (adapter, 512);
-- >    // use flowreturn as an error value
-- >    ret = my_library_foo (data);
-- >    gst_adapter_unmap (adapter);
-- >    gst_adapter_flush (adapter, 512);
-- >  }
-- >  return ret;
-- >}
-- 
-- 
-- For another example, a simple element inside GStreamer that uses t'GI.GstBase.Objects.Adapter.Adapter'
-- is the libvisual element.
-- 
-- An element using t'GI.GstBase.Objects.Adapter.Adapter' in its sink pad chain function should ensure that
-- when the FLUSH_STOP event is received, that any queued data is cleared using
-- 'GI.GstBase.Objects.Adapter.adapterClear'. Data should also be cleared or processed on EOS and
-- when changing state from 'GI.Gst.Enums.StatePaused' to 'GI.Gst.Enums.StateReady'.
-- 
-- Also check the GST_BUFFER_FLAG_DISCONT flag on the buffer. Some elements might
-- need to clear the adapter after a discontinuity.
-- 
-- The adapter will keep track of the timestamps of the buffers
-- that were pushed. The last seen timestamp before the current position
-- can be queried with 'GI.GstBase.Objects.Adapter.adapterPrevPts'. This function can
-- optionally return the number of bytes between the start of the buffer that
-- carried the timestamp and the current adapter position. The distance is
-- useful when dealing with, for example, raw audio samples because it allows
-- you to calculate the timestamp of the current adapter position by using the
-- last seen timestamp and the amount of bytes since.  Additionally, the
-- 'GI.GstBase.Objects.Adapter.adapterPrevPtsAtOffset' can be used to determine the last
-- seen timestamp at a particular offset in the adapter.
-- 
-- The adapter will also keep track of the offset of the buffers
-- (@/GST_BUFFER_OFFSET/@) that were pushed. The last seen offset before the
-- current position can be queried with 'GI.GstBase.Objects.Adapter.adapterPrevOffset'. This function
-- can optionally return the number of bytes between the start of the buffer
-- that carried the offset and the current adapter position.
-- 
-- Additionally the adapter also keeps track of the PTS, DTS and buffer offset
-- at the last discontinuity, which can be retrieved with
-- 'GI.GstBase.Objects.Adapter.adapterPtsAtDiscont', 'GI.GstBase.Objects.Adapter.adapterDtsAtDiscont' and
-- 'GI.GstBase.Objects.Adapter.adapterOffsetAtDiscont'. The number of bytes that were consumed
-- since then can be queried with 'GI.GstBase.Objects.Adapter.adapterDistanceFromDiscont'.
-- 
-- A last thing to note is that while t'GI.GstBase.Objects.Adapter.Adapter' is pretty optimized,
-- merging buffers still might be an operation that requires a @/malloc()/@ and
-- @/memcpy()/@ operation, and these operations are not the fastest. Because of
-- this, some functions like 'GI.GstBase.Objects.Adapter.adapterAvailableFast' are provided to help
-- speed up such cases should you want to. To avoid repeated memory allocations,
-- @/gst_adapter_copy()/@ can be used to copy data into a (statically allocated)
-- user provided buffer.
-- 
-- t'GI.GstBase.Objects.Adapter.Adapter' is not MT safe. All operations on an adapter must be serialized by
-- the caller. This is not normally a problem, however, as the normal use case
-- of t'GI.GstBase.Objects.Adapter.Adapter' is inside one pad\'s chain function, in which case access is
-- serialized via the pad\'s STREAM_LOCK.
-- 
-- Note that 'GI.GstBase.Objects.Adapter.adapterPush' takes ownership of the buffer passed. Use
-- @/gst_buffer_ref()/@ before pushing it into the adapter if you still want to
-- access the buffer later. The adapter will never modify the data in the
-- buffer pushed in it.

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

module GI.GstBase.Objects.Adapter
    ( 

-- * Exported types
    Adapter(..)                             ,
    IsAdapter                               ,
    toAdapter                               ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveAdapterMethod                    ,
#endif


-- ** available #method:available#

#if defined(ENABLE_OVERLOADING)
    AdapterAvailableMethodInfo              ,
#endif
    adapterAvailable                        ,


-- ** availableFast #method:availableFast#

#if defined(ENABLE_OVERLOADING)
    AdapterAvailableFastMethodInfo          ,
#endif
    adapterAvailableFast                    ,


-- ** clear #method:clear#

#if defined(ENABLE_OVERLOADING)
    AdapterClearMethodInfo                  ,
#endif
    adapterClear                            ,


-- ** copy #method:copy#

#if defined(ENABLE_OVERLOADING)
    AdapterCopyMethodInfo                   ,
#endif
    adapterCopy                             ,


-- ** distanceFromDiscont #method:distanceFromDiscont#

#if defined(ENABLE_OVERLOADING)
    AdapterDistanceFromDiscontMethodInfo    ,
#endif
    adapterDistanceFromDiscont              ,


-- ** dtsAtDiscont #method:dtsAtDiscont#

#if defined(ENABLE_OVERLOADING)
    AdapterDtsAtDiscontMethodInfo           ,
#endif
    adapterDtsAtDiscont                     ,


-- ** flush #method:flush#

#if defined(ENABLE_OVERLOADING)
    AdapterFlushMethodInfo                  ,
#endif
    adapterFlush                            ,


-- ** getBuffer #method:getBuffer#

#if defined(ENABLE_OVERLOADING)
    AdapterGetBufferMethodInfo              ,
#endif
    adapterGetBuffer                        ,


-- ** getBufferFast #method:getBufferFast#

#if defined(ENABLE_OVERLOADING)
    AdapterGetBufferFastMethodInfo          ,
#endif
    adapterGetBufferFast                    ,


-- ** getBufferList #method:getBufferList#

#if defined(ENABLE_OVERLOADING)
    AdapterGetBufferListMethodInfo          ,
#endif
    adapterGetBufferList                    ,


-- ** getList #method:getList#

#if defined(ENABLE_OVERLOADING)
    AdapterGetListMethodInfo                ,
#endif
    adapterGetList                          ,


-- ** map #method:map#

#if defined(ENABLE_OVERLOADING)
    AdapterMapMethodInfo                    ,
#endif
    adapterMap                              ,


-- ** maskedScanUint32 #method:maskedScanUint32#

#if defined(ENABLE_OVERLOADING)
    AdapterMaskedScanUint32MethodInfo       ,
#endif
    adapterMaskedScanUint32                 ,


-- ** maskedScanUint32Peek #method:maskedScanUint32Peek#

#if defined(ENABLE_OVERLOADING)
    AdapterMaskedScanUint32PeekMethodInfo   ,
#endif
    adapterMaskedScanUint32Peek             ,


-- ** new #method:new#

    adapterNew                              ,


-- ** offsetAtDiscont #method:offsetAtDiscont#

#if defined(ENABLE_OVERLOADING)
    AdapterOffsetAtDiscontMethodInfo        ,
#endif
    adapterOffsetAtDiscont                  ,


-- ** prevDts #method:prevDts#

#if defined(ENABLE_OVERLOADING)
    AdapterPrevDtsMethodInfo                ,
#endif
    adapterPrevDts                          ,


-- ** prevDtsAtOffset #method:prevDtsAtOffset#

#if defined(ENABLE_OVERLOADING)
    AdapterPrevDtsAtOffsetMethodInfo        ,
#endif
    adapterPrevDtsAtOffset                  ,


-- ** prevOffset #method:prevOffset#

#if defined(ENABLE_OVERLOADING)
    AdapterPrevOffsetMethodInfo             ,
#endif
    adapterPrevOffset                       ,


-- ** prevPts #method:prevPts#

#if defined(ENABLE_OVERLOADING)
    AdapterPrevPtsMethodInfo                ,
#endif
    adapterPrevPts                          ,


-- ** prevPtsAtOffset #method:prevPtsAtOffset#

#if defined(ENABLE_OVERLOADING)
    AdapterPrevPtsAtOffsetMethodInfo        ,
#endif
    adapterPrevPtsAtOffset                  ,


-- ** ptsAtDiscont #method:ptsAtDiscont#

#if defined(ENABLE_OVERLOADING)
    AdapterPtsAtDiscontMethodInfo           ,
#endif
    adapterPtsAtDiscont                     ,


-- ** push #method:push#

#if defined(ENABLE_OVERLOADING)
    AdapterPushMethodInfo                   ,
#endif
    adapterPush                             ,


-- ** take #method:take#

#if defined(ENABLE_OVERLOADING)
    AdapterTakeMethodInfo                   ,
#endif
    adapterTake                             ,


-- ** takeBuffer #method:takeBuffer#

#if defined(ENABLE_OVERLOADING)
    AdapterTakeBufferMethodInfo             ,
#endif
    adapterTakeBuffer                       ,


-- ** takeBufferFast #method:takeBufferFast#

#if defined(ENABLE_OVERLOADING)
    AdapterTakeBufferFastMethodInfo         ,
#endif
    adapterTakeBufferFast                   ,


-- ** takeBufferList #method:takeBufferList#

#if defined(ENABLE_OVERLOADING)
    AdapterTakeBufferListMethodInfo         ,
#endif
    adapterTakeBufferList                   ,


-- ** takeList #method:takeList#

#if defined(ENABLE_OVERLOADING)
    AdapterTakeListMethodInfo               ,
#endif
    adapterTakeList                         ,


-- ** unmap #method:unmap#

#if defined(ENABLE_OVERLOADING)
    AdapterUnmapMethodInfo                  ,
#endif
    adapterUnmap                            ,




    ) 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.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 GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import qualified GI.Gst.Structs.BufferList as Gst.BufferList

-- | Memory-managed wrapper type.
newtype Adapter = Adapter (SP.ManagedPtr Adapter)
    deriving (Adapter -> Adapter -> Bool
(Adapter -> Adapter -> Bool)
-> (Adapter -> Adapter -> Bool) -> Eq Adapter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Adapter -> Adapter -> Bool
$c/= :: Adapter -> Adapter -> Bool
== :: Adapter -> Adapter -> Bool
$c== :: Adapter -> Adapter -> Bool
Eq)

instance SP.ManagedPtrNewtype Adapter where
    toManagedPtr :: Adapter -> ManagedPtr Adapter
toManagedPtr (Adapter ManagedPtr Adapter
p) = ManagedPtr Adapter
p

foreign import ccall "gst_adapter_get_type"
    c_gst_adapter_get_type :: IO B.Types.GType

instance B.Types.TypedObject Adapter where
    glibType :: IO GType
glibType = IO GType
c_gst_adapter_get_type

instance B.Types.GObject Adapter

-- | Convert 'Adapter' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Adapter where
    toGValue :: Adapter -> IO GValue
toGValue Adapter
o = do
        GType
gtype <- IO GType
c_gst_adapter_get_type
        Adapter -> (Ptr Adapter -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Adapter
o (GType
-> (GValue -> Ptr Adapter -> IO ()) -> Ptr Adapter -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Adapter -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Adapter
fromGValue GValue
gv = do
        Ptr Adapter
ptr <- GValue -> IO (Ptr Adapter)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Adapter)
        (ManagedPtr Adapter -> Adapter) -> Ptr Adapter -> IO Adapter
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Adapter -> Adapter
Adapter Ptr Adapter
ptr
        
    

-- | Type class for types which can be safely cast to `Adapter`, for instance with `toAdapter`.
class (SP.GObject o, O.IsDescendantOf Adapter o) => IsAdapter o
instance (SP.GObject o, O.IsDescendantOf Adapter o) => IsAdapter o

instance O.HasParentTypes Adapter
type instance O.ParentTypes Adapter = '[GObject.Object.Object]

-- | Cast to `Adapter`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toAdapter :: (MonadIO m, IsAdapter o) => o -> m Adapter
toAdapter :: o -> m Adapter
toAdapter = IO Adapter -> m Adapter
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Adapter -> m Adapter) -> (o -> IO Adapter) -> o -> m Adapter
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Adapter -> Adapter) -> o -> IO Adapter
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Adapter -> Adapter
Adapter

#if defined(ENABLE_OVERLOADING)
type family ResolveAdapterMethod (t :: Symbol) (o :: *) :: * where
    ResolveAdapterMethod "available" o = AdapterAvailableMethodInfo
    ResolveAdapterMethod "availableFast" o = AdapterAvailableFastMethodInfo
    ResolveAdapterMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAdapterMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAdapterMethod "clear" o = AdapterClearMethodInfo
    ResolveAdapterMethod "copy" o = AdapterCopyMethodInfo
    ResolveAdapterMethod "distanceFromDiscont" o = AdapterDistanceFromDiscontMethodInfo
    ResolveAdapterMethod "dtsAtDiscont" o = AdapterDtsAtDiscontMethodInfo
    ResolveAdapterMethod "flush" o = AdapterFlushMethodInfo
    ResolveAdapterMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAdapterMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAdapterMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveAdapterMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAdapterMethod "map" o = AdapterMapMethodInfo
    ResolveAdapterMethod "maskedScanUint32" o = AdapterMaskedScanUint32MethodInfo
    ResolveAdapterMethod "maskedScanUint32Peek" o = AdapterMaskedScanUint32PeekMethodInfo
    ResolveAdapterMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAdapterMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAdapterMethod "offsetAtDiscont" o = AdapterOffsetAtDiscontMethodInfo
    ResolveAdapterMethod "prevDts" o = AdapterPrevDtsMethodInfo
    ResolveAdapterMethod "prevDtsAtOffset" o = AdapterPrevDtsAtOffsetMethodInfo
    ResolveAdapterMethod "prevOffset" o = AdapterPrevOffsetMethodInfo
    ResolveAdapterMethod "prevPts" o = AdapterPrevPtsMethodInfo
    ResolveAdapterMethod "prevPtsAtOffset" o = AdapterPrevPtsAtOffsetMethodInfo
    ResolveAdapterMethod "ptsAtDiscont" o = AdapterPtsAtDiscontMethodInfo
    ResolveAdapterMethod "push" o = AdapterPushMethodInfo
    ResolveAdapterMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAdapterMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAdapterMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAdapterMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAdapterMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAdapterMethod "take" o = AdapterTakeMethodInfo
    ResolveAdapterMethod "takeBuffer" o = AdapterTakeBufferMethodInfo
    ResolveAdapterMethod "takeBufferFast" o = AdapterTakeBufferFastMethodInfo
    ResolveAdapterMethod "takeBufferList" o = AdapterTakeBufferListMethodInfo
    ResolveAdapterMethod "takeList" o = AdapterTakeListMethodInfo
    ResolveAdapterMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAdapterMethod "unmap" o = AdapterUnmapMethodInfo
    ResolveAdapterMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAdapterMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAdapterMethod "getBuffer" o = AdapterGetBufferMethodInfo
    ResolveAdapterMethod "getBufferFast" o = AdapterGetBufferFastMethodInfo
    ResolveAdapterMethod "getBufferList" o = AdapterGetBufferListMethodInfo
    ResolveAdapterMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAdapterMethod "getList" o = AdapterGetListMethodInfo
    ResolveAdapterMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAdapterMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAdapterMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAdapterMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveAdapterMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAdapterMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Adapter = AdapterSignalList
type AdapterSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Adapter::new
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GstBase" , name = "Adapter" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_new" gst_adapter_new :: 
    IO (Ptr Adapter)

-- | Creates a new t'GI.GstBase.Objects.Adapter.Adapter'. Free with 'GI.GObject.Objects.Object.objectUnref'.
adapterNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Adapter
    -- ^ __Returns:__ a new t'GI.GstBase.Objects.Adapter.Adapter'
adapterNew :: m Adapter
adapterNew  = IO Adapter -> m Adapter
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Adapter -> m Adapter) -> IO Adapter -> m Adapter
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
result <- IO (Ptr Adapter)
gst_adapter_new
    Text -> Ptr Adapter -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"adapterNew" Ptr Adapter
result
    Adapter
result' <- ((ManagedPtr Adapter -> Adapter) -> Ptr Adapter -> IO Adapter
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Adapter -> Adapter
Adapter) Ptr Adapter
result
    Adapter -> IO Adapter
forall (m :: * -> *) a. Monad m => a -> m a
return Adapter
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Adapter::available
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_available" gst_adapter_available :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | Gets the maximum amount of bytes available, that is it returns the maximum
-- value that can be supplied to 'GI.GstBase.Objects.Adapter.adapterMap' without that function
-- returning 'P.Nothing'.
adapterAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m Word64
    -- ^ __Returns:__ number of bytes available in /@adapter@/
adapterAvailable :: a -> m Word64
adapterAvailable a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_available Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterAvailableMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterAvailableMethodInfo a signature where
    overloadedMethod = adapterAvailable

#endif

-- method Adapter::available_fast
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_available_fast" gst_adapter_available_fast :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | Gets the maximum number of bytes that are immediately available without
-- requiring any expensive operations (like copying the data into a
-- temporary buffer).
adapterAvailableFast ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m Word64
    -- ^ __Returns:__ number of bytes that are available in /@adapter@/ without expensive
    -- operations
adapterAvailableFast :: a -> m Word64
adapterAvailableFast a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_available_fast Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterAvailableFastMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterAvailableFastMethodInfo a signature where
    overloadedMethod = adapterAvailableFast

#endif

-- method Adapter::clear
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_clear" gst_adapter_clear :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO ()

-- | Removes all buffers from /@adapter@/.
adapterClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m ()
adapterClear :: a -> m ()
adapterClear a
adapter = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Adapter -> IO ()
gst_adapter_clear Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data AdapterClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsAdapter a) => O.MethodInfo AdapterClearMethodInfo a signature where
    overloadedMethod = adapterClear

#endif

-- method Adapter::copy
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "offset"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the bytes offset in the adapter to start from"
--                 , 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 number of bytes to copy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "Bytes" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_copy_bytes" gst_adapter_copy_bytes :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- offset : TBasicType TUInt64
    Word64 ->                               -- size : TBasicType TUInt64
    IO (Ptr GLib.Bytes.Bytes)

-- | Similar to gst_adapter_copy, but more suitable for language bindings. /@size@/
-- bytes of data starting at /@offset@/ will be copied out of the buffers contained
-- in /@adapter@/ and into a new t'GI.GLib.Structs.Bytes.Bytes' structure which is returned. Depending on
-- the value of the /@size@/ argument an empty t'GI.GLib.Structs.Bytes.Bytes' structure may be returned.
-- 
-- /Since: 1.4/
adapterCopy ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@offset@/: the bytes offset in the adapter to start from
    -> Word64
    -- ^ /@size@/: the number of bytes to copy
    -> m GLib.Bytes.Bytes
    -- ^ __Returns:__ A new t'GI.GLib.Structs.Bytes.Bytes' structure containing the copied data.
adapterCopy :: a -> Word64 -> Word64 -> m Bytes
adapterCopy a
adapter Word64
offset Word64
size = IO Bytes -> m Bytes
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bytes -> m Bytes) -> IO Bytes -> m Bytes
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Bytes
result <- Ptr Adapter -> Word64 -> Word64 -> IO (Ptr Bytes)
gst_adapter_copy_bytes Ptr Adapter
adapter' Word64
offset Word64
size
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"adapterCopy" Ptr Bytes
result
    Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'

#if defined(ENABLE_OVERLOADING)
data AdapterCopyMethodInfo
instance (signature ~ (Word64 -> Word64 -> m GLib.Bytes.Bytes), MonadIO m, IsAdapter a) => O.MethodInfo AdapterCopyMethodInfo a signature where
    overloadedMethod = adapterCopy

#endif

-- method Adapter::distance_from_discont
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_distance_from_discont" gst_adapter_distance_from_discont :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | /No description available in the introspection data./
adapterDistanceFromDiscont ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -> m Word64
adapterDistanceFromDiscont :: a -> m Word64
adapterDistanceFromDiscont a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_distance_from_discont Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterDistanceFromDiscontMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterDistanceFromDiscontMethodInfo a signature where
    overloadedMethod = adapterDistanceFromDiscont

#endif

-- method Adapter::dts_at_discont
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_dts_at_discont" gst_adapter_dts_at_discont :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | Get the DTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
-- flag, or GST_CLOCK_TIME_NONE.
-- 
-- /Since: 1.10/
adapterDtsAtDiscont ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m Word64
    -- ^ __Returns:__ The DTS at the last discont or GST_CLOCK_TIME_NONE.
adapterDtsAtDiscont :: a -> m Word64
adapterDtsAtDiscont a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_dts_at_discont Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterDtsAtDiscontMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterDtsAtDiscontMethodInfo a signature where
    overloadedMethod = adapterDtsAtDiscont

#endif

-- method Adapter::flush
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flush"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to flush"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_flush" gst_adapter_flush :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- flush : TBasicType TUInt64
    IO ()

-- | Flushes the first /@flush@/ bytes in the /@adapter@/. The caller must ensure that
-- at least this many bytes are available.
-- 
-- See also: 'GI.GstBase.Objects.Adapter.adapterMap', 'GI.GstBase.Objects.Adapter.adapterUnmap'
adapterFlush ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@flush@/: the number of bytes to flush
    -> m ()
adapterFlush :: a -> Word64 -> m ()
adapterFlush a
adapter Word64
flush = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Adapter -> Word64 -> IO ()
gst_adapter_flush Ptr Adapter
adapter' Word64
flush
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data AdapterFlushMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsAdapter a) => O.MethodInfo AdapterFlushMethodInfo a signature where
    overloadedMethod = adapterFlush

#endif

-- method Adapter::get_buffer
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to get"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Buffer" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_get_buffer" gst_adapter_get_buffer :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.Buffer.Buffer)

-- | Returns a t'GI.Gst.Structs.Buffer.Buffer' containing the first /@nbytes@/ of the /@adapter@/, but
-- does not flush them from the adapter. See 'GI.GstBase.Objects.Adapter.adapterTakeBuffer'
-- for details.
-- 
-- Caller owns a reference to the returned buffer. @/gst_buffer_unref()/@ after
-- usage.
-- 
-- Free-function: gst_buffer_unref
-- 
-- /Since: 1.6/
adapterGetBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to get
    -> m (Maybe Gst.Buffer.Buffer)
    -- ^ __Returns:__ a t'GI.Gst.Structs.Buffer.Buffer' containing the first
    --     /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not available.
    --     @/gst_buffer_unref()/@ when no longer needed.
adapterGetBuffer :: a -> Word64 -> m (Maybe Buffer)
adapterGetBuffer a
adapter Word64
nbytes = IO (Maybe Buffer) -> m (Maybe Buffer)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Buffer) -> m (Maybe Buffer))
-> IO (Maybe Buffer) -> m (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Buffer
result <- Ptr Adapter -> Word64 -> IO (Ptr Buffer)
gst_adapter_get_buffer Ptr Adapter
adapter' Word64
nbytes
    Maybe Buffer
maybeResult <- Ptr Buffer -> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Buffer
result ((Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer))
-> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
result' -> do
        Buffer
result'' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) Ptr Buffer
result'
        Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe Buffer -> IO (Maybe Buffer)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Buffer
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterGetBufferMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.Buffer.Buffer)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterGetBufferMethodInfo a signature where
    overloadedMethod = adapterGetBuffer

#endif

-- method Adapter::get_buffer_fast
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to get"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Buffer" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_get_buffer_fast" gst_adapter_get_buffer_fast :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.Buffer.Buffer)

-- | Returns a t'GI.Gst.Structs.Buffer.Buffer' containing the first /@nbytes@/ of the /@adapter@/, but
-- does not flush them from the adapter. See 'GI.GstBase.Objects.Adapter.adapterTakeBufferFast'
-- for details.
-- 
-- Caller owns a reference to the returned buffer. @/gst_buffer_unref()/@ after
-- usage.
-- 
-- Free-function: gst_buffer_unref
-- 
-- /Since: 1.6/
adapterGetBufferFast ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to get
    -> m (Maybe Gst.Buffer.Buffer)
    -- ^ __Returns:__ a t'GI.Gst.Structs.Buffer.Buffer' containing the first
    --     /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not available.
    --     @/gst_buffer_unref()/@ when no longer needed.
adapterGetBufferFast :: a -> Word64 -> m (Maybe Buffer)
adapterGetBufferFast a
adapter Word64
nbytes = IO (Maybe Buffer) -> m (Maybe Buffer)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Buffer) -> m (Maybe Buffer))
-> IO (Maybe Buffer) -> m (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Buffer
result <- Ptr Adapter -> Word64 -> IO (Ptr Buffer)
gst_adapter_get_buffer_fast Ptr Adapter
adapter' Word64
nbytes
    Maybe Buffer
maybeResult <- Ptr Buffer -> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Buffer
result ((Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer))
-> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
result' -> do
        Buffer
result'' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) Ptr Buffer
result'
        Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe Buffer -> IO (Maybe Buffer)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Buffer
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterGetBufferFastMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.Buffer.Buffer)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterGetBufferFastMethodInfo a signature where
    overloadedMethod = adapterGetBufferFast

#endif

-- method Adapter::get_buffer_list
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to get"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "BufferList" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_get_buffer_list" gst_adapter_get_buffer_list :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.BufferList.BufferList)

-- | Returns a t'GI.Gst.Structs.BufferList.BufferList' of buffers containing the first /@nbytes@/ bytes of
-- the /@adapter@/ but does not flush them from the adapter. See
-- 'GI.GstBase.Objects.Adapter.adapterTakeBufferList' for details.
-- 
-- Caller owns the returned list. Call @/gst_buffer_list_unref()/@ to free
-- the list after usage.
-- 
-- /Since: 1.6/
adapterGetBufferList ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to get
    -> m (Maybe Gst.BufferList.BufferList)
    -- ^ __Returns:__ a t'GI.Gst.Structs.BufferList.BufferList' of buffers containing
    --     the first /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not
    --     available
adapterGetBufferList :: a -> Word64 -> m (Maybe BufferList)
adapterGetBufferList a
adapter Word64
nbytes = IO (Maybe BufferList) -> m (Maybe BufferList)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe BufferList) -> m (Maybe BufferList))
-> IO (Maybe BufferList) -> m (Maybe BufferList)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr BufferList
result <- Ptr Adapter -> Word64 -> IO (Ptr BufferList)
gst_adapter_get_buffer_list Ptr Adapter
adapter' Word64
nbytes
    Maybe BufferList
maybeResult <- Ptr BufferList
-> (Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr BufferList
result ((Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList))
-> (Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList)
forall a b. (a -> b) -> a -> b
$ \Ptr BufferList
result' -> do
        BufferList
result'' <- ((ManagedPtr BufferList -> BufferList)
-> Ptr BufferList -> IO BufferList
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr BufferList -> BufferList
Gst.BufferList.BufferList) Ptr BufferList
result'
        BufferList -> IO BufferList
forall (m :: * -> *) a. Monad m => a -> m a
return BufferList
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe BufferList -> IO (Maybe BufferList)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe BufferList
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterGetBufferListMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.BufferList.BufferList)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterGetBufferListMethodInfo a signature where
    overloadedMethod = adapterGetBufferList

#endif

-- method Adapter::get_list
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to get"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList (TInterface Name { namespace = "Gst" , name = "Buffer" }))
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_get_list" gst_adapter_get_list :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr (GList (Ptr Gst.Buffer.Buffer)))

-- | Returns a t'GI.GLib.Structs.List.List' of buffers containing the first /@nbytes@/ bytes of the
-- /@adapter@/, but does not flush them from the adapter. See
-- 'GI.GstBase.Objects.Adapter.adapterTakeList' for details.
-- 
-- Caller owns returned list and contained buffers. @/gst_buffer_unref()/@ each
-- buffer in the list before freeing the list after usage.
-- 
-- /Since: 1.6/
adapterGetList ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to get
    -> m [Gst.Buffer.Buffer]
    -- ^ __Returns:__ a t'GI.GLib.Structs.List.List' of
    --     buffers containing the first /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/
    --     bytes are not available
adapterGetList :: a -> Word64 -> m [Buffer]
adapterGetList a
adapter Word64
nbytes = IO [Buffer] -> m [Buffer]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Buffer] -> m [Buffer]) -> IO [Buffer] -> m [Buffer]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr (GList (Ptr Buffer))
result <- Ptr Adapter -> Word64 -> IO (Ptr (GList (Ptr Buffer)))
gst_adapter_get_list Ptr Adapter
adapter' Word64
nbytes
    [Ptr Buffer]
result' <- Ptr (GList (Ptr Buffer)) -> IO [Ptr Buffer]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Buffer))
result
    [Buffer]
result'' <- (Ptr Buffer -> IO Buffer) -> [Ptr Buffer] -> IO [Buffer]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) [Ptr Buffer]
result'
    Ptr (GList (Ptr Buffer)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Buffer))
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    [Buffer] -> IO [Buffer]
forall (m :: * -> *) a. Monad m => a -> m a
return [Buffer]
result''

#if defined(ENABLE_OVERLOADING)
data AdapterGetListMethodInfo
instance (signature ~ (Word64 -> m [Gst.Buffer.Buffer]), MonadIO m, IsAdapter a) => O.MethodInfo AdapterGetListMethodInfo a signature where
    overloadedMethod = adapterGetList

#endif

-- method Adapter::map
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "size"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to map/peek"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "size"
--              , argType = TBasicType TUInt64
--              , direction = DirectionOut
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the number of bytes to map/peek"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Just (TCArray False (-1) 1 (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_map" gst_adapter_map :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Word64 ->                           -- size : TBasicType TUInt64
    IO (Ptr Word8)

-- | Gets the first /@size@/ bytes stored in the /@adapter@/. The returned pointer is
-- valid until the next function is called on the adapter.
-- 
-- Note that setting the returned pointer as the data of a t'GI.Gst.Structs.Buffer.Buffer' is
-- incorrect for general-purpose plugins. The reason is that if a downstream
-- element stores the buffer so that it has access to it outside of the bounds
-- of its chain function, the buffer will have an invalid data pointer after
-- your element flushes the bytes. In that case you should use
-- 'GI.GstBase.Objects.Adapter.adapterTake', which returns a freshly-allocated buffer that you can set
-- as t'GI.Gst.Structs.Buffer.Buffer' memory or the potentially more performant
-- 'GI.GstBase.Objects.Adapter.adapterTakeBuffer'.
-- 
-- Returns 'P.Nothing' if /@size@/ bytes are not available.
adapterMap ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m (Maybe ByteString)
    -- ^ __Returns:__ 
    --     a pointer to the first /@size@/ bytes of data, or 'P.Nothing'
adapterMap :: a -> m (Maybe ByteString)
adapterMap a
adapter = IO (Maybe ByteString) -> m (Maybe ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe ByteString) -> m (Maybe ByteString))
-> IO (Maybe ByteString) -> m (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
size <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Word8
result <- Ptr Adapter -> Ptr Word64 -> IO (Ptr Word8)
gst_adapter_map Ptr Adapter
adapter' Ptr Word64
size
    Word64
size' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
size
    Maybe ByteString
maybeResult <- Ptr Word8 -> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Word8
result ((Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString))
-> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
result' -> do
        ByteString
result'' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
size') Ptr Word8
result'
        ByteString -> IO ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
size
    Maybe ByteString -> IO (Maybe ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ByteString
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterMapMethodInfo
instance (signature ~ (m (Maybe ByteString)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterMapMethodInfo a signature where
    overloadedMethod = adapterMap

#endif

-- method Adapter::masked_scan_uint32
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "mask"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "mask to apply to data before matching against @pattern"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pattern to match (after mask is applied)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "offset"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "offset into the adapter data from which to start scanning, returns\n         the last scanned position."
--                 , 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 "number of bytes to scan from offset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_masked_scan_uint32" gst_adapter_masked_scan_uint32 :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word32 ->                               -- mask : TBasicType TUInt32
    Word32 ->                               -- pattern : TBasicType TUInt32
    Word64 ->                               -- offset : TBasicType TUInt64
    Word64 ->                               -- size : TBasicType TUInt64
    IO Int64

-- | Scan for pattern /@pattern@/ with applied mask /@mask@/ in the adapter data,
-- starting from offset /@offset@/.
-- 
-- The bytes in /@pattern@/ and /@mask@/ are interpreted left-to-right, regardless
-- of endianness.  All four bytes of the pattern must be present in the
-- adapter for it to match, even if the first or last bytes are masked out.
-- 
-- It is an error to call this function without making sure that there is
-- enough data (offset+size bytes) in the adapter.
-- 
-- This function calls 'GI.GstBase.Objects.Adapter.adapterMaskedScanUint32Peek' passing 'P.Nothing'
-- for value.
adapterMaskedScanUint32 ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word32
    -- ^ /@mask@/: mask to apply to data before matching against /@pattern@/
    -> Word32
    -- ^ /@pattern@/: pattern to match (after mask is applied)
    -> Word64
    -- ^ /@offset@/: offset into the adapter data from which to start scanning, returns
    --          the last scanned position.
    -> Word64
    -- ^ /@size@/: number of bytes to scan from offset
    -> m Int64
    -- ^ __Returns:__ offset of the first match, or -1 if no match was found.
    -- 
    -- Example:
    -- >
    -- >// Assume the adapter contains 0x00 0x01 0x02 ... 0xfe 0xff
    -- >
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x00010203, 0, 256);
    -- >// -> returns 0
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x00010203, 1, 255);
    -- >// -> returns -1
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffffffff, 0x01020304, 1, 255);
    -- >// -> returns 1
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffff, 0x0001, 0, 256);
    -- >// -> returns -1
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffff, 0x0203, 0, 256);
    -- >// -> returns 0
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffff0000, 0x02030000, 0, 256);
    -- >// -> returns 2
    -- >gst_adapter_masked_scan_uint32 (adapter, 0xffff0000, 0x02030000, 0, 4);
    -- >// -> returns -1
adapterMaskedScanUint32 :: a -> Word32 -> Word32 -> Word64 -> Word64 -> m Int64
adapterMaskedScanUint32 a
adapter Word32
mask Word32
pattern Word64
offset Word64
size = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Int64
result <- Ptr Adapter -> Word32 -> Word32 -> Word64 -> Word64 -> IO Int64
gst_adapter_masked_scan_uint32 Ptr Adapter
adapter' Word32
mask Word32
pattern Word64
offset Word64
size
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result

#if defined(ENABLE_OVERLOADING)
data AdapterMaskedScanUint32MethodInfo
instance (signature ~ (Word32 -> Word32 -> Word64 -> Word64 -> m Int64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterMaskedScanUint32MethodInfo a signature where
    overloadedMethod = adapterMaskedScanUint32

#endif

-- method Adapter::masked_scan_uint32_peek
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "mask"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "mask to apply to data before matching against @pattern"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pattern"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pattern to match (after mask is applied)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "offset"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "offset into the adapter data from which to start scanning, returns\n         the last scanned position."
--                 , 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 "number of bytes to scan from offset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUInt32
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to uint32 to return matching data"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_masked_scan_uint32_peek" gst_adapter_masked_scan_uint32_peek :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word32 ->                               -- mask : TBasicType TUInt32
    Word32 ->                               -- pattern : TBasicType TUInt32
    Word64 ->                               -- offset : TBasicType TUInt64
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Word32 ->                           -- value : TBasicType TUInt32
    IO Int64

-- | Scan for pattern /@pattern@/ with applied mask /@mask@/ in the adapter data,
-- starting from offset /@offset@/.  If a match is found, the value that matched
-- is returned through /@value@/, otherwise /@value@/ is left untouched.
-- 
-- The bytes in /@pattern@/ and /@mask@/ are interpreted left-to-right, regardless
-- of endianness.  All four bytes of the pattern must be present in the
-- adapter for it to match, even if the first or last bytes are masked out.
-- 
-- It is an error to call this function without making sure that there is
-- enough data (offset+size bytes) in the adapter.
adapterMaskedScanUint32Peek ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word32
    -- ^ /@mask@/: mask to apply to data before matching against /@pattern@/
    -> Word32
    -- ^ /@pattern@/: pattern to match (after mask is applied)
    -> Word64
    -- ^ /@offset@/: offset into the adapter data from which to start scanning, returns
    --          the last scanned position.
    -> Word64
    -- ^ /@size@/: number of bytes to scan from offset
    -> m ((Int64, Word32))
    -- ^ __Returns:__ offset of the first match, or -1 if no match was found.
adapterMaskedScanUint32Peek :: a -> Word32 -> Word32 -> Word64 -> Word64 -> m (Int64, Word32)
adapterMaskedScanUint32Peek a
adapter Word32
mask Word32
pattern Word64
offset Word64
size = IO (Int64, Word32) -> m (Int64, Word32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int64, Word32) -> m (Int64, Word32))
-> IO (Int64, Word32) -> m (Int64, Word32)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word32
value <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Int64
result <- Ptr Adapter
-> Word32 -> Word32 -> Word64 -> Word64 -> Ptr Word32 -> IO Int64
gst_adapter_masked_scan_uint32_peek Ptr Adapter
adapter' Word32
mask Word32
pattern Word64
offset Word64
size Ptr Word32
value
    Word32
value' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
value
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
value
    (Int64, Word32) -> IO (Int64, Word32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int64
result, Word32
value')

#if defined(ENABLE_OVERLOADING)
data AdapterMaskedScanUint32PeekMethodInfo
instance (signature ~ (Word32 -> Word32 -> Word64 -> Word64 -> m ((Int64, Word32))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterMaskedScanUint32PeekMethodInfo a signature where
    overloadedMethod = adapterMaskedScanUint32Peek

#endif

-- method Adapter::offset_at_discont
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_offset_at_discont" gst_adapter_offset_at_discont :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | Get the offset that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
-- flag, or GST_BUFFER_OFFSET_NONE.
-- 
-- /Since: 1.10/
adapterOffsetAtDiscont ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m Word64
    -- ^ __Returns:__ The offset at the last discont or GST_BUFFER_OFFSET_NONE.
adapterOffsetAtDiscont :: a -> m Word64
adapterOffsetAtDiscont a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_offset_at_discont Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterOffsetAtDiscontMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterOffsetAtDiscontMethodInfo a signature where
    overloadedMethod = adapterOffsetAtDiscont

#endif

-- method Adapter::prev_dts
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "distance"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to location for distance, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_prev_dts" gst_adapter_prev_dts :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Word64 ->                           -- distance : TBasicType TUInt64
    IO Word64

-- | Get the dts that was before the current byte in the adapter. When
-- /@distance@/ is given, the amount of bytes between the dts and the current
-- position is returned.
-- 
-- The dts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
-- the adapter is first created or when it is cleared. This also means that before
-- the first byte with a dts is removed from the adapter, the dts
-- and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
adapterPrevDts ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m ((Word64, Word64))
    -- ^ __Returns:__ The previously seen dts.
adapterPrevDts :: a -> m (Word64, Word64)
adapterPrevDts a
adapter = IO (Word64, Word64) -> m (Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64) -> m (Word64, Word64))
-> IO (Word64, Word64) -> m (Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
distance <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Word64
result <- Ptr Adapter -> Ptr Word64 -> IO Word64
gst_adapter_prev_dts Ptr Adapter
adapter' Ptr Word64
distance
    Word64
distance' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
distance
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
distance
    (Word64, Word64) -> IO (Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
result, Word64
distance')

#if defined(ENABLE_OVERLOADING)
data AdapterPrevDtsMethodInfo
instance (signature ~ (m ((Word64, Word64))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPrevDtsMethodInfo a signature where
    overloadedMethod = adapterPrevDts

#endif

-- method Adapter::prev_dts_at_offset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "offset"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the offset in the adapter at which to get timestamp"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "distance"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to location for distance, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_prev_dts_at_offset" gst_adapter_prev_dts_at_offset :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- offset : TBasicType TUInt64
    Ptr Word64 ->                           -- distance : TBasicType TUInt64
    IO Word64

-- | Get the dts that was before the byte at offset /@offset@/ in the adapter. When
-- /@distance@/ is given, the amount of bytes between the dts and the current
-- position is returned.
-- 
-- The dts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
-- the adapter is first created or when it is cleared. This also means that before
-- the first byte with a dts is removed from the adapter, the dts
-- and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
-- 
-- /Since: 1.2/
adapterPrevDtsAtOffset ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@offset@/: the offset in the adapter at which to get timestamp
    -> m ((Word64, Word64))
    -- ^ __Returns:__ The previously seen dts at given offset.
adapterPrevDtsAtOffset :: a -> Word64 -> m (Word64, Word64)
adapterPrevDtsAtOffset a
adapter Word64
offset = IO (Word64, Word64) -> m (Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64) -> m (Word64, Word64))
-> IO (Word64, Word64) -> m (Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
distance <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Word64
result <- Ptr Adapter -> Word64 -> Ptr Word64 -> IO Word64
gst_adapter_prev_dts_at_offset Ptr Adapter
adapter' Word64
offset Ptr Word64
distance
    Word64
distance' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
distance
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
distance
    (Word64, Word64) -> IO (Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
result, Word64
distance')

#if defined(ENABLE_OVERLOADING)
data AdapterPrevDtsAtOffsetMethodInfo
instance (signature ~ (Word64 -> m ((Word64, Word64))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPrevDtsAtOffsetMethodInfo a signature where
    overloadedMethod = adapterPrevDtsAtOffset

#endif

-- method Adapter::prev_offset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "distance"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to a location for distance, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_prev_offset" gst_adapter_prev_offset :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Word64 ->                           -- distance : TBasicType TUInt64
    IO Word64

-- | Get the offset that was before the current byte in the adapter. When
-- /@distance@/ is given, the amount of bytes between the offset and the current
-- position is returned.
-- 
-- The offset is reset to GST_BUFFER_OFFSET_NONE and the distance is set to 0
-- when the adapter is first created or when it is cleared. This also means that
-- before the first byte with an offset is removed from the adapter, the offset
-- and distance returned are GST_BUFFER_OFFSET_NONE and 0 respectively.
-- 
-- /Since: 1.10/
adapterPrevOffset ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m ((Word64, Word64))
    -- ^ __Returns:__ The previous seen offset.
adapterPrevOffset :: a -> m (Word64, Word64)
adapterPrevOffset a
adapter = IO (Word64, Word64) -> m (Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64) -> m (Word64, Word64))
-> IO (Word64, Word64) -> m (Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
distance <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Word64
result <- Ptr Adapter -> Ptr Word64 -> IO Word64
gst_adapter_prev_offset Ptr Adapter
adapter' Ptr Word64
distance
    Word64
distance' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
distance
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
distance
    (Word64, Word64) -> IO (Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
result, Word64
distance')

#if defined(ENABLE_OVERLOADING)
data AdapterPrevOffsetMethodInfo
instance (signature ~ (m ((Word64, Word64))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPrevOffsetMethodInfo a signature where
    overloadedMethod = adapterPrevOffset

#endif

-- method Adapter::prev_pts
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "distance"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to location for distance, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_prev_pts" gst_adapter_prev_pts :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Word64 ->                           -- distance : TBasicType TUInt64
    IO Word64

-- | Get the pts that was before the current byte in the adapter. When
-- /@distance@/ is given, the amount of bytes between the pts and the current
-- position is returned.
-- 
-- The pts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
-- the adapter is first created or when it is cleared. This also means that before
-- the first byte with a pts is removed from the adapter, the pts
-- and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
adapterPrevPts ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m ((Word64, Word64))
    -- ^ __Returns:__ The previously seen pts.
adapterPrevPts :: a -> m (Word64, Word64)
adapterPrevPts a
adapter = IO (Word64, Word64) -> m (Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64) -> m (Word64, Word64))
-> IO (Word64, Word64) -> m (Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
distance <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Word64
result <- Ptr Adapter -> Ptr Word64 -> IO Word64
gst_adapter_prev_pts Ptr Adapter
adapter' Ptr Word64
distance
    Word64
distance' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
distance
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
distance
    (Word64, Word64) -> IO (Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
result, Word64
distance')

#if defined(ENABLE_OVERLOADING)
data AdapterPrevPtsMethodInfo
instance (signature ~ (m ((Word64, Word64))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPrevPtsMethodInfo a signature where
    overloadedMethod = adapterPrevPts

#endif

-- method Adapter::prev_pts_at_offset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "offset"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the offset in the adapter at which to get timestamp"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "distance"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to location for distance, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_prev_pts_at_offset" gst_adapter_prev_pts_at_offset :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- offset : TBasicType TUInt64
    Ptr Word64 ->                           -- distance : TBasicType TUInt64
    IO Word64

-- | Get the pts that was before the byte at offset /@offset@/ in the adapter. When
-- /@distance@/ is given, the amount of bytes between the pts and the current
-- position is returned.
-- 
-- The pts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
-- the adapter is first created or when it is cleared. This also means that before
-- the first byte with a pts is removed from the adapter, the pts
-- and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
-- 
-- /Since: 1.2/
adapterPrevPtsAtOffset ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@offset@/: the offset in the adapter at which to get timestamp
    -> m ((Word64, Word64))
    -- ^ __Returns:__ The previously seen pts at given offset.
adapterPrevPtsAtOffset :: a -> Word64 -> m (Word64, Word64)
adapterPrevPtsAtOffset a
adapter Word64
offset = IO (Word64, Word64) -> m (Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64) -> m (Word64, Word64))
-> IO (Word64, Word64) -> m (Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
distance <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Word64
result <- Ptr Adapter -> Word64 -> Ptr Word64 -> IO Word64
gst_adapter_prev_pts_at_offset Ptr Adapter
adapter' Word64
offset Ptr Word64
distance
    Word64
distance' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
distance
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
distance
    (Word64, Word64) -> IO (Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
result, Word64
distance')

#if defined(ENABLE_OVERLOADING)
data AdapterPrevPtsAtOffsetMethodInfo
instance (signature ~ (Word64 -> m ((Word64, Word64))), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPrevPtsAtOffsetMethodInfo a signature where
    overloadedMethod = adapterPrevPtsAtOffset

#endif

-- method Adapter::pts_at_discont
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_pts_at_discont" gst_adapter_pts_at_discont :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO Word64

-- | Get the PTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
-- flag, or GST_CLOCK_TIME_NONE.
-- 
-- /Since: 1.10/
adapterPtsAtDiscont ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m Word64
    -- ^ __Returns:__ The PTS at the last discont or GST_CLOCK_TIME_NONE.
adapterPtsAtDiscont :: a -> m Word64
adapterPtsAtDiscont a
adapter = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Word64
result <- Ptr Adapter -> IO Word64
gst_adapter_pts_at_discont Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data AdapterPtsAtDiscontMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPtsAtDiscontMethodInfo a signature where
    overloadedMethod = adapterPtsAtDiscont

#endif

-- method Adapter::push
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , 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 to add to queue in the adapter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_push" gst_adapter_push :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Gst.Buffer.Buffer ->                -- buf : TInterface (Name {namespace = "Gst", name = "Buffer"})
    IO ()

-- | Adds the data from /@buf@/ to the data stored inside /@adapter@/ and takes
-- ownership of the buffer.
adapterPush ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Gst.Buffer.Buffer
    -- ^ /@buf@/: a t'GI.Gst.Structs.Buffer.Buffer' to add to queue in the adapter
    -> m ()
adapterPush :: a -> Buffer -> m ()
adapterPush a
adapter Buffer
buf = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Buffer
buf' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Buffer
buf
    Ptr Adapter -> Ptr Buffer -> IO ()
gst_adapter_push Ptr Adapter
adapter' Ptr Buffer
buf'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buf
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data AdapterPushMethodInfo
instance (signature ~ (Gst.Buffer.Buffer -> m ()), MonadIO m, IsAdapter a) => O.MethodInfo AdapterPushMethodInfo a signature where
    overloadedMethod = adapterPush

#endif

-- method Adapter::take
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to take"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "nbytes"
--              , argType = TBasicType TUInt64
--              , direction = DirectionOut
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the number of bytes to take"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Just (TCArray False (-1) 1 (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_take" gst_adapter_take :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Ptr Word64 ->                           -- nbytes : TBasicType TUInt64
    IO (Ptr Word8)

-- | Returns a freshly allocated buffer containing the first /@nbytes@/ bytes of the
-- /@adapter@/. The returned bytes will be flushed from the adapter.
-- 
-- Caller owns returned value. g_free after usage.
-- 
-- Free-function: g_free
adapterTake ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m (Maybe ByteString)
    -- ^ __Returns:__ 
    --     oven-fresh hot data, or 'P.Nothing' if /@nbytes@/ bytes are not available
adapterTake :: a -> m (Maybe ByteString)
adapterTake a
adapter = IO (Maybe ByteString) -> m (Maybe ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe ByteString) -> m (Maybe ByteString))
-> IO (Maybe ByteString) -> m (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Word64
nbytes <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Word8
result <- Ptr Adapter -> Ptr Word64 -> IO (Ptr Word8)
gst_adapter_take Ptr Adapter
adapter' Ptr Word64
nbytes
    Word64
nbytes' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
nbytes
    Maybe ByteString
maybeResult <- Ptr Word8 -> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Word8
result ((Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString))
-> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
result' -> do
        ByteString
result'' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
nbytes') Ptr Word8
result'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result'
        ByteString -> IO ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nbytes
    Maybe ByteString -> IO (Maybe ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ByteString
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterTakeMethodInfo
instance (signature ~ (m (Maybe ByteString)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterTakeMethodInfo a signature where
    overloadedMethod = adapterTake

#endif

-- method Adapter::take_buffer
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to take"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Buffer" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_take_buffer" gst_adapter_take_buffer :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.Buffer.Buffer)

-- | Returns a t'GI.Gst.Structs.Buffer.Buffer' containing the first /@nbytes@/ bytes of the
-- /@adapter@/. The returned bytes will be flushed from the adapter.
-- This function is potentially more performant than
-- 'GI.GstBase.Objects.Adapter.adapterTake' since it can reuse the memory in pushed buffers
-- by subbuffering or merging. This function will always return a
-- buffer with a single memory region.
-- 
-- Note that no assumptions should be made as to whether certain buffer
-- flags such as the DISCONT flag are set on the returned buffer, or not.
-- The caller needs to explicitly set or unset flags that should be set or
-- unset.
-- 
-- Since 1.6 this will also copy over all GstMeta of the input buffers except
-- for meta with the 'GI.Gst.Flags.MetaFlagsPooled' flag or with the \"memory\" tag.
-- 
-- Caller owns a reference to the returned buffer. @/gst_buffer_unref()/@ after
-- usage.
-- 
-- Free-function: gst_buffer_unref
adapterTakeBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to take
    -> m (Maybe Gst.Buffer.Buffer)
    -- ^ __Returns:__ a t'GI.Gst.Structs.Buffer.Buffer' containing the first
    --     /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not available.
    --     @/gst_buffer_unref()/@ when no longer needed.
adapterTakeBuffer :: a -> Word64 -> m (Maybe Buffer)
adapterTakeBuffer a
adapter Word64
nbytes = IO (Maybe Buffer) -> m (Maybe Buffer)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Buffer) -> m (Maybe Buffer))
-> IO (Maybe Buffer) -> m (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Buffer
result <- Ptr Adapter -> Word64 -> IO (Ptr Buffer)
gst_adapter_take_buffer Ptr Adapter
adapter' Word64
nbytes
    Maybe Buffer
maybeResult <- Ptr Buffer -> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Buffer
result ((Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer))
-> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
result' -> do
        Buffer
result'' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) Ptr Buffer
result'
        Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe Buffer -> IO (Maybe Buffer)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Buffer
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterTakeBufferMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.Buffer.Buffer)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterTakeBufferMethodInfo a signature where
    overloadedMethod = adapterTakeBuffer

#endif

-- method Adapter::take_buffer_fast
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to take"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "Buffer" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_take_buffer_fast" gst_adapter_take_buffer_fast :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.Buffer.Buffer)

-- | Returns a t'GI.Gst.Structs.Buffer.Buffer' containing the first /@nbytes@/ of the /@adapter@/.
-- The returned bytes will be flushed from the adapter.  This function
-- is potentially more performant than 'GI.GstBase.Objects.Adapter.adapterTakeBuffer' since
-- it can reuse the memory in pushed buffers by subbuffering or
-- merging. Unlike 'GI.GstBase.Objects.Adapter.adapterTakeBuffer', the returned buffer may
-- be composed of multiple non-contiguous t'GI.Gst.Structs.Memory.Memory' objects, no
-- copies are made.
-- 
-- Note that no assumptions should be made as to whether certain buffer
-- flags such as the DISCONT flag are set on the returned buffer, or not.
-- The caller needs to explicitly set or unset flags that should be set or
-- unset.
-- 
-- This will also copy over all GstMeta of the input buffers except
-- for meta with the 'GI.Gst.Flags.MetaFlagsPooled' flag or with the \"memory\" tag.
-- 
-- This function can return buffer up to the return value of
-- 'GI.GstBase.Objects.Adapter.adapterAvailable' without making copies if possible.
-- 
-- Caller owns a reference to the returned buffer. @/gst_buffer_unref()/@ after
-- usage.
-- 
-- Free-function: gst_buffer_unref
-- 
-- /Since: 1.2/
adapterTakeBufferFast ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to take
    -> m (Maybe Gst.Buffer.Buffer)
    -- ^ __Returns:__ a t'GI.Gst.Structs.Buffer.Buffer' containing the first
    --     /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not available.
    --     @/gst_buffer_unref()/@ when no longer needed.
adapterTakeBufferFast :: a -> Word64 -> m (Maybe Buffer)
adapterTakeBufferFast a
adapter Word64
nbytes = IO (Maybe Buffer) -> m (Maybe Buffer)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Buffer) -> m (Maybe Buffer))
-> IO (Maybe Buffer) -> m (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Buffer
result <- Ptr Adapter -> Word64 -> IO (Ptr Buffer)
gst_adapter_take_buffer_fast Ptr Adapter
adapter' Word64
nbytes
    Maybe Buffer
maybeResult <- Ptr Buffer -> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Buffer
result ((Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer))
-> (Ptr Buffer -> IO Buffer) -> IO (Maybe Buffer)
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
result' -> do
        Buffer
result'' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) Ptr Buffer
result'
        Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe Buffer -> IO (Maybe Buffer)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Buffer
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterTakeBufferFastMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.Buffer.Buffer)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterTakeBufferFastMethodInfo a signature where
    overloadedMethod = adapterTakeBufferFast

#endif

-- method Adapter::take_buffer_list
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to take"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gst" , name = "BufferList" })
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_take_buffer_list" gst_adapter_take_buffer_list :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr Gst.BufferList.BufferList)

-- | Returns a t'GI.Gst.Structs.BufferList.BufferList' of buffers containing the first /@nbytes@/ bytes of
-- the /@adapter@/. The returned bytes will be flushed from the adapter.
-- When the caller can deal with individual buffers, this function is more
-- performant because no memory should be copied.
-- 
-- Caller owns the returned list. Call @/gst_buffer_list_unref()/@ to free
-- the list after usage.
-- 
-- /Since: 1.6/
adapterTakeBufferList ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to take
    -> m (Maybe Gst.BufferList.BufferList)
    -- ^ __Returns:__ a t'GI.Gst.Structs.BufferList.BufferList' of buffers containing
    --     the first /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/ bytes are not
    --     available
adapterTakeBufferList :: a -> Word64 -> m (Maybe BufferList)
adapterTakeBufferList a
adapter Word64
nbytes = IO (Maybe BufferList) -> m (Maybe BufferList)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe BufferList) -> m (Maybe BufferList))
-> IO (Maybe BufferList) -> m (Maybe BufferList)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr BufferList
result <- Ptr Adapter -> Word64 -> IO (Ptr BufferList)
gst_adapter_take_buffer_list Ptr Adapter
adapter' Word64
nbytes
    Maybe BufferList
maybeResult <- Ptr BufferList
-> (Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr BufferList
result ((Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList))
-> (Ptr BufferList -> IO BufferList) -> IO (Maybe BufferList)
forall a b. (a -> b) -> a -> b
$ \Ptr BufferList
result' -> do
        BufferList
result'' <- ((ManagedPtr BufferList -> BufferList)
-> Ptr BufferList -> IO BufferList
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr BufferList -> BufferList
Gst.BufferList.BufferList) Ptr BufferList
result'
        BufferList -> IO BufferList
forall (m :: * -> *) a. Monad m => a -> m a
return BufferList
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    Maybe BufferList -> IO (Maybe BufferList)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe BufferList
maybeResult

#if defined(ENABLE_OVERLOADING)
data AdapterTakeBufferListMethodInfo
instance (signature ~ (Word64 -> m (Maybe Gst.BufferList.BufferList)), MonadIO m, IsAdapter a) => O.MethodInfo AdapterTakeBufferListMethodInfo a signature where
    overloadedMethod = adapterTakeBufferList

#endif

-- method Adapter::take_list
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nbytes"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the number of bytes to take"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList (TInterface Name { namespace = "Gst" , name = "Buffer" }))
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_take_list" gst_adapter_take_list :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    Word64 ->                               -- nbytes : TBasicType TUInt64
    IO (Ptr (GList (Ptr Gst.Buffer.Buffer)))

-- | Returns a t'GI.GLib.Structs.List.List' of buffers containing the first /@nbytes@/ bytes of the
-- /@adapter@/. The returned bytes will be flushed from the adapter.
-- When the caller can deal with individual buffers, this function is more
-- performant because no memory should be copied.
-- 
-- Caller owns returned list and contained buffers. @/gst_buffer_unref()/@ each
-- buffer in the list before freeing the list after usage.
adapterTakeList ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> Word64
    -- ^ /@nbytes@/: the number of bytes to take
    -> m [Gst.Buffer.Buffer]
    -- ^ __Returns:__ a t'GI.GLib.Structs.List.List' of
    --     buffers containing the first /@nbytes@/ of the adapter, or 'P.Nothing' if /@nbytes@/
    --     bytes are not available
adapterTakeList :: a -> Word64 -> m [Buffer]
adapterTakeList a
adapter Word64
nbytes = IO [Buffer] -> m [Buffer]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Buffer] -> m [Buffer]) -> IO [Buffer] -> m [Buffer]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr (GList (Ptr Buffer))
result <- Ptr Adapter -> Word64 -> IO (Ptr (GList (Ptr Buffer)))
gst_adapter_take_list Ptr Adapter
adapter' Word64
nbytes
    [Ptr Buffer]
result' <- Ptr (GList (Ptr Buffer)) -> IO [Ptr Buffer]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr Buffer))
result
    [Buffer]
result'' <- (Ptr Buffer -> IO Buffer) -> [Ptr Buffer] -> IO [Buffer]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Gst.Buffer.Buffer) [Ptr Buffer]
result'
    Ptr (GList (Ptr Buffer)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr Buffer))
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    [Buffer] -> IO [Buffer]
forall (m :: * -> *) a. Monad m => a -> m a
return [Buffer]
result''

#if defined(ENABLE_OVERLOADING)
data AdapterTakeListMethodInfo
instance (signature ~ (Word64 -> m [Gst.Buffer.Buffer]), MonadIO m, IsAdapter a) => O.MethodInfo AdapterTakeListMethodInfo a signature where
    overloadedMethod = adapterTakeList

#endif

-- method Adapter::unmap
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "adapter"
--           , argType =
--               TInterface Name { namespace = "GstBase" , name = "Adapter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GstAdapter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_adapter_unmap" gst_adapter_unmap :: 
    Ptr Adapter ->                          -- adapter : TInterface (Name {namespace = "GstBase", name = "Adapter"})
    IO ()

-- | Releases the memory obtained with the last 'GI.GstBase.Objects.Adapter.adapterMap'.
adapterUnmap ::
    (B.CallStack.HasCallStack, MonadIO m, IsAdapter a) =>
    a
    -- ^ /@adapter@/: a t'GI.GstBase.Objects.Adapter.Adapter'
    -> m ()
adapterUnmap :: a -> m ()
adapterUnmap a
adapter = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Adapter
adapter' <- a -> IO (Ptr Adapter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
adapter
    Ptr Adapter -> IO ()
gst_adapter_unmap Ptr Adapter
adapter'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
adapter
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data AdapterUnmapMethodInfo
instance (signature ~ (m ()), MonadIO m, IsAdapter a) => O.MethodInfo AdapterUnmapMethodInfo a signature where
    overloadedMethod = adapterUnmap

#endif