2015-03-11 00:06:55 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2015 Julien Isorce <julien.isorce@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2021-04-23 18:05:45 +00:00
|
|
|
#if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
|
|
|
|
# define GL_SILENCE_DEPRECATION
|
|
|
|
#endif
|
|
|
|
|
2015-03-11 00:06:55 +00:00
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#include <gst/gl/cocoa/gstgldisplay_cocoa.h>
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_gl_display_debug
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstGLDisplayCocoa, gst_gl_display_cocoa, GST_TYPE_GL_DISPLAY);
|
|
|
|
|
|
|
|
static guintptr gst_gl_display_cocoa_get_handle (GstGLDisplay * display);
|
|
|
|
|
2017-10-01 17:04:15 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
2017-05-20 10:16:50 +00:00
|
|
|
#define NSEventMaskAny NSAnyEventMask
|
|
|
|
#endif
|
|
|
|
|
2015-03-11 00:06:55 +00:00
|
|
|
static void
|
|
|
|
gst_gl_display_cocoa_class_init (GstGLDisplayCocoaClass * klass)
|
|
|
|
{
|
|
|
|
GST_GL_DISPLAY_CLASS (klass)->get_handle =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_display_cocoa_get_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_display_cocoa_init (GstGLDisplayCocoa * display_cocoa)
|
|
|
|
{
|
|
|
|
GstGLDisplay *display = (GstGLDisplay *) display_cocoa;
|
|
|
|
display->type = GST_GL_DISPLAY_TYPE_COCOA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_gl_display_cocoa_new:
|
|
|
|
*
|
|
|
|
* Create a new #GstGLDisplayCocoa.
|
|
|
|
*
|
2022-10-15 09:16:01 +00:00
|
|
|
* Returns: (transfer full): a new #GstGLDisplayCocoa
|
2015-03-11 00:06:55 +00:00
|
|
|
*/
|
|
|
|
GstGLDisplayCocoa *
|
|
|
|
gst_gl_display_cocoa_new (void)
|
|
|
|
{
|
2017-05-15 17:31:31 +00:00
|
|
|
GstGLDisplayCocoa *display;
|
|
|
|
|
2015-03-11 00:06:55 +00:00
|
|
|
GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
|
|
|
|
|
2023-05-10 20:35:27 +00:00
|
|
|
if (NSApp == nil)
|
|
|
|
g_warning ("An NSApplication needs to be running on the main thread "
|
|
|
|
"to ensure correct behaviour on macOS. Use gst_macos_main() or call "
|
|
|
|
"[NSApplication sharedApplication] in your code before using this element.");
|
|
|
|
|
2017-05-15 17:31:31 +00:00
|
|
|
display = g_object_new (GST_TYPE_GL_DISPLAY_COCOA, NULL);
|
|
|
|
gst_object_ref_sink (display);
|
|
|
|
|
|
|
|
return display;
|
2015-03-11 00:06:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guintptr
|
|
|
|
gst_gl_display_cocoa_get_handle (GstGLDisplay * display)
|
|
|
|
{
|
|
|
|
return (guintptr) NSApp;
|
|
|
|
}
|