Gjsify LogoGjsify Logo

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_alloc() method call. When %NULL is used as the allocator, the default allocator will be used.

New allocators can be registered with gst_allocator_register(). Allocators are identified by name and can be retrieved with gst_allocator_find(). gst_allocator_set_default() can be used to change the default allocator.

New memory can be created with gst_memory_new_wrapped() 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_get_sizes() and gst_memory_resize() respectively.

Getting access to the data of the memory is performed with gst_memory_map(). The call will return a pointer to offset bytes into the region of memory. After the memory access is completed, gst_memory_unmap() should be called.

Memory can be copied with gst_memory_copy(), which will return a writable copy. gst_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_is_span() returns %TRUE.

record

Hierarchy

  • Memory

Index

Constructors

Properties

align: number

the alignment of the memory

field
allocator: Gst.Allocator

pointer to the #GstAllocator

field
maxsize: number

the maximum size allocated

field
miniObject: Gst.MiniObject

parent structure

field
offset: number

the offset where valid data starts

field
parent: Memory

parent memory block

field
size: number

the size of valid data

field
name: string

Methods

  • copy(offset: number, size: number): Memory
  • Return 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.

    Parameters

    • offset: number

      offset to copy from

    • size: number

      size to copy, or -1 to copy to the end of the memory region

    Returns Memory

  • getSizes(): [number, number, number]
  • Get the current size, offset and maxsize of mem.

    Returns [number, number, number]

  • isSpan(mem2: Memory): [boolean, number]
  • 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 and mem2 can be merged efficiently by performing gst_memory_share() on the parent object from the returned offset.

    Parameters

    Returns [boolean, number]

  • isType(memType: string): boolean
  • Check if mem if allocated with an allocator for mem_type.

    Parameters

    • memType: string

      a memory type

    Returns boolean

  • Create 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.

    This function takes ownership of old mem and returns a reference to a new #GstMemory.

    Parameters

    Returns [Memory, MapInfo]

  • Fill info with the pointer and sizes of the memory in mem that can be accessed according to flags.

    This function can return %FALSE for various reasons:

    • the memory backed by mem is not accessible with the given flags.
    • the memory was already mapped with a different mapping.

    info and its contents remain valid for as long as mem is valid and until gst_memory_unmap() is called.

    For each gst_memory_map() call, a corresponding gst_memory_unmap() call should be done.

    Parameters

    Returns [boolean, MapInfo]

  • resize(offset: number, size: number): void
  • Resize the memory region. mem should be writable and offset + size should be less than the maxsize of mem.

    #GST_MEMORY_FLAG_ZERO_PREFIXED and #GST_MEMORY_FLAG_ZERO_PADDED will be cleared when offset or padding is increased respectively.

    Parameters

    • offset: number

      a new offset

    • size: number

      a new size

    Returns void

  • share(offset: number, size: number): Memory
  • Return 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 -1 to return a shared copy from offset to the end of the memory region.

    Parameters

    • offset: number

      offset to share from

    • size: number

      size to share, or -1 to share to the end of the memory region

    Returns Memory

  • Release the memory obtained with gst_memory_map()

    Parameters

    Returns void

  • Allocate a new memory block that wraps the given data.

    The prefix/padding must be filled with 0 if flags contains #GST_MEMORY_FLAG_ZERO_PREFIXED and #GST_MEMORY_FLAG_ZERO_PADDED respectively.

    Parameters

    • flags: MemoryFlags

      #GstMemoryFlags

    • data: Uint8Array

      data to wrap

    • maxsize: number

      allocated size of data

    • offset: number

      offset in data

    • notify: GLib.DestroyNotify

      called with user_data when the memory is freed

    Returns Memory

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method