2012-07-19 08:27:23 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidisplay_wayland.c - VA/Wayland display abstraction
|
|
|
|
*
|
2013-01-29 13:14:45 +00:00
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2012-07-19 08:27:23 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstvaapidisplay_wayland
|
|
|
|
* @short_description: VA/Wayland display abstraction
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysdeps.h"
|
|
|
|
#include "gstvaapidisplay_priv.h"
|
|
|
|
#include "gstvaapidisplay_wayland.h"
|
|
|
|
#include "gstvaapidisplay_wayland_priv.h"
|
2014-12-10 17:12:24 +00:00
|
|
|
#include "gstvaapiwindow_wayland.h"
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
#define DEBUG_VAAPI_DISPLAY 1
|
2012-07-19 08:27:23 +00:00
|
|
|
#include "gstvaapidebug.h"
|
|
|
|
|
2018-12-03 12:56:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GstVaapiDisplayWayland, gst_vaapi_display_wayland,
|
|
|
|
GST_TYPE_VAAPI_DISPLAY);
|
2016-10-13 03:53:17 +00:00
|
|
|
|
2012-07-19 08:27:23 +00:00
|
|
|
static inline const gchar *
|
2013-12-20 12:27:07 +00:00
|
|
|
get_default_display_name (void)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
static const gchar *g_display_name;
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!g_display_name)
|
|
|
|
g_display_name = getenv ("WAYLAND_DISPLAY");
|
|
|
|
return g_display_name;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2012-07-24 17:58:55 +00:00
|
|
|
/* Mangle display name with our prefix */
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_display_name (GstVaapiDisplay * display, const gchar * display_name)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
g_free (priv->display_name);
|
|
|
|
|
|
|
|
if (!display_name) {
|
|
|
|
display_name = get_default_display_name ();
|
|
|
|
if (!display_name)
|
|
|
|
display_name = "";
|
|
|
|
}
|
|
|
|
priv->display_name = g_strdup (display_name);
|
|
|
|
return priv->display_name != NULL;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 12:27:05 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
output_handle_geometry (void *data, struct wl_output *output,
|
|
|
|
int x, int y, int physical_width, int physical_height,
|
|
|
|
int subpixel, const char *make, const char *model, int transform)
|
2012-07-27 12:27:05 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv = data;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->phys_width = physical_width;
|
|
|
|
priv->phys_height = physical_height;
|
2012-07-27 12:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
output_handle_mode (void *data, struct wl_output *wl_output,
|
|
|
|
uint32_t flags, int width, int height, int refresh)
|
2012-07-27 12:27:05 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv = data;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
|
|
|
priv->width = width;
|
|
|
|
priv->height = height;
|
|
|
|
}
|
2012-07-27 12:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_output_listener output_listener = {
|
2013-12-20 12:27:07 +00:00
|
|
|
output_handle_geometry,
|
|
|
|
output_handle_mode,
|
2012-07-27 12:27:05 +00:00
|
|
|
};
|
|
|
|
|
2019-01-14 10:30:48 +00:00
|
|
|
static void
|
|
|
|
handle_xdg_wm_base_ping (void *user_data, struct xdg_wm_base *xdg_wm_base,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
xdg_wm_base_pong (xdg_wm_base, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
|
|
|
handle_xdg_wm_base_ping
|
|
|
|
};
|
|
|
|
|
2020-07-22 07:36:18 +00:00
|
|
|
static void
|
|
|
|
dmabuf_format (void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf,
|
|
|
|
uint32_t format)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dmabuf_modifier (void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf,
|
|
|
|
uint32_t format, uint32_t modifier_hi, uint32_t modifier_lo)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayWaylandPrivate *const priv = data;
|
|
|
|
GstDRMFormat drm_format = {
|
|
|
|
.format = format,
|
|
|
|
.modifier = (guint64) modifier_hi << 32 | modifier_lo
|
|
|
|
};
|
|
|
|
|
|
|
|
if (gst_vaapi_video_format_from_drm_format (format) ==
|
|
|
|
GST_VIDEO_FORMAT_UNKNOWN) {
|
|
|
|
GST_LOG ("ignoring unknown format 0x%x with modifier 0x%" G_GINT64_MODIFIER
|
|
|
|
"x", format, drm_format.modifier);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG ("got format 0x%x (%s) with modifier 0x%" G_GINT64_MODIFIER "x",
|
|
|
|
format, gst_video_format_to_string (gst_vaapi_video_format_from_drm_format
|
|
|
|
(format)), drm_format.modifier);
|
|
|
|
|
|
|
|
g_array_append_val (priv->dmabuf_formats, drm_format);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {
|
|
|
|
dmabuf_format,
|
|
|
|
dmabuf_modifier,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-19 08:27:23 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
registry_handle_global (void *data,
|
2012-11-02 18:18:37 +00:00
|
|
|
struct wl_registry *registry,
|
2013-12-20 12:27:07 +00:00
|
|
|
uint32_t id, const char *interface, uint32_t version)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv = data;
|
|
|
|
|
|
|
|
if (strcmp (interface, "wl_compositor") == 0)
|
|
|
|
priv->compositor =
|
|
|
|
wl_registry_bind (registry, id, &wl_compositor_interface, 1);
|
2020-06-19 07:11:20 +00:00
|
|
|
else if (strcmp (interface, "wl_subcompositor") == 0)
|
|
|
|
priv->subcompositor =
|
|
|
|
wl_registry_bind (registry, id, &wl_subcompositor_interface, 1);
|
2013-12-20 12:27:07 +00:00
|
|
|
else if (strcmp (interface, "wl_shell") == 0)
|
2019-01-14 08:58:19 +00:00
|
|
|
priv->wl_shell = wl_registry_bind (registry, id, &wl_shell_interface, 1);
|
2019-01-14 10:30:48 +00:00
|
|
|
else if (strcmp (interface, "xdg_wm_base") == 0) {
|
|
|
|
priv->xdg_wm_base =
|
|
|
|
wl_registry_bind (registry, id, &xdg_wm_base_interface, 1);
|
|
|
|
xdg_wm_base_add_listener (priv->xdg_wm_base, &xdg_wm_base_listener, priv);
|
|
|
|
} else if (strcmp (interface, "wl_output") == 0) {
|
2020-06-11 06:32:05 +00:00
|
|
|
if (!priv->output) {
|
|
|
|
priv->output = wl_registry_bind (registry, id, &wl_output_interface, 1);
|
|
|
|
wl_output_add_listener (priv->output, &output_listener, priv);
|
|
|
|
}
|
2020-07-22 07:36:18 +00:00
|
|
|
} else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0) {
|
|
|
|
priv->dmabuf =
|
|
|
|
wl_registry_bind (registry, id, &zwp_linux_dmabuf_v1_interface, 3);
|
|
|
|
zwp_linux_dmabuf_v1_add_listener (priv->dmabuf, &dmabuf_listener, priv);
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2012-11-02 18:18:37 +00:00
|
|
|
static const struct wl_registry_listener registry_listener = {
|
2013-12-20 12:27:07 +00:00
|
|
|
registry_handle_global,
|
|
|
|
NULL,
|
2012-11-02 18:18:37 +00:00
|
|
|
};
|
2012-07-19 08:27:23 +00:00
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_setup (GstVaapiDisplay * display)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
wl_display_set_user_data (priv->wl_display, priv);
|
|
|
|
priv->registry = wl_display_get_registry (priv->wl_display);
|
|
|
|
wl_registry_add_listener (priv->registry, ®istry_listener, priv);
|
|
|
|
priv->event_fd = wl_display_get_fd (priv->wl_display);
|
|
|
|
wl_display_roundtrip (priv->wl_display);
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!priv->width || !priv->height) {
|
|
|
|
wl_display_roundtrip (priv->wl_display);
|
2013-01-28 13:45:28 +00:00
|
|
|
if (!priv->width || !priv->height) {
|
2013-12-20 12:27:07 +00:00
|
|
|
GST_ERROR ("failed to determine the display size");
|
|
|
|
return FALSE;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->compositor) {
|
|
|
|
GST_ERROR ("failed to bind compositor interface");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-14 10:30:48 +00:00
|
|
|
if (priv->xdg_wm_base)
|
|
|
|
return TRUE;
|
|
|
|
|
2019-01-14 08:58:19 +00:00
|
|
|
if (!priv->wl_shell) {
|
|
|
|
GST_ERROR ("failed to bind wl_shell interface");
|
2013-12-20 12:27:07 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-01-14 10:30:48 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return TRUE;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_bind_display (GstVaapiDisplay * display,
|
2013-05-07 09:39:34 +00:00
|
|
|
gpointer native_display)
|
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->wl_display = native_display;
|
|
|
|
priv->use_foreign_display = TRUE;
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* XXX: how to get socket/display name? */
|
|
|
|
GST_WARNING ("wayland: get display name");
|
|
|
|
set_display_name (display, NULL);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return gst_vaapi_display_wayland_setup (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapi_display_wayland_open_display (GstVaapiDisplay * display,
|
|
|
|
const gchar * name)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!set_display_name (display, name))
|
|
|
|
return FALSE;
|
2013-05-31 09:09:40 +00:00
|
|
|
|
2017-06-26 19:18:25 +00:00
|
|
|
priv->wl_display = wl_display_connect (name);
|
|
|
|
if (!priv->wl_display)
|
|
|
|
return FALSE;
|
|
|
|
priv->use_foreign_display = FALSE;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return gst_vaapi_display_wayland_setup (display);
|
|
|
|
}
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
static void
|
|
|
|
gst_vaapi_display_wayland_close_display (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
|
|
|
|
2018-09-12 10:06:22 +00:00
|
|
|
g_clear_pointer (&priv->output, wl_output_destroy);
|
2019-01-14 08:58:19 +00:00
|
|
|
g_clear_pointer (&priv->wl_shell, wl_shell_destroy);
|
2019-01-14 10:30:48 +00:00
|
|
|
g_clear_pointer (&priv->xdg_wm_base, xdg_wm_base_destroy);
|
2020-06-19 07:11:20 +00:00
|
|
|
g_clear_pointer (&priv->subcompositor, wl_subcompositor_destroy);
|
2018-09-12 10:06:22 +00:00
|
|
|
g_clear_pointer (&priv->compositor, wl_compositor_destroy);
|
|
|
|
g_clear_pointer (&priv->registry, wl_registry_destroy);
|
2015-04-28 00:31:50 +00:00
|
|
|
|
2020-07-22 07:36:18 +00:00
|
|
|
g_array_unref (priv->dmabuf_formats);
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->wl_display) {
|
|
|
|
if (!priv->use_foreign_display)
|
|
|
|
wl_display_disconnect (priv->wl_display);
|
|
|
|
priv->wl_display = NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:06:22 +00:00
|
|
|
g_clear_pointer (&priv->display_name, g_free);
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_get_display_info (GstVaapiDisplay * display,
|
|
|
|
GstVaapiDisplayInfo * info)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
info->native_display = priv->wl_display;
|
|
|
|
info->display_name = priv->display_name;
|
|
|
|
if (!info->va_display) {
|
|
|
|
info->va_display = vaGetDisplayWl (priv->wl_display);
|
|
|
|
if (!info->va_display)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2012-07-27 12:27:05 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_get_size (GstVaapiDisplay * display,
|
|
|
|
guint * pwidth, guint * pheight)
|
2012-07-27 12:27:05 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!priv->output)
|
|
|
|
return;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pwidth)
|
|
|
|
*pwidth = priv->width;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pheight)
|
|
|
|
*pheight = priv->height;
|
2012-07-27 12:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_get_size_mm (GstVaapiDisplay * display,
|
|
|
|
guint * pwidth, guint * pheight)
|
2012-07-27 12:27:05 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (display);
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!priv->output)
|
|
|
|
return;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pwidth)
|
|
|
|
*pwidth = priv->phys_width;
|
2012-07-27 12:27:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pheight)
|
|
|
|
*pheight = priv->phys_height;
|
2012-07-27 12:27:05 +00:00
|
|
|
}
|
|
|
|
|
2014-12-10 17:12:24 +00:00
|
|
|
static GstVaapiWindow *
|
|
|
|
gst_vaapi_display_wayland_create_window (GstVaapiDisplay * display,
|
|
|
|
GstVaapiID id, guint width, guint height)
|
|
|
|
{
|
2016-02-03 10:04:15 +00:00
|
|
|
if (id != GST_VAAPI_ID_INVALID)
|
|
|
|
return NULL;
|
|
|
|
return gst_vaapi_window_wayland_new (display, width, height);
|
2014-12-10 17:12:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static void
|
2016-10-13 03:53:17 +00:00
|
|
|
gst_vaapi_display_wayland_init (GstVaapiDisplayWayland * display)
|
2013-05-07 09:39:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayWaylandPrivate *const priv =
|
2016-10-13 03:53:17 +00:00
|
|
|
gst_vaapi_display_wayland_get_instance_private (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
display->priv = priv;
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->event_fd = -1;
|
2020-07-22 07:36:18 +00:00
|
|
|
priv->dmabuf_formats = g_array_new (FALSE, FALSE, sizeof (GstDRMFormat));
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:27:23 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
|
|
|
|
2014-12-10 17:02:55 +00:00
|
|
|
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_WAYLAND;
|
2016-10-13 03:53:17 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
dpy_class->bind_display = gst_vaapi_display_wayland_bind_display;
|
|
|
|
dpy_class->open_display = gst_vaapi_display_wayland_open_display;
|
|
|
|
dpy_class->close_display = gst_vaapi_display_wayland_close_display;
|
|
|
|
dpy_class->get_display = gst_vaapi_display_wayland_get_display_info;
|
|
|
|
dpy_class->get_size = gst_vaapi_display_wayland_get_size;
|
|
|
|
dpy_class->get_size_mm = gst_vaapi_display_wayland_get_size_mm;
|
2014-12-10 17:12:24 +00:00
|
|
|
dpy_class->create_window = gst_vaapi_display_wayland_create_window;
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_wayland_new:
|
|
|
|
* @display_name: the Wayland display name
|
|
|
|
*
|
|
|
|
* Opens an Wayland #wl_display using @display_name and returns a
|
|
|
|
* newly allocated #GstVaapiDisplay object. The Wayland display will
|
|
|
|
* be cloed when the reference count of the object reaches zero.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_new (const gchar * display_name)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2018-06-01 03:36:51 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
|
|
|
|
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
|
|
|
|
return gst_vaapi_display_config (display,
|
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) display_name);
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_wayland_new_with_display:
|
|
|
|
* @wl_display: an Wayland #wl_display
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiDisplay based on the Wayland @wl_display
|
|
|
|
* display. The caller still owns the display and must call
|
|
|
|
* wl_display_disconnect() when all #GstVaapiDisplay references are
|
|
|
|
* released. Doing so too early can yield undefined behaviour.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_new_with_display (struct wl_display *wl_display)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2018-06-01 03:36:51 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (wl_display, NULL);
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2018-06-01 03:36:51 +00:00
|
|
|
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
|
|
|
|
return gst_vaapi_display_config (display,
|
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, wl_display);
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|
|
|
|
|
2017-11-08 04:26:38 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_wayland_new_with_va_display:
|
|
|
|
* @va_display: a VADisplay #va_display
|
|
|
|
* @wl_display: an Wayland #wl_display
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiDisplay based on the VADisplay @va_display and
|
|
|
|
* the Wayland @wl_display display.
|
|
|
|
* The caller still owns the display and must call
|
|
|
|
* wl_display_disconnect() when all #GstVaapiDisplay references are
|
|
|
|
* released.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstVaapiDisplay *
|
|
|
|
gst_vaapi_display_wayland_new_with_va_display (VADisplay va_display,
|
|
|
|
struct wl_display *wl_display)
|
|
|
|
{
|
2018-06-01 03:36:51 +00:00
|
|
|
GstVaapiDisplay *display;
|
2017-11-08 04:26:38 +00:00
|
|
|
GstVaapiDisplayInfo info = {
|
|
|
|
.va_display = va_display,
|
|
|
|
.native_display = wl_display,
|
|
|
|
};
|
|
|
|
|
|
|
|
g_return_val_if_fail (wl_display, NULL);
|
|
|
|
|
2018-06-01 03:36:51 +00:00
|
|
|
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_WAYLAND, NULL);
|
|
|
|
if (!gst_vaapi_display_config (display,
|
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info)) {
|
|
|
|
gst_object_unref (display);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return display;
|
2017-11-08 04:26:38 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:27:23 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_wayland_get_display:
|
|
|
|
* @display: a #GstVaapiDisplayWayland
|
|
|
|
*
|
|
|
|
* Returns the underlying Wayland #wl_display that was created by
|
|
|
|
* gst_vaapi_display_wayland_new() or that was bound from
|
|
|
|
* gst_vaapi_display_wayland_new_with_display().
|
|
|
|
*
|
|
|
|
* Return value: the Wayland #wl_display attached to @display
|
|
|
|
*/
|
|
|
|
struct wl_display *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_wayland_get_display (GstVaapiDisplayWayland * display)
|
2012-07-19 08:27:23 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_WAYLAND (display), NULL);
|
2012-07-19 08:27:23 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return GST_VAAPI_DISPLAY_WL_DISPLAY (display);
|
2012-07-19 08:27:23 +00:00
|
|
|
}
|