| 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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 | 1295 |
| 1296 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { | 1296 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { |
| 1297 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 1297 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1298 "SetSendCodec() failed to set audio packet size"); | 1298 "SetSendCodec() failed to set audio packet size"); |
| 1299 return -1; | 1299 return -1; |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 return 0; | 1302 return 0; |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 void Channel::SetBitRate(int bitrate_bps) { | 1305 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { |
| 1306 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1306 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1307 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); | 1307 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); |
| 1308 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1308 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1309 if (*encoder) | 1309 if (*encoder) |
| 1310 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); | 1310 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); |
| 1311 }); | 1311 }); |
| 1312 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 1312 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
| 1313 | 1313 |
| 1314 // We give smoothed bitrate allocation to audio network adaptor as | 1314 // We give smoothed bitrate allocation to audio network adaptor as |
| 1315 // the uplink bandwidth. | 1315 // the uplink bandwidth. |
| 1316 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as | 1316 // The probing spikes should not affect the bitrate smoother more than 25%. |
| 1317 // we pass the probing interval to this function. | 1317 // To simplify the calculations we use a step response as input signal. |
| 1318 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000; | 1318 // The step response of an exponential filter is |
| 1319 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs); | 1319 // u(t) = 1 - e^(-t / time_constant). |
| 1320 // In order to limit the affect of a BWE spike within 25% of its value before |
| 1321 // the next probing, we would choose a time constant that fulfills |
| 1322 // 1 - e^(-probing_interval_ms / time_constant) < 0.25 |
| 1323 // Then 4 * probing_interval_ms is a good choice. |
| 1324 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4); |
| 1320 bitrate_smoother_.AddSample(bitrate_bps); | 1325 bitrate_smoother_.AddSample(bitrate_bps); |
| 1321 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1326 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1322 if (*encoder) { | 1327 if (*encoder) { |
| 1323 (*encoder)->OnReceivedUplinkBandwidth( | 1328 (*encoder)->OnReceivedUplinkBandwidth( |
| 1324 static_cast<int>(*bitrate_smoother_.GetAverage())); | 1329 static_cast<int>(*bitrate_smoother_.GetAverage())); |
| 1325 } | 1330 } |
| 1326 }); | 1331 }); |
| 1327 } | 1332 } |
| 1328 | 1333 |
| 1329 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1334 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3246 int64_t min_rtt = 0; | 3251 int64_t min_rtt = 0; |
| 3247 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3252 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3248 0) { | 3253 0) { |
| 3249 return 0; | 3254 return 0; |
| 3250 } | 3255 } |
| 3251 return rtt; | 3256 return rtt; |
| 3252 } | 3257 } |
| 3253 | 3258 |
| 3254 } // namespace voe | 3259 } // namespace voe |
| 3255 } // namespace webrtc | 3260 } // namespace webrtc |
| OLD | NEW |