Index: webrtc/modules/congestion_controller/probe_controller.cc |
diff --git a/webrtc/modules/congestion_controller/probe_controller.cc b/webrtc/modules/congestion_controller/probe_controller.cc |
index 7e1d936a1eb7d2be61d108cd4c82bee777325338..672a7d36d1a01b939a5522069b32d5b096f97397 100644 |
--- a/webrtc/modules/congestion_controller/probe_controller.cc |
+++ b/webrtc/modules/congestion_controller/probe_controller.cc |
@@ -46,10 +46,12 @@ constexpr int kAlrProbingIntervalLimitMs = 5000; |
ProbeController::ProbeController(PacedSender* pacer, Clock* clock) |
: pacer_(pacer), |
clock_(clock), |
+ network_state_(kNetworkUp), |
state_(State::kInit), |
min_bitrate_to_probe_further_bps_(kExponentialProbingDisabled), |
time_last_probing_initiated_ms_(0), |
estimated_bitrate_bps_(0), |
+ start_bitrate_bps_(0), |
max_bitrate_bps_(0), |
last_alr_probing_time_(clock_->TimeInMilliseconds()) {} |
@@ -57,12 +59,9 @@ void ProbeController::SetBitrates(int min_bitrate_bps, |
int start_bitrate_bps, |
int max_bitrate_bps) { |
rtc::CritScope cs(&critsect_); |
- if (state_ == State::kInit) { |
- // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of |
- // 1.2 Mbps to continue probing. |
- InitiateProbing({3 * start_bitrate_bps, 6 * start_bitrate_bps}, |
- 4 * start_bitrate_bps); |
- } |
+ |
+ start_bitrate_bps_ = |
+ start_bitrate_bps > 0 ? start_bitrate_bps : min_bitrate_bps; |
int old_max_bitrate_bps = max_bitrate_bps_; |
max_bitrate_bps_ = max_bitrate_bps; |
@@ -73,12 +72,30 @@ void ProbeController::SetBitrates(int min_bitrate_bps, |
// |estimated_bitrate_bps_| is valid (> 0) and |
// the current bitrate is lower than the new |max_bitrate_bps|, and |
// |max_bitrate_bps_| was increased. |
- if (state_ != State::kWaitingForProbingResult && |
+ if (state_ == State::kProbingComplete && |
estimated_bitrate_bps_ != 0 && |
estimated_bitrate_bps_ < old_max_bitrate_bps && |
max_bitrate_bps_ > old_max_bitrate_bps) { |
InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); |
} |
+ |
+ MaybeInitiateProbing(); |
honghaiz3
2016/11/07 23:31:41
It is a little strange here that you may have call
Sergey Ulanov
2016/11/08 00:10:57
Replaced MaybeIntiiateProbing() with InitiateExpon
|
+} |
+ |
+void ProbeController::OnNetworkStateChanged(NetworkState state) { |
+ rtc::CritScope cs(&critsect_); |
+ network_state_ = state; |
+ MaybeInitiateProbing(); |
+} |
+ |
+void ProbeController::MaybeInitiateProbing() { |
+ if (network_state_ == kNetworkUp && state_ == State::kInit) { |
+ RTC_DCHECK_GT(start_bitrate_bps_, 0); |
+ // When probing at 1.8 Mbps ( 6x 300), this represents a threshold of |
+ // 1.2 Mbps to continue probing. |
+ InitiateProbing({3 * start_bitrate_bps_, 6 * start_bitrate_bps_}, |
+ 4 * start_bitrate_bps_); |
+ } |
} |
void ProbeController::SetEstimatedBitrate(int bitrate_bps) { |