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 #if !GLIB_CHECK_VERSION(2,58,0)
473 #define G_APPROX_VALUE(a, b, epsilon) \
474 (((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon))
477 GST_START_TEST (test_live_switch)
479 GstElement *audioresample;
487 setup_audioresample (4, 0xf, 48000, 48000, GST_AUDIO_NE (S16));
489 caps = gst_pad_get_current_caps (mysrcpad);
490 fail_unless (gst_caps_is_fixed (caps));
492 fail_unless (gst_element_set_state (audioresample,
493 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
494 "could not set to playing");
496 gst_segment_init (&segment, GST_FORMAT_TIME);
497 newseg = gst_event_new_segment (&segment);
498 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
500 /* downstream can accept the requested rate */
501 live_switch_push (0, 48000, caps);
503 /* buffer is directly passed through */
504 fail_unless_equals_int (g_list_length (buffers), 1);
506 /* Downstream can never accept this rate */
507 live_switch_push (1, 40000, caps);
509 /* one additional buffer is provided with the new sample rate */
510 fail_unless_equals_int (g_list_length (buffers), 2);
512 /* Downstream can never accept this rate */
513 live_switch_push (2, 50000, caps);
515 /* two additional buffers are provided. One is the drained remainder of
516 * the previous sample rate, the second is the buffer with the new sample
518 fail_unless_equals_int (g_list_length (buffers), 4);
520 /* Send EOS to drain the remaining samples */
521 fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
522 fail_unless_equals_int (g_list_length (buffers), 5);
524 /* Now test that each buffer has the expected samples. We simply check this
525 * by checking whether the timestamps, durations and sizes are matching */
526 for (l = buffers, i = 0; l; l = l->next, i++) {
527 GstBuffer *buffer = GST_BUFFER (l->data);
531 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
532 fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer),
534 fail_unless_equals_int (gst_buffer_get_size (buffer), 48000 * 4 * 2);
537 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 1 * GST_SECOND);
538 fail_unless_equals_int (gst_buffer_get_size (buffer), 47961 * 4 * 2);
541 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
542 GST_BUFFER_DURATION (buffer), 2 * GST_SECOND,
543 GST_SECOND / 48000 + 1));
544 fail_unless_equals_int (gst_buffer_get_size (buffer), 38 * 4 * 2);
547 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 2 * GST_SECOND);
548 fail_unless_equals_int (gst_buffer_get_size (buffer), 47969 * 4 * 2);
551 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
552 GST_BUFFER_DURATION (buffer), 3 * GST_SECOND,
553 GST_SECOND / 48000 + 1));
554 fail_unless_equals_int (gst_buffer_get_size (buffer), 30 * 4 * 2);
557 g_assert_not_reached ();
561 gst_buffer_unref (buffer);
564 g_list_free (buffers);
567 cleanup_audioresample (audioresample);
568 gst_caps_unref (caps);
573 static gint current_rate = 0;
576 live_switch_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
578 switch (GST_QUERY_TYPE (query)) {
579 case GST_QUERY_ACCEPT_CAPS:{
580 GstCaps *acceptable_caps;
583 acceptable_caps = gst_pad_get_current_caps (mysrcpad);
584 acceptable_caps = gst_caps_make_writable (acceptable_caps);
585 gst_caps_set_simple (acceptable_caps, "rate", G_TYPE_INT, current_rate,
588 gst_query_parse_accept_caps (query, &caps);
590 gst_query_set_accept_caps_result (query, gst_caps_can_intersect (caps,
593 gst_caps_unref (acceptable_caps);
597 case GST_QUERY_CAPS:{
598 GstCaps *acceptable_caps;
602 acceptable_caps = gst_pad_get_current_caps (mysrcpad);
603 acceptable_caps = gst_caps_make_writable (acceptable_caps);
604 gst_caps_set_simple (acceptable_caps, "rate", G_TYPE_INT, current_rate,
607 gst_query_parse_caps (query, &filter);
611 gst_caps_intersect_full (filter, acceptable_caps,
612 GST_CAPS_INTERSECT_FIRST);
614 caps = gst_caps_ref (acceptable_caps);
616 gst_query_set_caps_result (query, caps);
618 gst_caps_unref (caps);
619 gst_caps_unref (acceptable_caps);
624 return gst_pad_query_default (pad, parent, query);
629 live_switch_push_downstream (gint pts, gint rate)
634 gst_pad_push_event (mysinkpad, gst_event_new_reconfigure ());
636 inbuffer = gst_buffer_new_and_alloc (48000 * 4 * 2);
637 gst_buffer_memset (inbuffer, 0, 0, 48000 * 4 * 2);
639 GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
640 GST_BUFFER_TIMESTAMP (inbuffer) = pts * GST_SECOND;
641 GST_BUFFER_OFFSET (inbuffer) = 0;
642 GST_BUFFER_OFFSET_END (inbuffer) = 47999;
644 /* pushing gives away my reference ... */
645 fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
647 /* ... but it ends up being collected on the global buffer list */
650 GST_START_TEST (test_live_switch_downstream)
652 GstElement *audioresample;
660 setup_audioresample (4, 0xf, 48000, 48000, GST_AUDIO_NE (S16));
662 gst_pad_set_query_function (mysinkpad, live_switch_sink_query);
664 caps = gst_pad_get_current_caps (mysrcpad);
665 fail_unless (gst_caps_is_fixed (caps));
667 fail_unless (gst_element_set_state (audioresample,
668 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
669 "could not set to playing");
671 gst_segment_init (&segment, GST_FORMAT_TIME);
672 newseg = gst_event_new_segment (&segment);
673 fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
675 /* buffer is directly passed through */
676 live_switch_push_downstream (0, 48000);
677 fail_unless_equals_int (g_list_length (buffers), 1);
679 /* Reconfigure downstream to 40000 Hz */
680 live_switch_push_downstream (1, 40000);
682 /* one additional buffer is provided with the new sample rate */
683 fail_unless_equals_int (g_list_length (buffers), 2);
685 /* Reconfigure downstream to 50000 Hz */
686 live_switch_push_downstream (2, 50000);
688 /* two additional buffers are provided. One is the drained remainder of
689 * the previous sample rate, the second is the buffer with the new sample
691 fail_unless_equals_int (g_list_length (buffers), 4);
693 /* Send EOS to drain the remaining samples */
694 fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
695 fail_unless_equals_int (g_list_length (buffers), 5);
697 /* Now test that each buffer has the expected samples. We simply check this
698 * by checking whether the timestamps, durations and sizes are matching */
699 for (l = buffers, i = 0; l; l = l->next, i++) {
700 GstBuffer *buffer = GST_BUFFER (l->data);
704 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
705 fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer),
707 fail_unless_equals_int (gst_buffer_get_size (buffer), 48000 * 4 * 2);
710 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 1 * GST_SECOND);
711 fail_unless_equals_int (gst_buffer_get_size (buffer), 39966 * 4 * 2);
714 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
715 GST_BUFFER_DURATION (buffer), 2 * GST_SECOND,
716 GST_SECOND / 40000 + 1));
717 fail_unless_equals_int (gst_buffer_get_size (buffer), 34 * 4 * 2);
720 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 2 * GST_SECOND);
721 fail_unless_equals_int (gst_buffer_get_size (buffer), 49966 * 4 * 2);
724 fail_unless (G_APPROX_VALUE (GST_BUFFER_PTS (buffer) +
725 GST_BUFFER_DURATION (buffer), 3 * GST_SECOND,
726 GST_SECOND / 50000 + 1));
727 fail_unless_equals_int (gst_buffer_get_size (buffer), 33 * 4 * 2);
730 g_assert_not_reached ();
734 gst_buffer_unref (buffer);
737 g_list_free (buffers);
740 cleanup_audioresample (audioresample);
741 gst_caps_unref (caps);
746 #ifndef GST_DISABLE_PARSE
748 static GMainLoop *loop;
749 static gint messages = 0;
752 element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
756 s = gst_structure_to_string (gst_message_get_structure (message));
757 GST_DEBUG ("Received message: %s", s);
764 eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
766 GST_DEBUG ("Received eos");
767 g_main_loop_quit (loop);
771 test_pipeline (const gchar * format, gint inrate, gint outrate, gint quality)
773 GstElement *pipeline;
775 GError *error = NULL;
780 ("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",
781 format, inrate, quality, format, outrate);
783 pipeline = gst_parse_launch (pipe_str, &error);
784 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
785 error ? error->message : "(invalid error)");
788 bus = gst_element_get_bus (pipeline);
789 fail_if (bus == NULL);
790 gst_bus_add_signal_watch (bus);
791 g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
793 g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
795 gst_element_set_state (pipeline, GST_STATE_PLAYING);
797 /* run until we receive EOS */
798 loop = g_main_loop_new (NULL, FALSE);
800 g_main_loop_run (loop);
802 g_main_loop_unref (loop);
805 gst_element_set_state (pipeline, GST_STATE_NULL);
807 gst_bus_remove_signal_watch (bus);
808 gst_object_unref (bus);
810 fail_if (messages > 0, "Received imperfect timestamp messages");
811 gst_object_unref (pipeline);
814 GST_START_TEST (test_pipelines)
818 /* Test qualities 0, 5 and 10 */
819 for (quality = 0; quality < 11; quality += 5) {
820 GST_DEBUG ("Checking with quality %d", quality);
822 test_pipeline ("S8", 44100, 48000, quality);
823 test_pipeline ("S8", 48000, 44100, quality);
825 test_pipeline (GST_AUDIO_NE (S16), 44100, 48000, quality);
826 test_pipeline (GST_AUDIO_NE (S16), 48000, 44100, quality);
828 test_pipeline (GST_AUDIO_NE (S24), 44100, 48000, quality);
829 test_pipeline (GST_AUDIO_NE (S24), 48000, 44100, quality);
831 test_pipeline (GST_AUDIO_NE (S32), 44100, 48000, quality);
832 test_pipeline (GST_AUDIO_NE (S32), 48000, 44100, quality);
834 test_pipeline (GST_AUDIO_NE (F32), 44100, 48000, quality);
835 test_pipeline (GST_AUDIO_NE (F32), 48000, 44100, quality);
837 test_pipeline (GST_AUDIO_NE (F64), 44100, 48000, quality);
838 test_pipeline (GST_AUDIO_NE (F64), 48000, 44100, quality);
844 GST_START_TEST (test_preference_passthrough)
846 GstStateChangeReturn ret;
847 GstElement *pipeline, *src;
853 GError *error = NULL;
856 pipeline = gst_parse_launch ("audiotestsrc num-buffers=1 name=src ! "
857 "audioresample ! audio/x-raw,format=" GST_AUDIO_NE (S16) ",channels=1,"
858 "rate=8000 ! fakesink can-activate-pull=false", &error);
859 fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
860 error ? error->message : "(invalid error)");
862 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
863 fail_unless_equals_int (ret, GST_STATE_CHANGE_ASYNC);
865 /* run until we receive EOS */
866 bus = gst_element_get_bus (pipeline);
867 fail_if (bus == NULL);
868 msg = gst_bus_timed_pop_filtered (bus, -1, GST_MESSAGE_EOS);
869 gst_message_unref (msg);
870 gst_object_unref (bus);
872 src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
873 fail_unless (src != NULL);
874 pad = gst_element_get_static_pad (src, "src");
875 fail_unless (pad != NULL);
876 caps = gst_pad_get_current_caps (pad);
877 GST_LOG ("current audiotestsrc caps: %" GST_PTR_FORMAT, caps);
878 fail_unless (caps != NULL);
879 s = gst_caps_get_structure (caps, 0);
880 fail_unless (gst_structure_get_int (s, "rate", &rate));
881 /* there's no need to resample, audiotestsrc supports any rate, so make
882 * sure audioresample provided upstream with the right caps to negotiate
884 fail_unless_equals_int (rate, 8000);
885 gst_caps_unref (caps);
886 gst_object_unref (pad);
887 gst_object_unref (src);
889 gst_element_set_state (pipeline, GST_STATE_NULL);
890 gst_object_unref (pipeline);
898 _message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
900 GMainLoop *loop = user_data;
902 switch (GST_MESSAGE_TYPE (message)) {
903 case GST_MESSAGE_ERROR:
904 case GST_MESSAGE_WARNING:
905 g_assert_not_reached ();
907 case GST_MESSAGE_EOS:
908 g_main_loop_quit (loop);
920 GstClockTime next_out_ts;
921 guint64 next_out_off;
923 guint64 in_buffer_count, out_buffer_count;
927 fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
930 TimestampDriftCtx *ctx = user_data;
932 ctx->out_buffer_count++;
933 if (ctx->latency == GST_CLOCK_TIME_NONE) {
934 ctx->latency = 1000 - gst_buffer_get_size (buffer) / 8;
937 /* Check if we have a perfectly timestamped stream */
938 if (ctx->next_out_ts != GST_CLOCK_TIME_NONE)
939 fail_unless (ctx->next_out_ts == GST_BUFFER_TIMESTAMP (buffer),
940 "expected timestamp %" GST_TIME_FORMAT " got timestamp %"
941 GST_TIME_FORMAT, GST_TIME_ARGS (ctx->next_out_ts),
942 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
944 /* Check if we have a perfectly offsetted stream */
945 fail_unless (GST_BUFFER_OFFSET_END (buffer) ==
946 GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
947 "expected offset end %" G_GUINT64_FORMAT " got offset end %"
949 GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
950 GST_BUFFER_OFFSET_END (buffer));
951 if (ctx->next_out_off != GST_BUFFER_OFFSET_NONE) {
952 fail_unless (GST_BUFFER_OFFSET (buffer) == ctx->next_out_off,
953 "expected offset %" G_GUINT64_FORMAT " got offset %" G_GUINT64_FORMAT,
954 ctx->next_out_off, GST_BUFFER_OFFSET (buffer));
957 if (ctx->in_buffer_count != ctx->out_buffer_count) {
958 GST_INFO ("timestamp %" GST_TIME_FORMAT,
959 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
962 if (ctx->in_ts != GST_CLOCK_TIME_NONE && ctx->in_buffer_count > 1
963 && ctx->in_buffer_count == ctx->out_buffer_count) {
964 fail_unless (GST_BUFFER_TIMESTAMP (buffer) ==
965 ctx->in_ts - gst_util_uint64_scale_round (ctx->latency, GST_SECOND,
967 "expected output timestamp %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT
968 ") got output timestamp %" GST_TIME_FORMAT " (%" G_GUINT64_FORMAT ")",
969 GST_TIME_ARGS (ctx->in_ts - gst_util_uint64_scale_round (ctx->latency,
971 ctx->in_ts - gst_util_uint64_scale_round (ctx->latency, GST_SECOND,
972 4096), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
973 GST_BUFFER_TIMESTAMP (buffer));
977 GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer);
978 ctx->next_out_off = GST_BUFFER_OFFSET_END (buffer);
982 identity_handoff_cb (GstElement * object, GstBuffer * buffer,
985 TimestampDriftCtx *ctx = user_data;
987 ctx->in_ts = GST_BUFFER_TIMESTAMP (buffer);
988 ctx->in_buffer_count++;
991 GST_START_TEST (test_timestamp_drift)
993 TimestampDriftCtx ctx =
994 { GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE,
995 GST_BUFFER_OFFSET_NONE, 0, 0
997 GstElement *pipeline;
998 GstElement *audiotestsrc, *capsfilter1, *identity, *audioresample,
999 *capsfilter2, *fakesink;
1004 pipeline = gst_pipeline_new ("pipeline");
1005 fail_unless (pipeline != NULL);
1007 audiotestsrc = gst_element_factory_make ("audiotestsrc", "src");
1008 fail_unless (audiotestsrc != NULL);
1009 g_object_set (G_OBJECT (audiotestsrc), "num-buffers", 10000,
1010 "samplesperbuffer", 4000, NULL);
1012 capsfilter1 = gst_element_factory_make ("capsfilter", "capsfilter1");
1013 fail_unless (capsfilter1 != NULL);
1014 caps = gst_caps_from_string ("audio/x-raw, format=" GST_AUDIO_NE (F64)
1015 ", channels=1, rate=16384");
1016 g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
1017 gst_caps_unref (caps);
1019 identity = gst_element_factory_make ("identity", "identity");
1020 fail_unless (identity != NULL);
1021 g_object_set (G_OBJECT (identity), "sync", FALSE, "signal-handoffs", TRUE,
1023 g_signal_connect (identity, "handoff", (GCallback) identity_handoff_cb, &ctx);
1025 audioresample = gst_element_factory_make ("audioresample", "resample");
1026 fail_unless (audioresample != NULL);
1027 capsfilter2 = gst_element_factory_make ("capsfilter", "capsfilter2");
1028 fail_unless (capsfilter2 != NULL);
1029 caps = gst_caps_from_string ("audio/x-raw, format=" GST_AUDIO_NE (F64)
1030 ", channels=1, rate=4096");
1031 g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
1032 gst_caps_unref (caps);
1034 fakesink = gst_element_factory_make ("fakesink", "sink");
1035 fail_unless (fakesink != NULL);
1036 g_object_set (G_OBJECT (fakesink), "sync", FALSE, "async", FALSE,
1037 "signal-handoffs", TRUE, NULL);
1038 g_signal_connect (fakesink, "handoff", (GCallback) fakesink_handoff_cb, &ctx);
1041 gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, capsfilter1, identity,
1042 audioresample, capsfilter2, fakesink, NULL);
1043 fail_unless (gst_element_link_many (audiotestsrc, capsfilter1, identity,
1044 audioresample, capsfilter2, fakesink, NULL));
1046 loop = g_main_loop_new (NULL, FALSE);
1048 bus = gst_element_get_bus (pipeline);
1049 gst_bus_add_signal_watch (bus);
1050 g_signal_connect (bus, "message", (GCallback) _message_cb, loop);
1052 fail_unless (gst_element_set_state (pipeline,
1053 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
1054 g_main_loop_run (loop);
1056 fail_unless (gst_element_set_state (pipeline,
1057 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
1058 g_main_loop_unref (loop);
1059 gst_bus_remove_signal_watch (bus);
1060 gst_object_unref (bus);
1062 gst_object_unref (pipeline);
1066 #define FFT_HELPERS(type,ffttag,ffttag2,scale); \
1067 static gdouble magnitude##ffttag (const GstFFT##ffttag##Complex *c) \
1069 gdouble mag = (gdouble) c->r * (gdouble) c->r; \
1070 mag += (gdouble) c->i * (gdouble) c->i; \
1071 mag /= scale * scale; \
1072 mag = 10.0 * log10 (mag); \
1075 static gdouble find_main_frequency_spot_##ffttag (const GstFFT##ffttag##Complex *v, \
1079 gdouble maxmag = -9999; \
1081 for (i=0; i<elements; ++i) { \
1082 gdouble mag = magnitude##ffttag (v+i); \
1083 if (mag > maxmag) { \
1088 return maxidx / (gdouble) elements; \
1090 static gboolean is_zero_except_##ffttag (const GstFFT##ffttag##Complex *v, int elements, \
1094 for (i=0; i<elements; ++i) { \
1095 gdouble pos = i / (gdouble) elements; \
1096 gdouble mag = magnitude##ffttag (v+i); \
1097 if (fabs (pos - spot) > 0.01) { \
1098 if (mag > -55.0) { \
1105 static void compare_ffts_##ffttag (GstBuffer *inbuffer, GstBuffer *outbuffer) \
1107 GstMapInfo inmap, outmap; \
1108 int insamples, outsamples; \
1109 gdouble inspot, outspot; \
1110 GstFFT##ffttag *inctx, *outctx; \
1111 GstFFT##ffttag##Complex *in, *out; \
1113 gst_buffer_map (inbuffer, &inmap, GST_MAP_READ); \
1114 gst_buffer_map (outbuffer, &outmap, GST_MAP_READWRITE); \
1116 insamples = inmap.size / sizeof(type) & ~1; \
1117 outsamples = outmap.size / sizeof(type) & ~1; \
1118 inctx = gst_fft_##ffttag2##_new (insamples, FALSE); \
1119 outctx = gst_fft_##ffttag2##_new (outsamples, FALSE); \
1120 in = g_new (GstFFT##ffttag##Complex, insamples / 2 + 1); \
1121 out = g_new (GstFFT##ffttag##Complex, outsamples / 2 + 1); \
1123 gst_fft_##ffttag2##_window (inctx, (type*)inmap.data, \
1124 GST_FFT_WINDOW_HAMMING); \
1125 gst_fft_##ffttag2##_fft (inctx, (type*)inmap.data, in); \
1126 gst_fft_##ffttag2##_window (outctx, (type*)outmap.data, \
1127 GST_FFT_WINDOW_HAMMING); \
1128 gst_fft_##ffttag2##_fft (outctx, (type*)outmap.data, out); \
1130 inspot = find_main_frequency_spot_##ffttag (in, insamples / 2 + 1); \
1131 outspot = find_main_frequency_spot_##ffttag (out, outsamples / 2 + 1); \
1132 GST_LOG ("Spots are %.3f and %.3f", inspot, outspot); \
1133 fail_unless (fabs (outspot - inspot) < 0.05); \
1134 fail_unless (is_zero_except_##ffttag (in, insamples / 2 + 1, inspot)); \
1135 fail_unless (is_zero_except_##ffttag (out, outsamples / 2 + 1, outspot)); \
1137 gst_buffer_unmap (inbuffer, &inmap); \
1138 gst_buffer_unmap (outbuffer, &outmap); \
1140 gst_fft_##ffttag2##_free (inctx); \
1141 gst_fft_##ffttag2##_free (outctx); \
1145 FFT_HELPERS (float, F32, f32, 2048.0f);
1146 FFT_HELPERS (double, F64, f64, 2048.0);
1147 FFT_HELPERS (gint16, S16, s16, 32767.0);
1148 FFT_HELPERS (gint32, S32, s32, 2147483647.0);
1150 #define FILL_BUFFER(type, desc, value); \
1151 static void init_##type##_##desc (GstBuffer *buffer) \
1156 gst_buffer_map (buffer, &map, GST_MAP_WRITE); \
1157 ptr = (type *)map.data; \
1158 nsamples = map.size / sizeof (type); \
1159 for (i = 0; i < nsamples; ++i) { \
1162 gst_buffer_unmap (buffer, &map); \
1165 FILL_BUFFER (float, silence, 0.0f);
1166 FILL_BUFFER (double, silence, 0.0);
1167 FILL_BUFFER (gint16, silence, 0);
1168 FILL_BUFFER (gint32, silence, 0);
1169 FILL_BUFFER (float, sine, sinf (i * 0.01f));
1170 FILL_BUFFER (float, sine2, sinf (i * 1.8f));
1171 FILL_BUFFER (double, sine, sin (i * 0.01));
1172 FILL_BUFFER (double, sine2, sin (i * 1.8));
1173 FILL_BUFFER (gint16, sine, (gint16) (32767 * sinf (i * 0.01f)));
1174 FILL_BUFFER (gint16, sine2, (gint16) (32767 * sinf (i * 1.8f)));
1175 FILL_BUFFER (gint32, sine, (gint32) (2147483647.0 * sin (i * 0.01)));
1176 FILL_BUFFER (gint32, sine2, (gint32) (2147483647.0 * sin (i * 1.8)));
1179 run_fft_pipeline (int inrate, int outrate, int quality, int width,
1180 const gchar * format, void (*init) (GstBuffer *),
1181 void (*compare_ffts) (GstBuffer *, GstBuffer *))
1183 GstElement *audioresample;
1184 GstBuffer *inbuffer, *outbuffer;
1185 const int nsamples = 2048;
1187 audioresample = setup_audioresample (1, 0, inrate, outrate, format);
1188 fail_unless (audioresample != NULL);
1189 g_object_set (audioresample, "quality", quality, NULL);
1191 fail_unless (gst_element_set_state (audioresample,
1192 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1193 "could not set to playing");
1195 inbuffer = gst_buffer_new_and_alloc (nsamples * width / 8);
1196 GST_BUFFER_DURATION (inbuffer) = GST_FRAMES_TO_CLOCK_TIME (nsamples, inrate);
1197 GST_BUFFER_TIMESTAMP (inbuffer) = 0;
1201 gst_buffer_ref (inbuffer);
1202 /* pushing gives away my reference ... */
1203 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1204 /* ... but it ends up being collected on the global buffer list */
1205 fail_unless_equals_int (g_list_length (buffers), 1);
1206 /* retrieve out buffer */
1207 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1209 fail_unless (gst_element_set_state (audioresample,
1210 GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
1212 if (inbuffer == outbuffer)
1213 gst_buffer_unref (inbuffer);
1215 (*compare_ffts) (inbuffer, outbuffer);
1218 cleanup_audioresample (audioresample);
1221 GST_START_TEST (test_fft)
1225 static const int frequencies[] =
1226 { 8000, 16000, 44100, 48000, 128000, 12345, 54321 };
1228 /* audioresample uses a mixed float/double code path for floats with quality>8, make sure we test it */
1229 for (quality = 0; quality <= 10; quality += 5) {
1230 for (f0 = 0; f0 < G_N_ELEMENTS (frequencies); ++f0) {
1231 for (f1 = 0; f1 < G_N_ELEMENTS (frequencies); ++f1) {
1232 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1233 GST_AUDIO_NE (F32), &init_float_silence, &compare_ffts_F32);
1234 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1235 GST_AUDIO_NE (F32), &init_float_sine, &compare_ffts_F32);
1236 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1237 GST_AUDIO_NE (F32), &init_float_sine2, &compare_ffts_F32);
1238 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1239 GST_AUDIO_NE (F64), &init_double_silence, &compare_ffts_F64);
1240 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1241 GST_AUDIO_NE (F64), &init_double_sine, &compare_ffts_F64);
1242 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 64,
1243 GST_AUDIO_NE (F64), &init_double_sine2, &compare_ffts_F64);
1244 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1245 GST_AUDIO_NE (S16), &init_gint16_silence, &compare_ffts_S16);
1246 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1247 GST_AUDIO_NE (S16), &init_gint16_sine, &compare_ffts_S16);
1248 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 16,
1249 GST_AUDIO_NE (S16), &init_gint16_sine2, &compare_ffts_S16);
1250 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1251 GST_AUDIO_NE (S32), &init_gint32_silence, &compare_ffts_S32);
1252 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1253 GST_AUDIO_NE (S32), &init_gint32_sine, &compare_ffts_S32);
1254 run_fft_pipeline (frequencies[f0], frequencies[f0], quality, 32,
1255 GST_AUDIO_NE (S32), &init_gint32_sine2, &compare_ffts_S32);
1264 audioresample_suite (void)
1266 Suite *s = suite_create ("audioresample");
1267 TCase *tc_chain = tcase_create ("general");
1269 suite_add_tcase (s, tc_chain);
1270 tcase_add_test (tc_chain, test_perfect_stream);
1271 tcase_add_test (tc_chain, test_discont_stream);
1272 tcase_add_test (tc_chain, test_reuse);
1273 tcase_add_test (tc_chain, test_shutdown);
1274 tcase_add_test (tc_chain, test_live_switch);
1275 tcase_add_test (tc_chain, test_live_switch_downstream);
1276 tcase_add_test (tc_chain, test_timestamp_drift);
1277 tcase_add_test (tc_chain, test_fft);
1279 #ifndef GST_DISABLE_PARSE
1280 tcase_set_timeout (tc_chain, 360);
1281 tcase_add_test (tc_chain, test_pipelines);
1282 tcase_add_test (tc_chain, test_preference_passthrough);
1288 GST_CHECK_MAIN (audioresample);