From 181c68d79a86c995af5be62b2a36f503988dc637 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 4 Jan 2004 18:02:30 +0000 Subject: gst-libs/gst/xoverlay/xoverlay.*: Add optional "desired size" signal and querying. Original commit message from CVS: 2004-01-04 Benjamin Otte * gst-libs/gst/xoverlay/xoverlay.c: (gst_x_overlay_base_init), (gst_x_overlay_got_xwindow_id), (gst_x_overlay_get_desired_size), (gst_x_overlay_got_desired_size): * gst-libs/gst/xoverlay/xoverlay.h: Add optional "desired size" signal and querying. --- ChangeLog | 8 +++++ gst-libs/gst/xoverlay/xoverlay.c | 68 ++++++++++++++++++++++++++++++++++++++-- gst-libs/gst/xoverlay/xoverlay.h | 9 ++++++ 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cf6c7cc..86cc7f8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-01-04 Benjamin Otte + + * gst-libs/gst/xoverlay/xoverlay.c: (gst_x_overlay_base_init), + (gst_x_overlay_got_xwindow_id), (gst_x_overlay_get_desired_size), + (gst_x_overlay_got_desired_size): + * gst-libs/gst/xoverlay/xoverlay.h: + Add optional "desired size" signal and querying. + 2004-01-04 Ronald Bultje * gst/matroska/matroska-demux.c: diff --git a/gst-libs/gst/xoverlay/xoverlay.c b/gst-libs/gst/xoverlay/xoverlay.c index 390453c1..c0bbcec0 100644 --- a/gst-libs/gst/xoverlay/xoverlay.c +++ b/gst-libs/gst/xoverlay/xoverlay.c @@ -27,6 +27,7 @@ enum { HAVE_XWINDOW_ID, + DESIRED_SIZE, LAST_SIGNAL }; @@ -62,6 +63,10 @@ gst_x_overlay_get_type (void) return gst_x_overlay_type; } +/* FIXME: evil hack, we should figure out our marshal handling in this interfaces some day */ +extern void gst_marshal_VOID__INT_INT (GClosure *closure, GValue *return_value, guint n_param_values, + const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); + static void gst_x_overlay_base_init (gpointer g_class) { @@ -75,8 +80,15 @@ gst_x_overlay_base_init (gpointer g_class) GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, - G_TYPE_POINTER); + g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, + G_TYPE_INT); + gst_x_overlay_signals[DESIRED_SIZE] = + g_signal_new ("desired_size_changed", + GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstXOverlayClass, desired_size), + NULL, NULL, + gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, + G_TYPE_INT, G_TYPE_INT); initialized = TRUE; } @@ -119,5 +131,55 @@ gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, XID xwindow_id) g_return_if_fail (GST_IS_X_OVERLAY (overlay)); g_signal_emit (G_OBJECT (overlay), - gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, xwindow_id); + gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, (gint) xwindow_id); +} + +/** + * gst_x_overlay_get_desired_size: + * @overlay: a #GstXOverlay which got a XWindow. + * @width: pointer to a gint taking the width or NULL. + * @height: pointer to a gint taking the height or NULL. + * + * Gets the desired size of the overlay. If the overlay doesn't know its desired + * size, width and height are set to 0. + */ +void +gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height) +{ + guint width_tmp, height_tmp; + GstXOverlayClass *klass; + + g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE ((overlay), GST_TYPE_X_OVERLAY)); + + klass = GST_X_OVERLAY_GET_CLASS (overlay); + if (klass->get_desired_size && GST_IS_X_OVERLAY (overlay)) { + /* this ensures that elements don't need to check width and height for NULL + but apps may use NULL */ + klass->get_desired_size (overlay, width ? width : &width_tmp, height ? height : &height_tmp); + } else { + if (width) + *width = 0; + if (height) + *height = 0; + } } + +/** + * gst_x_overlay_got_desired_size: + * @overlay: a #GstXOverlay which changed its desired size. + * @width: The new desired width + * @height: The new desired height + * + * This will fire a "desired_size_changed" signal. + * + * This function should be used by video overlay developpers. + */ +void +gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height) +{ + g_return_if_fail (GST_IS_X_OVERLAY (overlay)); + + g_signal_emit (G_OBJECT (overlay), + gst_x_overlay_signals[DESIRED_SIZE], 0, width, height); +} + diff --git a/gst-libs/gst/xoverlay/xoverlay.h b/gst-libs/gst/xoverlay/xoverlay.h index 062fadf4..4c684870 100644 --- a/gst-libs/gst/xoverlay/xoverlay.h +++ b/gst-libs/gst/xoverlay/xoverlay.h @@ -50,10 +50,17 @@ typedef struct _GstXOverlayClass { /* virtual functions */ void (* set_xwindow_id) (GstXOverlay *overlay, XID xwindow_id); + /* optional virtual functions */ + void (* get_desired_size) (GstXOverlay *overlay, + guint *width, + guint *height); /* signals */ void (*have_xwindow_id) (GstXOverlay *overlay, XID xwindow_id); + void (* desired_size) (GstXOverlay *overlay, + guint width, + guint height); gpointer _gst_reserved[GST_PADDING]; } GstXOverlayClass; @@ -62,9 +69,11 @@ GType gst_x_overlay_get_type (void); /* virtual class function wrappers */ void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id); +void gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height); /* public methods to fire signals */ void gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, XID xwindow_id); +void gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height); G_END_DECLS -- cgit v1.2.1