GstGlBaseMemory

## GstGlBaseMemory GstGlBaseMemory — memory subclass for GL buffers |

## Functions

void | (*GstGLAllocationParamsCopyFunc) ()
void | (*GstGLAllocationParamsFreeFunc) ()
gboolean | gst_gl_allocation_params_init ()
GstGLAllocationParams * | gst_gl_allocation_params_copy ()
void | gst_gl_allocation_params_free ()
void | gst_gl_allocation_params_free_data ()
void | gst_gl_allocation_params_copy_data ()
void | gst_gl_base_memory_init_once ()
void | gst_gl_base_memory_init ()
gboolean | gst_is_gl_base_memory ()
GstGLBaseMemory * | (*GstGLBaseMemoryAllocatorAllocFunction) ()
gboolean | (*GstGLBaseMemoryAllocatorCreateFunction) ()
gpointer | (*GstGLBaseMemoryAllocatorMapFunction) ()
void | (*GstGLBaseMemoryAllocatorUnmapFunction) ()
GstGLBaseMemory * | (*GstGLBaseMemoryAllocatorCopyFunction) ()
void | (*GstGLBaseMemoryAllocatorDestroyFunction) ()
GstGLBaseMemory * | gst_gl_base_memory_alloc ()
gboolean | gst_gl_base_memory_alloc_data ()
gboolean | gst_gl_base_memory_memcpy ()

## Types and Values

| GstGLBaseMemoryAllocator
| GstGLBaseMemoryAllocatorClass
#define | GST_GL_BASE_MEMORY_ALLOCATOR_NAME
#define | GST_MAP_GL
enum | GstGLBaseMemoryError
#define | GST_GL_BASE_MEMORY_ERROR
enum | GstGLBaseMemoryTransfer
struct | GstGLAllocationParams
#define | GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC
#define | GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM
#define | GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE
#define | GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER
| GstGLBaseMemory

## Object Hierarchy

        GBoxed
        ╰── GstGLAllocationParams
        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstAllocator
                    ╰── GstGLBaseMemoryAllocator
                        ├── GstGLBufferAllocator
                        ├── GstGLMemoryAllocator
                        ╰── GstGLRenderbufferAllocator

## Includes

    #include <gst/codecparsers/gstmpeg4parser.h>

## Description

GstGLBaseMemory is a GstMemory subclass providing the basis of support for the mapping of GL buffers.

Data is uploaded or downloaded from the GPU as is necessary.

## Functions

### GstGLAllocationParamsCopyFunc ()

    void
    (*GstGLAllocationParamsCopyFunc) (GstGLAllocationParams *src,
                                      GstGLAllocationParams *dest);

Copies the parameters from `src` into `dest` . The subclass must compose copy functions from the superclass.

#### Parameters

src | the source GstGLAllocationParams to copy from |
dest | the source GstGLAllocationParams to copy |

### GstGLAllocationParamsFreeFunc ()

    void
    (*GstGLAllocationParamsFreeFunc) (gpointer params);

Free any dynamically allocated data. The subclass must call the superclass' free.

#### Parameters

params | a GstGLAllocationParams |

### gst_gl_allocation_params_init ()

    gboolean
    gst_gl_allocation_params_init (GstGLAllocationParams *params,
                                   gsize struct_size,
                                   guint alloc_flags,
                                   GstGLAllocationParamsCopyFunc copy,
                                   GstGLAllocationParamsFreeFunc free,
                                   GstGLContext *context,
                                   gsize alloc_size,
                                   GstAllocationParams *alloc_params,
                                   gpointer wrapped_data,
                                   gpointer gl_handle,
                                   gpointer user_data,
                                   GDestroyNotify notify);

`notify` will be called once for each allocated memory using these `params` when freeing the memory.

#### Parameters

