Index: webrtc/modules/audio_coding/neteq/neteq_unittest.cc |
diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc |
index 1a54c54c39453e0faefe821c62738348cfd97a03..68a4921147a788b82cb19db4ffe56c10edfeabe2 100644 |
--- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc |
+++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc |
@@ -23,9 +23,10 @@ |
#include "gflags/gflags.h" |
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
#include "webrtc/base/ignore_wundef.h" |
+#include "webrtc/base/protobuf_utils.h" |
#include "webrtc/base/sha1digest.h" |
#include "webrtc/base/stringencode.h" |
-#include "webrtc/base/protobuf_utils.h" |
+#include "webrtc/common_types.h" |
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
@@ -250,10 +251,10 @@ class NetEqDecodingTest : public ::testing::Test { |
static void PopulateRtpInfo(int frame_index, |
int timestamp, |
- WebRtcRTPHeader* rtp_info); |
+ RTPHeader* rtp_info); |
static void PopulateCng(int frame_index, |
int timestamp, |
- WebRtcRTPHeader* rtp_info, |
+ RTPHeader* rtp_info, |
uint8_t* payload, |
size_t* payload_len); |
@@ -318,15 +319,13 @@ void NetEqDecodingTest::Process() { |
// Check if time to receive. |
while (packet_ && sim_clock_ >= packet_->time_ms()) { |
if (packet_->payload_length_bytes() > 0) { |
- WebRtcRTPHeader rtp_header; |
- packet_->ConvertHeader(&rtp_header); |
#ifndef WEBRTC_CODEC_ISAC |
// Ignore payload type 104 (iSAC-swb) if ISAC is not supported. |
- if (rtp_header.header.payloadType != 104) |
+ if (packet_->header().payloadType != 104) |
#endif |
ASSERT_EQ(0, |
neteq_->InsertPacket( |
- rtp_header.header, |
+ packet_->header(), |
rtc::ArrayView<const uint8_t>( |
packet_->payload(), packet_->payload_length_bytes()), |
static_cast<uint32_t>(packet_->time_ms() * |
@@ -409,24 +408,24 @@ void NetEqDecodingTest::DecodeAndCompare( |
void NetEqDecodingTest::PopulateRtpInfo(int frame_index, |
int timestamp, |
- WebRtcRTPHeader* rtp_info) { |
- rtp_info->header.sequenceNumber = frame_index; |
- rtp_info->header.timestamp = timestamp; |
- rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
- rtp_info->header.payloadType = 94; // PCM16b WB codec. |
- rtp_info->header.markerBit = 0; |
+ RTPHeader* rtp_info) { |
+ rtp_info->sequenceNumber = frame_index; |
+ rtp_info->timestamp = timestamp; |
+ rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. |
+ rtp_info->payloadType = 94; // PCM16b WB codec. |
+ rtp_info->markerBit = 0; |
} |
void NetEqDecodingTest::PopulateCng(int frame_index, |
int timestamp, |
- WebRtcRTPHeader* rtp_info, |
+ RTPHeader* rtp_info, |
uint8_t* payload, |
size_t* payload_len) { |
- rtp_info->header.sequenceNumber = frame_index; |
- rtp_info->header.timestamp = timestamp; |
- rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
- rtp_info->header.payloadType = 98; // WB CNG. |
- rtp_info->header.markerBit = 0; |
+ rtp_info->sequenceNumber = frame_index; |
+ rtp_info->timestamp = timestamp; |
+ rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. |
+ rtp_info->payloadType = 98; // WB CNG. |
+ rtp_info->markerBit = 0; |
payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. |
*payload_len = 1; // Only noise level, no spectral parameters. |
} |
@@ -521,13 +520,13 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { |
const size_t kPayloadBytes = kSamples * 2; |
for (size_t i = 0; i < num_frames; ++i) { |
const uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
- rtp_info.header.sequenceNumber = i; |
- rtp_info.header.timestamp = i * kSamples; |
- rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. |
- rtp_info.header.payloadType = 94; // PCM16b WB codec. |
- rtp_info.header.markerBit = 0; |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ RTPHeader rtp_info; |
+ rtp_info.sequenceNumber = i; |
+ rtp_info.timestamp = i * kSamples; |
+ rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. |
+ rtp_info.payloadType = 94; // PCM16b WB codec. |
+ rtp_info.markerBit = 0; |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
} |
// Pull out all data. |
for (size_t i = 0; i < num_frames; ++i) { |
@@ -566,9 +565,9 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { |
int num_packets = (frame_index % 10 == 0 ? 2 : 1); |
for (int n = 0; n < num_packets; ++n) { |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++frame_index; |
} |
@@ -594,9 +593,9 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { |
int num_packets = (i % 10 == 9 ? 0 : 1); |
for (int n = 0; n < num_packets; ++n) { |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++frame_index; |
} |
@@ -632,9 +631,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
while (next_input_time_ms <= t_ms) { |
// Insert one 30 ms speech frame. |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++seq_no; |
timestamp += kSamples; |
next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; |
@@ -659,10 +658,10 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
// Insert one CNG frame each 100 ms. |
uint8_t payload[kPayloadBytes]; |
size_t payload_len; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
ASSERT_EQ(0, neteq_->InsertPacket( |
- rtp_info.header, |
+ rtp_info, |
rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
++seq_no; |
timestamp += kCngPeriodSamples; |
@@ -702,10 +701,10 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
// Insert one CNG frame each 100 ms. |
uint8_t payload[kPayloadBytes]; |
size_t payload_len; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
ASSERT_EQ(0, neteq_->InsertPacket( |
- rtp_info.header, |
+ rtp_info, |
rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
++seq_no; |
timestamp += kCngPeriodSamples; |
@@ -720,9 +719,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
while (next_input_time_ms <= t_ms) { |
// Insert one 30 ms speech frame. |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++seq_no; |
timestamp += kSamples; |
next_input_time_ms += kFrameSizeMs * drift_factor; |
@@ -831,10 +830,10 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { |
TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
const size_t kPayloadBytes = 100; |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(0, 0, &rtp_info); |
- rtp_info.header.payloadType = 1; // Not registered as a decoder. |
- EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ rtp_info.payloadType = 1; // Not registered as a decoder. |
+ EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
} |
@@ -847,10 +846,10 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { |
const size_t kPayloadBytes = 100; |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(0, 0, &rtp_info); |
- rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
- EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ rtp_info.payloadType = 103; // iSAC, but the payload is invalid. |
+ EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
// Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
// to GetAudio. |
for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
@@ -944,9 +943,9 @@ class NetEqBgnTest : public NetEqDecodingTest { |
// Payload of 10 ms of PCM16 32 kHz. |
uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(0, 0, &rtp_info); |
- rtp_info.header.payloadType = payload_type; |
+ rtp_info.payloadType = payload_type; |
uint32_t receive_timestamp = 0; |
bool muted; |
@@ -958,7 +957,7 @@ class NetEqBgnTest : public NetEqDecodingTest { |
ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); |
ASSERT_EQ(0, neteq_->InsertPacket( |
- rtp_info.header, |
+ rtp_info, |
rtc::ArrayView<const uint8_t>(payload, enc_len_bytes), |
receive_timestamp)); |
output.Reset(); |
@@ -968,8 +967,8 @@ class NetEqBgnTest : public NetEqDecodingTest { |
ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
// Next packet. |
- rtp_info.header.timestamp += expected_samples_per_channel; |
- rtp_info.header.sequenceNumber++; |
+ rtp_info.timestamp += expected_samples_per_channel; |
+ rtp_info.sequenceNumber++; |
receive_timestamp += expected_samples_per_channel; |
} |
@@ -1090,12 +1089,12 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, |
while (next_input_time_ms <= t_ms) { |
// Insert one 30 ms speech frame. |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { |
// This sequence number was not in the set to drop. Insert it. |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, |
- receive_timestamp)); |
+ ASSERT_EQ(0, |
+ neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
++packets_inserted; |
} |
NetEqNetworkStatistics network_stats; |
@@ -1179,11 +1178,11 @@ void NetEqDecodingTest::DuplicateCng() { |
// Insert three speech packets. Three are needed to get the frame length |
// correct. |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
bool muted; |
for (int i = 0; i < 3; ++i) { |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++seq_no; |
timestamp += kSamples; |
@@ -1200,9 +1199,9 @@ void NetEqDecodingTest::DuplicateCng() { |
size_t payload_len; |
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
// This is the first time this CNG packet is inserted. |
- ASSERT_EQ(0, neteq_->InsertPacket( |
- rtp_info.header, |
- rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
+ ASSERT_EQ( |
+ 0, neteq_->InsertPacket( |
+ rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
// Pull audio once and make sure CNG is played. |
ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
@@ -1214,9 +1213,9 @@ void NetEqDecodingTest::DuplicateCng() { |
// Insert the same CNG packet again. Note that at this point it is old, since |
// we have already decoded the first copy of it. |
- ASSERT_EQ(0, neteq_->InsertPacket( |
- rtp_info.header, |
- rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
+ ASSERT_EQ( |
+ 0, neteq_->InsertPacket( |
+ rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
// Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since |
// we have already pulled out CNG once. |
@@ -1233,7 +1232,7 @@ void NetEqDecodingTest::DuplicateCng() { |
++seq_no; |
timestamp += kCngPeriodSamples; |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
// Pull audio once and verify that the output is speech again. |
ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
@@ -1263,13 +1262,13 @@ TEST_F(NetEqDecodingTest, CngFirst) { |
size_t payload_len; |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
- ASSERT_EQ(NetEq::kOK, |
- neteq_->InsertPacket( |
- rtp_info.header, |
- rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
+ ASSERT_EQ( |
+ NetEq::kOK, |
+ neteq_->InsertPacket( |
+ rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
++seq_no; |
timestamp += kCngPeriodSamples; |
@@ -1285,7 +1284,7 @@ TEST_F(NetEqDecodingTest, CngFirst) { |
do { |
ASSERT_LT(timeout_counter++, 20) << "Test timed out"; |
PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
- ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
++seq_no; |
timestamp += kSamples; |
@@ -1309,20 +1308,20 @@ class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { |
void InsertPacket(uint32_t rtp_timestamp) { |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(0, rtp_timestamp, &rtp_info); |
- EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
+ EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
} |
void InsertCngPacket(uint32_t rtp_timestamp) { |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
size_t payload_len; |
PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); |
- EXPECT_EQ(NetEq::kOK, |
- neteq_->InsertPacket( |
- rtp_info.header, |
- rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
+ EXPECT_EQ( |
+ NetEq::kOK, |
+ neteq_->InsertPacket( |
+ rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
} |
bool GetAudioReturnMuted() { |
@@ -1545,10 +1544,10 @@ TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { |
const size_t kSamples = 10 * 16; |
const size_t kPayloadBytes = kSamples * 2; |
uint8_t payload[kPayloadBytes] = {0}; |
- WebRtcRTPHeader rtp_info; |
+ RTPHeader rtp_info; |
PopulateRtpInfo(0, 0, &rtp_info); |
- EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
- EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); |
+ EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
+ EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
AudioFrame out_frame1, out_frame2; |
bool muted; |
@@ -1570,8 +1569,8 @@ TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { |
// Insert new data. Timestamp is corrected for the time elapsed since the last |
// packet. |
PopulateRtpInfo(0, kSamples * 1000, &rtp_info); |
- EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); |
- EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); |
+ EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
+ EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
int counter = 0; |
while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { |