# 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_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.

## GstMapInfo

A structure containing the result of a map operation such as gst_memory_map. It contains the data and size.

GstMapInfo cannot be used with g_auto because it is ambiguous whether it needs to be unmapped using gst_buffer_unmap or gst_memory_unmap. Instead, GstBufferMapInfo and GstMemoryMapInfo can be used in that case.

### Members

`memory` (GstMemory *) –

a pointer to the mapped memory

`flags` (GstMapFlags) –

flags used when mapping the memory

`data` (guint8*) –

a pointer to the mapped data

`size` (gsize) –

the valid size in data

`maxsize` (gsize) –

the maximum bytes in data

`user_data` (gpointer*) –

extra private user_data that the implementation of the memory can use to store extra info.

## Gst.MapInfo

A structure containing the result of a map operation such as Gst.Memory.prototype.map. It contains the data and size.

Gst.MapInfo cannot be used with g_auto because it is ambiguous whether it needs to be unmapped using Gst.Buffer.prototype.unmap or Gst.Memory.prototype.unmap. Instead, GstBufferMapInfo (not introspectable) and GstMemoryMapInfo (not introspectable) can be used in that case.

### Members

`memory` (Gst.Memory) –

a pointer to the mapped memory

`flags` (Gst.MapFlags) –

flags used when mapping the memory

`data` ([ Number ]) –

a pointer to the mapped data

`size` (Number) –

the valid size in data

`maxsize` (Number) –

the maximum bytes in data

`user_data` ([ Object ]) –

extra private user_data that the implementation of the memory can use to store extra info.

## Gst.MapInfo

A structure containing the result of a map operation such as Gst.Memory.map. It contains the data and size.

Gst.MapInfo cannot be used with g_auto because it is ambiguous whether it needs to be unmapped using Gst.Buffer.unmap or Gst.Memory.unmap. Instead, GstBufferMapInfo (not introspectable) and GstMemoryMapInfo (not introspectable) can be used in that case.

### Members

`memory` (Gst.Memory) –

a pointer to the mapped memory

`flags` (Gst.MapFlags) –

flags used when mapping the memory

`data` ([ int ]) –

a pointer to the mapped data

`size` (int) –

the valid size in data

`maxsize` (int) –

the maximum bytes in data

`user_data` ([ object ]) –

extra private user_data that the implementation of the memory can use to store extra info.

## GstMemory

Base structure for memory implementations. Custom memory will put this structure as the first member of their structure.

### Members

`mini_object` (GstMiniObject) –

parent structure

`allocator` (GstAllocator *) –

pointer to the GstAllocator

`parent` (GstMemory *) –

parent memory block

`maxsize` (gsize) –

the maximum size allocated

`align` (gsize) –

the alignment of the memory

`offset` (gsize) –

the offset where valid data starts

`size` (gsize) –

the size of valid data

## Gst.Memory

Base structure for memory implementations. Custom memory will put this structure as the first member of their structure.

### Members

`mini_object` (Gst.MiniObject) –

parent structure

`allocator` (Gst.Allocator) –

pointer to the Gst.Allocator

`parent` (Gst.Memory) –

parent memory block

`maxsize` (Number) –

the maximum size allocated

`align` (Number) –

the alignment of the memory

`offset` (Number) –

the offset where valid data starts

`size` (Number) –

the size of valid data

## Gst.Memory

Base structure for memory implementations. Custom memory will put this structure as the first member of their structure.

### Members

`mini_object` (Gst.MiniObject) –

parent structure

`allocator` (Gst.Allocator) –

pointer to the Gst.Allocator

`parent` (Gst.Memory) –

parent memory block

`maxsize` (int) –

the maximum size allocated

`align` (int) –

the alignment of the memory

`offset` (int) –

the offset where valid data starts

`size` (int) –

the size of valid data

### Constructors

#### gst_memory_new_wrapped

    GstMemory *
    gst_memory_new_wrapped (GstMemoryFlags flags,
                            gpointer data,
                            gsize maxsize,
                            gsize offset,
                            gsize size,
                            gpointer user_data,
                            GDestroyNotify notify)

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

GstMemoryFlags

`data` ( [arraylength=size][element-typeguint8][transfer: none]) –

data to wrap

`maxsize` –

allocated size of data

`offset` –

offset in data

`size` –

size of valid data

`user_data` ( [nullable]) –