params | the GstGLAllocationParams to initialize |
struct_size | the struct size of the implementation |
alloc_flags | some alloc flags |
copy | a copy function |
free | a free function |
context | a GstGLContext. | [transfer none]
alloc_size | the number of bytes to allocate. |
alloc_params | a GstAllocationParams to apply. | [transfer none][allow-none]
wrapped_data | a sysmem data pointer to initialize the allocation with. | [transfer none][allow-none]
gl_handle | a GL handle to initialize the allocation with. | [transfer none]
user_data | user data to call `notify` with. | [transfer none][allow-none]
notify | a GDestroyNotify. | [allow-none]

#### Returns

whether the paramaters could be initialized

Since: 1.8

### gst_gl_allocation_params_copy ()

    GstGLAllocationParams *
    gst_gl_allocation_params_copy (GstGLAllocationParams *src);

#### Parameters

src | the GstGLAllocationParams to initialize |

#### Returns

a copy of the GstGLAllocationParams specified by `src` or `NULL` on failure.

[transfer full]

Since: 1.8

### gst_gl_allocation_params_free ()

    void
    gst_gl_allocation_params_free (GstGLAllocationParams *params);

Frees the GstGLAllocationParams and all associated data.

#### Parameters

params | the GstGLAllocationParams to initialize |

Since: 1.8

### gst_gl_allocation_params_free_data ()

    void
    gst_gl_allocation_params_free_data (GstGLAllocationParams *params);

Frees the dynamically allocated data in `params` . Direct subclasses should call this function in their own overriden free function.

#### Parameters

params | the source GstGLAllocationParams |

Since: 1.8

### gst_gl_allocation_params_copy_data ()

    void
    gst_gl_allocation_params_copy_data (GstGLAllocationParams *src,
                                        GstGLAllocationParams *dest);

Copies the dynamically allocated data from `src` to `dest` . Direct subclasses should call this function in their own overriden copy function.

#### Parameters

src | the source GstGLAllocationParams |
dest | the destination GstGLAllocationParams |

Since: 1.8

### gst_gl_base_memory_init_once ()

    void
    gst_gl_base_memory_init_once (void);

Initializes the GL Base Memory allocator. It is safe to call this function multiple times. This must be called before any other GstGLBaseMemory operation.

Since: 1.8

### gst_gl_base_memory_init ()

    void
    gst_gl_base_memory_init (GstGLBaseMemory *mem,
                             GstAllocator *allocator,
                             GstMemory *parent,
                             GstGLContext *context,
                             GstAllocationParams *params,
                             gsize size,
                             gpointer user_data,
                             GDestroyNotify notify);

Initializes `mem` with the required parameters

#### Parameters

mem | the GstGLBaseMemory to initialize |
allocator | the GstAllocator to initialize with |
parent | the parent GstMemory to initialize with. | [allow-none]
context | the GstGLContext to initialize with |
params | the `GstAllocationParams` to initialize with. | [allow-none]
size | the number of bytes to be allocated |
user_data | user data to call `notify` with. | [allow-none]
notify | a GDestroyNotify. | [allow-none]

Since: 1.8

### gst_is_gl_base_memory ()

    gboolean
    gst_is_gl_base_memory (GstMemory *mem);

#### Parameters

mem | a GstMemory |

#### Returns

whether the memory at `mem` is a GstGLBaseMemory

Since: 1.8

### GstGLBaseMemoryAllocatorAllocFunction ()

    GstGLBaseMemory *
    (*GstGLBaseMemoryAllocatorAllocFunction)
                                   (GstGLBaseMemoryAllocator *allocator,
                                    GstGLAllocationParams *params);

Note: not called with a GL context current

#### Parameters

allocator | a GstGLBaseMemoryAllocator |
params | the GstGLAllocationParams to allocate the memory with |

#### Returns

a newly allocated GstGLBaseMemory from `allocator` and `params`

Since: 1.8

### GstGLBaseMemoryAllocatorCreateFunction ()

    gboolean
    (*GstGLBaseMemoryAllocatorCreateFunction)
                                   (GstGLBaseMemory *mem,
                                    GError **error);

