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

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

Issue 2029593002: Update RateStatistics to handle too-little-data case. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comment Created 4 years, 6 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 clusters->push_back(*cluster); 78 clusters->push_back(*cluster);
79 } 79 }
80 80
81 RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime( 81 RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(
82 RemoteBitrateObserver* observer) 82 RemoteBitrateObserver* observer)
83 : observer_(observer), 83 : observer_(observer),
84 inter_arrival_(), 84 inter_arrival_(),
85 estimator_(), 85 estimator_(),
86 detector_(OverUseDetectorOptions()), 86 detector_(OverUseDetectorOptions()),
87 incoming_bitrate_(kBitrateWindowMs, 8000), 87 incoming_bitrate_(kBitrateWindowMs, 8000),
88 incoming_bitrate_initialized_(false),
88 total_probes_received_(0), 89 total_probes_received_(0),
89 first_packet_time_ms_(-1), 90 first_packet_time_ms_(-1),
90 last_update_ms_(-1), 91 last_update_ms_(-1),
91 ssrcs_() { 92 ssrcs_() {
92 RTC_DCHECK(observer_); 93 RTC_DCHECK(observer_);
93 LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating."; 94 LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating.";
94 network_thread_.DetachFromThread(); 95 network_thread_.DetachFromThread();
95 } 96 }
96 97
97 void RemoteBitrateEstimatorAbsSendTime::ComputeClusters( 98 void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool was_paced) { 237 bool was_paced) {
237 assert(send_time_24bits < (1ul << 24)); 238 assert(send_time_24bits < (1ul << 24));
238 // Shift up send time to use the full 32 bits that inter_arrival works with, 239 // Shift up send time to use the full 32 bits that inter_arrival works with,
239 // so wrapping works properly. 240 // so wrapping works properly.
240 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift; 241 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift;
241 int64_t send_time_ms = static_cast<int64_t>(timestamp) * kTimestampToMs; 242 int64_t send_time_ms = static_cast<int64_t>(timestamp) * kTimestampToMs;
242 243
243 int64_t now_ms = arrival_time_ms; 244 int64_t now_ms = arrival_time_ms;
244 // TODO(holmer): SSRCs are only needed for REMB, should be broken out from 245 // TODO(holmer): SSRCs are only needed for REMB, should be broken out from
245 // here. 246 // here.
247
248 // Check if incoming bitrate estimate is valid, and if it needs to be reset.
249 rtc::Optional<uint32_t> incoming_bitrate = incoming_bitrate_.Rate(now_ms);
250 if (incoming_bitrate) {
251 incoming_bitrate_initialized_ = true;
252 } else if (incoming_bitrate_initialized_) {
253 // Incoming bitrate had a previous valid value, but now not enough data
254 // point are left within the current window. Reset incoming bitrate
255 // estimator so that the window size will only contain new data points.
256 incoming_bitrate_.Reset();
257 incoming_bitrate_initialized_ = false;
258 }
246 incoming_bitrate_.Update(payload_size, now_ms); 259 incoming_bitrate_.Update(payload_size, now_ms);
247 260
248 if (first_packet_time_ms_ == -1) 261 if (first_packet_time_ms_ == -1)
249 first_packet_time_ms_ = arrival_time_ms; 262 first_packet_time_ms_ = arrival_time_ms;
250 263
251 uint32_t ts_delta = 0; 264 uint32_t ts_delta = 0;
252 int64_t t_delta = 0; 265 int64_t t_delta = 0;
253 int size_delta = 0; 266 int size_delta = 0;
254 // For now only try to detect probes while we don't have a valid estimate, and 267 // For now only try to detect probes while we don't have a valid estimate, and
255 // make sure the packet was paced. We currently assume that only packets 268 // make sure the packet was paced. We currently assume that only packets
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 detector_.Detect(estimator_->offset(), ts_delta_ms, 309 detector_.Detect(estimator_->offset(), ts_delta_ms,
297 estimator_->num_of_deltas(), arrival_time_ms); 310 estimator_->num_of_deltas(), arrival_time_ms);
298 } 311 }
299 312
300 if (!update_estimate) { 313 if (!update_estimate) {
301 // Check if it's time for a periodic update or if we should update because 314 // Check if it's time for a periodic update or if we should update because
302 // of an over-use. 315 // of an over-use.
303 if (last_update_ms_ == -1 || 316 if (last_update_ms_ == -1 ||
304 now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval()) { 317 now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval()) {
305 update_estimate = true; 318 update_estimate = true;
306 } else if (detector_.State() == kBwOverusing && 319 } else if (detector_.State() == kBwOverusing) {
307 remote_rate_.TimeToReduceFurther( 320 rtc::Optional<uint32_t> incoming_rate = incoming_bitrate_.Rate(now_ms);
308 now_ms, incoming_bitrate_.Rate(now_ms))) { 321 if (incoming_rate &&
309 update_estimate = true; 322 remote_rate_.TimeToReduceFurther(now_ms, *incoming_rate)) {
323 update_estimate = true;
324 }
310 } 325 }
311 } 326 }
312 327
313 if (update_estimate) { 328 if (update_estimate) {
314 // The first overuse should immediately trigger a new estimate. 329 // The first overuse should immediately trigger a new estimate.
315 // We also have to update the estimate immediately if we are overusing 330 // We also have to update the estimate immediately if we are overusing
316 // and the target bitrate is too high compared to what we are receiving. 331 // and the target bitrate is too high compared to what we are receiving.
317 const RateControlInput input(detector_.State(), 332 const RateControlInput input(detector_.State(),
318 incoming_bitrate_.Rate(now_ms), 333 incoming_bitrate_.Rate(now_ms),
319 estimator_->var_noise()); 334 estimator_->var_noise());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return true; 403 return true;
389 } 404 }
390 405
391 void RemoteBitrateEstimatorAbsSendTime::SetMinBitrate(int min_bitrate_bps) { 406 void RemoteBitrateEstimatorAbsSendTime::SetMinBitrate(int min_bitrate_bps) {
392 // Called from both the configuration thread and the network thread. Shouldn't 407 // Called from both the configuration thread and the network thread. Shouldn't
393 // be called from the network thread in the future. 408 // be called from the network thread in the future.
394 rtc::CritScope lock(&crit_); 409 rtc::CritScope lock(&crit_);
395 remote_rate_.SetMinBitrate(min_bitrate_bps); 410 remote_rate_.SetMinBitrate(min_bitrate_bps);
396 } 411 }
397 } // namespace webrtc 412 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698