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 7515903bcb1e63e0cd8698b8e6b41d5627c5f272..98569a6aeb887db3d5f1ed9d50c5735fb89c69cd 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" |
@@ -1266,6 +1267,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)); |
@@ -1460,8 +1463,10 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_G722_stereo_20ms) { |
#if WEBRTC_OPUS_SUPPORT_120MS_PTIME |
#define MAYBE_Opus_stereo_20ms DISABLED_Opus_stereo_20ms |
+#define MAYBE_OpusFromFormat_stereo_20ms DISABLED_OpusFromFormat_stereo_20ms |
#else |
#define MAYBE_Opus_stereo_20ms Opus_stereo_20ms |
+#define MAYBE_OpusFromFormat_stereo_20ms OpusFromFormat_stereo_20ms |
#endif |
TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms) { |
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); |
@@ -1478,10 +1483,30 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms) { |
50, test::AcmReceiveTestOldApi::kStereoOutput); |
} |
+TEST_F(AcmSenderBitExactnessNewApi, MAYBE_OpusFromFormat_stereo_20ms) { |
+ const SdpAudioFormat kOpusFormat("opus", 48000, 2, {{"stereo", "1"}}); |
+ AudioEncoderOpus encoder(120, kOpusFormat); |
+ ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(&encoder, 120)); |
+ Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( |
+ "855041f2490b887302bce9d544731849", |
+ "855041f2490b887302bce9d544731849", |
+ "9692eede45638eb425e0daf9c75b5c7a", |
+ "86d3552bb3492247f965cdd0e88a1c82"), |
+ AcmReceiverBitExactnessOldApi::PlatformChecksum( |
+ "d781cce1ab986b618d0da87226cdde30", |
+ "d781cce1ab986b618d0da87226cdde30", |
+ "8d6782b905c3230d4b0e3e83e1fc3439", |
+ "798347a685fac7d0c2d8f748ffe66881"), |
+ 50, test::AcmReceiveTestOldApi::kStereoOutput); |
+} |
+ |
#if WEBRTC_OPUS_SUPPORT_120MS_PTIME |
#define MAYBE_Opus_stereo_20ms_voip DISABLED_Opus_stereo_20ms_voip |
+#define MAYBE_OpusFromFormat_stereo_20ms_voip \ |
+ DISABLED_OpusFromFormat_stereo_20ms_voip |
#else |
#define MAYBE_Opus_stereo_20ms_voip Opus_stereo_20ms_voip |
+#define MAYBE_OpusFromFormat_stereo_20ms_voip OpusFromFormat_stereo_20ms_voip |
#endif |
TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms_voip) { |
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); |
@@ -1500,9 +1525,28 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms_voip) { |
50, test::AcmReceiveTestOldApi::kStereoOutput); |
} |
+TEST_F(AcmSenderBitExactnessNewApi, MAYBE_OpusFromFormat_stereo_20ms_voip) { |
+ const SdpAudioFormat kOpusFormat("opus", 48000, 2, {{"stereo", "1"}}); |
+ AudioEncoderOpus encoder(120, kOpusFormat); |
+ ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(&encoder, 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; |
@@ -1532,11 +1576,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()) { |
@@ -1561,10 +1606,31 @@ 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); } |
+}; |
+ |
#if WEBRTC_OPUS_SUPPORT_120MS_PTIME |
#define MAYBE_Opus_48khz_20ms_10kbps DISABLED_Opus_48khz_20ms_10kbps |
+#define MAYBE_OpusFromFormat_48khz_20ms_10kbps \ |
+ DISABLED_OpusFromFormat_48khz_20ms_10kbps |
#else |
#define MAYBE_Opus_48khz_20ms_10kbps Opus_48khz_20ms_10kbps |
+#define MAYBE_OpusFromFormat_48khz_20ms_10kbps OpusFromFormat_48khz_20ms_10kbps |
#endif |
TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_10kbps) { |
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); |
@@ -1575,10 +1641,25 @@ TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_10kbps) { |
#endif // WEBRTC_ANDROID |
} |
+TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_10kbps) { |
+ AudioEncoderOpus encoder( |
+ 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "10000"}})); |
+ ASSERT_TRUE(SetUpSender()); |
+ ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 107)); |
+#if defined(WEBRTC_ANDROID) |
+ RunInner(9288); |
+#else |
+ RunInner(9024); |
+#endif // WEBRTC_ANDROID |
+} |
+ |
#if WEBRTC_OPUS_SUPPORT_120MS_PTIME |
#define MAYBE_Opus_48khz_20ms_50kbps DISABLED_Opus_48khz_20ms_50kbps |
+#define MAYBE_OpusFromFormat_48khz_20ms_50kbps \ |
+ DISABLED_OpusFromFormat_48khz_20ms_50kbps |
#else |
#define MAYBE_Opus_48khz_20ms_50kbps Opus_48khz_20ms_50kbps |
+#define MAYBE_OpusFromFormat_48khz_20ms_50kbps OpusFromFormat_48khz_20ms_50kbps |
#endif |
TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_50kbps) { |
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); |
@@ -1589,18 +1670,42 @@ TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_50kbps) { |
#endif // WEBRTC_ANDROID |
} |
+TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_50kbps) { |
+ AudioEncoderOpus encoder( |
+ 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "50000"}})); |
+ ASSERT_TRUE(SetUpSender()); |
+ ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 107)); |
+#if defined(WEBRTC_ANDROID) |
+ RunInner(47960); |
+#else |
+ RunInner(49544); |
+#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) || WEBRTC_OPUS_SUPPORT_120MS_PTIME |
#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, MAYBE_OpusFromFormat_48khz_20ms_100kbps) { |
+ AudioEncoderOpus encoder( |
+ 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "100000"}})); |
+ ASSERT_TRUE(SetUpSender()); |
+ ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 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)); |