Break apart AudioCodingModule and AcmReceiver
This change makes AudioCodingModule a pure sender and AcmReceiver a pure
receiver.
The Config struct is in practice no longer used by AudioCodingModule,
so a new definition is included in AcmReceiver. The old definition
remains in AudioCodingModule while downstream clients are being
updated.
Bug: webrtc:14867
Change-Id: If0d0b4214c5aa278cf6c85c5b62c6da644de20e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291533
Reviewed-by: Tomas Lundqvist <tomasl@google.com>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39244}
diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc
index 9f9c4aa..014a1d2 100644
--- a/modules/audio_coding/test/EncodeDecodeTest.cc
+++ b/modules/audio_coding/test/EncodeDecodeTest.cc
@@ -102,34 +102,32 @@
: _playoutLengthSmpls(kWebRtc10MsPcmAudio),
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) {}
-void Receiver::Setup(AudioCodingModule* acm,
+void Receiver::Setup(acm2::AcmReceiver* acm_receiver,
RTPStream* rtpStream,
absl::string_view out_file_name,
size_t channels,
int file_num) {
- EXPECT_EQ(0, acm->InitializeReceiver());
-
if (channels == 1) {
- acm->SetReceiveCodecs({{107, {"L16", 8000, 1}},
- {108, {"L16", 16000, 1}},
- {109, {"L16", 32000, 1}},
- {0, {"PCMU", 8000, 1}},
- {8, {"PCMA", 8000, 1}},
- {102, {"ILBC", 8000, 1}},
- {9, {"G722", 8000, 1}},
- {120, {"OPUS", 48000, 2}},
- {13, {"CN", 8000, 1}},
- {98, {"CN", 16000, 1}},
- {99, {"CN", 32000, 1}}});
+ acm_receiver->SetCodecs({{107, {"L16", 8000, 1}},
+ {108, {"L16", 16000, 1}},
+ {109, {"L16", 32000, 1}},
+ {0, {"PCMU", 8000, 1}},
+ {8, {"PCMA", 8000, 1}},
+ {102, {"ILBC", 8000, 1}},
+ {9, {"G722", 8000, 1}},
+ {120, {"OPUS", 48000, 2}},
+ {13, {"CN", 8000, 1}},
+ {98, {"CN", 16000, 1}},
+ {99, {"CN", 32000, 1}}});
} else {
ASSERT_EQ(channels, 2u);
- acm->SetReceiveCodecs({{111, {"L16", 8000, 2}},
- {112, {"L16", 16000, 2}},
- {113, {"L16", 32000, 2}},
- {110, {"PCMU", 8000, 2}},
- {118, {"PCMA", 8000, 2}},
- {119, {"G722", 8000, 2}},
- {120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
+ acm_receiver->SetCodecs({{111, {"L16", 8000, 2}},
+ {112, {"L16", 16000, 2}},
+ {113, {"L16", 32000, 2}},
+ {110, {"PCMU", 8000, 2}},
+ {118, {"PCMA", 8000, 2}},
+ {119, {"G722", 8000, 2}},
+ {120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
}
int playSampFreq;
@@ -146,7 +144,7 @@
_realPayloadSizeBytes = 0;
_playoutBuffer = new int16_t[kWebRtc10MsPcmAudio];
_frequency = playSampFreq;
- _acm = acm;
+ _acm_receiver = acm_receiver;
_firstTime = true;
}
@@ -171,8 +169,9 @@
}
}
- EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
- _rtpHeader));
+ EXPECT_EQ(0, _acm_receiver->InsertPacket(
+ _rtpHeader, rtc::ArrayView<const uint8_t>(
+ _incomingPayload, _realPayloadSizeBytes)));
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
_payloadSizeBytes, &_nextTime);
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
@@ -185,7 +184,7 @@
bool Receiver::PlayoutData() {
AudioFrame audioFrame;
bool muted;
- int32_t ok = _acm->PlayoutData10Ms(_frequency, &audioFrame, &muted);
+ int32_t ok = _acm_receiver->GetAudio(_frequency, &audioFrame, &muted);
if (muted) {
ADD_FAILURE();
return false;
@@ -240,8 +239,7 @@
int file_num = 0;
for (const auto& send_codec : send_codecs) {
RTPFile rtpFile;
- std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create(
- AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory())));
+ std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create());
std::string fileName = webrtc::test::TempFilename(
webrtc::test::OutputPath(), "encode_decode_rtp");
@@ -256,8 +254,12 @@
rtpFile.Open(fileName.c_str(), "rb");
rtpFile.ReadHeader();
+ std::unique_ptr<acm2::AcmReceiver> acm_receiver(
+ std::make_unique<acm2::AcmReceiver>(
+ acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory())));
Receiver receiver;
- receiver.Setup(acm.get(), &rtpFile, "encodeDecode_out", 1, file_num);
+ receiver.Setup(acm_receiver.get(), &rtpFile, "encodeDecode_out", 1,
+ file_num);
receiver.Run();
receiver.Teardown();
rtpFile.Close();