From 5e356922bf33d7bb6a8a036957d4adc3bb4e5ea1 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 23 Jul 2012 12:56:33 +0200 Subject: [PATCH] tests: add support for Wayland. --- tests/Makefile.am | 8 ++++ tests/output.c | 10 +++++ tests/test-display.c | 40 +++++++++++++++++-- tests/test-windows.c | 108 ++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 134 insertions(+), 32 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 71c5531..1aacdc9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,6 +41,14 @@ TEST_LIBS += \ $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-@GST_MAJORMINOR@.la endif +if USE_WAYLAND +TEST_CFLAGS += $(WAYLAND_CFLAGS) +TEST_LIBS += \ + $(LIBVA_WAYLAND_LIBS) \ + $(WAYLAND_LIBS) \ + $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland-@GST_MAJORMINOR@.la +endif + test_codecs_source_c = test-mpeg2.c test-h264.c test-vc1.c test-jpeg.c test_codecs_source_h = $(test_codecs_source_c:%.c=%.h) test-decode.h diff --git a/tests/output.c b/tests/output.c index 583347c..d47af7d 100644 --- a/tests/output.c +++ b/tests/output.c @@ -30,11 +30,21 @@ # include # include #endif +#if USE_WAYLAND +# include +# include +#endif #include "output.h" static const VideoOutputInfo *g_video_output; static const VideoOutputInfo g_video_outputs[] = { /* Video outputs are sorted in test order for automatic characterisation */ +#if USE_WAYLAND + { "wayland", + gst_vaapi_display_wayland_new, + gst_vaapi_window_wayland_new + }, +#endif #if USE_X11 { "x11", gst_vaapi_display_x11_new, diff --git a/tests/test-display.c b/tests/test-display.c index 47caa3d..2ebbed0 100644 --- a/tests/test-display.c +++ b/tests/test-display.c @@ -22,10 +22,13 @@ #include "config.h" #include #if USE_X11 -#include +# include #endif #if USE_GLX -#include +# include +#endif +#if USE_WAYLAND +# include #endif #ifdef HAVE_VA_VA_GLX_H @@ -147,8 +150,6 @@ dump_caps(GstVaapiDisplay *display) int main(int argc, char *argv[]) { - Display *x11_display; - VADisplay va_display; GstVaapiDisplay *display; guint width, height, par_n, par_d; @@ -178,6 +179,8 @@ main(int argc, char *argv[]) g_print("# Create display with gst_vaapi_display_x11_new_with_display()\n"); g_print("#\n"); { + Display *x11_display; + x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); @@ -196,6 +199,9 @@ main(int argc, char *argv[]) g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n"); g_print("#\n"); { + Display *x11_display; + VADisplay va_display; + x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); @@ -239,6 +245,8 @@ main(int argc, char *argv[]) g_print("# Create display with gst_vaapi_display_glx_new_with_display()\n"); g_print("#\n"); { + Display *x11_display; + x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); @@ -258,6 +266,9 @@ main(int argc, char *argv[]) g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n"); g_print("#\n"); { + Display *x11_display; + VADisplay va_display; + x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); @@ -278,6 +289,27 @@ main(int argc, char *argv[]) #endif #endif +#if USE_WAYLAND + g_print("#\n"); + g_print("# Create display with gst_vaapi_display_wayland_new()\n"); + g_print("#\n"); + { + display = gst_vaapi_display_wayland_new(NULL); + if (!display) + g_error("could not create Gst/VA display"); + + gst_vaapi_display_get_size(display, &width, &height); + g_print("Display size: %ux%u\n", width, height); + + gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d); + g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); + + dump_caps(display); + g_object_unref(display); + } + g_print("\n"); +#endif + gst_deinit(); return 0; } diff --git a/tests/test-windows.c b/tests/test-windows.c index 56c3168..ec6c3d9 100644 --- a/tests/test-windows.c +++ b/tests/test-windows.c @@ -19,28 +19,34 @@ * Boston, MA 02110-1301 USA */ -#include -#include +#include "config.h" #include #include +#if USE_X11 +# include +# include +#endif +#if USE_WAYLAND +# include +# include +#endif #include "image.h" -static inline void pause(void) +static inline void +pause(void) { g_print("Press any key to continue...\n"); getchar(); } -int -main(int argc, char *argv[]) +static GstVaapiSurface * +create_test_surface(GstVaapiDisplay *display, guint width, guint height) { - GstVaapiDisplay *display; - GstVaapiWindow *window; - GstVaapiSurface *surface; - GstVaapiImage *image = NULL; - guint flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME; + GstVaapiImage *image = NULL; + GstVaapiSurface *surface; guint i; + static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420; static const GstVaapiImageFormat image_formats[] = { GST_VAAPI_IMAGE_NV12, GST_VAAPI_IMAGE_YV12, @@ -53,18 +59,6 @@ main(int argc, char *argv[]) 0 }; - static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420; - static const guint width = 320; - static const guint height = 240; - static const guint win_width = 640; - static const guint win_height = 480; - - gst_init(&argc, &argv); - - display = gst_vaapi_display_x11_new(NULL); - if (!display) - g_error("could not create Gst/VA display"); - surface = gst_vaapi_surface_new(display, chroma_type, width, height); if (!surface) g_error("could not create Gst/VA surface"); @@ -73,11 +67,10 @@ main(int argc, char *argv[]) const GstVaapiImageFormat format = image_formats[i]; image = image_generate(display, format, width, height); - if (image) { - if (image_upload(image, surface)) - break; - g_object_unref(image); - } + if (!image) + break; + if (image_upload(image, surface)) + break; } if (!image) g_error("could not create Gst/VA image"); @@ -85,6 +78,34 @@ main(int argc, char *argv[]) if (!gst_vaapi_surface_sync(surface)) g_error("could not complete image upload"); + g_object_unref(image); + return surface; +} + +int +main(int argc, char *argv[]) +{ + GstVaapiDisplay *display; + GstVaapiWindow *window; + GstVaapiSurface *surface; + guint flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME; + + static const guint width = 320; + static const guint height = 240; + static const guint win_width = 640; + static const guint win_height = 480; + + gst_init(&argc, &argv); + +#if USE_X11 + display = gst_vaapi_display_x11_new(NULL); + if (!display) + g_error("could not create Gst/VA display"); + + surface = create_test_surface(display, width, height); + if (!surface) + g_error("could not create Gst/VA surface"); + g_print("#\n"); g_print("# Create window with gst_vaapi_window_x11_new()\n"); g_print("#\n"); @@ -141,9 +162,40 @@ main(int argc, char *argv[]) XDestroyWindow(dpy, win); } - g_object_unref(image); g_object_unref(surface); g_object_unref(display); +#endif + +#if USE_WAYLAND + display = gst_vaapi_display_wayland_new(NULL); + if (!display) + g_error("could not create Gst/VA (Wayland) display"); + + surface = create_test_surface(display, width, height); + if (!surface) + g_error("could not create Gst/VA surface"); + + g_print("#\n"); + g_print("# Create window with gst_vaapi_window_wayland_new()\n"); + g_print("#\n"); + { + window = gst_vaapi_window_wayland_new(display, win_width, win_height); + if (!window) + g_error("could not create window"); + + gst_vaapi_window_show(window); + + if (!gst_vaapi_window_put_surface(window, surface, NULL, NULL, flags)) + g_error("could not render surface"); + + pause(); + g_object_unref(window); + } + + g_object_unref(surface); + g_object_unref(display); +#endif + gst_deinit(); return 0; } -- 2.7.4