gi-gst-1.0.26: GStreamer bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gst.Structs.Buffer

Description

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

Exported types

newtype Buffer Source #

Memory-managed wrapper type.

Constructors

Buffer (ManagedPtr Buffer) 

Instances

Instances details
Eq Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

Methods

(==) :: Buffer -> Buffer -> Bool #

(/=) :: Buffer -> Buffer -> Bool #

GBoxed Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

ManagedPtrNewtype Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

Methods

toManagedPtr :: Buffer -> ManagedPtr Buffer

TypedObject Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

Methods

glibType :: IO GType

HasParentTypes Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

tag ~ 'AttrSet => Constructible Buffer tag Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

Methods

new :: MonadIO m => (ManagedPtr Buffer -> Buffer) -> [AttrOp Buffer tag] -> m Buffer

IsGValue (Maybe Buffer) Source #

Convert Buffer to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gst.Structs.Buffer

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Buffer -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Buffer)

type ParentTypes Buffer Source # 
Instance details

Defined in GI.Gst.Structs.Buffer

type ParentTypes Buffer = '[] :: [Type]

newZeroBuffer :: MonadIO m => m Buffer Source #

Construct a Buffer struct initialized to zero.

Methods

addCustomMeta

bufferAddCustomMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Text

name: the registered name of the desired custom meta

-> m (Maybe CustomMeta)

Returns: The CustomMeta that was added to the buffer

Creates and adds a CustomMeta for the desired name. name must have been successfully registered with metaRegisterCustom.

Since: 1.20

addMeta

bufferAddMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> MetaInfo

info: a MetaInfo

-> Ptr ()

params: params for info

-> m (Maybe Meta)

Returns: the metadata for the api in info on buffer.

Adds metadata for info to buffer using the parameters in params.

addParentBufferMeta

bufferAddParentBufferMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Buffer

ref: a Buffer to ref

-> m (Maybe ParentBufferMeta)

Returns: The ParentBufferMeta that was added to the buffer

Adds a ParentBufferMeta to buffer that holds a reference on ref until the buffer is freed.

Since: 1.6

addProtectionMeta

bufferAddProtectionMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: Buffer holding an encrypted sample, to which protection metadata should be added.

-> Structure

info: a Structure holding cryptographic information relating to the sample contained in buffer. This function takes ownership of info.

-> m ProtectionMeta

Returns: a pointer to the added ProtectionMeta if successful

Attaches protection metadata to a Buffer.

Since: 1.6

addReferenceTimestampMeta

bufferAddReferenceTimestampMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Caps

reference: identifier for the timestamp reference.

-> Word64

timestamp: timestamp

-> Word64

duration: duration, or CLOCK_TIME_NONE

-> m (Maybe ReferenceTimestampMeta)

Returns: The ReferenceTimestampMeta that was added to the buffer

Adds 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

bufferAppend Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buf1: the first source Buffer to append.

-> Buffer

buf2: the second source Buffer to append.

-> m Buffer

Returns: the new Buffer that contains the memory of the two source buffers.

Appends all the memory from buf2 to buf1. The result buffer will contain a concatenation of the memory of buf1 and buf2.

appendMemory

bufferAppendMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Memory

mem: a Memory.

-> m () 

Appends 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

bufferAppendRegion Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buf1: the first source Buffer to append.

-> Buffer

buf2: the second source Buffer to append.

-> Int64

offset: the offset in buf2

-> Int64

size: the size or -1 of buf2

-> m Buffer

Returns: the new Buffer that contains the memory of the two source buffers.

Appends 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

bufferCopyDeep Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buf: a Buffer.

-> m Buffer

Returns: a new copy of buf.

Creates a copy of the given buffer. This will make a newly allocated copy of the data the source buffer contains.

Since: 1.6

copyInto

bufferCopyInto Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

dest: a destination Buffer

-> Buffer

src: a source Buffer

-> [BufferCopyFlags]

flags: flags indicating what metadata fields should be copied.

-> Word64

offset: offset to copy from

-> Word64

size: total size to copy. If -1, all data is copied.

-> m Bool

Returns: True if the copying succeeded, False otherwise.

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

bufferCopyRegion Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

parent: a Buffer.

-> [BufferCopyFlags]

flags: the BufferCopyFlags

-> Word64

offset: the offset into parent Buffer at which the new sub-buffer begins.

-> Word64

size: the size of the new Buffer sub-buffer, in bytes. If -1, all data is copied.

-> m Buffer

