2 * test-vaapipostproc.c - Testsuite for VAAPI Postprocessor
4 * Copyright (C) 2017 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
24 #include <gst/base/gstbasetransform.h>
26 typedef struct _CustomData
34 _check_passthrough_mode (gpointer user_data)
37 AppData *data = (AppData *) user_data;
39 ret = gst_base_transform_is_passthrough (GST_BASE_TRANSFORM (data->postproc));
42 gst_println ("Now this pipeline is on passthrough mode");
44 gst_println ("Now this pipeline is NOT on passthrough mode");
50 set_contrast (AppData * data)
52 static gfloat value = 1.0;
54 value = value == 1.0 ? 0.5 : 1.0;
55 g_object_set (data->postproc, "contrast", value, NULL);
56 gst_println ("contrast value is changed to %f", value);
58 g_timeout_add (300, _check_passthrough_mode, data);
62 change_size (AppData * data)
66 g_object_set (data->postproc, "width", 1280, "height", 720, NULL);
67 gst_println ("frame size is changed to 1280x720");
70 g_object_set (data->postproc, "width", 0, "height", 0, NULL);
71 gst_println ("frame size is changed to default");
75 g_timeout_add (300, _check_passthrough_mode, data);
78 /* Process keyboard input */
80 handle_keyboard (GIOChannel * source, GIOCondition cond, AppData * data)
84 if (g_io_channel_read_line (source, &str, NULL, NULL,
85 NULL) != G_IO_STATUS_NORMAL) {
89 switch (g_ascii_tolower (str[0])) {
99 g_main_loop_quit (data->loop);
111 main (int argc, char *argv[])
113 AppData data = { 0, };
114 GstStateChangeReturn ret;
115 GIOChannel *io_stdin;
117 /* Initialize GStreamer */
118 gst_init (&argc, &argv);
120 /* Print usage map */
121 gst_println ("USAGE: Choose one of the following options, then press enter:\n"
122 " 's' to set contrast\n" " 'c' to change size\n" " 'q' to quit\n");
126 ("videotestsrc name=src ! vaapih264enc ! vaapih264dec ! vaapipostproc name=postproc ! vaapisink",
128 data.postproc = gst_bin_get_by_name (GST_BIN (data.pipeline), "postproc");
130 /* Add a keyboard watch so we get notified of keystrokes */
131 io_stdin = g_io_channel_unix_new (fileno (stdin));
132 g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc) handle_keyboard, &data);
135 ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
136 if (ret == GST_STATE_CHANGE_FAILURE) {
137 g_printerr ("Unable to set the pipeline to the playing state.\n");
138 gst_object_unref (data.pipeline);
142 g_timeout_add (300, _check_passthrough_mode, &data);
144 /* Create a GLib Main Loop and set it to run */
145 data.loop = g_main_loop_new (NULL, FALSE);
146 g_main_loop_run (data.loop);
149 g_main_loop_unref (data.loop);
150 g_io_channel_unref (io_stdin);
151 gst_element_set_state (data.pipeline, GST_STATE_NULL);
153 gst_object_unref (data.postproc);
154 gst_object_unref (data.pipeline);