1 /* GStreamer interactive videoscale test
2 * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
29 make_pipeline (gint type)
36 pstr = g_strdup_printf ("videotestsrc ! capsfilter name=filter ! "
40 pstr = g_strdup_printf ("videotestsrc ! queue ! capsfilter name=filter ! "
44 pstr = g_strdup_printf ("videotestsrc ! videoscale ! "
45 "capsfilter name=filter ! " "ximagesink");
49 g_strdup_printf ("videotestsrc ! queue ! videoscale ! "
50 "capsfilter name=filter ! " "ximagesink");
54 g_strdup_printf ("videotestsrc ! videoscale ! queue ! "
55 "capsfilter name=filter ! " "ximagesink");
58 pstr = g_strdup_printf ("v4l2src ! videoconvert ! videoscale ! "
59 "capsfilter name=filter ! " "ximagesink");
65 result = gst_parse_launch_full (pstr, NULL, GST_PARSE_FLAG_NONE, NULL);
66 g_print ("created test %d: \"%s\"\n", type, pstr);
75 main (int argc, char **argv)
77 GstElement *pipe, *filter;
81 gint round, type, stop;
83 gst_init (&argc, &argv);
89 type = atoi (argv[1]);
96 pipe = make_pipeline (type);
100 filter = gst_bin_get_by_name (GST_BIN (pipe), "filter");
107 for (round = 0; round < MAX_ROUND; round++) {
109 g_print ("resize to %dx%d (%d/%d) \r", width, height, round, MAX_ROUND);
111 /* we prefer our fixed width and height but allow other dimensions to pass
114 g_strdup_printf ("video/x-raw, width=(int)%d, height=(int)%d;"
115 "video/x-raw", width, height);
117 caps = gst_caps_from_string (capsstr);
119 g_object_set (filter, "caps", caps, NULL);
120 gst_caps_unref (caps);
123 gst_element_set_state (pipe, GST_STATE_PLAYING);
128 else if (width < 200)
134 else if (height < 150)
138 gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
141 g_print ("got error \n");
143 gst_message_unref (message);
146 g_print ("test %d done \n", type);
148 gst_object_unref (filter);
149 gst_element_set_state (pipe, GST_STATE_NULL);
150 gst_object_unref (pipe);