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 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 | 1297 |
1298 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { | 1298 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { |
1299 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 1299 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
1300 "SetSendCodec() failed to set audio packet size"); | 1300 "SetSendCodec() failed to set audio packet size"); |
1301 return -1; | 1301 return -1; |
1302 } | 1302 } |
1303 | 1303 |
1304 return 0; | 1304 return 0; |
1305 } | 1305 } |
1306 | 1306 |
1307 void Channel::SetBitRate(int bitrate_bps) { | 1307 void Channel::SetBitRate(int bitrate_bps, |
| 1308 rtc::Optional<int64_t> probing_interval_ms) { |
1308 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1309 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1309 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); | 1310 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); |
1310 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1311 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1311 if (*encoder) | 1312 if (*encoder) |
1312 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); | 1313 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); |
1313 }); | 1314 }); |
1314 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 1315 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
1315 | 1316 |
1316 // We give smoothed bitrate allocation to audio network adaptor as | 1317 // We give smoothed bitrate allocation to audio network adaptor as |
1317 // the uplink bandwidth. | 1318 // the uplink bandwidth. |
1318 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as | 1319 // The probing spikes should not affect the bitrate smoother more than 25%. |
1319 // we pass the probing interval to this function. | 1320 // To simplify the calculations we use a step response as input signal. |
1320 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000; | 1321 // The calculation show a step response for an |
1321 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs); | 1322 // exponential filter (bitrate_smoother use an exponential filter) with the |
1322 bitrate_smoother_.AddSample(bitrate_bps); | 1323 // length of probing_interval and an amplitude of 1. |
1323 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1324 // 0.22 = 1 - e^(-t/probing_interval * 4) | t = probing_interval. |
1324 if (*encoder) { | 1325 if (probing_interval_ms) { |
1325 (*encoder)->OnReceivedUplinkBandwidth( | 1326 bitrate_smoother_.SetTimeConstantMs(*probing_interval_ms * 4); |
1326 static_cast<int>(*bitrate_smoother_.GetAverage())); | 1327 bitrate_smoother_.AddSample(bitrate_bps); |
1327 } | 1328 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1328 }); | 1329 if (*encoder) { |
| 1330 (*encoder)->OnReceivedUplinkBandwidth( |
| 1331 static_cast<int>(*bitrate_smoother_.GetAverage())); |
| 1332 } |
| 1333 }); |
| 1334 } |
1329 } | 1335 } |
1330 | 1336 |
1331 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1337 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
1332 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1338 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1333 if (*encoder) | 1339 if (*encoder) |
1334 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); | 1340 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); |
1335 }); | 1341 }); |
1336 } | 1342 } |
1337 | 1343 |
1338 int32_t Channel::SetVADStatus(bool enableVAD, | 1344 int32_t Channel::SetVADStatus(bool enableVAD, |
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 int64_t min_rtt = 0; | 3262 int64_t min_rtt = 0; |
3257 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3263 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3258 0) { | 3264 0) { |
3259 return 0; | 3265 return 0; |
3260 } | 3266 } |
3261 return rtt; | 3267 return rtt; |
3262 } | 3268 } |
3263 | 3269 |
3264 } // namespace voe | 3270 } // namespace voe |
3265 } // namespace webrtc | 3271 } // namespace webrtc |
OLD | NEW |