docs: add win32 code snippets to GstXOverlay Gtk+ example

This commit is contained in:
Philip Flarsheim 2012-01-05 01:51:35 +00:00 committed by Tim-Philipp Müller
parent b15b03ee6f
commit 08af765ea2

View file

@ -148,8 +148,11 @@
* #ifdef GDK_WINDOWING_X11 * #ifdef GDK_WINDOWING_X11
* #include <gdk/gdkx.h> // for GDK_WINDOW_XID * #include <gdk/gdkx.h> // for GDK_WINDOW_XID
* #endif * #endif
* #ifdef GDK_WINDOWING_WIN32
* #include <gdk/gdkwin32.h> // for GDK_WINDOW_HWND
* #endif
* ... * ...
* static gulong video_window_xid = 0; * static guintptr video_window_handle = 0;
* ... * ...
* static GstBusSyncReply * static GstBusSyncReply
* bus_sync_handler (GstBus * bus, GstMessage * message, gpointer user_data) * bus_sync_handler (GstBus * bus, GstMessage * message, gpointer user_data)
@ -160,14 +163,14 @@
* if (!gst_structure_has_name (message->structure, "prepare-xwindow-id")) * if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
* return GST_BUS_PASS; * return GST_BUS_PASS;
* *
* if (video_window_xid != 0) { * if (video_window_handle != 0) {
* GstXOverlay *xoverlay; * GstXOverlay *xoverlay;
* *
* // GST_MESSAGE_SRC (message) will be the video sink element * // GST_MESSAGE_SRC (message) will be the video sink element
* xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message)); * xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message));
* gst_x_overlay_set_window_handle (xoverlay, video_window_xid); * gst_x_overlay_set_window_handle (xoverlay, video_window_handle);
* } else { * } else {
* g_warning ("Should have obtained video_window_xid by now!"); * g_warning ("Should have obtained video_window_handle by now!");
* } * }
* *
* gst_message_unref (message); * gst_message_unref (message);
@ -178,6 +181,8 @@
* video_widget_realize_cb (GtkWidget * widget, gpointer data) * video_widget_realize_cb (GtkWidget * widget, gpointer data)
* { * {
* #if GTK_CHECK_VERSION(2,18,0) * #if GTK_CHECK_VERSION(2,18,0)
* // Tell Gtk+/Gdk to create a native window for this widget instead of
* // drawing onto the parent widget.
* // This is here just for pedagogical purposes, GDK_WINDOW_XID will call * // This is here just for pedagogical purposes, GDK_WINDOW_XID will call
* // it as well in newer Gtk versions * // it as well in newer Gtk versions
* if (!gdk_window_ensure_native (widget->window)) * if (!gdk_window_ensure_native (widget->window))
@ -185,7 +190,16 @@
* #endif * #endif
* *
* #ifdef GDK_WINDOWING_X11 * #ifdef GDK_WINDOWING_X11
* video_window_xid = GDK_WINDOW_XID (gtk_widget_get_window (video_window)); * {
* gulong xid = GDK_WINDOW_XID (gtk_widget_get_window (video_window));
* video_window_handle = xid;
* }
* #endif
* #ifdef GDK_WINDOWING_WIN32
* {
* HWND wnd = GDK_WINDOW_HWND (gtk_widget_get_window (video_window));
* video_window_handle = (guintptr) wnd;
* }
* #endif * #endif
* } * }
* ... * ...
@ -211,12 +225,12 @@
* gtk_widget_show_all (app_window); * gtk_widget_show_all (app_window);
* *
* // realize window now so that the video window gets created and we can * // realize window now so that the video window gets created and we can
* // obtain its XID before the pipeline is started up and the videosink * // obtain its XID/HWND before the pipeline is started up and the videosink
* // asks for the XID of the window to render onto * // asks for the XID/HWND of the window to render onto
* gtk_widget_realize (video_window); * gtk_widget_realize (video_window);
* *
* // we should have the XID now * // we should have the XID/HWND now
* g_assert (video_window_xid != 0); * g_assert (video_window_handle != 0);
* ... * ...
* // set up sync handler for setting the xid once the pipeline is started * // set up sync handler for setting the xid once the pipeline is started
* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); * bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));