[longomatch] Handle XOverlay for all platforms
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Handle XOverlay for all platforms
- Date: Fri, 24 Aug 2012 21:40:14 +0000 (UTC)
commit 23f7ab2ac84463705c8e18af380b72098c79c494
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Aug 24 19:21:46 2012 +0200
Handle XOverlay for all platforms
libcesarplayer/bacon-video-widget-gst-0.10.c | 31 +++++++++++--------------
libcesarplayer/gst-camera-capturer.c | 26 +++++++--------------
libcesarplayer/video-utils.c | 16 +++++++++++++
libcesarplayer/video-utils.h | 5 ++++
4 files changed, 44 insertions(+), 34 deletions(-)
---
diff --git a/libcesarplayer/bacon-video-widget-gst-0.10.c b/libcesarplayer/bacon-video-widget-gst-0.10.c
index 7e84709..e3aef5f 100644
--- a/libcesarplayer/bacon-video-widget-gst-0.10.c
+++ b/libcesarplayer/bacon-video-widget-gst-0.10.c
@@ -59,16 +59,24 @@
#include <math.h>
/* gtk+/gnome */
-#ifdef WIN32
+#include <gdk/gdk.h>
+#if defined (GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+#elif defined (GDK_WINDOWING_WIN32)
#include <gdk/gdkwin32.h>
+#elif defined (GDK_WINDOWING_QUARTZ)
+#include <gdk/gdkquartz.h>
+#endif
+#include <gtk/gtk.h>
+
+
+#ifdef WIN32
#define DEFAULT_VIDEO_SINK "autovideosink"
#define BACKUP_VIDEO_SINK "autovideosink"
#else
-#include <gdk/gdkx.h>
#define DEFAULT_VIDEO_SINK "gsettingsvideosink"
#define BACKUP_VIDEO_SINK "autovideosink"
#endif
-#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
@@ -532,6 +540,7 @@ bacon_video_widget_realize (GtkWidget * widget)
bvw->priv->video_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (bvw->priv->video_window, widget);
+ gdk_window_ensure_native(bvw->priv->video_window);
gdk_color_parse ("black", &colour);
gdk_colormap_alloc_color (gtk_widget_get_colormap (widget),
@@ -653,13 +662,7 @@ bacon_video_widget_expose_event (GtkWidget * widget, GdkEventExpose * event)
if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay)) {
-#ifdef WIN32
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_HWND (bvw->priv->video_window));
-#else
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_XID (bvw->priv->video_window));
-#endif
+ gst_set_window_handle(xoverlay, bvw->priv->video_window);
}
/* Start with a nice black canvas */
@@ -5352,13 +5355,7 @@ bvw_element_msg_sync (GstBus * bus, GstMessage * msg, gpointer data)
g_return_if_fail (bvw->priv->xoverlay != NULL);
g_return_if_fail (bvw->priv->video_window != NULL);
-#ifdef WIN32
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_HWND (bvw->priv->video_window));
-#else
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_XID (bvw->priv->video_window));
-#endif
+ gst_set_window_handle(bvw->priv->xoverlay, bvw->priv->video_window);
}
}
diff --git a/libcesarplayer/gst-camera-capturer.c b/libcesarplayer/gst-camera-capturer.c
index 1e8d461..cebcb0e 100644
--- a/libcesarplayer/gst-camera-capturer.c
+++ b/libcesarplayer/gst-camera-capturer.c
@@ -47,11 +47,15 @@
#endif
/* gtk+/gnome */
-#ifdef WIN32
-#include <gdk/gdkwin32.h>
-#else
+#include <gdk/gdk.h>
+#if defined (GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
+#elif defined (GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#elif defined (GDK_WINDOWING_QUARTZ)
+#include <gdk/gdkquartz.h>
#endif
+#include <gtk/gtk.h>
#ifdef WIN32
#define DEFAULT_SOURCE_TYPE GST_CAMERA_CAPTURE_SOURCE_TYPE_DSHOW
@@ -653,13 +657,7 @@ gst_camera_capturer_expose_event (GtkWidget * widget, GdkEventExpose * event)
if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay)) {
gdk_window_show (gcc->priv->video_window);
-#ifdef WIN32
- gst_x_overlay_set_xwindow_id (gcc->priv->xoverlay,
- GDK_WINDOW_HWND (gcc->priv->video_window));
-#else
- gst_x_overlay_set_xwindow_id (gcc->priv->xoverlay,
- GDK_WINDOW_XID (gcc->priv->video_window));
-#endif
+ gst_set_window_handle (gcc->priv->xoverlay,gcc->priv->video_window);
}
/* Start with a nice black canvas */
@@ -1564,13 +1562,7 @@ gcc_element_msg_sync (GstBus * bus, GstMessage * msg, gpointer data)
g_return_if_fail (gcc->priv->xoverlay != NULL);
g_return_if_fail (gcc->priv->video_window != NULL);
-#ifdef WIN32
- gst_x_overlay_set_xwindow_id (gcc->priv->xoverlay,
- GDK_WINDOW_HWND (gcc->priv->video_window));
-#else
- gst_x_overlay_set_xwindow_id (gcc->priv->xoverlay,
- GDK_WINDOW_XID (gcc->priv->video_window));
-#endif
+ gst_set_window_handle (gcc->priv->xoverlay,gcc->priv->video_window);
}
}
diff --git a/libcesarplayer/video-utils.c b/libcesarplayer/video-utils.c
index 9053db8..80f37a4 100644
--- a/libcesarplayer/video-utils.c
+++ b/libcesarplayer/video-utils.c
@@ -237,6 +237,22 @@ totem_ratio_fits_screen (GdkWindow * video_window, int video_width,
}
void
+gst_set_window_handle(GstXOverlay *xoverlay, GdkWindow *window)
+{
+ guintptr window_handle;
+
+ /* Retrieve window handler from GDK */
+#if defined (GDK_WINDOWING_WIN32)
+ window_handle = (guintptr)GDK_WINDOW_HWND (window);
+#elif defined (GDK_WINDOWING_QUARTZ)
+ window_handle = gdk_quartz_window_get_nsview (window);
+#elif defined (GDK_WINDOWING_X11)
+ window_handle = GDK_WINDOW_XID (window);
+#endif
+ gst_x_overlay_set_window_handle (xoverlay, window_handle);
+}
+
+void
init_backend (int argc, char **argv)
{
gst_init(&argc, &argv);
diff --git a/libcesarplayer/video-utils.h b/libcesarplayer/video-utils.h
index 0fc074c..aa90595 100644
--- a/libcesarplayer/video-utils.h
+++ b/libcesarplayer/video-utils.h
@@ -1,4 +1,6 @@
+#include <gst/gst.h>
+#include <gst/interfaces/xoverlay.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
@@ -25,3 +27,6 @@ gboolean totem_ratio_fits_screen (GdkWindow * window, int video_width,
int video_height, gfloat ratio);
EXPORT void init_backend (int argc, char **argv);
+EXPORT void gst_set_window_handle (GstXOverlay *overlay, GdkWindow *window);
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]