mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
tests: add support for Wayland.
This commit is contained in:
parent
621bb12be6
commit
5e356922bf
4 changed files with 134 additions and 32 deletions
|
@ -41,6 +41,14 @@ TEST_LIBS += \
|
||||||
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-@GST_MAJORMINOR@.la
|
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx-@GST_MAJORMINOR@.la
|
||||||
endif
|
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_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
|
test_codecs_source_h = $(test_codecs_source_c:%.c=%.h) test-decode.h
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,21 @@
|
||||||
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||||
# include <gst/vaapi/gstvaapiwindow_glx.h>
|
# include <gst/vaapi/gstvaapiwindow_glx.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if USE_WAYLAND
|
||||||
|
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||||
|
# include <gst/vaapi/gstvaapiwindow_wayland.h>
|
||||||
|
#endif
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
|
||||||
static const VideoOutputInfo *g_video_output;
|
static const VideoOutputInfo *g_video_output;
|
||||||
static const VideoOutputInfo g_video_outputs[] = {
|
static const VideoOutputInfo g_video_outputs[] = {
|
||||||
/* Video outputs are sorted in test order for automatic characterisation */
|
/* 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
|
#if USE_X11
|
||||||
{ "x11",
|
{ "x11",
|
||||||
gst_vaapi_display_x11_new,
|
gst_vaapi_display_x11_new,
|
||||||
|
|
|
@ -22,10 +22,13 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
#if USE_X11
|
#if USE_X11
|
||||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||||
#endif
|
#endif
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
#include <gst/vaapi/gstvaapidisplay_glx.h>
|
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||||
|
#endif
|
||||||
|
#if USE_WAYLAND
|
||||||
|
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_VA_VA_GLX_H
|
#ifdef HAVE_VA_VA_GLX_H
|
||||||
|
@ -147,8 +150,6 @@ dump_caps(GstVaapiDisplay *display)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Display *x11_display;
|
|
||||||
VADisplay va_display;
|
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
guint width, height, par_n, par_d;
|
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("# Create display with gst_vaapi_display_x11_new_with_display()\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
{
|
{
|
||||||
|
Display *x11_display;
|
||||||
|
|
||||||
x11_display = XOpenDisplay(NULL);
|
x11_display = XOpenDisplay(NULL);
|
||||||
if (!x11_display)
|
if (!x11_display)
|
||||||
g_error("could not create 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("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
{
|
{
|
||||||
|
Display *x11_display;
|
||||||
|
VADisplay va_display;
|
||||||
|
|
||||||
x11_display = XOpenDisplay(NULL);
|
x11_display = XOpenDisplay(NULL);
|
||||||
if (!x11_display)
|
if (!x11_display)
|
||||||
g_error("could not create 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("# Create display with gst_vaapi_display_glx_new_with_display()\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
{
|
{
|
||||||
|
Display *x11_display;
|
||||||
|
|
||||||
x11_display = XOpenDisplay(NULL);
|
x11_display = XOpenDisplay(NULL);
|
||||||
if (!x11_display)
|
if (!x11_display)
|
||||||
g_error("could not create 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("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
{
|
{
|
||||||
|
Display *x11_display;
|
||||||
|
VADisplay va_display;
|
||||||
|
|
||||||
x11_display = XOpenDisplay(NULL);
|
x11_display = XOpenDisplay(NULL);
|
||||||
if (!x11_display)
|
if (!x11_display)
|
||||||
g_error("could not create X11 display");
|
g_error("could not create X11 display");
|
||||||
|
@ -278,6 +289,27 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
#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();
|
gst_deinit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,28 +19,34 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
#include "config.h"
|
||||||
#include <gst/vaapi/gstvaapiwindow_x11.h>
|
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
#include <gst/vaapi/gstvaapiimage.h>
|
#include <gst/vaapi/gstvaapiimage.h>
|
||||||
|
#if USE_X11
|
||||||
|
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||||
|
# include <gst/vaapi/gstvaapiwindow_x11.h>
|
||||||
|
#endif
|
||||||
|
#if USE_WAYLAND
|
||||||
|
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||||
|
# include <gst/vaapi/gstvaapiwindow_wayland.h>
|
||||||
|
#endif
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
static inline void pause(void)
|
static inline void
|
||||||
|
pause(void)
|
||||||
{
|
{
|
||||||
g_print("Press any key to continue...\n");
|
g_print("Press any key to continue...\n");
|
||||||
getchar();
|
getchar();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static GstVaapiSurface *
|
||||||
main(int argc, char *argv[])
|
create_test_surface(GstVaapiDisplay *display, guint width, guint height)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *display;
|
GstVaapiImage *image = NULL;
|
||||||
GstVaapiWindow *window;
|
GstVaapiSurface *surface;
|
||||||
GstVaapiSurface *surface;
|
|
||||||
GstVaapiImage *image = NULL;
|
|
||||||
guint flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
|
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||||
static const GstVaapiImageFormat image_formats[] = {
|
static const GstVaapiImageFormat image_formats[] = {
|
||||||
GST_VAAPI_IMAGE_NV12,
|
GST_VAAPI_IMAGE_NV12,
|
||||||
GST_VAAPI_IMAGE_YV12,
|
GST_VAAPI_IMAGE_YV12,
|
||||||
|
@ -53,18 +59,6 @@ main(int argc, char *argv[])
|
||||||
0
|
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);
|
surface = gst_vaapi_surface_new(display, chroma_type, width, height);
|
||||||
if (!surface)
|
if (!surface)
|
||||||
g_error("could not create Gst/VA surface");
|
g_error("could not create Gst/VA surface");
|
||||||
|
@ -73,11 +67,10 @@ main(int argc, char *argv[])
|
||||||
const GstVaapiImageFormat format = image_formats[i];
|
const GstVaapiImageFormat format = image_formats[i];
|
||||||
|
|
||||||
image = image_generate(display, format, width, height);
|
image = image_generate(display, format, width, height);
|
||||||
if (image) {
|
if (!image)
|
||||||
if (image_upload(image, surface))
|
break;
|
||||||
break;
|
if (image_upload(image, surface))
|
||||||
g_object_unref(image);
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!image)
|
if (!image)
|
||||||
g_error("could not create Gst/VA image");
|
g_error("could not create Gst/VA image");
|
||||||
|
@ -85,6 +78,34 @@ main(int argc, char *argv[])
|
||||||
if (!gst_vaapi_surface_sync(surface))
|
if (!gst_vaapi_surface_sync(surface))
|
||||||
g_error("could not complete image upload");
|
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("#\n");
|
||||||
g_print("# Create window with gst_vaapi_window_x11_new()\n");
|
g_print("# Create window with gst_vaapi_window_x11_new()\n");
|
||||||
g_print("#\n");
|
g_print("#\n");
|
||||||
|
@ -141,9 +162,40 @@ main(int argc, char *argv[])
|
||||||
XDestroyWindow(dpy, win);
|
XDestroyWindow(dpy, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(image);
|
|
||||||
g_object_unref(surface);
|
g_object_unref(surface);
|
||||||
g_object_unref(display);
|
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();
|
gst_deinit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue