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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 estimator->detector.State(), now_ms); | 126 estimator->detector.State(), now_ms); |
127 estimator->detector.Detect(estimator->estimator.offset(), | 127 estimator->detector.Detect(estimator->estimator.offset(), |
128 timestamp_delta_ms, | 128 timestamp_delta_ms, |
129 estimator->estimator.num_of_deltas(), now_ms); | 129 estimator->estimator.num_of_deltas(), now_ms); |
130 } | 130 } |
131 if (estimator->detector.State() == kBwOverusing) { | 131 if (estimator->detector.State() == kBwOverusing) { |
132 rtc::Optional<uint32_t> incoming_bitrate_bps = | 132 rtc::Optional<uint32_t> incoming_bitrate_bps = |
133 incoming_bitrate_.Rate(now_ms); | 133 incoming_bitrate_.Rate(now_ms); |
134 if (incoming_bitrate_bps && | 134 if (incoming_bitrate_bps && |
135 (prior_state != kBwOverusing || | 135 (prior_state != kBwOverusing || |
136 remote_rate_->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) { | 136 GetRemoteRate()->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) { |
brandtr
2016/11/28 13:17:18
This change (and the one at the end) do not seem t
| |
137 // The first overuse should immediately trigger a new estimate. | 137 // The first overuse should immediately trigger a new estimate. |
138 // We also have to update the estimate immediately if we are overusing | 138 // We also have to update the estimate immediately if we are overusing |
139 // and the target bitrate is too high compared to what we are receiving. | 139 // and the target bitrate is too high compared to what we are receiving. |
140 UpdateEstimate(now_ms); | 140 UpdateEstimate(now_ms); |
141 } | 141 } |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 void RemoteBitrateEstimatorSingleStream::Process() { | 145 void RemoteBitrateEstimatorSingleStream::Process() { |
146 if (TimeUntilNextProcess() > 0) { | 146 if (TimeUntilNextProcess() > 0) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 // Make sure that we trigger an over-use if any of the over-use detectors | 182 // Make sure that we trigger an over-use if any of the over-use detectors |
183 // is detecting over-use. | 183 // is detecting over-use. |
184 if (it->second->detector.State() > bw_state) { | 184 if (it->second->detector.State() > bw_state) { |
185 bw_state = it->second->detector.State(); | 185 bw_state = it->second->detector.State(); |
186 } | 186 } |
187 ++it; | 187 ++it; |
188 } | 188 } |
189 } | 189 } |
190 // We can't update the estimate if we don't have any active streams. | 190 // We can't update the estimate if we don't have any active streams. |
191 if (overuse_detectors_.empty()) { | 191 if (overuse_detectors_.empty()) { |
192 remote_rate_.reset(new AimdRateControl()); | |
193 return; | 192 return; |
194 } | 193 } |
194 AimdRateControl* remote_rate = GetRemoteRate(); | |
195 | 195 |
196 double mean_noise_var = sum_var_noise / | 196 double mean_noise_var = sum_var_noise / |
197 static_cast<double>(overuse_detectors_.size()); | 197 static_cast<double>(overuse_detectors_.size()); |
198 const RateControlInput input(bw_state, | 198 const RateControlInput input(bw_state, |
199 incoming_bitrate_.Rate(now_ms), | 199 incoming_bitrate_.Rate(now_ms), |
200 mean_noise_var); | 200 mean_noise_var); |
201 remote_rate_->Update(&input, now_ms); | 201 remote_rate->Update(&input, now_ms); |
202 uint32_t target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms); | 202 uint32_t target_bitrate = remote_rate->UpdateBandwidthEstimate(now_ms); |
203 if (remote_rate_->ValidEstimate()) { | 203 if (remote_rate->ValidEstimate()) { |
204 process_interval_ms_ = remote_rate_->GetFeedbackInterval(); | 204 process_interval_ms_ = remote_rate->GetFeedbackInterval(); |
205 std::vector<uint32_t> ssrcs; | 205 std::vector<uint32_t> ssrcs; |
206 GetSsrcs(&ssrcs); | 206 GetSsrcs(&ssrcs); |
207 observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate); | 207 observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate); |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t avg_rtt_ms, | 211 void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t avg_rtt_ms, |
212 int64_t max_rtt_ms) { | 212 int64_t max_rtt_ms) { |
213 CriticalSectionScoped cs(crit_sect_.get()); | 213 CriticalSectionScoped cs(crit_sect_.get()); |
214 remote_rate_->SetRtt(avg_rtt_ms); | 214 GetRemoteRate()->SetRtt(avg_rtt_ms); |
215 } | 215 } |
216 | 216 |
217 void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) { | 217 void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) { |
218 CriticalSectionScoped cs(crit_sect_.get()); | 218 CriticalSectionScoped cs(crit_sect_.get()); |
219 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc); | 219 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc); |
220 if (it != overuse_detectors_.end()) { | 220 if (it != overuse_detectors_.end()) { |
221 delete it->second; | 221 delete it->second; |
222 overuse_detectors_.erase(it); | 222 overuse_detectors_.erase(it); |
223 } | 223 } |
224 } | 224 } |
(...skipping 18 matching lines...) Expand all Loading... | |
243 std::vector<uint32_t>* ssrcs) const { | 243 std::vector<uint32_t>* ssrcs) const { |
244 assert(ssrcs); | 244 assert(ssrcs); |
245 ssrcs->resize(overuse_detectors_.size()); | 245 ssrcs->resize(overuse_detectors_.size()); |
246 int i = 0; | 246 int i = 0; |
247 for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin(); | 247 for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin(); |
248 it != overuse_detectors_.end(); ++it, ++i) { | 248 it != overuse_detectors_.end(); ++it, ++i) { |
249 (*ssrcs)[i] = it->first; | 249 (*ssrcs)[i] = it->first; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 AimdRateControl* RemoteBitrateEstimatorSingleStream::GetRemoteRate() { | |
254 if (!remote_rate_) | |
255 remote_rate_.reset(new AimdRateControl()); | |
256 return remote_rate_.get(); | |
257 } | |
258 | |
253 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) { | 259 void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) { |
254 CriticalSectionScoped cs(crit_sect_.get()); | 260 CriticalSectionScoped cs(crit_sect_.get()); |
255 remote_rate_->SetMinBitrate(min_bitrate_bps); | 261 remote_rate_->SetMinBitrate(min_bitrate_bps); |
256 } | 262 } |
257 | 263 |
258 } // namespace webrtc | 264 } // namespace webrtc |
OLD | NEW |