| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 int32_t Channel::InFrameType(FrameType frame_type) { | 381 int32_t Channel::InFrameType(FrameType frame_type) { |
| 382 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 382 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 383 "Channel::InFrameType(frame_type=%d)", frame_type); | 383 "Channel::InFrameType(frame_type=%d)", frame_type); |
| 384 | 384 |
| 385 rtc::CritScope cs(&_callbackCritSect); | 385 rtc::CritScope cs(&_callbackCritSect); |
| 386 _sendFrameType = (frame_type == kAudioFrameSpeech); | 386 _sendFrameType = (frame_type == kAudioFrameSpeech); |
| 387 return 0; | 387 return 0; |
| 388 } | 388 } |
| 389 | 389 |
| 390 int32_t Channel::OnRxVadDetected(int vadDecision) { | |
| 391 rtc::CritScope cs(&_callbackCritSect); | |
| 392 if (_rxVadObserverPtr) { | |
| 393 _rxVadObserverPtr->OnRxVad(_channelId, vadDecision); | |
| 394 } | |
| 395 | |
| 396 return 0; | |
| 397 } | |
| 398 | |
| 399 bool Channel::SendRtp(const uint8_t* data, | 390 bool Channel::SendRtp(const uint8_t* data, |
| 400 size_t len, | 391 size_t len, |
| 401 const PacketOptions& options) { | 392 const PacketOptions& options) { |
| 402 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 393 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 403 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); | 394 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); |
| 404 | 395 |
| 405 rtc::CritScope cs(&_callbackCritSect); | 396 rtc::CritScope cs(&_callbackCritSect); |
| 406 | 397 |
| 407 if (_transportPtr == NULL) { | 398 if (_transportPtr == NULL) { |
| 408 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 399 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return MixerParticipant::AudioFrameInfo::kError; | 569 return MixerParticipant::AudioFrameInfo::kError; |
| 579 } | 570 } |
| 580 | 571 |
| 581 if (muted) { | 572 if (muted) { |
| 582 // TODO(henrik.lundin): We should be able to do better than this. But we | 573 // TODO(henrik.lundin): We should be able to do better than this. But we |
| 583 // will have to go through all the cases below where the audio samples may | 574 // will have to go through all the cases below where the audio samples may |
| 584 // be used, and handle the muted case in some way. | 575 // be used, and handle the muted case in some way. |
| 585 audioFrame->Mute(); | 576 audioFrame->Mute(); |
| 586 } | 577 } |
| 587 | 578 |
| 588 if (_RxVadDetection) { | |
| 589 UpdateRxVadDetection(*audioFrame); | |
| 590 } | |
| 591 | |
| 592 // Convert module ID to internal VoE channel ID | 579 // Convert module ID to internal VoE channel ID |
| 593 audioFrame->id_ = VoEChannelId(audioFrame->id_); | 580 audioFrame->id_ = VoEChannelId(audioFrame->id_); |
| 594 // Store speech type for dead-or-alive detection | 581 // Store speech type for dead-or-alive detection |
| 595 _outputSpeechType = audioFrame->speech_type_; | 582 _outputSpeechType = audioFrame->speech_type_; |
| 596 | 583 |
| 597 ChannelState::State state = channel_state_.Get(); | 584 ChannelState::State state = channel_state_.Get(); |
| 598 | 585 |
| 599 if (state.rx_apm_is_enabled) { | |
| 600 int err = rx_audioproc_->ProcessStream(audioFrame); | |
| 601 if (err) { | |
| 602 LOG(LS_ERROR) << "ProcessStream() error: " << err; | |
| 603 assert(false); | |
| 604 } | |
| 605 } | |
| 606 | |
| 607 { | 586 { |
| 608 // Pass the audio buffers to an optional sink callback, before applying | 587 // Pass the audio buffers to an optional sink callback, before applying |
| 609 // scaling/panning, as that applies to the mix operation. | 588 // scaling/panning, as that applies to the mix operation. |
| 610 // External recipients of the audio (e.g. via AudioTrack), will do their | 589 // External recipients of the audio (e.g. via AudioTrack), will do their |
| 611 // own mixing/dynamic processing. | 590 // own mixing/dynamic processing. |
| 612 rtc::CritScope cs(&_callbackCritSect); | 591 rtc::CritScope cs(&_callbackCritSect); |
| 613 if (audio_sink_) { | 592 if (audio_sink_) { |
| 614 AudioSinkInterface::Data data( | 593 AudioSinkInterface::Data data( |
| 615 &audioFrame->data_[0], audioFrame->samples_per_channel_, | 594 &audioFrame->data_[0], audioFrame->samples_per_channel_, |
| 616 audioFrame->sample_rate_hz_, audioFrame->num_channels_, | 595 audioFrame->sample_rate_hz_, audioFrame->num_channels_, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 capture_start_rtp_time_stamp_(-1), | 833 capture_start_rtp_time_stamp_(-1), |
| 855 capture_start_ntp_time_ms_(-1), | 834 capture_start_ntp_time_ms_(-1), |
| 856 _engineStatisticsPtr(NULL), | 835 _engineStatisticsPtr(NULL), |
| 857 _outputMixerPtr(NULL), | 836 _outputMixerPtr(NULL), |
| 858 _transmitMixerPtr(NULL), | 837 _transmitMixerPtr(NULL), |
| 859 _moduleProcessThreadPtr(NULL), | 838 _moduleProcessThreadPtr(NULL), |
| 860 _audioDeviceModulePtr(NULL), | 839 _audioDeviceModulePtr(NULL), |
| 861 _voiceEngineObserverPtr(NULL), | 840 _voiceEngineObserverPtr(NULL), |
| 862 _callbackCritSectPtr(NULL), | 841 _callbackCritSectPtr(NULL), |
| 863 _transportPtr(NULL), | 842 _transportPtr(NULL), |
| 864 _rxVadObserverPtr(NULL), | |
| 865 _oldVadDecision(-1), | |
| 866 _sendFrameType(0), | 843 _sendFrameType(0), |
| 867 _externalMixing(false), | 844 _externalMixing(false), |
| 868 _mixFileWithMicrophone(false), | 845 _mixFileWithMicrophone(false), |
| 869 input_mute_(false), | 846 input_mute_(false), |
| 870 previous_frame_muted_(false), | 847 previous_frame_muted_(false), |
| 871 _panLeft(1.0f), | 848 _panLeft(1.0f), |
| 872 _panRight(1.0f), | 849 _panRight(1.0f), |
| 873 _outputGain(1.0f), | 850 _outputGain(1.0f), |
| 874 _lastLocalTimeStamp(0), | 851 _lastLocalTimeStamp(0), |
| 875 _lastPayloadType(0), | 852 _lastPayloadType(0), |
| 876 _includeAudioLevelIndication(false), | 853 _includeAudioLevelIndication(false), |
| 877 _outputSpeechType(AudioFrame::kNormalSpeech), | 854 _outputSpeechType(AudioFrame::kNormalSpeech), |
| 878 _RxVadDetection(false), | |
| 879 _rxAgcIsEnabled(false), | |
| 880 _rxNsIsEnabled(false), | |
| 881 restored_packet_in_use_(false), | 855 restored_packet_in_use_(false), |
| 882 rtcp_observer_(new VoERtcpObserver(this)), | 856 rtcp_observer_(new VoERtcpObserver(this)), |
| 883 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), | 857 network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())), |
| 884 associate_send_channel_(ChannelOwner(nullptr)), | 858 associate_send_channel_(ChannelOwner(nullptr)), |
| 885 pacing_enabled_(config.enable_voice_pacing), | 859 pacing_enabled_(config.enable_voice_pacing), |
| 886 feedback_observer_proxy_(new TransportFeedbackProxy()), | 860 feedback_observer_proxy_(new TransportFeedbackProxy()), |
| 887 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 861 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
| 888 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), | 862 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
| 889 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), | 863 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), |
| 890 kMaxRetransmissionWindowMs)), | 864 kMaxRetransmissionWindowMs)), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 912 configuration.event_log = &(*event_log_proxy_); | 886 configuration.event_log = &(*event_log_proxy_); |
| 913 configuration.retransmission_rate_limiter = | 887 configuration.retransmission_rate_limiter = |
| 914 retransmission_rate_limiter_.get(); | 888 retransmission_rate_limiter_.get(); |
| 915 | 889 |
| 916 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 890 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
| 917 _rtpRtcpModule->SetSendingMediaStatus(false); | 891 _rtpRtcpModule->SetSendingMediaStatus(false); |
| 918 | 892 |
| 919 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); | 893 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); |
| 920 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( | 894 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( |
| 921 statistics_proxy_.get()); | 895 statistics_proxy_.get()); |
| 922 | |
| 923 Config audioproc_config; | |
| 924 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | |
| 925 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); | |
| 926 } | 896 } |
| 927 | 897 |
| 928 Channel::~Channel() { | 898 Channel::~Channel() { |
| 929 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); | 899 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); |
| 930 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 900 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
| 931 "Channel::~Channel() - dtor"); | 901 "Channel::~Channel() - dtor"); |
| 932 | 902 |
| 933 if (_outputExternalMedia) { | 903 if (_outputExternalMedia) { |
| 934 DeRegisterExternalMediaProcessing(kPlaybackPerChannel); | 904 DeRegisterExternalMediaProcessing(kPlaybackPerChannel); |
| 935 } | 905 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) || | 1041 !RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) || |
| 1072 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { | 1042 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { |
| 1073 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1043 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1074 "Channel::Init() failed to register CN (%d/%d) " | 1044 "Channel::Init() failed to register CN (%d/%d) " |
| 1075 "correctly - 1", | 1045 "correctly - 1", |
| 1076 codec.pltype, codec.plfreq); | 1046 codec.pltype, codec.plfreq); |
| 1077 } | 1047 } |
| 1078 } | 1048 } |
| 1079 } | 1049 } |
| 1080 | 1050 |
| 1081 if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) { | |
| 1082 LOG(LS_ERROR) << "noise_suppression()->set_level(kDefaultNsMode) failed."; | |
| 1083 return -1; | |
| 1084 } | |
| 1085 if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) { | |
| 1086 LOG(LS_ERROR) << "gain_control()->set_mode(kDefaultRxAgcMode) failed."; | |
| 1087 return -1; | |
| 1088 } | |
| 1089 | |
| 1090 return 0; | 1051 return 0; |
| 1091 } | 1052 } |
| 1092 | 1053 |
| 1093 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, | 1054 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, |
| 1094 OutputMixer& outputMixer, | 1055 OutputMixer& outputMixer, |
| 1095 voe::TransmitMixer& transmitMixer, | 1056 voe::TransmitMixer& transmitMixer, |
| 1096 ProcessThread& moduleProcessThread, | 1057 ProcessThread& moduleProcessThread, |
| 1097 AudioDeviceModule& audioDeviceModule, | 1058 AudioDeviceModule& audioDeviceModule, |
| 1098 VoiceEngineObserver* voiceEngineObserver, | 1059 VoiceEngineObserver* voiceEngineObserver, |
| 1099 rtc::CriticalSection* callbackCritSect) { | 1060 rtc::CriticalSection* callbackCritSect) { |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 _engineStatisticsPtr->SetLastError( | 2263 _engineStatisticsPtr->SetLastError( |
| 2303 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 2264 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
| 2304 "SetSendTelephoneEventPayloadType() failed to register send" | 2265 "SetSendTelephoneEventPayloadType() failed to register send" |
| 2305 "payload type"); | 2266 "payload type"); |
| 2306 return -1; | 2267 return -1; |
| 2307 } | 2268 } |
| 2308 } | 2269 } |
| 2309 return 0; | 2270 return 0; |
| 2310 } | 2271 } |
| 2311 | 2272 |
| 2312 int Channel::UpdateRxVadDetection(AudioFrame& audioFrame) { | |
| 2313 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2314 "Channel::UpdateRxVadDetection()"); | |
| 2315 | |
| 2316 int vadDecision = 1; | |
| 2317 | |
| 2318 vadDecision = (audioFrame.vad_activity_ == AudioFrame::kVadActive) ? 1 : 0; | |
| 2319 | |
| 2320 if ((vadDecision != _oldVadDecision) && _rxVadObserverPtr) { | |
| 2321 OnRxVadDetected(vadDecision); | |
| 2322 _oldVadDecision = vadDecision; | |
| 2323 } | |
| 2324 | |
| 2325 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2326 "Channel::UpdateRxVadDetection() => vadDecision=%d", | |
| 2327 vadDecision); | |
| 2328 return 0; | |
| 2329 } | |
| 2330 | |
| 2331 int Channel::RegisterRxVadObserver(VoERxVadCallback& observer) { | |
| 2332 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2333 "Channel::RegisterRxVadObserver()"); | |
| 2334 rtc::CritScope cs(&_callbackCritSect); | |
| 2335 | |
| 2336 if (_rxVadObserverPtr) { | |
| 2337 _engineStatisticsPtr->SetLastError( | |
| 2338 VE_INVALID_OPERATION, kTraceError, | |
| 2339 "RegisterRxVadObserver() observer already enabled"); | |
| 2340 return -1; | |
| 2341 } | |
| 2342 _rxVadObserverPtr = &observer; | |
| 2343 _RxVadDetection = true; | |
| 2344 return 0; | |
| 2345 } | |
| 2346 | |
| 2347 int Channel::DeRegisterRxVadObserver() { | |
| 2348 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2349 "Channel::DeRegisterRxVadObserver()"); | |
| 2350 rtc::CritScope cs(&_callbackCritSect); | |
| 2351 | |
| 2352 if (!_rxVadObserverPtr) { | |
| 2353 _engineStatisticsPtr->SetLastError( | |
| 2354 VE_INVALID_OPERATION, kTraceWarning, | |
| 2355 "DeRegisterRxVadObserver() observer already disabled"); | |
| 2356 return 0; | |
| 2357 } | |
| 2358 _rxVadObserverPtr = NULL; | |
| 2359 _RxVadDetection = false; | |
| 2360 return 0; | |
| 2361 } | |
| 2362 | |
| 2363 int Channel::VoiceActivityIndicator(int& activity) { | 2273 int Channel::VoiceActivityIndicator(int& activity) { |
| 2364 activity = _sendFrameType; | 2274 activity = _sendFrameType; |
| 2365 return 0; | 2275 return 0; |
| 2366 } | 2276 } |
| 2367 | 2277 |
| 2368 #ifdef WEBRTC_VOICE_ENGINE_AGC | |
| 2369 | |
| 2370 int Channel::SetRxAgcStatus(bool enable, AgcModes mode) { | |
| 2371 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2372 "Channel::SetRxAgcStatus(enable=%d, mode=%d)", (int)enable, | |
| 2373 (int)mode); | |
| 2374 | |
| 2375 GainControl::Mode agcMode = kDefaultRxAgcMode; | |
| 2376 switch (mode) { | |
| 2377 case kAgcDefault: | |
| 2378 break; | |
| 2379 case kAgcUnchanged: | |
| 2380 agcMode = rx_audioproc_->gain_control()->mode(); | |
| 2381 break; | |
| 2382 case kAgcFixedDigital: | |
| 2383 agcMode = GainControl::kFixedDigital; | |
| 2384 break; | |
| 2385 case kAgcAdaptiveDigital: | |
| 2386 agcMode = GainControl::kAdaptiveDigital; | |
| 2387 break; | |
| 2388 default: | |
| 2389 _engineStatisticsPtr->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | |
| 2390 "SetRxAgcStatus() invalid Agc mode"); | |
| 2391 return -1; | |
| 2392 } | |
| 2393 | |
| 2394 if (rx_audioproc_->gain_control()->set_mode(agcMode) != 0) { | |
| 2395 _engineStatisticsPtr->SetLastError( | |
| 2396 VE_APM_ERROR, kTraceError, "SetRxAgcStatus() failed to set Agc mode"); | |
| 2397 return -1; | |
| 2398 } | |
| 2399 if (rx_audioproc_->gain_control()->Enable(enable) != 0) { | |
| 2400 _engineStatisticsPtr->SetLastError( | |
| 2401 VE_APM_ERROR, kTraceError, "SetRxAgcStatus() failed to set Agc state"); | |
| 2402 return -1; | |
| 2403 } | |
| 2404 | |
| 2405 _rxAgcIsEnabled = enable; | |
| 2406 channel_state_.SetRxApmIsEnabled(_rxAgcIsEnabled || _rxNsIsEnabled); | |
| 2407 | |
| 2408 return 0; | |
| 2409 } | |
| 2410 | |
| 2411 int Channel::GetRxAgcStatus(bool& enabled, AgcModes& mode) { | |
| 2412 bool enable = rx_audioproc_->gain_control()->is_enabled(); | |
| 2413 GainControl::Mode agcMode = rx_audioproc_->gain_control()->mode(); | |
| 2414 | |
| 2415 enabled = enable; | |
| 2416 | |
| 2417 switch (agcMode) { | |
| 2418 case GainControl::kFixedDigital: | |
| 2419 mode = kAgcFixedDigital; | |
| 2420 break; | |
| 2421 case GainControl::kAdaptiveDigital: | |
| 2422 mode = kAgcAdaptiveDigital; | |
| 2423 break; | |
| 2424 default: | |
| 2425 _engineStatisticsPtr->SetLastError(VE_APM_ERROR, kTraceError, | |
| 2426 "GetRxAgcStatus() invalid Agc mode"); | |
| 2427 return -1; | |
| 2428 } | |
| 2429 | |
| 2430 return 0; | |
| 2431 } | |
| 2432 | |
| 2433 int Channel::SetRxAgcConfig(AgcConfig config) { | |
| 2434 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2435 "Channel::SetRxAgcConfig()"); | |
| 2436 | |
| 2437 if (rx_audioproc_->gain_control()->set_target_level_dbfs( | |
| 2438 config.targetLeveldBOv) != 0) { | |
| 2439 _engineStatisticsPtr->SetLastError( | |
| 2440 VE_APM_ERROR, kTraceError, | |
| 2441 "SetRxAgcConfig() failed to set target peak |level|" | |
| 2442 "(or envelope) of the Agc"); | |
| 2443 return -1; | |
| 2444 } | |
| 2445 if (rx_audioproc_->gain_control()->set_compression_gain_db( | |
| 2446 config.digitalCompressionGaindB) != 0) { | |
| 2447 _engineStatisticsPtr->SetLastError( | |
| 2448 VE_APM_ERROR, kTraceError, | |
| 2449 "SetRxAgcConfig() failed to set the range in |gain| the" | |
| 2450 " digital compression stage may apply"); | |
| 2451 return -1; | |
| 2452 } | |
| 2453 if (rx_audioproc_->gain_control()->enable_limiter(config.limiterEnable) != | |
| 2454 0) { | |
| 2455 _engineStatisticsPtr->SetLastError( | |
| 2456 VE_APM_ERROR, kTraceError, | |
| 2457 "SetRxAgcConfig() failed to set hard limiter to the signal"); | |
| 2458 return -1; | |
| 2459 } | |
| 2460 | |
| 2461 return 0; | |
| 2462 } | |
| 2463 | |
| 2464 int Channel::GetRxAgcConfig(AgcConfig& config) { | |
| 2465 config.targetLeveldBOv = rx_audioproc_->gain_control()->target_level_dbfs(); | |
| 2466 config.digitalCompressionGaindB = | |
| 2467 rx_audioproc_->gain_control()->compression_gain_db(); | |
| 2468 config.limiterEnable = rx_audioproc_->gain_control()->is_limiter_enabled(); | |
| 2469 | |
| 2470 return 0; | |
| 2471 } | |
| 2472 | |
| 2473 #endif // #ifdef WEBRTC_VOICE_ENGINE_AGC | |
| 2474 | |
| 2475 #ifdef WEBRTC_VOICE_ENGINE_NR | |
| 2476 | |
| 2477 int Channel::SetRxNsStatus(bool enable, NsModes mode) { | |
| 2478 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2479 "Channel::SetRxNsStatus(enable=%d, mode=%d)", (int)enable, | |
| 2480 (int)mode); | |
| 2481 | |
| 2482 NoiseSuppression::Level nsLevel = kDefaultNsMode; | |
| 2483 switch (mode) { | |
| 2484 case kNsDefault: | |
| 2485 break; | |
| 2486 case kNsUnchanged: | |
| 2487 nsLevel = rx_audioproc_->noise_suppression()->level(); | |
| 2488 break; | |
| 2489 case kNsConference: | |
| 2490 nsLevel = NoiseSuppression::kHigh; | |
| 2491 break; | |
| 2492 case kNsLowSuppression: | |
| 2493 nsLevel = NoiseSuppression::kLow; | |
| 2494 break; | |
| 2495 case kNsModerateSuppression: | |
| 2496 nsLevel = NoiseSuppression::kModerate; | |
| 2497 break; | |
| 2498 case kNsHighSuppression: | |
| 2499 nsLevel = NoiseSuppression::kHigh; | |
| 2500 break; | |
| 2501 case kNsVeryHighSuppression: | |
| 2502 nsLevel = NoiseSuppression::kVeryHigh; | |
| 2503 break; | |
| 2504 } | |
| 2505 | |
| 2506 if (rx_audioproc_->noise_suppression()->set_level(nsLevel) != 0) { | |
| 2507 _engineStatisticsPtr->SetLastError( | |
| 2508 VE_APM_ERROR, kTraceError, "SetRxNsStatus() failed to set NS level"); | |
| 2509 return -1; | |
| 2510 } | |
| 2511 if (rx_audioproc_->noise_suppression()->Enable(enable) != 0) { | |
| 2512 _engineStatisticsPtr->SetLastError( | |
| 2513 VE_APM_ERROR, kTraceError, "SetRxNsStatus() failed to set NS state"); | |
| 2514 return -1; | |
| 2515 } | |
| 2516 | |
| 2517 _rxNsIsEnabled = enable; | |
| 2518 channel_state_.SetRxApmIsEnabled(_rxAgcIsEnabled || _rxNsIsEnabled); | |
| 2519 | |
| 2520 return 0; | |
| 2521 } | |
| 2522 | |
| 2523 int Channel::GetRxNsStatus(bool& enabled, NsModes& mode) { | |
| 2524 bool enable = rx_audioproc_->noise_suppression()->is_enabled(); | |
| 2525 NoiseSuppression::Level ncLevel = rx_audioproc_->noise_suppression()->level(); | |
| 2526 | |
| 2527 enabled = enable; | |
| 2528 | |
| 2529 switch (ncLevel) { | |
| 2530 case NoiseSuppression::kLow: | |
| 2531 mode = kNsLowSuppression; | |
| 2532 break; | |
| 2533 case NoiseSuppression::kModerate: | |
| 2534 mode = kNsModerateSuppression; | |
| 2535 break; | |
| 2536 case NoiseSuppression::kHigh: | |
| 2537 mode = kNsHighSuppression; | |
| 2538 break; | |
| 2539 case NoiseSuppression::kVeryHigh: | |
| 2540 mode = kNsVeryHighSuppression; | |
| 2541 break; | |
| 2542 } | |
| 2543 | |
| 2544 return 0; | |
| 2545 } | |
| 2546 | |
| 2547 #endif // #ifdef WEBRTC_VOICE_ENGINE_NR | |
| 2548 | |
| 2549 int Channel::SetLocalSSRC(unsigned int ssrc) { | 2278 int Channel::SetLocalSSRC(unsigned int ssrc) { |
| 2550 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2279 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 2551 "Channel::SetLocalSSRC()"); | 2280 "Channel::SetLocalSSRC()"); |
| 2552 if (channel_state_.Get().sending) { | 2281 if (channel_state_.Get().sending) { |
| 2553 _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, | 2282 _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, |
| 2554 "SetLocalSSRC() already sending"); | 2283 "SetLocalSSRC() already sending"); |
| 2555 return -1; | 2284 return -1; |
| 2556 } | 2285 } |
| 2557 _rtpRtcpModule->SetSSRC(ssrc); | 2286 _rtpRtcpModule->SetSSRC(ssrc); |
| 2558 return 0; | 2287 return 0; |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 int64_t min_rtt = 0; | 3205 int64_t min_rtt = 0; |
| 3477 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3206 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3478 0) { | 3207 0) { |
| 3479 return 0; | 3208 return 0; |
| 3480 } | 3209 } |
| 3481 return rtt; | 3210 return rtt; |
| 3482 } | 3211 } |
| 3483 | 3212 |
| 3484 } // namespace voe | 3213 } // namespace voe |
| 3485 } // namespace webrtc | 3214 } // namespace webrtc |
| OLD | NEW |