Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- addMeta
- addParentBufferMeta
- addProtectionMeta
- addReferenceTimestampMeta
- append
- appendMemory
- appendRegion
- copyDeep
- copyInto
- copyRegion
- extract
- extractDup
- fill
- findMemory
- foreachMeta
- getAllMemory
- getFlags
- getMaxMemory
- getMemory
- getMemoryRange
- getMeta
- getNMeta
- getReferenceTimestampMeta
- getSize
- getSizes
- getSizesRange
- hasFlags
- insertMemory
- isAllMemoryWritable
- isMemoryRangeWritable
- map
- mapRange
- memcmp
- memset
- nMemory
- new
- newAllocate
- newWrapped
- newWrappedBytes
- newWrappedFull
- peekMemory
- prependMemory
- removeAllMemory
- removeMemory
- removeMemoryRange
- removeMeta
- replaceAllMemory
- replaceMemory
- replaceMemoryRange
- resize
- resizeRange
- setFlags
- setSize
- unmap
- unsetFlags
- Properties
Buffers are the basic unit of data transfer in GStreamer. They contain the
timing and offset along with other arbitrary metadata that is associated
with the Memory
blocks that the buffer contains.
Buffers are usually created with bufferNew
. After a buffer has been
created one will typically allocate memory for it and add it to the buffer.
The following example creates a buffer that can hold a given video frame
with a given width, height and bits per plane.
C code
GstBuffer *buffer; GstMemory *memory; gint size, width, height, bpp; ... size = width * height * bpp; buffer = gst_buffer_new (); memory = gst_allocator_alloc (NULL, size, NULL); gst_buffer_insert_memory (buffer, -1, memory); ...
Alternatively, use bufferNewAllocate
to create a buffer with
preallocated data of a given size.
Buffers can contain a list of Memory
objects. You can retrieve how many
memory objects with bufferNMemory
and you can get a pointer
to memory with bufferPeekMemory
A buffer will usually have timestamps, and a duration, but neither of these
are guaranteed (they may be set to CLOCK_TIME_NONE
). Whenever a
meaningful value can be given for these, they should be set. The timestamps
and duration are measured in nanoseconds (they are GstClockTime
values).
The buffer DTS refers to the timestamp when the buffer should be decoded and is usually monotonically increasing. The buffer PTS refers to the timestamp when the buffer content should be presented to the user and is not always monotonically increasing.
A buffer can also have one or both of a start and an end offset. These are
media-type specific. For video buffers, the start offset will generally be
the frame number. For audio buffers, it will be the number of samples
produced so far. For compressed data, it could be the byte offset in a
source or destination file. Likewise, the end offset will be the offset of
the end of the buffer. These can only be meaningfully interpreted if you
know the media type of the buffer (the preceding CAPS event). Either or both
can be set to BUFFER_OFFSET_NONE
.
gst_buffer_ref()
is used to increase the refcount of a buffer. This must be
done when you want to keep a handle to the buffer after pushing it to the
next element. The buffer refcount determines the writability of the buffer, a
buffer is only writable when the refcount is exactly 1, i.e. when the caller
has the only reference to the buffer.
To efficiently create a smaller buffer out of an existing one, you can
use bufferCopyRegion
. This method tries to share the memory objects
between the two buffers.
If a plug-in wants to modify the buffer data or metadata in-place, it should
first obtain a buffer that is safe to modify by using
gst_buffer_make_writable()
. This function is optimized so that a copy will
only be made when it is necessary.
Several flags of the buffer can be set and unset with the
GST_BUFFER_FLAG_SET()
and GST_BUFFER_FLAG_UNSET()
macros. Use
GST_BUFFER_FLAG_IS_SET()
to test if a certain BufferFlags
flag is set.
Buffers can be efficiently merged into a larger buffer with
bufferAppend
. Copying of memory will only be done when absolutely
needed.
Arbitrary extra metadata can be set on a buffer with bufferAddMeta
.
Metadata can be retrieved with bufferGetMeta
. See also Meta
An element should either unref the buffer or push it out on a src pad
using padPush
(see Pad
).
Buffers are usually freed by unreffing them with gst_buffer_unref()
. When
the refcount drops to 0, any memory and metadata pointed to by the buffer is
unreffed as well. Buffers allocated from a BufferPool
will be returned to
the pool when the refcount drops to 0.
The ParentBufferMeta
is a meta which can be attached to a Buffer
to hold a reference to another buffer that is only released when the child
Buffer
is released.
Typically, ParentBufferMeta
is used when the child buffer is directly
using the Memory
of the parent buffer, and wants to prevent the parent
buffer from being returned to a buffer pool until the Memory
is available
for re-use. (Since 1.6)
Synopsis
- newtype Buffer = Buffer (ManagedPtr Buffer)
- newZeroBuffer :: MonadIO m => m Buffer
- noBuffer :: Maybe Buffer
- bufferAddMeta :: (HasCallStack, MonadIO m) => Buffer -> MetaInfo -> Ptr () -> m (Maybe Meta)
- bufferAddParentBufferMeta :: (HasCallStack, MonadIO m) => Buffer -> Buffer -> m (Maybe ParentBufferMeta)
- bufferAddProtectionMeta :: (HasCallStack, MonadIO m) => Buffer -> Structure -> m ProtectionMeta
- bufferAddReferenceTimestampMeta :: (HasCallStack, MonadIO m) => Buffer -> Caps -> Word64 -> Word64 -> m (Maybe ReferenceTimestampMeta)
- bufferAppend :: (HasCallStack, MonadIO m) => Buffer -> Buffer -> m Buffer
- bufferAppendMemory :: (HasCallStack, MonadIO m) => Buffer -> Memory -> m ()
- bufferAppendRegion :: (HasCallStack, MonadIO m) => Buffer -> Buffer -> Int64 -> Int64 -> m Buffer
- bufferCopyDeep :: (HasCallStack, MonadIO m) => Buffer -> m Buffer
- bufferCopyInto :: (HasCallStack, MonadIO m) => Buffer -> Buffer -> [BufferCopyFlags] -> Word64 -> Word64 -> m Bool
- bufferCopyRegion :: (HasCallStack, MonadIO m) => Buffer -> [BufferCopyFlags] -> Word64 -> Word64 -> m Buffer
- bufferExtract :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> Maybe ByteString -> m (Word64, Maybe ByteString)
- bufferExtractDup :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> Word64 -> m ByteString
- bufferFill :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> ByteString -> m Word64
- bufferFindMemory :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> Word64 -> m (Bool, Word32, Word32, Word64)
- bufferForeachMeta :: (HasCallStack, MonadIO m) => Buffer -> BufferForeachMetaFunc -> m Bool
- bufferGetAllMemory :: (HasCallStack, MonadIO m) => Buffer -> m (Maybe Memory)
- bufferGetFlags :: (HasCallStack, MonadIO m) => Buffer -> m [BufferFlags]
- bufferGetMaxMemory :: (HasCallStack, MonadIO m) => m Word32
- bufferGetMemory :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> m (Maybe Memory)
- bufferGetMemoryRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> m (Maybe Memory)
- bufferGetMeta :: (HasCallStack, MonadIO m) => Buffer -> GType -> m (Maybe Meta)
- bufferGetNMeta :: (HasCallStack, MonadIO m) => Buffer -> GType -> m Word32
- bufferGetReferenceTimestampMeta :: (HasCallStack, MonadIO m) => Buffer -> Maybe Caps -> m (Maybe ReferenceTimestampMeta)
- bufferGetSize :: (HasCallStack, MonadIO m) => Buffer -> m Word64
- bufferGetSizes :: (HasCallStack, MonadIO m) => Buffer -> m (Word64, Word64, Word64)
- bufferGetSizesRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> m (Word64, Word64, Word64)
- bufferHasFlags :: (HasCallStack, MonadIO m) => Buffer -> [BufferFlags] -> m Bool
- bufferInsertMemory :: (HasCallStack, MonadIO m) => Buffer -> Int32 -> Memory -> m ()
- bufferIsAllMemoryWritable :: (HasCallStack, MonadIO m) => Buffer -> m Bool
- bufferIsMemoryRangeWritable :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> m Bool
- bufferMap :: (HasCallStack, MonadIO m) => Buffer -> [MapFlags] -> m (Bool, MapInfo)
- bufferMapRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> [MapFlags] -> m (Bool, MapInfo)
- bufferMemcmp :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> ByteString -> m Int32
- bufferMemset :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> Word8 -> Word64 -> m Word64
- bufferNMemory :: (HasCallStack, MonadIO m) => Buffer -> m Word32
- bufferNew :: (HasCallStack, MonadIO m) => m Buffer
- bufferNewAllocate :: (HasCallStack, MonadIO m, IsAllocator a) => Maybe a -> Word64 -> Maybe AllocationParams -> m (Maybe Buffer)
- bufferNewWrapped :: (HasCallStack, MonadIO m) => ByteString -> m Buffer
- bufferNewWrappedBytes :: (HasCallStack, MonadIO m) => Bytes -> m Buffer
- bufferNewWrappedFull :: (HasCallStack, MonadIO m) => [MemoryFlags] -> ByteString -> Word64 -> Word64 -> Maybe DestroyNotify -> m Buffer
- bufferPeekMemory :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> m (Maybe Memory)
- bufferPrependMemory :: (HasCallStack, MonadIO m) => Buffer -> Memory -> m ()
- bufferRemoveAllMemory :: (HasCallStack, MonadIO m) => Buffer -> m ()
- bufferRemoveMemory :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> m ()
- bufferRemoveMemoryRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> m ()
- bufferRemoveMeta :: (HasCallStack, MonadIO m) => Buffer -> Meta -> m Bool
- bufferReplaceAllMemory :: (HasCallStack, MonadIO m) => Buffer -> Memory -> m ()
- bufferReplaceMemory :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Memory -> m ()
- bufferReplaceMemoryRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> Memory -> m ()
- bufferResize :: (HasCallStack, MonadIO m) => Buffer -> Int64 -> Int64 -> m ()
- bufferResizeRange :: (HasCallStack, MonadIO m) => Buffer -> Word32 -> Int32 -> Int64 -> Int64 -> m Bool
- bufferSetFlags :: (HasCallStack, MonadIO m) => Buffer -> [BufferFlags] -> m Bool
- bufferSetSize :: (HasCallStack, MonadIO m) => Buffer -> Int64 -> m ()
- bufferUnmap :: (HasCallStack, MonadIO m) => Buffer -> MapInfo -> m ()
- bufferUnsetFlags :: (HasCallStack, MonadIO m) => Buffer -> [BufferFlags] -> m Bool
- getBufferDts :: MonadIO m => Buffer -> m Word64
- setBufferDts :: MonadIO m => Buffer -> Word64 -> m ()
- getBufferDuration :: MonadIO m => Buffer -> m Word64
- setBufferDuration :: MonadIO m => Buffer -> Word64 -> m ()
- getBufferMiniObject :: MonadIO m => Buffer -> m MiniObject
- getBufferOffset :: MonadIO m => Buffer -> m Word64
- setBufferOffset :: MonadIO m => Buffer -> Word64 -> m ()
- getBufferOffsetEnd :: MonadIO m => Buffer -> m Word64
- setBufferOffsetEnd :: MonadIO m => Buffer -> Word64 -> m ()
- clearBufferPool :: MonadIO m => Buffer -> m ()
- getBufferPool :: MonadIO m => Buffer -> m (Maybe BufferPool)
- setBufferPool :: MonadIO m => Buffer -> Ptr BufferPool -> m ()
- getBufferPts :: MonadIO m => Buffer -> m Word64
- setBufferPts :: MonadIO m => Buffer -> Word64 -> m ()
Exported types
Memory-managed wrapper type.
Methods
addMeta
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> MetaInfo |
|
-> Ptr () |
|
-> m (Maybe Meta) | Returns: the metadata for the api in |
Add metadata for info
to buffer
using the parameters in params
.
addParentBufferMeta
bufferAddParentBufferMeta Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Buffer |
|
-> m (Maybe ParentBufferMeta) | Returns: The |
Add a ParentBufferMeta
to buffer
that holds a reference on
ref
until the buffer is freed.
Since: 1.6
addProtectionMeta
bufferAddProtectionMeta Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Structure |
|
-> m ProtectionMeta | Returns: a pointer to the added |
Attaches protection metadata to a Buffer
.
Since: 1.6
addReferenceTimestampMeta
bufferAddReferenceTimestampMeta Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Caps |
|
-> Word64 |
|
-> Word64 |
|
-> m (Maybe ReferenceTimestampMeta) | Returns: The |
Add a ReferenceTimestampMeta
to buffer
that holds a timestamp
and
optionally duration
based on a specific timestamp reference
. See the
documentation of ReferenceTimestampMeta
for details.
Since: 1.14
append
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Buffer |
|
-> m Buffer | Returns: the new |
Append all the memory from buf2
to buf1
. The result buffer will contain a
concatenation of the memory of buf1
and buf2
.
appendMemory
Append the memory block mem
to buffer
. This function takes
ownership of mem
and thus doesn't increase its refcount.
This function is identical to bufferInsertMemory
with an index of -1.
See bufferInsertMemory
for more details.
appendRegion
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Buffer |
|
-> Int64 |
|
-> Int64 |
|
-> m Buffer | Returns: the new |
Append size
bytes at offset
from buf2
to buf1
. The result buffer will
contain a concatenation of the memory of buf1
and the requested region of
buf2
.
copyDeep
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m Buffer | Returns: a new copy of |
Create a copy of the given buffer. This will make a newly allocated copy of the data the source buffer contains.
Since: 1.6
copyInto
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Buffer |
|
-> [BufferCopyFlags] |
|
-> Word64 |
|
-> Word64 |
|
-> m Bool |
Copies the information from src
into dest
.
If dest
already contains memory and flags
contains GST_BUFFER_COPY_MEMORY,
the memory from src
will be appended to dest
.
flags
indicate which fields will be copied.
copyRegion
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> [BufferCopyFlags] |
|
-> Word64 |
|
-> Word64 |
|
-> m Buffer | Returns: the new |
Creates a sub-buffer from parent
at offset
and size
.
This sub-buffer uses the actual memory space of the parent buffer.
This function will copy the offset and timestamp fields when the
offset is 0. If not, they will be set to CLOCK_TIME_NONE
and
BUFFER_OFFSET_NONE
.
If offset
equals 0 and size
equals the total size of buffer
, the
duration and offset end fields are also copied. If not they will be set
to CLOCK_TIME_NONE
and BUFFER_OFFSET_NONE
.
MT safe.
extract
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> Maybe ByteString |
|
-> m (Word64, Maybe ByteString) | Returns: The amount of bytes extracted. This value can be lower than |
Copy size
bytes starting from offset
in buffer
to dest
.
extractDup
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> Word64 |
|
-> m ByteString |
Extracts a copy of at most size
bytes the data at offset
into
newly-allocated memory. dest
must be freed using free
when done.
Since: 1.0.10
fill
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> ByteString |
|
-> m Word64 | Returns: The amount of bytes copied. This value can be lower than |
Copy size
bytes from src
to buffer
at offset
.
findMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> Word64 |
|
-> m (Bool, Word32, Word32, Word64) | Returns: |
Find the memory blocks that span size
bytes starting from offset
in buffer
.
When this function returns True
, idx
will contain the index of the first
memory block where the byte for offset
can be found and length
contains the
number of memory blocks containing the size
remaining bytes. skip
contains
the number of bytes to skip in the memory block at idx
to get to the byte
for offset
.
size
can be -1 to get all the memory blocks after idx
.
foreachMeta
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> BufferForeachMetaFunc |
|
-> m Bool | Returns: |
Call func
with userData
for each meta in buffer
.
func
can modify the passed meta pointer or its contents. The return value
of func
define if this function returns or if the remaining metadata items
in the buffer should be skipped.
getAllMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m (Maybe Memory) | Returns: a |
Get all the memory block in buffer
. The memory blocks will be merged
into one large Memory
.
getFlags
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m [BufferFlags] | Returns: the flags set on this buffer. |
Get the BufferFlags
flags set on this buffer.
Since: 1.10
getMaxMemory
:: (HasCallStack, MonadIO m) | |
=> m Word32 | Returns: the maximum amount of memory blocks that a buffer can hold. |
Get the maximum amount of memory blocks that a buffer can hold. This is a compile time constant that can be queried with the function.
When more memory blocks are added, existing memory blocks will be merged together to make room for the new block.
Since: 1.2
getMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> m (Maybe Memory) | Returns: a |
Get the memory block at index idx
in buffer
.
getMemoryRange
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> m (Maybe Memory) | Returns: a |
Get length
memory blocks in buffer
starting at idx
. The memory blocks will
be merged into one large Memory
.
If length
is -1, all memory starting from idx
is merged.
getMeta
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> GType |
|
-> m (Maybe Meta) | Returns: the metadata for |
Get the metadata for api
on buffer. When there is no such metadata, Nothing
is
returned. If multiple metadata with the given api
are attached to this
buffer only the first one is returned. To handle multiple metadata with a
given API use gst_buffer_iterate_meta()
or bufferForeachMeta
instead
and check the meta->info.api member for the API type.
getNMeta
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> GType |
|
-> m Word32 | Returns: number of metas of type |
No description available in the introspection data.
Since: 1.14
getReferenceTimestampMeta
bufferGetReferenceTimestampMeta Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Maybe Caps |
|
-> m (Maybe ReferenceTimestampMeta) | Returns: the |
Find the first ReferenceTimestampMeta
on buffer
that conforms to
reference
. Conformance is tested by checking if the meta's reference is a
subset of reference
.
Buffers can contain multiple ReferenceTimestampMeta
metadata items.
Since: 1.14
getSize
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m Word64 | Returns: total size of the memory blocks in |
Get the total size of the memory blocks in buffer
.
getSizes
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m (Word64, Word64, Word64) | Returns: total size of the memory blocks in |
Get the total size of the memory blocks in b
.
When not Nothing
, offset
will contain the offset of the data in the
first memory block in buffer
and maxsize
will contain the sum of
the size and offset
and the amount of extra padding on the last
memory block. offset
and maxsize
can be used to resize the
buffer memory blocks with bufferResize
.
getSizesRange
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> m (Word64, Word64, Word64) | Returns: total size of |
Get the total size of length
memory blocks stating from idx
in buffer
.
When not Nothing
, offset
will contain the offset of the data in the
memory block in buffer
at idx
and maxsize
will contain the sum of the size
and offset
and the amount of extra padding on the memory block at idx
+
length
-1.
offset
and maxsize
can be used to resize the buffer memory blocks with
bufferResizeRange
.
hasFlags
bufferHasFlags :: (HasCallStack, MonadIO m) => Buffer -> [BufferFlags] -> m Bool Source #
No description available in the introspection data.
insertMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Int32 |
|
-> Memory |
|
-> m () |
Insert the memory block mem
to buffer
at idx
. This function takes ownership
of mem
and thus doesn't increase its refcount.
Only bufferGetMaxMemory
can be added to a buffer. If more memory is
added, existing memory blocks will automatically be merged to make room for
the new memory.
isAllMemoryWritable
bufferIsAllMemoryWritable Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m Bool | Returns: |
Check if all memory blocks in buffer
are writable.
Note that this function does not check if buffer
is writable, use
gst_buffer_is_writable()
to check that if needed.
Since: 1.4
isMemoryRangeWritable
bufferIsMemoryRangeWritable Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> m Bool | Returns: |
Check if length
memory blocks in buffer
starting from idx
are writable.
length
can be -1 to check all the memory blocks after idx
.
Note that this function does not check if buffer
is writable, use
gst_buffer_is_writable()
to check that if needed.
Since: 1.4
map
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> [MapFlags] |
|
-> m (Bool, MapInfo) | Returns: |
This function fills info
with the MapInfo
of all merged memory
blocks in buffer
.
flags
describe the desired access of the memory. When flags
is
GST_MAP_WRITE
, buffer
should be writable (as returned from
gst_buffer_is_writable()
).
When buffer
is writable but the memory isn't, a writable copy will
automatically be created and returned. The readonly copy of the
buffer memory will then also be replaced with this writable copy.
The memory in info
should be unmapped with bufferUnmap
after
usage.
mapRange
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> [MapFlags] |
|
-> m (Bool, MapInfo) | Returns: |
This function fills info
with the MapInfo
of length
merged memory blocks
starting at idx
in buffer
. When length
is -1, all memory blocks starting
from idx
are merged and mapped.
flags
describe the desired access of the memory. When flags
is
GST_MAP_WRITE
, buffer
should be writable (as returned from
gst_buffer_is_writable()
).
When buffer
is writable but the memory isn't, a writable copy will
automatically be created and returned. The readonly copy of the buffer memory
will then also be replaced with this writable copy.
The memory in info
should be unmapped with bufferUnmap
after usage.
memcmp
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> ByteString |
|
-> m Int32 | Returns: 0 if the memory is equal. |
Compare size
bytes starting from offset
in buffer
with the memory in mem
.
memset
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word64 |
|
-> Word8 |
|
-> Word64 |
|
-> m Word64 | Returns: The amount of bytes filled. This value can be lower than |
Fill buf
with size
bytes with val
starting from offset
.
nMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m Word32 | Returns: the number of memory blocks this buffer is made of. |
Get the amount of memory blocks that this buffer has. This amount is never
larger than what bufferGetMaxMemory
returns.
new
:: (HasCallStack, MonadIO m) | |
=> m Buffer | Returns: the new |
Creates a newly allocated buffer without any data.
MT safe.
newAllocate
:: (HasCallStack, MonadIO m, IsAllocator a) | |
=> Maybe a |
|
-> Word64 |
|
-> Maybe AllocationParams |
|
-> m (Maybe Buffer) | Returns: a new |
Tries to create a newly allocated buffer with data of the given size and
extra parameters from allocator
. If the requested amount of memory can't be
allocated, Nothing
will be returned. The allocated buffer memory is not cleared.
When allocator
is Nothing
, the default memory allocator will be used.
Note that when size
== 0, the buffer will not have memory associated with it.
MT safe.
newWrapped
:: (HasCallStack, MonadIO m) | |
=> ByteString |
|
-> m Buffer | Returns: a new |
Creates a new buffer that wraps the given data
. The memory will be freed
with g_free and will be marked writable.
MT safe.
newWrappedBytes
bufferNewWrappedBytes Source #
:: (HasCallStack, MonadIO m) | |
=> Bytes |
|
-> m Buffer | Returns: a new |
newWrappedFull
:: (HasCallStack, MonadIO m) | |
=> [MemoryFlags] |
|
-> ByteString |
|
-> Word64 |
|
-> Word64 |
|
-> Maybe DestroyNotify |
|
-> m Buffer | Returns: a new |
Allocate a new buffer that wraps the given memory. data
must point to
maxsize
of memory, the wrapped buffer will have the region from offset
and
size
visible.
When the buffer is destroyed, notify
will be called with userData
.
The prefix/padding must be filled with 0 if flags
contains
GST_MEMORY_FLAG_ZERO_PREFIXED
and GST_MEMORY_FLAG_ZERO_PADDED
respectively.
peekMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> m (Maybe Memory) | Returns: the |
Get the memory block at idx
in buffer
. The memory block stays valid until
the memory block in buffer
is removed, replaced or merged, typically with
any call that modifies the memory in buffer
.
prependMemory
Prepend the memory block mem
to buffer
. This function takes
ownership of mem
and thus doesn't increase its refcount.
This function is identical to bufferInsertMemory
with an index of 0.
See bufferInsertMemory
for more details.
removeAllMemory
bufferRemoveAllMemory Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> m () |
Remove all the memory blocks in buffer
.
removeMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> m () |
Remove the memory block in b
at index i
.
removeMemoryRange
bufferRemoveMemoryRange Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> m () |
Remove length
memory blocks in buffer
starting from idx
.
length
can be -1, in which case all memory starting from idx
is removed.
removeMeta
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Meta |
|
-> m Bool | Returns: |
Remove the metadata for meta
on buffer
.
replaceAllMemory
bufferReplaceAllMemory Source #
Replaces all memory in buffer
with mem
.
replaceMemory
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Memory |
|
-> m () |
Replaces the memory block at index idx
in buffer
with mem
.
replaceMemoryRange
bufferReplaceMemoryRange Source #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> Memory |
|
-> m () |
Replaces length
memory blocks in buffer
starting at idx
with mem
.
If length
is -1, all memory starting from idx
will be removed and
replaced with mem
.
buffer
should be writable.
resize
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Int64 |
|
-> Int64 |
|
-> m () |
Set the offset and total size of the memory blocks in buffer
.
resizeRange
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Word32 |
|
-> Int32 |
|
-> Int64 |
|
-> Int64 |
|
-> m Bool |
Set the total size of the length
memory blocks starting at idx
in
buffer
setFlags
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> [BufferFlags] |
|
-> m Bool | Returns: |
Sets one or more buffer flags on a buffer.
Since: 1.10
setSize
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Int64 |
|
-> m () |
Set the total size of the memory blocks in buffer
.
unmap
Release the memory previously mapped with bufferMap
.
unsetFlags
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> [BufferFlags] |
|
-> m Bool | Returns: true if |
Clears one or more buffer flags.
Since: 1.10
Properties
dts
decoding timestamp of the buffer, can be CLOCK_TIME_NONE
when the
dts is not known or relevant. The dts contains the timestamp when the
media should be processed.
getBufferDts :: MonadIO m => Buffer -> m Word64 Source #
Get the value of the “dts
” field.
When overloading is enabled, this is equivalent to
get
buffer #dts
setBufferDts :: MonadIO m => Buffer -> Word64 -> m () Source #
Set the value of the “dts
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #dts:=
value ]
duration
duration in time of the buffer data, can be CLOCK_TIME_NONE
when the duration is not known or relevant.
getBufferDuration :: MonadIO m => Buffer -> m Word64 Source #
Get the value of the “duration
” field.
When overloading is enabled, this is equivalent to
get
buffer #duration
setBufferDuration :: MonadIO m => Buffer -> Word64 -> m () Source #
Set the value of the “duration
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #duration:=
value ]
miniObject
the parent structure
getBufferMiniObject :: MonadIO m => Buffer -> m MiniObject Source #
Get the value of the “mini_object
” field.
When overloading is enabled, this is equivalent to
get
buffer #miniObject
offset
a media specific offset for the buffer data. For video frames, this is the frame number of this buffer. For audio samples, this is the offset of the first sample in this buffer. For file data or compressed data this is the byte offset of the first byte in this buffer.
getBufferOffset :: MonadIO m => Buffer -> m Word64 Source #
Get the value of the “offset
” field.
When overloading is enabled, this is equivalent to
get
buffer #offset
setBufferOffset :: MonadIO m => Buffer -> Word64 -> m () Source #
Set the value of the “offset
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #offset:=
value ]
offsetEnd
the last offset contained in this buffer. It has the same
format as offset
.
getBufferOffsetEnd :: MonadIO m => Buffer -> m Word64 Source #
Get the value of the “offset_end
” field.
When overloading is enabled, this is equivalent to
get
buffer #offsetEnd
setBufferOffsetEnd :: MonadIO m => Buffer -> Word64 -> m () Source #
Set the value of the “offset_end
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #offsetEnd:=
value ]
pool
pointer to the pool owner of the buffer
clearBufferPool :: MonadIO m => Buffer -> m () Source #
Set the value of the “pool
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#pool
getBufferPool :: MonadIO m => Buffer -> m (Maybe BufferPool) Source #
Get the value of the “pool
” field.
When overloading is enabled, this is equivalent to
get
buffer #pool
setBufferPool :: MonadIO m => Buffer -> Ptr BufferPool -> m () Source #
Set the value of the “pool
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #pool:=
value ]
pts
presentation timestamp of the buffer, can be CLOCK_TIME_NONE
when the
pts is not known or relevant. The pts contains the timestamp when the
media should be presented to the user.
getBufferPts :: MonadIO m => Buffer -> m Word64 Source #
Get the value of the “pts
” field.
When overloading is enabled, this is equivalent to
get
buffer #pts
setBufferPts :: MonadIO m => Buffer -> Word64 -> m () Source #
Set the value of the “pts
” field.
When overloading is enabled, this is equivalent to
set
buffer [ #pts:=
value ]