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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/342>
This commit is contained in:
Hyunjun Ko 2020-06-19 09:21:16 +02:00 committed by Michael Olbrich
parent a5f37a21ec
commit a362d99e9e
5 changed files with 49 additions and 0 deletions

View file

@ -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

View file

@ -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,

View file

@ -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 *

View file

@ -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,

View file

@ -633,6 +633,12 @@ gst_vaapisink_video_overlay_set_render_rectangle (GstVideoOverlay * overlay,
display_rect->width = width;
display_rect->height = height;
if (gst_vaapisink_ensure_render_rect (sink, width, height) && sink->window) {
gst_vaapi_window_set_render_rectangle (sink->window, x, y, width, height);
gst_vaapi_window_set_size (sink->window, width, height);
gst_vaapisink_reconfigure_window (sink);
}
GST_DEBUG ("render rect (%d,%d):%ux%u",
display_rect->x, display_rect->y,
display_rect->width, display_rect->height);