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

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

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

Powered by Google App Engine
This is Rietveld 408576698