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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 _outputSpeechType(AudioFrame::kNormalSpeech), | 917 _outputSpeechType(AudioFrame::kNormalSpeech), |
918 restored_packet_in_use_(false), | 918 restored_packet_in_use_(false), |
919 rtcp_observer_(new VoERtcpObserver(this)), | 919 rtcp_observer_(new VoERtcpObserver(this)), |
920 associate_send_channel_(ChannelOwner(nullptr)), | 920 associate_send_channel_(ChannelOwner(nullptr)), |
921 pacing_enabled_(config.enable_voice_pacing), | 921 pacing_enabled_(config.enable_voice_pacing), |
922 feedback_observer_proxy_(new TransportFeedbackProxy()), | 922 feedback_observer_proxy_(new TransportFeedbackProxy()), |
923 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 923 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
924 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), | 924 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
925 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), | 925 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), |
926 kMaxRetransmissionWindowMs)), | 926 kMaxRetransmissionWindowMs)), |
927 decoder_factory_(config.acm_config.decoder_factory), | 927 decoder_factory_(config.acm_config.decoder_factory) { |
928 // Bitrate smoother can be initialized with arbitrary time constant | |
929 // (0 used here). The actual time constant will be set in SetBitRate. | |
930 bitrate_smoother_(0, Clock::GetRealTimeClock()) { | |
931 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 928 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
932 "Channel::Channel() - ctor"); | 929 "Channel::Channel() - ctor"); |
933 AudioCodingModule::Config acm_config(config.acm_config); | 930 AudioCodingModule::Config acm_config(config.acm_config); |
934 acm_config.id = VoEModuleId(instanceId, channelId); | 931 acm_config.id = VoEModuleId(instanceId, channelId); |
935 acm_config.neteq_config.enable_muted_state = true; | 932 acm_config.neteq_config.enable_muted_state = true; |
936 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 933 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
937 | 934 |
938 _outputAudioLevel.Clear(); | 935 _outputAudioLevel.Clear(); |
939 | 936 |
940 RtpRtcp::Configuration configuration; | 937 RtpRtcp::Configuration configuration; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 } | 1321 } |
1325 } | 1322 } |
1326 | 1323 |
1327 return 0; | 1324 return 0; |
1328 } | 1325 } |
1329 | 1326 |
1330 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { | 1327 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { |
1331 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1328 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1332 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); | 1329 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); |
1333 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1330 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1334 if (*encoder) | 1331 if (*encoder) { |
1335 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); | 1332 (*encoder)->OnReceivedTargetAudioBitrate( |
| 1333 bitrate_bps, rtc::Optional<int64_t>(probing_interval_ms)); |
| 1334 } |
1336 }); | 1335 }); |
1337 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 1336 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
1338 | |
1339 // We give smoothed bitrate allocation to audio network adaptor as | |
1340 // the uplink bandwidth. | |
1341 // The probing spikes should not affect the bitrate smoother more than 25%. | |
1342 // To simplify the calculations we use a step response as input signal. | |
1343 // The step response of an exponential filter is | |
1344 // u(t) = 1 - e^(-t / time_constant). | |
1345 // In order to limit the affect of a BWE spike within 25% of its value before | |
1346 // the next probing, we would choose a time constant that fulfills | |
1347 // 1 - e^(-probing_interval_ms / time_constant) < 0.25 | |
1348 // Then 4 * probing_interval_ms is a good choice. | |
1349 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4); | |
1350 bitrate_smoother_.AddSample(bitrate_bps); | |
1351 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | |
1352 if (*encoder) { | |
1353 (*encoder)->OnReceivedUplinkBandwidth( | |
1354 static_cast<int>(*bitrate_smoother_.GetAverage())); | |
1355 } | |
1356 }); | |
1357 } | 1337 } |
1358 | 1338 |
1359 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1339 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
1360 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1340 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1361 if (*encoder) | 1341 if (*encoder) |
1362 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); | 1342 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); |
1363 }); | 1343 }); |
1364 } | 1344 } |
1365 | 1345 |
1366 int32_t Channel::SetVADStatus(bool enableVAD, | 1346 int32_t Channel::SetVADStatus(bool enableVAD, |
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 int64_t min_rtt = 0; | 3268 int64_t min_rtt = 0; |
3289 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3269 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3290 0) { | 3270 0) { |
3291 return 0; | 3271 return 0; |
3292 } | 3272 } |
3293 return rtt; | 3273 return rtt; |
3294 } | 3274 } |
3295 | 3275 |
3296 } // namespace voe | 3276 } // namespace voe |
3297 } // namespace webrtc | 3277 } // namespace webrtc |
OLD | NEW |