AudioCodingModuleTest.TwoWayCommunication: Don't let the ACM create encoders
It will soon lose the ability to do so. Bug: webrtc:8396 Change-Id: I7d8e1549c44628fc9bdf2480468a0f1d3ae812f2 Reviewed-on: https://webrtc-review.googlesource.com/102062 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24853}
This commit is contained in:
@ -1330,6 +1330,7 @@ if (rtc_include_tests) {
|
||||
"..:module_api",
|
||||
"../..:webrtc_common",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../../api/audio_codecs/isac:audio_encoder_isac_float",
|
||||
|
@ -21,8 +21,8 @@
|
||||
#endif
|
||||
|
||||
#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/test/PCMFile.h"
|
||||
#include "modules/audio_coding/test/utility.h"
|
||||
#include "test/gtest.h"
|
||||
@ -59,34 +59,31 @@ TwoWayCommunication::~TwoWayCommunication() {
|
||||
_outFileRefB.Close();
|
||||
}
|
||||
|
||||
void TwoWayCommunication::SetUpAutotest() {
|
||||
CodecInst codecInst_A;
|
||||
CodecInst codecInst_B;
|
||||
CodecInst dummyCodec;
|
||||
|
||||
EXPECT_EQ(0, _acmA->Codec("ISAC", &codecInst_A, 16000, 1));
|
||||
EXPECT_EQ(0, _acmB->Codec("L16", &codecInst_B, 8000, 1));
|
||||
EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec));
|
||||
|
||||
void TwoWayCommunication::SetUpAutotest(
|
||||
AudioEncoderFactory* const encoder_factory,
|
||||
const SdpAudioFormat& format1,
|
||||
const int payload_type1,
|
||||
const SdpAudioFormat& format2,
|
||||
const int payload_type2) {
|
||||
//--- Set A codecs
|
||||
EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
|
||||
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(codecInst_B.pltype,
|
||||
CodecInstToSdp(codecInst_B)));
|
||||
_acmA->SetEncoder(
|
||||
encoder_factory->MakeAudioEncoder(payload_type1, format1, absl::nullopt));
|
||||
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(payload_type2, format2));
|
||||
|
||||
//--- Set ref-A codecs
|
||||
EXPECT_GT(_acmRefA->RegisterSendCodec(codecInst_A), -1);
|
||||
EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(codecInst_B.pltype,
|
||||
CodecInstToSdp(codecInst_B)));
|
||||
_acmRefA->SetEncoder(
|
||||
encoder_factory->MakeAudioEncoder(payload_type1, format1, absl::nullopt));
|
||||
EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(payload_type2, format2));
|
||||
|
||||
//--- Set B codecs
|
||||
EXPECT_GT(_acmB->RegisterSendCodec(codecInst_B), -1);
|
||||
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(codecInst_A.pltype,
|
||||
CodecInstToSdp(codecInst_A)));
|
||||
_acmB->SetEncoder(
|
||||
encoder_factory->MakeAudioEncoder(payload_type2, format2, absl::nullopt));
|
||||
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(payload_type1, format1));
|
||||
|
||||
//--- Set ref-B codecs
|
||||
EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
|
||||
EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(codecInst_A.pltype,
|
||||
CodecInstToSdp(codecInst_A)));
|
||||
_acmRefB->SetEncoder(
|
||||
encoder_factory->MakeAudioEncoder(payload_type2, format2, absl::nullopt));
|
||||
EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(payload_type1, format1));
|
||||
|
||||
uint16_t frequencyHz;
|
||||
|
||||
@ -133,7 +130,15 @@ void TwoWayCommunication::SetUpAutotest() {
|
||||
}
|
||||
|
||||
void TwoWayCommunication::Perform() {
|
||||
SetUpAutotest();
|
||||
const SdpAudioFormat format1("ISAC", 16000, 1);
|
||||
const SdpAudioFormat format2("L16", 8000, 1);
|
||||
constexpr int payload_type1 = 17, payload_type2 = 18;
|
||||
|
||||
auto encoder_factory = CreateBuiltinAudioEncoderFactory();
|
||||
|
||||
SetUpAutotest(encoder_factory.get(), format1, payload_type1, format2,
|
||||
payload_type2);
|
||||
|
||||
unsigned int msecPassed = 0;
|
||||
unsigned int secPassed = 0;
|
||||
|
||||
@ -142,9 +147,6 @@ void TwoWayCommunication::Perform() {
|
||||
|
||||
AudioFrame audioFrame;
|
||||
|
||||
auto codecInst_B = _acmB->SendCodec();
|
||||
ASSERT_TRUE(codecInst_B);
|
||||
|
||||
// In the following loop we tests that the code can handle misuse of the APIs.
|
||||
// In the middle of a session with data flowing between two sides, called A
|
||||
// and B, APIs will be called, and the code should continue to run, and be
|
||||
@ -180,7 +182,8 @@ void TwoWayCommunication::Perform() {
|
||||
}
|
||||
// Re-register send codec on side B.
|
||||
if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
|
||||
EXPECT_EQ(0, _acmB->RegisterSendCodec(*codecInst_B));
|
||||
_acmB->SetEncoder(encoder_factory->MakeAudioEncoder(
|
||||
payload_type2, format2, absl::nullopt));
|
||||
EXPECT_TRUE(_acmB->SendCodec());
|
||||
}
|
||||
// Initialize receiver on side A.
|
||||
@ -188,8 +191,7 @@ void TwoWayCommunication::Perform() {
|
||||
EXPECT_EQ(0, _acmA->InitializeReceiver());
|
||||
// Re-register codec on side A.
|
||||
if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
|
||||
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(
|
||||
codecInst_B->pltype, CodecInstToSdp(*codecInst_B)));
|
||||
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(payload_type2, format2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/audio_codecs/audio_encoder_factory.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "modules/audio_coding/test/ACMTest.h"
|
||||
#include "modules/audio_coding/test/Channel.h"
|
||||
@ -29,7 +31,11 @@ class TwoWayCommunication : public ACMTest {
|
||||
void Perform();
|
||||
|
||||
private:
|
||||
void SetUpAutotest();
|
||||
void SetUpAutotest(AudioEncoderFactory* const encoder_factory,
|
||||
const SdpAudioFormat& format1,
|
||||
const int payload_type1,
|
||||
const SdpAudioFormat& format2,
|
||||
const int payload_type2);
|
||||
|
||||
std::unique_ptr<AudioCodingModule> _acmA;
|
||||
std::unique_ptr<AudioCodingModule> _acmB;
|
||||
|
Reference in New Issue
Block a user