plugins: add support for Wayland.

This commit is contained in:
Gwenole Beauchesne 2012-07-24 09:45:25 +02:00
parent 5e356922bf
commit 9e00c87367
5 changed files with 91 additions and 15 deletions

View file

@ -95,6 +95,10 @@ gst_vaapi_display_type_get_type(void)
#if USE_GLX
{ GST_VAAPI_DISPLAY_TYPE_GLX,
"VA/GLX display", "glx" },
#endif
#if USE_WAYLAND
{ GST_VAAPI_DISPLAY_TYPE_WAYLAND,
"VA/Wayland display", "wayland" },
#endif
{ 0, NULL, NULL },
};

View file

@ -65,11 +65,13 @@ typedef struct _GstVaapiDisplayClass GstVaapiDisplayClass;
* @GST_VAAPI_DISPLAY_TYPE_ANY: Automatic detection of the display type.
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
* @GST_VAAPI_DISPLAY_TYPE_GLX: VA/GLX display.
* @GST_VAAPI_DISPLAY_TYPE_WAYLAND: VA/Wayland display.
*/
enum _GstVaapiDisplayType {
GST_VAAPI_DISPLAY_TYPE_ANY = 0,
GST_VAAPI_DISPLAY_TYPE_X11,
GST_VAAPI_DISPLAY_TYPE_GLX,
GST_VAAPI_DISPLAY_TYPE_WAYLAND,
};
#define GST_VAAPI_TYPE_DISPLAY_TYPE \

View file

@ -19,6 +19,11 @@ libgstvaapi_LIBS += \
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-$(GST_MAJORMINOR).la
endif
if USE_WAYLAND
libgstvaapi_LIBS += \
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland-$(GST_MAJORMINOR).la
endif
libgstvaapi_la_SOURCES = \
gstvaapi.c \
gstvaapidecode.c \

View file

