| 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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 "SetSendCodec() failed to set audio packet size"); | 1278 "SetSendCodec() failed to set audio packet size"); |
| 1279 return -1; | 1279 return -1; |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 return 0; | 1282 return 0; |
| 1283 } | 1283 } |
| 1284 | 1284 |
| 1285 void Channel::SetBitRate(int bitrate_bps) { | 1285 void Channel::SetBitRate(int bitrate_bps) { |
| 1286 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1286 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1287 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); | 1287 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); |
| 1288 audio_coding_->SetBitRate(bitrate_bps); | 1288 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1289 if (*encoder) |
| 1290 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); |
| 1291 }); |
| 1289 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); | 1292 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
| 1290 } | 1293 } |
| 1291 | 1294 |
| 1292 void Channel::OnIncomingFractionLoss(int fraction_lost) { | 1295 void Channel::OnIncomingFractionLoss(int fraction_lost) { |
| 1293 network_predictor_->UpdatePacketLossRate(fraction_lost); | 1296 network_predictor_->UpdatePacketLossRate(fraction_lost); |
| 1294 uint8_t average_fraction_loss = network_predictor_->GetLossRate(); | 1297 uint8_t average_fraction_loss = network_predictor_->GetLossRate(); |
| 1295 | 1298 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1296 // Normalizes rate to 0 - 100. | 1299 if (*encoder) { |
| 1297 if (audio_coding_->SetPacketLossRate(100 * average_fraction_loss / 255) != | 1300 (*encoder)->OnReceivedUplinkPacketLossFraction(average_fraction_loss / |
| 1298 0) { | 1301 255.0f); |
| 1299 assert(false); // This should not happen. | 1302 } |
| 1300 } | 1303 }); |
| 1301 } | 1304 } |
| 1302 | 1305 |
| 1303 int32_t Channel::SetVADStatus(bool enableVAD, | 1306 int32_t Channel::SetVADStatus(bool enableVAD, |
| 1304 ACMVADMode mode, | 1307 ACMVADMode mode, |
| 1305 bool disableDTX) { | 1308 bool disableDTX) { |
| 1306 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1309 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1307 "Channel::SetVADStatus(mode=%d)", mode); | 1310 "Channel::SetVADStatus(mode=%d)", mode); |
| 1308 RTC_DCHECK(!(disableDTX && enableVAD)); // disableDTX mode is deprecated. | 1311 RTC_DCHECK(!(disableDTX && enableVAD)); // disableDTX mode is deprecated. |
| 1309 if (!codec_manager_.SetVAD(enableVAD, mode) || | 1312 if (!codec_manager_.SetVAD(enableVAD, mode) || |
| 1310 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) { | 1313 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 int success = -1; | 1490 int success = -1; |
| 1488 audio_coding_->QueryEncoder([&](AudioEncoder const* encoder) { | 1491 audio_coding_->QueryEncoder([&](AudioEncoder const* encoder) { |
| 1489 if (encoder) { | 1492 if (encoder) { |
| 1490 *enabled = encoder->GetDtx(); | 1493 *enabled = encoder->GetDtx(); |
| 1491 success = 0; | 1494 success = 0; |
| 1492 } | 1495 } |
| 1493 }); | 1496 }); |
| 1494 return success; | 1497 return success; |
| 1495 } | 1498 } |
| 1496 | 1499 |
| 1500 bool Channel::EnableAudioNetworkAdaptor(const std::string& config_string) { |
| 1501 bool success = false; |
| 1502 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1503 if (*encoder) { |
| 1504 success = (*encoder)->EnableAudioNetworkAdaptor( |
| 1505 config_string, Clock::GetRealTimeClock()); |
| 1506 } |
| 1507 }); |
| 1508 return success; |
| 1509 } |
| 1510 |
| 1511 void Channel::DisableAudioNetworkAdaptor() { |
| 1512 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1513 if (*encoder) |
| 1514 (*encoder)->DisableAudioNetworkAdaptor(); |
| 1515 }); |
| 1516 } |
| 1517 |
| 1518 void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms, |
| 1519 int max_frame_length_ms) { |
| 1520 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1521 if (*encoder) { |
| 1522 (*encoder)->SetReceiverFrameLengthRange(min_frame_length_ms, |
| 1523 max_frame_length_ms); |
| 1524 } |
| 1525 }); |
| 1526 } |
| 1527 |
| 1497 int32_t Channel::RegisterExternalTransport(Transport* transport) { | 1528 int32_t Channel::RegisterExternalTransport(Transport* transport) { |
| 1498 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1529 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1499 "Channel::RegisterExternalTransport()"); | 1530 "Channel::RegisterExternalTransport()"); |
| 1500 | 1531 |
| 1501 rtc::CritScope cs(&_callbackCritSect); | 1532 rtc::CritScope cs(&_callbackCritSect); |
| 1502 if (_externalTransport) { | 1533 if (_externalTransport) { |
| 1503 _engineStatisticsPtr->SetLastError( | 1534 _engineStatisticsPtr->SetLastError( |
| 1504 VE_INVALID_OPERATION, kTraceError, | 1535 VE_INVALID_OPERATION, kTraceError, |
| 1505 "RegisterExternalTransport() external transport already enabled"); | 1536 "RegisterExternalTransport() external transport already enabled"); |
| 1506 return -1; | 1537 return -1; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 } | 1678 } |
| 1648 | 1679 |
| 1649 int64_t nack_window_ms = rtt; | 1680 int64_t nack_window_ms = rtt; |
| 1650 if (nack_window_ms < kMinRetransmissionWindowMs) { | 1681 if (nack_window_ms < kMinRetransmissionWindowMs) { |
| 1651 nack_window_ms = kMinRetransmissionWindowMs; | 1682 nack_window_ms = kMinRetransmissionWindowMs; |
| 1652 } else if (nack_window_ms > kMaxRetransmissionWindowMs) { | 1683 } else if (nack_window_ms > kMaxRetransmissionWindowMs) { |
| 1653 nack_window_ms = kMaxRetransmissionWindowMs; | 1684 nack_window_ms = kMaxRetransmissionWindowMs; |
| 1654 } | 1685 } |
| 1655 retransmission_rate_limiter_->SetWindowSize(nack_window_ms); | 1686 retransmission_rate_limiter_->SetWindowSize(nack_window_ms); |
| 1656 | 1687 |
| 1688 // Invoke audio encoders OnReceivedRtt(). |
| 1689 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1690 if (*encoder) |
| 1691 (*encoder)->OnReceivedRtt(rtt); |
| 1692 }); |
| 1693 |
| 1657 uint32_t ntp_secs = 0; | 1694 uint32_t ntp_secs = 0; |
| 1658 uint32_t ntp_frac = 0; | 1695 uint32_t ntp_frac = 0; |
| 1659 uint32_t rtp_timestamp = 0; | 1696 uint32_t rtp_timestamp = 0; |
| 1660 if (0 != | 1697 if (0 != |
| 1661 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, | 1698 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, |
| 1662 &rtp_timestamp)) { | 1699 &rtp_timestamp)) { |
| 1663 // Waiting for RTCP. | 1700 // Waiting for RTCP. |
| 1664 return 0; | 1701 return 0; |
| 1665 } | 1702 } |
| 1666 | 1703 |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 int64_t min_rtt = 0; | 3242 int64_t min_rtt = 0; |
| 3206 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3243 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3207 0) { | 3244 0) { |
| 3208 return 0; | 3245 return 0; |
| 3209 } | 3246 } |
| 3210 return rtt; | 3247 return rtt; |
| 3211 } | 3248 } |
| 3212 | 3249 |
| 3213 } // namespace voe | 3250 } // namespace voe |
| 3214 } // namespace webrtc | 3251 } // namespace webrtc |
| OLD | NEW |