mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 05:28:48 +00:00
libs: display: wayland: add basic dmabuf protocol support
This is just the basic infrastructure. Hook up the interface and collect all supported formats. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>
This commit is contained in:
parent
9ccb0c57fa
commit
bef64a6420
3 changed files with 64 additions and 0 deletions
|
@ -105,6 +105,42 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
|||
handle_xdg_wm_base_ping
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
registry_handle_global (void *data,
|
||||
struct wl_registry *registry,
|
||||
|
@ -126,6 +162,10 @@ registry_handle_global (void *data,
|
|||
priv->output = wl_registry_bind (registry, id, &wl_output_interface, 1);
|
||||
wl_output_add_listener (priv->output, &output_listener, priv);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,6 +257,8 @@ gst_vaapi_display_wayland_close_display (GstVaapiDisplay * display)
|
|||
g_clear_pointer (&priv->compositor, wl_compositor_destroy);
|
||||
g_clear_pointer (&priv->registry, wl_registry_destroy);
|
||||
|
||||
g_array_unref (priv->dmabuf_formats);
|
||||
|
||||
if (priv->wl_display) {
|
||||
if (!priv->use_foreign_display)
|
||||
wl_display_disconnect (priv->wl_display);
|
||||
|
@ -294,6 +336,7 @@ gst_vaapi_display_wayland_init (GstVaapiDisplayWayland * display)
|
|||
|
||||
display->priv = priv;
|
||||
priv->event_fd = -1;
|
||||
priv->dmabuf_formats = g_array_new (FALSE, FALSE, sizeof (GstDRMFormat));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define GST_VAAPI_DISPLAY_WAYLAND_PRIV_H
|
||||
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
#include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||
#include "gstvaapidisplay_priv.h"
|
||||
|
@ -57,6 +58,13 @@ typedef struct _GstVaapiDisplayWaylandClass GstVaapiDisplayWaylandClass;
|
|||
#define GST_VAAPI_DISPLAY_WL_DISPLAY(display) \
|
||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(display)->wl_display
|
||||
|
||||
typedef struct _GstDRMFormat GstDRMFormat;
|
||||
|
||||
struct _GstDRMFormat {
|
||||
guint format;
|
||||
guint64 modifier;
|
||||
};
|
||||
|
||||
struct _GstVaapiDisplayWaylandPrivate
|
||||
{
|
||||
gchar *display_name;
|
||||
|
@ -65,7 +73,9 @@ struct _GstVaapiDisplayWaylandPrivate
|
|||
struct wl_shell *wl_shell;
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct wl_output *output;
|
||||
struct zwp_linux_dmabuf_v1 *dmabuf;
|
||||
struct wl_registry *registry;
|
||||
GArray *dmabuf_formats;
|
||||
guint width;
|
||||
guint height;
|
||||
guint phys_width;
|
||||
|
|
|
@ -174,12 +174,23 @@ if USE_WAYLAND
|
|||
command: [ wayland_scanner_bin, 'private-code', '@INPUT@', '@OUTPUT@' ],
|
||||
input: xdg_shell_xml_spec,
|
||||
output: 'xdg-shell-client-protocol.c')
|
||||
dmabuf_xml_spec = join_paths(wayland_protocols_basedir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml')
|
||||
dmabuf_header = custom_target('vaapi-dmabuf-client-header',
|
||||
command: [ wayland_scanner_bin, 'client-header', '@INPUT@', '@OUTPUT@' ],
|
||||
input: dmabuf_xml_spec,
|
||||
output: 'linux-dmabuf-unstable-v1-client-protocol.h')
|
||||
dmabuf_code = custom_target('vaapi-dmabuf-client-code',
|
||||
command: [ wayland_scanner_bin, 'private-code', '@INPUT@', '@OUTPUT@' ],
|
||||
input: dmabuf_xml_spec,
|
||||
output: 'linux-dmabuf-unstable-v1-client-protocol.c')
|
||||
|
||||
gstlibvaapi_sources += [
|
||||
'gstvaapidisplay_wayland.c',
|
||||
'gstvaapiwindow_wayland.c',
|
||||
xdg_shell_header,
|
||||
xdg_shell_code,
|
||||
dmabuf_header,
|
||||
dmabuf_code,
|
||||
]
|
||||
gstlibvaapi_headers += [
|
||||
'gstvaapidisplay_wayland.h',
|
||||
|
|
Loading…
Reference in a new issue