@ -32,12 +32,19 @@
#if USE_GLX
# include <gst/vaapi/gstvaapidisplay_glx.h>
#endif
#if USE_WAYLAND
# include <gst/vaapi/gstvaapidisplay_wayland.h>
#endif
#include "gstvaapipluginutil.h"
/* Preferred first */
static const char *display_types[] = {
"gst-vaapi-display",
"vaapi-display",
#if USE_WAYLAND
"wl-display",
"wl-display-name",
#endif
"x11-display",
"x11-display-name",
NULL
@ -50,6 +57,11 @@ typedef struct {
} DisplayMap;
static const DisplayMap g_display_map[] = {
#if USE_WAYLAND
{ "wayland",
GST_VAAPI_DISPLAY_TYPE_WAYLAND,
gst_vaapi_display_wayland_new },
#endif
#if USE_GLX
{ "glx",
GST_VAAPI_DISPLAY_TYPE_GLX,
@ -126,7 +138,15 @@ gst_vaapi_set_display(
{
GstVaapiDisplay *dpy = NULL;
if (!strcmp(type, "x11-display-name")) {
if (!strcmp(type, "vaapi-display")) {
g_return_if_fail(G_VALUE_HOLDS_POINTER(value));
dpy = gst_vaapi_display_new_with_display(g_value_get_pointer(value));
}
else if (!strcmp(type, "gst-vaapi-display")) {
g_return_if_fail(G_VALUE_HOLDS_OBJECT(value));
dpy = g_value_dup_object(value);
}
else if (!strcmp(type, "x11-display-name")) {
g_return_if_fail(G_VALUE_HOLDS_STRING(value));
#if USE_GLX
dpy = gst_vaapi_display_glx_new(g_value_get_string(value));
@ -142,14 +162,20 @@ gst_vaapi_set_display(
if (!dpy)
dpy = gst_vaapi_display_x11_new_with_display(g_value_get_pointer(value));
}
else if (!strcmp(type, "vaapi-display")) {
#if USE_WAYLAND
else if (!strcmp(type, "wl-display")) {
struct wl_display *wl_display;
g_return_if_fail(G_VALUE_HOLDS_POINTER(value));
dpy = gst_vaapi_display_new_with_display(g_value_get_pointer(value));
wl_display = g_value_get_pointer(value);
dpy = gst_vaapi_display_wayland_new_with_display(wl_display);
}
else if (!strcmp(type, "gst-vaapi-display")) {
g_return_if_fail(G_VALUE_HOLDS_OBJECT(value));
dpy = g_value_dup_object(value);
else if (!strcmp(type, "wl-display-name")) {
const gchar *display_name;
g_return_if_fail(G_VALUE_HOLDS_STRING(value));
display_name = g_value_get_string(value);
dpy = gst_vaapi_display_wayland_new(display_name);
}
#endif
if (dpy) {
if (*display)
@ -206,6 +232,19 @@ gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
res = FALSE;
break;
}
#if USE_WAYLAND
case GST_VAAPI_DISPLAY_TYPE_WAYLAND: {
GstVaapiDisplayWayland * const wlvadpy =
GST_VAAPI_DISPLAY_WAYLAND(display);
struct wl_display * const wldpy =
gst_vaapi_display_wayland_get_display(wlvadpy);
if (!strcmp(type, "wl-display"))
gst_video_context_query_set_pointer(query, type, wldpy);
else
res = FALSE;
break;
}
#endif
default:
res = FALSE;
break;

View file

@ -41,6 +41,10 @@
# include <gst/vaapi/gstvaapidisplay_glx.h>
# include <gst/vaapi/gstvaapiwindow_glx.h>
#endif
#if USE_WAYLAND
# include <gst/vaapi/gstvaapidisplay_wayland.h>
# include <gst/vaapi/gstvaapiwindow_wayland.h>
#endif
/* Supported interfaces */
#include <gst/interfaces/xoverlay.h>
@ -354,20 +358,27 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
#if USE_GLX
case GST_VAAPI_DISPLAY_TYPE_GLX:
sink->window = gst_vaapi_window_glx_new(display, width, height);
break;
goto notify_xoverlay_interface;
#endif
case GST_VAAPI_DISPLAY_TYPE_X11:
sink->window = gst_vaapi_window_x11_new(display, width, height);
break;
default:
GST_ERROR("unsupported display type %d", sink->display_type);
return FALSE;
}
if (sink->window)
notify_xoverlay_interface:
if (!sink->window)
break;
gst_x_overlay_got_window_handle(
GST_X_OVERLAY(sink),
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window))
);
break;
#if USE_WAYLAND
case GST_VAAPI_DISPLAY_TYPE_WAYLAND:
sink->window = gst_vaapi_window_wayland_new(display, width, height);
break;
#endif
default:
GST_ERROR("unsupported display type %d", sink->display_type);
return FALSE;
}
}
return sink->window != NULL;
}
@ -458,6 +469,16 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
sink->video_width = video_width;
sink->video_height = video_height;
#if USE_WAYLAND
/* XXX: fix GstVaapiDisplayWayland::get_size() */
if (sink->display_type == GST_VAAPI_DISPLAY_TYPE_WAYLAND) {
sink->window_width = video_width;
sink->window_height = video_height;
return gst_vaapisink_ensure_window(sink,
sink->window_width, sink->window_height);
}
#endif
gst_video_parse_caps_pixel_aspect_ratio(caps, &video_par_n, &video_par_d);
sink->video_par_n = video_par_n;
sink->video_par_d = video_par_d;
@ -662,7 +683,7 @@ error_transfer_surface:
#endif
static inline gboolean
gst_vaapisink_show_frame_x11(
gst_vaapisink_put_surface(
GstVaapiSink *sink,
GstVaapiSurface *surface,
guint flags
@ -715,8 +736,13 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer)
break;
#endif
case GST_VAAPI_DISPLAY_TYPE_X11:
success = gst_vaapisink_show_frame_x11(sink, surface, flags);
success = gst_vaapisink_put_surface(sink, surface, flags);
break;
#if USE_WAYLAND
case GST_VAAPI_DISPLAY_TYPE_WAYLAND:
success = gst_vaapisink_put_surface(sink, surface, flags);
break;
#endif
default:
GST_ERROR("unsupported display type %d", sink->display_type);
success = FALSE;