Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc

Issue 2708873003: Propagate packet pacing information to SendTimeHistory. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ce7d021587605005df2016813d599d0e48defbdf..40a119edd0b517e297238b07d3bfd8791db944cd 100644
--- a/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc
@@ -35,8 +35,8 @@ class SendTimeHistoryTest : public ::testing::Test {
void AddPacketWithSendTime(uint16_t sequence_number,
size_t length,
int64_t send_time_ms,
- int probe_cluster_id) {
- history_.AddAndRemoveOld(sequence_number, length, probe_cluster_id);
+ const PacedPacketInfo& pacing_info) {
+ history_.AddAndRemoveOld(sequence_number, length, pacing_info);
history_.OnSentPacket(sequence_number, send_time_ms);
}
@@ -44,50 +44,22 @@ class SendTimeHistoryTest : public ::testing::Test {
SendTimeHistory history_;
};
-// Help class extended so we can do EXPECT_EQ and collections.
-class PacketInfo : public webrtc::PacketInfo {
- public:
- PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number)
- : PacketInfo(arrival_time_ms,
- 0,
- sequence_number,
- 0,
- PacedPacketInfo::kNotAProbe) {}
- PacketInfo(int64_t arrival_time_ms,
- int64_t send_time_ms,
- uint16_t sequence_number,
- size_t payload_size,
- int probe_cluster_id)
- : webrtc::PacketInfo(-1,
- arrival_time_ms,
- send_time_ms,
- sequence_number,
- payload_size,
- 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 &&
- probe_cluster_id == other.probe_cluster_id;
- }
-};
-
TEST_F(SendTimeHistoryTest, AddRemoveOne) {
const uint16_t kSeqNo = 10;
- const int kProbeClusterId = 0;
- const PacketInfo kSentPacket(0, 1, kSeqNo, 1, kProbeClusterId);
- AddPacketWithSendTime(kSeqNo, 1, 1, kProbeClusterId);
+ // TODO(philipel): Fix PacedPacketInfo constructor?
+ const PacedPacketInfo kPacingInfo(0, 5, 1200);
+ const PacketInfo kSentPacket(0, 1, kSeqNo, 1, kPacingInfo);
+ AddPacketWithSendTime(kSeqNo, 1, 1, kPacingInfo);
- PacketInfo received_packet(0, 0, kSeqNo, 0, kProbeClusterId);
+ PacketInfo received_packet(0, 0, kSeqNo, 0, kPacingInfo);
EXPECT_TRUE(history_.GetInfo(&received_packet, false));
EXPECT_EQ(kSentPacket, received_packet);
- PacketInfo received_packet2(0, 0, kSeqNo, 0, kProbeClusterId);
+ PacketInfo received_packet2(0, 0, kSeqNo, 0, kPacingInfo);
EXPECT_TRUE(history_.GetInfo(&received_packet2, true));
EXPECT_EQ(kSentPacket, received_packet2);
- PacketInfo received_packet3(0, 0, kSeqNo, 0, kProbeClusterId);
+ PacketInfo received_packet3(0, 0, kSeqNo, 0, kPacingInfo);
EXPECT_FALSE(history_.GetInfo(&received_packet3, true));
}
@@ -96,9 +68,9 @@ TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) {
const int64_t kSendTime = 1000;
const int64_t kReceiveTime = 2000;
const size_t kPayloadSize = 42;
+ const PacedPacketInfo kPacingInfo(3, 10, 1212);
- AddPacketWithSendTime(kSeqNo, kPayloadSize, kSendTime,
- PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(kSeqNo, kPayloadSize, kSendTime, kPacingInfo);
PacketInfo info(kReceiveTime, kSeqNo);
EXPECT_TRUE(history_.GetInfo(&info, true));
@@ -106,6 +78,7 @@ TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) {
EXPECT_EQ(kSendTime, info.send_time_ms);
EXPECT_EQ(kSeqNo, info.sequence_number);
EXPECT_EQ(kPayloadSize, info.payload_size);
+ EXPECT_EQ(kPacingInfo, info.pacing_info);
}
TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) {
@@ -114,19 +87,19 @@ TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) {
const size_t num_items = 100;
const size_t kPacketSize = 400;
const size_t kTransmissionTime = 1234;
- const int kProbeClusterId = 1;
+ const PacedPacketInfo kPacingInfo(1, 2, 200);
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,
- kProbeClusterId));
- received_packets.push_back(PacketInfo(
- static_cast<int64_t>(i) + kTransmissionTime, 0,
- static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo::kNotAProbe));
+ kPacingInfo));
+ received_packets.push_back(
+ PacketInfo(static_cast<int64_t>(i) + kTransmissionTime, 0,
+ static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo()));
}
for (size_t i = 0; i < num_items; ++i) {
history_.AddAndRemoveOld(sent_packets[i].sequence_number,
sent_packets[i].payload_size,
- sent_packets[i].probe_cluster_id);
+ PacedPacketInfo(1, 2, 200));
}
for (size_t i = 0; i < num_items; ++i)
history_.OnSentPacket(sent_packets[i].sequence_number,
@@ -148,21 +121,19 @@ TEST_F(SendTimeHistoryTest, HistorySize) {
const int kItems = kDefaultHistoryLengthMs / 100;
for (int i = 0; i < kItems; ++i) {
clock_.AdvanceTimeMilliseconds(100);
- AddPacketWithSendTime(i, 0, i * 100, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(i, 0, i * 100, PacedPacketInfo());
}
for (int i = 0; i < kItems; ++i) {
- PacketInfo info(0, 0, static_cast<uint16_t>(i), 0,
- PacedPacketInfo::kNotAProbe);
+ PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, PacedPacketInfo());
EXPECT_TRUE(history_.GetInfo(&info, false));
EXPECT_EQ(i * 100, info.send_time_ms);
}
clock_.AdvanceTimeMilliseconds(101);
- AddPacketWithSendTime(kItems, 0, kItems * 101, PacedPacketInfo::kNotAProbe);
- PacketInfo info(0, 0, 0, 0, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(kItems, 0, kItems * 101, PacedPacketInfo());
+ PacketInfo info(0, 0, 0, 0, PacedPacketInfo());
EXPECT_FALSE(history_.GetInfo(&info, false));
for (int i = 1; i < (kItems + 1); ++i) {
- PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0,
- PacedPacketInfo::kNotAProbe);
+ PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, PacedPacketInfo());
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);
@@ -171,17 +142,16 @@ TEST_F(SendTimeHistoryTest, HistorySize) {
TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) {
const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max();
- AddPacketWithSendTime(kMaxSeqNo - 2, 0, 0, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(kMaxSeqNo - 2, 0, 0, PacedPacketInfo());
clock_.AdvanceTimeMilliseconds(100);
- AddPacketWithSendTime(kMaxSeqNo - 1, 1, 100, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(kMaxSeqNo - 1, 1, 100, PacedPacketInfo());
clock_.AdvanceTimeMilliseconds(100);
- AddPacketWithSendTime(kMaxSeqNo, 0, 200, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(kMaxSeqNo, 0, 200, PacedPacketInfo());
clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1);
- AddPacketWithSendTime(0, 0, kDefaultHistoryLengthMs,
- PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(0, 0, kDefaultHistoryLengthMs, PacedPacketInfo());
PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2));
EXPECT_FALSE(history_.GetInfo(&info, false));
@@ -197,7 +167,7 @@ TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) {
EXPECT_TRUE(history_.GetInfo(&info5, true));
clock_.AdvanceTimeMilliseconds(100);
- AddPacketWithSendTime(1, 0, 1100, PacedPacketInfo::kNotAProbe);
+ AddPacketWithSendTime(1, 0, 1100, PacedPacketInfo());
PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2));
EXPECT_FALSE(history_.GetInfo(&info6, false));
@@ -214,26 +184,29 @@ 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, 0},
- {0, kTimestamp + 1, kSeqNo + 1, 0, 1},
- {0, kTimestamp + 2, kSeqNo + 2, 0, 2}};
+ const PacedPacketInfo kPacingInfo1(1, 1, 100);
+ const PacedPacketInfo kPacingInfo2(2, 2, 200);
+ const PacedPacketInfo kPacingInfo3(3, 3, 300);
+ PacketInfo packets[3] = {{0, kTimestamp, kSeqNo, 0, kPacingInfo1},
+ {0, kTimestamp + 1, kSeqNo + 1, 0, kPacingInfo2},
+ {0, kTimestamp + 2, kSeqNo + 2, 0, kPacingInfo3}};
AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size,
- packets[0].send_time_ms, 0);
+ packets[0].send_time_ms, packets[0].pacing_info);
AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size,
- packets[1].send_time_ms, 1);
- PacketInfo info(0, 0, packets[0].sequence_number, 0, 0);
+ packets[1].send_time_ms, packets[1].pacing_info);
+ PacketInfo info(0, 0, packets[0].sequence_number, 0, PacedPacketInfo());
EXPECT_TRUE(history_.GetInfo(&info, true));
EXPECT_EQ(packets[0], info);
AddPacketWithSendTime(packets[2].sequence_number, packets[2].payload_size,
- packets[2].send_time_ms, 2);
+ packets[2].send_time_ms, packets[2].pacing_info);
- PacketInfo info2(0, 0, packets[1].sequence_number, 0, 1);
+ PacketInfo info2(0, 0, packets[1].sequence_number, 0, kPacingInfo1);
EXPECT_TRUE(history_.GetInfo(&info2, true));
EXPECT_EQ(packets[1], info2);
- PacketInfo info3(0, 0, packets[2].sequence_number, 0, 2);
+ PacketInfo info3(0, 0, packets[2].sequence_number, 0, kPacingInfo2);
EXPECT_TRUE(history_.GetInfo(&info3, true));
EXPECT_EQ(packets[2], info3);
}

Powered by Google App Engine
This is Rietveld 408576698