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

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

Issue 2032473002: Revert "Revert of Propagate probing cluster id to SendTimeHistory. (patchset #5 id:80001 of https:/… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 16 matching lines...) Expand all
27 : clock_(0), history_(&clock_, kDefaultHistoryLengthMs) {} 27 : clock_(0), history_(&clock_, kDefaultHistoryLengthMs) {}
28 ~SendTimeHistoryTest() {} 28 ~SendTimeHistoryTest() {}
29 29
30 virtual void SetUp() {} 30 virtual void SetUp() {}
31 31
32 virtual void TearDown() {} 32 virtual void TearDown() {}
33 33
34 void AddPacketWithSendTime(uint16_t sequence_number, 34 void AddPacketWithSendTime(uint16_t sequence_number,
35 size_t length, 35 size_t length,
36 bool was_paced, 36 bool was_paced,
37 int64_t send_time_ms) { 37 int64_t send_time_ms,
38 history_.AddAndRemoveOld(sequence_number, length, was_paced); 38 int probe_cluster_id) {
39 history_.AddAndRemoveOld(sequence_number, length, was_paced,
40 probe_cluster_id);
39 history_.OnSentPacket(sequence_number, send_time_ms); 41 history_.OnSentPacket(sequence_number, send_time_ms);
40 } 42 }
41 43
42 webrtc::SimulatedClock clock_; 44 webrtc::SimulatedClock clock_;
43 SendTimeHistory history_; 45 SendTimeHistory history_;
44 }; 46 };
45 47
46 // Help class extended so we can do EXPECT_EQ and collections. 48 // Help class extended so we can do EXPECT_EQ and collections.
47 class PacketInfo : public webrtc::PacketInfo { 49 class PacketInfo : public webrtc::PacketInfo {
48 public: 50 public:
49 PacketInfo() : webrtc::PacketInfo(-1, 0, 0, 0, 0, false) {} 51 PacketInfo()
52 : webrtc::PacketInfo(-1,
53 0,
54 0,
55 0,
56 0,
57 false,
58 webrtc::PacketInfo::kNotAProbe) {}
50 PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number) 59 PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number)
51 : PacketInfo(arrival_time_ms, 0, sequence_number, 0, false) {} 60 : PacketInfo(arrival_time_ms,
61 0,
62 sequence_number,
63 0,
64 false,
65 PacketInfo::kNotAProbe) {}
52 PacketInfo(int64_t arrival_time_ms, 66 PacketInfo(int64_t arrival_time_ms,
53 int64_t send_time_ms, 67 int64_t send_time_ms,
54 uint16_t sequence_number, 68 uint16_t sequence_number,
55 size_t payload_size, 69 size_t payload_size,
56 bool was_paced) 70 bool was_paced,
71 int probe_cluster_id)
57 : webrtc::PacketInfo(-1, 72 : webrtc::PacketInfo(-1,
58 arrival_time_ms, 73 arrival_time_ms,
59 send_time_ms, 74 send_time_ms,
60 sequence_number, 75 sequence_number,
61 payload_size, 76 payload_size,
62 was_paced) {} 77 was_paced,
78 probe_cluster_id) {}
63 bool operator==(const PacketInfo& other) const { 79 bool operator==(const PacketInfo& other) const {
64 return arrival_time_ms == other.arrival_time_ms && 80 return arrival_time_ms == other.arrival_time_ms &&
65 send_time_ms == other.send_time_ms && 81 send_time_ms == other.send_time_ms &&
66 sequence_number == other.sequence_number && 82 sequence_number == other.sequence_number &&
67 payload_size == other.payload_size && was_paced == other.was_paced; 83 payload_size == other.payload_size && was_paced == other.was_paced &&
84 probe_cluster_id == other.probe_cluster_id;
68 } 85 }
69 }; 86 };
70 87
71 TEST_F(SendTimeHistoryTest, AddRemoveOne) { 88 TEST_F(SendTimeHistoryTest, AddRemoveOne) {
72 const uint16_t kSeqNo = 10; 89 const uint16_t kSeqNo = 10;
73 const PacketInfo kSentPacket(0, 1, kSeqNo, 1, true); 90 const int kProbeClusterId = 0;
74 AddPacketWithSendTime(kSeqNo, 1, true, 1); 91 const PacketInfo kSentPacket(0, 1, kSeqNo, 1, true, kProbeClusterId);
92 AddPacketWithSendTime(kSeqNo, 1, true, 1, kProbeClusterId);
75 93
76 PacketInfo received_packet(0, 0, kSeqNo, 0, false); 94 PacketInfo received_packet(0, 0, kSeqNo, 0, false, kProbeClusterId);
77 EXPECT_TRUE(history_.GetInfo(&received_packet, false)); 95 EXPECT_TRUE(history_.GetInfo(&received_packet, false));
78 EXPECT_EQ(kSentPacket, received_packet); 96 EXPECT_EQ(kSentPacket, received_packet);
79 97
80 PacketInfo received_packet2(0, 0, kSeqNo, 0, false); 98 PacketInfo received_packet2(0, 0, kSeqNo, 0, false, kProbeClusterId);
81 EXPECT_TRUE(history_.GetInfo(&received_packet2, true)); 99 EXPECT_TRUE(history_.GetInfo(&received_packet2, true));
82 EXPECT_EQ(kSentPacket, received_packet2); 100 EXPECT_EQ(kSentPacket, received_packet2);
83 101
84 PacketInfo received_packet3(0, 0, kSeqNo, 0, false); 102 PacketInfo received_packet3(0, 0, kSeqNo, 0, false, kProbeClusterId);
85 EXPECT_FALSE(history_.GetInfo(&received_packet3, true)); 103 EXPECT_FALSE(history_.GetInfo(&received_packet3, true));
86 } 104 }
87 105
88 TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) { 106 TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) {
89 const uint16_t kSeqNo = 10; 107 const uint16_t kSeqNo = 10;
90 const int64_t kSendTime = 1000; 108 const int64_t kSendTime = 1000;
91 const int64_t kReceiveTime = 2000; 109 const int64_t kReceiveTime = 2000;
92 const size_t kPayloadSize = 42; 110 const size_t kPayloadSize = 42;
93 const bool kPaced = true; 111 const bool kPaced = true;
94 112
95 AddPacketWithSendTime(kSeqNo, kPayloadSize, kPaced, kSendTime); 113 AddPacketWithSendTime(kSeqNo, kPayloadSize, kPaced, kSendTime,
114 PacketInfo::kNotAProbe);
96 115
97 PacketInfo info(kReceiveTime, kSeqNo); 116 PacketInfo info(kReceiveTime, kSeqNo);
98 EXPECT_TRUE(history_.GetInfo(&info, true)); 117 EXPECT_TRUE(history_.GetInfo(&info, true));
99 EXPECT_EQ(kReceiveTime, info.arrival_time_ms); 118 EXPECT_EQ(kReceiveTime, info.arrival_time_ms);
100 EXPECT_EQ(kSendTime, info.send_time_ms); 119 EXPECT_EQ(kSendTime, info.send_time_ms);
101 EXPECT_EQ(kSeqNo, info.sequence_number); 120 EXPECT_EQ(kSeqNo, info.sequence_number);
102 EXPECT_EQ(kPayloadSize, info.payload_size); 121 EXPECT_EQ(kPayloadSize, info.payload_size);
103 EXPECT_EQ(kPaced, info.was_paced); 122 EXPECT_EQ(kPaced, info.was_paced);
104 } 123 }
105 124
106 TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) { 125 TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) {
107 std::vector<PacketInfo> sent_packets; 126 std::vector<PacketInfo> sent_packets;
108 std::vector<PacketInfo> received_packets; 127 std::vector<PacketInfo> received_packets;
109 const size_t num_items = 100; 128 const size_t num_items = 100;
110 const size_t kPacketSize = 400; 129 const size_t kPacketSize = 400;
111 const size_t kTransmissionTime = 1234; 130 const size_t kTransmissionTime = 1234;
112 const bool kPaced = true; 131 const bool kPaced = true;
132 const int kProbeClusterId = 1;
113 for (size_t i = 0; i < num_items; ++i) { 133 for (size_t i = 0; i < num_items; ++i) {
114 sent_packets.push_back(PacketInfo(0, static_cast<int64_t>(i), 134 sent_packets.push_back(PacketInfo(0, static_cast<int64_t>(i),
115 static_cast<uint16_t>(i), kPacketSize, 135 static_cast<uint16_t>(i), kPacketSize,
116 kPaced)); 136 kPaced, kProbeClusterId));
117 received_packets.push_back( 137 received_packets.push_back(PacketInfo(
118 PacketInfo(static_cast<int64_t>(i) + kTransmissionTime, 0, 138 static_cast<int64_t>(i) + kTransmissionTime, 0,
119 static_cast<uint16_t>(i), kPacketSize, false)); 139 static_cast<uint16_t>(i), kPacketSize, false, PacketInfo::kNotAProbe));
120 } 140 }
121 for (size_t i = 0; i < num_items; ++i) { 141 for (size_t i = 0; i < num_items; ++i) {
122 history_.AddAndRemoveOld(sent_packets[i].sequence_number, 142 history_.AddAndRemoveOld(
123 sent_packets[i].payload_size, 143 sent_packets[i].sequence_number, sent_packets[i].payload_size,
124 sent_packets[i].was_paced); 144 sent_packets[i].was_paced, sent_packets[i].probe_cluster_id);
125 } 145 }
126 for (size_t i = 0; i < num_items; ++i) 146 for (size_t i = 0; i < num_items; ++i)
127 history_.OnSentPacket(sent_packets[i].sequence_number, 147 history_.OnSentPacket(sent_packets[i].sequence_number,
128 sent_packets[i].send_time_ms); 148 sent_packets[i].send_time_ms);
129 std::random_shuffle(received_packets.begin(), received_packets.end()); 149 std::random_shuffle(received_packets.begin(), received_packets.end());
130 for (size_t i = 0; i < num_items; ++i) { 150 for (size_t i = 0; i < num_items; ++i) {
131 PacketInfo packet = received_packets[i]; 151 PacketInfo packet = received_packets[i];
132 EXPECT_TRUE(history_.GetInfo(&packet, false)); 152 EXPECT_TRUE(history_.GetInfo(&packet, false));
133 PacketInfo sent_packet = sent_packets[packet.sequence_number]; 153 PacketInfo sent_packet = sent_packets[packet.sequence_number];
134 sent_packet.arrival_time_ms = packet.arrival_time_ms; 154 sent_packet.arrival_time_ms = packet.arrival_time_ms;
135 EXPECT_EQ(sent_packet, packet); 155 EXPECT_EQ(sent_packet, packet);
136 EXPECT_TRUE(history_.GetInfo(&packet, true)); 156 EXPECT_TRUE(history_.GetInfo(&packet, true));
137 } 157 }
138 for (PacketInfo packet : sent_packets) 158 for (PacketInfo packet : sent_packets)
139 EXPECT_FALSE(history_.GetInfo(&packet, false)); 159 EXPECT_FALSE(history_.GetInfo(&packet, false));
140 } 160 }
141 161
142 TEST_F(SendTimeHistoryTest, HistorySize) { 162 TEST_F(SendTimeHistoryTest, HistorySize) {
143 const int kItems = kDefaultHistoryLengthMs / 100; 163 const int kItems = kDefaultHistoryLengthMs / 100;
144 for (int i = 0; i < kItems; ++i) { 164 for (int i = 0; i < kItems; ++i) {
145 clock_.AdvanceTimeMilliseconds(100); 165 clock_.AdvanceTimeMilliseconds(100);
146 AddPacketWithSendTime(i, 0, false, i * 100); 166 AddPacketWithSendTime(i, 0, false, i * 100, PacketInfo::kNotAProbe);
147 } 167 }
148 for (int i = 0; i < kItems; ++i) { 168 for (int i = 0; i < kItems; ++i) {
149 PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, false); 169 PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, false,
170 PacketInfo::kNotAProbe);
150 EXPECT_TRUE(history_.GetInfo(&info, false)); 171 EXPECT_TRUE(history_.GetInfo(&info, false));
151 EXPECT_EQ(i * 100, info.send_time_ms); 172 EXPECT_EQ(i * 100, info.send_time_ms);
152 } 173 }
153 clock_.AdvanceTimeMilliseconds(101); 174 clock_.AdvanceTimeMilliseconds(101);
154 AddPacketWithSendTime(kItems, 0, false, kItems * 101); 175 AddPacketWithSendTime(kItems, 0, false, kItems * 101, PacketInfo::kNotAProbe);
155 PacketInfo info(0, 0, 0, 0, false); 176 PacketInfo info(0, 0, 0, 0, false, PacketInfo::kNotAProbe);
156 EXPECT_FALSE(history_.GetInfo(&info, false)); 177 EXPECT_FALSE(history_.GetInfo(&info, false));
157 for (int i = 1; i < (kItems + 1); ++i) { 178 for (int i = 1; i < (kItems + 1); ++i) {
158 PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, false); 179 PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, false,
180 PacketInfo::kNotAProbe);
159 EXPECT_TRUE(history_.GetInfo(&info2, false)); 181 EXPECT_TRUE(history_.GetInfo(&info2, false));
160 int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100; 182 int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100;
161 EXPECT_EQ(expected_time_ms, info2.send_time_ms); 183 EXPECT_EQ(expected_time_ms, info2.send_time_ms);
162 } 184 }
163 } 185 }
164 186
165 TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { 187 TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) {
166 const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max(); 188 const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max();
167 AddPacketWithSendTime(kMaxSeqNo - 2, 0, false, 0); 189 AddPacketWithSendTime(kMaxSeqNo - 2, 0, false, 0, PacketInfo::kNotAProbe);
168 190
169 clock_.AdvanceTimeMilliseconds(100); 191 clock_.AdvanceTimeMilliseconds(100);
170 AddPacketWithSendTime(kMaxSeqNo - 1, 1, false, 100); 192 AddPacketWithSendTime(kMaxSeqNo - 1, 1, false, 100, PacketInfo::kNotAProbe);
171 193
172 clock_.AdvanceTimeMilliseconds(100); 194 clock_.AdvanceTimeMilliseconds(100);
173 AddPacketWithSendTime(kMaxSeqNo, 0, false, 200); 195 AddPacketWithSendTime(kMaxSeqNo, 0, false, 200, PacketInfo::kNotAProbe);
174 196
175 clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1); 197 clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1);
176 AddPacketWithSendTime(0, 0, false, kDefaultHistoryLengthMs); 198 AddPacketWithSendTime(0, 0, false, kDefaultHistoryLengthMs,
199 PacketInfo::kNotAProbe);
177 200
178 PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2)); 201 PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2));
179 EXPECT_FALSE(history_.GetInfo(&info, false)); 202 EXPECT_FALSE(history_.GetInfo(&info, false));
180 PacketInfo info2(0, static_cast<uint16_t>(kMaxSeqNo - 1)); 203 PacketInfo info2(0, static_cast<uint16_t>(kMaxSeqNo - 1));
181 EXPECT_TRUE(history_.GetInfo(&info2, false)); 204 EXPECT_TRUE(history_.GetInfo(&info2, false));
182 PacketInfo info3(0, static_cast<uint16_t>(kMaxSeqNo)); 205 PacketInfo info3(0, static_cast<uint16_t>(kMaxSeqNo));
183 EXPECT_TRUE(history_.GetInfo(&info3, false)); 206 EXPECT_TRUE(history_.GetInfo(&info3, false));
184 PacketInfo info4(0, 0); 207 PacketInfo info4(0, 0);
185 EXPECT_TRUE(history_.GetInfo(&info4, false)); 208 EXPECT_TRUE(history_.GetInfo(&info4, false));
186 209
187 // Create a gap (kMaxSeqNo - 1) -> 0. 210 // Create a gap (kMaxSeqNo - 1) -> 0.
188 PacketInfo info5(0, kMaxSeqNo); 211 PacketInfo info5(0, kMaxSeqNo);
189 EXPECT_TRUE(history_.GetInfo(&info5, true)); 212 EXPECT_TRUE(history_.GetInfo(&info5, true));
190 213
191 clock_.AdvanceTimeMilliseconds(100); 214 clock_.AdvanceTimeMilliseconds(100);
192 AddPacketWithSendTime(1, 0, false, 1100); 215 AddPacketWithSendTime(1, 0, false, 1100, PacketInfo::kNotAProbe);
193 216
194 PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2)); 217 PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2));
195 EXPECT_FALSE(history_.GetInfo(&info6, false)); 218 EXPECT_FALSE(history_.GetInfo(&info6, false));
196 PacketInfo info7(0, static_cast<uint16_t>(kMaxSeqNo - 1)); 219 PacketInfo info7(0, static_cast<uint16_t>(kMaxSeqNo - 1));
197 EXPECT_FALSE(history_.GetInfo(&info7, false)); 220 EXPECT_FALSE(history_.GetInfo(&info7, false));
198 PacketInfo info8(0, kMaxSeqNo); 221 PacketInfo info8(0, kMaxSeqNo);
199 EXPECT_FALSE(history_.GetInfo(&info8, false)); 222 EXPECT_FALSE(history_.GetInfo(&info8, false));
200 PacketInfo info9(0, 0); 223 PacketInfo info9(0, 0);
201 EXPECT_TRUE(history_.GetInfo(&info9, false)); 224 EXPECT_TRUE(history_.GetInfo(&info9, false));
202 PacketInfo info10(0, 1); 225 PacketInfo info10(0, 1);
203 EXPECT_TRUE(history_.GetInfo(&info10, false)); 226 EXPECT_TRUE(history_.GetInfo(&info10, false));
204 } 227 }
205 228
206 TEST_F(SendTimeHistoryTest, InterlievedGetAndRemove) { 229 TEST_F(SendTimeHistoryTest, InterlievedGetAndRemove) {
207 const uint16_t kSeqNo = 1; 230 const uint16_t kSeqNo = 1;
208 const int64_t kTimestamp = 2; 231 const int64_t kTimestamp = 2;
209 PacketInfo packets[3] = {{0, kTimestamp, kSeqNo, 0, false}, 232 PacketInfo packets[3] = {{0, kTimestamp, kSeqNo, 0, false, 0},
210 {0, kTimestamp + 1, kSeqNo + 1, 0, false}, 233 {0, kTimestamp + 1, kSeqNo + 1, 0, false, 1},
211 {0, kTimestamp + 2, kSeqNo + 2, 0, false}}; 234 {0, kTimestamp + 2, kSeqNo + 2, 0, false, 2}};
212 235
213 AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size, 236 AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size,
214 packets[0].was_paced, packets[0].send_time_ms); 237 packets[0].was_paced, packets[0].send_time_ms, 0);
215 AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size, 238 AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size,
216 packets[1].was_paced, packets[1].send_time_ms); 239 packets[1].was_paced, packets[1].send_time_ms, 1);
217 PacketInfo info(0, 0, packets[0].sequence_number, 0, false); 240 PacketInfo info(0, 0, packets[0].sequence_number, 0, false, 0);
218 EXPECT_TRUE(history_.GetInfo(&info, true)); 241 EXPECT_TRUE(history_.GetInfo(&info, true));
219 EXPECT_EQ(packets[0], info); 242 EXPECT_EQ(packets[0], info);
220 243
221 AddPacketWithSendTime(packets[2].sequence_number, packets[2].payload_size, 244 AddPacketWithSendTime(packets[2].sequence_number, packets[2].payload_size,
222 packets[2].was_paced, packets[2].send_time_ms); 245 packets[2].was_paced, packets[2].send_time_ms, 2);
223 246
224 PacketInfo info2(0, 0, packets[1].sequence_number, 0, false); 247 PacketInfo info2(0, 0, packets[1].sequence_number, 0, false, 1);
225 EXPECT_TRUE(history_.GetInfo(&info2, true)); 248 EXPECT_TRUE(history_.GetInfo(&info2, true));
226 EXPECT_EQ(packets[1], info2); 249 EXPECT_EQ(packets[1], info2);
227 250
228 PacketInfo info3(0, 0, packets[2].sequence_number, 0, false); 251 PacketInfo info3(0, 0, packets[2].sequence_number, 0, false, 2);
229 EXPECT_TRUE(history_.GetInfo(&info3, true)); 252 EXPECT_TRUE(history_.GetInfo(&info3, true));
230 EXPECT_EQ(packets[2], info3); 253 EXPECT_EQ(packets[2], info3);
231 } 254 }
232 255
233 } // namespace test 256 } // namespace test
234 } // namespace webrtc 257 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698