user_data

`notify` ( [nullable][scope async][closure]) –

called with user_data when the memory is freed

Returns ( [transfer: full][nullable]) –

a new GstMemory.

#### Gst.Memory.prototype.new_wrapped

    function Gst.Memory.prototype.new_wrapped(flags: Gst.MemoryFlags, data: [ Number ], maxsize: Number, offset: Number, size: Number, user_data: Object, notify: GLib.DestroyNotify): {
        // javascript wrapper for 'gst_memory_new_wrapped'
    }

Allocate a new memory block that wraps the given data.

The prefix/padding must be filled with 0 if flags contains Gst.MemoryFlags.ZERO_PREFIXED and Gst.MemoryFlags.ZERO_PADDED respectively.

Parameters:

`flags` (Gst.MemoryFlags) –

Gst.MemoryFlags

`data` ([ Number ]) –

data to wrap

`maxsize` (Number) –

allocated size of data

`offset` (Number) –

offset in data

`size` (Number) –

size of valid data

`user_data` (Object) –

user_data

`notify` (GLib.DestroyNotify) –

called with user_data when the memory is freed

Returns (Gst.Memory) –

a new Gst.Memory.

#### Gst.Memory.new_wrapped

    def Gst.Memory.new_wrapped (flags, data, maxsize, offset, size, *user_data, notify):
        #python wrapper for 'gst_memory_new_wrapped'

Allocate a new memory block that wraps the given data.

The prefix/padding must be filled with 0 if flags contains Gst.MemoryFlags.ZERO_PREFIXED and Gst.MemoryFlags.ZERO_PADDED respectively.

Parameters:

`flags` (Gst.MemoryFlags) –

Gst.MemoryFlags

`data` ([ int ]) –

data to wrap

`maxsize` (int) –

allocated size of data

`offset` (int) –

offset in data

`size` (int) –

size of valid data

`user_data` (variadic) –

user_data

`notify` (GLib.DestroyNotify) –

called with user_data when the memory is freed

Returns (Gst.Memory) –

a new Gst.Memory.

### Methods

#### gst_memory_copy

    GstMemory *
    gst_memory_copy (GstMemory * mem,
                     gssize offset,
                     gssize size)

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:

`mem` –

a GstMemory

`offset` –

offset to copy from

`size` –

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

Returns ( [transfer: full][nullable]) –

a new copy of mem if the copy succeeded, NULL otherwise.

#### Gst.Memory.prototype.copy

    function Gst.Memory.prototype.copy(offset: Number, size: Number): {
        // javascript wrapper for 'gst_memory_copy'
    }

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:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

offset to copy from

`size` (Number) –

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

Returns (Gst.Memory) –

a new copy of mem if the copy succeeded, NULL otherwise.

#### Gst.Memory.copy

    def Gst.Memory.copy (self, offset, size):
        #python wrapper for 'gst_memory_copy'

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:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

offset to copy from

`size` (int) –

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

Returns (Gst.Memory) –

a new copy of mem if the copy succeeded, NULL otherwise.

#### gst_memory_get_sizes

    gsize
    gst_memory_get_sizes (GstMemory * mem,
                          gsize* offset,
                          gsize* maxsize)

Get the current size, offset and maxsize of mem.

Parameters:

`mem` –

a GstMemory

`offset` ( [out][allow-none]) –

pointer to offset

`maxsize` ( [out][allow-none]) –

pointer to maxsize

Returns –

the current size of mem

#### Gst.Memory.prototype.get_sizes

    function Gst.Memory.prototype.get_sizes(): {
        // javascript wrapper for 'gst_memory_get_sizes'
    }

Get the current size, offset and maxsize of mem.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

Returns a tuple made of:

(Number ) –

the current size of mem

`offset` (Number ) –

the current size of mem

`maxsize` (Number ) –

the current size of mem

#### Gst.Memory.get_sizes

    def Gst.Memory.get_sizes (self):
        #python wrapper for 'gst_memory_get_sizes'

Get the current size, offset and maxsize of mem.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

Returns a tuple made of:

(int ) –

the current size of mem

`offset` (int ) –

the current size of mem

`maxsize` (int ) –

the current size of mem

#### gst_memory_init

    gst_memory_init (GstMemory * mem,
                     GstMemoryFlags flags,
                     GstAllocator * allocator,
                     GstMemory * parent,
                     gsize maxsize,
                     gsize align,
                     gsize offset,
                     gsize size)

