diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index 25a554a453..d5485637e1 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -834,187 +834,6 @@ TEST_F(AcmReRegisterIsacMtTestOldApi, MAYBE_DoTest) { // See https://code.google.com/p/webrtc/issues/detail?id=4752 for details. #if !defined(WEBRTC_IOS) -class AcmReceiverBitExactnessOldApi : public ::testing::Test { - protected: - struct ExternalDecoder { - int rtp_payload_type; - AudioDecoder* external_decoder; - int sample_rate_hz; - int num_channels; - std::string name; - }; - - void Run(int output_freq_hz, const std::string& checksum_ref) { - Run(output_freq_hz, checksum_ref, CreateBuiltinAudioDecoderFactory(), - [](AudioCodingModule*) {}); - } - - void Run(int output_freq_hz, - const std::string& checksum_ref, - rtc::scoped_refptr decoder_factory, - rtc::FunctionView decoder_reg) { - const std::string input_file_name = - webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); - std::unique_ptr packet_source( - test::RtpFileSource::Create(input_file_name)); -#ifdef WEBRTC_ANDROID - // Filter out iLBC and iSAC-swb since they are not supported on Android. - packet_source->FilterOutPayloadType(102); // iLBC. - packet_source->FilterOutPayloadType(104); // iSAC-swb. -#endif - - test::AudioChecksum checksum; - const std::string output_file_name = - webrtc::test::OutputPath() + - ::testing::UnitTest::GetInstance() - ->current_test_info() - ->test_case_name() + - "_" + ::testing::UnitTest::GetInstance()->current_test_info()->name() + - "_output.wav"; - test::OutputWavFile output_file(output_file_name, output_freq_hz, 1); - test::AudioSinkFork output(&checksum, &output_file); - - test::AcmReceiveTestOldApi test( - packet_source.get(), &output, output_freq_hz, - test::AcmReceiveTestOldApi::kArbitraryChannels, - std::move(decoder_factory)); - ASSERT_NO_FATAL_FAILURE(test.RegisterNetEqTestCodecs()); - decoder_reg(test.get_acm()); - test.Run(); - - std::string checksum_string = checksum.Finish(); - EXPECT_EQ(checksum_ref, checksum_string); - - // Delete the output file. - remove(output_file_name.c_str()); - } -}; - -#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ - defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_LINUX) && \ - defined(WEBRTC_ARCH_X86_64) -TEST_F(AcmReceiverBitExactnessOldApi, 8kHzOutput) { - std::string checksum_reference = GetCPUInfo(kAVX2) != 0 - ? "f531f3b7dabe96d9e928dece1d3a340b" - : "4710c99559aec2f9f02a983ba2146f2d"; - Run(/*output_freq_hz=*/8000, checksum_reference); -} - -TEST_F(AcmReceiverBitExactnessOldApi, 16kHzOutput) { - std::string checksum_reference = GetCPUInfo(kAVX2) != 0 - ? "c68d7ee520bb35b6d053e017b37bc2b3" - : "70b3217df49834b7093c631531068bd0"; - Run(/*output_freq_hz=*/16000, checksum_reference); -} - -TEST_F(AcmReceiverBitExactnessOldApi, 32kHzOutput) { - std::string checksum_reference = GetCPUInfo(kAVX2) != 0 - ? "dc790e447442ff6105467f29ab7315ae" - : "2679e4e596e33259228c62df545eb635"; - Run(/*output_freq_hz=*/32000, checksum_reference); -} - -TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutput) { - std::string checksum_reference = GetCPUInfo(kAVX2) != 0 - ? "d118436e154a976009171c4d451d5574" - : "f0148c5ef84e74e019ac7057af839102"; - Run(/*output_freq_hz=*/48000, checksum_reference); -} - -TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutputExternalDecoder) { - class ADFactory : public AudioDecoderFactory { - public: - ADFactory() - : mock_decoder_(new MockAudioDecoder()), - pcmu_decoder_(1), - decode_forwarder_(&pcmu_decoder_), - fact_(CreateBuiltinAudioDecoderFactory()) { - // Set expectations on the mock decoder and also delegate the calls to - // the real decoder. - EXPECT_CALL(*mock_decoder_, SampleRateHz()) - .Times(AtLeast(1)) - .WillRepeatedly( - Invoke(&pcmu_decoder_, &AudioDecoderPcmU::SampleRateHz)); - EXPECT_CALL(*mock_decoder_, Channels()) - .Times(AtLeast(1)) - .WillRepeatedly(Invoke(&pcmu_decoder_, &AudioDecoderPcmU::Channels)); - EXPECT_CALL(*mock_decoder_, DecodeInternal(_, _, _, _, _)) - .Times(AtLeast(1)) - .WillRepeatedly(Invoke(&decode_forwarder_, &DecodeForwarder::Decode)); - EXPECT_CALL(*mock_decoder_, HasDecodePlc()) - .Times(AtLeast(1)) - .WillRepeatedly( - Invoke(&pcmu_decoder_, &AudioDecoderPcmU::HasDecodePlc)); - EXPECT_CALL(*mock_decoder_, PacketDuration(_, _)) - .Times(AtLeast(1)) - .WillRepeatedly( - Invoke(&pcmu_decoder_, &AudioDecoderPcmU::PacketDuration)); - EXPECT_CALL(*mock_decoder_, Die()); - } - std::vector GetSupportedDecoders() override { - return fact_->GetSupportedDecoders(); - } - bool IsSupportedDecoder(const SdpAudioFormat& format) override { - return format.name == "MockPCMu" ? true - : fact_->IsSupportedDecoder(format); - } - std::unique_ptr MakeAudioDecoder( - const SdpAudioFormat& format, - absl::optional codec_pair_id) override { - return format.name == "MockPCMu" - ? std::move(mock_decoder_) - : fact_->MakeAudioDecoder(format, codec_pair_id); - } - - private: - // Class intended to forward a call from a mock DecodeInternal to Decode on - // the real decoder's Decode. DecodeInternal for the real decoder isn't - // public. - class DecodeForwarder { - public: - explicit DecodeForwarder(AudioDecoder* decoder) : decoder_(decoder) {} - int Decode(const uint8_t* encoded, - size_t encoded_len, - int sample_rate_hz, - int16_t* decoded, - AudioDecoder::SpeechType* speech_type) { - return decoder_->Decode(encoded, encoded_len, sample_rate_hz, - decoder_->PacketDuration(encoded, encoded_len) * - decoder_->Channels() * sizeof(int16_t), - decoded, speech_type); - } - - private: - AudioDecoder* const decoder_; - }; - - std::unique_ptr mock_decoder_; - AudioDecoderPcmU pcmu_decoder_; - DecodeForwarder decode_forwarder_; - rtc::scoped_refptr fact_; // Fallback factory. - }; - - auto factory = rtc::make_ref_counted(); - std::string checksum_reference = GetCPUInfo(kAVX2) != 0 - ? "d118436e154a976009171c4d451d5574" - : "f0148c5ef84e74e019ac7057af839102"; - Run(48000, checksum_reference, factory, - [](AudioCodingModule* acm) { - acm->SetReceiveCodecs({{0, {"MockPCMu", 8000, 1}}, - {103, {"ISAC", 16000, 1}}, - {104, {"ISAC", 32000, 1}}, - {93, {"L16", 8000, 1}}, - {94, {"L16", 16000, 1}}, - {95, {"L16", 32000, 1}}, - {8, {"PCMA", 8000, 1}}, - {102, {"ILBC", 8000, 1}}, - {13, {"CN", 8000, 1}}, - {98, {"CN", 16000, 1}}, - {99, {"CN", 32000, 1}}}); - }); -} -#endif - // This test verifies bit exactness for the send-side of ACM. The test setup is // a chain of three different test classes: //