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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, 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 peer-alloc=0 ! videoscale ! "
45 "capsfilter name=filter ! " "ximagesink");
49 g_strdup_printf ("videotestsrc peer-alloc=0 ! queue ! videoscale ! "
50 "capsfilter name=filter ! " "ximagesink");
54 g_strdup_printf ("videotestsrc peer-alloc=0 ! videoscale ! queue ! "
55 "capsfilter name=filter ! " "ximagesink");
58 pstr = g_strdup_printf ("videotestsrc peer-alloc=0 ! "
59 "capsfilter name=filter ! " "ximagesink");
62 pstr = g_strdup_printf ("videotestsrc ! videoscale ! "
63 "capsfilter name=filter ! " "ximagesink");
66 pstr = g_strdup_printf ("v4l2src ! ffmpegcolorspace ! videoscale ! "
67 "capsfilter name=filter ! " "ximagesink");
73 result = gst_parse_launch_full (pstr, NULL, GST_PARSE_FLAG_NONE, NULL);
74 g_print ("created test %d: \"%s\"\n", type, pstr);
83 main (int argc, char **argv)
85 GstElement *pipe, *filter;
89 gint round, type, stop;
91 gst_init (&argc, &argv);
97 type = atoi (argv[1]);
104 pipe = make_pipeline (type);
108 filter = gst_bin_get_by_name (GST_BIN (pipe), "filter");
115 for (round = 0; round < MAX_ROUND; round++) {
117 g_print ("resize to %dx%d (%d/%d) \r", width, height, round, MAX_ROUND);
119 /* we prefer our fixed width and height but allow other dimensions to pass
122 g_strdup_printf ("video/x-raw-rgb, width=(int)%d, height=(int)%d;"
123 "video/x-raw-rgb", width, height);
124 caps = gst_caps_from_string (capsstr);
126 g_object_set (filter, "caps", caps, NULL);
127 gst_caps_unref (caps);
130 gst_element_set_state (pipe, GST_STATE_PLAYING);
135 else if (width < 200)
141 else if (height < 150)
145 gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
148 g_print ("got error \n");
150 gst_message_unref (message);
153 g_print ("test %d done \n", type);
155 gst_object_unref (filter);
156 gst_element_set_state (pipe, GST_STATE_NULL);
157 gst_object_unref (pipe);