Commit 34a2b33c authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

tests: add support for headless decoding.

parent 657f0a4a
......@@ -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 += \
......
......@@ -22,6 +22,10 @@
#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>
......@@ -56,6 +60,12 @@ static const VideoOutputInfo g_video_outputs[] = {
gst_vaapi_display_glx_new,
gst_vaapi_window_glx_new
},
#endif
#if USE_DRM
{ "drm",
gst_vaapi_display_drm_new,
gst_vaapi_window_drm_new
},
#endif
{ NULL, }
};
......
......@@ -21,6 +21,15 @@
#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");
......
......@@ -22,6 +22,10 @@
#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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment