Commit ccabf454 authored by Matthew Waters's avatar Matthew Waters 🐨 Committed by Tim-Philipp Müller

[618/906] add wayland-egl window backend

parent d1699074
......@@ -16,8 +16,10 @@ libgstgl_@GST_API_VERSION@_la_SOURCES = \
gstglwindow.c
libgstgl_@GST_API_VERSION@_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
$(GST_BASE_LIBS) $(GST_LIBS) \
$(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-$(GST_API_VERSION) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(GL_LIBS)
if HAVE_WINDOW_WIN32
......@@ -35,6 +37,11 @@ SUBDIRS += x11
libgstgl_@GST_API_VERSION@_la_LIBADD += x11/libgstgl-x11.la
endif
if HAVE_WINDOW_WAYLAND
SUBDIRS += wayland
libgstgl_@GST_API_VERSION@_la_LIBADD += wayland/libgstgl-wayland.la
endif
libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
libgstgl_@GST_API_VERSION@include_HEADERS = \
gstglwindow.h \
......@@ -55,7 +62,8 @@ libgstgl_@GST_API_VERSION@_la_CFLAGS = \
$(X_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS)
$(GST_CFLAGS) \
$(GL_CFLAGS)
libgstgl_@GST_API_VERSION@_la_LDFLAGS = \
$(GST_LIB_LDFLAGS) \
......
......@@ -21,6 +21,7 @@ libgstgl_cocoa_la_CFLAGS = \
libgstgl_cocoa_la_OBJCFLAGS = \
$(GL_CFLAGS) \
$(GL_OBJCFLAGS) \
$(X_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
......
......@@ -33,15 +33,15 @@
#ifdef HAVE_WINDOW_COCOA
#include "cocoa/gstglwindow_cocoa.h"
#endif
#ifdef HAVE_WINDOW_WAYLAND
#include "wayland/gstglwindow_wayland_egl.h"
#endif
#define GST_CAT_DEFAULT gst_gl_window_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_window_debug, "glwindow", 0, "glwindow element");
#define gst_gl_window_parent_class parent_class
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstGLWindow, gst_gl_window, G_TYPE_OBJECT,
DEBUG_INIT);
G_DEFINE_ABSTRACT_TYPE (GstGLWindow, gst_gl_window, G_TYPE_OBJECT);
static void
gst_gl_window_init (GstGLWindow * window)
......@@ -60,8 +60,17 @@ gst_gl_window_new (GstGLRendererAPI render_api, guintptr external_gl_context)
{
GstGLWindow *window = NULL;
const gchar *user_choice;
static volatile gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_window_debug, "glwindow", 0,
"glwindow element");
g_once_init_leave (&_init, 1);
}
user_choice = g_getenv ("GST_GL_WINDOW");
GST_INFO ("creating a window, user choice:%s", user_choice);
#ifdef HAVE_WINDOW_X11
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "x11")))
window =
......@@ -78,6 +87,12 @@ gst_gl_window_new (GstGLRendererAPI render_api, guintptr external_gl_context)
window =
GST_GL_WINDOW (gst_gl_window_cocoa_new (render_api,
external_gl_context));
#endif
#ifdef HAVE_WINDOW_WAYLAND
if (!window && (!user_choice || g_strstr_len (user_choice, 7, "wayland")))
window =
GST_GL_WINDOW (gst_gl_window_wayland_egl_new (render_api,
external_gl_context));
#endif
if (!window) {
GST_WARNING ("could not create a window, user choice:%s", user_choice);
......
......@@ -136,6 +136,8 @@ void gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB
GstGLPlatform gst_gl_window_get_platform (GstGLWindow *window);
GST_DEBUG_CATEGORY_EXTERN (gst_gl_window_debug);
G_END_DECLS
#endif /* __GST_GL_WINDOW_H__ */
## Process this file with automake to produce Makefile.in
noinst_LTLIBRARIES = libgstgl-wayland.la
libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
libgstglwaylandincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/wayland
libgstgl_wayland_la_SOURCES = \
gstglwindow_wayland_egl.c \
wayland_event_source.c
libgstglwaylandinclude_HEADERS = \
gstglwindow_wayland_egl.h \
wayland_event_source.h
libgstgl_wayland_la_CFLAGS = \
$(GL_CFLAGS) \
$(X_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
-I$(top_srcdir)/gst-libs/gst/gl
libgstgl_wayland_la_LDFLAGS = \
$(GST_LIB_LDFLAGS) \
$(GST_ALL_LDFLAGS) \
$(GST_LT_LDFLAGS)
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@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.
*/
#ifndef __GST_GL_WINDOW_WAYLAND_EGL_H__
#define __GST_GL_WINDOW_WAYLAND_EGL_H__
#include <wayland-client.h>
#include <wayland-egl.h>
#include <wayland-cursor.h>
#include <EGL/egl.h>
#include "gstglwindow.h"
G_BEGIN_DECLS
#define GST_GL_TYPE_WINDOW_WAYLAND_EGL (gst_gl_window_wayland_egl_get_type())
#define GST_GL_WINDOW_WAYLAND_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL))
#define GST_GL_WINDOW_WAYLAND_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGLClass))
#define GST_GL_IS_WINDOW_WAYLAND_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_WINDOW_WAYLAND_EGL))
#define GST_GL_IS_WINDOW_WAYLAND_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_WINDOW_WAYLAND_EGL))
#define GST_GL_WINDOW_WAYLAND_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_WINDOW_WAYLAND_EGL, GstGLWindowWaylandEGL_Class))
typedef struct _GstGLWindowWaylandEGL GstGLWindowWaylandEGL;
typedef struct _GstGLWindowWaylandEGLClass GstGLWindowWaylandEGLClass;
struct window;
struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_seat *seat;
/* struct wl_pointer *pointer;
struct wl_keyboard *keyboard;*/
struct wl_shm *shm;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor *default_cursor;
struct wl_surface *cursor_surface;
struct window *window;
};
struct window {
struct display *display;
struct wl_egl_window *native;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct wl_callback *callback;
int fullscreen, configured;
int window_width, window_height;
};
struct _GstGLWindowWaylandEGL {
/*< private >*/
GstGLWindow parent;
EGLContext egl_context;
EGLDisplay egl_display;
EGLSurface egl_surface;
EGLConfig egl_config;
struct display display;
struct window window;
GSource *wl_source;
GMainContext *main_context;
GMainLoop *loop;
gpointer _reserved[GST_PADDING];
};
struct _GstGLWindowWaylandEGLClass {
/*< private >*/
GstGLWindowClass parent_class;
/*< private >*/
gpointer _reserved[GST_PADDING];
};
GType gst_gl_window_wayland_egl_get_type (void);
GstGLWindowWaylandEGL * gst_gl_window_wayland_egl_new (GstGLRendererAPI render_api,
guintptr external_gl_context);
G_END_DECLS
#endif /* __GST_GL_WINDOW_X11_H__ */
/*
* GStreamer
* Copyright (C) 2010 Intel Corporation.
* Copyright (C) 2012 Matthew Waters <ystreet00@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.
*
* Authors:
* Matthew Allum
* Robert Bragg
* Kristian Høgsberg
*/
/* code originally from clutter's wayland backend found here
* http://git.gnome.org/browse/clutter/tree/clutter/wayland/clutter-event-wayland.c
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdint.h>
#include <stdlib.h>
#include <wayland-client.h>
#include "wayland_event_source.h"
typedef struct _WaylandEventSource
{
GSource source;
GPollFD pfd;
uint32_t mask;
struct wl_display *display;
} WaylandEventSource;
static gboolean
wayland_event_source_prepare (GSource * base, gint * timeout)
{
WaylandEventSource *source = (WaylandEventSource *) base;
gboolean retval;
*timeout = -1;
/* We have to add/remove the GPollFD if we want to update our
* poll event mask dynamically. Instead, let's just flush all
* writes on idle */
wl_display_flush (source->display);
retval = FALSE; //clutter_events_pending ();
return retval;
}
static gboolean
wayland_event_source_check (GSource * base)
{
WaylandEventSource *source = (WaylandEventSource *) base;
gboolean retval;
retval = source->pfd.revents; // || clutter_events_pending();
return retval;
}
static gboolean
wayland_event_source_dispatch (GSource * base,
GSourceFunc callback, gpointer data)
{
WaylandEventSource *source = (WaylandEventSource *) base;
// ClutterEvent *event;
if (source->pfd.revents) {
wl_display_roundtrip (source->display);
source->pfd.revents = 0;
}
if (callback)
callback (data);
#if 0
event = clutter_event_get ();
if (event) {
/* forward the event into clutter for emission etc. */
clutter_do_event (event);
clutter_event_free (event);
}
#endif
return TRUE;
}
static GSourceFuncs wayland_event_source_funcs = {
wayland_event_source_prepare,
wayland_event_source_check,
wayland_event_source_dispatch,
NULL
};
GSource *
wayland_event_source_new (struct wl_display *display)
{
WaylandEventSource *source;
source = (WaylandEventSource *)
g_source_new (&wayland_event_source_funcs, sizeof (WaylandEventSource));
source->display = display;
source->pfd.fd = wl_display_get_fd (display);
source->pfd.events = G_IO_IN | G_IO_ERR;
g_source_add_poll (&source->source, &source->pfd);
return &source->source;
}
/*
* GStreamer
* Copyright (C) 2011 Intel Corporation.
* Copyright (C) 2012 Matthew Waters <ystreet00@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.
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
/* code originally from clutter's wayland backend found here
* http://git.gnome.org/browse/clutter/tree/clutter/wayland/clutter-event-wayland.h
*/
#ifndef __WAYLAND_EVENT_SOURCE_H__
#define __WAYLAND_EVENT_SOURCE_H__
#include <glib-object.h>
//#include <clutter/clutter-event.h>
#include <wayland-client.h>
GSource *
wayland_event_source_new (struct wl_display *display);
#endif /* __WAYLAND_EVENT_SOURCE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment