xoverlay: Add guintptr versions of functions
authorDavid Schleef <ds@schleef.org>
Sun, 5 Sep 2010 22:17:47 +0000 (15:17 -0700)
committerDavid Schleef <ds@schleef.org>
Wed, 15 Sep 2010 07:10:23 +0000 (00:10 -0700)
And deprecate the gulong versions.  This is to support platforms
where sizeof(unsigned long) < sizeof(void *).  Fixes #627565.

API: Add gst_x_overlay_set_window_handle()
API: Deprecate: gst_x_overlay_set_xwindow_id()
API: Add gst_x_overlay_got_window_handle()
API: Deprecate: gst_x_overlay_got_xwindow_id()
API: Add GstXOverlay::set_window_handle()
API: Deprecate: GstXOverlay::set_xwindow_id()

14 files changed:
gst-libs/gst/interfaces/xoverlay.c
gst-libs/gst/interfaces/xoverlay.h
sys/v4l/gstv4lxoverlay.c
sys/ximage/ximagesink.c
sys/xvimage/xvimagesink.c
tests/examples/overlay/gtk-xoverlay.c
tests/examples/overlay/qt-xoverlay.cpp
tests/examples/overlay/qtgv-xoverlay.cpp
tests/examples/seek/jsseek.c
tests/examples/seek/seek.c
tests/icles/stress-xoverlay.c
tests/icles/test-colorkey.c
tests/icles/test-xoverlay.c
win32/common/libgstinterfaces.def

index 84858e9..382d40d 100644 (file)
@@ -78,7 +78,7 @@
  *  
  *  XSync (disp, FALSE);
  *   
- *  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
+ *  gst_x_overlay_set_window_handle (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
  *      win);
  *   
  *  gst_message_unref (message);
  * usually the case when the application creates the videosink to use
  * (e.g. #xvimagesink, #ximagesink, etc.) itself; in this case, the application
  * can just create the videosink element, create and realize the window to
- * render the video on and then call gst_x_overlay_set_xwindow_id() directly
+ * render the video on and then call gst_x_overlay_set_window_handle() directly
  * with the XID or native window handle, before starting up the pipeline.
  * </para>
  * <para>
  * </para>
  * <para>
  * As response to the prepare-xwindow-id element message in the bus sync
- * handler, the application may use gst_x_overlay_set_xwindow_id() to tell
+ * handler, the application may use gst_x_overlay_set_window_handle() to tell
  * the video sink to render onto an existing window surface. At this point the
  * application should already have obtained the window handle / XID, so it
  * just needs to set it. It is generally not advisable to call any GUI toolkit
  *    
  *    // GST_MESSAGE_SRC (message) will be the video sink element
  *    xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message));
- *    gst_x_overlay_set_xwindow_id (xoverlay, video_window_xid);
+ *    gst_x_overlay_set_window_handle (xoverlay, video_window_xid);
  *  } else {
  *    g_warning ("Should have obtained video_window_xid by now!");
  *  }
  *   window.show();
  *   
  *   WId xwinid = window.winId();
- *   gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
+ *   gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
  * 
  *   // run the pipeline
  * 
