Chromium Code Reviews| Index: webrtc/modules/congestion_controller/congestion_controller.cc |
| diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc |
| index 5767448a5f7bf711a24ef214ea47d5f5cac18f20..4e88fe634a37e808789e5b5171c0ae24f0dc1d09 100644 |
| --- a/webrtc/modules/congestion_controller/congestion_controller.cc |
| +++ b/webrtc/modules/congestion_controller/congestion_controller.cc |
| @@ -32,6 +32,22 @@ namespace { |
| static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| +// Makes sure that the bitrate and the min, max values are in valid range. |
| +static void ClampBitrates(int* bitrate_bps, |
| + int* min_bitrate_bps, |
| + int* max_bitrate_bps) { |
| + // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| + // and that we don't try to set the min bitrate to 0 from any applications. |
| + // The congestion controller should allow a min bitrate of 0. |
| + const int kMinBitrateBps = 10000; |
| + if (*min_bitrate_bps < kMinBitrateBps) |
| + *min_bitrate_bps = kMinBitrateBps; |
| + if (*max_bitrate_bps > 0) |
| + *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); |
| + if (*bitrate_bps > 0) |
| + *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); |
| +} |
| + |
| class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| public: |
| WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) |
| @@ -212,21 +228,10 @@ void CongestionController::Init() { |
| min_bitrate_bps_); |
| } |
| - |
| void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| int start_bitrate_bps, |
| int max_bitrate_bps) { |
| - // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| - // and that we don't try to set the min bitrate to 0 from any applications. |
| - // The congestion controller should allow a min bitrate of 0. |
| - const int kMinBitrateBps = 10000; |
| - if (min_bitrate_bps < kMinBitrateBps) |
| - min_bitrate_bps = kMinBitrateBps; |
| - if (max_bitrate_bps > 0) |
| - max_bitrate_bps = std::max(min_bitrate_bps, max_bitrate_bps); |
| - if (start_bitrate_bps > 0) |
| - start_bitrate_bps = std::max(min_bitrate_bps, start_bitrate_bps); |
| - |
| + ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| bitrate_controller_->SetBitrates(start_bitrate_bps, |
| min_bitrate_bps, |
| max_bitrate_bps); |
| @@ -239,6 +244,24 @@ void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| MaybeTriggerOnNetworkChanged(); |
| } |
| +void CongestionController::ResetBweAndBitrates(int bitrate_bps, |
| + int min_bitrate_bps, |
| + int max_bitrate_bps) { |
| + ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| + 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
|
| + max_bitrate_bps); |
| + min_bitrate_bps_ = min_bitrate_bps; |
| + if (remote_bitrate_estimator_) |
| + 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.
|
| + |
| + RemoteBitrateEstimator* rbe = |
| + new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_); |
| + transport_feedback_adapter_.SetBitrateEstimator(rbe); |
| + rbe->SetMinBitrate(min_bitrate_bps); |
| + // TODO(holmer): Trigger a new probe once mid-call probing is implemented. |
| + MaybeTriggerOnNetworkChanged(); |
| +} |
| + |
| BitrateController* CongestionController::GetBitrateController() const { |
| return bitrate_controller_.get(); |
| } |