1 /* GStreamer interactive videocrop test
3 * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
30 make_pipeline (gint type)
37 pstr = g_strdup_printf ("videotestsrc ! videocrop name=crop ! "
44 result = gst_parse_launch_full (pstr, NULL, GST_PARSE_FLAG_NONE, NULL);
45 g_print ("created test %d: \"%s\"\n", type, pstr);
54 main (int argc, char **argv)
56 GstElement *pipe, *crop;
61 gint round, type, stop;
63 gst_init (&argc, &argv);
69 type = atoi (argv[1]);
76 pipe = make_pipeline (type);
80 crop = gst_bin_get_by_name (GST_BIN (pipe), "crop");
83 top = bottom = left = right = 0;
87 for (round = 0; round < MAX_ROUND; round++) {
88 g_print ("crop to %4d %4d %4d %4d (%d/%d) \r", top, bottom, left, right,
91 g_object_set (crop, "top", top, "bottom", bottom, "left", left, "right",
95 gst_element_set_state (pipe, GST_STATE_PLAYING);
106 else if (bottom < 10)
122 gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
125 g_print ("got error \n");
127 gst_message_unref (message);
130 g_print ("test %d done \n", type);
132 gst_object_unref (crop);
133 gst_element_set_state (pipe, GST_STATE_NULL);
134 gst_object_unref (pipe);