diff options
author | Julien Moutte <julien@moutte.net> | 2007-03-14 17:16:30 +0000 |
---|---|---|
committer | Julien Moutte <julien@moutte.net> | 2007-03-14 17:16:30 +0000 |
commit | e3ef9cd15d1f0fc55702c29cfb60338325b54065 (patch) | |
tree | c0b143ee7cb4477fe91bdb80607c90ee0178fceb /tests/check | |
parent | 04a574c282831d6b150244b3a8c8c791a9ea81ba (diff) | |
download | gst-plugins-bad-e3ef9cd15d1f0fc55702c29cfb60338325b54065.tar.gz gst-plugins-bad-e3ef9cd15d1f0fc55702c29cfb60338325b54065.tar.bz2 gst-plugins-bad-e3ef9cd15d1f0fc55702c29cfb60338325b54065.zip |
gst/audioresample/gstaudioresample.c: Handle discontinuous streams.
Original commit message from CVS:
2007-03-14 Julien MOUTTE <julien@moutte.net>
* gst/audioresample/gstaudioresample.c: (gst_audioresample_init),
(audioresample_transform_size), (audioresample_do_output),
(audioresample_transform), (audioresample_pushthrough): Handle
discontinuous streams.
* gst/audioresample/gstaudioresample.h:
* tests/check/elements/audioresample.c:
(test_discont_stream_instance), (GST_START_TEST),
(audioresample_suite): Add a test for discontinuous streams.
* win32/common/config.h: Updated.
Diffstat (limited to 'tests/check')
-rw-r--r-- | tests/check/elements/audioresample.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/check/elements/audioresample.c b/tests/check/elements/audioresample.c index bd5bf424..78e46540 100644 --- a/tests/check/elements/audioresample.c +++ b/tests/check/elements/audioresample.c @@ -144,6 +144,7 @@ fail_unless_perfect_stream () buffers = NULL; } +/* this tests that the output is a perfect stream if the input is */ static void test_perfect_stream_instance (int inrate, int outrate, int samples, int numbuffers) @@ -224,6 +225,89 @@ GST_START_TEST (test_perfect_stream) GST_END_TEST; +/* this tests that the output is a correct discontinuous stream + * if the input is; ie input drops in time come out the same way */ +static void +test_discont_stream_instance (int inrate, int outrate, int samples, + int numbuffers) +{ + GstElement *audioresample; + GstBuffer *inbuffer, *outbuffer; + GstCaps *caps; + GstClockTime ints; + + int i, j; + gint16 *p; + + audioresample = setup_audioresample (2, inrate, outrate); + caps = gst_pad_get_negotiated_caps (mysrcpad); + fail_unless (gst_caps_is_fixed (caps)); + + fail_unless (gst_element_set_state (audioresample, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + for (j = 1; j <= numbuffers; ++j) { + + inbuffer = gst_buffer_new_and_alloc (samples * 4); + GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate; + /* "drop" half the buffers */ + ints = GST_BUFFER_DURATION (inbuffer) * 2 * (j - 1); + GST_BUFFER_TIMESTAMP (inbuffer) = ints; + GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples; + GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples; + + gst_buffer_set_caps (inbuffer, caps); + + p = (gint16 *) GST_BUFFER_DATA (inbuffer); + + /* create a 16 bit signed ramp */ + for (i = 0; i < samples; ++i) { + *p = -32767 + i * (65535 / samples); + ++p; + *p = -32767 + i * (65535 / samples); + ++p; + } + + /* pushing gives away my reference ... */ + fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); + + /* check if the timestamp of the pushed buffer matches the incoming one */ + outbuffer = g_list_nth_data (buffers, g_list_length (buffers) - 1); + fail_if (outbuffer == NULL); + fail_unless_equals_uint64 (ints, GST_BUFFER_TIMESTAMP (outbuffer)); + if (j > 1) { + fail_unless (GST_BUFFER_IS_DISCONT (outbuffer), + "expected discont buffer"); + } + } + + /* cleanup */ + gst_caps_unref (caps); + cleanup_audioresample (audioresample); +} + +GST_START_TEST (test_discont_stream) +{ + /* integral scalings */ + test_discont_stream_instance (48000, 24000, 500, 20); + test_discont_stream_instance (48000, 12000, 500, 20); + test_discont_stream_instance (12000, 24000, 500, 20); + test_discont_stream_instance (12000, 48000, 500, 20); + + /* non-integral scalings */ + test_discont_stream_instance (44100, 8000, 500, 20); + test_discont_stream_instance (8000, 44100, 500, 20); + + /* wacky scalings */ + test_discont_stream_instance (12345, 54321, 500, 20); + test_discont_stream_instance (101, 99, 500, 20); +} + +GST_END_TEST; + + + GST_START_TEST (test_reuse) { GstElement *audioresample; @@ -295,6 +379,7 @@ audioresample_suite (void) suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_perfect_stream); + tcase_add_test (tc_chain, test_discont_stream); tcase_add_test (tc_chain, test_reuse); return s; |