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