Memory
- class Memory(*args, **kwargs)
- Constructors:
Memory()
new_wrapped(flags:Gst.MemoryFlags, data:list, maxsize:int, offset:int, user_data=None, notify:GLib.DestroyNotify=None) -> Gst.Memory or None
Constructors
- class Memory
- classmethod new_wrapped(flags: MemoryFlags, data: Sequence[int], maxsize: int, offset: int, user_data: None, notify: Callable[[...], None] | None = None) Memory | None
Allocate a new memory block that wraps the given
data
.The prefix/padding must be filled with 0 if
flags
containsGST_MEMORY_FLAG_ZERO_PREFIXED
andGST_MEMORY_FLAG_ZERO_PADDED
respectively.- Parameters:
flags –
MemoryFlags
data – data to wrap
maxsize – allocated size of
data
offset – offset in
data
user_data – user_data
notify – called with
user_data
when the memory is freed
Methods
- class Memory
-
- is_span(mem2: Memory) tuple[bool, int]
Check if
mem1
and mem2 share the memory with a common parent memory object and that the memory is contiguous.If this is the case, the memory of
mem1
andmem2
can be merged efficiently by performingshare()
on the parent object from the returnedoffset
.- Parameters:
mem2 – a
Memory
- is_type(mem_type: str) bool
Check if
mem
if allocated with an allocator formem_type
.Added in version 1.2.
- Parameters:
mem_type – a memory type
- make_mapped(flags: MapFlags) tuple[Memory | None, MapInfo]
Create a
Memory
object that is mapped withflags
. Ifmem
is mappable withflags
, this function returns the mappedmem
directly. Otherwise a mapped copy ofmem
is returned.This function takes ownership of old
mem
and returns a reference to a newMemory
.- Parameters:
flags – mapping flags
- map(flags: MapFlags) tuple[bool, MapInfo]
Fill
info
with the pointer and sizes of the memory inmem
that can be accessed according toflags
.This function can return
False
for various reasons:the memory backed by
mem
is not accessible with the givenflags
.the memory was already mapped with a different mapping.
info
and its contents remain valid for as long asmem
is valid and untilunmap()
is called.For each
map()
call, a correspondingunmap()
call should be done.- Parameters:
flags – mapping flags
- resize(offset: int, size: int) None
Resize the memory region.
mem
should be writable and offset + size should be less than the maxsize ofmem
.GST_MEMORY_FLAG_ZERO_PREFIXED
andGST_MEMORY_FLAG_ZERO_PADDED
will be cleared when offset or padding is increased respectively.- Parameters:
offset – a new offset
size – a new size
Return a shared copy of
size
bytes frommem
starting fromoffset
. 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 -1 to return a shared copy fromoffset
to the end of the memory region.- Parameters:
offset – offset to share from
size – size to share, or -1 to share to the end of the memory region