As this virtual method is called with an OpenGL context current, use this function to allocate and OpenGL resources needed for your application

#### Parameters

mem | a GstGLBaseMemory |
error | a GError to use on failure |

#### Returns

whether the creation succeeded

Since: 1.8

### GstGLBaseMemoryAllocatorMapFunction ()

    gpointer
    (*GstGLBaseMemoryAllocatorMapFunction)
                                   (GstGLBaseMemory *mem,
                                    GstMapInfo *info,
                                    gsize maxsize);

Also see `gst_memory_map()`;

#### Parameters

mem | a GstGLBaseMemory |
info | a GstMapInfo to map with |
maxsize | the size to map |

#### Returns

the mapped pointer

Since: 1.8

### GstGLBaseMemoryAllocatorUnmapFunction ()

    void
    (*GstGLBaseMemoryAllocatorUnmapFunction)
                                   (GstGLBaseMemory *mem,
                                    GstMapInfo *info);

Also see `gst_memory_unmap()`;

#### Parameters

mem | a GstGLBaseMemory |
info | a GstMapInfo to map with |

Since: 1.8

### GstGLBaseMemoryAllocatorCopyFunction ()

    GstGLBaseMemory *
    (*GstGLBaseMemoryAllocatorCopyFunction)
                                   (GstGLBaseMemory *mem,
                                    gssize offset,
                                    gssize size);

Also see `gst_memory_copy()`;

#### Parameters

mem | a GstGLBaseMemory |
offset | the offset to copy from |
size | the number of bytes to copy |

#### Returns

the newly copied GstGLMemory or `NULL`

Since: 1.8

### GstGLBaseMemoryAllocatorDestroyFunction ()

    void
    (*GstGLBaseMemoryAllocatorDestroyFunction)
                                   (GstGLBaseMemory *mem);

Destroy any resources allocated throughout the lifetime of `mem`

#### Parameters

mem | a GstGLBaseMemory |

Since: 1.8

### gst_gl_base_memory_alloc ()

    GstGLBaseMemory *
    gst_gl_base_memory_alloc (GstGLBaseMemoryAllocator *allocator,
                              GstGLAllocationParams *params);

#### Parameters

allocator | a GstGLBaseMemoryAllocator |
params | the GstGLAllocationParams to allocate the memory with |

#### Returns

a new GstGLBaseMemory from `allocator` with the requested `params` .

Since: 1.8

### gst_gl_base_memory_alloc_data ()

    gboolean
    gst_gl_base_memory_alloc_data (GstGLBaseMemory *gl_mem);

### gst_gl_base_memory_memcpy ()

    gboolean
    gst_gl_base_memory_memcpy (GstGLBaseMemory *src,
                               GstGLBaseMemory *dest,
                               gssize offset,
                               gssize size);

#### Parameters

src | the source GstGLBaseMemory |
dest | the destination GstGLBaseMemory |
offset | the offset to start at |
size | the number of bytes to copy |

#### Returns

whether the copy suceeded.

Since: 1.8

## Types and Values

### GstGLBaseMemoryAllocator

    typedef struct _GstGLBaseMemoryAllocator GstGLBaseMemoryAllocator;

Opaque GstGLBaseMemoryAllocator struct

Since: 1.8

### GstGLBaseMemoryAllocatorClass

    typedef struct {
      GstAllocatorClass parent_class;

      GstGLBaseMemoryAllocatorAllocFunction         alloc;

      GstGLBaseMemoryAllocatorCreateFunction        create;
      GstGLBaseMemoryAllocatorMapFunction           map;
      GstGLBaseMemoryAllocatorUnmapFunction         unmap;
      GstGLBaseMemoryAllocatorCopyFunction          copy;
      GstGLBaseMemoryAllocatorDestroyFunction       destroy;
    } GstGLBaseMemoryAllocatorClass;

#### Members

