plugin: Add GL support for macOS

This commit is contained in:
Rafał Dzięgiel
2022-05-13 10:49:02 +02:00
parent f351982067
commit 1cdaa36559
3 changed files with 27 additions and 0 deletions

View File

@@ -42,6 +42,10 @@
#include <gst/gl/egl/gstgldisplay_egl.h>
#endif
#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS
#include <gdk/macos/gdkmacos.h>
#endif
#define GST_CAT_DEFAULT gst_clapper_gl_base_importer_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
@@ -151,6 +155,13 @@ retrieve_gl_context_on_main (GstClapperGLBaseImporter *self)
#endif
#endif
#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS
if (GDK_IS_MACOS_DISPLAY (gdk_display)) {
self->gst_display =
gst_gl_display_new_with_type (GST_GL_DISPLAY_TYPE_COCOA);
}
#endif
/* Fallback to generic display */
if (G_UNLIKELY (!self->gst_display)) {
GST_WARNING_OBJECT (self, "Unknown Gdk display!");
@@ -178,6 +189,13 @@ retrieve_gl_context_on_main (GstClapperGLBaseImporter *self)
goto have_display;
}
#endif
#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS
if (gst_gl_display_get_handle_type (self->gst_display) == GST_GL_DISPLAY_TYPE_COCOA) {
platform = GST_GL_PLATFORM_CGL;
GST_INFO_OBJECT (self, "Using CGL on macOS");
goto have_display;
}
#endif
g_clear_object (&self->gdk_context);
gst_clear_object (&self->gst_display);

View File

@@ -41,6 +41,7 @@ G_BEGIN_DECLS
#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 (GST_GL_HAVE_WINDOW_X11 && defined (GDK_WINDOWING_X11))
#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_GLX (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 && GST_GL_HAVE_PLATFORM_GLX)
#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_EGL (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 && GST_GL_HAVE_PLATFORM_EGL)
#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS (GST_GL_HAVE_WINDOW_COCOA && defined (GDK_WINDOWING_MACOS) && GST_GL_HAVE_PLATFORM_CGL)
typedef struct _GstClapperGLBaseImporter GstClapperGLBaseImporter;
typedef struct _GstClapperGLBaseImporterClass GstClapperGLBaseImporterClass;

View File

@@ -46,6 +46,14 @@ if gst_gl_have_window_wayland and gst_gl_have_platform_egl
endif
endif
if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
gtk_macos_dep = dependency('gtk4-macos', required: false)
if gtk_macos_dep.found()
gst_plugin_gl_base_deps += gtk_macos_dep
have_gtk_gl_windowing = true
endif
endif
if not have_gtk_gl_windowing
if gl_support_required
error('GL-based importer was enabled, but support for current GL windowing is missing')