From f7709826353cb0b3bc59eda16414a046f55f8144 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 18 Mar 2021 14:20:34 +1100 Subject: [PATCH] glupload: guard against glEGLImageTexture2D not existing e.g. if targetting EGL/opengl, we would attempt to use this GLES function when wrapping EGLImage's. Part-of: --- gst-libs/gst/gl/egl/gstglmemoryegl.c | 7 +++++++ gst-libs/gst/gl/gstglupload.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gst-libs/gst/gl/egl/gstglmemoryegl.c b/gst-libs/gst/gl/egl/gstglmemoryegl.c index 15a57bd..b4a308e 100644 --- a/gst-libs/gst/gl/egl/gstglmemoryegl.c +++ b/gst-libs/gst/gl/egl/gstglmemoryegl.c @@ -203,6 +203,13 @@ _gl_mem_create (GstGLMemoryEGL * gl_mem, GError ** error) } else { guint gl_target = gst_gl_texture_target_to_gl (gl_mem->mem.tex_target); + if (!gl->EGLImageTargetTexture2D) { + g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED, + "Required function glEGLImageTargetTexture2D() is not available for " + "attaching an EGLImage to a texture"); + return FALSE; + } + gl->ActiveTexture (GL_TEXTURE0 + gl_mem->mem.plane); gl->BindTexture (gl_target, gl_mem->mem.tex_id); gl->EGLImageTargetTexture2D (gl_target, diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c index 71e7068..f23e479 100644 --- a/gst-libs/gst/gl/gstglupload.c +++ b/gst-libs/gst/gl/gstglupload.c @@ -27,6 +27,7 @@ #include "gl.h" #include "gstglupload.h" +#include "gstglfuncs.h" #if GST_GL_HAVE_PLATFORM_EGL #include "egl/gsteglimage.h" @@ -525,6 +526,11 @@ _dma_buf_upload_transform_caps (gpointer impl, GstGLContext * context, GstCaps *ret; if (context) { + const GstGLFuncs *gl = context->gl_vtable; + + if (!gl->EGLImageTargetTexture2D) + return NULL; + /* Don't propose DMABuf caps feature unless it can be supported */ if (gst_gl_context_get_gl_platform (context) != GST_GL_PLATFORM_EGL) return NULL; @@ -625,6 +631,9 @@ _dma_buf_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps, n_mem = gst_buffer_n_memory (buffer); meta = gst_buffer_get_video_meta (buffer); + if (!dmabuf->upload->context->gl_vtable->EGLImageTargetTexture2D) + return FALSE; + /* dmabuf upload is only supported with EGL contexts. */ if (gst_gl_context_get_gl_platform (dmabuf->upload->context) != GST_GL_PLATFORM_EGL) @@ -834,6 +843,11 @@ _direct_dma_buf_upload_transform_caps (gpointer impl, GstGLContext * context, GstCaps *ret; if (context) { + const GstGLFuncs *gl = context->gl_vtable; + + if (!gl->EGLImageTargetTexture2D) + return NULL; + /* Don't propose direct DMABuf caps feature unless it can be supported */ if (gst_gl_context_get_gl_platform (context) != GST_GL_PLATFORM_EGL) return NULL; -- 2.7.4