mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +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
|
||||
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
|
||||
|
||||
|
|
|
@ -30,11 +30,21 @@
|
|||
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||
# include <gst/vaapi/gstvaapiwindow_glx.h>
|
||||
#endif
|
||||
#if USE_WAYLAND
|
||||
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||
# include <gst/vaapi/gstvaapiwindow_wayland.h>
|
||||
#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,
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
#include "config.h"
|
||||
#include <gst/video/video.h>
|
||||
#if USE_X11
|
||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||
#endif
|
||||
#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
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -19,28 +19,34 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||
#include <gst/vaapi/gstvaapiwindow_x11.h>
|
||||
#include "config.h"
|
||||
#include <gst/vaapi/gstvaapisurface.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"
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue