2014-04-12 19:43:50 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it un der 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
|
|
|
|
|
|
|
|
#import <OpenGLES/EAGL.h>
|
2014-04-13 14:53:58 +00:00
|
|
|
#import <QuartzCore/QuartzCore.h>
|
2014-04-12 19:43:50 +00:00
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
|
|
|
#include "gstglwindow_eagl.h"
|
|
|
|
#include "gstglcontext_eagl.h"
|
2020-05-29 05:44:55 +00:00
|
|
|
#include "gstglios_utils.h"
|
2014-04-12 19:43:50 +00:00
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT gst_gl_window_eagl_debug
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
#define GST_GL_WINDOW_EAGL_LAYER(obj) \
|
|
|
|
((__bridge CAEAGLLayer *)(obj->priv->layer))
|
|
|
|
#define GST_GL_WINDOW_EAGL_QUEUE(obj) \
|
|
|
|
((__bridge dispatch_queue_t)(obj->priv->gl_queue))
|
|
|
|
|
2016-04-10 22:34:00 +00:00
|
|
|
static void gst_gl_window_eagl_finalize (GObject * object);
|
2014-04-12 19:43:50 +00:00
|
|
|
|
|
|
|
static guintptr gst_gl_window_eagl_get_display (GstGLWindow * window);
|
|
|
|
static guintptr gst_gl_window_eagl_get_window_handle (GstGLWindow * window);
|
|
|
|
static void gst_gl_window_eagl_set_window_handle (GstGLWindow * window,
|
|
|
|
guintptr handle);
|
2015-01-23 03:11:48 +00:00
|
|
|
static void gst_gl_window_eagl_set_preferred_size (GstGLWindow * window,
|
2015-01-23 05:52:25 +00:00
|
|
|
gint width, gint height);
|
2015-01-23 03:11:48 +00:00
|
|
|
static void gst_gl_window_eagl_draw (GstGLWindow * window);
|
2016-04-10 22:34:00 +00:00
|
|
|
static void gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
|
|
|
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy);
|
2020-05-29 09:08:51 +00:00
|
|
|
static void gst_gl_window_eagl_quit (GstGLWindow *window);
|
2014-04-12 19:43:50 +00:00
|
|
|
|
|
|
|
struct _GstGLWindowEaglPrivate
|
|
|
|
{
|
2020-05-29 05:44:55 +00:00
|
|
|
gboolean pending_set_window_handle;
|
|
|
|
gpointer external_view;
|
|
|
|
gpointer internal_view;
|
|
|
|
gpointer layer;
|
2020-11-26 12:45:05 +00:00
|
|
|
CGFloat window_width, window_height;
|
2015-01-23 03:11:48 +00:00
|
|
|
gint preferred_width, preferred_height;
|
2017-02-03 13:46:39 +00:00
|
|
|
gpointer gl_queue;
|
2020-05-29 05:44:55 +00:00
|
|
|
GMutex draw_lock;
|
|
|
|
GCond cond;
|
2020-05-29 09:08:51 +00:00
|
|
|
|
|
|
|
gboolean shutting_down;
|
|
|
|
GstGLContext *last_context;
|
2014-04-12 19:43:50 +00:00
|
|
|
};
|
|
|
|
|
2018-06-24 11:35:20 +00:00
|
|
|
#define DEBUG_INIT \
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_DEFAULT, "glwindow");
|
|
|
|
#define gst_gl_window_eagl_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstGLWindowEagl, gst_gl_window_eagl,
|
|
|
|
GST_TYPE_GL_WINDOW, G_ADD_PRIVATE (GstGLWindowEagl) DEBUG_INIT);
|
|
|
|
|
2014-04-12 19:43:50 +00:00
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_class_init (GstGLWindowEaglClass * klass)
|
|
|
|
{
|
2016-04-10 22:34:00 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2015-03-06 04:31:18 +00:00
|
|
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
2014-04-12 19:43:50 +00:00
|
|
|
|
2016-04-10 22:34:00 +00:00
|
|
|
gobject_class->finalize = gst_gl_window_eagl_finalize;
|
|
|
|
|
2014-04-12 19:43:50 +00:00
|
|
|
window_class->get_display =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_get_display);
|
|
|
|
window_class->get_window_handle =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_get_window_handle);
|
|
|
|
window_class->set_window_handle =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_window_handle);
|
|
|
|
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_draw);
|
2015-01-23 03:11:48 +00:00
|
|
|
window_class->set_preferred_size =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_set_preferred_size);
|
2016-04-10 22:34:00 +00:00
|
|
|
window_class->send_message_async =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_gl_window_eagl_send_message_async);
|
2020-05-29 09:08:51 +00:00
|
|
|
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_eagl_quit);
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_init (GstGLWindowEagl * window)
|
|
|
|
{
|
2018-06-23 19:33:16 +00:00
|
|
|
window->priv = gst_gl_window_eagl_get_instance_private (window);
|
2016-04-10 22:34:00 +00:00
|
|
|
window->priv->gl_queue =
|
2017-02-03 13:46:39 +00:00
|
|
|
(__bridge_retained gpointer)dispatch_queue_create ("org.freedesktop.gstreamer.glwindow", NULL);
|
2020-05-29 05:44:55 +00:00
|
|
|
g_mutex_init (&window->priv->draw_lock);
|
|
|
|
g_cond_init (&window->priv->cond);
|
2016-04-10 22:34:00 +00:00
|
|
|
}
|
2015-03-06 04:31:18 +00:00
|
|
|
|
2016-04-10 22:34:00 +00:00
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstGLWindowEagl *window = GST_GL_WINDOW_EAGL (object);
|
2020-05-29 05:44:55 +00:00
|
|
|
|
|
|
|
if (window->priv->layer)
|
|
|
|
CFRelease (window->priv->layer);
|
|
|
|
window->priv->layer = NULL;
|
2017-02-03 13:46:39 +00:00
|
|
|
CFRelease(window->priv->gl_queue);
|
2020-05-29 05:44:55 +00:00
|
|
|
g_mutex_clear (&window->priv->draw_lock);
|
|
|
|
g_cond_clear (&window->priv->cond);
|
|
|
|
|
2016-04-10 22:34:00 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be called in the gl thread */
|
|
|
|
GstGLWindowEagl *
|
2015-07-24 07:00:27 +00:00
|
|
|
gst_gl_window_eagl_new (GstGLDisplay * display)
|
2014-04-12 19:43:50 +00:00
|
|
|
{
|
2017-05-15 17:31:31 +00:00
|
|
|
GstGLWindowEagl *window;
|
|
|
|
|
2015-07-24 07:00:27 +00:00
|
|
|
/* there isn't an eagl display type */
|
2017-05-15 17:31:31 +00:00
|
|
|
window = g_object_new (GST_TYPE_GL_WINDOW_EAGL, NULL);
|
|
|
|
gst_object_ref_sink (window);
|
|
|
|
|
|
|
|
return window;
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guintptr
|
|
|
|
gst_gl_window_eagl_get_display (GstGLWindow * window)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guintptr
|
|
|
|
gst_gl_window_eagl_get_window_handle (GstGLWindow * window)
|
|
|
|
{
|
2020-05-29 05:44:55 +00:00
|
|
|
return (guintptr) GST_GL_WINDOW_EAGL (window)->priv->internal_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_create_gl_window (GstGLWindowEagl * window_eagl)
|
|
|
|
{
|
|
|
|
GstGLWindowEaglPrivate *priv = window_eagl->priv;
|
|
|
|
UIView *external_view;
|
|
|
|
CGRect rect;
|
|
|
|
GstGLUIView *view;
|
|
|
|
|
|
|
|
g_mutex_lock (&priv->draw_lock);
|
|
|
|
|
|
|
|
external_view = (__bridge UIView *) priv->external_view;
|
|
|
|
rect = CGRectMake (0, 0, external_view.frame.size.width, external_view.frame.size.height);
|
|
|
|
|
|
|
|
window_eagl->priv->window_width = rect.size.width;
|
|
|
|
window_eagl->priv->window_height = rect.size.height;
|
|
|
|
|
|
|
|
view = [[GstGLUIView alloc] initWithFrame:rect];
|
|
|
|
[view setGstWindow:window_eagl];
|
|
|
|
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
|
view.contentMode = UIViewContentModeRedraw;
|
|
|
|
|
|
|
|
priv->internal_view = (__bridge_retained gpointer) view;
|
|
|
|
[external_view addSubview:view];
|
|
|
|
priv->internal_view = (__bridge_retained gpointer) view;
|
|
|
|
priv->layer = (__bridge_retained gpointer) [view layer];
|
|
|
|
|
|
|
|
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
|
|
|
|
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
|
|
|
|
|
|
|
[[view layer] setOpaque:YES];
|
|
|
|
[(CAEAGLLayer *) [view layer] setDrawableProperties:dict];
|
|
|
|
|
|
|
|
g_cond_broadcast (&priv->cond);
|
|
|
|
g_mutex_unlock (&priv->draw_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ensure_window_handle_is_set_unlocked (GstGLWindowEagl * window_eagl)
|
|
|
|
{
|
|
|
|
GstGLContext *context;
|
|
|
|
|
|
|
|
if (!window_eagl->priv->pending_set_window_handle)
|
|
|
|
return;
|
|
|
|
|
|
|
|
context = gst_gl_window_get_context (GST_GL_WINDOW (window_eagl));
|
|
|
|
if (!context) {
|
|
|
|
g_critical ("Window does not have a GstGLContext attached!. "
|
|
|
|
"Aborting set window handle.");
|
|
|
|
g_mutex_unlock (&window_eagl->priv->draw_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!window_eagl->priv->internal_view)
|
|
|
|
g_cond_wait (&window_eagl->priv->cond, &window_eagl->priv->draw_lock);
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (context, "handle set, updating layer");
|
|
|
|
gst_gl_context_eagl_update_layer (context, window_eagl->priv->layer);
|
|
|
|
gst_object_unref (context);
|
|
|
|
|
|
|
|
window_eagl->priv->pending_set_window_handle = FALSE;
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_set_window_handle (GstGLWindow * window, guintptr handle)
|
|
|
|
{
|
|
|
|
GstGLWindowEagl *window_eagl;
|
|
|
|
|
|
|
|
window_eagl = GST_GL_WINDOW_EAGL (window);
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
g_mutex_lock (&window_eagl->priv->draw_lock);
|
|
|
|
if (window_eagl->priv->external_view)
|
|
|
|
CFRelease (window_eagl->priv->external_view);
|
|
|
|
window_eagl->priv->external_view = (gpointer)handle;
|
|
|
|
window_eagl->priv->pending_set_window_handle = TRUE;
|
|
|
|
g_mutex_unlock (&window_eagl->priv->draw_lock);
|
2015-08-25 07:09:14 +00:00
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
/* XXX: Maybe we need an async set_window_handle? */
|
|
|
|
_gl_invoke_on_main ((GstGLWindowEaglFunc) _create_gl_window,
|
|
|
|
gst_object_ref (window_eagl), gst_object_unref);
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 09:08:51 +00:00
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_quit (GstGLWindow * window)
|
|
|
|
{
|
|
|
|
GstGLWindowEagl *window_eagl = (GstGLWindowEagl *) window;
|
|
|
|
|
|
|
|
window_eagl->priv->shutting_down = TRUE;
|
|
|
|
|
|
|
|
GST_GL_WINDOW_CLASS (parent_class)->quit (window);
|
|
|
|
}
|
|
|
|
|
2015-01-23 03:11:48 +00:00
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_set_preferred_size (GstGLWindow * window, gint width, gint height)
|
2014-04-12 19:43:50 +00:00
|
|
|
{
|
2015-01-23 05:52:25 +00:00
|
|
|
GstGLWindowEagl *window_eagl = GST_GL_WINDOW_EAGL (window);
|
2015-01-23 03:11:48 +00:00
|
|
|
|
|
|
|
window_eagl->priv->preferred_width = width;
|
|
|
|
window_eagl->priv->preferred_height = height;
|
|
|
|
}
|
2014-04-12 19:43:50 +00:00
|
|
|
|
2016-04-10 22:34:00 +00:00
|
|
|
static void
|
|
|
|
gst_gl_window_eagl_send_message_async (GstGLWindow * window,
|
|
|
|
GstGLWindowCB callback, gpointer data, GDestroyNotify destroy)
|
|
|
|
{
|
|
|
|
GstGLWindowEagl *window_eagl = (GstGLWindowEagl *) window;
|
|
|
|
GstGLContext *context = gst_gl_window_get_context (window);
|
2020-05-29 09:08:51 +00:00
|
|
|
GstGLContext *unref_context = NULL;
|
|
|
|
GThread *thread;
|
|
|
|
|
|
|
|
if (context)
|
|
|
|
window_eagl->priv->last_context = unref_context = context;
|
|
|
|
|
|
|
|
/* we may not have a context if we are shutting down */
|
|
|
|
if (!context && window_eagl->priv->shutting_down) {
|
|
|
|
context = window_eagl->priv->last_context;
|
|
|
|
window_eagl->priv->shutting_down = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
|
|
thread = gst_gl_context_get_thread (context);
|
2016-04-10 22:34:00 +00:00
|
|
|
|
2016-04-12 14:43:18 +00:00
|
|
|
if (thread == g_thread_self()) {
|
2016-04-10 22:34:00 +00:00
|
|
|
/* this case happens for nested calls happening from inside the GCD queue */
|
|
|
|
callback (data);
|
|
|
|
if (destroy)
|
|
|
|
destroy (data);
|
2020-05-29 09:08:51 +00:00
|
|
|
if (unref_context)
|
|
|
|
gst_object_unref (unref_context);
|
2016-04-10 22:34:00 +00:00
|
|
|
} else {
|
2017-02-03 13:46:39 +00:00
|
|
|
dispatch_async ((__bridge dispatch_queue_t)(window_eagl->priv->gl_queue), ^{
|
2016-04-10 22:34:00 +00:00
|
|
|
gst_gl_context_activate (context, TRUE);
|
|
|
|
callback (data);
|
2020-05-29 09:08:51 +00:00
|
|
|
if (unref_context)
|
|
|
|
gst_object_unref (unref_context);
|
2016-04-10 22:34:00 +00:00
|
|
|
if (destroy)
|
|
|
|
destroy (data);
|
|
|
|
});
|
|
|
|
}
|
2016-04-12 14:43:18 +00:00
|
|
|
if (thread)
|
|
|
|
g_thread_unref (thread);
|
2016-04-10 22:34:00 +00:00
|
|
|
}
|
|
|
|
|
2014-04-12 19:43:50 +00:00
|
|
|
static void
|
|
|
|
draw_cb (gpointer data)
|
|
|
|
{
|
2015-01-23 03:11:48 +00:00
|
|
|
GstGLWindowEagl *window_eagl = data;
|
2014-04-12 19:43:50 +00:00
|
|
|
GstGLWindow *window = GST_GL_WINDOW (window_eagl);
|
|
|
|
GstGLContext *context = gst_gl_window_get_context (window);
|
|
|
|
GstGLContextEagl *eagl_context = GST_GL_CONTEXT_EAGL (context);
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
g_mutex_lock (&window_eagl->priv->draw_lock);
|
|
|
|
|
|
|
|
ensure_window_handle_is_set_unlocked (window_eagl);
|
|
|
|
|
|
|
|
if (window_eagl->priv->internal_view) {
|
2014-04-13 14:53:58 +00:00
|
|
|
CGSize size;
|
|
|
|
CAEAGLLayer *eagl_layer;
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
eagl_layer = GST_GL_WINDOW_EAGL_LAYER (window_eagl);
|
2014-04-13 14:53:58 +00:00
|
|
|
size = eagl_layer.frame.size;
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
size = CGSizeMake (size.width * eagl_layer.contentsScale, size.height * eagl_layer.contentsScale);
|
2018-03-16 07:57:36 +00:00
|
|
|
|
2015-09-17 07:06:37 +00:00
|
|
|
if (window->queue_resize || window_eagl->priv->window_width != size.width ||
|
2015-02-24 03:23:49 +00:00
|
|
|
window_eagl->priv->window_height != size.height) {
|
|
|
|
|
gl/eagl: Fix automatic resize behaviour
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/681
added a layoutSubViews, which never gets called, because it should have been
called layoutSubviews (non-capital "v"). However after fixing that, it still
doesn't work correctly, because window_width/height values are immediately
updated and then draw_cb will never trigger the resize path, because the
values are already up to date.
Update the values inside the resize path again instead, so the check for
entering the resize path is logically always correct.
This makes the layoutSubviews unnecessary, as it only updated the internal
size values prematurely, so it is deleted instead of method naming fixed.
These changes were originally done to avoid accessing UIKit objects on the
main thread, but no additional accesses are added here, only internal
private variable assignments under the same draw_lock, so there should be
no threading issues reintroduced.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/945>
2020-11-26 12:52:26 +00:00
|
|
|
window_eagl->priv->window_width = size.width;
|
|
|
|
window_eagl->priv->window_height = size.height;
|
|
|
|
|
2015-02-24 03:23:49 +00:00
|
|
|
gst_gl_context_eagl_resize (eagl_context);
|
2014-04-13 14:53:58 +00:00
|
|
|
|
2015-09-17 07:06:37 +00:00
|
|
|
gst_gl_window_resize (window, window_eagl->priv->window_width,
|
2015-02-24 03:23:49 +00:00
|
|
|
window_eagl->priv->window_height);
|
2014-04-13 14:53:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 19:43:50 +00:00
|
|
|
gst_gl_context_eagl_prepare_draw (eagl_context);
|
|
|
|
|
|
|
|
if (window->draw)
|
|
|
|
window->draw (window->draw_data);
|
|
|
|
|
2017-05-21 10:03:01 +00:00
|
|
|
gst_gl_context_swap_buffers (context);
|
2014-04-12 19:43:50 +00:00
|
|
|
|
|
|
|
gst_gl_context_eagl_finish_draw (eagl_context);
|
|
|
|
|
2020-05-29 05:44:55 +00:00
|
|
|
g_mutex_unlock (&window_eagl->priv->draw_lock);
|
|
|
|
|
2014-04-12 19:43:50 +00:00
|
|
|
gst_object_unref (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-23 03:11:48 +00:00
|
|
|
gst_gl_window_eagl_draw (GstGLWindow * window)
|
2014-04-12 19:43:50 +00:00
|
|
|
{
|
2015-01-23 03:11:48 +00:00
|
|
|
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
2014-04-12 19:43:50 +00:00
|
|
|
}
|
2020-05-29 05:44:55 +00:00
|
|
|
|
|
|
|
gpointer
|
|
|
|
gst_gl_window_eagl_get_layer (GstGLWindowEagl * window_eagl)
|
|
|
|
{
|
|
|
|
gpointer layer;
|
|
|
|
|
|
|
|
g_mutex_lock (&window_eagl->priv->draw_lock);
|
|
|
|
if (window_eagl->priv->layer)
|
|
|
|
CFRetain (window_eagl->priv->layer);
|
|
|
|
layer = window_eagl->priv->layer;
|
|
|
|
g_mutex_unlock (&window_eagl->priv->draw_lock);
|
|
|
|
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@implementation GstGLUIView {
|
|
|
|
GstGLWindowEagl * window_eagl;
|
|
|
|
};
|
|
|
|
|
|
|
|
+(Class) layerClass
|
|
|
|
{
|
|
|
|
return [CAEAGLLayer class];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) setGstWindow:(GstGLWindowEagl *) window
|
|
|
|
{
|
|
|
|
window_eagl = window;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
void
|
|
|
|
_gl_invoke_on_main (GstGLWindowEaglFunc func, gpointer data, GDestroyNotify notify)
|
|
|
|
{
|
|
|
|
if ([NSThread isMainThread]) {
|
|
|
|
func (data);
|
|
|
|
if (notify)
|
|
|
|
notify (data);
|
|
|
|
} else {
|
|
|
|
dispatch_async (dispatch_get_main_queue (), ^{
|
|
|
|
func (data);
|
|
|
|
if (notify)
|
|
|
|
notify (data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|