GstMemory

GstMemory is a lightweight refcounted object that wraps a region of memory. They are typically used to manage the data of a #GstBuffer.

A GstMemory object has an allocated region of memory of maxsize. The maximum size does not change during the lifetime of the memory object. The memory also has an offset and size property that specifies the valid range of memory in the allocated region.

Memory is usually created by allocators with a gst.allocator.Allocator.alloc method call. When null is used as the allocator, the default allocator will be used.

New allocators can be registered with gst.allocator.Allocator.register. Allocators are identified by name and can be retrieved with gst.allocator.Allocator.find. gst.allocator.Allocator.setDefault can be used to change the default allocator.

New memory can be created with gst.memory.Memory.newWrapped that wraps the memory allocated elsewhere.

Refcounting of the memory block is performed with gst_memory_ref() and gst_memory_unref().

The size of the memory can be retrieved and changed with gst.memory.Memory.getSizes and gst.memory.Memory.resize respectively.

Getting access to the data of the memory is performed with gst.memory.Memory.map. The call will return a pointer to offset bytes into the region of memory. After the memory access is completed, gst.memory.Memory.unmap should be called.

Memory can be copied with gst.memory.Memory.copy, which will return a writable copy. gst.memory.Memory.share will create a new memory block that shares the memory with an existing memory block at a custom offset and with a custom size.

Memory can be efficiently merged when gst.memory.Memory.isSpan returns true.

Members

Variables

align_
size_t align_;

the alignment of the memory

allocator
GstAllocator* allocator;

pointer to the #GstAllocator

maxsize
size_t maxsize;

the maximum size allocated

miniObject
GstMiniObject miniObject;

parent structure

offset
size_t offset;

the offset where valid data starts

parent
GstMemory* parent;

parent memory block

size
size_t size;

the size of valid data