Returns: the new Buffer or Nothing if the arguments were invalid.

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.

extract

bufferExtract Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word64

offset: the offset to extract

-> Maybe ByteString

dest: the destination address

-> m (Word64, Maybe ByteString)

Returns: The amount of bytes extracted. This value can be lower than size when buffer did not contain enough data.

Copies size bytes starting from offset in buffer to dest.

extractDup

bufferExtractDup Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Word64

offset: the offset to extract

-> Word64

size: the size to extract

-> 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

bufferFill Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word64

offset: the offset to fill

-> ByteString

src: the source address

-> m Word64

Returns: The amount of bytes copied. This value can be lower than size when buffer did not contain enough data.

Copies size bytes from src to buffer at offset.

findMemory

bufferFindMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word64

offset: an offset

-> Word64

size: a size

-> m (Bool, Word32, Word32, Word64)

Returns: True when size bytes starting from offset could be found in buffer and idx, length and skip will be filled.

Finds 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

bufferForeachMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> BufferForeachMetaFunc

func: a BufferForeachMetaFunc to call

-> m Bool

Returns: False when func returned False for one of the metadata.

Calls func with userData for each meta in buffer.

func can modify the passed meta pointer or its contents. The return value of func defines if this function returns or if the remaining metadata items in the buffer should be skipped.

getAllMemory

bufferGetAllMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m (Maybe Memory)

Returns: a Memory that contains the merged memory.

Gets all the memory blocks in buffer. The memory blocks will be merged into one large Memory.

getCustomMeta

bufferGetCustomMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Text

name: the registered name of the custom meta to retrieve.

-> m (Maybe CustomMeta)

Returns: the CustomMeta

Finds the first CustomMeta on buffer for the desired name.

Since: 1.20

getFlags

bufferGetFlags Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> m [BufferFlags]

Returns: the flags set on this buffer.

Gets the BufferFlags flags set on this buffer.

Since: 1.10

getMaxMemory

bufferGetMaxMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Word32

Returns: the maximum amount of memory blocks that a buffer can hold.

Gets 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

bufferGetMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> m (Maybe Memory)

Returns: a Memory that contains the data of the memory block at idx.

Gets the memory block at index idx in buffer.

getMemoryRange

bufferGetMemoryRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length

-> m (Maybe Memory)

Returns: a Memory that contains the merged data of length blocks starting at idx.

Gets 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

bufferGetMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> GType

api: the GType of an API

-> m (Maybe Meta)

Returns: the metadata for api on buffer.

Gets 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

bufferGetNMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> GType

apiType: the GType of an API

-> m Word32

Returns: number of metas of type apiType on buffer.

No description available in the introspection data.

Since: 1.14

getReferenceTimestampMeta

bufferGetReferenceTimestampMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Maybe Caps

reference: a reference Caps

-> m (Maybe ReferenceTimestampMeta)

Returns: the ReferenceTimestampMeta or Nothing when there is no such metadata on buffer.

Finds 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

bufferGetSize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m Word64

Returns: total size of the memory blocks in buffer.

Gets the total size of the memory blocks in buffer.

getSizes

bufferGetSizes Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m (Word64, Word64, Word64)

Returns: total size of the memory blocks in buffer.

Gets the total size of the memory blocks in buffer.

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

bufferGetSizesRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length

-> m (Word64, Word64, Word64)

Returns: total size of length memory blocks starting at idx in buffer.

Gets 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 Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> [BufferFlags]

flags: the BufferFlags flag to check.

-> m Bool

Returns: True if all flags in flags are found on buffer.

Gives the status of a specific flag on a buffer.

Since: 1.10

insertMemory

bufferInsertMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Int32

idx: the index to add the memory at, or -1 to append it to the end

-> Memory

mem: a Memory.

-> m () 

Inserts the memory block mem into 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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m Bool

Returns: True if all memory blocks in buffer are writable

Checks 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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length, should not be 0

-> m Bool

Returns: True if the memory range is writable

Checks 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

bufferMap Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> [MapFlags]

flags: flags for the mapping

-> m (Bool, MapInfo)

Returns: True if the map succeeded and info contains valid data.

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

bufferMapRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length

-> [MapFlags]

flags: flags for the mapping

-> m (Bool, MapInfo)

Returns: True if the map succeeded and info contains valid data.

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

bufferMemcmp Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word64

offset: the offset in buffer

-> ByteString

mem: the memory to compare

-> m Int32

Returns: 0 if the memory is equal.

