Index: webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc b/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc |
index b525813cdca123e51b43e435e06ca05e882f1240..227391a3f417a054eda56e7bdfb6488f735bebe2 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc |
@@ -34,8 +34,10 @@ class SendTimeHistoryTest : public ::testing::Test { |
void AddPacketWithSendTime(uint16_t sequence_number, |
size_t length, |
bool was_paced, |
- int64_t send_time_ms) { |
- history_.AddAndRemoveOld(sequence_number, length, was_paced); |
+ int64_t send_time_ms, |
+ int probe_cluster_id) { |
+ history_.AddAndRemoveOld(sequence_number, length, was_paced, |
+ probe_cluster_id); |
history_.OnSentPacket(sequence_number, send_time_ms); |
} |
@@ -46,42 +48,58 @@ class SendTimeHistoryTest : public ::testing::Test { |
// Help class extended so we can do EXPECT_EQ and collections. |
class PacketInfo : public webrtc::PacketInfo { |
public: |
- PacketInfo() : webrtc::PacketInfo(-1, 0, 0, 0, 0, false) {} |
+ PacketInfo() |
+ : webrtc::PacketInfo(-1, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ false, |
+ webrtc::PacketInfo::kNotAProbe) {} |
PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number) |
- : PacketInfo(arrival_time_ms, 0, sequence_number, 0, false) {} |
+ : PacketInfo(arrival_time_ms, |
+ 0, |
+ sequence_number, |
+ 0, |
+ false, |
+ PacketInfo::kNotAProbe) {} |
PacketInfo(int64_t arrival_time_ms, |
int64_t send_time_ms, |
uint16_t sequence_number, |
size_t payload_size, |
- bool was_paced) |
+ bool was_paced, |
+ int probe_cluster_id) |
: webrtc::PacketInfo(-1, |
arrival_time_ms, |
send_time_ms, |
sequence_number, |
payload_size, |
- was_paced) {} |
+ was_paced, |
+ probe_cluster_id) {} |
bool operator==(const PacketInfo& other) const { |
return arrival_time_ms == other.arrival_time_ms && |
send_time_ms == other.send_time_ms && |
sequence_number == other.sequence_number && |
- payload_size == other.payload_size && was_paced == other.was_paced; |
+ payload_size == other.payload_size && was_paced == other.was_paced && |
+ probe_cluster_id == other.probe_cluster_id; |
} |
}; |
TEST_F(SendTimeHistoryTest, AddRemoveOne) { |
const uint16_t kSeqNo = 10; |
- const PacketInfo kSentPacket(0, 1, kSeqNo, 1, true); |
- AddPacketWithSendTime(kSeqNo, 1, true, 1); |
+ const int kProbeClusterId = 0; |
+ const PacketInfo kSentPacket(0, 1, kSeqNo, 1, true, kProbeClusterId); |
+ AddPacketWithSendTime(kSeqNo, 1, true, 1, kProbeClusterId); |
- PacketInfo received_packet(0, 0, kSeqNo, 0, false); |
+ PacketInfo received_packet(0, 0, kSeqNo, 0, false, kProbeClusterId); |
EXPECT_TRUE(history_.GetInfo(&received_packet, false)); |
EXPECT_EQ(kSentPacket, received_packet); |
- PacketInfo received_packet2(0, 0, kSeqNo, 0, false); |
+ PacketInfo received_packet2(0, 0, kSeqNo, 0, false, kProbeClusterId); |
EXPECT_TRUE(history_.GetInfo(&received_packet2, true)); |
EXPECT_EQ(kSentPacket, received_packet2); |
- PacketInfo received_packet3(0, 0, kSeqNo, 0, false); |
+ PacketInfo received_packet3(0, 0, kSeqNo, 0, false, kProbeClusterId); |
EXPECT_FALSE(history_.GetInfo(&received_packet3, true)); |
} |
@@ -92,7 +110,8 @@ TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) { |
const size_t kPayloadSize = 42; |
const bool kPaced = true; |
- AddPacketWithSendTime(kSeqNo, kPayloadSize, kPaced, kSendTime); |
+ AddPacketWithSendTime(kSeqNo, kPayloadSize, kPaced, kSendTime, |
+ PacketInfo::kNotAProbe); |
PacketInfo info(kReceiveTime, kSeqNo); |
EXPECT_TRUE(history_.GetInfo(&info, true)); |
@@ -110,18 +129,19 @@ TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) { |
const size_t kPacketSize = 400; |
const size_t kTransmissionTime = 1234; |
const bool kPaced = true; |
+ const int kProbeClusterId = 1; |
for (size_t i = 0; i < num_items; ++i) { |
sent_packets.push_back(PacketInfo(0, static_cast<int64_t>(i), |
static_cast<uint16_t>(i), kPacketSize, |
- kPaced)); |
- received_packets.push_back( |
- PacketInfo(static_cast<int64_t>(i) + kTransmissionTime, 0, |
- static_cast<uint16_t>(i), kPacketSize, false)); |
+ kPaced, kProbeClusterId)); |
+ received_packets.push_back(PacketInfo( |
+ static_cast<int64_t>(i) + kTransmissionTime, 0, |
+ static_cast<uint16_t>(i), kPacketSize, false, PacketInfo::kNotAProbe)); |
} |
for (size_t i = 0; i < num_items; ++i) { |
- history_.AddAndRemoveOld(sent_packets[i].sequence_number, |
- sent_packets[i].payload_size, |
- sent_packets[i].was_paced); |
+ history_.AddAndRemoveOld( |
+ sent_packets[i].sequence_number, sent_packets[i].payload_size, |
+ sent_packets[i].was_paced, sent_packets[i].probe_cluster_id); |
} |
for (size_t i = 0; i < num_items; ++i) |
history_.OnSentPacket(sent_packets[i].sequence_number, |
@@ -143,19 +163,21 @@ TEST_F(SendTimeHistoryTest, HistorySize) { |
const int kItems = kDefaultHistoryLengthMs / 100; |
for (int i = 0; i < kItems; ++i) { |
clock_.AdvanceTimeMilliseconds(100); |
- AddPacketWithSendTime(i, 0, false, i * 100); |
+ AddPacketWithSendTime(i, 0, false, i * 100, PacketInfo::kNotAProbe); |
} |
for (int i = 0; i < kItems; ++i) { |
- PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, false); |
+ PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, false, |
+ PacketInfo::kNotAProbe); |
EXPECT_TRUE(history_.GetInfo(&info, false)); |
EXPECT_EQ(i * 100, info.send_time_ms); |
} |
clock_.AdvanceTimeMilliseconds(101); |
- AddPacketWithSendTime(kItems, 0, false, kItems * 101); |
- PacketInfo info(0, 0, 0, 0, false); |
+ AddPacketWithSendTime(kItems, 0, false, kItems * 101, PacketInfo::kNotAProbe); |
+ PacketInfo info(0, 0, 0, 0, false, PacketInfo::kNotAProbe); |
EXPECT_FALSE(history_.GetInfo(&info, false)); |
for (int i = 1; i < (kItems + 1); ++i) { |
- PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, false); |
+ PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, false, |
+ PacketInfo::kNotAProbe); |
EXPECT_TRUE(history_.GetInfo(&info2, false)); |
int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100; |
EXPECT_EQ(expected_time_ms, info2.send_time_ms); |
@@ -164,16 +186,17 @@ TEST_F(SendTimeHistoryTest, HistorySize) { |
TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { |
const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max(); |
- AddPacketWithSendTime(kMaxSeqNo - 2, 0, false, 0); |
+ AddPacketWithSendTime(kMaxSeqNo - 2, 0, false, 0, PacketInfo::kNotAProbe); |
clock_.AdvanceTimeMilliseconds(100); |
- AddPacketWithSendTime(kMaxSeqNo - 1, 1, false, 100); |
+ AddPacketWithSendTime(kMaxSeqNo - 1, 1, false, 100, PacketInfo::kNotAProbe); |
clock_.AdvanceTimeMilliseconds(100); |
- AddPacketWithSendTime(kMaxSeqNo, 0, false, 200); |
+ AddPacketWithSendTime(kMaxSeqNo, 0, false, 200, PacketInfo::kNotAProbe); |
clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1); |
- AddPacketWithSendTime(0, 0, false, kDefaultHistoryLengthMs); |
+ AddPacketWithSendTime(0, 0, false, kDefaultHistoryLengthMs, |
+ PacketInfo::kNotAProbe); |
PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2)); |
EXPECT_FALSE(history_.GetInfo(&info, false)); |
@@ -189,7 +212,7 @@ TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { |
EXPECT_TRUE(history_.GetInfo(&info5, true)); |
clock_.AdvanceTimeMilliseconds(100); |
- AddPacketWithSendTime(1, 0, false, 1100); |
+ AddPacketWithSendTime(1, 0, false, 1100, PacketInfo::kNotAProbe); |
PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2)); |
EXPECT_FALSE(history_.GetInfo(&info6, false)); |
@@ -206,26 +229,26 @@ TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { |
TEST_F(SendTimeHistoryTest, InterlievedGetAndRemove) { |
const uint16_t kSeqNo = 1; |
const int64_t kTimestamp = 2; |
- PacketInfo packets[3] = {{0, kTimestamp, kSeqNo, 0, false}, |
- {0, kTimestamp + 1, kSeqNo + 1, 0, false}, |
- {0, kTimestamp + 2, kSeqNo + 2, 0, false}}; |
+ PacketInfo packets[3] = {{0, kTimestamp, kSeqNo, 0, false, 0}, |
+ {0, kTimestamp + 1, kSeqNo + 1, 0, false, 1}, |
+ {0, kTimestamp + 2, kSeqNo + 2, 0, false, 2}}; |
AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size, |
- packets[0].was_paced, packets[0].send_time_ms); |
+ packets[0].was_paced, packets[0].send_time_ms, 0); |
AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size, |
- packets[1].was_paced, packets[1].send_time_ms); |
- PacketInfo info(0, 0, packets[0].sequence_number, 0, false); |
+ packets[1].was_paced, packets[1].send_time_ms, 1); |
+ PacketInfo info(0, 0, packets[0].sequence_number, 0, false, 0); |
EXPECT_TRUE(history_.GetInfo(&info, true)); |
EXPECT_EQ(packets[0], info); |
AddPacketWithSendTime(packets[2].sequence_number, packets[2].payload_size, |
- packets[2].was_paced, packets[2].send_time_ms); |
+ packets[2].was_paced, packets[2].send_time_ms, 2); |
- PacketInfo info2(0, 0, packets[1].sequence_number, 0, false); |
+ PacketInfo info2(0, 0, packets[1].sequence_number, 0, false, 1); |
EXPECT_TRUE(history_.GetInfo(&info2, true)); |
EXPECT_EQ(packets[1], info2); |
- PacketInfo info3(0, 0, packets[2].sequence_number, 0, false); |
+ PacketInfo info3(0, 0, packets[2].sequence_number, 0, false, 2); |
EXPECT_TRUE(history_.GetInfo(&info3, true)); |
EXPECT_EQ(packets[2], info3); |
} |