xoverlay: add new vmethod ::set_render_rectangle()
authorStefan Kost <ensonic@users.sf.net>
Wed, 17 Feb 2010 13:00:13 +0000 (15:00 +0200)
committerStefan Kost <ensonic@users.sf.net>
Thu, 11 Mar 2010 08:24:57 +0000 (10:24 +0200)
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
gst-libs/gst/interfaces/Makefile.am
gst-libs/gst/interfaces/xoverlay.c
gst-libs/gst/interfaces/xoverlay.h

index 0622405..1a91601 100644 (file)
@@ -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
 <SUBSECTION Standard>
 GST_TYPE_X_OVERLAY
 GST_X_OVERLAY
index 0deacbf..e9bdf39 100644 (file)
@@ -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)
index 224505a..9121b1e 100644 (file)
@@ -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;
+}
index d6609a4..b4f2682 100644 (file)
@@ -24,6 +24,7 @@
 #define __GST_X_OVERLAY_H__
 
 #include <gst/gst.h>
+#include <gst/video/gstvideosink.h>
 
 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);