[gtk: 1/2] gtkgstsink: Support EGL under x11




commit c51eb7665e4788008c69dcda87acc376cb51e155
Author: Rafał Dzięgiel <rafostar github gmail com>
Date:   Fri May 14 19:25:23 2021 +0200

    gtkgstsink: Support EGL under x11
    
    Add support for EGL under x11 windowing system to GStreamer sink

 modules/media/gtkgstsink.c | 38 +++++++++++++++++++++++++++++++-------
 modules/media/meson.build  |  6 ++++--
 2 files changed, 35 insertions(+), 9 deletions(-)
---
diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c
index 8a0a124e3b..273df334c5 100644
--- a/modules/media/gtkgstsink.c
+++ b/modules/media/gtkgstsink.c
@@ -25,12 +25,19 @@
 #include "gtkgstpaintableprivate.h"
 #include "gtkintl.h"
 
-#if GST_GL_HAVE_WINDOW_X11 && GST_GL_HAVE_PLATFORM_GLX && defined (GDK_WINDOWING_X11)
+#if GST_GL_HAVE_WINDOW_X11 && (GST_GL_HAVE_PLATFORM_GLX || GST_GL_HAVE_PLATFORM_EGL) && defined 
(GDK_WINDOWING_X11)
+#define HAVE_GST_X11_SUPPORT
 #include <gdk/x11/gdkx.h>
+#if GST_GL_HAVE_PLATFORM_GLX
 #include <gst/gl/x11/gstgldisplay_x11.h>
 #endif
+#if GST_GL_HAVE_PLATFORM_EGL
+#include <gst/gl/egl/gstgldisplay_egl.h>
+#endif
+#endif
 
 #if GST_GL_HAVE_WINDOW_WAYLAND && GST_GL_HAVE_PLATFORM_EGL && defined (GDK_WINDOWING_WAYLAND)
+#define HAVE_GST_WAYLAND_SUPPORT
 #include <gdk/wayland/gdkwayland.h>
 #include <gst/gl/wayland/gstgldisplay_wayland.h>
 #endif
@@ -351,31 +358,48 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
 
   gdk_gl_context_make_current (self->gdk_context);
 
-#if GST_GL_HAVE_WINDOW_X11 && GST_GL_HAVE_PLATFORM_GLX && defined (GDK_WINDOWING_X11)
+#ifdef HAVE_GST_X11_SUPPORT
   if (GDK_IS_X11_DISPLAY (display))
     {
-      GstGLPlatform platform = GST_GL_PLATFORM_GLX;
+      GstGLPlatform platform;
       GstGLAPI gl_api;
       guintptr gl_handle;
+      gpointer display_ptr;
 
-      GST_DEBUG_OBJECT (self, "got GLX on X11!");
+#if GST_GL_HAVE_PLATFORM_EGL
+      display_ptr = gdk_x11_display_get_egl_display (display);
+      if (display_ptr)
+        {
+          GST_DEBUG_OBJECT (self, "got EGL on X11!");
+          platform = GST_GL_PLATFORM_EGL;
+          self->gst_display = GST_GL_DISPLAY (gst_gl_display_egl_new_with_egl_display (display_ptr));
+        }
+#endif
+#if GST_GL_HAVE_PLATFORM_GLX
+      if (!self->gst_display)
+        {
+          GST_DEBUG_OBJECT (self, "got GLX on X11!");
+          platform = GST_GL_PLATFORM_GLX;
+          display_ptr = gdk_x11_display_get_xdisplay (display);
+          self->gst_display = GST_GL_DISPLAY (gst_gl_display_x11_new_with_display (display_ptr));
+        }
+#endif
 
       gl_api = gst_gl_context_get_current_gl_api (platform, NULL, NULL);
       gl_handle = gst_gl_context_get_current_gl_context (platform);
       if (gl_handle)
         {
-          self->gst_display = GST_GL_DISPLAY (gst_gl_display_x11_new_with_display 
(gdk_x11_display_get_xdisplay (display)));
           self->gst_app_context = gst_gl_context_new_wrapped (self->gst_display, gl_handle, platform, 
gl_api);
         }
       else
         {
-          GST_ERROR_OBJECT (self, "Failed to get handle from GdkGLContext, not using GLX");
+          GST_ERROR_OBJECT (self, "Failed to get handle from GdkGLContext");
           return;
         }
     }
   else
 #endif
-#if GST_GL_HAVE_WINDOW_WAYLAND && GST_GL_HAVE_PLATFORM_EGL && defined (GDK_WINDOWING_WAYLAND)
+#ifdef HAVE_GST_WAYLAND_SUPPORT
   if (GDK_IS_WAYLAND_DISPLAY (display))
     {
       GstGLPlatform platform = GST_GL_PLATFORM_GLX;
diff --git a/modules/media/meson.build b/modules/media/meson.build
index 154390e7fe..bebb9bdf88 100644
--- a/modules/media/meson.build
+++ b/modules/media/meson.build
@@ -45,8 +45,10 @@ gstplayer_dep = dependency('gstreamer-player-1.0', version: '>= 1.12.3',
                            required: get_option('media-gstreamer'))
 gstgl_dep = dependency('gstreamer-gl-1.0', version: '>= 1.12.3',
                        required: get_option('media-gstreamer'))
+gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : '>= 1.12.3',
+                          required: get_option('media-gstreamer'))
 
-if gstplayer_dep.found() and gstgl_dep.found()
+if gstplayer_dep.found() and gstgl_dep.found() and gstglegl_dep.found()
   media_backends += 'gstreamer'
   cdata.set('HAVE_GSTREAMER', 1)
   shared_module('media-gstreamer',
@@ -56,7 +58,7 @@ if gstplayer_dep.found() and gstgl_dep.found()
       'gtkgstsink.c',
     ],
     c_args: extra_c_args,
-    dependencies: [ libm, libgtk_dep, gstplayer_dep, gstgl_dep ],
+    dependencies: [ libm, libgtk_dep, gstplayer_dep, gstgl_dep, gstglegl_dep ],
     name_suffix: module_suffix,
     install_dir: media_install_dir,
     install: true,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]