GstGLMemory

GstGLMemory — memory subclass for GL textures

Synopsis

#define             GST_GL_MEMORY_VIDEO_FORMATS_STR
struct              GstGLVideoAllocationParams;
#define             GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO
void                gst_gl_video_allocation_params_copy_data
                                                        (GstGLVideoAllocationParams *src_vid,
                                                         GstGLVideoAllocationParams *dest_vid);
void                gst_gl_video_allocation_params_free_data
                                                        (GstGLVideoAllocationParams *params);
gboolean            gst_gl_video_allocation_params_init_full
                                                        (GstGLVideoAllocationParams *params,
                                                         gsize struct_size,
                                                         guint alloc_flags,
                                                         GstGLAllocationParamsCopyFunc copy,
                                                         GstGLAllocationParamsFreeFunc free,
                                                         GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         gpointer wrapped_data,
                                                         guint gl_handle,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target);
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         gpointer wrapped_data,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         guint tex_id,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);
                    GstGLMemoryAllocator;
                    GstGLMemoryAllocatorClass;
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default
                                                        (GstGLContext *context);
void                gst_gl_memory_init_once             (void);
                    GstGLMemory;
void                gst_gl_memory_init                  (GstGLMemory *mem,
                                                         GstAllocator *allocator,
                                                         GstMemory *parent,
                                                         GstGLContext *context,
                                                         GstGLTextureTarget target,
                                                         GstAllocationParams *params,
                                                         GstVideoInfo *info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);
gboolean            gst_is_gl_memory                    (GstMemory *mem);
#define             GST_GL_MEMORY_ALLOCATOR_NAME
gboolean            gst_gl_memory_copy_into             (GstGLMemory *gl_mem,
                                                         guint tex_id,
                                                         GstGLTextureTarget target,
                                                         GstVideoGLTextureType tex_type,
                                                         gint width,
                                                         gint height);
gboolean            gst_gl_memory_copy_teximage         (GstGLMemory *src,
                                                         guint tex_id,
                                                         GstGLTextureTarget out_target,
                                                         GstVideoGLTextureType out_tex_type,
                                                         gint width,
                                                         gint height);
gboolean            gst_gl_memory_read_pixels           (GstGLMemory *gl_mem,
                                                         gpointer read_pointer);
void                gst_gl_memory_texsubimage           (GstGLMemory *gl_mem,
                                                         gpointer read_pointer);
gint                gst_gl_memory_get_texture_height    (GstGLMemory *gl_mem);
guint               gst_gl_memory_get_texture_id        (GstGLMemory *gl_mem);
GstGLTextureTarget  gst_gl_memory_get_texture_target    (GstGLMemory *gl_mem);
GstVideoGLTextureType gst_gl_memory_get_texture_type    (GstGLMemory *gl_mem);
gint                gst_gl_memory_get_texture_width     (GstGLMemory *gl_mem);
gboolean            gst_gl_memory_setup_buffer          (GstGLMemoryAllocator *allocator,
                                                         GstBuffer *buffer,
                                                         GstGLVideoAllocationParams *params);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GstObject
               +----GstAllocator
                     +----GstGLBaseMemoryAllocator
                           +----GstGLMemoryAllocator
                                 +----GstGLMemoryPBOAllocator

Description

GstGLMemory is a GstGLBaseMemory subclass providing support for the mapping of OpenGL textures.

GstGLMemory is created or wrapped through gst_gl_base_memory_alloc() with GstGLVideoAllocationParams.

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

Details

GST_GL_MEMORY_VIDEO_FORMATS_STR

#define             GST_GL_MEMORY_VIDEO_FORMATS_STR

struct GstGLVideoAllocationParams

struct GstGLVideoAllocationParams {
  GstGLAllocationParams  parent;

  GstVideoInfo          *v_info;
  guint                  plane;
  GstVideoAlignment     *valign;
  GstGLTextureTarget     target;
};

GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO

#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO (1 << 3)

gst_gl_video_allocation_params_copy_data ()

void                gst_gl_video_allocation_params_copy_data
                                                        (GstGLVideoAllocationParams *src_vid,
                                                         GstGLVideoAllocationParams *dest_vid);

Copy and set any dynamically allocated resources in dest_vid. Intended for subclass usage only to chain up at the end of a subclass copy function.

src_vid :

source GstGLVideoAllocationParams to copy from

dest_vid :

destination GstGLVideoAllocationParams to copy into

Since 1.8


gst_gl_video_allocation_params_free_data ()

void                gst_gl_video_allocation_params_free_data
                                                        (GstGLVideoAllocationParams *params);

Unset and free any dynamically allocated resources. Intended for subclass usage only to chain up at the end of a subclass free function.

Since 1.8


gst_gl_video_allocation_params_init_full ()

gboolean            gst_gl_video_allocation_params_init_full
                                                        (GstGLVideoAllocationParams *params,
                                                         gsize struct_size,
                                                         guint alloc_flags,
                                                         GstGLAllocationParamsCopyFunc copy,
                                                         GstGLAllocationParamsFreeFunc free,
                                                         GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         gpointer wrapped_data,
                                                         guint gl_handle,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);

