static void _gl_mem_destroy (GstGLMemoryEGL * mem) { if (mem->image) gst_egl_image_unref (mem->image); GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class)->destroy ((GstGLBaseMemory *) mem); }
static void _gl_mem_destroy (GstGLMemoryPBO * gl_mem) { if (gl_mem->pbo) gst_memory_unref (GST_MEMORY_CAST (gl_mem->pbo)); gl_mem->pbo = NULL; GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class)->destroy ((GstGLBaseMemory *) gl_mem); }
static void _ios_gl_memory_destroy (GstGLBaseMemory * gl_mem) { GstIOSGLMemory *mem = (GstIOSGLMemory *) gl_mem; mem->gl_notify (mem->gl_data); gst_memory_unref (GST_MEMORY_CAST (mem->cv_mem)); GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (gst_ios_gl_memory_allocator_parent_class)->destroy (gl_mem); }
static gboolean _gl_mem_create (GstGLMemoryEGL * gl_mem, GError ** error) { GstGLContext *context = gl_mem->mem.mem.context; GstGLContextEGL *ctx_egl = GST_GL_CONTEXT_EGL (context); const GstGLFuncs *gl = context->gl_vtable; GstGLBaseMemoryAllocatorClass *alloc_class; if (!gst_gl_context_check_feature (GST_GL_CONTEXT (context), "EGL_KHR_image_base")) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API, "EGL_KHR_image_base is not supported"); return FALSE; } alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class); if (!alloc_class->create ((GstGLBaseMemory *) gl_mem, error)) return FALSE; if (gl_mem->image == NULL) { EGLImageKHR image = ctx_egl->eglCreateImageKHR (ctx_egl->egl_display, ctx_egl->egl_context, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer) (guintptr) gl_mem->mem.tex_id, NULL); GST_TRACE ("Generating EGLImage handle:%p from a texture:%u", gl_mem->image, gl_mem->mem.tex_id); if (eglGetError () != EGL_SUCCESS) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED, "Failed to create EGLImage"); return FALSE; } gl_mem->image = gst_egl_image_new_wrapped (context, image, 0, 0, NULL, (GstEGLImageDestroyNotify) _destroy_egl_image); } else { gl->ActiveTexture (GL_TEXTURE0 + gl_mem->mem.plane); gl->BindTexture (GL_TEXTURE_2D, gl_mem->mem.tex_id); gl->EGLImageTargetTexture2D (GL_TEXTURE_2D, gst_egl_image_get_image (GST_EGL_IMAGE (gl_mem->image))); } return TRUE; }
static gboolean _gl_mem_create (GstGLMemoryPBO * gl_mem, GError ** error) { GstGLContext *context = gl_mem->mem.mem.context; GstGLBaseMemoryAllocatorClass *alloc_class; alloc_class = GST_GL_BASE_MEMORY_ALLOCATOR_CLASS (parent_class); if (!alloc_class->create ((GstGLBaseMemory *) gl_mem, error)) return FALSE; if (CONTEXT_SUPPORTS_PBO_DOWNLOAD (context) || CONTEXT_SUPPORTS_PBO_UPLOAD (context)) { GstAllocationParams alloc_params = { 0, GST_MEMORY_CAST (gl_mem)->align, 0, 0 }; GstGLBaseMemoryAllocator *buf_allocator; GstGLBufferAllocationParams *params; buf_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find (GST_GL_BUFFER_ALLOCATOR_NAME)); params = gst_gl_buffer_allocation_params_new (context, GST_MEMORY_CAST (gl_mem)->size, &alloc_params, GL_PIXEL_UNPACK_BUFFER, GL_STREAM_DRAW); /* FIXME: lazy init this for resource constrained platforms * Will need to fix pbo detection based on the existence of the mem.id then */ gl_mem->pbo = (GstGLBuffer *) gst_gl_base_memory_alloc (buf_allocator, (GstGLAllocationParams *) params); gst_gl_allocation_params_free ((GstGLAllocationParams *) params); gst_object_unref (buf_allocator); GST_CAT_LOG (GST_CAT_GL_MEMORY, "generated pbo %u", gl_mem->pbo->id); } return TRUE; }