Delete method DecoderDatabase::RegisterPayload(...NetEqDecoder...)
Bug: webrtc:10185 Change-Id: I69ce40b1c7267b039cd1d2237c5d5bbae3a81875 Reviewed-on: https://webrtc-review.googlesource.com/c/116683 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26208}
This commit is contained in:
parent
0486f0914f
commit
0554368eed
@ -61,17 +61,6 @@ DecoderDatabase::DecoderInfo::DecoderInfo(
|
||||
DecoderDatabase::DecoderInfo::DecoderInfo(DecoderInfo&&) = default;
|
||||
DecoderDatabase::DecoderInfo::~DecoderInfo() = default;
|
||||
|
||||
bool DecoderDatabase::DecoderInfo::CanGetDecoder() const {
|
||||
if (subtype_ == Subtype::kNormal && !decoder_) {
|
||||
// TODO(ossu): Keep a check here for now, since a number of tests create
|
||||
// DecoderInfos without factories.
|
||||
RTC_DCHECK(factory_);
|
||||
return factory_->IsSupportedDecoder(audio_format_);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const {
|
||||
if (subtype_ != Subtype::kNormal) {
|
||||
// These are handled internally, so they have no AudioDecoder objects.
|
||||
@ -168,32 +157,6 @@ std::vector<int> DecoderDatabase::SetCodecs(
|
||||
return changed_payload_types;
|
||||
}
|
||||
|
||||
int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& name) {
|
||||
if (rtp_payload_type > 0x7F) {
|
||||
return kInvalidRtpPayloadType;
|
||||
}
|
||||
if (codec_type == NetEqDecoder::kDecoderArbitrary) {
|
||||
return kCodecNotSupported; // Only supported through InsertExternal.
|
||||
}
|
||||
const auto opt_format = NetEqDecoderToSdpAudioFormat(codec_type);
|
||||
if (!opt_format) {
|
||||
return kCodecNotSupported;
|
||||
}
|
||||
DecoderInfo info(*opt_format, codec_pair_id_, decoder_factory_, name);
|
||||
if (!info.CanGetDecoder()) {
|
||||
return kCodecNotSupported;
|
||||
}
|
||||
auto ret =
|
||||
decoders_.insert(std::make_pair(rtp_payload_type, std::move(info)));
|
||||
if (ret.second == false) {
|
||||
// Database already contains a decoder with type |rtp_payload_type|.
|
||||
return kDecoderExists;
|
||||
}
|
||||
return kOK;
|
||||
}
|
||||
|
||||
int DecoderDatabase::RegisterPayload(int rtp_payload_type,
|
||||
const SdpAudioFormat& audio_format) {
|
||||
if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) {
|
||||
|
||||
@ -53,10 +53,6 @@ class DecoderDatabase {
|
||||
DecoderInfo(DecoderInfo&&);
|
||||
~DecoderInfo();
|
||||
|
||||
// Was this info object created with a specification that allows us to
|
||||
// actually produce a decoder?
|
||||
bool CanGetDecoder() const;
|
||||
|
||||
// Get the AudioDecoder object, creating it first if necessary.
|
||||
AudioDecoder* GetDecoder() const;
|
||||
|
||||
@ -146,14 +142,6 @@ class DecoderDatabase {
|
||||
virtual std::vector<int> SetCodecs(
|
||||
const std::map<int, SdpAudioFormat>& codecs);
|
||||
|
||||
// Registers |rtp_payload_type| as a decoder of type |codec_type|. The |name|
|
||||
// is only used to populate the name field in the DecoderInfo struct in the
|
||||
// database, and can be arbitrary (including empty). Returns kOK on success;
|
||||
// otherwise an error code.
|
||||
virtual int RegisterPayload(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& name);
|
||||
|
||||
// Registers a decoder for the given payload type. Returns kOK on success;
|
||||
// otherwise an error code.
|
||||
virtual int RegisterPayload(int rtp_payload_type,
|
||||
|
||||
@ -36,17 +36,12 @@ TEST(DecoderDatabase, CreateAndDestroy) {
|
||||
TEST(DecoderDatabase, InsertAndRemove) {
|
||||
rtc::scoped_refptr<MockAudioDecoderFactory> factory(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*factory, IsSupportedDecoder(_))
|
||||
.WillOnce(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName));
|
||||
db.RegisterPayload(kPayloadType, SdpAudioFormat(kCodecName, 8000, 1)));
|
||||
EXPECT_EQ(1, db.Size());
|
||||
EXPECT_FALSE(db.Empty());
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType));
|
||||
@ -57,22 +52,13 @@ TEST(DecoderDatabase, InsertAndRemove) {
|
||||
TEST(DecoderDatabase, InsertAndRemoveAll) {
|
||||
rtc::scoped_refptr<MockAudioDecoderFactory> factory(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*factory, IsSupportedDecoder(_))
|
||||
.WillOnce(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}))
|
||||
.WillOnce(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcma", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const std::string kCodecName1 = "Robert\'); DROP TABLE Students;";
|
||||
const std::string kCodecName2 = "https://xkcd.com/327/";
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, kCodecName1));
|
||||
db.RegisterPayload(0, SdpAudioFormat(kCodecName1, 8000, 1)));
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(1, NetEqDecoder::kDecoderPCMa, kCodecName2));
|
||||
db.RegisterPayload(1, SdpAudioFormat(kCodecName2, 8000, 1)));
|
||||
EXPECT_EQ(2, db.Size());
|
||||
EXPECT_FALSE(db.Empty());
|
||||
db.RemoveAll();
|
||||
@ -83,11 +69,6 @@ TEST(DecoderDatabase, InsertAndRemoveAll) {
|
||||
TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
rtc::scoped_refptr<MockAudioDecoderFactory> factory(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*factory, IsSupportedDecoder(_))
|
||||
.WillOnce(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
auto* decoder = new MockAudioDecoder;
|
||||
EXPECT_CALL(*factory, MakeAudioDecoderMock(_, _, _))
|
||||
.WillOnce(Invoke([decoder](const SdpAudioFormat& format,
|
||||
@ -98,10 +79,10 @@ TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
}));
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
const std::string kCodecName = "pcmu";
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName));
|
||||
db.RegisterPayload(kPayloadType, SdpAudioFormat(kCodecName, 8000, 1)));
|
||||
const DecoderDatabase::DecoderInfo* info;
|
||||
info = db.GetDecoderInfo(kPayloadType);
|
||||
ASSERT_TRUE(info != NULL);
|
||||
@ -115,10 +96,8 @@ TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
TEST(DecoderDatabase, GetDecoder) {
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCM16B,
|
||||
kCodecName));
|
||||
db.RegisterPayload(kPayloadType, SdpAudioFormat("l16", 8000, 1)));
|
||||
AudioDecoder* dec = db.GetDecoder(kPayloadType);
|
||||
ASSERT_TRUE(dec != NULL);
|
||||
}
|
||||
@ -126,11 +105,6 @@ TEST(DecoderDatabase, GetDecoder) {
|
||||
TEST(DecoderDatabase, TypeTests) {
|
||||
rtc::scoped_refptr<MockAudioDecoderFactory> factory(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*factory, IsSupportedDecoder(_))
|
||||
.WillOnce(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadTypePcmU = 0;
|
||||
const uint8_t kPayloadTypeCng = 13;
|
||||
@ -140,16 +114,15 @@ TEST(DecoderDatabase, TypeTests) {
|
||||
// Load into database.
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadTypePcmU, NetEqDecoder::kDecoderPCMu, "pcmu"));
|
||||
db.RegisterPayload(kPayloadTypePcmU, SdpAudioFormat("pcmu", 8000, 1)));
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadTypeCng, NetEqDecoder::kDecoderCNGnb,
|
||||
"cng-nb"));
|
||||
db.RegisterPayload(kPayloadTypeCng, SdpAudioFormat("cn", 8000, 1)));
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadTypeDtmf,
|
||||
SdpAudioFormat("telephone-event", 8000, 1)));
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadTypeDtmf, NetEqDecoder::kDecoderAVT, "avt"));
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(kPayloadTypeRed, NetEqDecoder::kDecoderRED, "red"));
|
||||
db.RegisterPayload(kPayloadTypeRed, SdpAudioFormat("red", 8000, 1)));
|
||||
EXPECT_EQ(4, db.Size());
|
||||
// Test.
|
||||
EXPECT_FALSE(db.IsComfortNoise(kPayloadNotUsed));
|
||||
@ -169,19 +142,14 @@ TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
constexpr int kNumPayloads = 10;
|
||||
rtc::scoped_refptr<MockAudioDecoderFactory> factory(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*factory, IsSupportedDecoder(_))
|
||||
.Times(kNumPayloads)
|
||||
.WillRepeatedly(Invoke([](const SdpAudioFormat& format) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
// Load a number of payloads into the database. Payload types are 0, 1, ...,
|
||||
// while the decoder type is the same for all payload types (this does not
|
||||
// matter for the test).
|
||||
for (uint8_t payload_type = 0; payload_type < kNumPayloads; ++payload_type) {
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(payload_type, NetEqDecoder::kDecoderPCMu, ""));
|
||||
EXPECT_EQ(
|
||||
DecoderDatabase::kOK,
|
||||
db.RegisterPayload(payload_type, SdpAudioFormat("pcmu", 8000, 1)));
|
||||
}
|
||||
PacketList packet_list;
|
||||
for (int i = 0; i < kNumPayloads + 1; ++i) {
|
||||
@ -218,11 +186,11 @@ TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) {
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), absl::nullopt);
|
||||
// Load payload types.
|
||||
ASSERT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, "pcmu"));
|
||||
db.RegisterPayload(0, SdpAudioFormat("pcmu", 8000, 1)));
|
||||
ASSERT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(103, NetEqDecoder::kDecoderISAC, "isac"));
|
||||
db.RegisterPayload(103, SdpAudioFormat("isac", 16000, 1)));
|
||||
ASSERT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(13, NetEqDecoder::kDecoderCNGnb, "cng-nb"));
|
||||
db.RegisterPayload(13, SdpAudioFormat("cn", 8000, 1)));
|
||||
// Verify that no decoders are active from the start.
|
||||
EXPECT_EQ(NULL, db.GetActiveDecoder());
|
||||
EXPECT_EQ(NULL, db.GetActiveCngDecoder());
|
||||
|
||||
@ -167,14 +167,6 @@ class NetEq {
|
||||
// Replaces the current set of decoders with the given one.
|
||||
virtual void SetCodecs(const std::map<int, SdpAudioFormat>& codecs) = 0;
|
||||
|
||||
// Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the
|
||||
// information in the codec database. Returns 0 on success, -1 on failure.
|
||||
// The name is only used to provide information back to the caller about the
|
||||
// decoders. Hence, the name is arbitrary, and may be empty.
|
||||
virtual int RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& codec_name,
|
||||
uint8_t rtp_payload_type) = 0;
|
||||
|
||||
// Associates |rtp_payload_type| with the given codec, which NetEq will
|
||||
// instantiate when it needs it. Returns true iff successful.
|
||||
virtual bool RegisterPayloadType(int rtp_payload_type,
|
||||
|
||||
@ -29,17 +29,8 @@ class MockDecoderDatabase : public DecoderDatabase {
|
||||
MOCK_CONST_METHOD0(Empty, bool());
|
||||
MOCK_CONST_METHOD0(Size, int());
|
||||
MOCK_METHOD0(Reset, void());
|
||||
MOCK_METHOD3(RegisterPayload,
|
||||
int(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& name));
|
||||
MOCK_METHOD2(RegisterPayload,
|
||||
int(int rtp_payload_type, const SdpAudioFormat& audio_format));
|
||||
MOCK_METHOD4(InsertExternal,
|
||||
int(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& codec_name,
|
||||
AudioDecoder* decoder));
|
||||
MOCK_METHOD1(Remove, int(uint8_t rtp_payload_type));
|
||||
MOCK_METHOD0(RemoveAll, void());
|
||||
MOCK_CONST_METHOD1(GetDecoderInfo,
|
||||
|
||||
@ -77,8 +77,6 @@ absl::optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
|
||||
return SdpAudioFormat("cn", 32000, 1);
|
||||
case NetEqDecoder::kDecoderCNGswb48kHz:
|
||||
return SdpAudioFormat("cn", 48000, 1);
|
||||
case NetEqDecoder::kDecoderReplacementForTest:
|
||||
return SdpAudioFormat("replacement", 48000, 1);
|
||||
default:
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
@ -48,8 +48,6 @@ enum class NetEqDecoder {
|
||||
kDecoderArbitrary,
|
||||
kDecoderOpus,
|
||||
kDecoderOpus_2ch,
|
||||
// Used in NetEqTestFactory
|
||||
kDecoderReplacementForTest,
|
||||
};
|
||||
|
||||
absl::optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd);
|
||||
|
||||
@ -177,7 +177,7 @@ NetEqNetworkStatistics RunTest(int loss_cadence, std::string* checksum) {
|
||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"));
|
||||
AudioDecoderPlc dec(std::move(input_file), kSampleRateHz);
|
||||
// Masquerading as a PCM16b decoder.
|
||||
decoders[kPayloadType] = {NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16b_PLC"};
|
||||
decoders.emplace(kPayloadType, SdpAudioFormat("l16", 32000, 1));
|
||||
|
||||
// Output is simply a checksum calculator.
|
||||
auto output = absl::make_unique<AudioChecksumWithOutput>(checksum);
|
||||
|
||||
@ -236,20 +236,6 @@ void NetEqImpl::SetCodecs(const std::map<int, SdpAudioFormat>& codecs) {
|
||||
}
|
||||
}
|
||||
|
||||
int NetEqImpl::RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& name,
|
||||
uint8_t rtp_payload_type) {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
RTC_LOG(LS_VERBOSE) << "RegisterPayloadType "
|
||||
<< static_cast<int>(rtp_payload_type) << " "
|
||||
<< static_cast<int>(codec);
|
||||
if (decoder_database_->RegisterPayload(rtp_payload_type, codec, name) !=
|
||||
DecoderDatabase::kOK) {
|
||||
return kFail;
|
||||
}
|
||||
return kOK;
|
||||
}
|
||||
|
||||
bool NetEqImpl::RegisterPayloadType(int rtp_payload_type,
|
||||
const SdpAudioFormat& audio_format) {
|
||||
RTC_LOG(LS_VERBOSE) << "NetEqImpl::RegisterPayloadType: payload type "
|
||||
|
||||
@ -137,10 +137,6 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
|
||||
void SetCodecs(const std::map<int, SdpAudioFormat>& codecs) override;
|
||||
|
||||
int RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& codec_name,
|
||||
uint8_t rtp_payload_type) override;
|
||||
|
||||
bool RegisterPayloadType(int rtp_payload_type,
|
||||
const SdpAudioFormat& audio_format) override;
|
||||
|
||||
|
||||
@ -179,7 +179,7 @@ class NetEqImplTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
void TestDtmfPacket(NetEqDecoder decoder_type) {
|
||||
void TestDtmfPacket(int sample_rate_hz) {
|
||||
const size_t kPayloadLength = 4;
|
||||
const uint8_t kPayloadType = 110;
|
||||
const uint32_t kReceiveTime = 17;
|
||||
@ -195,8 +195,8 @@ class NetEqImplTest : public ::testing::Test {
|
||||
rtp_header.timestamp = 0x12345678;
|
||||
rtp_header.ssrc = 0x87654321;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
|
||||
decoder_type, "telephone-event", kPayloadType));
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(
|
||||
kPayloadType, SdpAudioFormat("telephone-event", sample_rate_hz, 1)));
|
||||
|
||||
// Insert first packet.
|
||||
EXPECT_EQ(NetEq::kOK,
|
||||
@ -263,16 +263,6 @@ TEST(NetEq, CreateAndDestroy) {
|
||||
delete neteq;
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, RegisterPayloadTypeNetEqDecoder) {
|
||||
CreateInstance();
|
||||
uint8_t rtp_payload_type = 0;
|
||||
NetEqDecoder codec_type = NetEqDecoder::kDecoderPCMu;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_CALL(*mock_decoder_database_,
|
||||
RegisterPayload(rtp_payload_type, codec_type, kCodecName));
|
||||
neteq_->RegisterPayloadType(codec_type, kCodecName, rtp_payload_type);
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, RegisterPayloadType) {
|
||||
CreateInstance();
|
||||
constexpr int rtp_payload_type = 0;
|
||||
@ -411,8 +401,8 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
||||
rtp_header.timestamp = 0x12345678;
|
||||
rtp_header.ssrc = 0x87654321;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
|
||||
NetEqDecoder::kDecoderPCM16B, "", kPayloadType));
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", 8000, 1)));
|
||||
|
||||
// Insert packets. The buffer should not flush.
|
||||
for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) {
|
||||
@ -434,19 +424,19 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, TestDtmfPacketAVT) {
|
||||
TestDtmfPacket(NetEqDecoder::kDecoderAVT);
|
||||
TestDtmfPacket(8000);
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, TestDtmfPacketAVT16kHz) {
|
||||
TestDtmfPacket(NetEqDecoder::kDecoderAVT16kHz);
|
||||
TestDtmfPacket(16000);
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, TestDtmfPacketAVT32kHz) {
|
||||
TestDtmfPacket(NetEqDecoder::kDecoderAVT32kHz);
|
||||
TestDtmfPacket(32000);
|
||||
}
|
||||
|
||||
TEST_F(NetEqImplTest, TestDtmfPacketAVT48kHz) {
|
||||
TestDtmfPacket(NetEqDecoder::kDecoderAVT48kHz);
|
||||
TestDtmfPacket(48000);
|
||||
}
|
||||
|
||||
// This test verifies that timestamps propagate from the incoming packets
|
||||
@ -671,8 +661,8 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) {
|
||||
EXPECT_EQ(AudioFrame::kPLC, output.speech_type_);
|
||||
|
||||
// Register the payload type.
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
|
||||
NetEqDecoder::kDecoderPCM16B, "", kPayloadType));
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", 8000, 1)));
|
||||
|
||||
// Insert 10 packets.
|
||||
for (size_t i = 0; i < 10; ++i) {
|
||||
@ -954,8 +944,8 @@ TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) {
|
||||
rtp_header.timestamp = 0x12345678;
|
||||
rtp_header.ssrc = 0x87654321;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
|
||||
NetEqDecoder::kDecoderPCM16B, "", kPayloadType));
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", 8000, 1)));
|
||||
|
||||
// Insert packets until the buffer flushes.
|
||||
for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) {
|
||||
@ -1321,8 +1311,8 @@ TEST_F(NetEqImplTest, EnableRtxHandling) {
|
||||
rtp_header.timestamp = 0x12345678;
|
||||
rtp_header.ssrc = 0x87654321;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(
|
||||
NetEqDecoder::kDecoderPCM16B, "", kPayloadType));
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", 8000, 1)));
|
||||
EXPECT_EQ(NetEq::kOK,
|
||||
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||
AudioFrame output;
|
||||
|
||||
@ -89,51 +89,12 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
|
||||
const std::string file_name =
|
||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
||||
input_file_.reset(new test::InputAudioFile(file_name));
|
||||
NetEqDecoder mono_decoder;
|
||||
NetEqDecoder multi_decoder;
|
||||
switch (sample_rate_hz_) {
|
||||
case 8000:
|
||||
mono_decoder = NetEqDecoder::kDecoderPCM16B;
|
||||
if (num_channels_ == 2) {
|
||||
multi_decoder = NetEqDecoder::kDecoderPCM16B_2ch;
|
||||
} else if (num_channels_ == 5) {
|
||||
multi_decoder = NetEqDecoder::kDecoderPCM16B_5ch;
|
||||
} else {
|
||||
FAIL() << "Only 2 and 5 channels supported for 8000 Hz.";
|
||||
}
|
||||
break;
|
||||
case 16000:
|
||||
mono_decoder = NetEqDecoder::kDecoderPCM16Bwb;
|
||||
if (num_channels_ == 2) {
|
||||
multi_decoder = NetEqDecoder::kDecoderPCM16Bwb_2ch;
|
||||
} else {
|
||||
FAIL() << "More than 2 channels is not supported for 16000 Hz.";
|
||||
}
|
||||
break;
|
||||
case 32000:
|
||||
mono_decoder = NetEqDecoder::kDecoderPCM16Bswb32kHz;
|
||||
if (num_channels_ == 2) {
|
||||
multi_decoder = NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch;
|
||||
} else {
|
||||
FAIL() << "More than 2 channels is not supported for 32000 Hz.";
|
||||
}
|
||||
break;
|
||||
case 48000:
|
||||
mono_decoder = NetEqDecoder::kDecoderPCM16Bswb48kHz;
|
||||
if (num_channels_ == 2) {
|
||||
multi_decoder = NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch;
|
||||
} else {
|
||||
FAIL() << "More than 2 channels is not supported for 48000 Hz.";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FAIL() << "We shouldn't get here.";
|
||||
}
|
||||
ASSERT_EQ(NetEq::kOK, neteq_mono_->RegisterPayloadType(mono_decoder, "mono",
|
||||
kPayloadTypeMono));
|
||||
ASSERT_EQ(NetEq::kOK,
|
||||
neteq_->RegisterPayloadType(multi_decoder, "multi-channel",
|
||||
kPayloadTypeMulti));
|
||||
RTC_CHECK_GE(num_channels_, 2);
|
||||
ASSERT_TRUE(neteq_mono_->RegisterPayloadType(
|
||||
kPayloadTypeMono, SdpAudioFormat("l16", sample_rate_hz_, 1)));
|
||||
ASSERT_TRUE(neteq_->RegisterPayloadType(
|
||||
kPayloadTypeMulti,
|
||||
SdpAudioFormat("l16", sample_rate_hz_, num_channels_)));
|
||||
}
|
||||
|
||||
virtual void TearDown() {}
|
||||
|
||||
@ -131,10 +131,8 @@ void AddMessage(FILE* file,
|
||||
void LoadDecoders(webrtc::NetEq* neteq) {
|
||||
ASSERT_EQ(true,
|
||||
neteq->RegisterPayloadType(0, SdpAudioFormat("pcmu", 8000, 1)));
|
||||
// Use non-SdpAudioFormat argument when registering PCMa, so that we get test
|
||||
// coverage for that as well.
|
||||
ASSERT_EQ(0, neteq->RegisterPayloadType(webrtc::NetEqDecoder::kDecoderPCMa,
|
||||
"pcma", 8));
|
||||
ASSERT_EQ(true,
|
||||
neteq->RegisterPayloadType(8, SdpAudioFormat("pcma", 8000, 1)));
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
ASSERT_EQ(true,
|
||||
neteq->RegisterPayloadType(102, SdpAudioFormat("ilbc", 8000, 1)));
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <utility> // pair
|
||||
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "modules/audio_coding/neteq/mock/mock_decoder_database.h"
|
||||
#include "modules/audio_coding/neteq/decoder_database.h"
|
||||
#include "modules/audio_coding/neteq/packet.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "test/gtest.h"
|
||||
@ -300,10 +300,11 @@ TEST(RedPayloadSplitter, CheckRedPayloads) {
|
||||
// do its job.
|
||||
DecoderDatabase decoder_database(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, absl::nullopt);
|
||||
decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb, "cng-nb");
|
||||
decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu");
|
||||
decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT, "avt");
|
||||
decoder_database.RegisterPayload(3, NetEqDecoder::kDecoderILBC, "ilbc");
|
||||
decoder_database.RegisterPayload(0, SdpAudioFormat("cn", 8000, 1));
|
||||
decoder_database.RegisterPayload(1, SdpAudioFormat("pcmu", 8000, 1));
|
||||
decoder_database.RegisterPayload(2,
|
||||
SdpAudioFormat("telephone-event", 8000, 1));
|
||||
decoder_database.RegisterPayload(3, SdpAudioFormat("ilbc", 8000, 1));
|
||||
|
||||
RedPayloadSplitter splitter;
|
||||
splitter.CheckRedPayloads(&packet_list, decoder_database);
|
||||
@ -334,8 +335,8 @@ TEST(RedPayloadSplitter, CheckRedPayloadsRecursiveRed) {
|
||||
// do its job.
|
||||
DecoderDatabase decoder_database(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, absl::nullopt);
|
||||
decoder_database.RegisterPayload(kRedPayloadType, NetEqDecoder::kDecoderRED,
|
||||
"red");
|
||||
decoder_database.RegisterPayload(kRedPayloadType,
|
||||
SdpAudioFormat("red", 8000, 1));
|
||||
|
||||
RedPayloadSplitter splitter;
|
||||
splitter.CheckRedPayloads(&packet_list, decoder_database);
|
||||
|
||||
@ -35,7 +35,7 @@ class NetEqIlbcQualityTest : public NetEqQualityTest {
|
||||
: NetEqQualityTest(FLAG_frame_size_ms,
|
||||
kInputSampleRateKhz,
|
||||
kOutputSampleRateKhz,
|
||||
NetEqDecoder::kDecoderILBC) {
|
||||
SdpAudioFormat("ilbc", 8000, 1)) {
|
||||
// Flag validation
|
||||
RTC_CHECK(FLAG_frame_size_ms == 20 || FLAG_frame_size_ms == 30 ||
|
||||
FLAG_frame_size_ms == 40 || FLAG_frame_size_ms == 60)
|
||||
|
||||
@ -44,7 +44,7 @@ NetEqIsacQualityTest::NetEqIsacQualityTest()
|
||||
: NetEqQualityTest(kIsacBlockDurationMs,
|
||||
kIsacInputSamplingKhz,
|
||||
kIsacOutputSamplingKhz,
|
||||
NetEqDecoder::kDecoderISAC),
|
||||
SdpAudioFormat("isac", 16000, 1)),
|
||||
isac_encoder_(NULL),
|
||||
bit_rate_kbps_(FLAG_bit_rate_kbps) {
|
||||
// Flag validation
|
||||
|
||||
@ -73,7 +73,7 @@ NetEqOpusQualityTest::NetEqOpusQualityTest()
|
||||
: NetEqQualityTest(kOpusBlockDurationMs * FLAG_sub_packets,
|
||||
kOpusSamplingKhz,
|
||||
kOpusSamplingKhz,
|
||||
NetEqDecoder::kDecoderOpus),
|
||||
SdpAudioFormat("opus", 48000, 2)),
|
||||
opus_encoder_(NULL),
|
||||
repacketizer_(NULL),
|
||||
sub_block_size_samples_(
|
||||
@ -103,7 +103,8 @@ NetEqOpusQualityTest::NetEqOpusQualityTest()
|
||||
|
||||
// Redefine decoder type if input is stereo.
|
||||
if (channels_ > 1) {
|
||||
decoder_type_ = NetEqDecoder::kDecoderOpus_2ch;
|
||||
audio_format_ = SdpAudioFormat(
|
||||
"opus", 48000, 2, std::map<std::string, std::string>{{"stereo", "1"}});
|
||||
}
|
||||
application_ = FLAG_application;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class NetEqPcm16bQualityTest : public NetEqQualityTest {
|
||||
: NetEqQualityTest(FLAG_frame_size_ms,
|
||||
kInputSampleRateKhz,
|
||||
kOutputSampleRateKhz,
|
||||
NetEqDecoder::kDecoderPCM16Bswb48kHz) {
|
||||
SdpAudioFormat("l16", 48000, 1)) {
|
||||
// Flag validation
|
||||
RTC_CHECK(FLAG_frame_size_ms >= 10 && FLAG_frame_size_ms <= 60 &&
|
||||
(FLAG_frame_size_ms % 10) == 0)
|
||||
|
||||
@ -35,7 +35,7 @@ class NetEqPcmuQualityTest : public NetEqQualityTest {
|
||||
: NetEqQualityTest(FLAG_frame_size_ms,
|
||||
kInputSampleRateKhz,
|
||||
kOutputSampleRateKhz,
|
||||
NetEqDecoder::kDecoderPCMu) {
|
||||
SdpAudioFormat("pcmu", 8000, 1)) {
|
||||
// Flag validation
|
||||
RTC_CHECK(FLAG_frame_size_ms >= 10 && FLAG_frame_size_ms <= 60 &&
|
||||
(FLAG_frame_size_ms % 10) == 0)
|
||||
|
||||
@ -33,8 +33,6 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
||||
const std::string kInputFileName =
|
||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
||||
const int kSampRateHz = 32000;
|
||||
const webrtc::NetEqDecoder kDecoderType =
|
||||
webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz;
|
||||
const std::string kDecoderName = "pcm16-swb32";
|
||||
const int kPayloadType = 95;
|
||||
|
||||
@ -43,7 +41,8 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
||||
config.sample_rate_hz = kSampRateHz;
|
||||
NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory());
|
||||
// Register decoder in |neteq|.
|
||||
if (neteq->RegisterPayloadType(kDecoderType, kDecoderName, kPayloadType) != 0)
|
||||
if (!neteq->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", kSampRateHz, 1)))
|
||||
return -1;
|
||||
|
||||
// Set up AudioLoop object.
|
||||
|
||||
@ -135,8 +135,8 @@ static double ProbTrans00Solver(int units,
|
||||
NetEqQualityTest::NetEqQualityTest(int block_duration_ms,
|
||||
int in_sampling_khz,
|
||||
int out_sampling_khz,
|
||||
NetEqDecoder decoder_type)
|
||||
: decoder_type_(decoder_type),
|
||||
const SdpAudioFormat& format)
|
||||
: audio_format_(format),
|
||||
channels_(static_cast<size_t>(FLAG_channels)),
|
||||
decoded_time_ms_(0),
|
||||
decodable_time_ms_(0),
|
||||
@ -271,8 +271,7 @@ bool FixedLossModel::Lost(int now_ms) {
|
||||
}
|
||||
|
||||
void NetEqQualityTest::SetUp() {
|
||||
ASSERT_EQ(0,
|
||||
neteq_->RegisterPayloadType(decoder_type_, "noname", kPayloadType));
|
||||
ASSERT_TRUE(neteq_->RegisterPayloadType(kPayloadType, audio_format_));
|
||||
rtp_generator_->set_drift_factor(drift_factor_);
|
||||
|
||||
int units = block_duration_ms_ / kPacketLossTimeUnitMs;
|
||||
|
||||
@ -98,7 +98,7 @@ class NetEqQualityTest : public ::testing::Test {
|
||||
NetEqQualityTest(int block_duration_ms,
|
||||
int in_sampling_khz,
|
||||
int out_sampling_khz,
|
||||
NetEqDecoder decoder_type);
|
||||
const SdpAudioFormat& format);
|
||||
~NetEqQualityTest() override;
|
||||
|
||||
void SetUp() override;
|
||||
@ -132,7 +132,7 @@ class NetEqQualityTest : public ::testing::Test {
|
||||
// Write to log file. Usage Log() << ...
|
||||
std::ofstream& Log();
|
||||
|
||||
NetEqDecoder decoder_type_;
|
||||
SdpAudioFormat audio_format_;
|
||||
const size_t channels_;
|
||||
|
||||
private:
|
||||
|
||||
@ -280,42 +280,40 @@ NetEqLifetimeStatistics NetEqTest::LifetimeStats() const {
|
||||
|
||||
NetEqTest::DecoderMap NetEqTest::StandardDecoderMap() {
|
||||
DecoderMap codecs = {
|
||||
{0, std::make_pair(NetEqDecoder::kDecoderPCMu, "pcmu")},
|
||||
{8, std::make_pair(NetEqDecoder::kDecoderPCMa, "pcma")},
|
||||
{0, SdpAudioFormat("pcmu", 8000, 1)},
|
||||
{8, SdpAudioFormat("pcma", 8000, 1)},
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
{102, std::make_pair(NetEqDecoder::kDecoderILBC, "ilbc")},
|
||||
{102, SdpAudioFormat("ilbc", 8000, 1)},
|
||||
#endif
|
||||
{103, std::make_pair(NetEqDecoder::kDecoderISAC, "isac")},
|
||||
{103, SdpAudioFormat("isac", 16000, 1)},
|
||||
#if !defined(WEBRTC_ANDROID)
|
||||
{104, std::make_pair(NetEqDecoder::kDecoderISACswb, "isac-swb")},
|
||||
{104, SdpAudioFormat("isac", 32000, 1)},
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
{111, std::make_pair(NetEqDecoder::kDecoderOpus, "opus")},
|
||||
{111, SdpAudioFormat("opus", 48000, 2)},
|
||||
#endif
|
||||
{93, std::make_pair(NetEqDecoder::kDecoderPCM16B, "pcm16-nb")},
|
||||
{94, std::make_pair(NetEqDecoder::kDecoderPCM16Bwb, "pcm16-wb")},
|
||||
{95, std::make_pair(NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16-swb32")},
|
||||
{96, std::make_pair(NetEqDecoder::kDecoderPCM16Bswb48kHz, "pcm16-swb48")},
|
||||
{9, std::make_pair(NetEqDecoder::kDecoderG722, "g722")},
|
||||
{106, std::make_pair(NetEqDecoder::kDecoderAVT, "avt")},
|
||||
{114, std::make_pair(NetEqDecoder::kDecoderAVT16kHz, "avt-16")},
|
||||
{115, std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")},
|
||||
{116, std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")},
|
||||
{117, std::make_pair(NetEqDecoder::kDecoderRED, "red")},
|
||||
{13, std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb")},
|
||||
{98, std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb")},
|
||||
{99, std::make_pair(NetEqDecoder::kDecoderCNGswb32kHz, "cng-swb32")},
|
||||
{100, std::make_pair(NetEqDecoder::kDecoderCNGswb48kHz, "cng-swb48")}
|
||||
{93, SdpAudioFormat("l16", 8000, 1)},
|
||||
{94, SdpAudioFormat("l16", 16000, 1)},
|
||||
{95, SdpAudioFormat("l16", 32000, 1)},
|
||||
{96, SdpAudioFormat("l16", 48000, 1)},
|
||||
{9, SdpAudioFormat("g722", 8000, 1)},
|
||||
{106, SdpAudioFormat("telephone-event", 8000, 1)},
|
||||
{114, SdpAudioFormat("telephone-event", 16000, 1)},
|
||||
{115, SdpAudioFormat("telephone-event", 32000, 1)},
|
||||
{116, SdpAudioFormat("telephone-event", 48000, 1)},
|
||||
{117, SdpAudioFormat("red", 8000, 1)},
|
||||
{13, SdpAudioFormat("cn", 8000, 1)},
|
||||
{98, SdpAudioFormat("cn", 16000, 1)},
|
||||
{99, SdpAudioFormat("cn", 32000, 1)},
|
||||
{100, SdpAudioFormat("cn", 48000, 1)}
|
||||
};
|
||||
return codecs;
|
||||
}
|
||||
|
||||
void NetEqTest::RegisterDecoders(const DecoderMap& codecs) {
|
||||
for (const auto& c : codecs) {
|
||||
RTC_CHECK_EQ(
|
||||
neteq_->RegisterPayloadType(c.second.first, c.second.second, c.first),
|
||||
NetEq::kOK)
|
||||
<< "Cannot register " << c.second.second << " to payload type "
|
||||
RTC_CHECK(neteq_->RegisterPayloadType(c.first, c.second))
|
||||
<< "Cannot register " << c.second.name << " to payload type "
|
||||
<< c.first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class NetEqSimulationEndedCallback {
|
||||
// directed to an AudioSink object.
|
||||
class NetEqTest : public NetEqSimulator {
|
||||
public:
|
||||
using DecoderMap = std::map<int, std::pair<NetEqDecoder, std::string> >;
|
||||
using DecoderMap = std::map<int, SdpAudioFormat>;
|
||||
|
||||
struct Callbacks {
|
||||
NetEqTestErrorCallback* error_callback = nullptr;
|
||||
|
||||
@ -399,39 +399,7 @@ std::unique_ptr<NetEqTest> NetEqTestFactory::InitializeTest(
|
||||
|
||||
std::cout << "Output file: " << output_file_name << std::endl;
|
||||
|
||||
NetEqTest::DecoderMap codecs = {
|
||||
{FLAG_pcmu, std::make_pair(NetEqDecoder::kDecoderPCMu, "pcmu")},
|
||||
{FLAG_pcma, std::make_pair(NetEqDecoder::kDecoderPCMa, "pcma")},
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
{FLAG_ilbc, std::make_pair(NetEqDecoder::kDecoderILBC, "ilbc")},
|
||||
#endif
|
||||
{FLAG_isac, std::make_pair(NetEqDecoder::kDecoderISAC, "isac")},
|
||||
#if !defined(WEBRTC_ANDROID)
|
||||
{FLAG_isac_swb, std::make_pair(NetEqDecoder::kDecoderISACswb, "isac-swb")},
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
{FLAG_opus, std::make_pair(NetEqDecoder::kDecoderOpus, "opus")},
|
||||
#endif
|
||||
{FLAG_pcm16b, std::make_pair(NetEqDecoder::kDecoderPCM16B, "pcm16-nb")},
|
||||
{FLAG_pcm16b_wb,
|
||||
std::make_pair(NetEqDecoder::kDecoderPCM16Bwb, "pcm16-wb")},
|
||||
{FLAG_pcm16b_swb32,
|
||||
std::make_pair(NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16-swb32")},
|
||||
{FLAG_pcm16b_swb48,
|
||||
std::make_pair(NetEqDecoder::kDecoderPCM16Bswb48kHz, "pcm16-swb48")},
|
||||
{FLAG_g722, std::make_pair(NetEqDecoder::kDecoderG722, "g722")},
|
||||
{FLAG_avt, std::make_pair(NetEqDecoder::kDecoderAVT, "avt")},
|
||||
{FLAG_avt_16, std::make_pair(NetEqDecoder::kDecoderAVT16kHz, "avt-16")},
|
||||
{FLAG_avt_32, std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")},
|
||||
{FLAG_avt_48, std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")},
|
||||
{FLAG_red, std::make_pair(NetEqDecoder::kDecoderRED, "red")},
|
||||
{FLAG_cn_nb, std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb")},
|
||||
{FLAG_cn_wb, std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb")},
|
||||
{FLAG_cn_swb32,
|
||||
std::make_pair(NetEqDecoder::kDecoderCNGswb32kHz, "cng-swb32")},
|
||||
{FLAG_cn_swb48,
|
||||
std::make_pair(NetEqDecoder::kDecoderCNGswb48kHz, "cng-swb48")}
|
||||
};
|
||||
NetEqTest::DecoderMap codecs = NetEqTest::StandardDecoderMap();
|
||||
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory =
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
@ -475,8 +443,9 @@ std::unique_ptr<NetEqTest> NetEqTestFactory::InitializeTest(
|
||||
return decoder;
|
||||
});
|
||||
|
||||
codecs[replacement_pt] = {NetEqDecoder::kDecoderReplacementForTest,
|
||||
"replacement codec"};
|
||||
RTC_CHECK(
|
||||
codecs.insert({replacement_pt, SdpAudioFormat("replacement", 48000, 1)})
|
||||
.second);
|
||||
}
|
||||
|
||||
// Create a text log file if needed.
|
||||
|
||||
@ -1732,10 +1732,8 @@ std::unique_ptr<test::NetEqStatsGetter> CreateNetEqTestAndRun(
|
||||
std::move(replacement_file), 48000, false);
|
||||
});
|
||||
|
||||
test::NetEqTest::DecoderMap codecs;
|
||||
|
||||
codecs[kReplacementPt] = {NetEqDecoder::kDecoderPCM16Bswb48kHz,
|
||||
"replacement codec"};
|
||||
test::NetEqTest::DecoderMap codecs = {
|
||||
{kReplacementPt, SdpAudioFormat("l16", 48000, 1)}};
|
||||
|
||||
std::unique_ptr<test::NetEqDelayAnalyzer> delay_cb(
|
||||
new test::NetEqDelayAnalyzer);
|
||||
|
||||
@ -134,8 +134,9 @@ void FuzzOneInputTest(const uint8_t* data, size_t size) {
|
||||
// kPayloadType is the payload type that will be used for encoding. Verify
|
||||
// that it is included in the standard decoder map, and that it points to the
|
||||
// expected decoder type.
|
||||
RTC_CHECK_EQ(codecs.count(kPayloadType), 1);
|
||||
RTC_CHECK(codecs[kPayloadType].first == NetEqDecoder::kDecoderPCM16Bswb32kHz);
|
||||
const auto it = codecs.find(kPayloadType);
|
||||
RTC_CHECK(it != codecs.end());
|
||||
RTC_CHECK(it->second == SdpAudioFormat("l16", 32000, 2));
|
||||
|
||||
NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs, nullptr,
|
||||
std::move(input), std::move(output), callbacks);
|
||||
|
||||
@ -138,6 +138,13 @@ class FuzzSignalInput : public NetEqInput {
|
||||
int64_t next_output_event_ms_ = 0;
|
||||
int64_t output_event_period_ms_ = 10;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
bool MapHas(const std::map<int, T>& m, int key, const T& value) {
|
||||
const auto it = m.find(key);
|
||||
return (it != m.end() && it->second == value);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void FuzzOneInputTest(const uint8_t* data, size_t size) {
|
||||
@ -170,17 +177,14 @@ void FuzzOneInputTest(const uint8_t* data, size_t size) {
|
||||
// rate_types contains the payload types that will be used for encoding.
|
||||
// Verify that they all are included in the standard decoder map, and that
|
||||
// they point to the expected decoder types.
|
||||
RTC_CHECK_EQ(codecs.count(rate_types[0].second), 1);
|
||||
RTC_CHECK(codecs[rate_types[0].second].first == NetEqDecoder::kDecoderPCM16B);
|
||||
RTC_CHECK_EQ(codecs.count(rate_types[1].second), 1);
|
||||
RTC_CHECK(codecs[rate_types[1].second].first ==
|
||||
NetEqDecoder::kDecoderPCM16Bwb);
|
||||
RTC_CHECK_EQ(codecs.count(rate_types[2].second), 1);
|
||||
RTC_CHECK(codecs[rate_types[2].second].first ==
|
||||
NetEqDecoder::kDecoderPCM16Bswb32kHz);
|
||||
RTC_CHECK_EQ(codecs.count(rate_types[3].second), 1);
|
||||
RTC_CHECK(codecs[rate_types[3].second].first ==
|
||||
NetEqDecoder::kDecoderPCM16Bswb48kHz);
|
||||
RTC_CHECK(
|
||||
MapHas(codecs, rate_types[0].second, SdpAudioFormat("l16", 8000, 1)));
|
||||
RTC_CHECK(
|
||||
MapHas(codecs, rate_types[1].second, SdpAudioFormat("l16", 16000, 1)));
|
||||
RTC_CHECK(
|
||||
MapHas(codecs, rate_types[2].second, SdpAudioFormat("l16", 32000, 1)));
|
||||
RTC_CHECK(
|
||||
MapHas(codecs, rate_types[3].second, SdpAudioFormat("l16", 48000, 1)));
|
||||
|
||||
NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs, nullptr,
|
||||
std::move(input), std::move(output), callbacks);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user