@@ -328,9 +328,7 @@ gst_x_overlay_get_type (void)
 static void
 gst_x_overlay_base_init (gpointer g_class)
 {
-  GstXOverlayClass *overlay_class = (GstXOverlayClass *) g_class;
 
-  overlay_class->set_xwindow_id = NULL;
 }
 
 /**
@@ -342,10 +340,37 @@ gst_x_overlay_base_init (gpointer g_class)
  * use this method to tell to a XOverlay to display video output to a
  * specific XWindow. Passing 0 as the xwindow_id will tell the overlay to
  * stop using that window and create an internal one.
+ *
+ * Deprecated: Use gst_x_overlay_set_window_handle() instead.
  */
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+void gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
+#endif
 void
 gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
 {
+  GST_WARNING_OBJECT (overlay,
+      "Using deprecated gst_x_overlay_set_xwindow_id()");
+  gst_x_overlay_set_window_handle (overlay, xwindow_id);
+}
+#endif
+
+/**
+ * gst_x_overlay_set_window_handle:
+ * @overlay: a #GstXOverlay to set the XWindow on.
+ * @xwindow_id: a #XID referencing the XWindow.
+ *
+ * This will call the video overlay's set_window_handle method. You
+ * should use this method to tell to a XOverlay to display video output to a
+ * specific XWindow. Passing 0 as the xwindow_id will tell the overlay to
+ * stop using that window and create an internal one.
+ *
+ * Since: 0.10.31
+ */
+void
+gst_x_overlay_set_window_handle (GstXOverlay * overlay, guintptr handle)
+{
   GstXOverlayClass *klass;
 
   g_return_if_fail (overlay != NULL);
@@ -353,8 +378,21 @@ gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
 
   klass = GST_X_OVERLAY_GET_CLASS (overlay);
 
-  if (klass->set_xwindow_id) {
-    klass->set_xwindow_id (overlay, xwindow_id);
+  if (klass->set_window_handle) {
+    klass->set_window_handle (overlay, handle);
+  } else {
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+#define set_xwindow_id set_xwindow_id_disabled
+#endif
+    if (sizeof (guintptr) <= sizeof (gulong) && klass->set_xwindow_id) {
+      GST_WARNING_OBJECT (overlay,
+          "Calling deprecated set_xwindow_id() method");
+      klass->set_xwindow_id (overlay, handle);
+    } else {
+      g_warning ("Refusing to cast guintptr to smaller gulong");
+    }
+#endif
   }
 }
 
@@ -366,19 +404,45 @@ gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
  * This will post a "have-xwindow-id" element message on the bus.
  *
  * This function should only be used by video overlay plugin developers.
+ *
+ * Deprecated: Use gst_x_overlay_got_window_handle() instead.
  */
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+void gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
+#endif
 void
 gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
 {
+  GST_WARNING_OBJECT (overlay,
+      "Using deprecated gst_x_overlay_got_xwindow_id()");
+  gst_x_overlay_got_xwindow_id (overlay, xwindow_id);
+}
+#endif
+
+/**
+ * gst_x_overlay_got_window_handle:
+ * @overlay: a #GstXOverlay which got a window
+ * @handle: a platform-specific handle referencing the window
+ *
+ * This will post a "have-xwindow-id" element message on the bus.
+ *
+ * This function should only be used by video overlay plugin developers.
+ */
+void
+gst_x_overlay_got_window_handle (GstXOverlay * overlay, guintptr handle)
+{
   GstStructure *s;
   GstMessage *msg;
 
   g_return_if_fail (overlay != NULL);
   g_return_if_fail (GST_IS_X_OVERLAY (overlay));
 
-  GST_LOG_OBJECT (GST_OBJECT (overlay), "xwindow_id = %lu", xwindow_id);
-  s = gst_structure_new ("have-xwindow-id", "xwindow-id", G_TYPE_ULONG,
-      xwindow_id, NULL);
+  GST_LOG_OBJECT (GST_OBJECT (overlay), "xwindow_id = %" G_GUINTPTR_FORMAT,
+      handle);
+  s = gst_structure_new ("have-xwindow-id",
+      "xwindow-id", G_TYPE_ULONG, (unsigned long) handle,
+      "window-handle", G_TYPE_UINT64, (guint64) handle, NULL);
   msg = gst_message_new_element (GST_OBJECT (overlay), s);
   gst_element_post_message (GST_ELEMENT (overlay), msg);
 }
@@ -468,7 +532,7 @@ gst_x_overlay_handle_events (GstXOverlay * overlay, gboolean handle_events)
  * @height: the height of the render area inside the window
  *
  * Configure a subregion as a video target within the window set by
- * gst_x_overlay_set_xwindow_id(). If this is not used or not supported
+ * gst_x_overlay_set_window_handle(). If this is not used or not supported
  * the video will fill the area of the window set as the overlay to 100%.
  * By specifying the rectangle, the video can be overlayed to a specific region
  * of that window only. After setting the new rectangle one should call
index 779f59d..055f510 100644 (file)
@@ -63,8 +63,13 @@ struct _GstXOverlayClass {
   GTypeInterface klass;
 
   /* virtual functions */
+#ifndef GST_DISABLE_DEPRECATED
   void (* set_xwindow_id)      (GstXOverlay *overlay,
                                 gulong       xwindow_id);
+#else
+  void (* set_xwindow_id_disabled) (GstXOverlay *overlay,
+                                gulong       xwindow_id);
+#endif /* not GST_DISABLE_DEPRECATED */
 
   void (* expose)              (GstXOverlay *overlay);
   
@@ -75,15 +80,19 @@ struct _GstXOverlayClass {
                                  gint x, gint y,
                                  gint width, gint height);
 
+  void (* set_window_handle)   (GstXOverlay *overlay,
+                                guintptr    handle);
     /*< private >*/
-  gpointer                 _gst_reserved[GST_PADDING - 2];
+  gpointer                 _gst_reserved[GST_PADDING - 3];
 };
 
 GType   gst_x_overlay_get_type          (void);
 
 /* virtual class function wrappers */
+#ifndef GST_DISABLE_DEPRECATED
 void gst_x_overlay_set_xwindow_id      (GstXOverlay *overlay, 
                                         gulong xwindow_id);
+#endif
 
 gboolean gst_x_overlay_set_render_rectangle (GstXOverlay *overlay,
                                              gint x, gint y,
@@ -94,9 +103,16 @@ void gst_x_overlay_expose              (GstXOverlay *overlay);
 void gst_x_overlay_handle_events       (GstXOverlay *overlay,
                                         gboolean     handle_events);
 
+void gst_x_overlay_set_window_handle   (GstXOverlay *overlay, 
+                                        guintptr handle);
 
 /* public methods to dispatch bus messages */
+#ifndef GST_DISABLE_DEPRECATED
 void gst_x_overlay_got_xwindow_id     (GstXOverlay *overlay, gulong xwindow_id);
+#endif
+
+void gst_x_overlay_got_window_handle  (GstXOverlay *overlay,
+    guintptr handle);
 
 void gst_x_overlay_prepare_xwindow_id (GstXOverlay *overlay);
 
index cefb883..5867caf 100644 (file)
@@ -46,14 +46,14 @@ struct _GstV4lXv
   GMutex *mutex;
 };
 
-static void gst_v4l_xoverlay_set_xwindow_id (GstXOverlay * overlay,
-    XID xwindow_id);
+static void gst_v4l_xoverlay_set_window_handle (GstXOverlay * overlay,
+    guintptr xwindow_id);
 
 void
 gst_v4l_xoverlay_interface_init (GstXOverlayClass * klass)
 {
   /* default virtual functions */
-  klass->set_xwindow_id = gst_v4l_xoverlay_set_xwindow_id;
+  klass->set_window_handle = gst_v4l_xoverlay_set_window_handle;
 
   GST_DEBUG_CATEGORY_INIT (v4lxv_debug, "v4lxv", 0,
       "V4L XOverlay interface debugging");
@@ -126,7 +126,7 @@ gst_v4l_xoverlay_open (GstV4lElement * v4lelement)
   v4lelement->xv = v4lxv;
 
   if (v4lelement->xwindow_id) {
-    gst_v4l_xoverlay_set_xwindow_id (GST_X_OVERLAY (v4lelement),
+    gst_v4l_xoverlay_set_window_handle (GST_X_OVERLAY (v4lelement),
         v4lelement->xwindow_id);
   }
 }
@@ -140,7 +140,7 @@ gst_v4l_xoverlay_close (GstV4lElement * v4lelement)
     return;
 
   if (v4lelement->xwindow_id) {
-    gst_v4l_xoverlay_set_xwindow_id (GST_X_OVERLAY (v4lelement), 0);
+    gst_v4l_xoverlay_set_window_handle (GST_X_OVERLAY (v4lelement), 0);
   }
 
   XCloseDisplay (v4lxv->dpy);
@@ -189,8 +189,9 @@ idle_refresh (gpointer data)
 }
 
 static void
-gst_v4l_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
+gst_v4l_xoverlay_set_window_handle (GstXOverlay * overlay, guintptr id)
 {
+  XID xwindow_id = id;
   GstV4lElement *v4lelement = GST_V4LELEMENT (overlay);
   GstV4lXv *v4lxv;
   XWindowAttributes attr;
index 0e768b0..8645dae 100644 (file)
@@ -886,7 +886,7 @@ gst_ximagesink_xwindow_new (GstXImageSink * ximagesink, gint width, gint height)
 
   gst_ximagesink_xwindow_decorate (ximagesink, xwindow);
 
-  gst_x_overlay_got_xwindow_id (GST_X_OVERLAY (ximagesink), xwindow->win);
+  gst_x_overlay_got_window_handle (GST_X_OVERLAY (ximagesink), xwindow->win);
 
   return xwindow;
 }
@@ -2008,8 +2008,9 @@ gst_ximagesink_navigation_init (GstNavigationInterface * iface)
 }
 
 static void
