From e2a34f8275d341192318b648b05cf65d4961edbe Mon Sep 17 00:00:00 2001 From: "henrike@webrtc.org" Date: Mon, 7 Nov 2011 21:33:24 +0000 Subject: [PATCH] Removes the API for setting RX VAD since the RX vad should always be on anyways. Review URL: http://webrtc-codereview.appspot.com/264001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@897 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/interface/audio_coding_module.h | 28 --------- .../audio_coding/main/source/acm_neteq.cc | 58 +++++-------------- .../audio_coding/main/source/acm_neteq.h | 30 +++------- .../main/source/audio_coding_module_impl.cc | 20 ------- .../main/source/audio_coding_module_impl.h | 7 --- src/voice_engine/main/source/channel.cc | 12 ---- 6 files changed, 23 insertions(+), 132 deletions(-) diff --git a/src/modules/audio_coding/main/interface/audio_coding_module.h b/src/modules/audio_coding/main/interface/audio_coding_module.h index b4b9cc96b..73bddd186 100644 --- a/src/modules/audio_coding/main/interface/audio_coding_module.h +++ b/src/modules/audio_coding/main/interface/audio_coding_module.h @@ -799,34 +799,6 @@ class AudioCodingModule: public Module { // Generate comfort noise when receiving DTX packets // - /////////////////////////////////////////////////////////////////////////// - // WebRtc_Word16 SetReceiveVADStatus() - // configure VAD status i.e. on/off on the incoming stream - // Running VAD on decoded audio is desired in some applications, e.g. - // conferencing. - // - // Input: - // -enable : true to enable VAD on incoming stream, and false - // to disable. - // - // Return value: - // -1 if failed to enable/disable VAD, - // 0 if succeded to enable/disable VAD. - // - virtual WebRtc_Word16 SetReceiveVADStatus(const bool enable) = 0; - - /////////////////////////////////////////////////////////////////////////// - // bool ReceiveVADStatus() - // Call this API to get whether VAD is enabled on incoming stream or not. - // Running VAD on decoded audio is desired in some applications, e.g. - // conferencing. - // - // Return value: - // true if VAD is enabled on the incoming stream, - // false if VAD is disabled on the incoming stream. - // - virtual bool ReceiveVADStatus() const = 0; - /////////////////////////////////////////////////////////////////////////// // WebRtc_Word16 SetReceiveVADMode() // Configure VAD aggressiveness on the incoming stream. diff --git a/src/modules/audio_coding/main/source/acm_neteq.cc b/src/modules/audio_coding/main/source/acm_neteq.cc index d3a69d9c4..18d9032d5 100644 --- a/src/modules/audio_coding/main/source/acm_neteq.cc +++ b/src/modules/audio_coding/main/source/acm_neteq.cc @@ -142,6 +142,10 @@ ACMNetEQ::Init() } _isInitialized[idx] = true; } + if (EnableVAD() == -1) + { + return -1; + } return 0; } @@ -919,20 +923,14 @@ ACMNetEQ::RTPPack( } } - -bool -ACMNetEQ::VADStatus() const -{ - CriticalSectionScoped lock(*_netEqCritSect); - return _vadStatus; -} - - WebRtc_Word16 -ACMNetEQ::SetVADStatus( - const bool status) +ACMNetEQ::EnableVAD() { CriticalSectionScoped lock(*_netEqCritSect); + if (_vadStatus) + { + return 0; + } for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++) { if(!_isInitialized[idx]) @@ -941,42 +939,16 @@ ACMNetEQ::SetVADStatus( "SetVADStatus: NetEq is not initialized."); return -1; } - if(_vadStatus && !status) + // VAD was off and we have to turn it on + if(EnableVADByIdxSafe(idx) < 0) { - // We have been using VAD but we want to stop using it calling the - // following function with NULL as VAD instance switches off the - // post-decode VAD - if(WebRtcNetEQ_SetVADInstance(_inst[idx], NULL, - (WebRtcNetEQ_VADInitFunction) WebRtcVad_Init, - (WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode, - (WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0) - { - LogError("setVADinstance", idx); - return -1; - } - // Free VAD Memory - if(_ptrVADInst[idx] != NULL) - { - WebRtcVad_Free(_ptrVADInst[idx]); - _ptrVADInst[idx] = NULL; - } - - // Set previous VAD status to UNKNOWN - _previousAudioActivity = AudioFrame::kVadUnknown; + return -1; } - else if(!_vadStatus && status) - { - // VAD was off and we have to turn it on - if(EnableVADByIdxSafe(idx) < 0) - { - return -1; - } - // Set previous VAD status to PASSIVE - _previousAudioActivity = AudioFrame::kVadPassive; - } + // Set previous VAD status to PASSIVE + _previousAudioActivity = AudioFrame::kVadPassive; } - _vadStatus = status; + _vadStatus = true; return 0; } diff --git a/src/modules/audio_coding/main/source/acm_neteq.h b/src/modules/audio_coding/main/source/acm_neteq.h index da19b8d60..821d1ebda 100644 --- a/src/modules/audio_coding/main/source/acm_neteq.h +++ b/src/modules/audio_coding/main/source/acm_neteq.h @@ -249,28 +249,6 @@ public: // WebRtc_Word32 ResetJitterStatistics() const; - // - // VADStatus() - // Get the current VAD status. - // - // Return value : True if VAD is enabled. - // False if VAD is disabled. - // - bool VADStatus() const; - - // - // SetVADStatus() - // Enable/disable VAD. - // - // Input: - // - enable : Enable if true, disable if false. - // - // Return value : 0 if ok. - // -1 if an error occurred. - // - WebRtc_Word16 SetVADStatus( - const bool status); - // // VADMode() // Get the current VAD Mode. @@ -408,6 +386,14 @@ private: WebRtc_Word16 InitByIdxSafe( const WebRtc_Word16 idx); + // EnableVAD() + // Enable VAD. + // + // Return value : 0 if ok. + // -1 if an error occurred. + // + WebRtc_Word16 EnableVAD(); + WebRtc_Word16 EnableVADByIdxSafe( const WebRtc_Word16 idx); diff --git a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc index a2ae11249..7878210e9 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -2094,26 +2094,6 @@ AudioCodingModuleImpl::PlayoutData10Ms( // Generate comfort noise when receiving DTX packets // -// Get VAD status on the incoming stream -bool -AudioCodingModuleImpl::ReceiveVADStatus() const -{ - WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, _id, - "ReceiveVADStatus()"); - return _netEq.VADStatus(); -} - - -// configure VAD status i.e on/off on the incoming stream -WebRtc_Word16 -AudioCodingModuleImpl::SetReceiveVADStatus( - const bool enable) -{ - WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, _id, - "SetReceiveVADStatus()"); - return _netEq.SetVADStatus(enable); -} - // Get VAD aggressiveness on the incoming stream ACMVADMode AudioCodingModuleImpl::ReceiveVADMode() const diff --git a/src/modules/audio_coding/main/source/audio_coding_module_impl.h b/src/modules/audio_coding/main/source/audio_coding_module_impl.h index eb5176cd5..32246357a 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module_impl.h +++ b/src/modules/audio_coding/main/source/audio_coding_module_impl.h @@ -152,13 +152,6 @@ public: WebRtc_Word32 RegisterVADCallback( ACMVADCallback* vadCallback); - // Get VAD status on the incoming stream - bool ReceiveVADStatus() const; - - // configure VAD status i.e on/off on the incoming stream - WebRtc_Word16 SetReceiveVADStatus( - const bool enable); - // Get VAD aggressiveness on the incoming stream ACMVADMode ReceiveVADMode() const; diff --git a/src/voice_engine/main/source/channel.cc b/src/voice_engine/main/source/channel.cc index 8ddfde573..d83da8750 100644 --- a/src/voice_engine/main/source/channel.cc +++ b/src/voice_engine/main/source/channel.cc @@ -1401,8 +1401,6 @@ Channel::Init() // out-of-band Dtmf tones are played out by default (_audioCodingModule.SetDtmfPlayoutStatus(true) == -1) || #endif - // Enable RX VAD by default (improves output mixing). - (_audioCodingModule.SetReceiveVADStatus(true) == -1) || (_audioCodingModule.InitializeSender() == -1)) { _engineStatisticsPtr->SetLastError( @@ -4720,16 +4718,6 @@ Channel::RegisterRxVadObserver(VoERxVadCallback &observer) "RegisterRxVadObserver() observer already enabled"); return -1; } - if (!_audioCodingModule.ReceiveVADStatus()) - { - if (_audioCodingModule.SetReceiveVADStatus(true) == -1) - { - _engineStatisticsPtr->SetLastError( - VE_AUDIO_CODING_MODULE_ERROR, kTraceError, - "RegisterRxVadObserver() failed to enable RX VAD"); - return -1; - } - } _rxVadObserverPtr = &observer; _RxVadDetection = true; return 0;