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.
22 #include <gst/check/gstcheck.h>
24 #ifndef GST_DISABLE_PARSE
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, GstState target_state)
51 GstMessageType revent;
52 GstStateChangeReturn ret;
55 bus = gst_element_get_bus (pipe);
58 fail_if (gst_element_set_state (pipe, target_state) ==
59 GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to playing", descr);
60 ret = gst_element_get_state (pipe, NULL, NULL, 10 * GST_SECOND);
61 if (ret == GST_STATE_CHANGE_ASYNC) {
62 g_critical ("Pipeline '%s' failed to go to PAUSED fast enough", descr);
64 } else if ((ret != GST_STATE_CHANGE_SUCCESS)
65 && (ret != GST_STATE_CHANGE_NO_PREROLL)) {
66 g_critical ("Pipeline '%s' failed to go into PAUSED state (%s)", descr,
67 gst_element_state_change_return_get_name (ret));
72 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2);
74 /* always have to pop the message before getting back into poll */
76 revent = GST_MESSAGE_TYPE (message);
77 gst_message_unref (message);
79 revent = GST_MESSAGE_UNKNOWN;
82 if (revent == tevent) {
84 } else if (revent == GST_MESSAGE_UNKNOWN) {
85 g_critical ("Unexpected timeout in gst_bus_poll, looking for %d: %s",
88 } else if (revent & events) {
92 ("Unexpected message received of type %d, '%s', looking for %d: %s",
93 revent, gst_message_type_get_name (revent), tevent, descr);
97 fail_if (gst_element_set_state (pipe, GST_STATE_NULL) ==
98 GST_STATE_CHANGE_FAILURE, "Could not set pipeline %s to NULL", descr);
99 gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
100 gst_object_unref (pipe);
102 gst_bus_set_flushing (bus, TRUE);
103 gst_object_unref (bus);
106 GST_START_TEST (test_rtp_payloaders)
110 /* FIXME: going to playing would be nice, but thet leads to lot of failure */
111 GstState target_state = GST_STATE_PAUSED;
113 /* we use is-live here to avoid preroll */
114 #define PIPELINE_STRING(bufcount, bufsize, pl, dpl) "fakesrc is-live=true num-buffers=" bufcount " filltype=2 sizetype=2 sizemax=" bufsize " ! " pl " ! " dpl " ! fakesink"
115 #define DEFAULT_BUFCOUNT "5"
116 #define DEFAULT_BUFSIZE "16"
118 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpilbcpay",
120 run_pipeline (setup_pipeline (s), s,
121 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
122 GST_MESSAGE_UNKNOWN, target_state);
124 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpgsmpay",
126 run_pipeline (setup_pipeline (s), s,
127 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
128 GST_MESSAGE_UNKNOWN, target_state);
130 /* This one needs a bit different buffer size than others or it doesn't work. */
131 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, "52", "rtpamrpay", "rtpamrdepay");
132 run_pipeline (setup_pipeline (s), s,
133 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
134 GST_MESSAGE_UNKNOWN, target_state);
136 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtppcmapay",
138 run_pipeline (setup_pipeline (s), s,
139 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
140 GST_MESSAGE_UNKNOWN, target_state);
142 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtppcmupay",
144 run_pipeline (setup_pipeline (s), s,
145 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
146 GST_MESSAGE_UNKNOWN, target_state);
148 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpmpapay",
150 run_pipeline (setup_pipeline (s), s,
151 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
152 GST_MESSAGE_UNKNOWN, target_state);
154 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtph263ppay",
156 run_pipeline (setup_pipeline (s), s,
157 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
158 GST_MESSAGE_UNKNOWN, target_state);
160 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtph263pay",
162 run_pipeline (setup_pipeline (s), s,
163 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
164 GST_MESSAGE_UNKNOWN, target_state);
166 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtph264pay",
168 run_pipeline (setup_pipeline (s), s,
169 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
170 GST_MESSAGE_UNKNOWN, target_state);
172 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpL16pay",
174 run_pipeline (setup_pipeline (s), s,
175 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
176 GST_MESSAGE_UNKNOWN, target_state);
178 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpmp2tpay",
180 run_pipeline (setup_pipeline (s), s,
181 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
182 GST_MESSAGE_UNKNOWN, target_state);
184 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpmp4vpay",
186 run_pipeline (setup_pipeline (s), s,
187 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
188 GST_MESSAGE_UNKNOWN, target_state);
190 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpmp4gpay",
192 run_pipeline (setup_pipeline (s), s,
193 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
194 GST_MESSAGE_UNKNOWN, target_state);
196 /* Cannot be tested with fakesrc becouse speex payloader requires a valid header?! */
198 s = PIPELINE_STRING(DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpspeexpay", "rtpspeexdepay");
199 run_pipeline (setup_pipeline (s), s,
200 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
201 GST_MESSAGE_UNKNOWN, target_state);
204 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtptheorapay",
206 run_pipeline (setup_pipeline (s), s,
207 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
208 GST_MESSAGE_UNKNOWN, target_state);
210 s = PIPELINE_STRING (DEFAULT_BUFCOUNT, DEFAULT_BUFSIZE, "rtpvorbispay",
212 run_pipeline (setup_pipeline (s), s,
213 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
214 GST_MESSAGE_UNKNOWN, target_state);
216 /*s = FAKESRC " ! ! rtpac3depay ! " FAKESINK */
217 /*s = FAKESRC " ! ! asteriskh263 ! " FAKESINK; */
218 /*s = FAKESRC " ! ! rtpmpvdepay ! " FAKESINK; */
219 /*s = FAKESRC " ! ! rtpmp4adepay ! " FAKESINK; */
220 /*s = FAKESRC " ! ! rtpsv3vdepay ! " FAKESINK; */
224 GST_START_TEST (test_video_encoders_decoders)
227 GstState target_state = GST_STATE_PLAYING;
229 /* no is-live on the source because we actually want to preroll since
230 * run_pipeline only goes into PAUSED */
231 #define ENC_DEC_PIPELINE_STRING(bufcount, enc, dec) "videotestsrc num-buffers=" bufcount " ! " enc " ! " dec " ! fakesink"
232 #define DEFAULT_BUFCOUNT "5"
234 s = ENC_DEC_PIPELINE_STRING (DEFAULT_BUFCOUNT, "jpegenc", "jpegdec");
235 run_pipeline (setup_pipeline (s), s,
236 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
237 GST_MESSAGE_UNKNOWN, target_state);
239 s = ENC_DEC_PIPELINE_STRING (DEFAULT_BUFCOUNT, "pngenc", "pngdec");
240 run_pipeline (setup_pipeline (s), s,
241 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
242 GST_MESSAGE_UNKNOWN, target_state);
244 s = ENC_DEC_PIPELINE_STRING (DEFAULT_BUFCOUNT, "smokeenc", "smokedec");
245 run_pipeline (setup_pipeline (s), s,
246 GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
247 GST_MESSAGE_UNKNOWN, target_state);
251 #endif /* #ifndef GST_DISABLE_PARSE */
253 simple_launch_lines_suite (void)
255 Suite *s = suite_create ("Pipelines");
256 TCase *tc_chain = tcase_create ("linear");
258 /* time out after 60s, not the default 3 */
259 tcase_set_timeout (tc_chain, 60);
261 suite_add_tcase (s, tc_chain);
262 #ifndef GST_DISABLE_PARSE
263 tcase_add_test (tc_chain, test_rtp_payloaders);
264 tcase_add_test (tc_chain, test_video_encoders_decoders);
270 main (int argc, char **argv)
274 Suite *s = simple_launch_lines_suite ();
275 SRunner *sr = srunner_create (s);
277 gst_check_init (&argc, &argv);
279 srunner_run_all (sr, CK_NORMAL);
280 nf = srunner_ntests_failed (sr);