-gst_ximagesink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
+gst_ximagesink_set_window_handle (GstXOverlay * overlay, guintptr id)
 {
+  XID xwindow_id = id;
   GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
   GstXWindow *xwindow = NULL;
   XWindowAttributes attr;
@@ -2124,7 +2125,7 @@ gst_ximagesink_set_event_handling (GstXOverlay * overlay,
 static void
 gst_ximagesink_xoverlay_init (GstXOverlayClass * iface)
 {
-  iface->set_xwindow_id = gst_ximagesink_set_xwindow_id;
+  iface->set_window_handle = gst_ximagesink_set_window_handle;
   iface->expose = gst_ximagesink_expose;
   iface->handle_events = gst_ximagesink_set_event_handling;
 }
index b4a0096..cd0aca5 100644 (file)
@@ -1012,7 +1012,7 @@ gst_xvimagesink_xwindow_new (GstXvImageSink * xvimagesink,
 
   gst_xvimagesink_xwindow_decorate (xvimagesink, xwindow);
 
-  gst_x_overlay_got_xwindow_id (GST_X_OVERLAY (xvimagesink), xwindow->win);
+  gst_x_overlay_got_window_handle (GST_X_OVERLAY (xvimagesink), xwindow->win);
 
   return xwindow;
 }
@@ -2794,8 +2794,9 @@ gst_xvimagesink_navigation_init (GstNavigationInterface * iface)
 }
 
 static void
-gst_xvimagesink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
+gst_xvimagesink_set_window_handle (GstXOverlay * overlay, guintptr id)
 {
+  XID xwindow_id = id;
   GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
   GstXWindow *xwindow = NULL;
 
@@ -2951,7 +2952,7 @@ gst_xvimagesink_set_render_rectangle (GstXOverlay * overlay, gint x, gint y,
 static void
 gst_xvimagesink_xoverlay_init (GstXOverlayClass * iface)
 {
-  iface->set_xwindow_id = gst_xvimagesink_set_xwindow_id;
+  iface->set_window_handle = gst_xvimagesink_set_window_handle;
   iface->expose = gst_xvimagesink_expose;
   iface->handle_events = gst_xvimagesink_set_event_handling;
   iface->set_render_rectangle = gst_xvimagesink_set_render_rectangle;
index aaf77fd..cb0dc54 100644 (file)
@@ -134,7 +134,7 @@ main (int argc, char **argv)
 
   video_window_xwindow = gtk_widget_get_window (video_window);
   embed_xid = GDK_WINDOW_XID (video_window_xwindow);
-  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
+  gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), embed_xid);
 
   /* run the pipeline */
 
index 7edfabb..aa483a7 100644 (file)
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
   window.show();
   
   WId xwinid = window.winId();
-  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
+  gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
 
   /* run the pipeline */
 
index 6925286..58af85b 100644 (file)
@@ -93,7 +93,7 @@ void SinkPipeline::startPipeline()
    * just set it directly here now (instead of waiting for a prepare-xwindow-id
    * element message in a sync bus handler and setting it there) */
 
-  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
+  gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
 
   sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
   if (sret == GST_STATE_CHANGE_FAILURE) {
index 83d54d6..95b1482 100644 (file)
@@ -2451,7 +2451,7 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
      * shouldn't be done from a non-GUI thread without explicit locking).  */
     g_assert (embed_xid != 0);
 
-    gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (element), embed_xid);
+    gst_x_overlay_set_window_handle (GST_X_OVERLAY (element), embed_xid);
   }
   return GST_BUS_PASS;
 }
