Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2390883004: Hooking up audio network adaptor to VoE. (Closed)
Patch Set: adding a comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/network_predictor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 previous_frame_muted_(false), 847 previous_frame_muted_(false),
848 _panLeft(1.0f), 848 _panLeft(1.0f),
849 _panRight(1.0f), 849 _panRight(1.0f),
850 _outputGain(1.0f), 850 _outputGain(1.0f),
851 _lastLocalTimeStamp(0), 851 _lastLocalTimeStamp(0),
852 _lastPayloadType(0), 852 _lastPayloadType(0),
853 _includeAudioLevelIndication(false), 853 _includeAudioLevelIndication(false),
854 _outputSpeechType(AudioFrame::kNormalSpeech), 854 _outputSpeechType(AudioFrame::kNormalSpeech),
855 restored_packet_in_use_(false), 855 restored_packet_in_use_(false),
856 rtcp_observer_(new VoERtcpObserver(this)), 856 rtcp_observer_(new VoERtcpObserver(this)),
857 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())),
858 associate_send_channel_(ChannelOwner(nullptr)), 857 associate_send_channel_(ChannelOwner(nullptr)),
859 pacing_enabled_(config.enable_voice_pacing), 858 pacing_enabled_(config.enable_voice_pacing),
860 feedback_observer_proxy_(new TransportFeedbackProxy()), 859 feedback_observer_proxy_(new TransportFeedbackProxy()),
861 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), 860 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
862 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), 861 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
863 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), 862 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
864 kMaxRetransmissionWindowMs)), 863 kMaxRetransmissionWindowMs)),
865 decoder_factory_(config.acm_config.decoder_factory) { 864 decoder_factory_(config.acm_config.decoder_factory) {
866 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 865 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
867 "Channel::Channel() - ctor"); 866 "Channel::Channel() - ctor");
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 "SetSendCodec() failed to set audio packet size"); 1277 "SetSendCodec() failed to set audio packet size");
1279 return -1; 1278 return -1;
1280 } 1279 }
1281 1280
1282 return 0; 1281 return 0;
1283 } 1282 }
1284 1283
1285 void Channel::SetBitRate(int bitrate_bps) { 1284 void Channel::SetBitRate(int bitrate_bps) {
1286 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1285 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1287 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); 1286 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps);
1288 audio_coding_->SetBitRate(bitrate_bps); 1287 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1288 if (*encoder)
1289 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps);
1290 });
1289 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 1291 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
1290 } 1292 }
1291 1293
1292 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1294 void Channel::OnIncomingFractionLoss(int fraction_lost) {
1293 network_predictor_->UpdatePacketLossRate(fraction_lost); 1295 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1294 uint8_t average_fraction_loss = network_predictor_->GetLossRate(); 1296 if (*encoder)
1295 1297 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f);
1296 // Normalizes rate to 0 - 100. 1298 });
1297 if (audio_coding_->SetPacketLossRate(100 * average_fraction_loss / 255) !=
1298 0) {
1299 assert(false); // This should not happen.
1300 }
1301 } 1299 }
1302 1300
1303 int32_t Channel::SetVADStatus(bool enableVAD, 1301 int32_t Channel::SetVADStatus(bool enableVAD,
1304 ACMVADMode mode, 1302 ACMVADMode mode,
1305 bool disableDTX) { 1303 bool disableDTX) {
1306 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1304 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1307 "Channel::SetVADStatus(mode=%d)", mode); 1305 "Channel::SetVADStatus(mode=%d)", mode);
1308 RTC_DCHECK(!(disableDTX && enableVAD)); // disableDTX mode is deprecated. 1306 RTC_DCHECK(!(disableDTX && enableVAD)); // disableDTX mode is deprecated.
1309 if (!codec_manager_.SetVAD(enableVAD, mode) || 1307 if (!codec_manager_.SetVAD(enableVAD, mode) ||
1310 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) { 1308 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get())) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 int success = -1; 1485 int success = -1;
1488 audio_coding_->QueryEncoder([&](AudioEncoder const* encoder) { 1486 audio_coding_->QueryEncoder([&](AudioEncoder const* encoder) {
1489 if (encoder) { 1487 if (encoder) {
1490 *enabled = encoder->GetDtx(); 1488 *enabled = encoder->GetDtx();
1491 success = 0; 1489 success = 0;
1492 } 1490 }
1493 }); 1491 });
1494 return success; 1492 return success;
1495 } 1493 }
1496 1494
1495 bool Channel::EnableAudioNetworkAdaptor(const std::string& config_string) {
1496 bool success = false;
1497 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1498 if (*encoder) {
1499 success = (*encoder)->EnableAudioNetworkAdaptor(
1500 config_string, Clock::GetRealTimeClock());
1501 }
1502 });
1503 return success;
1504 }
1505
1506 void Channel::DisableAudioNetworkAdaptor() {
1507 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1508 if (*encoder)
1509 (*encoder)->DisableAudioNetworkAdaptor();
1510 });
1511 }
1512
1513 void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms,
1514 int max_frame_length_ms) {
1515 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1516 if (*encoder) {
1517 (*encoder)->SetReceiverFrameLengthRange(min_frame_length_ms,
1518 max_frame_length_ms);
1519 }
1520 });
1521 }
1522
1497 int32_t Channel::RegisterExternalTransport(Transport* transport) { 1523 int32_t Channel::RegisterExternalTransport(Transport* transport) {
1498 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1524 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1499 "Channel::RegisterExternalTransport()"); 1525 "Channel::RegisterExternalTransport()");
1500 1526
1501 rtc::CritScope cs(&_callbackCritSect); 1527 rtc::CritScope cs(&_callbackCritSect);
1502 if (_externalTransport) { 1528 if (_externalTransport) {
1503 _engineStatisticsPtr->SetLastError( 1529 _engineStatisticsPtr->SetLastError(
1504 VE_INVALID_OPERATION, kTraceError, 1530 VE_INVALID_OPERATION, kTraceError,
1505 "RegisterExternalTransport() external transport already enabled"); 1531 "RegisterExternalTransport() external transport already enabled");
1506 return -1; 1532 return -1;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 } 1673 }
1648 1674
1649 int64_t nack_window_ms = rtt; 1675 int64_t nack_window_ms = rtt;
1650 if (nack_window_ms < kMinRetransmissionWindowMs) { 1676 if (nack_window_ms < kMinRetransmissionWindowMs) {
1651 nack_window_ms = kMinRetransmissionWindowMs; 1677 nack_window_ms = kMinRetransmissionWindowMs;
1652 } else if (nack_window_ms > kMaxRetransmissionWindowMs) { 1678 } else if (nack_window_ms > kMaxRetransmissionWindowMs) {
1653 nack_window_ms = kMaxRetransmissionWindowMs; 1679 nack_window_ms = kMaxRetransmissionWindowMs;
1654 } 1680 }
1655 retransmission_rate_limiter_->SetWindowSize(nack_window_ms); 1681 retransmission_rate_limiter_->SetWindowSize(nack_window_ms);
1656 1682
1683 // Invoke audio encoders OnReceivedRtt().
1684 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1685 if (*encoder)
1686 (*encoder)->OnReceivedRtt(rtt);
1687 });
1688
1657 uint32_t ntp_secs = 0; 1689 uint32_t ntp_secs = 0;
1658 uint32_t ntp_frac = 0; 1690 uint32_t ntp_frac = 0;
1659 uint32_t rtp_timestamp = 0; 1691 uint32_t rtp_timestamp = 0;
1660 if (0 != 1692 if (0 !=
1661 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, 1693 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL,
1662 &rtp_timestamp)) { 1694 &rtp_timestamp)) {
1663 // Waiting for RTCP. 1695 // Waiting for RTCP.
1664 return 0; 1696 return 0;
1665 } 1697 }
1666 1698
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 int64_t min_rtt = 0; 3237 int64_t min_rtt = 0;
3206 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3238 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3207 0) { 3239 0) {
3208 return 0; 3240 return 0;
3209 } 3241 }
3210 return rtt; 3242 return rtt;
3211 } 3243 }
3212 3244
3213 } // namespace voe 3245 } // namespace voe
3214 } // namespace webrtc 3246 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/network_predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698