From 7269bc26d0a4bf44bd77a039fb54777625ef5f39 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 17 Feb 2010 15:00:13 +0200 Subject: [PATCH] xoverlay: add new vmethod ::set_render_rectangle() Add set_render_rectangle() vmethod to the interface to better support windowless toolkits (e.g. qt graphicsview or video on canvas in general). Right now we always fill the widget to 100%. With the patch we can use a rectangular target region. Fixes #610249. API: GstXOverlay::set_render_rectangle() --- docs/libs/gst-plugins-base-libs-sections.txt | 1 + gst-libs/gst/interfaces/Makefile.am | 6 +++- gst-libs/gst/interfaces/xoverlay.c | 38 ++++++++++++++++++++ gst-libs/gst/interfaces/xoverlay.h | 30 ++++++++++------ 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 0622405205..1a91601aac 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -790,6 +790,7 @@ gst_x_overlay_got_xwindow_id gst_x_overlay_prepare_xwindow_id gst_x_overlay_expose gst_x_overlay_handle_events +gst_x_overlay_set_render_rectangle GST_TYPE_X_OVERLAY GST_X_OVERLAY diff --git a/gst-libs/gst/interfaces/Makefile.am b/gst-libs/gst/interfaces/Makefile.am index 0deacbf098..e9bdf39b56 100644 --- a/gst-libs/gst/interfaces/Makefile.am +++ b/gst-libs/gst/interfaces/Makefile.am @@ -1,6 +1,7 @@ lib_LTLIBRARIES = libgstinterfaces-@GST_MAJORMINOR@.la libgstinterfacesincludedir = \ - $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/interfaces + $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/interfaces \ + $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video headers_interfaces = \ colorbalance.h \ @@ -89,10 +90,13 @@ GstInterfaces-@GST_MAJORMINOR@.gir: $(INTROSPECTION_SCANNER) libgstinterfaces-@G -I$(top_srcdir)/gst-libs \ -I$(top_builddir)/gst-libs \ --add-include-path=`$(PKG_CONFIG) --variable=libdir gstreamer-0.10`/gst \ + --add-include-path=$(builddir)/../video \ --library=gstinterfaces-0.10 \ --include=Gst-0.10 \ + --include=GstVideo-0.10 \ --libtool="$(top_builddir)/libtool" \ --pkg gstreamer-0.10 \ + --pkg gstreamer-video-0.10 \ --output $@ \ $(gir_headers) \ $(gir_sources) diff --git a/gst-libs/gst/interfaces/xoverlay.c b/gst-libs/gst/interfaces/xoverlay.c index 224505a56b..9121b1e0b8 100644 --- a/gst-libs/gst/interfaces/xoverlay.c +++ b/gst-libs/gst/interfaces/xoverlay.c @@ -456,3 +456,41 @@ gst_x_overlay_handle_events (GstXOverlay * overlay, gboolean handle_events) klass->handle_events (overlay, handle_events); } } + +/** + * gst_x_overlay_set_render_rectangle: + * @overlay: a #GstXOverlay + * @rect: the target 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 + * 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 + * gst_x_overlay_expose() to force a redraw. To unset the region pass %NULL for + * the @rect parameter. + * + * This method is needed for non fullscreen video overlay in UI toolkits that do + * not support subwindows. + * + * Return: %FALSE if not supported by the sink. + * + * Since: 0.10.27 + */ +gboolean +gst_x_overlay_set_render_rectangle (GstXOverlay * overlay, + GstVideoRectangle * rect) +{ + GstXOverlayClass *klass; + + g_return_val_if_fail (overlay != NULL, FALSE); + g_return_val_if_fail (GST_IS_X_OVERLAY (overlay), FALSE); + + klass = GST_X_OVERLAY_GET_CLASS (overlay); + + if (klass->set_render_rectangle) { + klass->set_render_rectangle (overlay, rect); + return TRUE; + } + return FALSE; +} diff --git a/gst-libs/gst/interfaces/xoverlay.h b/gst-libs/gst/interfaces/xoverlay.h index d6609a4f61..b4f2682e3f 100644 --- a/gst-libs/gst/interfaces/xoverlay.h +++ b/gst-libs/gst/interfaces/xoverlay.h @@ -24,6 +24,7 @@ #define __GST_X_OVERLAY_H__ #include +#include G_BEGIN_DECLS @@ -62,27 +63,34 @@ struct _GstXOverlayClass { GTypeInterface klass; /* virtual functions */ - void (* set_xwindow_id) (GstXOverlay *overlay, - gulong xwindow_id); + void (* set_xwindow_id) (GstXOverlay *overlay, + gulong xwindow_id); - void (* expose) (GstXOverlay *overlay); + void (* expose) (GstXOverlay *overlay); - void (* handle_events) (GstXOverlay *overlay, - gboolean handle_events); + void (* handle_events) (GstXOverlay *overlay, + gboolean handle_events); - /*< private >*/ - gpointer _gst_reserved[GST_PADDING - 1]; + void (* set_render_rectangle) (GstXOverlay *overlay, + GstVideoRectangle *rect); + /*< private >*/ + gpointer _gst_reserved[GST_PADDING - 2]; }; GType gst_x_overlay_get_type (void); /* virtual class function wrappers */ -void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id); +void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, + gulong xwindow_id); -void gst_x_overlay_expose (GstXOverlay *overlay); +gboolean gst_x_overlay_set_render_rectangle (GstXOverlay *overlay, + GstVideoRectangle *rect); + +void gst_x_overlay_expose (GstXOverlay *overlay); + +void gst_x_overlay_handle_events (GstXOverlay *overlay, + gboolean handle_events); -void gst_x_overlay_handle_events (GstXOverlay *overlay, - gboolean handle_events); /* public methods to dispatch bus messages */ void gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id);