Initializes a newly allocated mem with the given parameters. This function will call gst_mini_object_init with the default memory parameters.

Parameters:

`mem` –

a GstMemory

`flags` –

GstMemoryFlags

`allocator` –

the GstAllocator

`parent` –

the parent of mem

`maxsize` –

the total size of the memory

`align` –

the alignment of the memory

`offset` –

The offset in the memory

`size` –

the size of valid data in the memory

#### gst_memory_is_span

    gboolean
    gst_memory_is_span (GstMemory * mem1,
                        GstMemory * mem2,
                        gsize* offset)

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:

`mem1` –

a GstMemory

`mem2` –

a GstMemory

`offset` ( [out]) –

a pointer to a result offset

Returns –

TRUE if the memory is contiguous and of a common parent.

#### Gst.Memory.prototype.is_span

    function Gst.Memory.prototype.is_span(mem2: Gst.Memory): {
        // javascript wrapper for 'gst_memory_is_span'
    }

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.prototype.share on the parent object from the returned offset.

Parameters:

`mem1` (Gst.Memory) –

a Gst.Memory

`mem2` (Gst.Memory) –

a Gst.Memory

Returns a tuple made of:

(Number ) –

TRUE if the memory is contiguous and of a common parent.

`offset` (Number ) –

TRUE if the memory is contiguous and of a common parent.

#### Gst.Memory.is_span

    def Gst.Memory.is_span (self, mem2):
        #python wrapper for 'gst_memory_is_span'

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:

`mem1` (Gst.Memory) –

a Gst.Memory

`mem2` (Gst.Memory) –

a Gst.Memory

Returns a tuple made of:

(bool ) –

TRUE if the memory is contiguous and of a common parent.

`offset` (int ) –

TRUE if the memory is contiguous and of a common parent.

#### gst_memory_is_type

    gboolean
    gst_memory_is_type (GstMemory * mem,
                        const gchar* mem_type)

Check if mem if allocated with an allocator for mem_type.

Parameters:

`mem` –

a GstMemory

`mem_type` –

a memory type

Returns –

TRUE if mem was allocated from an allocator for mem_type.

Since : 1.2

#### Gst.Memory.prototype.is_type

    function Gst.Memory.prototype.is_type(mem_type: String): {
        // javascript wrapper for 'gst_memory_is_type'
    }

Check if mem if allocated with an allocator for mem_type.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`mem_type` (String) –

a memory type

Returns (Number) –

TRUE if mem was allocated from an allocator for mem_type.

Since : 1.2

#### Gst.Memory.is_type

    def Gst.Memory.is_type (self, mem_type):
        #python wrapper for 'gst_memory_is_type'

Check if mem if allocated with an allocator for mem_type.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`mem_type` (str) –

a memory type

Returns (bool) –

TRUE if mem was allocated from an allocator for mem_type.

Since : 1.2

#### gst_memory_make_mapped

    GstMemory *
    gst_memory_make_mapped (GstMemory * mem,
                            GstMapInfo * info,
                            GstMapFlags flags)

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:

`mem` ( [transfer: full]) –

a GstMemory

`info` ( [out]) –

pointer for info

`flags` –

mapping flags

Returns ( [transfer: full][nullable]) –

a GstMemory object mapped with flags or NULL when a mapping is not possible.

#### Gst.Memory.prototype.make_mapped

    function Gst.Memory.prototype.make_mapped(flags: Gst.MapFlags): {
        // javascript wrapper for 'gst_memory_make_mapped'
    }

Create a Gst.Memory 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 Gst.Memory.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`flags` (Gst.MapFlags) –

mapping flags

Returns a tuple made of:

(Gst.Memory ) –

a Gst.Memory object mapped with flags or NULL when a mapping is not possible.

`info` (Gst.MapInfo ) –

a Gst.Memory object mapped with flags or NULL when a mapping is not possible.

#### Gst.Memory.make_mapped

    def Gst.Memory.make_mapped (self, flags):
        #python wrapper for 'gst_memory_make_mapped'

Create a Gst.Memory 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 Gst.Memory.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`flags` (Gst.MapFlags) –

mapping flags

Returns a tuple made of:

(Gst.Memory ) –

a Gst.Memory object mapped with flags or NULL when a mapping is not possible.

