gst.memory

Module for [Memory] class

class Memory

Types 1

classMemory : gobject.boxed.Boxed

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.

Methods
void * _cPtr(Flag!"Dup" dup = No.Dup) nothrow
GType _getGType() static nothrow
GType _gType() @property nothrow
Memory self() nothrowReturns `this`, for use in `with` statements.
gst.mini_object.MiniObject miniObject() @property nothrowGet `miniObject` field. Returns: parent structure
gst.allocator.Allocator allocator() @property nothrowGet `allocator` field. Returns: pointer to the #GstAllocator
void allocator(gst.allocator.Allocator propval) @property nothrowSet `allocator` field. Params: propval = pointer to the #GstAllocator
gst.memory.Memory parent() @property nothrowGet `parent` field. Returns: parent memory block
void parent(gst.memory.Memory propval) @property nothrowSet `parent` field. Params: propval = parent memory block
size_t maxsize() @property nothrowGet `maxsize` field. Returns: the maximum size allocated
void maxsize(size_t propval) @property nothrowSet `maxsize` field. Params: propval = the maximum size allocated
size_t align_() @property nothrowGet `align_` field. Returns: the alignment of the memory
void align_(size_t propval) @property nothrowSet `align_` field. Params: propval = the alignment of the memory
size_t offset() @property nothrowGet `offset` field. Returns: the offset where valid data starts
void offset(size_t propval) @property nothrowSet `offset` field. Params: propval = the offset where valid data starts
size_t size() @property nothrowGet `size` field. Returns: the size of valid data
void size(size_t propval) @property nothrowSet `size` field. Params: propval = the size of valid data
gst.memory.Memory newWrapped(gst.types.MemoryFlags flags, ubyte[] data, size_t maxsize, size_t offset, glib.types.DestroyNotify notify = null) static nothrowAllocate a new memory block that wraps the given data.
gst.memory.Memory copy(ptrdiff_t offset, ptrdiff_t size) nothrowReturn a copy of size bytes from mem starting from offset. This copy is guaranteed to be writable. size can be set to -1 to return a copy from offset to the end of the memory region.
size_t getSizes(out size_t offset, out size_t maxsize) nothrowGet the current size, offset and maxsize of mem.
bool isSpan(gst.memory.Memory mem2, out size_t offset) nothrowCheck if mem1 and mem2 share the memory with a common parent memory object and that the memory is contiguous.
bool isType(string memType) nothrowCheck if mem if allocated with an allocator for mem_type.
gst.memory.Memory makeMapped(out gst.map_info.MapInfo info, gst.types.MapFlags flags) nothrowCreate a #GstMemory object that is mapped with flags. If mem is mappable with flags, this function returns the mapped mem directly. Otherwise a mapped copy of mem is returned.
bool map(out gst.map_info.MapInfo info, gst.types.MapFlags flags) nothrowFill info with the pointer and sizes of the memory in mem that can be accessed according to flags.
void resize(ptrdiff_t offset, size_t size) nothrowResize the memory region. mem should be writable and offset + size should be less than the maxsize of mem.
gst.memory.Memory share(ptrdiff_t offset, ptrdiff_t size) nothrowReturn a shared copy of size bytes from mem starting from offset. No memory copy is performed and the memory region is simply shared. The result is guaranteed to be non-writable. size can be set to...
void unmap(gst.map_info.MapInfo info) nothrowRelease the memory obtained with [gst.memory.Memory.map]
Constructors
this(gst.allocator.Allocator allocator = gst.allocator.Allocator.init, gst.memory.Memory parent = gst.memory.Memory.init, size_t maxsize = size_t.init, size_t align_ = size_t.init, size_t offset = size_t.init, size_t size = size_t.init)Create a `memory.Memory` boxed type. Params: allocator = pointer to the #GstAllocator parent = parent memory block maxsize = the maximum size allocated align_ = the alignment of the memory offset =...
this(void * ptr, Flag!"Take" take)