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

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

Issue 2422063002: Use bayesian estimate of acked bitrate. (Closed)
Patch Set: Window changes. Created 4 years, 1 month 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 it = std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); 146 it = std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
147 return std::max((*it)->next_rtp_time(), time_now_us); 147 return std::max((*it)->next_rtp_time(), time_now_us);
148 } 148 }
149 } // namespace test 149 } // namespace test
150 150
151 DelayBasedBweTest::DelayBasedBweTest() 151 DelayBasedBweTest::DelayBasedBweTest()
152 : clock_(100000000), 152 : clock_(100000000),
153 bitrate_estimator_(&clock_), 153 bitrate_estimator_(&clock_),
154 stream_generator_(new test::StreamGenerator(1e6, // Capacity. 154 stream_generator_(new test::StreamGenerator(1e6, // Capacity.
155 clock_.TimeInMicroseconds())), 155 clock_.TimeInMicroseconds())),
156 arrival_time_offset_ms_(0) {} 156 arrival_time_offset_ms_(0),
157 first_update_(true) {}
157 158
158 DelayBasedBweTest::~DelayBasedBweTest() {} 159 DelayBasedBweTest::~DelayBasedBweTest() {}
159 160
160 void DelayBasedBweTest::AddDefaultStream() { 161 void DelayBasedBweTest::AddDefaultStream() {
161 stream_generator_->AddStream(new test::RtpStream(30, 3e5)); 162 stream_generator_->AddStream(new test::RtpStream(30, 3e5));
162 } 163 }
163 164
164 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0; 165 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0;
165 166
166 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, 167 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 for (auto& packet : packets) { 213 for (auto& packet : packets) {
213 RTC_CHECK_GE(packet.arrival_time_ms + arrival_time_offset_ms_, 0); 214 RTC_CHECK_GE(packet.arrival_time_ms + arrival_time_offset_ms_, 0);
214 packet.arrival_time_ms += arrival_time_offset_ms_; 215 packet.arrival_time_ms += arrival_time_offset_ms_;
215 } 216 }
216 DelayBasedBwe::Result result = 217 DelayBasedBwe::Result result =
217 bitrate_estimator_.IncomingPacketFeedbackVector(packets); 218 bitrate_estimator_.IncomingPacketFeedbackVector(packets);
218 const uint32_t kDummySsrc = 0; 219 const uint32_t kDummySsrc = 0;
219 if (result.updated) { 220 if (result.updated) {
220 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, 221 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc},
221 result.target_bitrate_bps); 222 result.target_bitrate_bps);
222 if (result.target_bitrate_bps < bitrate_bps) 223 if (!first_update_ && result.target_bitrate_bps < bitrate_bps)
223 overuse = true; 224 overuse = true;
225 first_update_ = false;
224 } 226 }
225 227
226 clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds()); 228 clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds());
227 return overuse; 229 return overuse;
228 } 230 }
229 231
230 // Run the bandwidth estimator with a stream of |number_of_frames| frames, or 232 // Run the bandwidth estimator with a stream of |number_of_frames| frames, or
231 // until it reaches |target_bitrate|. 233 // until it reaches |target_bitrate|.
232 // Can for instance be used to run the estimator for some time to get it 234 // Can for instance be used to run the estimator for some time to get it
233 // into a steady state. 235 // into a steady state.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 bool overuse = GenerateAndProcessFrame(kDefaultSsrc, bitrate_bps); 359 bool overuse = GenerateAndProcessFrame(kDefaultSsrc, bitrate_bps);
358 if (overuse) { 360 if (overuse) {
359 EXPECT_GT(bitrate_observer_.latest_bitrate(), bitrate_bps); 361 EXPECT_GT(bitrate_observer_.latest_bitrate(), bitrate_bps);
360 bitrate_bps = bitrate_observer_.latest_bitrate(); 362 bitrate_bps = bitrate_observer_.latest_bitrate();
361 bitrate_observer_.Reset(); 363 bitrate_observer_.Reset();
362 } else if (bitrate_observer_.updated()) { 364 } else if (bitrate_observer_.updated()) {
363 bitrate_bps = bitrate_observer_.latest_bitrate(); 365 bitrate_bps = bitrate_observer_.latest_bitrate();
364 bitrate_observer_.Reset(); 366 bitrate_observer_.Reset();
365 } 367 }
366 ++iterations; 368 ++iterations;
367 // ASSERT_LE(iterations, expected_iterations);
368 } 369 }
369 ASSERT_EQ(expected_iterations, iterations); 370 ASSERT_EQ(expected_iterations, iterations);
370 } 371 }
371 372
372 void DelayBasedBweTest::CapacityDropTestHelper( 373 void DelayBasedBweTest::CapacityDropTestHelper(
373 int number_of_streams, 374 int number_of_streams,
374 bool wrap_time_stamp, 375 bool wrap_time_stamp,
375 uint32_t expected_bitrate_drop_delta, 376 uint32_t expected_bitrate_drop_delta,
376 int64_t receiver_clock_offset_change_ms) { 377 int64_t receiver_clock_offset_change_ms) {
377 const int kFramerate = 30; 378 const int kFramerate = 30;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); 482 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
482 send_time_ms += kFrameIntervalMs; 483 send_time_ms += kFrameIntervalMs;
483 } 484 }
484 uint32_t bitrate_before = 0; 485 uint32_t bitrate_before = 0;
485 std::vector<uint32_t> ssrcs; 486 std::vector<uint32_t> ssrcs;
486 bitrate_estimator_.LatestEstimate(&ssrcs, &bitrate_before); 487 bitrate_estimator_.LatestEstimate(&ssrcs, &bitrate_before);
487 488
488 clock_.AdvanceTimeMilliseconds(silence_time_s * 1000); 489 clock_.AdvanceTimeMilliseconds(silence_time_s * 1000);
489 send_time_ms += silence_time_s * 1000; 490 send_time_ms += silence_time_s * 1000;
490 491
491 for (size_t i = 0; i < 21; ++i) { 492 for (size_t i = 0; i < 22; ++i) {
492 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 493 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
493 sequence_number++, 1000); 494 sequence_number++, 1000);
494 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); 495 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
495 send_time_ms += kFrameIntervalMs; 496 send_time_ms += kFrameIntervalMs;
496 } 497 }
497 uint32_t bitrate_after = 0; 498 uint32_t bitrate_after = 0;
498 bitrate_estimator_.LatestEstimate(&ssrcs, &bitrate_after); 499 bitrate_estimator_.LatestEstimate(&ssrcs, &bitrate_after);
499 EXPECT_LT(bitrate_after, bitrate_before); 500 EXPECT_LT(bitrate_after, bitrate_before);
500 } 501 }
501 } // namespace webrtc 502 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698