`info` (Gst.MapInfo ) –

a Gst.Memory object mapped with flags or NULL when a mapping is not possible.

#### gst_memory_map

    gboolean
    gst_memory_map (GstMemory * mem,
                    GstMapInfo * info,
                    GstMapFlags flags)

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:

`mem` –

a GstMemory

`info` ( [out]) –

pointer for info

`flags` –

mapping flags

Returns –

TRUE if the map operation was successful.

#### Gst.Memory.prototype.map

    function Gst.Memory.prototype.map(flags: Gst.MapFlags): {
        // javascript wrapper for 'gst_memory_map'
    }

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.prototype.unmap is called.

For each Gst.Memory.prototype.map call, a corresponding Gst.Memory.prototype.unmap call should be done.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`flags` (Gst.MapFlags) –

mapping flags

Returns a tuple made of:

(Number ) –

TRUE if the map operation was successful.

`info` (Gst.MapInfo ) –

TRUE if the map operation was successful.

#### Gst.Memory.map

    def Gst.Memory.map (self, flags):
        #python wrapper for 'gst_memory_map'

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:

`mem` (Gst.Memory) –

a Gst.Memory

`flags` (Gst.MapFlags) –

mapping flags

Returns a tuple made of:

(bool ) –

TRUE if the map operation was successful.

`info` (Gst.MapInfo ) –

TRUE if the map operation was successful.

#### gst_memory_ref

    GstMemory *
    gst_memory_ref (GstMemory * memory)

Increase the refcount of this memory.

Parameters:

`memory` –

The memory to refcount

Returns ( [transfer: full]) –

memory (for convenience when doing assignments)

#### gst_memory_resize

    gst_memory_resize (GstMemory * mem,
                       gssize offset,
                       gsize size)

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:

`mem` –

a GstMemory

`offset` –

a new offset

`size` –

a new size

#### Gst.Memory.prototype.resize

    function Gst.Memory.prototype.resize(offset: Number, size: Number): {
        // javascript wrapper for 'gst_memory_resize'
    }

Resize the memory region. mem should be writable and offset + size should be less than the maxsize of mem.

Gst.MemoryFlags.ZERO_PREFIXED and Gst.MemoryFlags.ZERO_PADDED will be cleared when offset or padding is increased respectively.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

a new offset

`size` (Number) –

a new size

#### Gst.Memory.resize

    def Gst.Memory.resize (self, offset, size):
        #python wrapper for 'gst_memory_resize'

Resize the memory region. mem should be writable and offset + size should be less than the maxsize of mem.

Gst.MemoryFlags.ZERO_PREFIXED and Gst.MemoryFlags.ZERO_PADDED will be cleared when offset or padding is increased respectively.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

a new offset

`size` (int) –

a new size

#### gst_memory_share

    GstMemory *
    gst_memory_share (GstMemory * mem,
                      gssize offset,
                      gssize size)

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:

`mem` –

a GstMemory

`offset` –

offset to share from

`size` –

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

Returns –

a new GstMemory.

#### Gst.Memory.prototype.share

    function Gst.Memory.prototype.share(offset: Number, size: Number): {
        // javascript wrapper for 'gst_memory_share'
    }

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:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

offset to share from

`size` (Number) –

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

Returns (Gst.Memory) –

a new Gst.Memory.

#### Gst.Memory.share

    def Gst.Memory.share (self, offset, size):
        #python wrapper for 'gst_memory_share'

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:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

offset to share from

`size` (int) –

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

Returns (Gst.Memory) –

a new Gst.Memory.

#### gst_memory_unmap

    gst_memory_unmap (GstMemory * mem,
                      GstMapInfo * info)

Release the memory obtained with gst_memory_map

Parameters:

`mem` –

a GstMemory

`info` –

a GstMapInfo

#### Gst.Memory.prototype.unmap

    function Gst.Memory.prototype.unmap(info: Gst.MapInfo): {
        // javascript wrapper for 'gst_memory_unmap'
    }

Release the memory obtained with Gst.Memory.prototype.map

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

a Gst.MapInfo

#### Gst.Memory.unmap

    def Gst.Memory.unmap (self, info):
        #python wrapper for 'gst_memory_unmap'

Release the memory obtained with Gst.Memory.map

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

a Gst.MapInfo

#### gst_memory_unref

    gst_memory_unref (GstMemory * memory)

