summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2016-07-01 16:01:54 +0900
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-07-05 21:01:38 +0200
commitda4d916a8c0ee2fa5c3b7ac66470736629d25965 (patch)
tree3aec890f10f129f026efd8c629a0a3ca55c1dcf3 /tests
parente8fabf6a9923328def8f3d7f0c3105dc34b285d9 (diff)
tests: elements: Add testsuite for vaapisink
https://bugzilla.gnome.org/show_bug.cgi?id=765798
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/elements/Makefile.am68
-rw-r--r--tests/elements/test-vaapisink.c115
3 files changed, 185 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 578b6053..ca587979 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -158,4 +158,6 @@ EXTRA_DIST = \
$(test_utils_source_h) \
$(NULL)
+SUBDIRS = elements
+
-include $(top_srcdir)/git.mk
diff --git a/tests/elements/Makefile.am b/tests/elements/Makefile.am
new file mode 100644
index 00000000..73e39ed4
--- /dev/null
+++ b/tests/elements/Makefile.am
@@ -0,0 +1,68 @@
+noinst_PROGRAMS = \
+ test-vaapisink \
+ $(NULL)
+
+TEST_CFLAGS = \
+ -DGST_USE_UNSTABLE_API \
+ -I$(top_srcdir)/gst-libs \
+ -I$(top_builddir)/gst-libs \
+ $(LIBVA_CFLAGS) \
+ $(GST_CFLAGS) \
+ $(GST_VIDEO_CFLAGS) \
+ $(NULL)
+
+GST_VAAPI_LIBS = $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi.la
+TEST_LIBS = \
+ $(LIBVA_LIBS) \
+ $(GST_LIBS) \
+ $(NULL)
+
+if USE_DRM
+GST_VAAPI_LIBS += $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-drm.la
+TEST_CFLAGS += $(LIBVA_DRM_CFLAGS)
+TEST_LIBS += $(LIBVA_DRM_LIBS)
+endif
+
+if USE_X11
+GST_VAAPI_LIBS += $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-x11.la
+TEST_CFLAGS += $(X11_CFLAGS)
+TEST_LIBS += \
+ $(LIBVA_X11_LIBS) \
+ $(X11_LIBS) \
+ $(NULL)
+endif
+
+if USE_GLX
+GST_VAAPI_LIBS += $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-glx.la
+TEST_CFLAGS += $(X11_CFLAGS) $(GL_CFLAGS)
+TEST_LIBS += \
+ $(LIBVA_GLX_LIBS) \
+ $(X11_LIBS) \
+ $(GL_LIBS) \
+ $(NULL)
+endif
+
+if USE_EGL
+GST_VAAPI_LIBS += $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-egl.la
+TEST_CFLAGS += $(EGL_CFLAGS)
+TEST_LIBS += \
+ $(LIBVA_EGL_LIBS) \
+ $(EGL_LIBS) \
+ $(NULL)
+endif
+
+if USE_WAYLAND
+GST_VAAPI_LIBS += $(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland.la
+TEST_CFLAGS += $(WAYLAND_CFLAGS)
+TEST_LIBS += \
+ $(LIBVA_WAYLAND_LIBS) \
+ $(WAYLAND_LIBS) \
+ $(NULL)
+endif
+
+test_vaapisink_SOURCES = test-vaapisink.c
+test_vaapisink_CFLAGS = $(TEST_CFLAGS)
+test_vaapisink_LDFLAGS = $(GST_VAAPI_LIBS)
+test_vaapisink_LDADD = $(TEST_LIBS)
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/elements/test-vaapisink.c b/tests/elements/test-vaapisink.c
new file mode 100644
index 00000000..7167aecf
--- /dev/null
+++ b/tests/elements/test-vaapisink.c
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <string.h>
+#include <gst/gst.h>
+
+#include <gst/vaapi/gstvaapitypes.h>
+
+typedef struct _CustomData
+{
+ GstElement *pipeline;
+ GstElement *video_sink;
+ GstElement *src_sink;
+ GMainLoop *loop;
+ GstPad *src_pad;
+ gboolean orient_automatic;
+} AppData;
+
+static void
+send_rotate_event (AppData * data)
+{
+ gboolean res = FALSE;
+ GstEvent *event;
+
+ event = gst_event_new_tag (gst_tag_list_new (GST_TAG_IMAGE_ORIENTATION,
+ "rotate-90", NULL));
+
+ /* Send the event */
+ res = gst_pad_push_event (data->src_pad, event);
+ g_print ("Sending event %p done: %d\n", event, res);
+}
+
+/* Process keyboard input */
+static gboolean
+handle_keyboard (GIOChannel * source, GIOCondition cond, AppData * data)
+{
+ gchar *str = NULL;
+
+ if (g_io_channel_read_line (source, &str, NULL, NULL,
+ NULL) != G_IO_STATUS_NORMAL) {
+ return TRUE;
+ }
+
+ switch (g_ascii_tolower (str[0])) {
+ case 'r':
+ send_rotate_event (data);
+ break;
+ case 's':{
+ g_object_set (G_OBJECT (data->video_sink), "rotation",
+ GST_VAAPI_ROTATION_AUTOMATIC, NULL);
+ break;
+ }
+ case 'q':
+ g_main_loop_quit (data->loop);
+ break;
+ default:
+ break;
+ }
+
+ g_free (str);
+
+ return TRUE;
+}
+
+int
+main (int argc, char *argv[])
+{
+ AppData data;
+ GstStateChangeReturn ret;
+ GIOChannel *io_stdin;
+
+ /* Initialize GStreamer */
+ gst_init (&argc, &argv);
+
+ /* Initialize our data structure */
+ memset (&data, 0, sizeof (data));
+
+ /* Print usage map */
+ g_print ("USAGE: Choose one of the following options, then press enter:\n"
+ " 'r' to send image-orientation tag event\n \
+ 's' to set orient-automatic\n \
+ 'Q' to quit\n");
+
+ data.pipeline =
+ gst_parse_launch
+ ("videotestsrc name=src ! vaapisink name=vaapisink", NULL);
+ data.video_sink = gst_bin_get_by_name (GST_BIN (data.pipeline), "vaapisink");
+ data.src_sink = gst_bin_get_by_name (GST_BIN (data.pipeline), "src");
+ data.src_pad = gst_element_get_static_pad (data.src_sink, "src");
+
+ /* Add a keyboard watch so we get notified of keystrokes */
+ io_stdin = g_io_channel_unix_new (fileno (stdin));
+ g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc) handle_keyboard, &data);
+
+ /* Start playing */
+ ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ g_printerr ("Unable to set the pipeline to the playing state.\n");
+ gst_object_unref (data.pipeline);
+ return -1;
+ }
+
+ /* Create a GLib Main Loop and set it to run */
+ data.loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (data.loop);
+
+ /* Free resources */
+ g_main_loop_unref (data.loop);
+ g_io_channel_unref (io_stdin);
+ gst_element_set_state (data.pipeline, GST_STATE_NULL);
+
+ if (data.video_sink != NULL)
+ gst_object_unref (data.video_sink);
+ gst_object_unref (data.pipeline);
+
+ return 0;
+}