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

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

Issue 2917873002: Refactored incoming bitrate estimator. (Closed)
Patch Set: Respond to comments Created 3 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) 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 "
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <limits> 13 #include <limits>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/ptr_util.h"
17 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" 18 #include "webrtc/modules/congestion_controller/delay_based_bwe.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
20 21
21 constexpr size_t kMtu = 1200; 22 constexpr size_t kMtu = 1200;
22 constexpr uint32_t kAcceptedBitrateErrorBps = 50000; 23 constexpr uint32_t kAcceptedBitrateErrorBps = 50000;
23 24
24 // Number of packets needed before we have a valid estimate. 25 // Number of packets needed before we have a valid estimate.
25 constexpr int kNumInitialPackets = 2; 26 constexpr int kNumInitialPackets = 2;
26 27
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 packet.arrival_time_ms = prev_arrival_time_us_ / 1000; 143 packet.arrival_time_ms = prev_arrival_time_us_ / 1000;
143 ++i; 144 ++i;
144 } 145 }
145 it = std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare); 146 it = std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
146 return std::max((*it)->next_rtp_time(), time_now_us); 147 return std::max((*it)->next_rtp_time(), time_now_us);
147 } 148 }
148 } // namespace test 149 } // namespace test
149 150
150 DelayBasedBweTest::DelayBasedBweTest() 151 DelayBasedBweTest::DelayBasedBweTest()
151 : clock_(100000000), 152 : clock_(100000000),
153 acknowledged_bitrate_estimator_(
154 rtc::MakeUnique<AcknowledgedBitrateEstimator>()),
152 bitrate_estimator_(new DelayBasedBwe(nullptr, &clock_)), 155 bitrate_estimator_(new DelayBasedBwe(nullptr, &clock_)),
153 stream_generator_(new test::StreamGenerator(1e6, // Capacity. 156 stream_generator_(new test::StreamGenerator(1e6, // Capacity.
154 clock_.TimeInMicroseconds())), 157 clock_.TimeInMicroseconds())),
155 arrival_time_offset_ms_(0), 158 arrival_time_offset_ms_(0),
156 first_update_(true) {} 159 first_update_(true) {}
157 160
158 DelayBasedBweTest::~DelayBasedBweTest() {} 161 DelayBasedBweTest::~DelayBasedBweTest() {}
159 162
160 void DelayBasedBweTest::AddDefaultStream() { 163 void DelayBasedBweTest::AddDefaultStream() {
161 stream_generator_->AddStream(new test::RtpStream(30, 3e5)); 164 stream_generator_->AddStream(new test::RtpStream(30, 3e5));
(...skipping 12 matching lines...) Expand all
174 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, 177 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms,
175 int64_t send_time_ms, 178 int64_t send_time_ms,
176 uint16_t sequence_number, 179 uint16_t sequence_number,
177 size_t payload_size, 180 size_t payload_size,
178 const PacedPacketInfo& pacing_info) { 181 const PacedPacketInfo& pacing_info) {
179 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); 182 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0);
180 PacketFeedback packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, 183 PacketFeedback packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms,
181 sequence_number, payload_size, pacing_info); 184 sequence_number, payload_size, pacing_info);
182 std::vector<PacketFeedback> packets; 185 std::vector<PacketFeedback> packets;
183 packets.push_back(packet); 186 packets.push_back(packet);
187 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector(packets);
184 DelayBasedBwe::Result result = 188 DelayBasedBwe::Result result =
185 bitrate_estimator_->IncomingPacketFeedbackVector(packets); 189 bitrate_estimator_->IncomingPacketFeedbackVector(
190 packets, acknowledged_bitrate_estimator_->bitrate_bps());
186 const uint32_t kDummySsrc = 0; 191 const uint32_t kDummySsrc = 0;
187 if (result.updated) { 192 if (result.updated) {
188 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, 193 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc},
189 result.target_bitrate_bps); 194 result.target_bitrate_bps);
190 } 195 }
191 } 196 }
192 197
193 // Generates a frame of packets belonging to a stream at a given bitrate and 198 // Generates a frame of packets belonging to a stream at a given bitrate and
194 // with a given ssrc. The stream is pushed through a very simple simulated 199 // with a given ssrc. The stream is pushed through a very simple simulated
195 // network, and is then given to the receive-side bandwidth estimator. 200 // network, and is then given to the receive-side bandwidth estimator.
(...skipping 10 matching lines...) Expand all
206 return false; 211 return false;
207 212
208 bool overuse = false; 213 bool overuse = false;
209 bitrate_observer_.Reset(); 214 bitrate_observer_.Reset();
210 clock_.AdvanceTimeMicroseconds(1000 * packets.back().arrival_time_ms - 215 clock_.AdvanceTimeMicroseconds(1000 * packets.back().arrival_time_ms -
211 clock_.TimeInMicroseconds()); 216 clock_.TimeInMicroseconds());
212 for (auto& packet : packets) { 217 for (auto& packet : packets) {
213 RTC_CHECK_GE(packet.arrival_time_ms + arrival_time_offset_ms_, 0); 218 RTC_CHECK_GE(packet.arrival_time_ms + arrival_time_offset_ms_, 0);
214 packet.arrival_time_ms += arrival_time_offset_ms_; 219 packet.arrival_time_ms += arrival_time_offset_ms_;
215 } 220 }
221
222 acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector(packets);
216 DelayBasedBwe::Result result = 223 DelayBasedBwe::Result result =
217 bitrate_estimator_->IncomingPacketFeedbackVector(packets); 224 bitrate_estimator_->IncomingPacketFeedbackVector(
225 packets, acknowledged_bitrate_estimator_->bitrate_bps());
218 const uint32_t kDummySsrc = 0; 226 const uint32_t kDummySsrc = 0;
219 if (result.updated) { 227 if (result.updated) {
220 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc}, 228 bitrate_observer_.OnReceiveBitrateChanged({kDummySsrc},
221 result.target_bitrate_bps); 229 result.target_bitrate_bps);
222 if (!first_update_ && result.target_bitrate_bps < bitrate_bps) 230 if (!first_update_ && result.target_bitrate_bps < bitrate_bps)
223 overuse = true; 231 overuse = true;
224 first_update_ = false; 232 first_update_ = false;
225 } 233 }
226 234
227 clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds()); 235 clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds());
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, 504 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms,
497 sequence_number++, 1000); 505 sequence_number++, 1000);
498 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); 506 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
499 send_time_ms += kFrameIntervalMs; 507 send_time_ms += kFrameIntervalMs;
500 } 508 }
501 uint32_t bitrate_after = 0; 509 uint32_t bitrate_after = 0;
502 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); 510 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after);
503 EXPECT_LT(bitrate_after, bitrate_before); 511 EXPECT_LT(bitrate_after, bitrate_before);
504 } 512 }
505 } // namespace webrtc 513 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698