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

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

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

Powered by Google App Engine
This is Rietveld 408576698