Chromium Code Reviews| 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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 // We give smoothed bitrate allocation to audio network adaptor as | 1344 // We give smoothed bitrate allocation to audio network adaptor as |
| 1345 // the uplink bandwidth. | 1345 // the uplink bandwidth. |
| 1346 // The probing spikes should not affect the bitrate smoother more than 25%. | 1346 // The probing spikes should not affect the bitrate smoother more than 25%. |
| 1347 // To simplify the calculations we use a step response as input signal. | 1347 // To simplify the calculations we use a step response as input signal. |
| 1348 // The step response of an exponential filter is | 1348 // The step response of an exponential filter is |
| 1349 // u(t) = 1 - e^(-t / time_constant). | 1349 // u(t) = 1 - e^(-t / time_constant). |
| 1350 // In order to limit the affect of a BWE spike within 25% of its value before | 1350 // In order to limit the affect of a BWE spike within 25% of its value before |
| 1351 // the next probing, we would choose a time constant that fulfills | 1351 // the next probing, we would choose a time constant that fulfills |
| 1352 // 1 - e^(-probing_interval_ms / time_constant) < 0.25 | 1352 // 1 - e^(-probing_interval_ms / time_constant) < 0.25 |
| 1353 // Then 4 * probing_interval_ms is a good choice. | 1353 // Then 4 * probing_interval_ms is a good choice. |
| 1354 rtc::CritScope lock(&bitrate_smoother_lock_); | |
| 1354 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4); | 1355 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4); |
| 1355 bitrate_smoother_.AddSample(bitrate_bps); | 1356 bitrate_bps_ = rtc::Optional<int>(bitrate_bps); |
| 1356 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | |
| 1357 if (*encoder) { | |
| 1358 (*encoder)->OnReceivedUplinkBandwidth( | |
| 1359 static_cast<int>(*bitrate_smoother_.GetAverage())); | |
| 1360 } | |
| 1361 }); | |
| 1362 } | 1357 } |
| 1363 | 1358 |
| 1364 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1359 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
| 1365 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1360 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1366 if (*encoder) | 1361 if (*encoder) |
| 1367 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); | 1362 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); |
| 1368 }); | 1363 }); |
| 1369 } | 1364 } |
| 1370 | 1365 |
| 1371 int32_t Channel::SetVADStatus(bool enableVAD, | 1366 int32_t Channel::SetVADStatus(bool enableVAD, |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2748 // If pacing is enabled we always store packets. | 2743 // If pacing is enabled we always store packets. |
| 2749 if (!pacing_enabled_) | 2744 if (!pacing_enabled_) |
| 2750 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); | 2745 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); |
| 2751 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); | 2746 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); |
| 2752 if (enable) | 2747 if (enable) |
| 2753 audio_coding_->EnableNack(maxNumberOfPackets); | 2748 audio_coding_->EnableNack(maxNumberOfPackets); |
| 2754 else | 2749 else |
| 2755 audio_coding_->DisableNack(); | 2750 audio_coding_->DisableNack(); |
| 2756 } | 2751 } |
| 2757 | 2752 |
| 2753 void Channel::AdaptCodec() { | |
| 2754 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | |
| 2755 rtc::CritScope lock(&bitrate_smoother_lock_); | |
|
the sun
2016/12/13 16:43:24
Which threads can we be running on? Is it possible
michaelt
2016/12/13 17:01:26
No, since AdaptCodec() runs on the worker queue. A
| |
| 2756 if (bitrate_bps_) { | |
| 2757 bitrate_smoother_.AddSample(*bitrate_bps_); | |
| 2758 if (*encoder) { | |
| 2759 (*encoder)->OnReceivedUplinkBandwidth( | |
| 2760 static_cast<int>(*bitrate_smoother_.GetAverage())); | |
| 2761 } | |
| 2762 } | |
| 2763 }); | |
| 2764 } | |
| 2765 | |
| 2758 // Called when we are missing one or more packets. | 2766 // Called when we are missing one or more packets. |
| 2759 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { | 2767 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { |
| 2760 return _rtpRtcpModule->SendNACK(sequence_numbers, length); | 2768 return _rtpRtcpModule->SendNACK(sequence_numbers, length); |
| 2761 } | 2769 } |
| 2762 | 2770 |
| 2763 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) { | 2771 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) { |
| 2764 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 2772 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 2765 "Channel::Demultiplex()"); | 2773 "Channel::Demultiplex()"); |
| 2766 _audioFrame.CopyFrom(audioFrame); | 2774 _audioFrame.CopyFrom(audioFrame); |
| 2767 _audioFrame.id_ = _channelId; | 2775 _audioFrame.id_ = _channelId; |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3285 int64_t min_rtt = 0; | 3293 int64_t min_rtt = 0; |
| 3286 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3294 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3287 0) { | 3295 0) { |
| 3288 return 0; | 3296 return 0; |
| 3289 } | 3297 } |
| 3290 return rtt; | 3298 return rtt; |
| 3291 } | 3299 } |
| 3292 | 3300 |
| 3293 } // namespace voe | 3301 } // namespace voe |
| 3294 } // namespace webrtc | 3302 } // namespace webrtc |
| OLD | NEW |