From a362d99e9e3bb705f4c4fd1e1e3aa869d86ec342 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Fri, 19 Jun 2020 09:21:16 +0200 Subject: libs: window: implements gst_vaapi_window_set_render_rectangle Implements new vmethod gst_vaapi_window_set_render_rectangle, which is doing set the information of the rendered rectangle set by user. This is necessary on wayland at least to get exact information of external surface. And vaapisink calls this when gst_video_overlay_set_render_rectangle is called. Part-of: --- gst-libs/gst/vaapi/gstvaapiwindow.c | 26 ++++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiwindow.h | 4 ++++ gst-libs/gst/vaapi/gstvaapiwindow_priv.h | 1 + gst-libs/gst/vaapi/gstvaapiwindow_wayland.c | 12 ++++++++++++ 4 files changed, 43 insertions(+) (limited to 'gst-libs') diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.c b/gst-libs/gst/vaapi/gstvaapiwindow.c index 01514038..7fd4502f 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow.c @@ -413,6 +413,32 @@ gst_vaapi_window_get_fullscreen (GstVaapiWindow * window) return window->is_fullscreen; } +/** + * gst_vaapi_window_set_render_rectangle: + * @window: a #GstVaapiWindow + * @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 + * + * Set information of the render area. + * + * Since: 1.18 + */ +void +gst_vaapi_window_set_render_rectangle (GstVaapiWindow * window, gint x, gint y, + gint width, gint height) +{ + const GstVaapiWindowClass *klass; + + g_return_if_fail (window != NULL); + + klass = GST_VAAPI_WINDOW_GET_CLASS (window); + + if (klass->set_render_rect) + klass->set_render_rect (window, x, y, width, height); +} + /** * gst_vaapi_window_set_fullscreen: * @window: a #GstVaapiWindow diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.h b/gst-libs/gst/vaapi/gstvaapiwindow.h index 56344396..c1628f79 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.h +++ b/gst-libs/gst/vaapi/gstvaapiwindow.h @@ -85,6 +85,10 @@ gst_vaapi_window_set_height (GstVaapiWindow * window, guint height); void gst_vaapi_window_set_size (GstVaapiWindow * window, guint width, guint height); +void +gst_vaapi_window_set_render_rectangle (GstVaapiWindow * window, gint x, gint y, + gint width, gint height); + gboolean gst_vaapi_window_put_surface (GstVaapiWindow * window, GstVaapiSurface * surface, const GstVaapiRectangle * src_rect, diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_priv.h b/gst-libs/gst/vaapi/gstvaapiwindow_priv.h index a0b05827..168e002c 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiwindow_priv.h @@ -129,6 +129,7 @@ struct _GstVaapiWindowClass guintptr (*get_colormap) (GstVaapiWindow * window); gboolean (*unblock) (GstVaapiWindow * window); gboolean (*unblock_cancel) (GstVaapiWindow * window); + void (*set_render_rect) (GstVaapiWindow * window, gint x, gint y, gint width, gint height); }; GstVaapiWindow * diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c index 4cf76a15..0f596e59 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c @@ -531,6 +531,17 @@ gst_vaapi_window_wayland_resize (GstVaapiWindow * window, return TRUE; } +void +gst_vaapi_window_wayland_set_render_rect (GstVaapiWindow * window, gint x, + gint y, gint width, gint height) +{ + GstVaapiWindowWaylandPrivate *const priv = + GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window); + + if (priv->video_subsurface) + wl_subsurface_set_position (priv->video_subsurface, x, y); +} + static inline gboolean frame_done (FrameState * frame) { @@ -991,6 +1002,7 @@ gst_vaapi_window_wayland_class_init (GstVaapiWindowWaylandClass * klass) window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen; window_class->unblock = gst_vaapi_window_wayland_unblock; window_class->unblock_cancel = gst_vaapi_window_wayland_unblock_cancel; + window_class->set_render_rect = gst_vaapi_window_wayland_set_render_rect; signals[SIZE_CHANGED] = g_signal_new ("size-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, -- cgit v1.2.3