[prev in list] [next in list] [prev in thread] [next in thread]
List: gstreamer-cvs
Subject: gst-plugins-bad: gl/examples: update gtk examples for wayland
From: ystreet () kemper ! freedesktop ! org (Matthew Waters)
Date: 2015-05-31 6:33:29
Message-ID: 20150531063329.D6C11761E8 () kemper ! freedesktop ! org
[Download RAW message or body]
Module: gst-plugins-bad
Branch: master
Commit: 21cbf763b056b00262593bf642bdfa7fac3c6b79
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=21cbf763b056b00262593bf642bdfa7fac3c6b79
Author: Matthew Waters <matthew@centricular.com>
Date: Sun May 31 15:40:15 2015 +1000
gl/examples: update gtk examples for wayland
---
tests/examples/gl/gtk/filtervideooverlay/main.cpp | 52 +++++++++++++++--
tests/examples/gl/gtk/switchvideooverlay/main.cpp | 64 +++++++++++++++++----
2 files changed, 100 insertions(+), 16 deletions(-)
diff --git a/tests/examples/gl/gtk/filtervideooverlay/main.cpp \
b/tests/examples/gl/gtk/filtervideooverlay/main.cpp index 8ca402d..70b4b00 100644
--- a/tests/examples/gl/gtk/filtervideooverlay/main.cpp
+++ b/tests/examples/gl/gtk/filtervideooverlay/main.cpp
@@ -27,6 +27,11 @@
static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* \
widget) {
+ GtkAllocation allocation;
+
+ if (gst_gtk_handle_need_context (bus, message, NULL))
+ return GST_BUS_DROP;
+
// ignore anything but 'prepare-window-handle' element messages
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
@@ -38,22 +43,55 @@ static GstBusSyncReply create_window (GstBus* bus, GstMessage* \
message, GtkWidge
gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), \
widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC \
(message)), allocation.x, allocation.y, allocation.width, allocation.height); +
gst_message_unref (message);
return GST_BUS_DROP;
}
-
-static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline)
+static gboolean
+resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink)
{
- g_print("End of stream\n");
+ GtkAllocation allocation;
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref(pipeline);
+ gtk_widget_get_allocation (widget, &allocation);
+ gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), allocation.x, \
allocation.y, allocation.width, allocation.height);
- gtk_main_quit();
+ return G_SOURCE_CONTINUE;
}
+static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline)
+{
+ GError *error = NULL;
+ gchar *details;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR:
+ gst_message_parse_error (message, &error, &details);
+
+ g_print("Error %s\n", error->message);
+ g_print("Details %s\n", details);
+ /* fallthrough */
+ case GST_MESSAGE_EOS:
+ g_print("End of stream\n");
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref(pipeline);
+
+ gtk_main_quit();
+ break;
+ case GST_MESSAGE_WARNING:
+ gst_message_parse_warning (message, &error, &details);
+
+ g_print("Warning %s\n", error->message);
+ g_print("Details %s\n", details);
+ break;
+ default:
+ break;
+ }
+}
static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, GstElement* videosink)
{
@@ -211,6 +249,7 @@ gint main (gint argc, gchar *argv[])
//area where the video is drawn
GtkWidget* area = gtk_drawing_area_new();
+ gtk_widget_set_redraw_on_allocate (area, TRUE);
gtk_container_add (GTK_CONTAINER (window), area);
gtk_widget_realize(area);
@@ -227,6 +266,7 @@ gint main (gint argc, gchar *argv[])
//needed when being in GST_STATE_READY, GST_STATE_PAUSED
//or resizing/obscuring the window
g_signal_connect(area, "draw", G_CALLBACK(expose_cb), videosink);
+ g_signal_connect(area, "configure-event", G_CALLBACK(resize_cb), videosink);
//start
GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
diff --git a/tests/examples/gl/gtk/switchvideooverlay/main.cpp \
b/tests/examples/gl/gtk/switchvideooverlay/main.cpp index e8378b8..ea53ea1 100644
--- a/tests/examples/gl/gtk/switchvideooverlay/main.cpp
+++ b/tests/examples/gl/gtk/switchvideooverlay/main.cpp
@@ -27,6 +27,11 @@
static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* \
widget) {
+ GtkAllocation allocation;
+
+ if (gst_gtk_handle_need_context (bus, message, NULL))
+ return GST_BUS_DROP;
+
// ignore anything but 'prepare-window-handle' element messages
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
@@ -38,22 +43,55 @@ static GstBusSyncReply create_window (GstBus* bus, GstMessage* \
message, GtkWidge
gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), \
widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC \
(message)), allocation.x, allocation.y, allocation.width, allocation.height); +
gst_message_unref (message);
return GST_BUS_DROP;
}
-
-static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline)
+static gboolean
+resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink)
{
- g_print("End of stream\n");
+ GtkAllocation allocation;
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref(pipeline);
+ gtk_widget_get_allocation (widget, &allocation);
+ gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), allocation.x, \
allocation.y, allocation.width, allocation.height);
- gtk_main_quit();
+ return G_SOURCE_CONTINUE;
}
+static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline)
+{
+ GError *error = NULL;
+ gchar *details;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR:
+ gst_message_parse_error (message, &error, &details);
+
+ g_print("Error %s\n", error->message);
+ g_print("Details %s\n", details);
+ /* fallthrough */
+ case GST_MESSAGE_EOS:
+ g_print("End of stream\n");
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref(pipeline);
+
+ gtk_main_quit();
+ break;
+ case GST_MESSAGE_WARNING:
+ gst_message_parse_warning (message, &error, &details);
+
+ g_print("Warning %s\n", error->message);
+ g_print("Details %s\n", details);
+ break;
+ default:
+ break;
+ }
+}
static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, GstElement* videosink)
{
@@ -65,9 +103,14 @@ static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, \
GstElement* videosink)
static gboolean on_click_drawing_area(GtkWidget* widget, GdkEventButton* event, \
GstElement* videosink) {
+ GtkAllocation allocation;
+
g_print ("switch the drawing area %p\n", widget);
gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (videosink), widget);
- gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink));
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (videosink), \
allocation.x, allocation.y, allocation.width, allocation.height); +
return FALSE;
}
@@ -115,9 +158,6 @@ static void area_realize_cb(GtkWidget* widget, gpointer data)
g_print ("realize %p\n", widget);
if (!gdk_window_ensure_native (gtk_widget_get_window (widget)))
g_error ("Failed to create native window!");
-
- //avoid flickering when resizing or obscuring the main window
- gtk_widget_set_app_paintable(widget, TRUE);
}
@@ -214,6 +254,8 @@ gint main (gint argc, gchar *argv[])
g_signal_connect(area_top_left, "realize", G_CALLBACK(area_realize_cb), NULL);
g_signal_connect(area_top_right, "realize", G_CALLBACK(area_realize_cb), NULL);
+ gtk_widget_set_redraw_on_allocate (area_top_left, TRUE);
+ gtk_widget_set_redraw_on_allocate (area_top_right, TRUE);
gtk_widget_realize(area_top_left);
gtk_widget_realize(area_top_right);
@@ -228,7 +270,9 @@ gint main (gint argc, gchar *argv[])
//needed when being in GST_STATE_READY, GST_STATE_PAUSED
//or resizing/obscuring the window
g_signal_connect(area_top_left, "draw", G_CALLBACK(expose_cb), videosink);
+ g_signal_connect(area_top_left, "configure-event", G_CALLBACK(resize_cb), \
videosink);
g_signal_connect(area_top_right, "draw", G_CALLBACK(expose_cb), videosink);
+ g_signal_connect(area_top_right, "configure-event", G_CALLBACK(resize_cb), \
videosink);
//switch the drawing area
g_signal_connect(area_top_left, "button-press-event", \
G_CALLBACK(on_click_drawing_area), videosink);
_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic