diff options
author | Matthew Waters <matthew@centricular.com> | 2015-05-27 16:42:55 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2015-05-31 16:04:13 +1000 |
commit | 349685ad27588dc622c98f40bd7579b06d56df6e (patch) | |
tree | 2a2f6c12487a619171435e50c43ac92b3fca4652 /tests/examples/gl/gtk/gstgtk.c | |
parent | de389e07dc553110bb68cc5399bcfc3802df067f (diff) | |
download | gstreamer-plugins-bad-349685ad27588dc622c98f40bd7579b06d56df6e.tar.gz |
tests/gl/gtk: implement setting a wayland display/surface
Diffstat (limited to 'tests/examples/gl/gtk/gstgtk.c')
-rw-r--r-- | tests/examples/gl/gtk/gstgtk.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/examples/gl/gtk/gstgtk.c b/tests/examples/gl/gtk/gstgtk.c index 07cd08d2d..3f89c5bd0 100644 --- a/tests/examples/gl/gtk/gstgtk.c +++ b/tests/examples/gl/gtk/gstgtk.c @@ -30,10 +30,55 @@ #if GST_GL_HAVE_WINDOW_X11 && defined(GDK_WINDOWING_X11) #include <gdk/gdkx.h> #endif +#if GST_GL_HAVE_WINDOW_WAYLAND && defined(GDK_WINDOWING_WAYLAND) +#include <gdk/gdkwayland.h> +#endif #if GST_GL_HAVE_WINDOW_COCOA && defined(GDK_WINDOWING_QUARTZ) #include <gdk/gdkquartz.h> #endif +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; + GstContext *context = NULL; + + gst_message_parse_context_type (msg, &context_type); + g_print ("got need context %s\n", context_type); + + if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) { + 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; + } + } + } + } + default: + break; + } + + return ret; +} void gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay, @@ -66,5 +111,12 @@ gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay, gst_video_overlay_set_window_handle (videooverlay, GDK_WINDOW_XID (window)); } else #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 +#endif g_error ("Unsupported Gtk+ backend"); } |