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

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

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

Powered by Google App Engine
This is Rietveld 408576698