Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #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" |
| 26 #include "webrtc/modules/utility/include/process_thread.h" | 26 #include "webrtc/modules/utility/include/process_thread.h" |
| 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 28 #include "webrtc/video/payload_router.h" | 28 #include "webrtc/video/payload_router.h" |
| 29 | 29 |
| 30 namespace webrtc { | 30 namespace webrtc { |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 33 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| 34 | 34 |
| 35 // Makes sure that the bitrate and the min, max values are in valid range. | |
| 36 static void ClampBitrates(int* bitrate_bps, | |
| 37 int* min_bitrate_bps, | |
| 38 int* max_bitrate_bps) { | |
| 39 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, | |
| 40 // and that we don't try to set the min bitrate to 0 from any applications. | |
| 41 // The congestion controller should allow a min bitrate of 0. | |
| 42 const int kMinBitrateBps = 10000; | |
| 43 if (*min_bitrate_bps < kMinBitrateBps) | |
| 44 *min_bitrate_bps = kMinBitrateBps; | |
| 45 if (*max_bitrate_bps > 0) | |
| 46 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); | |
| 47 if (*bitrate_bps > 0) | |
| 48 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); | |
| 49 } | |
| 50 | |
| 35 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 51 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| 36 public: | 52 public: |
| 37 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) | 53 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) |
| 38 : observer_(observer), | 54 : observer_(observer), |
| 39 clock_(clock), | 55 clock_(clock), |
| 40 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 56 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 41 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), | 57 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), |
| 42 using_absolute_send_time_(false), | 58 using_absolute_send_time_(false), |
| 43 packets_since_absolute_send_time_(0), | 59 packets_since_absolute_send_time_(0), |
| 44 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {} | 60 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {} |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 221 |
| 206 CongestionController::~CongestionController() {} | 222 CongestionController::~CongestionController() {} |
| 207 | 223 |
| 208 void CongestionController::Init() { | 224 void CongestionController::Init() { |
| 209 transport_feedback_adapter_.SetBitrateEstimator( | 225 transport_feedback_adapter_.SetBitrateEstimator( |
| 210 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); | 226 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); |
| 211 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 227 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
| 212 min_bitrate_bps_); | 228 min_bitrate_bps_); |
| 213 } | 229 } |
| 214 | 230 |
| 215 | |
| 216 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 231 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| 217 int start_bitrate_bps, | 232 int start_bitrate_bps, |
| 218 int max_bitrate_bps) { | 233 int max_bitrate_bps) { |
| 219 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, | 234 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 220 // and that we don't try to set the min bitrate to 0 from any applications. | |
| 221 // The congestion controller should allow a min bitrate of 0. | |
| 222 const int kMinBitrateBps = 10000; | |
| 223 if (min_bitrate_bps < kMinBitrateBps) | |
| 224 min_bitrate_bps = kMinBitrateBps; | |
| 225 if (max_bitrate_bps > 0) | |
| 226 max_bitrate_bps = std::max(min_bitrate_bps, max_bitrate_bps); | |
| 227 if (start_bitrate_bps > 0) | |
| 228 start_bitrate_bps = std::max(min_bitrate_bps, start_bitrate_bps); | |
| 229 | |
| 230 bitrate_controller_->SetBitrates(start_bitrate_bps, | 235 bitrate_controller_->SetBitrates(start_bitrate_bps, |
| 231 min_bitrate_bps, | 236 min_bitrate_bps, |
| 232 max_bitrate_bps); | 237 max_bitrate_bps); |
| 233 | 238 |
| 234 if (remote_bitrate_estimator_) | 239 if (remote_bitrate_estimator_) |
| 235 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | 240 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); |
| 236 min_bitrate_bps_ = min_bitrate_bps; | 241 min_bitrate_bps_ = min_bitrate_bps; |
| 237 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 242 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
| 238 min_bitrate_bps_); | 243 min_bitrate_bps_); |
| 239 MaybeTriggerOnNetworkChanged(); | 244 MaybeTriggerOnNetworkChanged(); |
| 240 } | 245 } |
| 241 | 246 |
| 247 void CongestionController::ResetBweAndBitrates(int bitrate_bps, | |
| 248 int min_bitrate_bps, | |
| 249 int max_bitrate_bps) { | |
| 250 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | |
| 251 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, | |
|
stefan-webrtc
2016/05/31 17:27:49
I wonder if we instead should simply recreate the
honghaiz3
2016/06/01 02:17:34
No we cannot because some of the objects in conges
stefan-webrtc
2016/06/01 07:38:36
I was referring to bitrate_controller_ and not con
honghaiz3
2016/06/01 16:54:10
Ah sorry that I mis-read it.
It had similar issue
| |
| 252 max_bitrate_bps); | |
| 253 min_bitrate_bps_ = min_bitrate_bps; | |
| 254 if (remote_bitrate_estimator_) | |
| 255 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | |
|
stefan-webrtc
2016/05/31 17:27:49
Here too, shouldn't we recreate this object as wel
honghaiz3
2016/06/01 02:17:34
Cannot for the same reason.
It was used by the vi
stefan-webrtc
2016/06/01 07:38:36
I see, could you add a TODO which says "Recreate t
honghaiz3
2016/06/01 16:54:10
Done.
| |
| 256 | |
| 257 RemoteBitrateEstimator* rbe = | |
| 258 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_); | |
| 259 transport_feedback_adapter_.SetBitrateEstimator(rbe); | |
| 260 rbe->SetMinBitrate(min_bitrate_bps); | |
| 261 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. | |
| 262 MaybeTriggerOnNetworkChanged(); | |
| 263 } | |
| 264 | |
| 242 BitrateController* CongestionController::GetBitrateController() const { | 265 BitrateController* CongestionController::GetBitrateController() const { |
| 243 return bitrate_controller_.get(); | 266 return bitrate_controller_.get(); |
| 244 } | 267 } |
| 245 | 268 |
| 246 RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( | 269 RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( |
| 247 bool send_side_bwe) { | 270 bool send_side_bwe) { |
| 248 if (send_side_bwe) { | 271 if (send_side_bwe) { |
| 249 return &remote_estimator_proxy_; | 272 return &remote_estimator_proxy_; |
| 250 } else { | 273 } else { |
| 251 return remote_bitrate_estimator_.get(); | 274 return remote_bitrate_estimator_.get(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 bool CongestionController::IsSendQueueFull() const { | 362 bool CongestionController::IsSendQueueFull() const { |
| 340 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 363 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 341 } | 364 } |
| 342 | 365 |
| 343 bool CongestionController::IsNetworkDown() const { | 366 bool CongestionController::IsNetworkDown() const { |
| 344 rtc::CritScope cs(&critsect_); | 367 rtc::CritScope cs(&critsect_); |
| 345 return network_state_ == kNetworkDown; | 368 return network_state_ == kNetworkDown; |
| 346 } | 369 } |
| 347 | 370 |
| 348 } // namespace webrtc | 371 } // namespace webrtc |
| OLD | NEW |