3 * unit test for audioresample, based on the audioresample unit test
5 * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
6 * Copyright (C) <2006> Tim-Philipp Müller <tim at centricular net>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
27 #include <gst/check/gstcheck.h>
29 #include <gst/audio/audio.h>
31 #include <gst/fft/gstfft.h>
32 #include <gst/fft/gstffts16.h>
33 #include <gst/fft/gstffts32.h>
34 #include <gst/fft/gstfftf32.h>
35 #include <gst/fft/gstfftf64.h>
37 /* For ease of programming we use globals to keep refs for our floating
38 * src and sink pads we create; otherwise we always have to do get_pad,
39 * get_peer, and then remove references in every test function */
40 static GstPad *mysrcpad, *mysinkpad;
42 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
43 #define FORMATS "{ F32LE, F64LE, S16LE, S32LE }"
45 #define FORMATS "{ F32BE, F64BE, S16BE, S32BE }"
48 #define RESAMPLE_CAPS \
50 "format = (string) "FORMATS", " \
51 "channels = (int) [ 1, MAX ], " \
52 "rate = (int) [ 1, MAX ], " \
53 "layout = (string) interleaved"
56 setup_audioresample (int channels, guint64 mask, int inrate, int outrate,
59 GstPadTemplate *sinktemplate;
60 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
63 GST_STATIC_CAPS (RESAMPLE_CAPS)
65 GstElement *audioresample;
67 GstStructure *structure;
69 GST_DEBUG ("setup_audioresample");
70 audioresample = gst_check_setup_element ("audioresample");
72 caps = gst_caps_from_string (RESAMPLE_CAPS);
73 structure = gst_caps_get_structure (caps, 0);
74 gst_structure_set (structure, "channels", G_TYPE_INT, channels,
75 "rate", G_TYPE_INT, inrate, "format", G_TYPE_STRING, format,
76 "channel-mask", GST_TYPE_BITMASK, mask, NULL);
77 fail_unless (gst_caps_is_fixed (caps));
79 fail_unless (gst_element_set_state (audioresample,
80 GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
81 "could not set to paused");
83 mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate);
84 gst_pad_set_active (mysrcpad, TRUE);
85 gst_check_setup_events (mysrcpad, audioresample, caps, GST_FORMAT_TIME);
86 gst_caps_unref (caps);
88 caps = gst_caps_from_string (RESAMPLE_CAPS);
89 structure = gst_caps_get_structure (caps, 0);
90 gst_structure_set (structure, "channels", G_TYPE_INT, channels,
91 "rate", G_TYPE_INT, outrate, "format", G_TYPE_STRING, format, NULL);
92 fail_unless (gst_caps_is_fixed (caps));
94 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
97 gst_check_setup_sink_pad_from_template (audioresample, sinktemplate);
98 gst_pad_set_active (mysinkpad, TRUE);
99 /* this installs a getcaps func that will always return the caps we set
101 gst_pad_use_fixed_caps (mysinkpad);
103 gst_caps_unref (caps);
104 gst_object_unref (sinktemplate);
106 return audioresample;
110 cleanup_audioresample (GstElement * audioresample)
112 GST_DEBUG ("cleanup_audioresample");
114 fail_unless (gst_element_set_state (audioresample,
115 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
117 gst_pad_set_active (mysrcpad, FALSE);
118 gst_pad_set_active (mysinkpad, FALSE);
119 gst_check_teardown_src_pad (audioresample);
120 gst_check_teardown_sink_pad (audioresample);
121 gst_check_teardown_element (audioresample);
122 gst_check_drop_buffers ();
126 fail_unless_perfect_stream (void)
128 guint64 timestamp = 0L, duration = 0L;
129 guint64 offset = 0L, offset_end = 0L;
134 for (l = buffers; l; l = l->next) {
135 buffer = GST_BUFFER (l->data);
136 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
137 GST_DEBUG ("buffer timestamp %" G_GUINT64_FORMAT ", duration %"
138 G_GUINT64_FORMAT " offset %" G_GUINT64_FORMAT " offset_end %"
140 GST_BUFFER_TIMESTAMP (buffer),
141 GST_BUFFER_DURATION (buffer),
142 GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));
144 fail_unless_equals_uint64 (timestamp, GST_BUFFER_TIMESTAMP (buffer));
145 fail_unless_equals_uint64 (offset, GST_BUFFER_OFFSET (buffer));
146 duration = GST_BUFFER_DURATION (buffer);
147 offset_end = GST_BUFFER_OFFSET_END (buffer);
149 timestamp += duration;
151 gst_buffer_unref (buffer);
153 g_list_free (buffers);
157 /* this tests that the output is a perfect stream if the input is */
159 test_perfect_stream_instance (int inrate, int outrate, int samples,
162 GstElement *audioresample;
163 GstBuffer *inbuffer, *outbuffer;
171 setup_audioresample (2, 0x3, inrate, outrate, GST_AUDIO_NE (S16));
172 caps = gst_pad_get_current_caps (mysrcpad);
173 fail_unless (gst_caps_is_fixed (caps));
175 fail_unless (gst_element_set_state (audioresample,
176 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
177 "could not set to playing");
179 for (j = 1; j <= numbuffers; ++j) {
181 inbuffer = gst_buffer_new_and_alloc (samples * 4);
182 GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (samples, inrate);
183 GST_BUFFER_TIMESTAMP (inbuffer) = GST_BUFFER_DURATION (inbuffer) * (j - 1);
184 GST_BUFFER_OFFSET (inbuffer) = offset;
186 GST_BUFFER_OFFSET_END (inbuffer) = offset;
188 gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
189 p = (gint16 *) map.data;
191 /* create a 16 bit signed ramp */
192 for (i = 0; i < samples; ++i) {
193 *p = -32767 + i * (65535 / samples);
195 *p = -32767 + i * (65535 / samples);
198 gst_buffer_unmap (inbuffer, &map);
200 /* pushing gives away my reference ... */
201 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
202 /* ... but it ends up being collected on the global buffer list */
203 fail_unless_equals_int (g_list_length (buffers), j);
206 /* FIXME: we should make audioresample handle eos by flushing out the last
207 * samples, which will give us one more, small, buffer */
208 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
209 ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
211 fail_unless_perfect_stream ();
214 gst_caps_unref (caps);
215 cleanup_audioresample (audioresample);
219 /* make sure that outgoing buffers are contiguous in timestamp/duration and
222 GST_START_TEST (test_perfect_stream)
224 /* integral scalings */
225 test_perfect_stream_instance (48000, 24000, 500, 20);
226 test_perfect_stream_instance (48000, 12000, 500, 20);
227 test_perfect_stream_instance (12000, 24000, 500, 20);
228 test_perfect_stream_instance (12000, 48000, 500, 20);
230 /* non-integral scalings */
231 test_perfect_stream_instance (44100, 8000, 500, 20);
232 test_perfect_stream_instance (8000, 44100, 500, 20);
235 test_perfect_stream_instance (12345, 54321, 500, 20);
236 test_perfect_stream_instance (101, 99, 500, 20);
241 /* this tests that the output is a correct discontinuous stream
242 * if the input is; ie input drops in time come out the same way */
244 test_discont_stream_instance (int inrate, int outrate, int samples,
247 GstElement *audioresample;
248 GstBuffer *inbuffer, *outbuffer;
256 GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
257 inrate, outrate, samples, numbuffers);
260 setup_audioresample (2, 3, inrate, outrate, GST_AUDIO_NE (S16));
261 caps = gst_pad_get_current_caps (mysrcpad);
262 fail_unless (gst_caps_is_fixed (caps));
264 fail_unless (gst_element_set_state (audioresample,
265 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
266 "could not set to playing");
268 for (j = 1; j <= numbuffers; ++j) {
270 inbuffer = gst_buffer_new_and_alloc (samples * 4);
271 GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
272 /* "drop" half the buffers */
273 ints = GST_BUFFER_DURATION (inbuffer) * 2 * (j - 1);
274 GST_BUFFER_TIMESTAMP (inbuffer) = ints;
275 GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples;
276 GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples;
278 gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
279 p = (gint16 *) map.data;
280 /* create a 16 bit signed ramp */
281 for (i = 0; i < samples; ++i) {
282 *p = -32767 + i * (65535 / samples);
284 *p = -32767 + i * (65535 / samples);
287 gst_buffer_unmap (inbuffer, &map);
289 GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
290 G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
291 G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (inbuffer),
292 GST_BUFFER_DURATION (inbuffer), GST_BUFFER_IS_DISCONT (inbuffer),
293 GST_BUFFER_OFFSET (inbuffer), GST_BUFFER_OFFSET_END (inbuffer));
294 /* pushing gives away my reference ... */
295 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
297 /* check if the timestamp of the pushed buffer matches the incoming one */
298 outbuffer = g_list_nth_data (buffers, g_list_length (buffers) - 1);
299 fail_if (outbuffer == NULL);
300 fail_unless_equals_uint64 (ints, GST_BUFFER_TIMESTAMP (outbuffer));
301 GST_DEBUG ("Got Buffer time:%" G_GUINT64_FORMAT " duration:%"
302 G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
303 G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (outbuffer),
304 GST_BUFFER_DURATION (outbuffer), GST_BUFFER_IS_DISCONT (outbuffer),
305 GST_BUFFER_OFFSET (outbuffer), GST_BUFFER_OFFSET_END (outbuffer));
307 fail_unless (GST_BUFFER_IS_DISCONT (outbuffer),
308 "expected discont for buffer #%d", j);
313 gst_caps_unref (caps);
314 cleanup_audioresample (audioresample);
317 GST_START_TEST (test_discont_stream)
319 /* integral scalings */
320 test_discont_stream_instance (48000, 24000, 5000, 20);
321 test_discont_stream_instance (48000, 12000, 5000, 20);
322 test_discont_stream_instance (12000, 24000, 5000, 20);
323 test_discont_stream_instance (12000, 48000, 5000, 20);
325 /* non-integral scalings */
326 test_discont_stream_instance (44100, 8000, 5000, 20);
327 test_discont_stream_instance (8000, 44100, 5000, 20);
330 test_discont_stream_instance (12345, 54321, 5000, 20);
331 test_discont_stream_instance (101, 99, 5000, 20);
338 GST_START_TEST (test_reuse)
340 GstElement *audioresample;
346 audioresample = setup_audioresample (1, 0, 9343, 48000, GST_AUDIO_NE (S16));
347 caps = gst_pad_get_current_caps (mysrcpad);
348 fail_unless (gst_caps_is_fixed (caps));
350 fail_unless (gst_element_set_state (audioresample,
351 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
352 "could not set to playing");
354 gst_segment_init (&segment, GST_FORMAT_TIME);
355 newseg = gst_event_new_segment (&segment);
356 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
358 inbuffer = gst_buffer_new_and_alloc (9343 * 4);
359 gst_buffer_memset (inbuffer, 0, 0, 9343 * 4);
360 GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
361 GST_BUFFER_TIMESTAMP (inbuffer) = 0;
362 GST_BUFFER_OFFSET (inbuffer) = 0;
364 /* pushing gives away my reference ... */
365 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
367 /* ... but it ends up being collected on the global buffer list */
368 fail_unless_equals_int (g_list_length (buffers), 1);
370 /* now reset and try again ... */
371 fail_unless (gst_element_set_state (audioresample,
372 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
374 fail_unless (gst_element_set_state (audioresample,
375 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
376 "could not set to playing");
378 newseg = gst_event_new_segment (&segment);
379 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
381 inbuffer = gst_buffer_new_and_alloc (9343 * 4);
382 gst_buffer_memset (inbuffer, 0, 0, 9343 * 4);
383 GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
384 GST_BUFFER_TIMESTAMP (inbuffer) = 0;
385 GST_BUFFER_OFFSET (inbuffer) = 0;
387 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
389 /* ... it also ends up being collected on the global buffer list. If we
390 * now have more than 2 buffers, then audioresample probably didn't clean
391 * up its internal buffer properly and tried to push the remaining samples
392 * when it got the second NEWSEGMENT event */
393 fail_unless_equals_int (g_list_length (buffers), 2);
395 cleanup_audioresample (audioresample);
396 gst_caps_unref (caps);
401 GST_START_TEST (test_shutdown)
403 GstElement *pipeline, *src, *cf1, *ar, *cf2, *sink;
407 /* create pipeline, force audioresample to actually resample */
408 pipeline = gst_pipeline_new (NULL);
410 src = gst_check_setup_element ("audiotestsrc");
411 cf1 = gst_check_setup_element ("capsfilter");
412 ar = gst_check_setup_element ("audioresample");
413 cf2 = gst_check_setup_element ("capsfilter");
414 g_object_set (cf2, "name", "capsfilter2", NULL);
415 sink = gst_check_setup_element ("fakesink");
417 caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 11025, NULL);
418 g_object_set (cf1, "caps", caps, NULL);
419 gst_caps_unref (caps);
421 caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 48000, NULL);
422 g_object_set (cf2, "caps", caps, NULL);
423 gst_caps_unref (caps);
425 /* don't want to sync against the clock, the more throughput the better */
426 g_object_set (src, "is-live", FALSE, NULL);
427 g_object_set (sink, "sync", FALSE, NULL);
429 gst_bin_add_many (GST_BIN (pipeline), src, cf1, ar, cf2, sink, NULL);
430 fail_if (!gst_element_link_many (src, cf1, ar, cf2, sink, NULL));
432 /* now, wait until pipeline is running and then shut it down again; repeat */
433 for (i = 0; i < 20; ++i) {
434 gst_element_set_state (pipeline, GST_STATE_PAUSED);
435 gst_element_get_state (pipeline, NULL, NULL, -1);
436 gst_element_set_state (pipeline, GST_STATE_PLAYING);
438 gst_element_set_state (pipeline, GST_STATE_NULL);
441 gst_object_unref (pipeline);
447 live_switch_push (gint pts, gint rate, GstCaps * caps)
452 desired = gst_caps_copy (caps);
453 gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
454 gst_pad_set_caps (mysrcpad, desired);
456 inbuffer = gst_buffer_new_and_alloc (rate * 4 * 2);
457 gst_buffer_memset (inbuffer, 0, 0, rate * 4 * 2);
459 GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
460 GST_BUFFER_TIMESTAMP (inbuffer) = pts * GST_SECOND;
461 GST_BUFFER_OFFSET (inbuffer) = 0;
462 GST_BUFFER_OFFSET_END (inbuffer) = rate - 1;
464 /* pushing gives away my reference ... */
465 fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
467 /* ... but it ends up being collected on the global buffer list */
469 gst_caps_unref (desired);
472 GST_START_TEST (test_live_switch)
474 GstElement *audioresample;
482 setup_audioresample (4, 0xf, 48000, 48000, GST_AUDIO_NE (S16));
484 caps = gst_pad_get_current_caps (mysrcpad);
485 fail_unless (gst_caps_is_fixed (caps));
487 fail_unless (gst_element_set_state (audioresample,
488 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
489 "could not set to playing");
491 gst_segment_init (&segment, GST_FORMAT_TIME);
492 newseg = gst_event_new_segment (&segment);
493 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
495 /* downstream can accept the requested rate */
496 live_switch_push (0, 48000, caps);
498 /* buffer is directly passed through */
499 fail_unless_equals_int (g_list_length (buffers), 1);
501 /* Downstream can never accept this rate */
502 live_switch_push (1, 40000, caps);
504 /* one additional buffer is provided with the new sample rate */
505 fail_unless_equals_int (g_list_length (buffers), 2);
507 /* Downstream can never accept this rate */
508 live_switch_push (2, 50000, caps);
510 /* two additional buffers are provided. One is the drained remainder of
511 * the previous sample rate, the second is the buffer with the new sample
513 fail_unless_equals_int (g_list_length (buffers), 4);
515 /* Send EOS to drain the remaining samples */
516 fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
517 fail_unless_equals_int (g_list_length (buffers), 5);
519 /* Now test that each buffer has the expected samples. We simply check this
520 * by checking whether the timestamps, durations and sizes are matching */
521 for (l = buffers, i = 0; l; l = l->next, i++) {
522 GstBuffer *buffer = GST_BUFFER (l->data);
526 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
527 fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer),
529 fail_unless_equals_int (gst_buffer_get_size (buffer), 48000 * 4 * 2);
532 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 1 * GST_SECOND);
533 fail_unless_equals_int (gst_buffer_get_size (buffer), 47961 * 4 * 2);
536 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
537 GST_BUFFER_DURATION (buffer), 2 * GST_SECOND,
538 GST_SECOND / 48000 + 1));
539 fail_unless_equals_int (gst_buffer_get_size (buffer), 38 * 4 * 2);
542 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 2 * GST_SECOND);
543 fail_unless_equals_int (gst_buffer_get_size (buffer), 47969 * 4 * 2);
546 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
547 GST_BUFFER_DURATION (buffer), 3 * GST_SECOND,
548 GST_SECOND / 48000 + 1));
549 fail_unless_equals_int (gst_buffer_get_size (buffer), 30 * 4 * 2);
552 g_assert_not_reached ();
556 gst_buffer_unref (buffer);
559 g_list_free (buffers);
562 cleanup_audioresample (audioresample);
563 gst_caps_unref (caps);
568 static gint current_rate = 0;
571 live_switch_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
573 switch (GST_QUERY_TYPE (query)) {
574 case GST_QUERY_ACCEPT_CAPS:{
575 GstCaps *acceptable_caps;
578 acceptable_caps = gst_pad_get_current_caps (mysrcpad);
579 acceptable_caps = gst_caps_make_writable (acceptable_caps);
580 gst_caps_set_simple (acceptable_caps, "rate", G_TYPE_INT, current_rate,
583 gst_query_parse_accept_caps (query, &caps);
585 gst_query_set_accept_caps_result (query, gst_caps_can_intersect (caps,
588 gst_caps_unref (acceptable_caps);
592 case GST_QUERY_CAPS:{
593 GstCaps *acceptable_caps;
597 acceptable_caps = gst_pad_get_current_caps (mysrcpad);
598 acceptable_caps = gst_caps_make_writable (acceptable_caps);
599 gst_caps_set_simple (acceptable_caps, "rate", G_TYPE_INT, current_rate,
602 gst_query_parse_caps (query, &filter);
606 gst_caps_intersect_full (filter, acceptable_caps,
607 GST_CAPS_INTERSECT_FIRST);
609 caps = gst_caps_ref (acceptable_caps);
611 gst_query_set_caps_result (query, caps);
613 gst_caps_unref (caps);
614 gst_caps_unref (acceptable_caps);
619 return gst_pad_query_default (pad, parent, query);
624 live_switch_push_downstream (gint pts, gint rate)
629 gst_pad_push_event (mysinkpad, gst_event_new_reconfigure ());
631 inbuffer = gst_buffer_new_and_alloc (48000 * 4 * 2);
632 gst_buffer_memset (inbuffer, 0, 0, 48000 * 4 * 2);
634 GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
635 GST_BUFFER_TIMESTAMP (inbuffer) = pts * GST_SECOND;
636 GST_BUFFER_OFFSET (inbuffer) = 0;
637 GST_BUFFER_OFFSET_END (inbuffer) = 47999;
639 /* pushing gives away my reference ... */
640 fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
642 /* ... but it ends up being collected on the global buffer list */
645 GST_START_TEST (test_live_switch_downstream)
647 GstElement *audioresample;
655 setup_audioresample (4, 0xf, 48000, 48000, GST_AUDIO_NE (S16));
657 gst_pad_set_query_function (mysinkpad, live_switch_sink_query);
659 caps = gst_pad_get_current_caps (mysrcpad);
660 fail_unless (gst_caps_is_fixed (caps));
662 fail_unless (gst_element_set_state (audioresample,
663 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
664 "could not set to playing");
666 gst_segment_init (&segment, GST_FORMAT_TIME);
667 newseg = gst_event_new_segment (&segment);
668 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
670 /* buffer is directly passed through */
671 live_switch_push_downstream (0, 48000);
672 fail_unless_equals_int (g_list_length (buffers), 1);
674 /* Reconfigure downstream to 40000 Hz */
675 live_switch_push_downstream (1, 40000);
677 /* one additional buffer is provided with the new sample rate */
678 fail_unless_equals_int (g_list_length (buffers), 2);
680 /* Reconfigure downstream to 50000 Hz */
681 live_switch_push_downstream (2, 50000);
683 /* two additional buffers are provided. One is the drained remainder of
684 * the previous sample rate, the second is the buffer with the new sample
686 fail_unless_equals_int (g_list_length (buffers), 4);
688 /* Send EOS to drain the remaining samples */
689 fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
690 fail_unless_equals_int (g_list_length (buffers), 5);
692 /* Now test that each buffer has the expected samples. We simply check this
693 * by checking whether the timestamps, durations and sizes are matching */
694 for (l = buffers, i = 0; l; l = l->next, i++) {
695 GstBuffer *buffer = GST_BUFFER (l->data);
699 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
700 fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer),
702 fail_unless_equals_int (gst_buffer_get_size (buffer), 48000 * 4 * 2);
705 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 1 * GST_SECOND);
706 fail_unless_equals_int (gst_buffer_get_size (buffer), 39966 * 4 * 2);
709 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
710 GST_BUFFER_DURATION (buffer), 2 * GST_SECOND,
711 GST_SECOND / 40000 + 1));
712 fail_unless_equals_int (gst_buffer_get_size (buffer), 34 * 4 * 2);
715 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 2 * GST_SECOND);
716 fail_unless_equals_int (gst_buffer_get_size (buffer), 49966 * 4 * 2);
719 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
720 GST_BUFFER_DURATION (buffer), 3 * GST_SECOND,
721 GST_SECOND / 50000 + 1));
722 fail_unless_equals_int (gst_buffer_get_size (buffer), 33 * 4 * 2);
725 g_assert_not_reached ();
729 gst_buffer_unref (buffer);
732 g_list_free (buffers);
735 cleanup_audioresample (audioresample);
736 gst_caps_unref (caps);
741 #ifndef GST_DISABLE_PARSE
743 static GMainLoop *loop;
744 static gint messages = 0;
747 element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
751 s = gst_structure_to_string (gst_message_get_structure (message));
752 GST_DEBUG ("Received message: %s", s);
759 eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
761 GST_DEBUG ("Received eos");
762 g_main_loop_quit (loop);
766 test_pipeline (const gchar * format, gint inrate, gint outrate, gint quality)
768 GstElement *pipeline;
770 GError *error = NULL;
775 ("audiotestsrc num-buffers=10 ! audioconvert ! audio/x-raw,format=%s,rate=%d,channels=2 ! audioresample quality=%d ! audio/x-raw,format=%s,rate=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
776 format, inrate, quality, format, outrate);
778 pipeline = gst_parse_launch (pipe_str, &error);
779 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
780 error ? error->message : "(invalid error)");
783 bus = gst_element_get_bus (pipeline);
784 fail_if (bus == NULL);
785 gst_bus_add_signal_watch (bus);
786 g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
788 g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
790 gst_element_set_state (pipeline, GST_STATE_PLAYING);
792 /* run until we receive EOS */
793 loop = g_main_loop_new (NULL, FALSE);
795 g_main_loop_run (loop);
797 g_main_loop_unref (loop);
800 gst_element_set_state (pipeline, GST_STATE_NULL);
802 gst_bus_remove_signal_watch (bus);
803 gst_object_unref (bus);
805 fail_if (messages > 0, "Received imperfect timestamp messages");
806 gst_object_unref (pipeline);
809 GST_START_TEST (test_pipelines)
813 /* Test qualities 0, 5 and 10 */
814 for (quality = 0; quality < 11; quality += 5) {
815 GST_DEBUG ("Checking with quality %d", quality);
817 test_pipeline ("S8", 44100, 48000, quality);
818 test_pipeline ("S8", 48000, 44100, quality);
820 test_pipeline (GST_AUDIO_NE (S16), 44100, 48000, quality);
821 test_pipeline (GST_AUDIO_NE (S16), 48000, 44100, quality);
823 test_pipeline (GST_AUDIO_NE (S24), 44100, 48000, quality);
824 test_pipeline (GST_AUDIO_NE (S24), 48000, 44100, quality);
826 test_pipeline (GST_AUDIO_NE (S32), 44100, 48000, quality);
827 test_pipeline (GST_AUDIO_NE (S32), 48000, 44100, quality);
829 test_pipeline (GST_AUDIO_NE (F32), 44100, 48000, quality);
830 test_pipeline (GST_AUDIO_NE (F32), 48000, 44100, quality);
832 test_pipeline (GST_AUDIO_NE (F64), 44100, 48000, quality);
833 test_pipeline (GST_AUDIO_NE (F64), 48000, 44100, quality);
839 GST_START_TEST (test_preference_passthrough)
841 GstStateChangeReturn ret;
842 GstElement *pipeline, *src;
848 GError *error = NULL;
851 pipeline = gst_parse_launch ("audiotestsrc num-buffers=1 name=src ! "
852 "audioresample ! audio/x-raw,format=" GST_AUDIO_NE (S16) ",channels=1,"
853 "rate=8000 ! fakesink can-activate-pull=false", &error);
854 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
855 error ? error->message : "(invalid error)");
857 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
858 fail_unless_equals_int (ret, GST_STATE_CHANGE_ASYNC);
860 /* run until we receive EOS */
861 bus = gst_element_get_bus (pipeline);
862 fail_if (bus == NULL);
863 msg = gst_bus_timed_pop_filtered (bus, -1, GST_MESSAGE_EOS);
864 gst_message_unref (msg);
865 gst_object_unref (bus);
867 src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
868 fail_unless (src != NULL);
869 pad = gst_element_get_static_pad (src, "src");
870 fail_unless (pad != NULL);
871 caps = gst_pad_get_current_caps (pad);
872 GST_LOG ("current audiotestsrc caps: %" GST_PTR_FORMAT, caps);
873 fail_unless (caps != NULL);
874 s = gst_caps_get_structure (caps, 0);
875 fail_unless (gst_structure_get_int (s, "rate", &rate));
876 /* there's no need to resample, audiotestsrc supports any rate, so make
877 * sure audioresample provided upstream with the right caps to negotiate
879 fail_unless_equals_int (rate, 8000);
880 gst_caps_unref (caps);
881 gst_object_unref (pad);
882 gst_object_unref (src);
884 gst_element_set_state (pipeline, GST_STATE_NULL);
885 gst_object_unref (pipeline);
893 _message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
895 GMainLoop *loop = user_data;
897 switch (GST_MESSAGE_TYPE (message)) {
898 case GST_MESSAGE_ERROR:
899 case GST_MESSAGE_WARNING:
900 g_assert_not_reached ();
902 case GST_MESSAGE_EOS:
903 g_main_loop_quit (loop);
915 GstClockTime next_out_ts;
916 guint64 next_out_off;
918 guint64 in_buffer_count, out_buffer_count;
922 fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
925 TimestampDriftCtx *ctx = user_data;
927 ctx->out_buffer_count++;
928 if (ctx->latency == GST_CLOCK_TIME_NONE) {
929 ctx->latency = 1000 - gst_buffer_get_size (buffer) / 8;
932 /* Check if we have a perfectly timestamped stream */
933 if (ctx->next_out_ts != GST_CLOCK_TIME_NONE)
934 fail_unless (ctx->next_out_ts == GST_BUFFER_TIMESTAMP (buffer),
935 "expected timestamp %" GST_TIME_FORMAT " got timestamp %"
936 GST_TIME_FORMAT, GST_TIME_ARGS (ctx->next_out_ts),
937 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
939 /* Check if we have a perfectly offsetted stream */
940 fail_unless (GST_BUFFER_OFFSET_END (buffer) ==
941 GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
942 "expected offset end %" G_GUINT64_FORMAT " got offset end %"
944 GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
945 GST_BUFFER_OFFSET_END (buffer));
946 if (ctx->next_out_off != GST_BUFFER_OFFSET_NONE) {
947 fail_unless (GST_BUFFER_OFFSET (buffer) == ctx->next_out_off,
948 "expected offset %" G_GUINT64_FORMAT " got offset %" G_GUINT64_FORMAT,
949 ctx->next_out_off, GST_BUFFER_OFFSET (buffer));
952 if (ctx->in_buffer_count != ctx->out_buffer_count) {
953 GST_INFO ("timestamp %" GST_TIME_FORMAT,
954 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
957 if (ctx->in_ts != GST_CLOCK_TIME_NONE && ctx->in_buffer_count > 1
958 && ctx->in_buffer_count == ctx->out_buffer_count) {
959 fail_unless (GST_BUFFER_TIMESTAMP (buffer) ==
960 ctx->in_ts - gst_util_uint64_scale_round (ctx->latency, GST_SECOND,
962 "expected output timestamp %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT
963 ") got output timestamp %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT ")",
964 GST_TIME_ARGS (ctx->in_ts - gst_util_uint64_scale_round (ctx->latency,
966 ctx->in_ts - gst_util_uint64_scale_round (ctx->latency, GST_SECOND,
967 4096), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
968 GST_BUFFER_TIMESTAMP (buffer));
972 GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer);
973 ctx->next_out_off = GST_BUFFER_OFFSET_END (buffer);
977 identity_handoff_cb (GstElement * object, GstBuffer * buffer,
980 TimestampDriftCtx *ctx = user_data;
982 ctx->in_ts = GST_BUFFER_TIMESTAMP (buffer);
983 ctx->in_buffer_count++;
986 GST_START_TEST (test_timestamp_drift)
988 TimestampDriftCtx ctx =
989 { GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE,
990 GST_BUFFER_OFFSET_NONE, 0, 0
992 GstElement *pipeline;
993 GstElement *audiotestsrc, *capsfilter1, *identity, *audioresample,
994 *capsfilter2, *fakesink;
999 pipeline = gst_pipeline_new ("pipeline");
1000 fail_unless (pipeline != NULL);
1002 audiotestsrc = gst_element_factory_make ("audiotestsrc", "src");
1003 fail_unless (audiotestsrc != NULL);
1004 g_object_set (G_OBJECT (audiotestsrc), "num-buffers", 10000,
1005 "samplesperbuffer", 4000, NULL);
1007 capsfilter1 = gst_element_factory_make ("capsfilter", "capsfilter1");
1008 fail_unless (capsfilter1 != NULL);
1009 caps = gst_caps_from_string ("audio/x-raw, format=" GST_AUDIO_NE (F64)
1010 ", channels=1, rate=16384");
1011 g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
1012 gst_caps_unref (caps);
1014 identity = gst_element_factory_make ("identity", "identity");
1015 fail_unless (identity != NULL);
1016 g_object_set (G_OBJECT (identity), "sync", FALSE, "signal-handoffs", TRUE,
1018 g_signal_connect (identity, "handoff", (GCallback) identity_handoff_cb, &ctx);
1020 audioresample = gst_element_factory_make ("audioresample", "resample");
1021 fail_unless (audioresample != NULL);
1022 capsfilter2 = gst_element_factory_make ("capsfilter", "capsfilter2");
1023 fail_unless (capsfilter2 != NULL);
1024 caps = gst_caps_from_string ("audio/x-raw, format=" GST_AUDIO_NE (F64)
1025 ", channels=1, rate=4096");
1026 g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
1027 gst_caps_unref (caps);
1029 fakesink = gst_element_factory_make ("fakesink", "sink");
1030 fail_unless (fakesink != NULL);
1031 g_object_set (G_OBJECT (fakesink), "sync", FALSE, "async", FALSE,
1032 "signal-handoffs", TRUE, NULL);
1033 g_signal_connect (fakesink, "handoff", (GCallback) fakesink_handoff_cb, &ctx);
1036 gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, capsfilter1, identity,
1037 audioresample, capsfilter2, fakesink, NULL);
1038 fail_unless (gst_element_link_many (audiotestsrc, capsfilter1, identity,
1039 audioresample, capsfilter2, fakesink, NULL));
1041 loop = g_main_loop_new (NULL, FALSE);
1043 bus = gst_element_get_bus (pipeline);
1044 gst_bus_add_signal_watch (bus);
1045 g_signal_connect (bus, "message", (GCallback) _message_cb, loop);
1047 fail_unless (gst_element_set_state (pipeline,
1048 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
1049 g_main_loop_run (loop);
1051 fail_unless (gst_element_set_state (pipeline,
1052 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
1053 g_main_loop_unref (loop);
1054 gst_bus_remove_signal_watch (bus);
1055 gst_object_unref (bus);
1057 gst_object_unref (pipeline);
1061 #define FFT_HELPERS(type,ffttag,ffttag2,scale); \
1062 static gdouble magnitude##ffttag (const GstFFT##ffttag##Complex *c) \
1064 gdouble mag = (gdouble) c->r * (gdouble) c->r; \
1065 mag += (gdouble) c->i * (gdouble) c->i; \
1066 mag /= scale * scale; \
1067 mag = 10.0 * log10 (mag); \
1070 static gdouble find_main_frequency_spot_##ffttag (const GstFFT##ffttag##Complex *v, \
1074 gdouble maxmag = -9999; \
1076 for (i=0; i<elements; ++i) { \
1077 gdouble mag = magnitude##ffttag (v+i); \
1078 if (mag > maxmag) { \
1083 return maxidx / (gdouble) elements; \
1085 static gboolean is_zero_except_##ffttag (const GstFFT##ffttag##Complex *v, int elements, \
1089 for (i=0; i<elements; ++i) { \
1090 gdouble pos = i / (gdouble) elements; \
1091 gdouble mag = magnitude##ffttag (v+i); \
1092 if (fabs (pos - spot) > 0.01) { \
1093 if (mag > -55.0) { \
1100 static void compare_ffts_##ffttag (GstBuffer *inbuffer, GstBuffer *outbuffer) \
1102 GstMapInfo inmap, outmap; \
1103 int insamples, outsamples; \
1104 gdouble inspot, outspot; \
1105 GstFFT##ffttag *inctx, *outctx; \
1106 GstFFT##ffttag##Complex *in, *out; \
1108 gst_buffer_map (inbuffer, &inmap, GST_MAP_READ); \
1109 gst_buffer_map (outbuffer, &outmap, GST_MAP_READWRITE); \
1111 insamples = inmap.size / sizeof(type) & ~1; \
1112 outsamples = outmap.size / sizeof(type) & ~1; \
1113 inctx = gst_fft_##ffttag2##_new (insamples, FALSE); \
1114 outctx = gst_fft_##ffttag2##_new (outsamples, FALSE); \
1115 in = g_new (GstFFT##ffttag##Complex, insamples / 2 + 1); \
1116 out = g_new (GstFFT##ffttag##Complex, outsamples / 2 + 1); \
1118 gst_fft_##ffttag2##_window (inctx, (type*)inmap.data, \
1119 GST_FFT_WINDOW_HAMMING); \
1120 gst_fft_##ffttag2##_fft (inctx, (type*)inmap.data, in); \
1121 gst_fft_##ffttag2##_window (outctx, (type*)outmap.data, \
1122 GST_FFT_WINDOW_HAMMING); \
1123 gst_fft_##ffttag2##_fft (outctx, (type*)outmap.data, out); \
1125 inspot = find_main_frequency_spot_##ffttag (in, insamples / 2 + 1); \
1126 outspot = find_main_frequency_spot_##ffttag (out, outsamples / 2 + 1); \
1127 GST_LOG ("Spots are %.3f and %.3f", inspot, outspot); \
1128 fail_unless (fabs (outspot - inspot) < 0.05); \
1129 fail_unless (is_zero_except_##ffttag (in, insamples / 2 + 1, inspot)); \
1130 fail_unless (is_zero_except_##ffttag (out, outsamples / 2 + 1, outspot)); \
1132 gst_buffer_unmap (inbuffer, &inmap); \
1133 gst_buffer_unmap (outbuffer, &outmap); \
1135 gst_fft_##ffttag2##_free (inctx); \
1136 gst_fft_##ffttag2##_free (outctx); \
1140 FFT_HELPERS (float, F32, f32, 2048.0f);
1141 FFT_HELPERS (double, F64, f64, 2048.0);
1142 FFT_HELPERS (gint16, S16, s16, 32767.0);
1143 FFT_HELPERS (gint32, S32, s32, 2147483647.0);
1145 #define FILL_BUFFER(type, desc, value); \
1146 static void init_##type##_##desc (GstBuffer *buffer) \
1151 gst_buffer_map (buffer, &map, GST_MAP_WRITE); \
1152 ptr = (type *)map.data; \
1153 nsamples = map.size / sizeof (type); \
1154 for (i = 0; i < nsamples; ++i) { \
1157 gst_buffer_unmap (buffer, &map); \
1160 FILL_BUFFER (float, silence, 0.0f);
1161 FILL_BUFFER (double, silence, 0.0);
1162 FILL_BUFFER (gint16, silence, 0);
1163 FILL_BUFFER (gint32, silence, 0);
1164 FILL_BUFFER (float, sine, sinf (i * 0.01f));
1165 FILL_BUFFER (float, sine2, sinf (i * 1.8f));
1166 FILL_BUFFER (double, sine, sin (i * 0.01));
1167 FILL_BUFFER (double, sine2, sin (i * 1.8));
1168 FILL_BUFFER (gint16, sine, (gint16) (32767 * sinf (i * 0.01f)));
1169 FILL_BUFFER (gint16, sine2, (gint16) (32767 * sinf (i * 1.8f)));
1170 FILL_BUFFER (gint32, sine, (gint32) (2147483647.0 * sin (i * 0.01)));
1171 FILL_BUFFER (gint32, sine2, (gint32) (2147483647.0 * sin (i * 1.8)));
1174 run_fft_pipeline (int inrate, int outrate, int quality, int width,
1175 const gchar * format, void (*init) (GstBuffer *),
1176 void (*compare_ffts) (GstBuffer *, GstBuffer *))
1178 GstElement *audioresample;
1179 GstBuffer *inbuffer, *outbuffer;
1180 const int nsamples = 2048;
1182 audioresample = setup_audioresample (1, 0, inrate, outrate, format);
1183 fail_unless (audioresample != NULL);
1184 g_object_set (audioresample, "quality", quality, NULL);
1186 fail_unless (gst_element_set_state (audioresample,
1187 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1188 "could not set to playing");
1190 inbuffer = gst_buffer_new_and_alloc (nsamples * width / 8);
1191 GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (nsamples, inrate);
1192 GST_BUFFER_TIMESTAMP (inbuffer) = 0;
1196 gst_buffer_ref (inbuffer);
1197 /* pushing gives away my reference ... */
1198 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1199 /* ... but it ends up being collected on the global buffer list */
1200 fail_unless_equals_int (g_list_length (buffers), 1);
1201 /* retrieve out buffer */
1202 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1204 fail_unless (gst_element_set_state (audioresample,
1205 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
1207 if (inbuffer == outbuffer)
1208 gst_buffer_unref (inbuffer);
1210 (*compare_ffts) (inbuffer, outbuffer);
1213 cleanup_audioresample (audioresample);
1216 GST_START_TEST (test_fft)
1220 static const int frequencies[] =
1221 { 8000, 16000, 44100, 48000, 128000, 12345, 54321 };
1223 /* audioresample uses a mixed float/double code path for floats with quality>8, make sure we test it */
1224 for (quality = 0; quality <= 10; quality += 5) {
1225 for (f0 = 0; f0 < G_N_ELEMENTS (frequencies); ++f0) {
1226 for (f1 = 0; f1 < G_N_ELEMENTS (frequencies); ++f1) {
1227 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1228 GST_AUDIO_NE (F32), &init_float_silence, &compare_ffts_F32);
1229 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1230 GST_AUDIO_NE (F32), &init_float_sine, &compare_ffts_F32);
1231 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1232 GST_AUDIO_NE (F32), &init_float_sine2, &compare_ffts_F32);
1233 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1234 GST_AUDIO_NE (F64), &init_double_silence, &compare_ffts_F64);
1235 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1236 GST_AUDIO_NE (F64), &init_double_sine, &compare_ffts_F64);
1237 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1238 GST_AUDIO_NE (F64), &init_double_sine2, &compare_ffts_F64);
1239 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1240 GST_AUDIO_NE (S16), &init_gint16_silence, &compare_ffts_S16);
1241 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1242 GST_AUDIO_NE (S16), &init_gint16_sine, &compare_ffts_S16);
1243 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1244 GST_AUDIO_NE (S16), &init_gint16_sine2, &compare_ffts_S16);
1245 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1246 GST_AUDIO_NE (S32), &init_gint32_silence, &compare_ffts_S32);
1247 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1248 GST_AUDIO_NE (S32), &init_gint32_sine, &compare_ffts_S32);
1249 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1250 GST_AUDIO_NE (S32), &init_gint32_sine2, &compare_ffts_S32);
1259 audioresample_suite (void)
1261 Suite *s = suite_create ("audioresample");
1262 TCase *tc_chain = tcase_create ("general");
1264 suite_add_tcase (s, tc_chain);
1265 tcase_add_test (tc_chain, test_perfect_stream);
1266 tcase_add_test (tc_chain, test_discont_stream);
1267 tcase_add_test (tc_chain, test_reuse);
1268 tcase_add_test (tc_chain, test_shutdown);
1269 tcase_add_test (tc_chain, test_live_switch);
1270 tcase_add_test (tc_chain, test_live_switch_downstream);
1271 tcase_add_test (tc_chain, test_timestamp_drift);
1272 tcase_add_test (tc_chain, test_fft);
1274 #ifndef GST_DISABLE_PARSE
1275 tcase_set_timeout (tc_chain, 360);
1276 tcase_add_test (tc_chain, test_pipelines);
1277 tcase_add_test (tc_chain, test_preference_passthrough);
1283 GST_CHECK_MAIN (audioresample);