summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2009-12-29 00:53:53 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-12-29 00:53:53 +0000
commit7388401f935fb3b0bb3212b18ae55521fec31d6e (patch)
tree9351fa41f04cc2919cba72d12889fdc465d82e98
parentf82ac8bf44120bd7b19438cb1a505a8dd1029c4e (diff)
tests: fix colorkey test up for Gtk+ >= 2.18
Make test-colorkey work with newer versions of Gtk+. See #601809.
-rw-r--r--tests/icles/test-colorkey.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/tests/icles/test-colorkey.c b/tests/icles/test-colorkey.c
index b0ba42a57..e51d36330 100644
--- a/tests/icles/test-colorkey.c
+++ b/tests/icles/test-colorkey.c
@@ -38,32 +38,9 @@
38 38
39static GtkWidget *video_window = NULL; 39static GtkWidget *video_window = NULL;
40static GstElement *sink = NULL; 40static GstElement *sink = NULL;
41static guint embed_xid = 0; 41static gulong embed_xid = 0;
42static GdkGC *trans_gc = NULL; 42static GdkGC *trans_gc = NULL;
43 43
44static GstBusSyncReply
45bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
46{
47 if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) &&
48 gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
49 GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
50
51 g_print ("got prepare-xwindow-id\n");
52 if (!embed_xid) {
53 embed_xid = GDK_WINDOW_XID (GDK_WINDOW (video_window->window));
54 }
55
56 if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
57 "force-aspect-ratio")) {
58 g_object_set (element, "force-aspect-ratio", TRUE, NULL);
59 }
60
61 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
62 embed_xid);
63 }
64 return GST_BUS_PASS;
65}
66
67static void 44static void
68redraw_overlay (GtkWidget * widget) 45redraw_overlay (GtkWidget * widget)
69{ 46{
@@ -102,6 +79,18 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
102} 79}
103 80
104static void 81static void
82realize_cb (GtkWidget * widget, gpointer data)
83{
84 /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
85 * as well */
86 if (!gdk_window_ensure_native (widget->window))
87 g_error ("Couldn't create native window needed for GstXOverlay!");
88
89 embed_xid = GDK_WINDOW_XID (video_window->window);
90 g_print ("Window realize: got XID %lu\n", embed_xid);
91}
92
93static void
105msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline) 94msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
106{ 95{
107 const GstStructure *s; 96 const GstStructure *s;
@@ -192,13 +181,16 @@ main (int argc, char **argv)
192 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); 181 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
193 gst_element_link (src, sink); 182 gst_element_link (src, sink);
194 183
195 g_object_set (G_OBJECT (sink), "autopaint-colorkey", FALSE, "force-aspect-ratio", TRUE, "draw-borders", FALSE, "colorkey", 0x7F7F7F, /* gray */ 184#define COLOR_GRAY 0x7F7F7F
196 NULL); 185
186 g_object_set (G_OBJECT (sink), "autopaint-colorkey", FALSE,
187 "force-aspect-ratio", TRUE, "draw-borders", FALSE,
188 "colorkey", COLOR_GRAY, NULL);
197 189
198 /* check xvimagesink capabilities */ 190 /* check xvimagesink capabilities */
199 sret = gst_element_set_state (pipeline, GST_STATE_READY); 191 sret = gst_element_set_state (pipeline, GST_STATE_READY);
200 if (sret == GST_STATE_CHANGE_FAILURE) { 192 if (sret == GST_STATE_CHANGE_FAILURE) {
201 g_printerr ("Can't set pipelien to READY\n"); 193 g_printerr ("Can't set pipeline to READY\n");
202 gst_object_unref (pipeline); 194 gst_object_unref (pipeline);
203 return -1; 195 return -1;
204 } 196 }
@@ -223,8 +215,6 @@ main (int argc, char **argv)
223 g_value_array_free (arr); 215 g_value_array_free (arr);
224 216
225 bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); 217 bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
226 gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler,
227 pipeline);
228 gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH); 218 gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
229 g_signal_connect (bus, "message::state-changed", 219 g_signal_connect (bus, "message::state-changed",
230 G_CALLBACK (msg_state_changed), pipeline); 220 G_CALLBACK (msg_state_changed), pipeline);
@@ -242,12 +232,28 @@ main (int argc, char **argv)
242 G_CALLBACK (handle_resize_cb), NULL); 232 G_CALLBACK (handle_resize_cb), NULL);
243 g_signal_connect (G_OBJECT (video_window), "expose-event", 233 g_signal_connect (G_OBJECT (video_window), "expose-event",
244 G_CALLBACK (handle_expose_cb), NULL); 234 G_CALLBACK (handle_expose_cb), NULL);
235 g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
245 gtk_widget_set_double_buffered (video_window, FALSE); 236 gtk_widget_set_double_buffered (video_window, FALSE);
246 gtk_container_add (GTK_CONTAINER (window), video_window); 237 gtk_container_add (GTK_CONTAINER (window), video_window);
247 238
248 /* show the gui and play */ 239 /* show the gui and play */
249 240
250 gtk_widget_show_all (window); 241 gtk_widget_show_all (window);
242
243 /* realize window now so that the video window gets created and we can
244 * obtain its XID before the pipeline is started up and the videosink
245 * asks for the XID of the window to render onto */
246 gtk_widget_realize (window);
247
248 /* we should have the XID now */
249 g_assert (embed_xid != 0);
250
251 /* we know what the video sink is in this case (xvimagesink), so we can
252 * just set it directly here now (instead of waiting for a prepare-xwindow-id
253 * element message in a sync bus handler and setting it there) */
254 g_print ("setting XID %lu\n", embed_xid);
255 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
256
251 g_idle_add (start_pipeline, pipeline); 257 g_idle_add (start_pipeline, pipeline);
252 gtk_main (); 258 gtk_main ();
253 259