Intended for subclass usage

params :

a GstGLVideoAllocationParams to initialize

struct_size :

the size of the struct in params

alloc_flags :

some allocation flags

copy :

a copy function

free :

a free function

context :

a GstGLContext

alloc_params :

the GstAllocationParams for wrapped_data. [allow-none]

v_info :

the GstVideoInfo for wrapped_data

plane :

the video plane wrapped_data represents

valign :

any GstVideoAlignment applied to symem mappings of wrapped_data. [allow-none]

target :

the GstGLTextureTarget

wrapped_data :

the optional data pointer to wrap. [allow-none]

gl_handle :

the optional OpenGL handle to wrap or 0

user_data :

user data to call notify with. [allow-none]

notify :

a GDestroyNotify. [allow-none]

Returns :

initializes params with the parameters specified

Since 1.8


gst_gl_video_allocation_params_new ()

GstGLVideoAllocationParams * gst_gl_video_allocation_params_new
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target);

context :

a GstGLContext

alloc_params :

the GstAllocationParams for wrapped_data. [allow-none]

v_info :

the GstVideoInfo for wrapped_data

plane :

the video plane wrapped_data represents

valign :

any GstVideoAlignment applied to symem mappings of wrapped_data. [allow-none]

target :

the GstGLTextureTarget for wrapped_data

Returns :

a new GstGLVideoAllocationParams for allocating GstGLMemory's

Since 1.8


gst_gl_video_allocation_params_new_wrapped_data ()

GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         gpointer wrapped_data,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);

context :

a GstGLContext

alloc_params :

the GstAllocationParams for wrapped_data. [allow-none]

v_info :

the GstVideoInfo for wrapped_data

plane :

the video plane wrapped_data represents

valign :

any GstVideoAlignment applied to symem mappings of wrapped_data. [allow-none]

target :

the GstGLTextureTarget for wrapped_data

wrapped_data :

the data pointer to wrap

user_data :

user data to call notify with. [allow-none]

notify :

a GDestroyNotify. [allow-none]

Returns :

a new GstGLVideoAllocationParams for wrapping wrapped_data

Since 1.8


gst_gl_video_allocation_params_new_wrapped_texture ()

GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture
                                                        (GstGLContext *context,
                                                         GstAllocationParams *alloc_params,
                                                         GstVideoInfo *v_info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         GstGLTextureTarget target,
                                                         guint tex_id,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);

context :

a GstGLContext

alloc_params :

the GstAllocationParams for tex_id. [allow-none]

v_info :

the GstVideoInfo for tex_id

plane :

the video plane tex_id represents

valign :

any GstVideoAlignment applied to symem mappings of tex_id. [allow-none]

target :

the GstGLTextureTarget for tex_id

tex_id :

the GL texture to wrap

user_data :

user data to call notify with. [allow-none]

notify :

a GDestroyNotify. [allow-none]

Returns :

a new GstGLVideoAllocationParams for wrapping tex_id

Since 1.8


GstGLMemoryAllocator

typedef struct _GstGLMemoryAllocator GstGLMemoryAllocator;

Opaque GstGLMemoryAllocator struct


GstGLMemoryAllocatorClass

typedef struct {
  GstGLBaseMemoryAllocatorClass             parent_class;

  GstGLBaseMemoryAllocatorMapFunction       map;
  GstGLBaseMemoryAllocatorCopyFunction      copy;
  GstGLBaseMemoryAllocatorUnmapFunction     unmap;
} GstGLMemoryAllocatorClass;

The GstGLMemoryAllocatorClass only contains private data


gst_gl_memory_allocator_get_default ()

GstGLMemoryAllocator * gst_gl_memory_allocator_get_default
                                                        (GstGLContext *context);

context :

a GstGLContext

Returns :

the default GstGLMemoryAllocator supported by context

Since 1.8


gst_gl_memory_init_once ()

void                gst_gl_memory_init_once             (void);

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

Since 1.4


GstGLMemory

typedef struct {
  GstGLBaseMemory           mem;

  guint                     tex_id;
  GstGLTextureTarget        tex_target;
  GstVideoGLTextureType     tex_type;
  GstVideoInfo              info;
  GstVideoAlignment         valign;
  guint                     plane;
  gfloat                    tex_scaling[2];
} GstGLMemory;

Represents information about a GL texture

GstGLBaseMemory mem;

the parent object

guint tex_id;

the GL texture id for this memory

GstGLTextureTarget tex_target;

the GL texture target for this memory

GstVideoGLTextureType tex_type;

the texture type

GstVideoInfo info;

the texture's GstVideoInfo

GstVideoAlignment valign;

data alignment for system memory mapping

guint plane;

data plane in info

gfloat tex_scaling[2];

GL shader scaling parameters for valign and/or width/height

gst_gl_memory_init ()