Compares size bytes starting from offset in buffer with the memory in mem.

memset

bufferMemset Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word64

offset: the offset in buffer

-> Word8

val: the value to set

-> Word64

size: the size to set

-> m Word64

Returns: The amount of bytes filled. This value can be lower than size when buffer did not contain enough data.

Fills buf with size bytes with val starting from offset.

nMemory

bufferNMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m Word32

Returns: the number of memory blocks this buffer is made of.

Gets the amount of memory blocks that this buffer has. This amount is never larger than what bufferGetMaxMemory returns.

new

bufferNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Buffer

Returns: the new Buffer.

Creates a newly allocated buffer without any data.

newAllocate

bufferNewAllocate Source #

Arguments

:: (HasCallStack, MonadIO m, IsAllocator a) 
=> Maybe a

allocator: the Allocator to use, or Nothing to use the default allocator

-> Word64

size: the size in bytes of the new buffer's data.

-> Maybe AllocationParams

params: optional parameters

-> m (Maybe Buffer)

Returns: a new Buffer

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.

newMemdup

bufferNewMemdup Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteString

data: data to copy into new buffer

-> m Buffer

Returns: a new Buffer

Creates a new buffer of size size and fills it with a copy of data.

Since: 1.20

newWrapped

bufferNewWrapped Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteString

data: data to wrap

-> m Buffer

Returns: a new Buffer

Creates a new buffer that wraps the given data. The memory will be freed with free and will be marked writable.

newWrappedBytes

bufferNewWrappedBytes Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Bytes

bytes: a Bytes to wrap

-> m Buffer

Returns: a new Buffer wrapping bytes

Creates a new Buffer that wraps the given bytes. The data inside bytes cannot be Nothing and the resulting buffer will be marked as read only.

Since: 1.16

newWrappedFull

bufferNewWrappedFull Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> [MemoryFlags]

flags: MemoryFlags

-> ByteString

data: data to wrap

-> Word64

maxsize: allocated size of data

-> Word64

offset: offset in data

-> Maybe DestroyNotify

notify: called with userData when the memory is freed

-> m Buffer

Returns: a new Buffer

Allocates 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

bufferPeekMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> m (Maybe Memory)

Returns: the Memory at idx.

Gets 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

bufferPrependMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Memory

mem: a Memory.

-> m () 

Prepends 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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> m () 

Removes all the memory blocks in buffer.

removeMemory

bufferRemoveMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> m () 

Removes the memory block in b at index i.

removeMemoryRange

bufferRemoveMemoryRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length

-> m () 

Removes length memory blocks in buffer starting from idx.

length can be -1, in which case all memory starting from idx is removed.

removeMeta

bufferRemoveMeta Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> Meta

meta: a Meta

-> m Bool

Returns: True if the metadata existed and was removed, False if no such metadata was on buffer.

Removes the metadata for meta on buffer.

replaceAllMemory

bufferReplaceAllMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Memory

mem: a Memory

-> m () 

Replaces all memory in buffer with mem.

replaceMemory

bufferReplaceMemory Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Memory

mem: a Memory

-> m () 

Replaces the memory block at index idx in buffer with mem.

replaceMemoryRange

bufferReplaceMemoryRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length, should not be 0

-> Memory

mem: a 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

bufferResize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Int64

offset: the offset adjustment

-> Int64

size: the new size or -1 to just adjust the offset

-> m () 

Sets the offset and total size of the memory blocks in buffer.

resizeRange

bufferResizeRange Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Word32

idx: an index

-> Int32

length: a length

-> Int64

offset: the offset adjustment

-> Int64

size: the new size or -1 to just adjust the offset

-> m Bool

Returns: True if resizing succeeded, False otherwise.

Sets the total size of the length memory blocks starting at idx in buffer

setFlags

bufferSetFlags Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> [BufferFlags]

flags: the BufferFlags to set.

-> m Bool

Returns: True if flags were successfully set on buffer.

Sets one or more buffer flags on a buffer.

Since: 1.10

setSize

bufferSetSize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> Int64

size: the new size

-> m () 

Sets the total size of the memory blocks in buffer.

unmap

bufferUnmap Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer.

-> MapInfo

info: a MapInfo

-> m () 

Releases the memory previously mapped with bufferMap.

unsetFlags

bufferUnsetFlags Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> [BufferFlags]

flags: the BufferFlags to clear

-> m Bool

Returns: true if flags is successfully cleared from buffer.

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 ]