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

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: Response to comments 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/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/rate_limiter.h" 20 #include "webrtc/base/rate_limiter.h"
21 #include "webrtc/base/socket.h" 21 #include "webrtc/base/socket.h"
22 #include "webrtc/base/thread_annotations.h" 22 #include "webrtc/base/thread_annotations.h"
23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
24 #include "webrtc/modules/congestion_controller/include/defines.h"
24 #include "webrtc/modules/congestion_controller/probe_controller.h" 25 #include "webrtc/modules/congestion_controller/probe_controller.h"
25 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" 26 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
26 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h" 27 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s end_time.h"
27 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h" 28 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
28 #include "webrtc/modules/utility/include/process_thread.h" 29 #include "webrtc/modules/utility/include/process_thread.h"
29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 30 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
30 #include "webrtc/video/payload_router.h" 31 #include "webrtc/video/payload_router.h"
31 32
32 namespace webrtc { 33 namespace webrtc {
33 namespace { 34 namespace {
34 35
35 static const uint32_t kTimeOffsetSwitchThreshold = 30; 36 static const uint32_t kTimeOffsetSwitchThreshold = 30;
36 static const int64_t kRetransmitWindowSizeMs = 500; 37 static const int64_t kRetransmitWindowSizeMs = 500;
37 38
38 // Makes sure that the bitrate and the min, max values are in valid range. 39 // Makes sure that the bitrate and the min, max values are in valid range.
39 static void ClampBitrates(int* bitrate_bps, 40 static void ClampBitrates(int* bitrate_bps,
40 int* min_bitrate_bps, 41 int* min_bitrate_bps,
41 int* max_bitrate_bps) { 42 int* max_bitrate_bps) {
42 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, 43 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps,
43 // and that we don't try to set the min bitrate to 0 from any applications. 44 // and that we don't try to set the min bitrate to 0 from any applications.
44 // The congestion controller should allow a min bitrate of 0. 45 // The congestion controller should allow a min bitrate of 0.
45 const int kMinBitrateBps = 10000; 46 if (*min_bitrate_bps < congestion_controller::kMinBitrateBps)
46 if (*min_bitrate_bps < kMinBitrateBps) 47 *min_bitrate_bps = congestion_controller::kMinBitrateBps;
47 *min_bitrate_bps = kMinBitrateBps;
48 if (*max_bitrate_bps > 0) 48 if (*max_bitrate_bps > 0)
49 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); 49 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps);
50 if (*bitrate_bps > 0) 50 if (*bitrate_bps > 0)
51 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); 51 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps);
52 } 52 }
53 53
54 class WrappingBitrateEstimator : public RemoteBitrateEstimator { 54 class WrappingBitrateEstimator : public RemoteBitrateEstimator {
55 public: 55 public:
56 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) 56 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock)
57 : observer_(observer), 57 : observer_(observer),
58 clock_(clock), 58 clock_(clock),
59 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 59 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
60 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), 60 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)),
61 using_absolute_send_time_(false), 61 using_absolute_send_time_(false),
62 packets_since_absolute_send_time_(0), 62 packets_since_absolute_send_time_(0),
63 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {} 63 min_bitrate_bps_(congestion_controller::kMinBitrateBps) {}
64 64
65 virtual ~WrappingBitrateEstimator() {} 65 virtual ~WrappingBitrateEstimator() {}
66 66
67 void IncomingPacket(int64_t arrival_time_ms, 67 void IncomingPacket(int64_t arrival_time_ms,
68 size_t payload_size, 68 size_t payload_size,
69 const RTPHeader& header) override { 69 const RTPHeader& header) override {
70 CriticalSectionScoped cs(crit_sect_.get()); 70 CriticalSectionScoped cs(crit_sect_.get());
71 PickEstimatorFromHeader(header); 71 PickEstimatorFromHeader(header);
72 rbe_->IncomingPacket(arrival_time_ms, payload_size, header); 72 rbe_->IncomingPacket(arrival_time_ms, payload_size, header);
73 } 73 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 pacer_(new PacedSender(clock_, packet_router_.get())), 164 pacer_(new PacedSender(clock_, packet_router_.get())),
165 remote_bitrate_estimator_( 165 remote_bitrate_estimator_(
166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
167 bitrate_controller_( 167 bitrate_controller_(
168 BitrateController::CreateBitrateController(clock_, event_log)), 168 BitrateController::CreateBitrateController(clock_, event_log)),
169 probe_controller_(new ProbeController(pacer_.get(), clock_)), 169 probe_controller_(new ProbeController(pacer_.get(), clock_)),
170 retransmission_rate_limiter_( 170 retransmission_rate_limiter_(
171 new RateLimiter(clock, kRetransmitWindowSizeMs)), 171 new RateLimiter(clock, kRetransmitWindowSizeMs)),
172 remote_estimator_proxy_(clock_, packet_router_.get()), 172 remote_estimator_proxy_(clock_, packet_router_.get()),
173 transport_feedback_adapter_(clock_, bitrate_controller_.get()), 173 transport_feedback_adapter_(clock_, bitrate_controller_.get()),
174 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 174 min_bitrate_bps_(congestion_controller::kMinBitrateBps),
175 max_bitrate_bps_(0), 175 max_bitrate_bps_(0),
176 last_reported_bitrate_bps_(0), 176 last_reported_bitrate_bps_(0),
177 last_reported_fraction_loss_(0), 177 last_reported_fraction_loss_(0),
178 last_reported_rtt_(0), 178 last_reported_rtt_(0),
179 network_state_(kNetworkUp) { 179 network_state_(kNetworkUp) {
180 Init(); 180 Init();
181 } 181 }
182 182
183 CongestionController::CongestionController( 183 CongestionController::CongestionController(
184 Clock* clock, 184 Clock* clock,
(...skipping 10 matching lines...) Expand all
195 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), 195 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
196 // Constructed last as this object calls the provided callback on 196 // Constructed last as this object calls the provided callback on
197 // construction. 197 // construction.
198 bitrate_controller_( 198 bitrate_controller_(
199 BitrateController::CreateBitrateController(clock_, event_log)), 199 BitrateController::CreateBitrateController(clock_, event_log)),
200 probe_controller_(new ProbeController(pacer_.get(), clock_)), 200 probe_controller_(new ProbeController(pacer_.get(), clock_)),
201 retransmission_rate_limiter_( 201 retransmission_rate_limiter_(
202 new RateLimiter(clock, kRetransmitWindowSizeMs)), 202 new RateLimiter(clock, kRetransmitWindowSizeMs)),
203 remote_estimator_proxy_(clock_, packet_router_.get()), 203 remote_estimator_proxy_(clock_, packet_router_.get()),
204 transport_feedback_adapter_(clock_, bitrate_controller_.get()), 204 transport_feedback_adapter_(clock_, bitrate_controller_.get()),
205 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), 205 min_bitrate_bps_(congestion_controller::kMinBitrateBps),
206 max_bitrate_bps_(0), 206 max_bitrate_bps_(0),
207 last_reported_bitrate_bps_(0), 207 last_reported_bitrate_bps_(0),
208 last_reported_fraction_loss_(0), 208 last_reported_fraction_loss_(0),
209 last_reported_rtt_(0), 209 last_reported_rtt_(0),
210 network_state_(kNetworkUp) { 210 network_state_(kNetworkUp) {
211 Init(); 211 Init();
212 } 212 }
213 213
214 CongestionController::~CongestionController() {} 214 CongestionController::~CongestionController() {}
215 215
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 bool CongestionController::IsSendQueueFull() const { 372 bool CongestionController::IsSendQueueFull() const {
373 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; 373 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
374 } 374 }
375 375
376 bool CongestionController::IsNetworkDown() const { 376 bool CongestionController::IsNetworkDown() const {
377 rtc::CritScope cs(&critsect_); 377 rtc::CritScope cs(&critsect_);
378 return network_state_ == kNetworkDown; 378 return network_state_ == kNetworkDown;
379 } 379 }
380 380
381 } // namespace webrtc 381 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698