OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 int64_t start_bitrate_bps, | 65 int64_t start_bitrate_bps, |
66 int64_t max_bitrate_bps) { | 66 int64_t max_bitrate_bps) { |
67 rtc::CritScope cs(&critsect_); | 67 rtc::CritScope cs(&critsect_); |
68 | 68 |
69 if (start_bitrate_bps > 0) { | 69 if (start_bitrate_bps > 0) { |
70 start_bitrate_bps_ = start_bitrate_bps; | 70 start_bitrate_bps_ = start_bitrate_bps; |
71 } else if (start_bitrate_bps_ == 0) { | 71 } else if (start_bitrate_bps_ == 0) { |
72 start_bitrate_bps_ = min_bitrate_bps; | 72 start_bitrate_bps_ = min_bitrate_bps; |
73 } | 73 } |
74 | 74 |
| 75 // The reason we use the variable |old_max_bitrate_pbs| is because we |
| 76 // need to set |max_bitrate_bps_| before we call InitiateProbing. |
75 int64_t old_max_bitrate_bps = max_bitrate_bps_; | 77 int64_t old_max_bitrate_bps = max_bitrate_bps_; |
76 max_bitrate_bps_ = max_bitrate_bps; | 78 max_bitrate_bps_ = max_bitrate_bps; |
77 | 79 |
78 switch (state_) { | 80 switch (state_) { |
79 case State::kInit: | 81 case State::kInit: |
80 if (network_state_ == kNetworkUp) | 82 if (network_state_ == kNetworkUp) |
81 InitiateExponentialProbing(); | 83 InitiateExponentialProbing(); |
82 break; | 84 break; |
83 | 85 |
84 case State::kWaitingForProbingResult: | 86 case State::kWaitingForProbingResult: |
85 break; | 87 break; |
86 | 88 |
87 case State::kProbingComplete: | 89 case State::kProbingComplete: |
88 // Initiate probing when |max_bitrate_| was increased mid-call. | 90 // If the new max bitrate is higher than the old max bitrate and the |
89 if (estimated_bitrate_bps_ != kExponentialProbingDisabled && | 91 // estimate is lower than the new max bitrate then initiate probing. |
90 estimated_bitrate_bps_ < old_max_bitrate_bps && | 92 if (estimated_bitrate_bps_ != 0 && |
91 max_bitrate_bps_ > old_max_bitrate_bps) { | 93 old_max_bitrate_bps < max_bitrate_bps_ && |
| 94 estimated_bitrate_bps_ < max_bitrate_bps_) { |
92 // The assumption is that if we jump more than 20% in the bandwidth | 95 // The assumption is that if we jump more than 20% in the bandwidth |
93 // estimate or if the bandwidth estimate is within 90% of the new | 96 // estimate or if the bandwidth estimate is within 90% of the new |
94 // max bitrate then the probing attempt was successful. | 97 // max bitrate then the probing attempt was successful. |
95 mid_call_probing_succcess_threshold_ = | 98 mid_call_probing_succcess_threshold_ = |
96 std::min(estimated_bitrate_bps_ * 1.2, max_bitrate_bps_ * 0.9); | 99 std::min(estimated_bitrate_bps_ * 1.2, max_bitrate_bps_ * 0.9); |
97 mid_call_probing_waiting_for_result_ = true; | 100 mid_call_probing_waiting_for_result_ = true; |
98 mid_call_probing_bitrate_bps_ = max_bitrate_bps_; | 101 mid_call_probing_bitrate_bps_ = max_bitrate_bps_; |
99 | 102 |
100 RTC_HISTOGRAM_COUNTS_10000("WebRTC.BWE.MidCallProbing.Initiated", | 103 RTC_HISTOGRAM_COUNTS_10000("WebRTC.BWE.MidCallProbing.Initiated", |
101 max_bitrate_bps_ / 1000); | 104 max_bitrate_bps_ / 1000); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 state_ = State::kWaitingForProbingResult; | 236 state_ = State::kWaitingForProbingResult; |
234 min_bitrate_to_probe_further_bps_ = | 237 min_bitrate_to_probe_further_bps_ = |
235 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; | 238 (*(bitrates_to_probe.end() - 1)) * kRepeatedProbeMinPercentage / 100; |
236 } else { | 239 } else { |
237 state_ = State::kProbingComplete; | 240 state_ = State::kProbingComplete; |
238 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; | 241 min_bitrate_to_probe_further_bps_ = kExponentialProbingDisabled; |
239 } | 242 } |
240 } | 243 } |
241 | 244 |
242 } // namespace webrtc | 245 } // namespace webrtc |
OLD | NEW |