|
Packit |
971217 |
/*
|
|
Packit |
971217 |
* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2009 David A. Schleef <ds@schleef.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 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gl/gl.h>
|
|
Packit |
971217 |
#include "gstgtk.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32)
|
|
Packit |
971217 |
#include <gdk/gdkwin32.h>
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11)
|
|
Packit |
971217 |
#include <gdk/gdkx.h>
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
Packit |
971217 |
#include <gdk/gdkwayland.h>
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ)
|
|
Packit |
971217 |
#include <gdk/gdkquartz.h>
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean
|
|
Packit |
971217 |
gst_gtk_handle_need_context (GstBus * bus, GstMessage * msg, gpointer data)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
gboolean ret = FALSE;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
switch (GST_MESSAGE_TYPE (msg)) {
|
|
Packit |
971217 |
case GST_MESSAGE_NEED_CONTEXT:
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
const gchar *context_type;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_message_parse_context_type (msg, &context_type);
|
|
Packit |
971217 |
g_print ("got need context %s\n", context_type);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) {
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
Packit |
971217 |
GstContext *context = NULL;
|
|
Packit |
971217 |
GdkDisplay *gdk_display = gdk_display_get_default ();
|
|
Packit |
971217 |
if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) {
|
|
Packit |
971217 |
struct wl_display *wayland_display =
|
|
Packit |
971217 |
gdk_wayland_display_get_wl_display (gdk_display);
|
|
Packit |
971217 |
if (wayland_display) {
|
|
Packit |
971217 |
GstStructure *s;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
context =
|
|
Packit |
971217 |
gst_context_new ("GstWaylandDisplayHandleContextType", TRUE);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
s = gst_context_writable_structure (context);
|
|
Packit |
971217 |
gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display,
|
|
Packit |
971217 |
NULL);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_element_set_context (GST_ELEMENT (msg->src), context);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
ret = TRUE;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
#else
|
|
Packit |
971217 |
GST_ERROR
|
|
Packit |
971217 |
("Asked for wayland display context, but compiled without wayland support");
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
default:
|
|
Packit |
971217 |
break;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return ret;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
void
|
|
Packit |
971217 |
gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay,
|
|
Packit |
971217 |
GtkWidget * widget)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GdkWindow *window;
|
|
Packit |
971217 |
GdkDisplay *display;
|
|
Packit |
971217 |
const gchar *user_choice = g_getenv ("GST_GL_WINDOW");
|
|
Packit |
971217 |
|
|
Packit |
971217 |
window = gtk_widget_get_window (widget);
|
|
Packit |
971217 |
display = gdk_window_get_display (window);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_WIN32 && defined(GDK_WINDOWING_WIN32)
|
|
Packit |
971217 |
if (GDK_IS_WIN32_DISPLAY (display) && (!user_choice
|
|
Packit |
971217 |
|| g_strcmp0 (user_choice, "win32") == 0)) {
|
|
Packit |
971217 |
gst_video_overlay_set_window_handle (videooverlay,
|
|
Packit |
971217 |
(guintptr) GDK_WINDOW_HWND (window));
|
|
Packit |
971217 |
} else
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ)
|
|
Packit |
971217 |
if (GDK_IS_QUARTZ_DISPLAY (display) && (!user_choice
|
|
Packit |
971217 |
|| g_strcmp0 (user_choice, "cocoa") == 0)) {
|
|
Packit |
971217 |
gst_video_overlay_set_window_handle (videooverlay, (guintptr)
|
|
Packit |
971217 |
gdk_quartz_window_get_nsview (window));
|
|
Packit |
971217 |
} else
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11)
|
|
Packit |
971217 |
if (GDK_IS_X11_DISPLAY (display) && (!user_choice
|
|
Packit |
971217 |
|| g_strcmp0 (user_choice, "x11") == 0)) {
|
|
Packit |
971217 |
gst_video_overlay_set_window_handle (videooverlay, GDK_WINDOW_XID (window));
|
|
Packit |
971217 |
} else
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND)
|
|
Packit |
971217 |
if (GDK_IS_WAYLAND_DISPLAY (display) && (!user_choice
|
|
Packit |
971217 |
|| g_strcmp0 (user_choice, "wayland") == 0)) {
|
|
Packit |
971217 |
gst_video_overlay_set_window_handle (videooverlay,
|
|
Packit |
971217 |
(guintptr) gdk_wayland_window_get_wl_surface (window));
|
|
Packit |
971217 |
} else
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
g_error ("Unsupported Gtk+ backend");
|
|
Packit |
971217 |
}
|