Decrease the refcount of a memory, freeing it if the refcount reaches 0.

Parameters:

`memory` ( [transfer: full]) –

the memory to refcount

## Function Macros

### GST_MEMORY_CAST

    #define GST_MEMORY_CAST(mem)   ((GstMemory *)(mem))

### GST_MEMORY_FLAGS

    #define GST_MEMORY_FLAGS(mem)  GST_MINI_OBJECT_FLAGS (mem)

A flags word containing GstMemoryFlags flags set on mem

Parameters:

`mem` –

a GstMemory.

### GST_MEMORY_FLAG_IS_SET

    #define GST_MEMORY_FLAG_IS_SET(mem,flag)   GST_MINI_OBJECT_FLAG_IS_SET (mem,flag)

Gives the status of a specific flag on a mem.

Parameters:

`mem` –

a GstMemory.

`flag` –

the GstMemoryFlags to check.

### GST_MEMORY_FLAG_UNSET

    #define GST_MEMORY_FLAG_UNSET(mem,flag)   GST_MINI_OBJECT_FLAG_UNSET (mem, flag)

Clear a specific flag on a mem.

Parameters:

`mem` –

a GstMemory.

`flag` –

the GstMemoryFlags to clear.

### GST_MEMORY_IS_NOT_MAPPABLE

    #define GST_MEMORY_IS_NOT_MAPPABLE(mem)     GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_NOT_MAPPABLE)

Check if mem can't be mapped via gst_memory_map without any preconditions

Parameters:

`mem` –

a GstMemory.

Since : 1.2

### GST_MEMORY_IS_NO_SHARE

    #define GST_MEMORY_IS_NO_SHARE(mem)        GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_NO_SHARE)

Check if mem cannot be shared between buffers

Parameters:

`mem` –

a GstMemory.

### GST_MEMORY_IS_PHYSICALLY_CONTIGUOUS

    #define GST_MEMORY_IS_PHYSICALLY_CONTIGUOUS(mem)     GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS)

Check if mem is physically contiguous.

Parameters:

`mem` –

a GstMemory.

Since : 1.2

### GST_MEMORY_IS_READONLY

    #define GST_MEMORY_IS_READONLY(mem)        GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_READONLY)

Check if mem is readonly.

Parameters:

`mem` –

a GstMemory.

### GST_MEMORY_IS_ZERO_PADDED

    #define GST_MEMORY_IS_ZERO_PADDED(mem)     GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_ZERO_PADDED)

Check if the padding in mem is 0 filled.

Parameters:

`mem` –

a GstMemory.

### GST_MEMORY_IS_ZERO_PREFIXED

    #define GST_MEMORY_IS_ZERO_PREFIXED(mem)   GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_ZERO_PREFIXED)

Check if the prefix in mem is 0 filled.

Parameters:

`mem` –

a GstMemory.

### gst_memory_is_writable

    #define gst_memory_is_writable(m)   gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (m))

### gst_memory_lock

    #define gst_memory_lock(m,f)        gst_mini_object_lock (GST_MINI_OBJECT_CAST (m), (f))

### gst_memory_make_writable

    #define gst_memory_make_writable(m) GST_MEMORY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (m)))

Returns a writable copy of m. If the source memory is already writable, this will simply return the same memory.

Parameters:

`m` ( [transfer: full]) –

a GstMemory

Returns ( [transfer: full][nullable]) –

a writable memory (which may or may not be the same as m) or NULL if copying is required but not possible.

### gst_memory_unlock

    #define gst_memory_unlock(m,f)      gst_mini_object_unlock (GST_MINI_OBJECT_CAST (m), (f))

## Enumerations

### GstMapFlags

Flags used when mapping memory

##### Members

`GST_MAP_READ` (1) –

map for read access

`GST_MAP_WRITE` (2) –

map for write access

`GST_MAP_FLAG_LAST` (65536) –

first flag that can be used for custom purposes

### Gst.MapFlags

Flags used when mapping memory

##### Members

`Gst.MapFlags.READ` (1) –

map for read access

`Gst.MapFlags.WRITE` (2) –

map for write access

`Gst.MapFlags.FLAG_LAST` (65536) –

first flag that can be used for custom purposes

### Gst.MapFlags

Flags used when mapping memory

##### Members

`Gst.MapFlags.READ` (1) –

map for read access

`Gst.MapFlags.WRITE` (2) –

