2009-07-14 18:36:13 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2009 David A. Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-08 11:53:56 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-07-14 18:36:13 +00:00
|
|
|
*/
|
2013-07-10 09:24:34 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2009-04-13 03:03:30 +00:00
|
|
|
|
2013-12-29 06:29:53 +00:00
|
|
|
#include <gst/gl/gl.h>
|
2009-04-13 03:03:30 +00:00
|
|
|
#include "gstgtk.h"
|
|
|
|
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32)
|
2009-04-13 03:03:30 +00:00
|
|
|
#include <gdk/gdkwin32.h>
|
2013-12-29 06:29:53 +00:00
|
|
|
#endif
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11)
|
2009-04-13 03:03:30 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2013-12-29 06:29:53 +00:00
|
|
|
#endif
|
2015-05-27 06:42:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
#include <gdk/gdkwayland.h>
|
|
|
|
#endif
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ)
|
2009-04-13 03:03:30 +00:00
|
|
|
#include <gdk/gdkquartz.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-27 06:42:55 +00:00
|
|
|
gboolean
|
|
|
|
gst_gtk_handle_need_context (GstBus * bus, GstMessage * msg, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
case GST_MESSAGE_NEED_CONTEXT:
|
|
|
|
{
|
|
|
|
const gchar *context_type;
|
|
|
|
|
|
|
|
gst_message_parse_context_type (msg, &context_type);
|
|
|
|
g_print ("got need context %s\n", context_type);
|
|
|
|
|
|
|
|
if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
|
2015-06-01 12:05:06 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
GstContext *context = NULL;
|
2015-05-27 06:42:55 +00:00
|
|
|
GdkDisplay *gdk_display = gdk_display_get_default ();
|
|
|
|
if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) {
|
|
|
|
struct wl_display *wayland_display =
|
|
|
|
gdk_wayland_display_get_wl_display (gdk_display);
|
|
|
|
if (wayland_display) {
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
context =
|
|
|
|
gst_context_new ("GstWaylandDisplayHandleContextType", TRUE);
|
|
|
|
|
|
|
|
s = gst_context_writable_structure (context);
|
|
|
|
gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gst_element_set_context (GST_ELEMENT (msg->src), context);
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2015-06-01 12:05:06 +00:00
|
|
|
#else
|
|
|
|
GST_ERROR
|
|
|
|
("Asked for wayland display context, but compiled without wayland support");
|
|
|
|
#endif
|
2015-05-27 06:42:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-04-13 03:03:30 +00:00
|
|
|
|
|
|
|
void
|
2012-06-06 14:51:47 +00:00
|
|
|
gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay,
|
2013-12-29 06:29:53 +00:00
|
|
|
GtkWidget * widget)
|
2009-04-13 03:03:30 +00:00
|
|
|
{
|
2013-12-29 06:29:53 +00:00
|
|
|
GdkWindow *window;
|
|
|
|
GdkDisplay *display;
|
|
|
|
const gchar *user_choice = g_getenv ("GST_GL_WINDOW");
|
2009-04-13 03:03:30 +00:00
|
|
|
|
2013-12-29 06:29:53 +00:00
|
|
|
window = gtk_widget_get_window (widget);
|
|
|
|
display = gdk_window_get_display (window);
|
2009-04-13 03:03:30 +00:00
|
|
|
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32)
|
2013-12-29 06:29:53 +00:00
|
|
|
if (GDK_IS_WIN32_DISPLAY (display) && (!user_choice
|
|
|
|
|| g_strcmp0 (user_choice, "win32") == 0)) {
|
|
|
|
gst_video_overlay_set_window_handle (videooverlay,
|
|
|
|
(guintptr) GDK_WINDOW_HWND (window));
|
|
|
|
} else
|
|
|
|
#endif
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ)
|
2013-12-29 06:29:53 +00:00
|
|
|
if (GDK_IS_QUARTZ_DISPLAY (display) && (!user_choice
|
|
|
|
|| g_strcmp0 (user_choice, "cocoa") == 0)) {
|
|
|
|
gst_video_overlay_set_window_handle (videooverlay, (guintptr)
|
|
|
|
gdk_quartz_window_get_nswindow (window));
|
|
|
|
} else
|
|
|
|
#endif
|
2014-04-29 06:38:55 +00:00
|
|
|
#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11)
|
2013-12-29 06:29:53 +00:00
|
|
|
if (GDK_IS_X11_DISPLAY (display) && (!user_choice
|
|
|
|
|| g_strcmp0 (user_choice, "x11") == 0)) {
|
|
|
|
gst_video_overlay_set_window_handle (videooverlay, GDK_WINDOW_XID (window));
|
|
|
|
} else
|
2015-05-27 06:42:55 +00:00
|
|
|
#endif
|
|
|
|
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
|
|
if (GDK_IS_WAYLAND_DISPLAY (display) && (!user_choice
|
|
|
|
|| g_strcmp0 (user_choice, "wayland") == 0)) {
|
|
|
|
gst_video_overlay_set_window_handle (videooverlay,
|
|
|
|
(guintptr) gdk_wayland_window_get_wl_surface (window));
|
|
|
|
} else
|
2013-12-29 06:29:53 +00:00
|
|
|
#endif
|
|
|
|
g_error ("Unsupported Gtk+ backend");
|
2009-04-13 03:03:30 +00:00
|
|
|
}
|