From 34a2b33c1ab9643cf81209ada648c64cd1e02b0f Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 1 Aug 2012 15:44:49 +0200 Subject: [PATCH] tests: add support for headless decoding. --- tests/Makefile.am | 7 ++++++ tests/output.c | 10 ++++++++ tests/test-display.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-windows.c | 34 ++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 1aacdc9..4c8edbb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,6 +24,13 @@ TEST_LIBS = \ $(GST_LIBS) \ $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-@GST_MAJORMINOR@.la +if USE_DRM +TEST_CFLAGS += $(LIBVA_DRM_CFLAGS) +TEST_LIBS += \ + $(LIBVA_DRM_LIBS) \ + $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-drm-@GST_MAJORMINOR@.la +endif + if USE_X11 TEST_CFLAGS += $(X11_CFLAGS) TEST_LIBS += \ diff --git a/tests/output.c b/tests/output.c index d47af7d..438c04c 100644 --- a/tests/output.c +++ b/tests/output.c @@ -22,6 +22,10 @@ #include "config.h" #include #include +#if USE_DRM +# include +# include +#endif #if USE_X11 # include # include @@ -57,6 +61,12 @@ static const VideoOutputInfo g_video_outputs[] = { gst_vaapi_window_glx_new }, #endif +#if USE_DRM + { "drm", + gst_vaapi_display_drm_new, + gst_vaapi_window_drm_new + }, +#endif { NULL, } }; diff --git a/tests/test-display.c b/tests/test-display.c index 2ebbed0..f86ebb8 100644 --- a/tests/test-display.c +++ b/tests/test-display.c @@ -21,6 +21,15 @@ #include "config.h" #include +#if USE_DRM +# include +# include +# include +# include +# ifndef DRM_DEVICE_PATH +# define DRM_DEVICE_PATH "/dev/dri/card0" +# endif +#endif #if USE_X11 # include #endif @@ -155,6 +164,66 @@ main(int argc, char *argv[]) gst_init(&argc, &argv); +#if USE_DRM + g_print("#\n"); + g_print("# Create display with gst_vaapi_display_drm_new()\n"); + g_print("#\n"); + { + display = gst_vaapi_display_drm_new(NULL); + if (!display) + g_error("could not create Gst/VA display"); + + dump_caps(display); + g_object_unref(display); + } + g_print("\n"); + + g_print("#\n"); + g_print("# Create display with gst_vaapi_display_drm_new_with_device()\n"); + g_print("#\n"); + { + int drm_device; + + drm_device = open(DRM_DEVICE_PATH, O_RDWR|O_CLOEXEC); + if (drm_device < 0) + g_error("could not open DRM device"); + + display = gst_vaapi_display_drm_new_with_device(drm_device); + if (!display) + g_error("could not create Gst/VA display"); + + dump_caps(display); + g_object_unref(display); + close(drm_device); + } + g_print("\n"); + + g_print("#\n"); + g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayDRM()]\n"); + g_print("#\n"); + { + int drm_device; + VADisplay va_display; + + drm_device = open(DRM_DEVICE_PATH, O_RDWR|O_CLOEXEC); + if (drm_device < 0) + g_error("could not open DRM device"); + + va_display = vaGetDisplayDRM(drm_device); + if (!va_display) + g_error("could not create VA display"); + + display = gst_vaapi_display_new_with_display(va_display); + if (!display) + g_error("could not create Gst/VA display"); + + dump_caps(display); + g_object_unref(display); + close(drm_device); + } + g_print("\n"); +#endif + #if USE_X11 g_print("#\n"); g_print("# Create display with gst_vaapi_display_x11_new()\n"); diff --git a/tests/test-windows.c b/tests/test-windows.c index ec6c3d9..8abc784 100644 --- a/tests/test-windows.c +++ b/tests/test-windows.c @@ -22,6 +22,10 @@ #include "config.h" #include #include +#if USE_DRM +# include +# include +#endif #if USE_X11 # include # include @@ -97,6 +101,36 @@ main(int argc, char *argv[]) gst_init(&argc, &argv); +#if USE_DRM + display = gst_vaapi_display_drm_new(NULL); + if (!display) + g_error("could not create Gst/VA (DRM) 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_drm_new()\n"); + g_print("#\n"); + { + window = gst_vaapi_window_drm_new(display, win_width, win_height); + if (!window) + g_error("could not create dummy 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 + #if USE_X11 display = gst_vaapi_display_x11_new(NULL); if (!display) -- 2.7.4