Removed sync packet support from NetEq.

I could not find a single place it was used, outside of the unittests
for the sync packet support itself.

Review-Url: https://codereview.webrtc.org/2309303002
Cr-Commit-Position: refs/heads/master@{#14130}
This commit is contained in:
ossu
2016-09-08 04:52:55 -07:00
committed by Commit bot
parent 2c993ce505
commit 17e3fa1fb4
7 changed files with 24 additions and 366 deletions

View File

@ -61,20 +61,6 @@ const std::string& PlatformChecksum(const std::string& checksum_general,
#endif // WEBRTC_WIN
}
bool IsAllZero(const int16_t* buf, size_t buf_length) {
bool all_zero = true;
for (size_t n = 0; n < buf_length && all_zero; ++n)
all_zero = buf[n] == 0;
return all_zero;
}
bool IsAllNonZero(const int16_t* buf, size_t buf_length) {
bool all_non_zero = true;
for (size_t n = 0; n < buf_length && all_non_zero; ++n)
all_non_zero = buf[n] != 0;
return all_non_zero;
}
#ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT
void Convert(const webrtc::NetEqNetworkStatistics& stats_raw,
webrtc::neteq_unittest::NetEqNetworkStatistics* stats) {
@ -1079,232 +1065,6 @@ TEST_F(NetEqBgnTestFade, RunTest) {
CheckBgn(32000);
}
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
#define MAYBE_SyncPacketInsert SyncPacketInsert
#else
#define MAYBE_SyncPacketInsert DISABLED_SyncPacketInsert
#endif
TEST_F(NetEqDecodingTest, MAYBE_SyncPacketInsert) {
WebRtcRTPHeader rtp_info;
uint32_t receive_timestamp = 0;
// For the readability use the following payloads instead of the defaults of
// this test.
uint8_t kPcm16WbPayloadType = 1;
uint8_t kCngNbPayloadType = 2;
uint8_t kCngWbPayloadType = 3;
uint8_t kCngSwb32PayloadType = 4;
uint8_t kCngSwb48PayloadType = 5;
uint8_t kAvtPayloadType = 6;
uint8_t kRedPayloadType = 7;
uint8_t kIsacPayloadType = 9; // Payload type 8 is already registered.
// Register decoders.
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb,
"pcm16-wb", kPcm16WbPayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb,
"cng-nb", kCngNbPayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb,
"cng-wb", kCngWbPayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb32kHz,
"cng-swb32", kCngSwb32PayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb48kHz,
"cng-swb48", kCngSwb48PayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderAVT, "avt",
kAvtPayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderRED, "red",
kRedPayloadType));
ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac",
kIsacPayloadType));
PopulateRtpInfo(0, 0, &rtp_info);
rtp_info.header.payloadType = kPcm16WbPayloadType;
// The first packet injected cannot be sync-packet.
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
// Payload length of 10 ms PCM16 16 kHz.
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
uint8_t payload[kPayloadBytes] = {0};
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
// Next packet. Last packet contained 10 ms audio.
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
// Unacceptable payload types CNG, AVT (DTMF), RED.
rtp_info.header.payloadType = kCngNbPayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.payloadType = kCngWbPayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.payloadType = kCngSwb32PayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.payloadType = kCngSwb48PayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.payloadType = kAvtPayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.payloadType = kRedPayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
// Change of codec cannot be initiated with a sync packet.
rtp_info.header.payloadType = kIsacPayloadType;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
// Change of SSRC is not allowed with a sync packet.
rtp_info.header.payloadType = kPcm16WbPayloadType;
++rtp_info.header.ssrc;
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
--rtp_info.header.ssrc;
EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
}
// First insert several noise like packets, then sync-packets. Decoding all
// packets should not produce error, statistics should not show any packet loss
// and sync-packets should decode to zero.
// TODO(turajs) we will have a better test if we have a referece NetEq, and
// when Sync packets are inserted in "test" NetEq we insert all-zero payload
// in reference NetEq and compare the output of those two.
TEST_F(NetEqDecodingTest, SyncPacketDecode) {
WebRtcRTPHeader rtp_info;
PopulateRtpInfo(0, 0, &rtp_info);
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
uint8_t payload[kPayloadBytes];
AudioFrame output;
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
for (size_t n = 0; n < kPayloadBytes; ++n) {
payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence.
}
// Insert some packets which decode to noise. We are not interested in
// actual decoded values.
uint32_t receive_timestamp = 0;
bool muted;
for (int n = 0; n < 100; ++n) {
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_);
ASSERT_EQ(1u, output.num_channels_);
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
const int kNumSyncPackets = 10;
// Make sure sufficient number of sync packets are inserted that we can
// conduct a test.
ASSERT_GT(kNumSyncPackets, algorithmic_frame_delay);
// Insert sync-packets, the decoded sequence should be all-zero.
for (int n = 0; n < kNumSyncPackets; ++n) {
ASSERT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
ASSERT_FALSE(muted);
ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_);
ASSERT_EQ(1u, output.num_channels_);
if (n > algorithmic_frame_delay) {
EXPECT_TRUE(IsAllZero(
output.data_, output.samples_per_channel_ * output.num_channels_));
}
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
// We insert regular packets, if sync packet are not correctly buffered then
// network statistics would show some packet loss.
for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) {
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
ASSERT_FALSE(muted);
if (n >= algorithmic_frame_delay + 1) {
// Expect that this frame contain samples from regular RTP.
EXPECT_TRUE(IsAllNonZero(
output.data_, output.samples_per_channel_ * output.num_channels_));
}
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
NetEqNetworkStatistics network_stats;
ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats));
// Expecting a "clean" network.
EXPECT_EQ(0, network_stats.packet_loss_rate);
EXPECT_EQ(0, network_stats.expand_rate);
EXPECT_EQ(0, network_stats.accelerate_rate);
EXPECT_LE(network_stats.preemptive_rate, 150);
}
// Test if the size of the packet buffer reported correctly when containing
// sync packets. Also, test if network packets override sync packets. That is to
// prefer decoding a network packet to a sync packet, if both have same sequence
// number and timestamp.
TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
WebRtcRTPHeader rtp_info;
PopulateRtpInfo(0, 0, &rtp_info);
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
uint8_t payload[kPayloadBytes];
AudioFrame output;
for (size_t n = 0; n < kPayloadBytes; ++n) {
payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence.
}
// Insert some packets which decode to noise. We are not interested in
// actual decoded values.
uint32_t receive_timestamp = 0;
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
bool muted;
for (int n = 0; n < algorithmic_frame_delay; ++n) {
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_);
ASSERT_EQ(1u, output.num_channels_);
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
const int kNumSyncPackets = 10;
WebRtcRTPHeader first_sync_packet_rtp_info;
memcpy(&first_sync_packet_rtp_info, &rtp_info, sizeof(rtp_info));
// Insert sync-packets, but no decoding.
for (int n = 0; n < kNumSyncPackets; ++n) {
ASSERT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
NetEqNetworkStatistics network_stats;
ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats));
EXPECT_EQ(kNumSyncPackets * 10 + algorithmic_delay_ms_,
network_stats.current_buffer_size_ms);
// Rewind |rtp_info| to that of the first sync packet.
memcpy(&rtp_info, &first_sync_packet_rtp_info, sizeof(rtp_info));
// Insert.
for (int n = 0; n < kNumSyncPackets; ++n) {
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
rtp_info.header.sequenceNumber++;
rtp_info.header.timestamp += kBlockSize16kHz;
receive_timestamp += kBlockSize16kHz;
}
// Decode.
for (int n = 0; n < kNumSyncPackets; ++n) {
ASSERT_EQ(0, neteq_->GetAudio(&output, &muted));
ASSERT_FALSE(muted);
ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_);
ASSERT_EQ(1u, output.num_channels_);
EXPECT_TRUE(IsAllNonZero(
output.data_, output.samples_per_channel_ * output.num_channels_));
}
}
void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
uint32_t start_timestamp,
const std::set<uint16_t>& drop_seq_numbers,