Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc

Issue 1151603008: Make the BWE threshold adaptive. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix string length issue. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 payload_size, &timestamp_delta, 98 payload_size, &timestamp_delta,
99 &time_delta, &size_delta)) { 99 &time_delta, &size_delta)) {
100 double timestamp_delta_ms = timestamp_delta * kTimestampToMs; 100 double timestamp_delta_ms = timestamp_delta * kTimestampToMs;
101 estimator->estimator.Update(time_delta, timestamp_delta_ms, size_delta, 101 estimator->estimator.Update(time_delta, timestamp_delta_ms, size_delta,
102 estimator->detector.State()); 102 estimator->detector.State());
103 estimator->detector.Detect(estimator->estimator.offset(), 103 estimator->detector.Detect(estimator->estimator.offset(),
104 timestamp_delta_ms, 104 timestamp_delta_ms,
105 estimator->estimator.num_of_deltas(), now_ms); 105 estimator->estimator.num_of_deltas(), now_ms);
106 } 106 }
107 if (estimator->detector.State() == kBwOverusing) { 107 if (estimator->detector.State() == kBwOverusing) {
108 uint32_t incoming_bitrate = incoming_bitrate_.Rate(now_ms); 108 uint32_t incoming_bitrate_bps = incoming_bitrate_.Rate(now_ms);
109 if (prior_state != kBwOverusing || 109 if (prior_state != kBwOverusing ||
110 remote_rate_->TimeToReduceFurther(now_ms, incoming_bitrate)) { 110 remote_rate_->TimeToReduceFurther(now_ms, incoming_bitrate_bps)) {
111 // The first overuse should immediately trigger a new estimate. 111 // The first overuse should immediately trigger a new estimate.
112 // We also have to update the estimate immediately if we are overusing 112 // We also have to update the estimate immediately if we are overusing
113 // and the target bitrate is too high compared to what we are receiving. 113 // and the target bitrate is too high compared to what we are receiving.
114 UpdateEstimate(now_ms); 114 UpdateEstimate(now_ms);
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 int32_t RemoteBitrateEstimatorSingleStream::Process() { 119 int32_t RemoteBitrateEstimatorSingleStream::Process() {
120 if (TimeUntilNextProcess() > 0) { 120 if (TimeUntilNextProcess() > 0) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // We can't update the estimate if we don't have any active streams. 165 // We can't update the estimate if we don't have any active streams.
166 if (overuse_detectors_.empty()) { 166 if (overuse_detectors_.empty()) {
167 remote_rate_.reset(new AimdRateControl(remote_rate_->GetMinBitrate())); 167 remote_rate_.reset(new AimdRateControl(remote_rate_->GetMinBitrate()));
168 return; 168 return;
169 } 169 }
170 double mean_noise_var = sum_var_noise / 170 double mean_noise_var = sum_var_noise /
171 static_cast<double>(overuse_detectors_.size()); 171 static_cast<double>(overuse_detectors_.size());
172 const RateControlInput input(bw_state, 172 const RateControlInput input(bw_state,
173 incoming_bitrate_.Rate(now_ms), 173 incoming_bitrate_.Rate(now_ms),
174 mean_noise_var); 174 mean_noise_var);
175 const RateControlRegion region = remote_rate_->Update(&input, now_ms); 175 remote_rate_->Update(&input, now_ms);
176 unsigned int target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms); 176 unsigned int target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms);
177 if (remote_rate_->ValidEstimate()) { 177 if (remote_rate_->ValidEstimate()) {
178 process_interval_ms_ = remote_rate_->GetFeedbackInterval(); 178 process_interval_ms_ = remote_rate_->GetFeedbackInterval();
179 std::vector<unsigned int> ssrcs; 179 std::vector<unsigned int> ssrcs;
180 GetSsrcs(&ssrcs); 180 GetSsrcs(&ssrcs);
181 observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate); 181 observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate);
182 } 182 }
183 for (it = overuse_detectors_.begin(); it != overuse_detectors_.end(); ++it) {
184 it->second->detector.SetRateControlRegion(region);
185 }
186 } 183 }
187 184
188 void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t rtt) { 185 void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t rtt) {
189 CriticalSectionScoped cs(crit_sect_.get()); 186 CriticalSectionScoped cs(crit_sect_.get());
190 remote_rate_->SetRtt(rtt); 187 remote_rate_->SetRtt(rtt);
191 } 188 }
192 189
193 void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) { 190 void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
194 CriticalSectionScoped cs(crit_sect_.get()); 191 CriticalSectionScoped cs(crit_sect_.get());
195 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc); 192 SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc);
(...skipping 30 matching lines...) Expand all
226 assert(ssrcs); 223 assert(ssrcs);
227 ssrcs->resize(overuse_detectors_.size()); 224 ssrcs->resize(overuse_detectors_.size());
228 int i = 0; 225 int i = 0;
229 for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin(); 226 for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();
230 it != overuse_detectors_.end(); ++it, ++i) { 227 it != overuse_detectors_.end(); ++it, ++i) {
231 (*ssrcs)[i] = it->first; 228 (*ssrcs)[i] = it->first;
232 } 229 }
233 } 230 }
234 231
235 } // namespace webrtc 232 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698