tests: add support for headless decoding.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 1 Aug 2012 13:44:49 +0000 (15:44 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 1 Aug 2012 14:40:17 +0000 (16:40 +0200)
tests/Makefile.am
tests/output.c
tests/test-display.c
tests/test-windows.c

index 1aacdc9..4c8edbb 100644 (file)
@@ -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      += \
index d47af7d..438c04c 100644 (file)
 #include "config.h"
 #include <string.h>
 #include <gst/gst.h>
+#if USE_DRM
+# include <gst/vaapi/gstvaapidisplay_drm.h>
+# include <gst/vaapi/gstvaapiwindow_drm.h>
+#endif
 #if USE_X11
 # include <gst/vaapi/gstvaapidisplay_x11.h>
 # include <gst/vaapi/gstvaapiwindow_x11.h>
@@ -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, }
 };
 
index 2ebbed0..f86ebb8 100644 (file)
 
 #include "config.h"
 #include <gst/video/video.h>
+#if USE_DRM
+# include <gst/vaapi/gstvaapidisplay_drm.h>
+# include <va/va_drm.h>
+# include <fcntl.h>
+# include <unistd.h>
+# ifndef DRM_DEVICE_PATH
+# define DRM_DEVICE_PATH "/dev/dri/card0"
+# endif
+#endif
 #if USE_X11
 # include <gst/vaapi/gstvaapidisplay_x11.h>
 #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");
index ec6c3d9..8abc784 100644 (file)
 #include "config.h"
 #include <gst/vaapi/gstvaapisurface.h>
 #include <gst/vaapi/gstvaapiimage.h>
+#if USE_DRM
+# include <gst/vaapi/gstvaapidisplay_drm.h>
+# include <gst/vaapi/gstvaapiwindow_drm.h>
+#endif
 #if USE_X11
 # include <gst/vaapi/gstvaapidisplay_x11.h>
 # include <gst/vaapi/gstvaapiwindow_x11.h>
@@ -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)