plugins: handle EGL when creating VAAPI display from gl

If GstGL reports a EGL platform force to create a EGL display using
the native EGL display.

https://bugzilla.gnome.org/show_bug.cgi?id=795391
This commit is contained in:
Víctor Manuel Jáquez Leal 2018-04-27 18:34:37 +02:00
parent 50470ae89f
commit e62f3d75cf

View file

@ -143,7 +143,7 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
gpointer native_display = gpointer native_display =
GSIZE_TO_POINTER (gst_gl_display_get_handle (gl_display)); GSIZE_TO_POINTER (gst_gl_display_get_handle (gl_display));
GstGLPlatform platform = gst_gl_context_get_gl_platform (gl_context); GstGLPlatform platform = gst_gl_context_get_gl_platform (gl_context);
GstVaapiDisplay *display, *out_display = NULL; GstVaapiDisplay *display = NULL, *out_display = NULL;
GstVaapiDisplayType display_type; GstVaapiDisplayType display_type;
switch (gst_gl_display_get_handle_type (gl_display)) { switch (gst_gl_display_get_handle_type (gl_display)) {
@ -162,11 +162,18 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
case GST_GL_DISPLAY_TYPE_WAYLAND: case GST_GL_DISPLAY_TYPE_WAYLAND:
display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
break; break;
#endif
#if USE_EGL
case GST_GL_DISPLAY_TYPE_EGL:
display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
goto egl_display;
break;
#endif #endif
case GST_GL_DISPLAY_TYPE_ANY:{ case GST_GL_DISPLAY_TYPE_ANY:{
/* Derive from the active window */ /* Derive from the active window */
GstGLWindow *const gl_window = gst_gl_context_get_window (gl_context); GstGLWindow *const gl_window = gst_gl_context_get_window (gl_context);
const gchar *const gl_window_type = g_getenv ("GST_GL_WINDOW"); const gchar *const gl_window_type = g_getenv ("GST_GL_WINDOW");
const gchar *const gl_platform_type = g_getenv ("GST_GL_PLATFORM");
display_type = GST_VAAPI_DISPLAY_TYPE_ANY; display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
if (!gl_window) if (!gl_window)
@ -181,6 +188,10 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
#if USE_WAYLAND #if USE_WAYLAND
if (!display_type && g_strcmp0 (gl_window_type, "wayland") == 0) if (!display_type && g_strcmp0 (gl_window_type, "wayland") == 0)
display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
#endif
#if USE_EGL
if (!display_type && g_strcmp0 (gl_platform_type, "egl") == 0)
display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
#endif #endif
} else { } else {
#if USE_X11 && GST_GL_HAVE_WINDOW_X11 #if USE_X11 && GST_GL_HAVE_WINDOW_X11
@ -189,9 +200,15 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
#elif USE_WAYLAND && GST_GL_HAVE_WINDOW_WAYLAND #elif USE_WAYLAND && GST_GL_HAVE_WINDOW_WAYLAND
if (!display_type) if (!display_type)
display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
#elif USE_EGL && GST_GL_HAVE_PLATFORM_EGL
if (!display_type)
display_type = GST_VAAPI_DISPLAY_TYPE_EGL;
#endif #endif
} }
gst_object_unref (gl_window); gst_object_unref (gl_window);
if (display_type == GST_VAAPI_DISPLAY_TYPE_EGL)
goto egl_display;
break; break;
} }
default: default:
@ -203,6 +220,7 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
if (!display) if (!display)
goto bail; goto bail;
egl_display:
switch (platform) { switch (platform) {
#if USE_EGL #if USE_EGL
case GST_GL_PLATFORM_EGL:{ case GST_GL_PLATFORM_EGL:{
@ -233,7 +251,7 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
out_display = out_display =
gst_vaapi_display_egl_new_with_native_display gst_vaapi_display_egl_new_with_native_display
(GSIZE_TO_POINTER (egl_handle), display_type, gles_version); (GSIZE_TO_POINTER (egl_handle), display_type, gles_version);
} else { } else if (display) {
out_display = gst_vaapi_display_egl_new (display, gles_version); out_display = gst_vaapi_display_egl_new (display, gles_version);
} }
break; break;