[gtk/gst.gl.win32: 15/20] gtkgstsink.c: Avoid g_setenv()
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gst.gl.win32: 15/20] gtkgstsink.c: Avoid g_setenv()
- Date: Fri, 21 May 2021 04:54:08 +0000 (UTC)
commit ecedf94245108a35a0c095e5402ec113bcab76df
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed May 19 14:18:35 2021 +0800
gtkgstsink.c: Avoid g_setenv()
Instead, we check whether GstGL has the gst_gl_display_new_with_type() when
building for Windows, and set up a GstGLDisplay with it if it is available
for desktop OpenGL. If we don't, or we are using EGL (libANGLE), show
messages to what one can do if the video fails to play due to GL context
initialization issues
modules/media/gtkgstsink.c | 18 +++++++++++++-----
modules/media/meson.build | 17 ++++++++++++++++-
2 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c
index 13346f7688..33ad04a41c 100644
--- a/modules/media/gtkgstsink.c
+++ b/modules/media/gtkgstsink.c
@@ -495,18 +495,26 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
if (gl_api == GST_GL_API_OPENGL3 || gl_api == GST_GL_API_OPENGL)
{
- g_setenv ("GST_GL_WINDOW", "win32", TRUE);
- g_setenv("GST_GL_PLATFORM", "wgl", TRUE);
+#ifdef HAVE_GST_GL_DISPLAY_NEW_WITH_TYPE
+ self->gst_display = gst_gl_display_new_with_type (GST_GL_DISPLAY_TYPE_WIN32);
+#else
+ g_message ("If media fails to play, set the envvar `GST_DEBUG=1`, and if GstGL context
creation fails");
+ g_message ("due to \"Couldn't create GL context: Cannot share context with non-EGL
context\",");
+ g_message ("set in the environment `GST_GL_PLATFORM=wgl` and `GST_GL_WINDOW=win32`,");
+ g_message ("and restart the GTK application");
+
self->gst_display = gst_gl_display_new ();
+#endif
}
#ifdef GST_GL_HAVE_PLATFORM_EGL
else
{
gpointer display_ptr = gdk_win32_display_get_egl_display (display);
- gl_api_str = gst_gl_api_to_string (gl_api);
- g_setenv ("GST_GL_API", gl_api_str, TRUE);
- g_free (gl_api_str);
+ g_message ("If media fails to play, set the envvar `GST_DEBUG=1`, and if GstGL context
creation fails");
+ g_message ("due to \"Couldn't create GL context: Failed to bind OpenGL API:
EGL_BAD_PARAMETER\",");
+ g_message ("set in the environment `GST_GL_API=gles2` and restart the GTK application");
+
self->gst_display = GST_GL_DISPLAY (gst_gl_display_egl_new_with_egl_display (display_ptr));
}
#endif
diff --git a/modules/media/meson.build b/modules/media/meson.build
index 154390e7fe..1bd91821d8 100644
--- a/modules/media/meson.build
+++ b/modules/media/meson.build
@@ -47,6 +47,21 @@ gstgl_dep = dependency('gstreamer-gl-1.0', version: '>= 1.12.3',
required: get_option('media-gstreamer'))
if gstplayer_dep.found() and gstgl_dep.found()
+ extra_win_cflags = []
+
+ if host_machine.system() == 'windows'
+ new_gst_gl_display_code = \
+ '''#include <gst/gl/gstgldisplay.h>
+ int main (int a, char ** g) {
+ GstGLDisplay *d = gst_gl_display_new_with_type (GST_GL_DISPLAY_TYPE_WIN32);
+ return 0;
+ }'''
+ if cc.links(new_gst_gl_display_code, dependencies : gstgl_dep)
+ message('libgstgl has gst_gl_display_new_with_type()')
+ extra_win_cflags += '-DHAVE_GST_GL_DISPLAY_NEW_WITH_TYPE'
+ endif
+ endif
+
media_backends += 'gstreamer'
cdata.set('HAVE_GSTREAMER', 1)
shared_module('media-gstreamer',
@@ -55,7 +70,7 @@ if gstplayer_dep.found() and gstgl_dep.found()
'gtkgstpaintable.c',
'gtkgstsink.c',
],
- c_args: extra_c_args,
+ c_args: extra_c_args + extra_win_cflags,
dependencies: [ libm, libgtk_dep, gstplayer_dep, gstgl_dep ],
name_suffix: module_suffix,
install_dir: media_install_dir,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]