From 18ac9d239e940b7627b37cf7645bf4050de4e17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 22 Feb 2016 12:53:00 +0200 Subject: [PATCH] player: Expose more GstVideoOverlay API in the GstPlayerVideoOverlayVideoRenderer Expose the expose() and set_render_rectangle() methods. These are useful for proper functioning of the video overlay in various situations and toolkits. --- docs/libs/gst-plugins-bad-libs-sections.txt | 5 ++ .../gstplayer-video-overlay-video-renderer.c | 87 ++++++++++++++++++- .../gstplayer-video-overlay-video-renderer.h | 4 + win32/common/libgstplayer.def | 3 + 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index c672555d71..2725d838d5 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -1575,6 +1575,11 @@ gst_player_video_overlay_video_renderer_new gst_player_video_overlay_video_renderer_get_window_handle gst_player_video_overlay_video_renderer_set_window_handle +gst_player_video_overlay_video_renderer_expose + +gst_player_video_overlay_video_renderer_get_render_rectangle +gst_player_video_overlay_video_renderer_set_render_rectangle + GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_CAST diff --git a/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.c b/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.c index ab8894fe1a..72a35e0491 100644 --- a/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.c +++ b/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.c @@ -39,6 +39,7 @@ struct _GstPlayerVideoOverlayVideoRenderer GstVideoOverlay *video_overlay; gpointer window_handle; + gint x, y, width, height; }; struct _GstPlayerVideoOverlayVideoRendererClass @@ -141,8 +142,9 @@ static void static void gst_player_video_overlay_video_renderer_init - (G_GNUC_UNUSED GstPlayerVideoOverlayVideoRenderer * self) + (GstPlayerVideoOverlayVideoRenderer * self) { + self->x = self->y = self->width = self->height = -1; } static GstElement *gst_player_video_overlay_video_renderer_create_video_sink @@ -162,6 +164,9 @@ static GstElement *gst_player_video_overlay_video_renderer_create_video_sink gst_video_overlay_set_window_handle (self->video_overlay, (guintptr) self->window_handle); + if (self->width != -1 || self->height != -1) + gst_video_overlay_set_render_rectangle (self->video_overlay, self->x, + self->y, self->width, self->height); return NULL; } @@ -222,3 +227,83 @@ gpointer return window_handle; } + +/** + * gst_player_video_overlay_video_renderer_expose: + * @self: a #GstPlayerVideoOverlayVideoRenderer instance. + * + * Tell an overlay that it has been exposed. This will redraw the current frame + * in the drawable even if the pipeline is PAUSED. + */ +void gst_player_video_overlay_video_renderer_expose + (GstPlayerVideoOverlayVideoRenderer * self) +{ + g_return_if_fail (GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (self)); + + if (self->video_overlay) + gst_video_overlay_expose (self->video_overlay); +} + +/** + * gst_player_video_overlay_video_renderer_set_render_rectangle: + * @self: a #GstPlayerVideoOverlayVideoRenderer instance + * @x: the horizontal offset of the render area inside the window + * @y: the vertical offset of the render area inside the window + * @width: the width of the render area inside the window + * @height: the height of the render area inside the window + * + * Configure a subregion as a video target within the window set by + * gst_player_video_overlay_video_renderer_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 gst_player_video_overlay_video_renderer_expose() to force a + * redraw. To unset the region pass -1 for the @width and @height parameters. + * + * This method is needed for non fullscreen video overlay in UI toolkits that + * do not support subwindows. + * + */ +void gst_player_video_overlay_video_renderer_set_render_rectangle + (GstPlayerVideoOverlayVideoRenderer * self, gint x, gint y, gint width, + gint height) +{ + g_return_if_fail (GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (self)); + + self->x = x; + self->y = y; + self->width = width; + self->height = height; + + if (self->video_overlay) + gst_video_overlay_set_render_rectangle (self->video_overlay, + x, y, width, height); +} + +/** + * gst_player_video_overlay_video_renderer_get_render_rectangle: + * @self: a #GstPlayerVideoOverlayVideoRenderer instance + * @x: (out) (allow-none): the horizontal offset of the render area inside the window + * @y: (out) (allow-none): the vertical offset of the render area inside the window + * @width: (out) (allow-none): the width of the render area inside the window + * @height: (out) (allow-none): the height of the render area inside the window + * + * Return the currently configured render rectangle. See gst_player_video_overlay_video_renderer_set_render_rectangle() + * for details. + * + */ +void gst_player_video_overlay_video_renderer_get_render_rectangle + (GstPlayerVideoOverlayVideoRenderer * self, gint * x, gint * y, + gint * width, gint * height) +{ + g_return_if_fail (GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (self)); + + if (x) + *x = self->x; + if (y) + *y = self->y; + if (width) + *width = self->width; + if (height) + *height = self->height; +} diff --git a/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.h b/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.h index 72a420b43d..be09113337 100644 --- a/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.h +++ b/gst-libs/gst/player/gstplayer-video-overlay-video-renderer.h @@ -44,6 +44,10 @@ GstPlayerVideoRenderer * gst_player_video_overlay_video_renderer_new (gpointer w void gst_player_video_overlay_video_renderer_set_window_handle (GstPlayerVideoOverlayVideoRenderer * self, gpointer window_handle); gpointer gst_player_video_overlay_video_renderer_get_window_handle (GstPlayerVideoOverlayVideoRenderer * self); +void gst_player_video_overlay_video_renderer_expose (GstPlayerVideoOverlayVideoRenderer * self); +void gst_player_video_overlay_video_renderer_set_render_rectangle (GstPlayerVideoOverlayVideoRenderer * self, gint x, gint y, gint width, gint height); +void gst_player_video_overlay_video_renderer_get_render_rectangle (GstPlayerVideoOverlayVideoRenderer * self, gint *x, gint *y, gint *width, gint *height); + G_END_DECLS #endif /* __GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_H__ */ diff --git a/win32/common/libgstplayer.def b/win32/common/libgstplayer.def index 5c5dbe7719..84d31e76c4 100644 --- a/win32/common/libgstplayer.def +++ b/win32/common/libgstplayer.def @@ -79,9 +79,12 @@ EXPORTS gst_player_video_info_get_pixel_aspect_ratio gst_player_video_info_get_type gst_player_video_info_get_width + gst_player_video_overlay_video_renderer_expose + gst_player_video_overlay_video_renderer_get_render_rectangle gst_player_video_overlay_video_renderer_get_type gst_player_video_overlay_video_renderer_get_window_handle gst_player_video_overlay_video_renderer_new + gst_player_video_overlay_video_renderer_set_render_rectangle gst_player_video_overlay_video_renderer_set_window_handle gst_player_video_renderer_get_type gst_player_visualization_copy