Chromium Code Reviews| Index: webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc |
| diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc |
| index c7bbfb0434428a75dd6c63462b94d230e89212c4..52b441db86411ec826d3bcea33d0795a39eb2753 100644 |
| --- a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc |
| +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc |
| @@ -26,6 +26,7 @@ |
| #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" |
| #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" |
| #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
| +#include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" |
| #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
| #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" |
| #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
| @@ -1265,6 +1266,8 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, |
| rtc::Md5Digest payload_checksum_; |
| }; |
| +class AcmSenderBitExactnessNewApi : public AcmSenderBitExactnessOldApi {}; |
| + |
| #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
| TEST_F(AcmSenderBitExactnessOldApi, IsacWb30ms) { |
| ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 16000, 1, 103, 480, 480)); |
| @@ -1489,9 +1492,47 @@ TEST_F(AcmSenderBitExactnessOldApi, Opus_stereo_20ms_voip) { |
| 50, test::AcmReceiveTestOldApi::kStereoOutput); |
| } |
| +static const SdpAudioFormat kOpusFormat("opus", 48000, 2, {{"stereo", "1"}}); |
|
ossu
2017/03/14 20:25:11
Replicate the tests for Opus, but using an SdpAudi
|
| + |
| +TEST_F(AcmSenderBitExactnessNewApi, OpusFromFormat_stereo_20ms) { |
| + std::unique_ptr<AudioEncoder> encoder( |
| + new AudioEncoderOpus(120, kOpusFormat)); |
| + ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(encoder.get(), 120)); |
| + Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( |
| + "855041f2490b887302bce9d544731849", |
| + "855041f2490b887302bce9d544731849", |
| + "9692eede45638eb425e0daf9c75b5c7a", |
| + "86d3552bb3492247f965cdd0e88a1c82"), |
| + AcmReceiverBitExactnessOldApi::PlatformChecksum( |
| + "d781cce1ab986b618d0da87226cdde30", |
| + "d781cce1ab986b618d0da87226cdde30", |
| + "8d6782b905c3230d4b0e3e83e1fc3439", |
| + "798347a685fac7d0c2d8f748ffe66881"), |
| + 50, test::AcmReceiveTestOldApi::kStereoOutput); |
| +} |
| + |
| +TEST_F(AcmSenderBitExactnessNewApi, OpusFromFormat_stereo_20ms_voip) { |
| + std::unique_ptr<AudioEncoder> encoder( |
| + new AudioEncoderOpus(120, kOpusFormat)); |
| + ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(encoder.get(), 120)); |
| + // If not set, default will be kAudio in case of stereo. |
| + EXPECT_EQ(0, send_test_->acm()->SetOpusApplication(kVoip)); |
| + Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( |
| + "9b9e12bc3cc793740966e11cbfa8b35b", |
| + "9b9e12bc3cc793740966e11cbfa8b35b", |
| + "0de6249018fdd316c21086db84e10610", |
| + "9c4cb69db77b85841a5f8225bb8f508b"), |
| + AcmReceiverBitExactnessOldApi::PlatformChecksum( |
| + "c7340b1189652ab6b5e80dade7390cb4", |
| + "c7340b1189652ab6b5e80dade7390cb4", |
| + "95612864c954ee63e28cc6eebad56626", |
| + "ae33ea2e43407cf9ebdabbbd6ca912a3"), |
| + 50, test::AcmReceiveTestOldApi::kStereoOutput); |
| +} |
| + |
| // This test is for verifying the SetBitRate function. The bitrate is changed at |
| // the beginning, and the number of generated bytes are checked. |
| -class AcmSetBitRateOldApi : public ::testing::Test { |
| +class AcmSetBitRateTest : public ::testing::Test { |
| protected: |
| static const int kTestDurationMs = 1000; |
| @@ -1521,11 +1562,12 @@ class AcmSetBitRateOldApi : public ::testing::Test { |
| payload_type, frame_size_samples); |
| } |
| - // Runs the test. SetUpSender() and RegisterSendCodec() must have been called |
| - // before calling this method. |
| - void Run(int target_bitrate_bps, int expected_total_bits) { |
| - ASSERT_TRUE(send_test_->acm()); |
| - send_test_->acm()->SetBitRate(target_bitrate_bps); |
| + bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder, |
| + int payload_type) { |
| + return send_test_->RegisterExternalCodec(external_speech_encoder); |
| + } |
| + |
| + void RunInner(int expected_total_bits) { |
| int nr_bytes = 0; |
| while (std::unique_ptr<test::Packet> next_packet = |
| send_test_->NextPacket()) { |
| @@ -1550,6 +1592,26 @@ class AcmSetBitRateOldApi : public ::testing::Test { |
| std::unique_ptr<test::InputAudioFile> audio_source_; |
| }; |
| +class AcmSetBitRateOldApi : public AcmSetBitRateTest { |
| + protected: |
| + // Runs the test. SetUpSender() must have been called and a codec must be set |
| + // up before calling this method. |
| + void Run(int target_bitrate_bps, int expected_total_bits) { |
| + ASSERT_TRUE(send_test_->acm()); |
| + send_test_->acm()->SetBitRate(target_bitrate_bps); |
| + RunInner(expected_total_bits); |
| + } |
| +}; |
| + |
| +class AcmSetBitRateNewApi : public AcmSetBitRateTest { |
| + protected: |
| + // Runs the test. SetUpSender() must have been called and a codec must be set |
| + // up before calling this method. |
| + void Run(int expected_total_bits) { |
| + RunInner(expected_total_bits); |
| + } |
| +}; |
| + |
| TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_10kbps) { |
| ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); |
| #if defined(WEBRTC_ANDROID) |
| @@ -1568,18 +1630,56 @@ TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_50kbps) { |
| #endif // WEBRTC_ANDROID |
| } |
| + |
| // The result on the Android platforms is inconsistent for this test case. |
| // On android_rel the result is different from android and android arm64 rel. |
| #if defined(WEBRTC_ANDROID) |
| #define MAYBE_Opus_48khz_20ms_100kbps DISABLED_Opus_48khz_20ms_100kbps |
| +#define MAYBE_OpusFromFormat_48khz_20ms_100kbps \ |
| + DISABLED_OpusFromFormat_48khz_20ms_100kbps |
| #else |
| #define MAYBE_Opus_48khz_20ms_100kbps Opus_48khz_20ms_100kbps |
| +#define MAYBE_OpusFromFormat_48khz_20ms_100kbps \ |
| + OpusFromFormat_48khz_20ms_100kbps |
| #endif |
| TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_100kbps) { |
| ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); |
| Run(100000, 100888); |
| } |
| +TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_10kbps) { |
| + std::unique_ptr<AudioEncoder> encoder(new AudioEncoderOpus( |
| + 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "10000"}}))); |
| + ASSERT_TRUE(SetUpSender()); |
| + ASSERT_TRUE(RegisterExternalSendCodec(encoder.get(), 107)); |
| +#if defined(WEBRTC_ANDROID) |
| + RunInner(9288); |
| +#else |
| + RunInner(9024); |
| +#endif // WEBRTC_ANDROID |
| +} |
| + |
| +TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_50kbps) { |
| + std::unique_ptr<AudioEncoder> encoder(new AudioEncoderOpus( |
| + 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "50000"}}))); |
| + ASSERT_TRUE(SetUpSender()); |
| + ASSERT_TRUE(RegisterExternalSendCodec(encoder.get(), 107)); |
| +#if defined(WEBRTC_ANDROID) |
| + RunInner(47960); |
| +#else |
| + RunInner(49544); |
| +#endif // WEBRTC_ANDROID |
| +} |
| + |
| +TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_100kbps) { |
| + std::unique_ptr<AudioEncoder> encoder(new AudioEncoderOpus( |
| + 107, |
| + SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "100000"}}))); |
| + ASSERT_TRUE(SetUpSender()); |
| + ASSERT_TRUE(RegisterExternalSendCodec(encoder.get(), 107)); |
| + RunInner(100888); |
| +} |
| + |
| // These next 2 tests ensure that the SetBitRate function has no effect on PCM |
| TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_8kbps) { |
| ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); |