OLD | NEW |
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (!inter_arrival_.get()) { | 289 if (!inter_arrival_.get()) { |
290 inter_arrival_.reset( | 290 inter_arrival_.reset( |
291 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, | 291 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, |
292 kTimestampToMs, true)); | 292 kTimestampToMs, true)); |
293 } | 293 } |
294 if (inter_arrival_->ComputeDeltas(timestamp, arrival_time_ms, payload_size, | 294 if (inter_arrival_->ComputeDeltas(timestamp, arrival_time_ms, payload_size, |
295 &ts_delta, &t_delta, &size_delta)) { | 295 &ts_delta, &t_delta, &size_delta)) { |
296 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); | 296 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); |
297 estimator_.Update(t_delta, ts_delta_ms, size_delta, detector_.State()); | 297 estimator_.Update(t_delta, ts_delta_ms, size_delta, detector_.State()); |
298 detector_.Detect(estimator_.offset(), ts_delta_ms, | 298 detector_.Detect(estimator_.offset(), ts_delta_ms, |
299 estimator_.num_of_deltas(), now_ms); | 299 estimator_.num_of_deltas(), arrival_time_ms); |
300 UpdateStats(static_cast<int>(t_delta - ts_delta_ms), now_ms); | 300 UpdateStats(static_cast<int>(t_delta - ts_delta_ms), now_ms); |
301 } | 301 } |
302 if (detector_.State() == kBwOverusing) { | 302 if (detector_.State() == kBwOverusing) { |
303 unsigned int incoming_bitrate = incoming_bitrate_.Rate(now_ms); | 303 uint32_t incoming_bitrate_bps = incoming_bitrate_.Rate(now_ms); |
304 if (prior_state != kBwOverusing || | 304 if (prior_state != kBwOverusing || |
305 remote_rate_.TimeToReduceFurther(now_ms, incoming_bitrate)) { | 305 remote_rate_.TimeToReduceFurther(now_ms, incoming_bitrate_bps)) { |
306 // The first overuse should immediately trigger a new estimate. | 306 // The first overuse should immediately trigger a new estimate. |
307 // We also have to update the estimate immediately if we are overusing | 307 // We also have to update the estimate immediately if we are overusing |
308 // and the target bitrate is too high compared to what we are receiving. | 308 // and the target bitrate is too high compared to what we are receiving. |
309 UpdateEstimate(now_ms); | 309 UpdateEstimate(now_ms); |
310 } | 310 } |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 int32_t RemoteBitrateEstimatorAbsSendTime::Process() { | 314 int32_t RemoteBitrateEstimatorAbsSendTime::Process() { |
315 if (TimeUntilNextProcess() > 0) { | 315 if (TimeUntilNextProcess() > 0) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // We can't update the estimate if we don't have any active streams. | 350 // We can't update the estimate if we don't have any active streams. |
351 inter_arrival_.reset(); | 351 inter_arrival_.reset(); |
352 // We deliberately don't reset the first_packet_time_ms_ here for now since | 352 // We deliberately don't reset the first_packet_time_ms_ here for now since |
353 // we only probe for bandwidth in the beginning of a call right now. | 353 // we only probe for bandwidth in the beginning of a call right now. |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 const RateControlInput input(detector_.State(), | 357 const RateControlInput input(detector_.State(), |
358 incoming_bitrate_.Rate(now_ms), | 358 incoming_bitrate_.Rate(now_ms), |
359 estimator_.var_noise()); | 359 estimator_.var_noise()); |
360 const RateControlRegion region = remote_rate_.Update(&input, now_ms); | 360 remote_rate_.Update(&input, now_ms); |
361 unsigned int target_bitrate = remote_rate_.UpdateBandwidthEstimate(now_ms); | 361 unsigned int target_bitrate = remote_rate_.UpdateBandwidthEstimate(now_ms); |
362 if (remote_rate_.ValidEstimate()) { | 362 if (remote_rate_.ValidEstimate()) { |
363 process_interval_ms_ = remote_rate_.GetFeedbackInterval(); | 363 process_interval_ms_ = remote_rate_.GetFeedbackInterval(); |
364 observer_->OnReceiveBitrateChanged(Keys(ssrcs_), target_bitrate); | 364 observer_->OnReceiveBitrateChanged(Keys(ssrcs_), target_bitrate); |
365 } | 365 } |
366 detector_.SetRateControlRegion(region); | |
367 } | 366 } |
368 | 367 |
369 void RemoteBitrateEstimatorAbsSendTime::OnRttUpdate(int64_t rtt) { | 368 void RemoteBitrateEstimatorAbsSendTime::OnRttUpdate(int64_t rtt) { |
370 CriticalSectionScoped cs(crit_sect_.get()); | 369 CriticalSectionScoped cs(crit_sect_.get()); |
371 remote_rate_.SetRtt(rtt); | 370 remote_rate_.SetRtt(rtt); |
372 } | 371 } |
373 | 372 |
374 void RemoteBitrateEstimatorAbsSendTime::RemoveStream(unsigned int ssrc) { | 373 void RemoteBitrateEstimatorAbsSendTime::RemoveStream(unsigned int ssrc) { |
375 CriticalSectionScoped cs(crit_sect_.get()); | 374 CriticalSectionScoped cs(crit_sect_.get()); |
376 ssrcs_.erase(ssrc); | 375 ssrcs_.erase(ssrc); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 423 |
425 RemoveStaleEntries( | 424 RemoveStaleEntries( |
426 &recent_update_time_ms_, | 425 &recent_update_time_ms_, |
427 &recent_propagation_delta_ms_, | 426 &recent_propagation_delta_ms_, |
428 now_ms - kPropagationDeltaQueueMaxTimeMs); | 427 now_ms - kPropagationDeltaQueueMaxTimeMs); |
429 | 428 |
430 total_propagation_delta_ms_ = | 429 total_propagation_delta_ms_ = |
431 std::max(total_propagation_delta_ms_ + propagation_delta_ms, 0); | 430 std::max(total_propagation_delta_ms_ + propagation_delta_ms, 0); |
432 } | 431 } |
433 } // namespace webrtc | 432 } // namespace webrtc |
OLD | NEW |