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

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.cc

Issue 2708873003: Propagate packet pacing information to SendTimeHistory. (Closed)
Patch Set: TransportFeedbackAdapterTest fix. 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h " 10 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h "
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 RTC_CHECK(packets != NULL); 54 RTC_CHECK(packets != NULL);
55 size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; 55 size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
56 size_t n_packets = 56 size_t n_packets =
57 std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); 57 std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
58 size_t payload_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets); 58 size_t payload_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets);
59 for (size_t i = 0; i < n_packets; ++i) { 59 for (size_t i = 0; i < n_packets; ++i) {
60 PacketInfo packet(-1, sequence_number_++); 60 PacketInfo packet(-1, sequence_number_++);
61 packet.send_time_ms = (time_now_us + kSendSideOffsetUs) / 1000; 61 packet.send_time_ms = (time_now_us + kSendSideOffsetUs) / 1000;
62 packet.payload_size = payload_size; 62 packet.payload_size = payload_size;
63 packet.probe_cluster_id = PacedPacketInfo::kNotAProbe;
64 packets->push_back(packet); 63 packets->push_back(packet);
65 } 64 }
66 next_rtp_time_ = time_now_us + (1000000 + fps_ / 2) / fps_; 65 next_rtp_time_ = time_now_us + (1000000 + fps_ / 2) / fps_;
67 return next_rtp_time_; 66 return next_rtp_time_;
68 } 67 }
69 68
70 // The send-side time when the next frame can be generated. 69 // The send-side time when the next frame can be generated.
71 int64_t RtpStream::next_rtp_time() const { 70 int64_t RtpStream::next_rtp_time() const {
72 return next_rtp_time_; 71 return next_rtp_time_;
73 } 72 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 stream_generator_->AddStream(new test::RtpStream(30, 3e5)); 161 stream_generator_->AddStream(new test::RtpStream(30, 3e5));
163 } 162 }
164 163
165 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0; 164 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0;
166 165
167 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, 166 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms,
168 int64_t send_time_ms, 167 int64_t send_time_ms,
169 uint16_t sequence_number, 168 uint16_t sequence_number,
170 size_t payload_size) { 169 size_t payload_size) {
171 IncomingFeedback(arrival_time_ms, send_time_ms, sequence_number, payload_size, 170 IncomingFeedback(arrival_time_ms, send_time_ms, sequence_number, payload_size,
172 PacedPacketInfo::kNotAProbe); 171 PacedPacketInfo());
173 } 172 }
174 173
175 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, 174 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms,
176 int64_t send_time_ms, 175 int64_t send_time_ms,
177 uint16_t sequence_number, 176 uint16_t sequence_number,
178 size_t payload_size, 177 size_t payload_size,
179 int probe_cluster_id) { 178 const PacedPacketInfo& pacing_info) {
180 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); 179 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0);
181 PacketInfo packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, 180 PacketInfo packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms,
182 sequence_number, payload_size, probe_cluster_id); 181 sequence_number, payload_size, pacing_info);
183 std::vector<PacketInfo> packets; 182 std::vector<PacketInfo> packets;
184 packets.push_back(packet); 183 packets.push_back(packet);
185 DelayBasedBwe::Result result = 184 DelayBasedBwe::Result result =
186 bitrate_estimator_->IncomingPacketFeedbackVector(packets); 185 bitrate_estimator_->IncomingPacketFeedbackVector(packets);
187 const uint32_t kDummySsrc = 0; 186 const uint32_t kDummySsrc = 0;
188 if (result.updated) { 187 if (result.updated) {
189 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, 188 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc},
190 result.target_bitrate_bps); 189 result.target_bitrate_bps);
191 } 190 }
192 } 191 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 257 }
259 } 258 }
260 EXPECT_TRUE(bitrate_update_seen); 259 EXPECT_TRUE(bitrate_update_seen);
261 return bitrate_bps; 260 return bitrate_bps;
262 } 261 }
263 262
264 void DelayBasedBweTest::InitialBehaviorTestHelper( 263 void DelayBasedBweTest::InitialBehaviorTestHelper(
265 uint32_t expected_converge_bitrate) { 264 uint32_t expected_converge_bitrate) {
266 const int kFramerate = 50; // 50 fps to avoid rounding errors. 265 const int kFramerate = 50; // 50 fps to avoid rounding errors.
267 const int kFrameIntervalMs = 1000 / kFramerate; 266 const int kFrameIntervalMs = 1000 / kFramerate;
267 const PacedPacketInfo kPacingInfo(0, 1, 100);
268 uint32_t bitrate_bps = 0; 268 uint32_t bitrate_bps = 0;
269 int64_t send_time_ms = 0; 269 int64_t send_time_ms = 0;
270 uint16_t sequence_number = 0; 270 uint16_t sequence_number = 0;
271 std::vector<uint32_t> ssrcs; 271 std::vector<uint32_t> ssrcs;
272 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); 272 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
273 EXPECT_EQ(0u, ssrcs.size()); 273 EXPECT_EQ(0u, ssrcs.size());
274 clock_.AdvanceTimeMilliseconds(1000); 274 clock_.AdvanceTimeMilliseconds(1000);
275 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); 275 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
276 EXPECT_FALSE(bitrate_observer_.updated()); 276 EXPECT_FALSE(bitrate_observer_.updated());
277 bitrate_observer_.Reset(); 277 bitrate_observer_.Reset();
278 clock_.AdvanceTimeMilliseconds(1000); 278 clock_.AdvanceTimeMilliseconds(1000);
279 // Inserting packets for 5 seconds to get a valid estimate. 279 // Inserting packets for 5 seconds to get a valid estimate.
280 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { 280 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) {
281 // NOTE!!! If the following line is moved under the if case then this test 281 // NOTE!!! If the following line is moved under the if case then this test
282 // wont work on windows realease bots. 282 // wont work on windows realease bots.
283 int cluster_id = 283 PacedPacketInfo pacing_info =
284 i < kInitialProbingPackets ? 0 : PacedPacketInfo::kNotAProbe; 284 i < kInitialProbingPackets ? kPacingInfo : PacedPacketInfo();
285 285
286 if (i == kNumInitialPackets) { 286 if (i == kNumInitialPackets) {
287 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); 287 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
288 EXPECT_EQ(0u, ssrcs.size()); 288 EXPECT_EQ(0u, ssrcs.size());
289 EXPECT_FALSE(bitrate_observer_.updated()); 289 EXPECT_FALSE(bitrate_observer_.updated());
290 bitrate_observer_.Reset(); 290 bitrate_observer_.Reset();
291 } 291 }
292 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 292 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
293 sequence_number++, kMtu, cluster_id); 293 sequence_number++, kMtu, pacing_info);
294 clock_.AdvanceTimeMilliseconds(1000 / kFramerate); 294 clock_.AdvanceTimeMilliseconds(1000 / kFramerate);
295 send_time_ms += kFrameIntervalMs; 295 send_time_ms += kFrameIntervalMs;
296 } 296 }
297 EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); 297 EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
298 ASSERT_EQ(1u, ssrcs.size()); 298 ASSERT_EQ(1u, ssrcs.size());
299 EXPECT_EQ(kDefaultSsrc, ssrcs.front()); 299 EXPECT_EQ(kDefaultSsrc, ssrcs.front());
300 EXPECT_NEAR(expected_converge_bitrate, bitrate_bps, kAcceptedBitrateErrorBps); 300 EXPECT_NEAR(expected_converge_bitrate, bitrate_bps, kAcceptedBitrateErrorBps);
301 EXPECT_TRUE(bitrate_observer_.updated()); 301 EXPECT_TRUE(bitrate_observer_.updated());
302 bitrate_observer_.Reset(); 302 bitrate_observer_.Reset();
303 EXPECT_EQ(bitrate_observer_.latest_bitrate(), bitrate_bps); 303 EXPECT_EQ(bitrate_observer_.latest_bitrate(), bitrate_bps);
304 } 304 }
305 305
306 void DelayBasedBweTest::RateIncreaseReorderingTestHelper( 306 void DelayBasedBweTest::RateIncreaseReorderingTestHelper(
307 uint32_t expected_bitrate_bps) { 307 uint32_t expected_bitrate_bps) {
308 const int kFramerate = 50; // 50 fps to avoid rounding errors. 308 const int kFramerate = 50; // 50 fps to avoid rounding errors.
309 const int kFrameIntervalMs = 1000 / kFramerate; 309 const int kFrameIntervalMs = 1000 / kFramerate;
310 const PacedPacketInfo kPacingInfo(0, 1, 100);
310 int64_t send_time_ms = 0; 311 int64_t send_time_ms = 0;
311 uint16_t sequence_number = 0; 312 uint16_t sequence_number = 0;
312 // Inserting packets for five seconds to get a valid estimate. 313 // Inserting packets for five seconds to get a valid estimate.
313 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { 314 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) {
314 // NOTE!!! If the following line is moved under the if case then this test 315 // NOTE!!! If the following line is moved under the if case then this test
315 // wont work on windows realease bots. 316 // wont work on windows realease bots.
316 int cluster_id = 317 PacedPacketInfo pacing_info =
317 i < kInitialProbingPackets ? 0 : PacedPacketInfo::kNotAProbe; 318 i < kInitialProbingPackets ? kPacingInfo : PacedPacketInfo();
318 319
319 // TODO(sprang): Remove this hack once the single stream estimator is gone, 320 // TODO(sprang): Remove this hack once the single stream estimator is gone,
320 // as it doesn't do anything in Process(). 321 // as it doesn't do anything in Process().
321 if (i == kNumInitialPackets) { 322 if (i == kNumInitialPackets) {
322 // Process after we have enough frames to get a valid input rate estimate. 323 // Process after we have enough frames to get a valid input rate estimate.
323 324
324 EXPECT_FALSE(bitrate_observer_.updated()); // No valid estimate. 325 EXPECT_FALSE(bitrate_observer_.updated()); // No valid estimate.
325 } 326 }
326 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 327 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
327 sequence_number++, kMtu, cluster_id); 328 sequence_number++, kMtu, pacing_info);
328 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); 329 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
329 send_time_ms += kFrameIntervalMs; 330 send_time_ms += kFrameIntervalMs;
330 } 331 }
331 EXPECT_TRUE(bitrate_observer_.updated()); 332 EXPECT_TRUE(bitrate_observer_.updated());
332 EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_.latest_bitrate(), 333 EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_.latest_bitrate(),
333 kAcceptedBitrateErrorBps); 334 kAcceptedBitrateErrorBps);
334 for (int i = 0; i < 10; ++i) { 335 for (int i = 0; i < 10; ++i) {
335 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); 336 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
336 send_time_ms += 2 * kFrameIntervalMs; 337 send_time_ms += 2 * kFrameIntervalMs;
337 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 338 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 496 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
496 sequence_number++, 1000); 497 sequence_number++, 1000);
497 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); 498 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
498 send_time_ms += kFrameIntervalMs; 499 send_time_ms += kFrameIntervalMs;
499 } 500 }
500 uint32_t bitrate_after = 0; 501 uint32_t bitrate_after = 0;
501 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); 502 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after);
502 EXPECT_LT(bitrate_after, bitrate_before); 503 EXPECT_LT(bitrate_after, bitrate_before);
503 } 504 }
504 } // namespace webrtc 505 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698