map for write access

`Gst.MapFlags.FLAG_LAST` (65536) –

first flag that can be used for custom purposes

### GstMemoryFlags

Flags for wrapped memory.

##### Members

`GST_MEMORY_FLAG_READONLY` (2) –

memory is readonly. It is not allowed to map the memory with GST_MAP_WRITE.

`GST_MEMORY_FLAG_NO_SHARE` (16) –

memory must not be shared. Copies will have to be made when this memory needs to be shared between buffers. (DEPRECATED: do not use in new code, instead you should create a custom GstAllocator for memory pooling instead of relying on the GstBuffer they were originally attached to.)

`GST_MEMORY_FLAG_ZERO_PREFIXED` (32) –

the memory prefix is filled with 0 bytes

`GST_MEMORY_FLAG_ZERO_PADDED` (64) –

the memory padding is filled with 0 bytes

`GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS` (128) –

the memory is physically contiguous. (Since: 1.2)

`GST_MEMORY_FLAG_NOT_MAPPABLE` (256) –

the memory can't be mapped via gst_memory_map without any preconditions. (Since: 1.2)

`GST_MEMORY_FLAG_LAST` (1048576) –

first flag that can be used for custom purposes

### Gst.MemoryFlags

Flags for wrapped memory.

##### Members

`Gst.MemoryFlags.READONLY` (2) –

memory is readonly. It is not allowed to map the memory with Gst.MapFlags.WRITE.

`Gst.MemoryFlags.NO_SHARE` (16) –

memory must not be shared. Copies will have to be made when this memory needs to be shared between buffers. (DEPRECATED: do not use in new code, instead you should create a custom GstAllocator for memory pooling instead of relying on the GstBuffer they were originally attached to.)

`Gst.MemoryFlags.ZERO_PREFIXED` (32) –

the memory prefix is filled with 0 bytes

`Gst.MemoryFlags.ZERO_PADDED` (64) –

the memory padding is filled with 0 bytes

`Gst.MemoryFlags.PHYSICALLY_CONTIGUOUS` (128) –

the memory is physically contiguous. (Since: 1.2)

`Gst.MemoryFlags.NOT_MAPPABLE` (256) –

the memory can't be mapped via Gst.Memory.prototype.map without any preconditions. (Since: 1.2)

`Gst.MemoryFlags.LAST` (1048576) –

first flag that can be used for custom purposes

### Gst.MemoryFlags

Flags for wrapped memory.

##### Members

`Gst.MemoryFlags.READONLY` (2) –

memory is readonly. It is not allowed to map the memory with Gst.MapFlags.WRITE.

`Gst.MemoryFlags.NO_SHARE` (16) –

memory must not be shared. Copies will have to be made when this memory needs to be shared between buffers. (DEPRECATED: do not use in new code, instead you should create a custom GstAllocator for memory pooling instead of relying on the GstBuffer they were originally attached to.)

`Gst.MemoryFlags.ZERO_PREFIXED` (32) –

the memory prefix is filled with 0 bytes

`Gst.MemoryFlags.ZERO_PADDED` (64) –

the memory padding is filled with 0 bytes

`Gst.MemoryFlags.PHYSICALLY_CONTIGUOUS` (128) –

the memory is physically contiguous. (Since: 1.2)

`Gst.MemoryFlags.NOT_MAPPABLE` (256) –

the memory can't be mapped via Gst.Memory.map without any preconditions. (Since: 1.2)

`Gst.MemoryFlags.LAST` (1048576) –

first flag that can be used for custom purposes

## Constants

### GST_MAP_INFO_INIT

    #define GST_MAP_INFO_INIT { NULL, (GstMapFlags) 0, NULL, 0, 0, { NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL}}

Initializer for GstMapInfo

### GST_MAP_READWRITE

    #define GST_MAP_READWRITE      ((GstMapFlags) (GST_MAP_READ | GST_MAP_WRITE))

GstMapFlags value alias for GST_MAP_READ | GST_MAP_WRITE

### Gst.MAP_READWRITE

GstMapFlags value alias for GST_MAP_READ | GST_MAP_WRITE

### Gst.MAP_READWRITE

GstMapFlags value alias for GST_MAP_READ | GST_MAP_WRITE

## Aliases

### GstMemoryMapInfo

    typedef GstMapInfo GstMemoryMapInfo

