xoverlay: Add guintptr versions of functions

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()
This commit is contained in:
David Schleef 2010-09-05 15:17:47 -07:00
parent d71890156a
commit 6dc02137fb
14 changed files with 119 additions and 34 deletions

View 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);
@ -105,7 +105,7 @@
* 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>
@ -123,7 +123,7 @@
* </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
@ -164,7 +164,7 @@
*
* // 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!");
* }
@ -264,7 +264,7 @@
* 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,9 +340,36 @@ 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;
@ -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,9 +404,33 @@ 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;
@ -376,9 +438,11 @@ gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
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

View 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);

View 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;

View 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;
}

View 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;

View 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 */

View 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 */

View 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) {

View 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;
}

View 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;
}

View 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);

View 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 ();

View 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;

View 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