summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2008-11-25 16:06:22 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-11-25 16:06:22 +0000
commit6ab4698b95bed4ca4032b791d84f26fd2e11224a (patch)
treebdfae8fc836e1cfad539e03200f9baef55411483 /tests
parent0b5fea8568e6e66485e1c3aeff03bf402c1427d1 (diff)
gst/videocrop/gstvideocrop.*: Fix renegotiation when changing properties using the new basetransform features. Fixes ...
Original commit message from CVS: * gst/videocrop/gstvideocrop.c: (gst_video_crop_init), (gst_video_crop_transform), (gst_video_crop_transform_caps), (gst_video_crop_set_caps), (gst_video_crop_set_property): * gst/videocrop/gstvideocrop.h: Fix renegotiation when changing properties using the new basetransform features. Fixes #561502. * tests/icles/Makefile.am: * tests/icles/videocrop2-test.c: (make_pipeline), (main): Add crazy interactive test unit for dynamically changing properties.
Diffstat (limited to 'tests')
-rw-r--r--tests/icles/Makefile.am7
-rw-r--r--tests/icles/videocrop2-test.c141
2 files changed, 147 insertions, 1 deletions
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index 0f545ce4..3cacdd1e 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -40,5 +40,10 @@ videobox_test_CFLAGS = $(GST_CFLAGS)
videobox_test_LDADD = $(GST_LIBS)
videobox_test_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-noinst_PROGRAMS = $(GTK_TESTS) $(V4L2_TESTS) $(X_TESTS) videocrop-test videobox-test
+videocrop2_test_SOURCES = videocrop2-test.c
+videocrop2_test_CFLAGS = $(GST_CFLAGS)
+videocrop2_test_LDADD = $(GST_LIBS)
+videocrop2_test_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+
+noinst_PROGRAMS = $(GTK_TESTS) $(V4L2_TESTS) $(X_TESTS) videocrop-test videobox-test videocrop2-test
diff --git a/tests/icles/videocrop2-test.c b/tests/icles/videocrop2-test.c
new file mode 100644
index 00000000..58d19322
--- /dev/null
+++ b/tests/icles/videocrop2-test.c
@@ -0,0 +1,141 @@
+/* GStreamer interactive videocrop test
+ *
+ * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include <gst/gst.h>
+
+static GstElement *
+make_pipeline (gint type)
+{
+ GstElement *result;
+ gchar *pstr;
+
+ switch (type) {
+ case 0:
+ pstr = g_strdup_printf ("videotestsrc ! videocrop name=crop ! "
+ "xvimagesink");
+ break;
+ default:
+ return NULL;
+ }
+
+ result = gst_parse_launch_full (pstr, NULL, GST_PARSE_FLAG_NONE, NULL);
+ g_print ("created test %d: \"%s\"\n", type, pstr);
+ g_free (pstr);
+
+ return result;
+}
+
+#define MAX_ROUND 500
+
+int
+main (int argc, char **argv)
+{
+ GstElement *pipe, *crop;
+ gint left, right;
+ gint top, bottom;
+ gint ldir, rdir;
+ gint tdir, bdir;
+ gint round, type, stop;
+
+ gst_init (&argc, &argv);
+
+ type = 0;
+ stop = -1;
+
+ if (argc > 1) {
+ type = atoi (argv[1]);
+ stop = type + 1;
+ }
+
+ while (TRUE) {
+ GstMessage *message;
+
+ pipe = make_pipeline (type);
+ if (pipe == NULL)
+ break;
+
+ crop = gst_bin_get_by_name (GST_BIN (pipe), "crop");
+ g_assert (crop);
+
+ top = bottom = left = right = 0;
+ tdir = bdir = 10;
+ ldir = rdir = 10;
+
+ for (round = 0; round < MAX_ROUND; round++) {
+ g_print ("crop to %4d %4d %4d %4d (%d/%d) \r", top, bottom, left, right,
+ round, MAX_ROUND);
+
+ g_object_set (crop, "top", top, "bottom", bottom, "left", left, "right",
+ right, NULL);
+
+ if (round == 0)
+ gst_element_set_state (pipe, GST_STATE_PLAYING);
+
+ top += tdir;
+ if (top >= 80)
+ tdir = -10;
+ else if (top < 10)
+ tdir = 10;
+
+ bottom += bdir;
+ if (bottom >= 60)
+ bdir = -10;
+ else if (bottom < 10)
+ bdir = 10;
+
+ left += ldir;
+ if (left >= 100)
+ ldir = -10;
+ else if (left < 10)
+ ldir = 10;
+
+ right += rdir;
+ if (right >= 80)
+ rdir = -10;
+ else if (right < 10)
+ rdir = 10;
+
+ message =
+ gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
+ 50 * GST_MSECOND);
+ if (message) {
+ g_print ("got error \n");
+
+ gst_message_unref (message);
+ }
+ }
+ g_print ("test %d done \n", type);
+
+ gst_object_unref (crop);
+ gst_element_set_state (pipe, GST_STATE_NULL);
+ gst_object_unref (pipe);
+
+ type++;
+ if (type == stop)
+ break;
+ }
+ return 0;
+}