OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 audio_network_adaptor_ = | 286 audio_network_adaptor_ = |
287 audio_network_adaptor_creator_(config_string, event_log, clock); | 287 audio_network_adaptor_creator_(config_string, event_log, clock); |
288 return audio_network_adaptor_.get() != nullptr; | 288 return audio_network_adaptor_.get() != nullptr; |
289 } | 289 } |
290 | 290 |
291 void AudioEncoderOpus::DisableAudioNetworkAdaptor() { | 291 void AudioEncoderOpus::DisableAudioNetworkAdaptor() { |
292 audio_network_adaptor_.reset(nullptr); | 292 audio_network_adaptor_.reset(nullptr); |
293 } | 293 } |
294 | 294 |
295 void AudioEncoderOpus::OnReceivedUplinkPacketLossFraction( | 295 void AudioEncoderOpus::OnReceivedUplinkPacketLossFraction( |
296 float uplink_packet_loss_fraction) { | 296 const rtc::Optional<float>& uplink_packet_loss_fraction) { |
297 if (!audio_network_adaptor_) { | 297 if (!audio_network_adaptor_) { |
298 packet_loss_fraction_smoother_->AddSample(uplink_packet_loss_fraction); | 298 if (uplink_packet_loss_fraction) { |
299 float average_fraction_loss = packet_loss_fraction_smoother_->GetAverage(); | 299 packet_loss_fraction_smoother_->AddSample(*uplink_packet_loss_fraction); |
300 return SetProjectedPacketLossRate(average_fraction_loss); | 300 float average_fraction_loss = |
| 301 packet_loss_fraction_smoother_->GetAverage(); |
| 302 SetProjectedPacketLossRate(average_fraction_loss); |
| 303 } |
| 304 } else { |
| 305 audio_network_adaptor_->SetUplinkPacketLossFraction( |
| 306 uplink_packet_loss_fraction); |
| 307 ApplyAudioNetworkAdaptor(); |
301 } | 308 } |
302 audio_network_adaptor_->SetUplinkPacketLossFraction( | |
303 uplink_packet_loss_fraction); | |
304 ApplyAudioNetworkAdaptor(); | |
305 } | 309 } |
306 | 310 |
307 void AudioEncoderOpus::OnReceivedUplinkBandwidth( | 311 void AudioEncoderOpus::OnReceivedUplinkBandwidth( |
308 int target_audio_bitrate_bps, | 312 int target_audio_bitrate_bps, |
309 rtc::Optional<int64_t> probing_interval_ms) { | 313 rtc::Optional<int64_t> probing_interval_ms) { |
310 if (audio_network_adaptor_) { | 314 if (audio_network_adaptor_) { |
311 audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps); | 315 audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps); |
312 // We give smoothed bitrate allocation to audio network adaptor as | 316 // We give smoothed bitrate allocation to audio network adaptor as |
313 // the uplink bandwidth. | 317 // the uplink bandwidth. |
314 // The probing spikes should not affect the bitrate smoother more than 25%. | 318 // The probing spikes should not affect the bitrate smoother more than 25%. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 config_.uplink_bandwidth_update_interval_ms) { | 565 config_.uplink_bandwidth_update_interval_ms) { |
562 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage(); | 566 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage(); |
563 if (smoothed_bitrate) | 567 if (smoothed_bitrate) |
564 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); | 568 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); |
565 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms); | 569 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms); |
566 } | 570 } |
567 } | 571 } |
568 } | 572 } |
569 | 573 |
570 } // namespace webrtc | 574 } // namespace webrtc |
OLD | NEW |