index 3baddcc..cc4d802 100644 (file)
@@ -2438,7 +2438,7 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
      * shouldn't be done from a non-GUI thread without explicit locking).  */
     g_assert (embed_xid != 0);
 
-    gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (element), embed_xid);
+    gst_x_overlay_set_window_handle (GST_X_OVERLAY (element), embed_xid);
   }
   return GST_BUS_PASS;
 }
index 4a7a3c7..9cfb308 100644 (file)
@@ -128,7 +128,7 @@ cycle_window (GstXOverlay * ov)
 
   XSync (disp, FALSE);
 
-  gst_x_overlay_set_xwindow_id (ov, win);
+  gst_x_overlay_set_window_handle (ov, win);
 
   if (old_win) {
     XDestroyWindow (disp, old_win);
index 72967bc..42818ba 100644 (file)
@@ -273,7 +273,7 @@ main (int argc, char **argv)
    * just set it directly here now (instead of waiting for a prepare-xwindow-id
    * element message in a sync bus handler and setting it there) */
   g_print ("setting XID %lu\n", embed_xid);
-  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
+  gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), embed_xid);
 
   g_idle_add (start_pipeline, pipeline);
   gtk_main ();
index 12a7e27..3a4a43c 100644 (file)
@@ -216,7 +216,7 @@ main (gint argc, gchar ** argv)
   /* we know what the video sink is in this case (xvimagesink), so we can
    * just set it directly here now (instead of waiting for a prepare-xwindow-id
    * element message in a sync bus handler and setting it there) */
-  gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
+  gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), embed_xid);
 
   anim_state.overlay = GST_X_OVERLAY (sink);
   anim_state.widget = video_window;
index ce579a9..2f45637 100644 (file)
@@ -113,8 +113,10 @@ EXPORTS
        gst_video_orientation_set_vflip
        gst_x_overlay_expose
        gst_x_overlay_get_type
+       gst_x_overlay_got_window_handle
        gst_x_overlay_got_xwindow_id
        gst_x_overlay_handle_events
        gst_x_overlay_prepare_xwindow_id
        gst_x_overlay_set_render_rectangle
+       gst_x_overlay_set_window_handle
        gst_x_overlay_set_xwindow_id