From 658a552fd5f38ece5e918492bc041c99d4092e3a Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Wed, 15 Aug 2018 15:20:49 +0200 Subject: [PATCH] Audio encoder tests: Create audio encoders the new way Specifically, don't expect the ACM to be able to create encoders; we have to give it an encoder that we make ourselves. Bug: webrtc:8396 Change-Id: I032b12f3813af6ac3ea0dfb688006899dffe4855 Reviewed-on: https://webrtc-review.googlesource.com/94150 Reviewed-by: Ivo Creusen Commit-Queue: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#24323} --- modules/audio_coding/test/EncodeDecodeTest.cc | 4 +++- modules/audio_coding/test/PacketLossTest.cc | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc index 4e16dc8989..a8c405357b 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/modules/audio_coding/test/EncodeDecodeTest.cc @@ -16,6 +16,7 @@ #include // no-presubmit-check TODO(webrtc:8982) #include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/codecs/audio_format_conversion.h" #include "modules/audio_coding/include/audio_coding_module.h" @@ -74,7 +75,8 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream, sendCodec.channels = channels; - EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec)); + acm->SetEncoder(CreateBuiltinAudioEncoderFactory()->MakeAudioEncoder( + sendCodec.pltype, CodecInstToSdp(sendCodec), absl::nullopt)); _packetization = new TestPacketization(rtpStream, sendCodec.plfreq); EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization)); diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc index c5cb3963b3..da6ea1c54a 100644 --- a/modules/audio_coding/test/PacketLossTest.cc +++ b/modules/audio_coding/test/PacketLossTest.cc @@ -97,10 +97,13 @@ void SenderWithFEC::Setup(AudioCodingModule* acm, } bool SenderWithFEC::SetFEC(bool enable_fec) { - if (_acm->SetCodecFEC(enable_fec) == 0) { - return true; - } - return false; + bool success = false; + _acm->ModifyEncoder([&](std::unique_ptr* enc) { + if (*enc && (*enc)->SetFec(enable_fec)) { + success = true; + } + }); + return success; } bool SenderWithFEC::SetPacketLossRate(int expected_loss_rate) {