summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2008-01-29 07:38:31 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2008-01-29 07:38:31 +0000
commit83e305cf5dd437f5dd30f2ef78de18a2e8dc3438 (patch)
treeb2f9b30db8853ba5f261f7168ad0e9448ffe0f1a /tests
parentc459b9da7d7fe346bceeb4968fae6959aa0f7697 (diff)
downloadgst-plugins-bad-83e305cf5dd437f5dd30f2ef78de18a2e8dc3438.tar.gz
gst-plugins-bad-83e305cf5dd437f5dd30f2ef78de18a2e8dc3438.tar.bz2
gst-plugins-bad-83e305cf5dd437f5dd30f2ef78de18a2e8dc3438.zip
Replace the switch plugin with the selector plugin. Add output- selector as the opposite of input-selectoo (was switc...
Original commit message from CVS: * configure.ac: * docs/plugins/Makefile.am: * docs/plugins/gst-plugins-bad-plugins-docs.sgml: * docs/plugins/gst-plugins-bad-plugins-sections.txt: * docs/plugins/gst-plugins-bad-plugins.args: * docs/plugins/gst-plugins-bad-plugins.hierarchy: * docs/plugins/gst-plugins-bad-plugins.interfaces: * docs/plugins/gst-plugins-bad-plugins.signals: * docs/plugins/inspect/plugin-metadata.xml: * docs/plugins/inspect/plugin-selector.xml: * docs/plugins/inspect/plugin-soundtouch.xml: * docs/plugins/inspect/plugin-switch.xml: * gst/selector/.cvsignore: * gst/selector/Makefile.am: * gst/selector/gstinputselector.c: * gst/selector/gstinputselector.h: * gst/selector/gstoutputselector.c: * gst/selector/gstoutputselector.h: * gst/selector/gstselector-marshal.list: * gst/selector/gstselector.c: * gst/selector/selector.vcproj: * gst/switch/.cvsignore: * gst/switch/Makefile.am: * gst/switch/gstswitch-marshal.list: * gst/switch/gstswitch.c: * gst/switch/gstswitch.h: * gst/switch/switch.vcproj: * tests/icles/.cvsignore: * tests/icles/Makefile.am: * tests/icles/output-selector-test.c: Replace the switch plugin with the selector plugin. Add output- selector as the opposite of input-selectoo (was switch). Add a test for output-selector. Add docs for the elements. The vcproj needs update. Fixes #500142.
Diffstat (limited to 'tests')
-rw-r--r--tests/icles/.gitignore5
-rw-r--r--tests/icles/Makefile.am12
-rwxr-xr-xtests/icles/output-selector-test.c149
3 files changed, 163 insertions, 3 deletions
diff --git a/tests/icles/.gitignore b/tests/icles/.gitignore
index bb39cc6c..aa8e2e41 100644
--- a/tests/icles/.gitignore
+++ b/tests/icles/.gitignore
@@ -1,4 +1,5 @@
equalizer-test
+metadata_editor
+output-selector-test
pitch-test
-v4l2src-test
-videocrop-test
+
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index b3fba24c..79d20316 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -11,6 +11,7 @@ else
GST_SOUNDTOUCH_TESTS =
endif
+
if USE_METADATA
if HAVE_GLADE
if HAVE_GTK
@@ -39,4 +40,13 @@ equalizer_test_CFLAGS = $(GST_CFLAGS)
equalizer_test_LDADD = $(GST_LIBS)
equalizer_test_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-noinst_PROGRAMS = $(GST_SOUNDTOUCH_TESTS) $(GST_METADATA_TESTS) equalizer-test
+
+output_selector_test_SOURCES = output-selector-test.c
+output_selector_test_CFLAGS = $(GST_CFLAGS)
+output_selector_test_LDADD = $(GST_LIBS)
+output_selector_test_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+
+
+noinst_PROGRAMS = $(GST_SOUNDTOUCH_TESTS) $(GST_METADATA_TESTS) \
+ equalizer-test output-selector-test
+
diff --git a/tests/icles/output-selector-test.c b/tests/icles/output-selector-test.c
new file mode 100755
index 00000000..304295cd
--- /dev/null
+++ b/tests/icles/output-selector-test.c
@@ -0,0 +1,149 @@
+#include <gst/gst.h>
+
+//[.. my_bus_callback goes here ..]
+
+static GMainLoop *loop;
+
+static gboolean
+my_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
+{
+ g_print ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR:{
+ GError *err;
+ gchar *debug;
+
+ gst_message_parse_error (message, &err, &debug);
+ g_print ("Error: %s\n", err->message);
+ g_error_free (err);
+ g_free (debug);
+
+ g_main_loop_quit (loop);
+ break;
+ }
+ case GST_MESSAGE_EOS:
+ /* end-of-stream */
+ g_main_loop_quit (loop);
+ break;
+ default:
+ /* unhandled message */
+ break;
+ }
+ /* we want to be notified again the next time there is a message
+ * on the bus, so returning TRUE (FALSE means we want to stop watching
+ * for messages on the bus and our callback should not be called again)
+ */
+ return TRUE;
+}
+
+static gboolean
+switch_cb (gpointer user_data)
+{
+
+ GstElement *sel = GST_ELEMENT (user_data);
+ gchar *old_pad_name, *new_pad_name;
+
+ g_object_get (G_OBJECT (sel), "active-pad", &old_pad_name, NULL);
+
+ if (g_str_equal (old_pad_name, "src0"))
+ new_pad_name = "src1";
+ else
+ new_pad_name = "src0";
+
+ g_object_set (G_OBJECT (sel), "active-pad", new_pad_name, NULL);
+
+ g_print ("switched from %s to %s\n", old_pad_name, new_pad_name);
+ g_free (old_pad_name);
+
+ return TRUE;
+
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+ GstElement *pipeline, *src, *toverlay, *osel, *sink1, *sink2, *convert;
+ GstPad *osel_src1, *osel_src2, *sinkpad;
+ GstBus *bus;
+
+ /* init GStreamer */
+ gst_init (&argc, &argv);
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* create elements */
+ pipeline = gst_element_factory_make ("pipeline", "pipeline");
+ src = gst_element_factory_make ("videotestsrc", "src");
+ toverlay = gst_element_factory_make ("timeoverlay", "timeoverlay");
+ osel = gst_element_factory_make ("output-selector", "osel");
+ convert = gst_element_factory_make ("ffmpegcolorspace", "convert");
+ sink1 = gst_element_factory_make ("xvimagesink", "sink1");
+ sink2 = gst_element_factory_make ("ximagesink", "sink2");
+
+ if (!pipeline || !src || !toverlay || !osel || !convert || !sink1 || !sink2) {
+ g_print ("missing element\n");
+ return -1;
+ }
+
+ /* add them to bin */
+ gst_bin_add_many (GST_BIN (pipeline), src, toverlay, osel, convert, sink1,
+ sink2, NULL);
+
+ /* set properties */
+ g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);
+ g_object_set (G_OBJECT (src), "do-timestamp", TRUE, NULL);
+ g_object_set (G_OBJECT (src), "num-buffers", 500, NULL);
+ g_object_set (G_OBJECT (sink1), "sync", FALSE, NULL);
+ g_object_set (G_OBJECT (sink2), "sync", FALSE, NULL);
+ g_object_set (G_OBJECT (osel), "resend-latest", TRUE, NULL);
+
+ /* link src ! timeoverlay ! osel */
+ if (!gst_element_link_many (src, toverlay, osel, NULL)) {
+ g_print ("linking failed\n");
+ return -1;
+ }
+
+ /* link output 1 */
+ sinkpad = gst_element_get_static_pad (sink1, "sink");
+ osel_src1 = gst_element_get_request_pad (osel, "src%d");
+ if (gst_pad_link (osel_src1, sinkpad) != GST_PAD_LINK_OK) {
+ g_print ("linking output 1 failed\n");
+ return -1;
+ }
+ gst_object_unref (sinkpad);
+
+ /* link output 2 */
+ sinkpad = gst_element_get_static_pad (convert, "sink");
+ osel_src2 = gst_element_get_request_pad (osel, "src%d");
+ if (gst_pad_link (osel_src2, sinkpad) != GST_PAD_LINK_OK) {
+ g_print ("linking output 2 failed\n");
+ return -1;
+ }
+ gst_object_unref (sinkpad);
+
+ if (!gst_element_link (convert, sink2)) {
+ g_print ("linking output 2 failed\n");
+ return -1;
+ }
+
+ /* add switch callback */
+ g_timeout_add (1000, switch_cb, osel);
+
+ /* change to playing */
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (bus, my_bus_callback, loop);
+ gst_object_unref (bus);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ /* now run */
+ g_main_loop_run (loop);
+
+ /* also clean up */
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_element_release_request_pad (osel, osel_src1);
+ gst_element_release_request_pad (osel, osel_src2);
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ return 0;
+}