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

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

Issue 2415543002: Set min BWE bitrate form 10kbps to 5kbps and centralize minimum bitrate. (Closed)
Patch Set: rebased. 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 11 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/rate_limiter.h" 19 #include "webrtc/base/rate_limiter.h"
20 #include "webrtc/base/socket.h" 20 #include "webrtc/base/socket.h"
21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
22 #include "webrtc/modules/congestion_controller/probe_controller.h" 22 #include "webrtc/modules/congestion_controller/probe_controller.h"
23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
23 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h" 24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h"
24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h" 25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
26 27
27 namespace webrtc { 28 namespace webrtc {
28 namespace { 29 namespace {
29 30
30 static const uint32_t kTimeOffsetSwitchThreshold = 30; 31 static const uint32_t kTimeOffsetSwitchThreshold = 30;
31 static const int64_t kRetransmitWindowSizeMs = 500; 32 static const int64_t kRetransmitWindowSizeMs = 500;
32 33
33 // Makes sure that the bitrate and the min, max values are in valid range. 34 // Makes sure that the bitrate and the min, max values are in valid range.
34 static void ClampBitrates(int* bitrate_bps, 35 static void ClampBitrates(int* bitrate_bps,
35 int* min_bitrate_bps, 36 int* min_bitrate_bps,
36 int* max_bitrate_bps) { 37 int* max_bitrate_bps) {
37 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, 38 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps,
38 // and that we don't try to set the min bitrate to 0 from any applications. 39 // and that we don't try to set the min bitrate to 0 from any applications.
39 // The congestion controller should allow a min bitrate of 0. 40 // The congestion controller should allow a min bitrate of 0.
40 const int kMinBitrateBps = 10000; 41 if (*min_bitrate_bps < congestion_controller::GetMinBitrateBps())
41 if (*min_bitrate_bps < kMinBitrateBps) 42 *min_bitrate_bps = congestion_controller::GetMinBitrateBps();
42 *min_bitrate_bps = kMinBitrateBps;
43 if (*max_bitrate_bps > 0) 43 if (*max_bitrate_bps > 0)
44 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); 44 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps);
45 if (*bitrate_bps > 0) 45 if (*bitrate_bps > 0)
46 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); 46 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps);
47 } 47 }
48 48
49 class WrappingBitrateEstimator : public RemoteBitrateEstimator { 49 class WrappingBitrateEstimator : public RemoteBitrateEstimator {
50 public: 50 public:
51 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) 51 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock)
52 : observer_(observer), 52 : observer_(observer),
53 clock_(clock), 53 clock_(clock),
54 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 54 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
55 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), 55 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)),
56 using_absolute_send_time_(false), 56 using_absolute_send_time_(false),
57 packets_since_absolute_send_time_(0), 57 packets_since_absolute_send_time_(0),
58 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {} 58 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()) {}
59 59
60 virtual ~WrappingBitrateEstimator() {} 60 virtual ~WrappingBitrateEstimator() {}
61 61
62 void IncomingPacket(int64_t arrival_time_ms, 62 void IncomingPacket(int64_t arrival_time_ms,
63 size_t payload_size, 63 size_t payload_size,
64 const RTPHeader& header) override { 64 const RTPHeader& header) override {
65 CriticalSectionScoped cs(crit_sect_.get()); 65 CriticalSectionScoped cs(crit_sect_.get());
66 PickEstimatorFromHeader(header); 66 PickEstimatorFromHeader(header);
67 rbe_->IncomingPacket(arrival_time_ms, payload_size, header); 67 rbe_->IncomingPacket(arrival_time_ms, payload_size, header);
68 } 68 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 pacer_(new PacedSender(clock_, packet_router_.get())), 159 pacer_(new PacedSender(clock_, packet_router_.get())),
160 remote_bitrate_estimator_( 160 remote_bitrate_estimator_(
161 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 161 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
162 bitrate_controller_( 162 bitrate_controller_(
163 BitrateController::CreateBitrateController(clock_, event_log)), 163 BitrateController::CreateBitrateController(clock_, event_log)),
164 probe_controller_(new ProbeController(pacer_.get(), clock_)), 164 probe_controller_(new ProbeController(pacer_.get(), clock_)),
165 retransmission_rate_limiter_( 165 retransmission_rate_limiter_(
166 new RateLimiter(clock, kRetransmitWindowSizeMs)), 166 new RateLimiter(clock, kRetransmitWindowSizeMs)),
167 remote_estimator_proxy_(clock_, packet_router_.get()), 167 remote_estimator_proxy_(clock_, packet_router_.get()),
168 transport_feedback_adapter_(clock_, bitrate_controller_.get()), 168 transport_feedback_adapter_(clock_, bitrate_controller_.get()),
169 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 169 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
170 max_bitrate_bps_(0), 170 max_bitrate_bps_(0),
171 last_reported_bitrate_bps_(0), 171 last_reported_bitrate_bps_(0),
172 last_reported_fraction_loss_(0), 172 last_reported_fraction_loss_(0),
173 last_reported_rtt_(0), 173 last_reported_rtt_(0),
174 network_state_(kNetworkUp) { 174 network_state_(kNetworkUp) {
175 Init(); 175 Init();
176 } 176 }
177 177
178 CongestionController::CongestionController( 178 CongestionController::CongestionController(
179 Clock* clock, 179 Clock* clock,
(...skipping 10 matching lines...) Expand all
190 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 190 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
191 // Constructed last as this object calls the provided callback on 191 // Constructed last as this object calls the provided callback on
192 // construction. 192 // construction.
193 bitrate_controller_( 193 bitrate_controller_(
194 BitrateController::CreateBitrateController(clock_, event_log)), 194 BitrateController::CreateBitrateController(clock_, event_log)),
195 probe_controller_(new ProbeController(pacer_.get(), clock_)), 195 probe_controller_(new ProbeController(pacer_.get(), clock_)),
196 retransmission_rate_limiter_( 196 retransmission_rate_limiter_(
197 new RateLimiter(clock, kRetransmitWindowSizeMs)), 197 new RateLimiter(clock, kRetransmitWindowSizeMs)),
198 remote_estimator_proxy_(clock_, packet_router_.get()), 198 remote_estimator_proxy_(clock_, packet_router_.get()),
199 transport_feedback_adapter_(clock_, bitrate_controller_.get()), 199 transport_feedback_adapter_(clock_, bitrate_controller_.get()),
200 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 200 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()),
201 max_bitrate_bps_(0), 201 max_bitrate_bps_(0),
202 last_reported_bitrate_bps_(0), 202 last_reported_bitrate_bps_(0),
203 last_reported_fraction_loss_(0), 203 last_reported_fraction_loss_(0),
204 last_reported_rtt_(0), 204 last_reported_rtt_(0),
205 network_state_(kNetworkUp) { 205 network_state_(kNetworkUp) {
206 Init(); 206 Init();
207 } 207 }
208 208
209 CongestionController::~CongestionController() {} 209 CongestionController::~CongestionController() {}
210 210
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 bool CongestionController::IsSendQueueFull() const { 367 bool CongestionController::IsSendQueueFull() const {
368 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 368 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
369 } 369 }
370 370
371 bool CongestionController::IsNetworkDown() const { 371 bool CongestionController::IsNetworkDown() const {
372 rtc::CritScope cs(&critsect_); 372 rtc::CritScope cs(&critsect_);
373 return network_state_ == kNetworkDown; 373 return network_state_ == kNetworkDown;
374 } 374 }
375 375
376 } // namespace webrtc 376 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698