Alias for GstMapInfo to be used with g_auto:

    void my_func(GstMemory *mem)
    {
      g_auto(GstMemoryMapInfo) map = GST_MAP_INFO_INIT;
      if (!gst_memory_map(mem, &map, GST_MAP_READWRITE))
        return;
      ...
      // No need to call gst_memory_unmap()
    }

GstMapInfo cannot be used with g_auto because it is ambiguous whether it needs to be unmapped using gst_buffer_unmap or gst_memory_unmap.

See also GstBufferMapInfo.

Since : 1.22

## Callbacks

### GstMemoryCopyFunction

    GstMemory *
    (*GstMemoryCopyFunction) (GstMemory * mem,
                              gssize offset,
                              gssize size)

Copy size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are copied.

Parameters:

`mem` –

a GstMemory

`offset` –

an offset

`size` –

a size or -1

Returns –

a new GstMemory object wrapping a copy of the requested region in mem.

### Gst.MemoryCopyFunction

    function Gst.MemoryCopyFunction(mem: Gst.Memory, offset: Number, size: Number): {
        // javascript wrapper for 'GstMemoryCopyFunction'
    }

Copy size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are copied.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

an offset

`size` (Number) –

a size or -1

Returns (Gst.Memory) –

a new Gst.Memory object wrapping a copy of the requested region in mem.

### Gst.MemoryCopyFunction

    def Gst.MemoryCopyFunction (mem, offset, size):
        #python wrapper for 'GstMemoryCopyFunction'

Copy size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are copied.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

an offset

`size` (int) –

a size or -1

Returns (Gst.Memory) –

a new Gst.Memory object wrapping a copy of the requested region in mem.

### GstMemoryIsSpanFunction

    gboolean
    (*GstMemoryIsSpanFunction) (GstMemory * mem1,
                                GstMemory * mem2,
                                gsize* offset)

Check if mem1 and mem2 occupy contiguous memory and return the offset of mem1 in the parent buffer in offset.

Parameters:

`mem1` –

a GstMemory

`mem2` –

a GstMemory

`offset` –

a result offset

Returns –

TRUE if mem1 and mem2 are in contiguous memory.

### Gst.MemoryIsSpanFunction

    function Gst.MemoryIsSpanFunction(mem1: Gst.Memory, mem2: Gst.Memory, offset: Number): {
        // javascript wrapper for 'GstMemoryIsSpanFunction'
    }

Check if mem1 and mem2 occupy contiguous memory and return the offset of mem1 in the parent buffer in offset.

Parameters:

`mem1` (Gst.Memory) –

a Gst.Memory

`mem2` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

a result offset

Returns (Number) –

TRUE if mem1 and mem2 are in contiguous memory.

### Gst.MemoryIsSpanFunction

    def Gst.MemoryIsSpanFunction (mem1, mem2, offset):
        #python wrapper for 'GstMemoryIsSpanFunction'

Check if mem1 and mem2 occupy contiguous memory and return the offset of mem1 in the parent buffer in offset.

Parameters:

`mem1` (Gst.Memory) –

a Gst.Memory

`mem2` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

a result offset

Returns (bool) –

TRUE if mem1 and mem2 are in contiguous memory.

### GstMemoryMapFullFunction

    gpointer
    (*GstMemoryMapFullFunction) (GstMemory * mem,
                                 GstMapInfo * info,
                                 gsize maxsize)

Get the memory of mem that can be accessed according to the mode specified in info's flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` –

a GstMemory

`info` –

the GstMapInfo to map with

`maxsize` –

size to map

Returns –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in info's flags.

### Gst.MemoryMapFullFunction

    function Gst.MemoryMapFullFunction(mem: Gst.Memory, info: Gst.MapInfo, maxsize: Number): {
        // javascript wrapper for 'GstMemoryMapFullFunction'
    }

Get the memory of mem that can be accessed according to the mode specified in info's flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

the Gst.MapInfo to map with

`maxsize` (Number) –

size to map

Returns (Object) –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in info's flags.

### Gst.MemoryMapFullFunction

    def Gst.MemoryMapFullFunction (mem, info, maxsize):
        #python wrapper for 'GstMemoryMapFullFunction'

Get the memory of mem that can be accessed according to the mode specified in info's flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

the Gst.MapInfo to map with

`maxsize` (int) –

size to map

Returns (object) –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in info's flags.

