mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-14 11:25:39 +00:00
display: egl: create VaapiDisplayEGL with native EGL display
gst_vaapi_display_egl_new_with_native_display() has been broken since it wasn't used. Currently it's needed to call this API to create a display providing the EGL display, so it could avoid duplicated calls to the native display (eg. eglTerminate). Signed-off-by: Victor Jaquez <vjaquez@igalia.com> https://bugzilla.gnome.org/show_bug.cgi?id=795391
This commit is contained in:
parent
bb8894aaf9
commit
50470ae89f
2 changed files with 60 additions and 22 deletions
|
@ -50,6 +50,7 @@ typedef struct
|
||||||
gpointer display;
|
gpointer display;
|
||||||
guint display_type;
|
guint display_type;
|
||||||
guint gles_version;
|
guint gles_version;
|
||||||
|
gpointer gl_display;
|
||||||
} InitParams;
|
} InitParams;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -97,27 +98,36 @@ static gboolean
|
||||||
gst_vaapi_display_egl_bind_display (GstVaapiDisplay * base_display,
|
gst_vaapi_display_egl_bind_display (GstVaapiDisplay * base_display,
|
||||||
gpointer native_params)
|
gpointer native_params)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *native_display = NULL;
|
GstVaapiDisplay *native_vaapi_display;
|
||||||
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
|
GstVaapiDisplayEGL *display = GST_VAAPI_DISPLAY_EGL (base_display);
|
||||||
EglDisplay *egl_display;
|
EglDisplay *egl_display;
|
||||||
|
EGLDisplay *native_egl_display;
|
||||||
guint gl_platform = EGL_PLATFORM_UNKNOWN;
|
guint gl_platform = EGL_PLATFORM_UNKNOWN;
|
||||||
const InitParams *params = (InitParams *) native_params;
|
const InitParams *params = (InitParams *) native_params;
|
||||||
|
|
||||||
if (params->display) {
|
native_vaapi_display = params->display;
|
||||||
native_display = params->display;
|
native_egl_display = params->gl_display;
|
||||||
} else {
|
|
||||||
|
if (!native_vaapi_display) {
|
||||||
#if USE_X11
|
#if USE_X11
|
||||||
native_display = gst_vaapi_display_x11_new (NULL);
|
if (params->display_type == GST_VAAPI_DISPLAY_TYPE_ANY
|
||||||
|
|| params->display_type == GST_VAAPI_DISPLAY_TYPE_X11
|
||||||
|
|| params->display_type == GST_VAAPI_DISPLAY_TYPE_EGL)
|
||||||
|
native_vaapi_display = gst_vaapi_display_x11_new (NULL);
|
||||||
#endif
|
#endif
|
||||||
#if USE_WAYLAND
|
#if USE_WAYLAND
|
||||||
if (!native_display)
|
if (!native_vaapi_display)
|
||||||
native_display = gst_vaapi_display_wayland_new (NULL);
|
native_vaapi_display = gst_vaapi_display_wayland_new (NULL);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
/* thus it could be unrefed */
|
||||||
|
gst_object_ref (native_vaapi_display);
|
||||||
}
|
}
|
||||||
if (!native_display)
|
if (!native_vaapi_display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gst_vaapi_display_replace (&display->display, native_display);
|
gst_vaapi_display_replace (&display->display, native_vaapi_display);
|
||||||
|
gst_object_unref (native_vaapi_display);
|
||||||
|
|
||||||
switch (GST_VAAPI_DISPLAY_GET_CLASS_TYPE (display->display)) {
|
switch (GST_VAAPI_DISPLAY_GET_CLASS_TYPE (display->display)) {
|
||||||
case GST_VAAPI_DISPLAY_TYPE_X11:
|
case GST_VAAPI_DISPLAY_TYPE_X11:
|
||||||
|
@ -130,8 +140,12 @@ gst_vaapi_display_egl_bind_display (GstVaapiDisplay * base_display,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
egl_display = egl_display_new (GST_VAAPI_DISPLAY_NATIVE (display->display),
|
if (native_egl_display) {
|
||||||
gl_platform);
|
egl_display = egl_display_new_wrapped (native_egl_display);
|
||||||
|
} else {
|
||||||
|
egl_display = egl_display_new (GST_VAAPI_DISPLAY_NATIVE (display->display),
|
||||||
|
gl_platform);
|
||||||
|
}
|
||||||
if (!egl_display)
|
if (!egl_display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -385,13 +399,14 @@ GstVaapiDisplay *
|
||||||
gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
|
gst_vaapi_display_egl_new_with_native_display (gpointer native_display,
|
||||||
GstVaapiDisplayType display_type, guint gles_version)
|
GstVaapiDisplayType display_type, guint gles_version)
|
||||||
{
|
{
|
||||||
InitParams params;
|
InitParams params = { NULL, };
|
||||||
|
|
||||||
g_return_val_if_fail (native_display != NULL, NULL);
|
g_return_val_if_fail (native_display != NULL, NULL);
|
||||||
|
|
||||||
params.display = native_display;
|
|
||||||
params.display_type = display_type;
|
params.display_type = display_type;
|
||||||
params.gles_version = gles_version;
|
params.gles_version = gles_version;
|
||||||
|
params.gl_display = native_display;
|
||||||
|
|
||||||
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
|
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY_EGL, NULL),
|
||||||
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, ¶ms);
|
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
#endif
|
#endif
|
||||||
#if USE_GST_GL_HELPERS
|
#if USE_GST_GL_HELPERS
|
||||||
# include <gst/gl/gl.h>
|
# include <gst/gl/gl.h>
|
||||||
|
#if USE_EGL && GST_GL_HAVE_PLATFORM_EGL
|
||||||
|
# include <gst/gl/egl/gstgldisplay_egl.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include "gstvaapipluginutil.h"
|
#include "gstvaapipluginutil.h"
|
||||||
#include "gstvaapipluginbase.h"
|
#include "gstvaapipluginbase.h"
|
||||||
|
@ -140,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;
|
GstVaapiDisplay *display, *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)) {
|
||||||
|
@ -195,16 +198,25 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
|
||||||
display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
|
display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_object_unref (gl_display);
|
|
||||||
|
|
||||||
display = gst_vaapi_create_display_from_handle (display_type, native_display);
|
display = gst_vaapi_create_display_from_handle (display_type, native_display);
|
||||||
if (!display)
|
if (!display)
|
||||||
return NULL;
|
goto bail;
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
#if USE_EGL
|
#if USE_EGL
|
||||||
case GST_GL_PLATFORM_EGL:{
|
case GST_GL_PLATFORM_EGL:{
|
||||||
guint gles_version;
|
guint gles_version;
|
||||||
|
guintptr egl_handle = 0;
|
||||||
|
#if GST_GL_HAVE_PLATFORM_EGL
|
||||||
|
GstGLDisplayEGL *egl_display;
|
||||||
|
|
||||||
|
egl_display = gst_gl_display_egl_from_gl_display (gl_display);
|
||||||
|
if (egl_display) {
|
||||||
|
egl_handle = gst_gl_display_get_handle (GST_GL_DISPLAY (egl_display));
|
||||||
|
gst_object_unref (egl_display);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (gst_gl_context_get_gl_api (gl_context)) {
|
switch (gst_gl_context_get_gl_api (gl_context)) {
|
||||||
case GST_GL_API_GLES1:
|
case GST_GL_API_GLES1:
|
||||||
|
@ -217,16 +229,21 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
|
||||||
case GST_GL_API_OPENGL3:
|
case GST_GL_API_OPENGL3:
|
||||||
gles_version = 0;
|
gles_version = 0;
|
||||||
create_egl_display:
|
create_egl_display:
|
||||||
out_display = gst_vaapi_display_egl_new (display, gles_version);
|
if (egl_handle != 0) {
|
||||||
|
out_display =
|
||||||
|
gst_vaapi_display_egl_new_with_native_display
|
||||||
|
(GSIZE_TO_POINTER (egl_handle), display_type, gles_version);
|
||||||
|
} else {
|
||||||
|
out_display = gst_vaapi_display_egl_new (display, gles_version);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
out_display = NULL;
|
out_display = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!out_display) {
|
if (!out_display)
|
||||||
gst_vaapi_display_unref (display);
|
goto bail;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
gst_vaapi_display_egl_set_gl_context (GST_VAAPI_DISPLAY_EGL (out_display),
|
gst_vaapi_display_egl_set_gl_context (GST_VAAPI_DISPLAY_EGL (out_display),
|
||||||
GSIZE_TO_POINTER (gst_gl_context_get_gl_context (gl_context)));
|
GSIZE_TO_POINTER (gst_gl_context_get_gl_context (gl_context)));
|
||||||
break;
|
break;
|
||||||
|
@ -236,7 +253,13 @@ gst_vaapi_create_display_from_gl_context (GstObject * gl_context_object)
|
||||||
out_display = gst_vaapi_display_ref (display);
|
out_display = gst_vaapi_display_ref (display);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_vaapi_display_unref (display);
|
|
||||||
|
bail:
|
||||||
|
if (display)
|
||||||
|
gst_vaapi_display_unref (display);
|
||||||
|
|
||||||
|
if (gl_display)
|
||||||
|
gst_object_unref (gl_display);
|
||||||
return out_display;
|
return out_display;
|
||||||
#endif
|
#endif
|
||||||
GST_ERROR ("unsupported GStreamer version %s", GST_API_VERSION_S);
|
GST_ERROR ("unsupported GStreamer version %s", GST_API_VERSION_S);
|
||||||
|
|
Loading…
Reference in a new issue