diff --git a/lib/gst/plugin/importers/gstclapperglbaseimporter.c b/lib/gst/plugin/importers/gstclapperglbaseimporter.c index 5b7dddba..8859685a 100644 --- a/lib/gst/plugin/importers/gstclapperglbaseimporter.c +++ b/lib/gst/plugin/importers/gstclapperglbaseimporter.c @@ -42,6 +42,10 @@ #include #endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS +#include +#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); diff --git a/lib/gst/plugin/importers/gstclapperglbaseimporter.h b/lib/gst/plugin/importers/gstclapperglbaseimporter.h index f7524ce0..65383768 100644 --- a/lib/gst/plugin/importers/gstclapperglbaseimporter.h +++ b/lib/gst/plugin/importers/gstclapperglbaseimporter.h @@ -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; diff --git a/lib/gst/plugin/importers/meson.build b/lib/gst/plugin/importers/meson.build index 57283588..de5e3d66 100644 --- a/lib/gst/plugin/importers/meson.build +++ b/lib/gst/plugin/importers/meson.build @@ -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')