diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-07-22 09:36:18 +0200 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-07-27 15:02:19 +0000 |
commit | bef64a6420541bda22851da5652f04c0bef00a6e (patch) | |
tree | bd2a7b0bf4e45b965261bb21cbb8422bc0c00b8a /gst-libs | |
parent | 9ccb0c57fa86b8b71b6185a4cf75ee957a6881f4 (diff) | |
download | gstreamer-vaapi-bef64a6420541bda22851da5652f04c0bef00a6e.tar.gz |
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>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_wayland.c | 43 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapidisplay_wayland_priv.h | 10 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/meson.build | 11 |
3 files changed, 64 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c index 8803c294..7dfe8578 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_wayland.c @@ -106,6 +106,42 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = { }; 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, uint32_t id, const char *interface, uint32_t version) @@ -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 diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_wayland_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_wayland_priv.h index b09adfb2..6822d822 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_wayland_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_wayland_priv.h @@ -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; diff --git a/gst-libs/gst/vaapi/meson.build b/gst-libs/gst/vaapi/meson.build index 246ac30b..bcf261fd 100644 --- a/gst-libs/gst/vaapi/meson.build +++ b/gst-libs/gst/vaapi/meson.build @@ -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', |