From 303b77eeff5d3715ba74bf886ecf3cfd84ae5b0c Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 27 Nov 2013 17:52:46 +1100 Subject: [PATCH] [890/906] x11: add display subclass GstGLDisplayX11 holds the display connection and name. Each thread requires it's own X11 Display connection (initialised from name) due to the fact that we do not want to call XInitThreads(). Doing so would result in segfaults when integrating with GUI toolkits Gtk, Qt, etc. The Display connection is for OpenGL platforms where a constant display is required in order to share contexts (egl). In the case of a wrapped context (added later), we do not have GstGLWindow to retreive the display from so a 'master' connection is used instead. --- gst-libs/gst/gl/egl/gstglcontext_egl.c | 24 +++-- gst-libs/gst/gl/gstgldisplay.c | 56 ++++++++++- gst-libs/gst/gl/gstgldisplay.h | 3 + gst-libs/gst/gl/gstglwindow.c | 2 +- gst-libs/gst/gl/x11/Makefile.am | 5 + gst-libs/gst/gl/x11/gstgldisplay_x11.c | 125 +++++++++++++++++++++++++ gst-libs/gst/gl/x11/gstgldisplay_x11.h | 72 ++++++++++++++ gst-libs/gst/gl/x11/gstglwindow_x11.c | 119 ++++------------------- gst-libs/gst/gl/x11/gstglwindow_x11.h | 11 +-- gst-libs/gst/gl/x11/x11_event_source.c | 7 +- 10 files changed, 298 insertions(+), 126 deletions(-) create mode 100644 gst-libs/gst/gl/x11/gstgldisplay_x11.c create mode 100644 gst-libs/gst/gl/x11/gstgldisplay_x11.h diff --git a/gst-libs/gst/gl/egl/gstglcontext_egl.c b/gst-libs/gst/gl/egl/gstglcontext_egl.c index 9007a490b5..9aafd743d8 100644 --- a/gst-libs/gst/gl/egl/gstglcontext_egl.c +++ b/gst-libs/gst/gl/egl/gstglcontext_egl.c @@ -31,6 +31,7 @@ #if GST_GL_HAVE_WINDOW_X11 #include "../x11/gstglwindow_x11.h" +#include #endif #if GST_GL_HAVE_WINDOW_WIN32 #include "../win32/gstglwindow_win32.h" @@ -232,14 +233,25 @@ gst_gl_context_egl_create_context (GstGLContext * context, goto failure; } - if (other_context) { - GstGLContextEGL *other_egl = (GstGLContextEGL *) other_context; - egl->egl_display = other_egl->egl_display; - } else { - egl->egl_display = eglGetDisplay ((EGLNativeDisplayType) - gst_gl_window_get_display (window)); + display = gst_gl_context_get_display (context); + native_display = gst_gl_display_get_handle (display); + + if (!native_display) { + GstGLWindow *window = NULL; + + if (other_context) + window = gst_gl_context_get_window (other_context); + if (!window) + window = gst_gl_context_get_window (context); + if (window) { + native_display = gst_gl_window_get_display (window); + gst_object_unref (window); + } } + egl->egl_display = eglGetDisplay ((EGLNativeDisplayType) native_display); + gst_object_unref (display); + if (eglInitialize (egl->egl_display, &majorVersion, &minorVersion)) { GST_INFO ("egl initialized, version: %d.%d", majorVersion, minorVersion); } else { diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index 49758e4d87..656eb83cb3 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -39,6 +39,10 @@ #include "gl.h" #include "gstgldisplay.h" +#if GST_GL_HAVE_WINDOW_X11 +#include +#endif + GST_DEBUG_CATEGORY_STATIC (gst_context); GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug); #define GST_CAT_DEFAULT gst_gl_display_debug @@ -54,24 +58,23 @@ G_DEFINE_TYPE_WITH_CODE (GstGLDisplay, gst_gl_display, G_TYPE_OBJECT, (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_DISPLAY, GstGLDisplayPrivate)) static void gst_gl_display_finalize (GObject * object); +static guintptr gst_gl_display_default_get_handle (GstGLDisplay * display); struct _GstGLDisplayPrivate { gint dummy; }; -/*------------------------------------------------------------ - --------------------- For klass GstGLDisplay --------------- - ----------------------------------------------------------*/ static void gst_gl_display_class_init (GstGLDisplayClass * klass) { g_type_class_add_private (klass, sizeof (GstGLDisplayPrivate)); + klass->get_handle = gst_gl_display_default_get_handle; + G_OBJECT_CLASS (klass)->finalize = gst_gl_display_finalize; } - static void gst_gl_display_init (GstGLDisplay * display) { @@ -108,7 +111,32 @@ gst_gl_display_finalize (GObject * object) GstGLDisplay * gst_gl_display_new (void) { - return g_object_new (GST_TYPE_GL_DISPLAY, NULL); + GstGLDisplay *display = NULL; + const gchar *user_choice; + static volatile gsize _init = 0; + + if (g_once_init_enter (&_init)) { + GST_DEBUG_CATEGORY_INIT (gst_gl_display_debug, "gldisplay", 0, + "gldisplay element"); + g_once_init_leave (&_init, 1); + } + + user_choice = g_getenv ("GST_GL_WINDOW"); + GST_INFO ("creating a window, user choice:%s", user_choice); + +#if GST_GL_HAVE_WINDOW_X11 + if (!display && (!user_choice || g_strstr_len (user_choice, 3, "x11"))) + display = GST_GL_DISPLAY (gst_gl_display_x11_new (NULL)); +#endif + if (!display) { + /* subclass returned a NULL window */ + GST_WARNING ("Could not create display. user specified %s, creating dummy", + user_choice ? user_choice : "(null)"); + + return g_object_new (GST_TYPE_GL_DISPLAY, NULL); + } + + return display; } GstGLAPI @@ -119,6 +147,24 @@ gst_gl_display_get_gl_api (GstGLDisplay * display) return display->gl_api; } +guintptr +gst_gl_display_get_handle (GstGLDisplay * display) +{ + GstGLDisplayClass *klass; + + g_return_val_if_fail (GST_IS_GL_DISPLAY (display), 0); + klass = GST_GL_DISPLAY_GET_CLASS (display); + g_return_val_if_fail (klass->get_handle != NULL, 0); + + return klass->get_handle (display); +} + +static guintptr +gst_gl_display_default_get_handle (GstGLDisplay * display) +{ + return 0; +} + /** * gst_context_set_gl_display: * @context: a #GstContext diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index 9863226960..0145545697 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -75,6 +75,8 @@ struct _GstGLDisplay struct _GstGLDisplayClass { GstObjectClass object_class; + + guintptr (*get_handle) (GstGLDisplay * display); }; GstGLDisplay *gst_gl_display_new (void); @@ -84,6 +86,7 @@ GstGLDisplay *gst_gl_display_new (void); GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display); gpointer gst_gl_display_get_gl_vtable (GstGLDisplay * display); +guintptr gst_gl_display_get_handle (GstGLDisplay * display); #define GST_GL_DISPLAY_CONTEXT_TYPE "gst.gl.GLDisplay" void gst_context_set_gl_display (GstContext * context, GstGLDisplay * display); diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c index 1e460dc764..966b3700a9 100644 --- a/gst-libs/gst/gl/gstglwindow.c +++ b/gst-libs/gst/gl/gstglwindow.c @@ -143,7 +143,7 @@ gst_gl_window_new (GstGLDisplay * display) #endif #if GST_GL_HAVE_WINDOW_X11 if (!window && (!user_choice || g_strstr_len (user_choice, 3, "x11"))) - window = GST_GL_WINDOW (gst_gl_window_x11_new ()); + window = GST_GL_WINDOW (gst_gl_window_x11_new (display)); #endif #if GST_GL_HAVE_WINDOW_WIN32 if (!window && (!user_choice || g_strstr_len (user_choice, 5, "win32"))) diff --git a/gst-libs/gst/gl/x11/Makefile.am b/gst-libs/gst/gl/x11/Makefile.am index e5db6d0528..fa96598ca1 100644 --- a/gst-libs/gst/gl/x11/Makefile.am +++ b/gst-libs/gst/gl/x11/Makefile.am @@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libgstgl-x11.la libgstgl_x11_la_SOURCES = \ + gstgldisplay_x11.c \ gstglwindow_x11.c \ x11_event_source.c @@ -10,6 +11,10 @@ noinst_HEADERS = \ gstglwindow_x11.h \ x11_event_source.h +libgstgl_x11includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl/x11 +libgstgl_x11include_HEADERS = \ + gstgldisplay_x11.h + if USE_GLX libgstgl_x11_la_SOURCES += gstglcontext_glx.c noinst_HEADERS += gstglcontext_glx.h diff --git a/gst-libs/gst/gl/x11/gstgldisplay_x11.c b/gst-libs/gst/gl/x11/gstgldisplay_x11.c new file mode 100644 index 0000000000..e6086b7839 --- /dev/null +++ b/gst-libs/gst/gl/x11/gstgldisplay_x11.c @@ -0,0 +1,125 @@ +/* + * GStreamer + * Copyright (C) 2013 Matthew Waters + * + * 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 + +#include + +GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug); +#define GST_CAT_DEFAULT gst_gl_display_debug + +G_DEFINE_TYPE (GstGLDisplayX11, gst_gl_display_x11, GST_TYPE_GL_DISPLAY); + +static void gst_gl_display_x11_finalize (GObject * object); +static guintptr gst_gl_display_x11_get_handle (GstGLDisplay * display); + +static void +gst_gl_display_x11_class_init (GstGLDisplayX11Class * klass) +{ + GST_GL_DISPLAY_CLASS (klass)->get_handle = + GST_DEBUG_FUNCPTR (gst_gl_display_x11_get_handle); + + G_OBJECT_CLASS (klass)->finalize = gst_gl_display_x11_finalize; +} + +static void +gst_gl_display_x11_init (GstGLDisplayX11 * display_x11) +{ + GstGLDisplay *display = (GstGLDisplay *) display_x11; + + display->type = GST_GL_DISPLAY_TYPE_X11; + display_x11->foreign_display = FALSE; +} + +static void +gst_gl_display_x11_finalize (GObject * object) +{ + GstGLDisplayX11 *display_x11 = GST_GL_DISPLAY_X11 (object); + + if (display_x11->name) + g_free (display_x11->name); + + if (!display_x11->foreign_display && display_x11->display) { + XCloseDisplay (display_x11->display); + } + + G_OBJECT_CLASS (gst_gl_display_x11_parent_class)->finalize (object); +} + +/** + * gst_gl_display_x11_new: + * @name: (allow-none): a display name + * + * Create a new #GstGLDisplayX11 from the x11 display name. See XOpenDisplay() + * for details on what is a valid name. + * + * Returns: (transfer full): a new #GstGLDisplayX11 or %NULL + */ +GstGLDisplayX11 * +gst_gl_display_x11_new (const gchar * name) +{ + GstGLDisplayX11 *ret; + + GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay"); + + ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL); + ret->name = g_strdup (name); + ret->display = XOpenDisplay (ret->name); + + if (!ret->display) { + GST_ERROR ("Failed to open X11 display connection with name, \'%s\'", name); + } + + return ret; +} + +/** + * gst_gl_display_x11_new_with_display: + * @display: an existing, x11 display + * + * Creates a new display connection from a X11 Display. + * + * Returns: (transfer full): a new #GstGLDisplayX11 + */ +GstGLDisplayX11 * +gst_gl_display_x11_new_with_display (Display * display) +{ + GstGLDisplayX11 *ret; + + g_return_val_if_fail (display != NULL, NULL); + + GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay"); + + ret = g_object_new (GST_TYPE_GL_DISPLAY_X11, NULL); + + ret->name = g_strdup (DisplayString (display)); + ret->display = display; + ret->foreign_display = TRUE; + + return ret; +} + +static guintptr +gst_gl_display_x11_get_handle (GstGLDisplay * display) +{ + return (guintptr) GST_GL_DISPLAY_X11 (display)->display; +} diff --git a/gst-libs/gst/gl/x11/gstgldisplay_x11.h b/gst-libs/gst/gl/x11/gstgldisplay_x11.h new file mode 100644 index 0000000000..d80ba51f1a --- /dev/null +++ b/gst-libs/gst/gl/x11/gstgldisplay_x11.h @@ -0,0 +1,72 @@ +/* + * GStreamer + * Copyright (C) 2013 Matthew Waters + * + * 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_DISPLAY_X11_H__ +#define __GST_GL_DISPLAY_X11_H__ + +#include + +#include +#include + +#include +#include + +G_BEGIN_DECLS + +GType gst_gl_display_x11_get_type (void); + +#define GST_TYPE_GL_DISPLAY_X11 (gst_gl_display_x11_get_type()) +#define GST_GL_DISPLAY_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_X11,GstGLDisplayX11)) +#define GST_GL_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_X11,GstGLDisplayX11Class)) +#define GST_IS_GL_DISPLAY_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_X11)) +#define GST_IS_GL_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_X11)) +#define GST_GL_DISPLAY_X11_CAST(obj) ((GstGLDisplayX11*)(obj)) + +typedef struct _GstGLDisplayX11 GstGLDisplayX11; +typedef struct _GstGLDisplayX11Class GstGLDisplayX11Class; + +/** + * GstGLDisplayX11: + * + * the contents of a #GstGLDisplayX11 are private and should only be accessed + * through the provided API + */ +struct _GstGLDisplayX11 +{ + GstGLDisplay parent; + + /* */ + gchar *name; + Display *display; + gboolean foreign_display; +}; + +struct _GstGLDisplayX11Class +{ + GstGLDisplayClass object_class; +}; + +GstGLDisplayX11 *gst_gl_display_x11_new (const gchar * name); +GstGLDisplayX11 *gst_gl_display_x11_new_with_display (Display *display); + +G_END_DECLS + +#endif /* __GST_GL_DISPLAY_X11_H__ */ diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c index ad100fefa6..27c4fb22ff 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.c +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c @@ -30,6 +30,7 @@ #include "x11_event_source.h" #include "gstglwindow_x11.h" +#include "gstgldisplay_x11.h" #define GST_GL_WINDOW_X11_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW_X11, GstGLWindowX11Private)) @@ -73,46 +74,6 @@ gboolean gst_gl_window_x11_create_context (GstGLWindow * window, gboolean gst_gl_window_x11_open (GstGLWindow * window, GError ** error); void gst_gl_window_x11_close (GstGLWindow * window); -static void -gst_gl_window_x11_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstGLWindowX11 *window_x11; - - g_return_if_fail (GST_GL_IS_WINDOW_X11 (object)); - - window_x11 = GST_GL_WINDOW_X11 (object); - - switch (prop_id) { - case ARG_DISPLAY: - window_x11->display_name = g_strdup (g_value_get_string (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_gl_window_x11_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstGLWindowX11 *window_x11; - - g_return_if_fail (GST_GL_IS_WINDOW_X11 (object)); - - window_x11 = GST_GL_WINDOW_X11 (object); - - switch (prop_id) { - case ARG_DISPLAY: - g_value_set_string (value, window_x11->display_name); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static void gst_gl_window_x11_finalize (GObject * object) { @@ -135,14 +96,8 @@ gst_gl_window_x11_class_init (GstGLWindowX11Class * klass) g_type_class_add_private (klass, sizeof (GstGLWindowX11Private)); - obj_class->set_property = gst_gl_window_x11_set_property; - obj_class->get_property = gst_gl_window_x11_get_property; obj_class->finalize = gst_gl_window_x11_finalize; - g_object_class_install_property (obj_class, ARG_DISPLAY, - g_param_spec_string ("display", "Display", "X Display name", NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - window_class->get_display = GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_display); window_class->set_window_handle = GST_DEBUG_FUNCPTR (gst_gl_window_x11_set_window_handle); @@ -169,10 +124,16 @@ gst_gl_window_x11_init (GstGLWindowX11 * window) /* Must be called in the gl thread */ GstGLWindowX11 * -gst_gl_window_x11_new (void) +gst_gl_window_x11_new (GstGLDisplay * display) { GstGLWindowX11 *window = NULL; + if ((display->type & GST_GL_DISPLAY_TYPE_X11) == GST_GL_DISPLAY_TYPE_NONE) { + GST_INFO ("Wrong display type %u for this window type %u", display->type, + GST_GL_DISPLAY_TYPE_X11); + return NULL; + } + window = g_object_new (GST_GL_TYPE_WINDOW_X11, NULL); return window; @@ -182,8 +143,10 @@ gboolean gst_gl_window_x11_open (GstGLWindow * window, GError ** error) { GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window); + GstGLDisplayX11 *display_x11 = (GstGLDisplayX11 *) window->display; - window_x11->device = XOpenDisplay (window_x11->display_name); + window_x11->device = XOpenDisplay (display_x11->name); +// window_x11->device = display_x11->display; if (window_x11->device == NULL) { g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, @@ -195,14 +158,13 @@ gst_gl_window_x11_open (GstGLWindow * window, GError ** error) GST_LOG ("gl device id: %ld", (gulong) window_x11->device); - window_x11->disp_send = XOpenDisplay (window_x11->display_name); +// window_x11->disp_send = XOpenDisplay (DisplayString (display_x11->display)); + window_x11->disp_send = XOpenDisplay (display_x11->name); XSynchronize (window_x11->disp_send, FALSE); GST_LOG ("gl display sender: %ld", (gulong) window_x11->disp_send); - g_assert (window_x11->device); - window_x11->screen = DefaultScreenOfDisplay (window_x11->device); window_x11->screen_num = DefaultScreen (window_x11->device); window_x11->visual = @@ -279,8 +241,8 @@ gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11) XSync (window_x11->device, FALSE); - XSetWindowBackgroundPixmap (window_x11->device, window_x11->internal_win_id, - None); + XSetWindowBackgroundPixmap (window_x11->device, + window_x11->internal_win_id, None); GST_LOG ("gl window id: %lud", (gulong) window_x11->internal_win_id); GST_LOG ("gl window props: x:%d y:%d", x, y); @@ -289,8 +251,8 @@ gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11) if (wm_atoms[0] == None) GST_DEBUG ("Cannot create WM_DELETE_WINDOW"); - XSetWMProtocols (window_x11->device, window_x11->internal_win_id, wm_atoms, - 1); + XSetWMProtocols (window_x11->device, window_x11->internal_win_id, + wm_atoms, 1); wm_hints.flags = StateHint; wm_hints.initial_state = NormalState; @@ -330,8 +292,6 @@ gst_gl_window_x11_close (GstGLWindow * window) while (XPending (window_x11->device)) XNextEvent (window_x11->device, &event); - XSetCloseDownMode (window_x11->device, DestroyAll); - /*XAddToSaveSet (display, w) Display *display; Window w; */ @@ -362,46 +322,6 @@ gst_gl_window_x11_close (GstGLWindow * window) g_mutex_unlock (&window_x11->disp_send_lock); } -guintptr -gst_gl_window_x11_get_gl_context (GstGLWindow * window) -{ - GstGLWindowX11Class *window_class; - - window_class = GST_GL_WINDOW_X11_GET_CLASS (window); - - return window_class->get_gl_context (GST_GL_WINDOW_X11 (window)); -} - -static void -callback_activate (GstGLWindow * window) -{ - GstGLWindowX11Class *window_class; - GstGLWindowX11Private *priv; - GstGLWindowX11 *window_x11; - - window_x11 = GST_GL_WINDOW_X11 (window); - window_class = GST_GL_WINDOW_X11_GET_CLASS (window_x11); - priv = window_x11->priv; - - priv->activate_result = window_class->activate (window_x11, priv->activate); -} - -gboolean -gst_gl_window_x11_activate (GstGLWindow * window, gboolean activate) -{ - GstGLWindowX11 *window_x11; - GstGLWindowX11Private *priv; - - window_x11 = GST_GL_WINDOW_X11 (window); - priv = window_x11->priv; - priv->activate = activate; - - gst_gl_window_send_message (window, GST_GL_WINDOW_CB (callback_activate), - window_x11); - - return priv->activate_result; -} - /* Not called by the gl thread */ void gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id) @@ -593,7 +513,6 @@ gst_gl_window_x11_handle_event (GstGLWindowX11 * window_x11) GstGLContext *context; GstGLContextClass *context_class; GstGLWindow *window; - gboolean ret = TRUE; window = GST_GL_WINDOW (window_x11); @@ -773,9 +692,7 @@ gst_gl_window_x11_untrap_x_errors (void) guintptr gst_gl_window_x11_get_display (GstGLWindow * window) { - GstGLWindowX11 *window_x11; - - window_x11 = GST_GL_WINDOW_X11 (window); + GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window); return (guintptr) window_x11->device; } diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.h b/gst-libs/gst/gl/x11/gstglwindow_x11.h index 68bdc7beb8..26509f1513 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.h +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.h @@ -54,7 +54,6 @@ struct _GstGLWindowX11 gboolean allow_extra_expose_events; /* opengl context */ - gchar *display_name; Display *device; Screen *screen; gint screen_num; @@ -95,21 +94,13 @@ struct _GstGLWindowX11Class { /*< private >*/ GstGLWindowClass parent_class; - gboolean (*choose_format) (GstGLWindowX11 *window, GError ** error); - gboolean (*create_context) (GstGLWindowX11 *window, GstGLAPI gl_api, - guintptr external_gl_context, GError ** error); - void (*swap_buffers) (GstGLWindowX11 *window); - gboolean (*activate) (GstGLWindowX11 *window, gboolean activate); - void (*destroy_context) (GstGLWindowX11 *window); - guintptr (*get_gl_context) (GstGLWindowX11 *window); - /*< private >*/ gpointer _reserved[GST_PADDING_LARGE]; }; GType gst_gl_window_x11_get_type (void); -GstGLWindowX11 * gst_gl_window_x11_new (void); +GstGLWindowX11 * gst_gl_window_x11_new (GstGLDisplay * display); void gst_gl_window_x11_trap_x_errors (void); gint gst_gl_window_x11_untrap_x_errors (void); diff --git a/gst-libs/gst/gl/x11/x11_event_source.c b/gst-libs/gst/gl/x11/x11_event_source.c index 0d83776a83..df6413a4fe 100644 --- a/gst-libs/gst/gl/x11/x11_event_source.c +++ b/gst-libs/gst/gl/x11/x11_event_source.c @@ -26,6 +26,7 @@ #include #include "x11_event_source.h" +#include "gstgldisplay_x11.h" extern gboolean gst_gl_window_x11_handle_event (GstGLWindowX11 * window_x11); @@ -45,7 +46,7 @@ x11_event_source_prepare (GSource * base, gint * timeout) *timeout = -1; - retval = XPending (source->window->device); //clutter_events_pending (); + retval = XPending (source->window->device); return retval; } @@ -56,7 +57,7 @@ x11_event_source_check (GSource * base) X11EventSource *source = (X11EventSource *) base; gboolean retval; - retval = source->pfd.revents; // || clutter_events_pending(); + retval = source->pfd.revents; return retval; } @@ -89,7 +90,7 @@ x11_event_source_new (GstGLWindowX11 * window_x11) source = (X11EventSource *) g_source_new (&x11_event_source_funcs, sizeof (X11EventSource)); source->window = window_x11; - source->pfd.fd = ConnectionNumber (window_x11->device); + source->pfd.fd = ConnectionNumber (source->window->device); source->pfd.events = G_IO_IN | G_IO_ERR; g_source_add_poll (&source->source, &source->pfd);