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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc

Issue 2628563003: Propagate packet pacing information to SenTimeHistory (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 }; 45 };
46 46
47 // Help class extended so we can do EXPECT_EQ and collections. 47 // Help class extended so we can do EXPECT_EQ and collections.
48 class PacketInfo : public webrtc::PacketInfo { 48 class PacketInfo : public webrtc::PacketInfo {
49 public: 49 public:
50 PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number) 50 PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number)
51 : PacketInfo(arrival_time_ms, 51 : PacketInfo(arrival_time_ms,
52 0, 52 0,
53 sequence_number, 53 sequence_number,
54 0, 54 0,
55 PacketInfo::kNotAProbe) {} 55 PacedPacketInfo::kNotAProbe) {}
56 PacketInfo(int64_t arrival_time_ms, 56 PacketInfo(int64_t arrival_time_ms,
57 int64_t send_time_ms, 57 int64_t send_time_ms,
58 uint16_t sequence_number, 58 uint16_t sequence_number,
59 size_t payload_size, 59 size_t payload_size,
60 int probe_cluster_id) 60 int probe_cluster_id)
61 : webrtc::PacketInfo(-1, 61 : webrtc::PacketInfo(-1,
62 arrival_time_ms, 62 arrival_time_ms,
63 send_time_ms, 63 send_time_ms,
64 sequence_number, 64 sequence_number,
65 payload_size, 65 payload_size,
(...skipping 25 matching lines...) Expand all
91 EXPECT_FALSE(history_.GetInfo(&received_packet3, true)); 91 EXPECT_FALSE(history_.GetInfo(&received_packet3, true));
92 } 92 }
93 93
94 TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) { 94 TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) {
95 const uint16_t kSeqNo = 10; 95 const uint16_t kSeqNo = 10;
96 const int64_t kSendTime = 1000; 96 const int64_t kSendTime = 1000;
97 const int64_t kReceiveTime = 2000; 97 const int64_t kReceiveTime = 2000;
98 const size_t kPayloadSize = 42; 98 const size_t kPayloadSize = 42;
99 99
100 AddPacketWithSendTime(kSeqNo, kPayloadSize, kSendTime, 100 AddPacketWithSendTime(kSeqNo, kPayloadSize, kSendTime,
101 PacketInfo::kNotAProbe); 101 PacedPacketInfo::kNotAProbe);
102 102
103 PacketInfo info(kReceiveTime, kSeqNo); 103 PacketInfo info(kReceiveTime, kSeqNo);
104 EXPECT_TRUE(history_.GetInfo(&info, true)); 104 EXPECT_TRUE(history_.GetInfo(&info, true));
105 EXPECT_EQ(kReceiveTime, info.arrival_time_ms); 105 EXPECT_EQ(kReceiveTime, info.arrival_time_ms);
106 EXPECT_EQ(kSendTime, info.send_time_ms); 106 EXPECT_EQ(kSendTime, info.send_time_ms);
107 EXPECT_EQ(kSeqNo, info.sequence_number); 107 EXPECT_EQ(kSeqNo, info.sequence_number);
108 EXPECT_EQ(kPayloadSize, info.payload_size); 108 EXPECT_EQ(kPayloadSize, info.payload_size);
109 } 109 }
110 110
111 TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) { 111 TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) {
112 std::vector<PacketInfo> sent_packets; 112 std::vector<PacketInfo> sent_packets;
113 std::vector<PacketInfo> received_packets; 113 std::vector<PacketInfo> received_packets;
114 const size_t num_items = 100; 114 const size_t num_items = 100;
115 const size_t kPacketSize = 400; 115 const size_t kPacketSize = 400;
116 const size_t kTransmissionTime = 1234; 116 const size_t kTransmissionTime = 1234;
117 const int kProbeClusterId = 1; 117 const int kProbeClusterId = 1;
118 for (size_t i = 0; i < num_items; ++i) { 118 for (size_t i = 0; i < num_items; ++i) {
119 sent_packets.push_back(PacketInfo(0, static_cast<int64_t>(i), 119 sent_packets.push_back(PacketInfo(0, static_cast<int64_t>(i),
120 static_cast<uint16_t>(i), kPacketSize, 120 static_cast<uint16_t>(i), kPacketSize,
121 kProbeClusterId)); 121 kProbeClusterId));
122 received_packets.push_back(PacketInfo( 122 received_packets.push_back(PacketInfo(
123 static_cast<int64_t>(i) + kTransmissionTime, 0, 123 static_cast<int64_t>(i) + kTransmissionTime, 0,
124 static_cast<uint16_t>(i), kPacketSize, PacketInfo::kNotAProbe)); 124 static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo::kNotAProbe));
125 } 125 }
126 for (size_t i = 0; i < num_items; ++i) { 126 for (size_t i = 0; i < num_items; ++i) {
127 history_.AddAndRemoveOld(sent_packets[i].sequence_number, 127 history_.AddAndRemoveOld(sent_packets[i].sequence_number,
128 sent_packets[i].payload_size, 128 sent_packets[i].payload_size,
129 sent_packets[i].probe_cluster_id); 129 sent_packets[i].probe_cluster_id);
130 } 130 }
131 for (size_t i = 0; i < num_items; ++i) 131 for (size_t i = 0; i < num_items; ++i)
132 history_.OnSentPacket(sent_packets[i].sequence_number, 132 history_.OnSentPacket(sent_packets[i].sequence_number,
133 sent_packets[i].send_time_ms); 133 sent_packets[i].send_time_ms);
134 std::random_shuffle(received_packets.begin(), received_packets.end()); 134 std::random_shuffle(received_packets.begin(), received_packets.end());
135 for (size_t i = 0; i < num_items; ++i) { 135 for (size_t i = 0; i < num_items; ++i) {
136 PacketInfo packet = received_packets[i]; 136 PacketInfo packet = received_packets[i];
137 EXPECT_TRUE(history_.GetInfo(&packet, false)); 137 EXPECT_TRUE(history_.GetInfo(&packet, false));
138 PacketInfo sent_packet = sent_packets[packet.sequence_number]; 138 PacketInfo sent_packet = sent_packets[packet.sequence_number];
139 sent_packet.arrival_time_ms = packet.arrival_time_ms; 139 sent_packet.arrival_time_ms = packet.arrival_time_ms;
140 EXPECT_EQ(sent_packet, packet); 140 EXPECT_EQ(sent_packet, packet);
141 EXPECT_TRUE(history_.GetInfo(&packet, true)); 141 EXPECT_TRUE(history_.GetInfo(&packet, true));
142 } 142 }
143 for (PacketInfo packet : sent_packets) 143 for (PacketInfo packet : sent_packets)
144 EXPECT_FALSE(history_.GetInfo(&packet, false)); 144 EXPECT_FALSE(history_.GetInfo(&packet, false));
145 } 145 }
146 146
147 TEST_F(SendTimeHistoryTest, HistorySize) { 147 TEST_F(SendTimeHistoryTest, HistorySize) {
148 const int kItems = kDefaultHistoryLengthMs / 100; 148 const int kItems = kDefaultHistoryLengthMs / 100;
149 for (int i = 0; i < kItems; ++i) { 149 for (int i = 0; i < kItems; ++i) {
150 clock_.AdvanceTimeMilliseconds(100); 150 clock_.AdvanceTimeMilliseconds(100);
151 AddPacketWithSendTime(i, 0, i * 100, PacketInfo::kNotAProbe); 151 AddPacketWithSendTime(i, 0, i * 100, PacedPacketInfo::kNotAProbe);
152 } 152 }
153 for (int i = 0; i < kItems; ++i) { 153 for (int i = 0; i < kItems; ++i) {
154 PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, PacketInfo::kNotAProbe); 154 PacketInfo info(0, 0, static_cast<uint16_t>(i), 0,
155 PacedPacketInfo::kNotAProbe);
155 EXPECT_TRUE(history_.GetInfo(&info, false)); 156 EXPECT_TRUE(history_.GetInfo(&info, false));
156 EXPECT_EQ(i * 100, info.send_time_ms); 157 EXPECT_EQ(i * 100, info.send_time_ms);
157 } 158 }
158 clock_.AdvanceTimeMilliseconds(101); 159 clock_.AdvanceTimeMilliseconds(101);
159 AddPacketWithSendTime(kItems, 0, kItems * 101, PacketInfo::kNotAProbe); 160 AddPacketWithSendTime(kItems, 0, kItems * 101, PacedPacketInfo::kNotAProbe);
160 PacketInfo info(0, 0, 0, 0, PacketInfo::kNotAProbe); 161 PacketInfo info(0, 0, 0, 0, PacedPacketInfo::kNotAProbe);
161 EXPECT_FALSE(history_.GetInfo(&info, false)); 162 EXPECT_FALSE(history_.GetInfo(&info, false));
162 for (int i = 1; i < (kItems + 1); ++i) { 163 for (int i = 1; i < (kItems + 1); ++i) {
163 PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, PacketInfo::kNotAProbe); 164 PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0,
165 PacedPacketInfo::kNotAProbe);
164 EXPECT_TRUE(history_.GetInfo(&info2, false)); 166 EXPECT_TRUE(history_.GetInfo(&info2, false));
165 int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100; 167 int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100;
166 EXPECT_EQ(expected_time_ms, info2.send_time_ms); 168 EXPECT_EQ(expected_time_ms, info2.send_time_ms);
167 } 169 }
168 } 170 }
169 171
170 TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { 172 TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) {
171 const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max(); 173 const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max();
172 AddPacketWithSendTime(kMaxSeqNo - 2, 0, 0, PacketInfo::kNotAProbe); 174 AddPacketWithSendTime(kMaxSeqNo - 2, 0, 0, PacedPacketInfo::kNotAProbe);
173 175
174 clock_.AdvanceTimeMilliseconds(100); 176 clock_.AdvanceTimeMilliseconds(100);
175 AddPacketWithSendTime(kMaxSeqNo - 1, 1, 100, PacketInfo::kNotAProbe); 177 AddPacketWithSendTime(kMaxSeqNo - 1, 1, 100, PacedPacketInfo::kNotAProbe);
176 178
177 clock_.AdvanceTimeMilliseconds(100); 179 clock_.AdvanceTimeMilliseconds(100);
178 AddPacketWithSendTime(kMaxSeqNo, 0, 200, PacketInfo::kNotAProbe); 180 AddPacketWithSendTime(kMaxSeqNo, 0, 200, PacedPacketInfo::kNotAProbe);
179 181
180 clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1); 182 clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1);
181 AddPacketWithSendTime(0, 0, kDefaultHistoryLengthMs, PacketInfo::kNotAProbe); 183 AddPacketWithSendTime(0, 0, kDefaultHistoryLengthMs,
184 PacedPacketInfo::kNotAProbe);
182 185
183 PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2)); 186 PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2));
184 EXPECT_FALSE(history_.GetInfo(&info, false)); 187 EXPECT_FALSE(history_.GetInfo(&info, false));
185 PacketInfo info2(0, static_cast<uint16_t>(kMaxSeqNo - 1)); 188 PacketInfo info2(0, static_cast<uint16_t>(kMaxSeqNo - 1));
186 EXPECT_TRUE(history_.GetInfo(&info2, false)); 189 EXPECT_TRUE(history_.GetInfo(&info2, false));
187 PacketInfo info3(0, static_cast<uint16_t>(kMaxSeqNo)); 190 PacketInfo info3(0, static_cast<uint16_t>(kMaxSeqNo));
188 EXPECT_TRUE(history_.GetInfo(&info3, false)); 191 EXPECT_TRUE(history_.GetInfo(&info3, false));
189 PacketInfo info4(0, 0); 192 PacketInfo info4(0, 0);
190 EXPECT_TRUE(history_.GetInfo(&info4, false)); 193 EXPECT_TRUE(history_.GetInfo(&info4, false));
191 194
192 // Create a gap (kMaxSeqNo - 1) -> 0. 195 // Create a gap (kMaxSeqNo - 1) -> 0.
193 PacketInfo info5(0, kMaxSeqNo); 196 PacketInfo info5(0, kMaxSeqNo);
194 EXPECT_TRUE(history_.GetInfo(&info5, true)); 197 EXPECT_TRUE(history_.GetInfo(&info5, true));
195 198
196 clock_.AdvanceTimeMilliseconds(100); 199 clock_.AdvanceTimeMilliseconds(100);
197 AddPacketWithSendTime(1, 0, 1100, PacketInfo::kNotAProbe); 200 AddPacketWithSendTime(1, 0, 1100, PacedPacketInfo::kNotAProbe);
198 201
199 PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2)); 202 PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2));
200 EXPECT_FALSE(history_.GetInfo(&info6, false)); 203 EXPECT_FALSE(history_.GetInfo(&info6, false));
201 PacketInfo info7(0, static_cast<uint16_t>(kMaxSeqNo - 1)); 204 PacketInfo info7(0, static_cast<uint16_t>(kMaxSeqNo - 1));
202 EXPECT_FALSE(history_.GetInfo(&info7, false)); 205 EXPECT_FALSE(history_.GetInfo(&info7, false));
203 PacketInfo info8(0, kMaxSeqNo); 206 PacketInfo info8(0, kMaxSeqNo);
204 EXPECT_FALSE(history_.GetInfo(&info8, false)); 207 EXPECT_FALSE(history_.GetInfo(&info8, false));
205 PacketInfo info9(0, 0); 208 PacketInfo info9(0, 0);
206 EXPECT_TRUE(history_.GetInfo(&info9, false)); 209 EXPECT_TRUE(history_.GetInfo(&info9, false));
207 PacketInfo info10(0, 1); 210 PacketInfo info10(0, 1);
(...skipping 22 matching lines...) Expand all
230 EXPECT_TRUE(history_.GetInfo(&info2, true)); 233 EXPECT_TRUE(history_.GetInfo(&info2, true));
231 EXPECT_EQ(packets[1], info2); 234 EXPECT_EQ(packets[1], info2);
232 235
233 PacketInfo info3(0, 0, packets[2].sequence_number, 0, 2); 236 PacketInfo info3(0, 0, packets[2].sequence_number, 0, 2);
234 EXPECT_TRUE(history_.GetInfo(&info3, true)); 237 EXPECT_TRUE(history_.GetInfo(&info3, true));
235 EXPECT_EQ(packets[2], info3); 238 EXPECT_EQ(packets[2], info3);
236 } 239 }
237 240
238 } // namespace test 241 } // namespace test
239 } // namespace webrtc 242 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/packet_router_unittest.cc ('k') | webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698