GstGLBaseMemoryAllocatorAllocFunction `alloc`; | a GstGLBaseMemoryAllocatorAllocFunction |
GstGLBaseMemoryAllocatorCreateFunction `create`; | a GstGLBaseMemoryAllocatorCreateFunction |
GstGLBaseMemoryAllocatorMapFunction `map`; | a GstGLBaseMemoryAllocatorMapFunction |
GstGLBaseMemoryAllocatorUnmapFunction `unmap`; | a GstGLBaseMemoryAllocatorUnmapFunction |
GstGLBaseMemoryAllocatorCopyFunction `copy`; | a GstGLBaseMemoryAllocatorCopyFunction |
GstGLBaseMemoryAllocatorDestroyFunction `destroy`; | a GstGLBaseMemoryAllocatorDestroyFunction |

Since: 1.8

### GST_GL_BASE_MEMORY_ALLOCATOR_NAME

    #define GST_GL_BASE_MEMORY_ALLOCATOR_NAME   "GLBaseMemory"

The name of the GL buffer allocator

Since: 1.8

### GST_MAP_GL

    #define GST_MAP_GL (GST_MAP_FLAG_LAST << 1)

Flag indicating that we should map the GL object instead of to system memory.

Combining GST_MAP_GL with GST_MAP_WRITE has the same semantics as though you are writing to OpenGL. Conversely, combining GST_MAP_GL with GST_MAP_READ has the same semantics as though you are reading from OpenGL.

### enum GstGLBaseMemoryError

#### Members

GST_GL_BASE_MEMORY_ERROR_FAILED | generic faliure |
GST_GL_BASE_MEMORY_ERROR_OLD_LIBS | the implementation is too old and doesn't implement enough features |
GST_GL_BASE_MEMORY_ERROR_RESOURCE_UNAVAILABLE | a resource could not be found |

### GST_GL_BASE_MEMORY_ERROR

    #define GST_GL_BASE_MEMORY_ERROR (gst_gl_base_memory_error_quark ())

### enum GstGLBaseMemoryTransfer

#### Members

GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD | the texture needs downloading to the data pointer |
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD | the data pointer needs uploading to the texture |

### struct GstGLAllocationParams

    struct GstGLAllocationParams {
      gsize                             struct_size;
      GstGLAllocationParamsCopyFunc     copy;
      GstGLAllocationParamsFreeFunc     free;

      guint                             alloc_flags;
      gsize                             alloc_size;
      GstAllocationParams              *alloc_params;
      GstGLContext                     *context;
      GDestroyNotify                    notify;
      gpointer                          user_data;

      /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM only */
      gpointer                          wrapped_data;
      /* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE only */
      gpointer                          gl_handle;
    };

#### Members

gsize `struct_size`; | the size of the struct (including and subclass data) |
GstGLAllocationParamsCopyFunc `copy`; | a GstGLAllocationParamsCopyFunc |
GstGLAllocationParamsFreeFunc `free`; | a GstGLAllocationParamsFreeFunc |
guint `alloc_flags`; | allocation flags |
gsize `alloc_size`; | the allocation size |
GstAllocationParams *`alloc_params`; | the GstAllocationParams |
GstGLContext *`context`; | a GstGLContext |
GDestroyNotify `notify`; | a GDestroyNotify |
gpointer `user_data`; | argument to call `notify` with |
gpointer `wrapped_data`; | the wrapped data pointer |
gpointer `gl_handle`; | the wrapped OpenGL handle |

### GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC

    #define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_ALLOC (1 << 0)

### GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM

    #define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_SYSMEM (1 << 1)

### GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE

    #define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_WRAP_GPU_HANDLE (1 << 2)

### GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER

    #define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_USER (1 << 16)

### GstGLBaseMemory

    typedef struct {
      GstMemory             mem;

      GstGLContext         *context;
    } GstGLBaseMemory;

Represents information about a GL memory object

#### Members

GstMemory `mem`; | the parent object |
GstGLContext *`context`; | the GstGLContext to use for GL operations |

## See Also

GstMemory, GstAllocator