void                gst_gl_memory_init                  (GstGLMemory *mem,
                                                         GstAllocator *allocator,
                                                         GstMemory *parent,
                                                         GstGLContext *context,
                                                         GstGLTextureTarget target,
                                                         GstAllocationParams *params,
                                                         GstVideoInfo *info,
                                                         guint plane,
                                                         GstVideoAlignment *valign,
                                                         gpointer user_data,
                                                         GDestroyNotify notify);

Initializes mem with the required parameters. info is assumed to have already have been modified with gst_video_info_align().

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

target :

the GstGLTextureTarget for this GstGLMemory

params :

the GstAllocationParams to initialize with. [allow-none]

info :

the GstVideoInfo for this GstGLMemory

plane :

the plane number (starting from 0) for this GstGLMemory

valign :

optional GstVideoAlignment parameters. [allow-none]

notify :

a GDestroyNotify. [allow-none]

user_data :

user data to call notify with. [allow-none]

Since 1.8


gst_is_gl_memory ()

gboolean            gst_is_gl_memory                    (GstMemory *mem);

mem :

a GstMemory

Returns :

whether the memory at mem is a GstGLMemory

Since 1.4


GST_GL_MEMORY_ALLOCATOR_NAME

#define GST_GL_MEMORY_ALLOCATOR_NAME   "GLMemory"

The name of the GL memory allocator


gst_gl_memory_copy_into ()

gboolean            gst_gl_memory_copy_into             (GstGLMemory *gl_mem,
                                                         guint tex_id,
                                                         GstGLTextureTarget target,
                                                         GstVideoGLTextureType tex_type,
                                                         gint width,
                                                         gint height);

Copies gl_mem into the texture specfified by tex_id. The format of tex_id is specified by tex_type, width and height.

gl_mem :

a GstGLMemory

tex_id :

OpenGL texture id

target :

the GstGLTextureTarget

tex_type :

the GstVideoGLTextureType

width :

width of tex_id

height :

height of tex_id

Returns :

Whether the copy suceeded

Since 1.8


gst_gl_memory_copy_teximage ()

gboolean            gst_gl_memory_copy_teximage         (GstGLMemory *src,
                                                         guint tex_id,
                                                         GstGLTextureTarget out_target,
                                                         GstVideoGLTextureType out_tex_type,
                                                         gint width,
                                                         gint height);

gst_gl_memory_read_pixels ()

gboolean            gst_gl_memory_read_pixels           (GstGLMemory *gl_mem,
                                                         gpointer read_pointer);

Reads the texture in GstGLMemory into read_pointer if no buffer is bound to GL_PIXEL_PACK_BUFFER. Otherwise read_pointer is the byte offset into the currently bound GL_PIXEL_PACK_BUFFER buffer to store the result of glReadPixels. See the OpenGL specification for glReadPixels for more details.

gl_mem :

a GstGLMemory

read_pointer :

the data pointer to pass to glReadPixels

Returns :

whether theread operation succeeded

Since 1.8


gst_gl_memory_texsubimage ()

void                gst_gl_memory_texsubimage           (GstGLMemory *gl_mem,
                                                         gpointer read_pointer);

See gst_gl_memory_read_pixels() for what read_pointer signifies.

gl_mem :

a GstGLMemory

read_pointer :

the data pointer to pass to glTexSubImage

Since 1.8


gst_gl_memory_get_texture_height ()

gint                gst_gl_memory_get_texture_height    (GstGLMemory *gl_mem);

gl_mem :

a GstGLMemory

Returns :

the texture height of gl_mem

Since 1.8


gst_gl_memory_get_texture_id ()

guint               gst_gl_memory_get_texture_id        (GstGLMemory *gl_mem);

gl_mem :

a GstGLMemory

Returns :

the OpenGL texture handle of gl_mem

Since 1.8


gst_gl_memory_get_texture_target ()

GstGLTextureTarget  gst_gl_memory_get_texture_target    (GstGLMemory *gl_mem);

gl_mem :

a GstGLMemory

Returns :

the GstGLTextureTarget of gl_mem

Since 1.8


gst_gl_memory_get_texture_type ()

GstVideoGLTextureType gst_gl_memory_get_texture_type    (GstGLMemory *gl_mem);

gl_mem :

a GstGLMemory

Returns :

the GstVideoGLTextureType of gl_mem

Since 1.8


gst_gl_memory_get_texture_width ()

gint                gst_gl_memory_get_texture_width     (GstGLMemory *gl_mem);

gl_mem :

a GstGLMemory

Returns :

the texture width of gl_mem

Since 1.8


gst_gl_memory_setup_buffer ()

gboolean            gst_gl_memory_setup_buffer          (GstGLMemoryAllocator *allocator,
                                                         GstBuffer *buffer,
                                                         GstGLVideoAllocationParams *params);

allocator :

the GstGLMemoryAllocator to allocate from

buffer :

a GstBuffer to setup

params :

the GstGLVideoAllocationParams to allocate with

Returns :

whether the buffer was correctly setup

Since 1.8

See Also

GstMemory, GstAllocator, GstGLBufferPool