GstVaapiDisplay * video_output_create_display (const gchar * display_name) { const VideoOutputInfo *o = g_video_output; GstVaapiDisplay *egl_display, *display = NULL; if (!o) { if (g_output_name) o = video_output_lookup (g_output_name); else { for (o = g_video_outputs; o->name != NULL; o++) { display = o->create_display (display_name); if (display) { if (gst_vaapi_display_get_display (display)) break; gst_vaapi_display_unref (display); display = NULL; } } } if (!o || !o->name) return NULL; g_print ("Using %s video output\n", o->name); g_video_output = o; } if (!display) display = o->create_display (display_name); if (g_egl_mode) { #if USE_EGL egl_display = gst_vaapi_display_egl_new (display, g_gles_version); #else egl_display = NULL; g_print ("error: unsupported EGL renderering mode\n"); #endif gst_vaapi_display_unref (display); if (!egl_display) return NULL; display = egl_display; } return display; }
static GstVaapiDisplay * gst_vaapi_create_display_from_egl (GstGLDisplay * gl_display, GstGLContext * gl_context, GstVaapiDisplayType display_type, gpointer native_display) { GstVaapiDisplay *display = NULL; #if USE_EGL GstGLAPI gl_api; gint gles_version; guintptr egl_handler; gl_api = gst_gl_context_get_gl_api (gl_context); gles_version = gst_vaapi_get_gles_version_from_gl_api (gl_api); if (gles_version == -1) return NULL; egl_handler = gst_vaapi_get_egl_handle_from_gl_display (gl_display); if (egl_handler != 0) { gpointer native_display_egl = GSIZE_TO_POINTER (egl_handler); display = gst_vaapi_display_egl_new_with_native_display (native_display_egl, display_type, gles_version); } if (!display) { GstVaapiDisplay *wrapped_display; wrapped_display = gst_vaapi_create_display_from_handle (display_type, native_display); if (wrapped_display) { display = gst_vaapi_display_egl_new (wrapped_display, gles_version); gst_object_unref (wrapped_display); } } if (display) { gst_vaapi_display_egl_set_gl_context (GST_VAAPI_DISPLAY_EGL (display), GSIZE_TO_POINTER (gst_gl_context_get_gl_context (gl_context))); } #endif return display; }
static GstVaapiDisplay * gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object) { #if USE_GST_GL_HELPERS GstGLContext *const gl_context = GST_GL_CONTEXT (gl_context_object); GstGLDisplay *const gl_display = gst_gl_context_get_display (gl_context); gpointer native_display = GSIZE_TO_POINTER (gst_gl_display_get_handle (gl_display)); GstVaapiDisplay *display, *out_display; GstVaapiDisplayType display_type; switch (gst_gl_display_get_handle_type (gl_display)) { #if USE_X11 case GST_GL_DISPLAY_TYPE_X11: display_type = GST_VAAPI_DISPLAY_TYPE_X11; break; #endif #if USE_WAYLAND case GST_GL_DISPLAY_TYPE_WAYLAND: display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; break; #endif case GST_GL_DISPLAY_TYPE_ANY:{ /* Derive from the active window */ GstGLWindow *const gl_window = gst_gl_context_get_window (gl_context); const gchar *const gl_window_type = g_getenv ("GST_GL_WINDOW"); display_type = GST_VAAPI_DISPLAY_TYPE_ANY; if (!gl_window) break; native_display = GSIZE_TO_POINTER (gst_gl_window_get_display (gl_window)); if (gl_window_type) { #if USE_X11 if (!display_type && g_strcmp0 (gl_window_type, "x11") == 0) display_type = GST_VAAPI_DISPLAY_TYPE_X11; #endif #if USE_WAYLAND if (!display_type && g_strcmp0 (gl_window_type, "wayland") == 0) display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; #endif } else { #if USE_X11 if (!display_type && GST_GL_HAVE_WINDOW_X11) display_type = GST_VAAPI_DISPLAY_TYPE_X11; #endif #if USE_WAYLAND if (!display_type && GST_GL_HAVE_WINDOW_WAYLAND) display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND; #endif } break; } default: display_type = GST_VAAPI_DISPLAY_TYPE_ANY; break; } if (!display_type) return NULL; display = gst_vaapi_create_display_from_handle (display_type, native_display); if (!display) return NULL; switch (gst_gl_context_get_gl_platform (gl_context)) { #if USE_EGL case GST_GL_PLATFORM_EGL:{ guint gles_version; switch (gst_gl_context_get_gl_api (gl_context)) { case GST_GL_API_GLES1: gles_version = 1; goto create_egl_display; case GST_GL_API_GLES2: gles_version = 2; goto create_egl_display; case GST_GL_API_OPENGL: case GST_GL_API_OPENGL3: gles_version = 0; create_egl_display: out_display = gst_vaapi_display_egl_new (display, gles_version); break; default: out_display = NULL; break; } if (!out_display) return NULL; gst_vaapi_display_egl_set_gl_context (GST_VAAPI_DISPLAY_EGL (out_display), GSIZE_TO_POINTER (gst_gl_context_get_gl_context (gl_context))); break; } #endif default: out_display = gst_vaapi_display_ref (display); break; } gst_vaapi_display_unref (display); return out_display; #endif GST_ERROR ("unsupported GStreamer version %s", GST_API_VERSION_S); return NULL; }