|
Packit |
971217 |
/*
|
|
Packit |
971217 |
* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
|
Packit |
971217 |
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
|
Packit |
971217 |
* Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* TODO: - Window resize handling
|
|
Packit |
971217 |
* - Event handling input event handling
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gst.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gl/egl/gstglcontext_egl.h>
|
|
Packit |
971217 |
#include "gstglwindow_android_egl.h"
|
|
Packit |
971217 |
#include "../gstglwindow_private.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define GST_CAT_DEFAULT gst_gl_window_debug
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define gst_gl_window_android_egl_parent_class parent_class
|
|
Packit |
971217 |
G_DEFINE_TYPE (GstGLWindowAndroidEGL, gst_gl_window_android_egl,
|
|
Packit |
971217 |
GST_TYPE_GL_WINDOW);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guintptr gst_gl_window_android_egl_get_display (GstGLWindow * window);
|
|
Packit |
971217 |
static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
|
|
Packit |
971217 |
window);
|
|
Packit |
971217 |
static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
|
Packit |
971217 |
guintptr handle);
|
|
Packit |
971217 |
static void gst_gl_window_android_egl_draw (GstGLWindow * window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window_class->get_display =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_display);
|
|
Packit |
971217 |
window_class->get_window_handle =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_window_handle);
|
|
Packit |
971217 |
window_class->set_window_handle =
|
|
Packit |
971217 |
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_set_window_handle);
|
|
Packit |
971217 |
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_draw);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_window_android_egl_init (GstGLWindowAndroidEGL * window)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Must be called in the gl thread */
|
|
Packit |
971217 |
GstGLWindowAndroidEGL *
|
|
Packit |
971217 |
gst_gl_window_android_egl_new (GstGLDisplay * display)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindowAndroidEGL *window;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if ((gst_gl_display_get_handle_type (display) & GST_GL_DISPLAY_TYPE_EGL) == 0)
|
|
Packit |
971217 |
/* we require an egl display to create android windows */
|
|
Packit |
971217 |
return NULL;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GST_DEBUG ("creating Android EGL window");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window = g_object_new (GST_TYPE_GL_WINDOW_ANDROID_EGL, NULL);
|
|
Packit |
971217 |
gst_object_ref_sink (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return window;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
|
|
Packit |
971217 |
guintptr handle)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window_egl->native_window = (EGLNativeWindowType) handle;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guintptr
|
|
Packit |
971217 |
gst_gl_window_android_egl_get_window_handle (GstGLWindow * window)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return (guintptr) window_egl->native_window;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
draw_cb (gpointer data)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstGLWindowAndroidEGL *window_egl = data;
|
|
Packit |
971217 |
GstGLWindow *window = GST_GL_WINDOW (window_egl);
|
|
Packit |
971217 |
GstGLContext *context = gst_gl_window_get_context (window);
|
|
Packit |
971217 |
GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (context_egl->egl_surface) {
|
|
Packit |
971217 |
gint width, height;
|
|
Packit |
971217 |
guint window_width, window_height;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_gl_window_get_surface_dimensions (window, &window_width,
|
|
Packit |
971217 |
&window_height);
|
|
Packit |
971217 |
if (eglQuerySurface (context_egl->egl_display, context_egl->egl_surface,
|
|
Packit |
971217 |
EGL_WIDTH, &width)
|
|
Packit |
971217 |
&& eglQuerySurface (context_egl->egl_display, context_egl->egl_surface,
|
|
Packit |
971217 |
EGL_HEIGHT, &height)
|
|
Packit |
971217 |
&& (window->queue_resize || width != window_egl->window_width
|
|
Packit |
971217 |
|| height != window_egl->window_height)) {
|
|
Packit |
971217 |
gst_gl_window_resize (window, width, height);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (window->draw)
|
|
Packit |
971217 |
window->draw (window->draw_data);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_gl_context_swap_buffers (context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_object_unref (context);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_gl_window_android_egl_draw (GstGLWindow * window)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, window);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guintptr
|
|
Packit |
971217 |
gst_gl_window_android_egl_get_display (GstGLWindow * window)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
return 0;
|
|
Packit |
971217 |
}
|