2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
4 * simple_launch_lines.c: Unit test for simple pipelines
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include <gst/check/gstcheck.h>
27 setup_pipeline (const gchar * pipe_descr)
31 pipeline = gst_parse_launch (pipe_descr, NULL);
32 g_return_val_if_fail (GST_IS_PIPELINE (pipeline), NULL);
38 * @pipe: the pipeline to run
39 * @desc: the description for use in messages
40 * @events: is a mask of expected events
41 * @tevent: is the expected terminal event.
43 * the poll call will time out after half a second.
46 run_pipeline (GstElement * pipe, const gchar * descr,
47 GstMessageType events, GstMessageType tevent)
51 GstMessageType revent;
52 GstStateChangeReturn ret;
55 bus = gst_element_get_bus (pipe);
58 ret = gst_element_set_state (pipe, GST_STATE_PLAYING);
59 ret = gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
60 if (ret != GST_STATE_CHANGE_SUCCESS) {
61 g_critical ("Couldn't set pipeline to PLAYING");
66 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2);
69 /* always have to pop the message before getting back into poll */
71 revent = GST_MESSAGE_TYPE (message);
72 gst_message_unref (message);
74 revent = GST_MESSAGE_UNKNOWN;
77 if (revent == tevent) {
79 } else if (revent == GST_MESSAGE_UNKNOWN) {
80 g_critical ("Unexpected timeout in gst_bus_poll, looking for %d: %s",
83 } else if (revent & events) {
86 g_critical ("Unexpected message received of type %d, looking for %d: %s",
87 revent, tevent, descr);
91 gst_element_set_state (pipe, GST_STATE_NULL);
92 gst_object_unref (pipe);
95 GST_START_TEST (test_element_negotiation)
99 /* see http://bugzilla.gnome.org/show_bug.cgi?id=315126 */
100 s = "fakesrc ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! audioconvert ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! fakesink";
101 run_pipeline (setup_pipeline (s), s,
102 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
103 GST_MESSAGE_UNKNOWN);
105 #ifdef HAVE_LIBVISUAL
106 s = "sinesrc ! tee name=t ! alsasink t. ! audioconvert ! libvisual_lv_scope ! ffmpegcolorspace ! xvimagesink";
107 run_pipeline (setup_pipeline (s), s,
108 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
109 GST_MESSAGE_UNKNOWN);
114 GST_START_TEST (test_basetransform_based)
116 /* Each of these tests is to check whether various basetransform based elements can
117 * select output caps when not allowed to do passthrough and going to a generic sink
118 * such as fakesink or filesink */
121 /* Check that videoscale can pick a height given only a width */
122 s = "videotestsrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! " "videoscale ! video/x-raw-yuv,width=640 ! fakesink";
123 run_pipeline (setup_pipeline (s), s,
124 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
125 GST_MESSAGE_UNKNOWN);
127 /* Test that ffmpegcolorspace can pick an output format that isn't passthrough without
128 * completely specified output caps */
129 s = "videotestsrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! " "ffmpegcolorspace ! video/x-raw-rgb ! fakesink";
130 run_pipeline (setup_pipeline (s), s,
131 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
132 GST_MESSAGE_UNKNOWN);
134 /* Check that audioresample can pick a samplerate to use from a
135 * range that doesn't include the input */
136 s = "sinesrc ! audio/x-raw-int,width=16,depth=16,rate=8000 ! audioresample ! "
137 "audio/x-raw-int,rate=[16000,48000] ! fakesink";
138 run_pipeline (setup_pipeline (s), s,
139 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
140 GST_MESSAGE_UNKNOWN);
142 /* Check that audioconvert can pick a depth to use, given a width */
143 s = "sinesrc ! audio/x-raw-int,width=16,depth=16 ! audioconvert ! "
144 "audio/x-raw-int,width=32 ! fakesink";
145 run_pipeline (setup_pipeline (s), s,
146 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
147 GST_MESSAGE_UNKNOWN);
150 simple_launch_lines_suite (void)
152 Suite *s = suite_create ("Pipelines");
153 TCase *tc_chain = tcase_create ("linear");
155 /* time out after 20s, not the default 3 */
156 tcase_set_timeout (tc_chain, 20);
158 suite_add_tcase (s, tc_chain);
159 // tcase_add_test (tc_chain, test_element_negotiation);
160 tcase_add_test (tc_chain, test_basetransform_based);
165 main (int argc, char **argv)
169 Suite *s = simple_launch_lines_suite ();
170 SRunner *sr = srunner_create (s);
172 gst_check_init (&argc, &argv);
174 srunner_run_all (sr, CK_NORMAL);
175 nf = srunner_ntests_failed (sr);