### GstMemoryMapFunction

    gpointer
    (*GstMemoryMapFunction) (GstMemory * mem,
                             gsize maxsize,
                             GstMapFlags flags)

Get the memory of mem that can be accessed according to the mode specified in flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` –

a GstMemory

`maxsize` –

size to map

`flags` –

access mode for the memory

Returns –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in flags.

### Gst.MemoryMapFunction

    function Gst.MemoryMapFunction(mem: Gst.Memory, maxsize: Number, flags: Gst.MapFlags): {
        // javascript wrapper for 'GstMemoryMapFunction'
    }

Get the memory of mem that can be accessed according to the mode specified in flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`maxsize` (Number) –

size to map

`flags` (Gst.MapFlags) –

access mode for the memory

Returns (Object) –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in flags.

### Gst.MemoryMapFunction

    def Gst.MemoryMapFunction (mem, maxsize, flags):
        #python wrapper for 'GstMemoryMapFunction'

Get the memory of mem that can be accessed according to the mode specified in flags. The function should return a pointer that contains at least maxsize bytes.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`maxsize` (int) –

size to map

`flags` (Gst.MapFlags) –

access mode for the memory

Returns (object) –

a pointer to memory of which at least maxsize bytes can be accessed according to the access pattern in flags.

### GstMemoryShareFunction

    GstMemory *
    (*GstMemoryShareFunction) (GstMemory * mem,
                               gssize offset,
                               gssize size)

Share size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are shared. This function does not make a copy of the bytes in mem.

Parameters:

`mem` –

a GstMemory

`offset` –

an offset

`size` –

a size or -1

Returns –

a new GstMemory object sharing the requested region in mem.

### Gst.MemoryShareFunction

    function Gst.MemoryShareFunction(mem: Gst.Memory, offset: Number, size: Number): {
        // javascript wrapper for 'GstMemoryShareFunction'
    }

Share size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are shared. This function does not make a copy of the bytes in mem.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (Number) –

an offset

`size` (Number) –

a size or -1

Returns (Gst.Memory) –

a new Gst.Memory object sharing the requested region in mem.

### Gst.MemoryShareFunction

    def Gst.MemoryShareFunction (mem, offset, size):
        #python wrapper for 'GstMemoryShareFunction'

Share size bytes from mem starting at offset and return them wrapped in a new GstMemory object. If size is set to -1, all bytes starting at offset are shared. This function does not make a copy of the bytes in mem.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`offset` (int) –

an offset

`size` (int) –

a size or -1

Returns (Gst.Memory) –

a new Gst.Memory object sharing the requested region in mem.

### GstMemoryUnmapFullFunction

    (*GstMemoryUnmapFullFunction) (GstMemory * mem,
                                   GstMapInfo * info)

Release the pointer previously retrieved with gst_memory_map with info.

Parameters:

`mem` –

a GstMemory

`info` –

a GstMapInfo

### Gst.MemoryUnmapFullFunction

    function Gst.MemoryUnmapFullFunction(mem: Gst.Memory, info: Gst.MapInfo): {
        // javascript wrapper for 'GstMemoryUnmapFullFunction'
    }

Release the pointer previously retrieved with Gst.Memory.prototype.map with info.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

a Gst.MapInfo

### Gst.MemoryUnmapFullFunction

    def Gst.MemoryUnmapFullFunction (mem, info):
        #python wrapper for 'GstMemoryUnmapFullFunction'

Release the pointer previously retrieved with Gst.Memory.map with info.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

`info` (Gst.MapInfo) –

a Gst.MapInfo

### GstMemoryUnmapFunction

    (*GstMemoryUnmapFunction) (GstMemory * mem)

Release the pointer previously retrieved with gst_memory_map.

Parameters:

`mem` –

a GstMemory

### Gst.MemoryUnmapFunction

    function Gst.MemoryUnmapFunction(mem: Gst.Memory): {
        // javascript wrapper for 'GstMemoryUnmapFunction'
    }

Release the pointer previously retrieved with Gst.Memory.prototype.map.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

### Gst.MemoryUnmapFunction

    def Gst.MemoryUnmapFunction (mem):
        #python wrapper for 'GstMemoryUnmapFunction'

Release the pointer previously retrieved with Gst.Memory.map.

Parameters:

`mem` (Gst.Memory) –

a Gst.Memory

The results of the search are