diff options
author | Andrew Comminos <andrewcomminos@gmail.com> | 2014-03-08 08:45:49 +0400 |
---|---|---|
committer | Andrew Comminos <andrewcomminos@gmail.com> | 2014-03-08 08:45:49 +0400 |
commit | 934588bed488e81e3a8cfc5ac956bef28e166be3 (patch) | |
tree | 080b3507a46baa6f798bdde20f8f146cfb1a6559 /src/androidTest | |
parent | 7d48e1cb5ba1156a63a7db7192f7f80f960502d0 (diff) |
Added tests for all encoders.
Diffstat (limited to 'src/androidTest')
-rw-r--r-- | src/androidTest/assets/jumble-test.p12 | bin | 2469 -> 0 bytes | |||
-rw-r--r-- | src/androidTest/assets/speech_48000.wav | bin | 1036844 -> 0 bytes | |||
-rw-r--r-- | src/androidTest/java/com/morlunk/jumble/test/EncoderTest.java | 79 | ||||
-rw-r--r-- | src/androidTest/java/com/morlunk/jumble/test/OpusTest.java | 58 |
4 files changed, 79 insertions, 58 deletions
diff --git a/src/androidTest/assets/jumble-test.p12 b/src/androidTest/assets/jumble-test.p12 Binary files differdeleted file mode 100644 index e75bda3..0000000 --- a/src/androidTest/assets/jumble-test.p12 +++ /dev/null diff --git a/src/androidTest/assets/speech_48000.wav b/src/androidTest/assets/speech_48000.wav Binary files differdeleted file mode 100644 index 8a42619..0000000 --- a/src/androidTest/assets/speech_48000.wav +++ /dev/null diff --git a/src/androidTest/java/com/morlunk/jumble/test/EncoderTest.java b/src/androidTest/java/com/morlunk/jumble/test/EncoderTest.java new file mode 100644 index 0000000..42bb610 --- /dev/null +++ b/src/androidTest/java/com/morlunk/jumble/test/EncoderTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 Andrew Comminos + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.morlunk.jumble.test; + +import android.test.AndroidTestCase; + +import com.googlecode.javacpp.BytePointer; +import com.googlecode.javacpp.IntPointer; +import com.googlecode.javacpp.Loader; +import com.googlecode.javacpp.Pointer; +import com.morlunk.jumble.audio.NativeAudioException; +import com.morlunk.jumble.audio.javacpp.CELT11; +import com.morlunk.jumble.audio.javacpp.CELT7; +import com.morlunk.jumble.audio.javacpp.Opus; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * This class tests the Opus and CELT encoders with blank PCM data. + * The bitrate is set to 40000bps. TODO: add test for varying bitrates. + * If any of these methods throw a NativeAudioException, then the test will fail. + * Created by andrew on 13/10/13. + */ +public class EncoderTest extends AndroidTestCase { + + private static final int SAMPLE_RATE = 48000; + private static final int BITRATE = 40000; + private static final int FRAME_SIZE = 480; + + static { + Loader.load(Opus.class); + } + + public void testOpusEncode() throws NativeAudioException { + Opus.OpusEncoder encoder = new Opus.OpusEncoder(SAMPLE_RATE, 1); + encoder.setBitrate(BITRATE); + assertEquals(encoder.getBitrate(), BITRATE); + + short[] pcm = new short[FRAME_SIZE]; + byte[] output = new byte[1024]; + encoder.encode(pcm, FRAME_SIZE, output, 1024); + } + + public void testCELT11Encode() throws NativeAudioException { + CELT11.CELT11Encoder encoder = new CELT11.CELT11Encoder(SAMPLE_RATE, 1); +// encoder.setBitrate(BITRATE); +// assertEquals(encoder.getBitrate(), BITRATE); + + short[] pcm = new short[FRAME_SIZE]; + byte[] output = new byte[1024]; + encoder.encode(pcm, FRAME_SIZE, output, 1024); + } + + public void testCELT7Encode() throws NativeAudioException { + CELT7.CELT7Encoder encoder = new CELT7.CELT7Encoder(SAMPLE_RATE, FRAME_SIZE, 1); +// encoder.setBitrate(BITRATE); +// assertEquals(encoder.getBitrate(), BITRATE); + + short[] pcm = new short[FRAME_SIZE]; + byte[] output = new byte[1024]; + encoder.encode(pcm, FRAME_SIZE, output, 1024); + } +} diff --git a/src/androidTest/java/com/morlunk/jumble/test/OpusTest.java b/src/androidTest/java/com/morlunk/jumble/test/OpusTest.java deleted file mode 100644 index 2b0b20c..0000000 --- a/src/androidTest/java/com/morlunk/jumble/test/OpusTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013 Andrew Comminos - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.morlunk.jumble.test; - -import android.test.AndroidTestCase; - -import com.googlecode.javacpp.BytePointer; -import com.googlecode.javacpp.IntPointer; -import com.googlecode.javacpp.Loader; -import com.googlecode.javacpp.Pointer; -import com.morlunk.jumble.audio.javacpp.Opus; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Created by andrew on 13/10/13. - */ -public class OpusTest extends AndroidTestCase { - - private static final int FRAME_SIZE = 480; - - static { - Loader.load(Opus.class); - } - - /** - * Tests the encoding of an empty 16 bit waveform of frame size 480 (mumble typical). - * This does not check the integrity of the encoding, it only tests the success - * of the operation. - */ - public void testEncodeFrame() throws IOException { - IntPointer error = new IntPointer(1); - error.put(0); - Pointer encoder = Opus.opus_encoder_create(48000, 1, Opus.OPUS_APPLICATION_VOIP, error); - assertEquals(error.get(), 0); - - short[] pcm = new short[FRAME_SIZE]; - byte[] output = new byte[1024]; - int result = Opus.opus_encode(encoder, pcm, FRAME_SIZE, output, output.length); - assertTrue(result > 0); - } -} |