From 524eb480811f140d466932746e63576ef0a04067 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Wed, 30 Nov 2011 16:21:22 +0000 Subject: [PATCH] Removing deprecated NetEQ APIs Removing WebRtcNetEQ_GetPreferredBufferSize and WebRtcNetEQ_GetCurrentDelay and all dependent APIs. Review URL: http://webrtc-codereview.appspot.com/289006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1063 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/interface/audio_coding_module.h | 29 ------ .../audio_coding/main/source/acm_neteq.cc | 38 ------- .../audio_coding/main/source/acm_neteq.h | 28 ------ .../main/source/audio_coding_module_impl.cc | 20 ---- .../main/source/audio_coding_module_impl.h | 6 -- .../audio_coding/main/test/APITest.cpp | 9 -- .../neteq/interface/webrtc_neteq_internal.h | 10 -- src/modules/audio_coding/neteq/webrtc_neteq.c | 98 ++++--------------- .../main/interface/voe_neteq_stats.h | 5 - src/voice_engine/main/source/channel.cc | 9 -- src/voice_engine/main/source/channel.h | 1 - .../main/source/voe_neteq_stats_impl.cc | 27 ----- .../main/source/voe_neteq_stats_impl.h | 3 - .../main/test/auto_test/voe_standard_test.cc | 4 - 14 files changed, 21 insertions(+), 266 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 9332595898..093dcdbf61 100644 --- a/src/modules/audio_coding/main/interface/audio_coding_module.h +++ b/src/modules/audio_coding/main/interface/audio_coding_module.h @@ -611,19 +611,6 @@ class AudioCodingModule: public Module { // virtual WebRtc_Word32 SetMinimumPlayoutDelay(const WebRtc_Word32 timeMs) = 0; - /////////////////////////////////////////////////////////////////////////// - // WebRtc_Word32 Delay() - // Get the current playout delay. - // - // Output: - // - delayInMs : delay in millisecond - // - // Return value: - // -1 if failed to get the delay, - // 0 if succeeded to get the delay. - // - virtual WebRtc_Word32 Delay(WebRtc_UWord16& delayMs) const = 0; - /////////////////////////////////////////////////////////////////////////// // WebRtc_Word32 RegisterIncomingMessagesCallback() // Used by the module to deliver messages to the codec module/application @@ -913,22 +900,6 @@ class AudioCodingModule: public Module { // virtual WebRtc_Word32 NetworkStatistics( ACMNetworkStatistics& networkStatistics) const = 0; - - /////////////////////////////////////////////////////////////////////////// - // WebRtc_Word32 PreferredBufferSize() - // Get the optimal buffer size calculated for the current network - // conditions. - // - // Output: - // -prefBuffSize : the optimal size of the jitter buffer in - // milliseconds. - // - // Return value: - // -1 if the preferred buffer size could not be computed, - // 0 if a valid buffer is computed successfully. - // - virtual WebRtc_Word32 PreferredBufferSize( - WebRtc_UWord16& prefBufSize) const = 0; }; } // namespace webrtc diff --git a/src/modules/audio_coding/main/source/acm_neteq.cc b/src/modules/audio_coding/main/source/acm_neteq.cc index 0342388d03..c2fbc6fb27 100644 --- a/src/modules/audio_coding/main/source/acm_neteq.cc +++ b/src/modules/audio_coding/main/source/acm_neteq.cc @@ -470,21 +470,6 @@ ACMNetEQ::NetworkStatistics( } } - -WebRtc_Word32 -ACMNetEQ::PreferredBufferSize( - WebRtc_UWord16* prefBufSize) const -{ - CriticalSectionScoped lock(*_netEqCritSect); - WebRtc_Word32 ok = WebRtcNetEQ_GetPreferredBufferSize(_inst[0], prefBufSize); - if((*prefBufSize == 0) || (*prefBufSize == 0xFFFF)) - { - ok = -1; - LogError("getPreferredBufferSize", 0); - } - return ok; -} - WebRtc_Word32 ACMNetEQ::RecIn( const WebRtc_Word8* incomingPayload, @@ -1028,29 +1013,6 @@ ACMNetEQ::RemoveCodec( return 0; } -WebRtc_Word16 -ACMNetEQ::Delay( - WebRtc_UWord16& currentDelayInMs) const -{ - CriticalSectionScoped lock(*_netEqCritSect); - if(!_isInitialized[0]) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, - "Delay: NetEq is not initialized."); - return -1; - } - if(WebRtcNetEQ_GetCurrentDelay(_inst[0], ¤tDelayInMs) < 0) - { - LogError("GetCurrentDelay", 0); - return -1; - } - else - { - return 0; - } -} - - WebRtc_Word16 ACMNetEQ::SetBackgroundNoiseMode( const ACMBackgroundNoiseMode mode) diff --git a/src/modules/audio_coding/main/source/acm_neteq.h b/src/modules/audio_coding/main/source/acm_neteq.h index 61046f14d2..171051d46f 100644 --- a/src/modules/audio_coding/main/source/acm_neteq.h +++ b/src/modules/audio_coding/main/source/acm_neteq.h @@ -213,20 +213,6 @@ public: WebRtc_Word32 NetworkStatistics( ACMNetworkStatistics* statistics) const; - // - // PreferredBufferSize() - // Get the currently preferred buffer size from NetEQ. - // - // Output: - // - prefBufSize : The optimal buffer size for the current network - // conditions. - // - // Return value : 0 if ok. - // <0 if NetEQ returned an error. - // - WebRtc_Word32 PreferredBufferSize( - WebRtc_UWord16* prefBufSize) const; - // // VADMode() // Get the current VAD Mode. @@ -283,20 +269,6 @@ public: bool isStereo = false); - // - // Delay() - // Get the length of the current audio buffer in milliseconds. That is - // approximately the playout delay, which can be used for lip-synch. - // - // Output: - // - currentDelayInMs : delay in audio buffer given in milliseconds - // - // return value : 0 if ok - // -1 if an error occurred. - // - WebRtc_Word16 Delay( - WebRtc_UWord16& currentDelayInMs) const; - // // SetBackgroundNoiseMode() // Set the mode of the background noise. 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 3709481319..654d337030 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 @@ -1815,17 +1815,6 @@ AudioCodingModuleImpl::SetMinimumPlayoutDelay( return _netEq.SetExtraDelay(timeMs); } -// current play out delay -WebRtc_Word32 -AudioCodingModuleImpl::Delay( - WebRtc_UWord16& delayMs) const -{ - // NetEQ will get an API for this later. - WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, _id, - "Delay()"); - return _netEq.Delay(delayMs); -} - // Get Dtmf playout status bool AudioCodingModuleImpl::DtmfPlayoutStatus() const @@ -2135,15 +2124,6 @@ AudioCodingModuleImpl::NetworkStatistics( return status; } -WebRtc_Word32 -AudioCodingModuleImpl::PreferredBufferSize( - WebRtc_UWord16& prefbufsize) const -{ - WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, _id, - "PreferedBufferSize()"); - return _netEq.PreferredBufferSize(&prefbufsize); -} - void AudioCodingModuleImpl::DestructEncoderInst( void* ptrInst) 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 707586fafe..c6eeb9c257 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 @@ -203,9 +203,6 @@ public: WebRtc_Word32 SetMinimumPlayoutDelay( const WebRtc_Word32 timeMs); - // current play out delay - WebRtc_Word32 Delay(WebRtc_UWord16& delayMs) const; - // configure Dtmf playout status i.e on/off playout the incoming outband Dtmf tone WebRtc_Word32 SetDtmfPlayoutStatus( const bool enable); @@ -243,9 +240,6 @@ public: WebRtc_Word32 NetworkStatistics( ACMNetworkStatistics& statistics) const; - WebRtc_Word32 PreferredBufferSize( - WebRtc_UWord16& prefbufsize) const; - void DestructEncoderInst(void* ptrInst); WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff); diff --git a/src/modules/audio_coding/main/test/APITest.cpp b/src/modules/audio_coding/main/test/APITest.cpp index 06f0d78f0f..e6d2f992d0 100644 --- a/src/modules/audio_coding/main/test/APITest.cpp +++ b/src/modules/audio_coding/main/test/APITest.cpp @@ -884,16 +884,12 @@ APITest::TestDelay(char side) WebRtc_UWord32 inTimestamp = 0; WebRtc_UWord32 outTimestamp = 0; double estimDelay = 0; - WebRtc_UWord16 delay = 0; double averageEstimDelay = 0; double averageDelay = 0; CircularBuffer estimDelayCB(100); - CircularBuffer delayCB(100); estimDelayCB.SetArithMean(true); - delayCB.SetArithMean(true); - if(side == 'A') { @@ -914,7 +910,6 @@ APITest::TestDelay(char side) inTimestamp = myChannel->LastInTimestamp(); CHECK_ERROR_MT(myACM->PlayoutTimestamp(outTimestamp)); - CHECK_ERROR_MT(myACM->Delay(delay)); if(!_randomTest) { @@ -938,10 +933,6 @@ APITest::TestDelay(char side) //printf("\n %6.1f \n", estimDelay); //std::cout << " " << std::flush; - CHECK_ERROR_MT(myACM->Delay(delay)); - delayCB.Update(delay); - delayCB.ArithMean(averageDelay); - if(_verbose) { fprintf(stdout, "\rExpected: %4d, retreived: %6.1f, measured: %6.1f", diff --git a/src/modules/audio_coding/neteq/interface/webrtc_neteq_internal.h b/src/modules/audio_coding/neteq/interface/webrtc_neteq_internal.h index affcd61a96..1f87e66284 100644 --- a/src/modules/audio_coding/neteq/interface/webrtc_neteq_internal.h +++ b/src/modules/audio_coding/neteq/interface/webrtc_neteq_internal.h @@ -110,16 +110,6 @@ typedef struct */ int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics *stats); -/* - * Get the optimal buffer size calculated for the current network conditions. - */ -int WebRtcNetEQ_GetPreferredBufferSize(void *inst, WebRtc_UWord16 *preferredBufferSize); - -/* - * Get the current buffer size in ms. Return value is 0 if ok, -1 if error. - */ -int WebRtcNetEQ_GetCurrentDelay(const void *inst, WebRtc_UWord16 *currentDelayMs); - /***********************************************/ /* Functions for post-decode VAD functionality */ /***********************************************/ diff --git a/src/modules/audio_coding/neteq/webrtc_neteq.c b/src/modules/audio_coding/neteq/webrtc_neteq.c index 7e51d1626f..e93154ed1d 100644 --- a/src/modules/audio_coding/neteq/webrtc_neteq.c +++ b/src/modules/audio_coding/neteq/webrtc_neteq.c @@ -1188,9 +1188,28 @@ int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics * /* Get buffer size */ /*******************/ - if (WebRtcNetEQ_GetCurrentDelay((void *) inst, &(stats->currentBufferSize)) != 0) + if (NetEqMainInst->MCUinst.fs != 0) { - return (-1); + WebRtc_Word32 temp32; + /* Query packet buffer for number of samples. */ + temp32 = WebRtcNetEQ_PacketBufferGetSize( + &NetEqMainInst->MCUinst.PacketBuffer_inst); + + /* Divide by sample rate. + * Calculate temp32 * 1000 / fs to get result in ms. */ + stats->currentBufferSize = (WebRtc_UWord16) + WebRtcSpl_DivU32U16(temp32 * 1000, NetEqMainInst->MCUinst.fs); + + /* Add number of samples yet to play in sync buffer. */ + temp32 = (WebRtc_Word32) (NetEqMainInst->DSPinst.endPosition - + NetEqMainInst->DSPinst.curPosition); + stats->currentBufferSize += (WebRtc_UWord16) + WebRtcSpl_DivU32U16(temp32 * 1000, NetEqMainInst->MCUinst.fs); + } + else + { + /* Sample rate not initialized. */ + stats->currentBufferSize = 0; } /***************************/ @@ -1512,81 +1531,6 @@ int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics * return (0); } -/* Get the optimal buffer size calculated for the current network conditions. */ -int WebRtcNetEQ_GetPreferredBufferSize(void *inst, WebRtc_UWord16 *preferredBufferSize) -{ - - MainInst_t *NetEqMainInst = (MainInst_t*) inst; - - /***************************/ - /* Get optimal buffer size */ - /***************************/ - - if (NetEqMainInst->MCUinst.fs != 0 && NetEqMainInst->MCUinst.fs <= WEBRTC_SPL_WORD16_MAX) - { - /* preferredBufferSize = Bopt * packSizeSamples / (fs/1000) */ - *preferredBufferSize - = (WebRtc_UWord16) WEBRTC_SPL_MUL_16_16( - (WebRtc_Word16) ((NetEqMainInst->MCUinst.BufferStat_inst.Automode_inst.optBufLevel) >> 8), /* optimal buffer level in packets shifted to Q0 */ - WebRtcSpl_DivW32W16ResW16( - (WebRtc_Word32) NetEqMainInst->MCUinst.BufferStat_inst.Automode_inst.packetSpeechLenSamp, /* samples per packet */ - WebRtcSpl_DivW32W16ResW16( (WebRtc_Word32) NetEqMainInst->MCUinst.fs, (WebRtc_Word16) 1000 ) /* samples per ms */ - ) ); - - /* add extra delay */ - if (NetEqMainInst->MCUinst.BufferStat_inst.Automode_inst.extraDelayMs > 0) - { - *preferredBufferSize - += NetEqMainInst->MCUinst.BufferStat_inst.Automode_inst.extraDelayMs; - } - } - else - { - /* sample rate not initialized */ - *preferredBufferSize = 0; - } - - return (0); - -} - -/* Get the current buffer size in ms. Return value is 0 if ok, -1 if error. */ -int WebRtcNetEQ_GetCurrentDelay(const void *inst, WebRtc_UWord16 *currentDelayMs) -{ - WebRtc_Word32 temp32; - const MainInst_t *NetEqMainInst = (const MainInst_t*) inst; - - /* Instance sanity */ - if (NetEqMainInst == NULL) return (-1); - - /*******************/ - /* Get buffer size */ - /*******************/ - - if (NetEqMainInst->MCUinst.fs != 0 && NetEqMainInst->MCUinst.fs <= WEBRTC_SPL_WORD16_MAX) - { - /* query packet buffer for number of samples */ - temp32 = WebRtcNetEQ_PacketBufferGetSize(&NetEqMainInst->MCUinst.PacketBuffer_inst); - - /* divide by sample rate */ - *currentDelayMs = WebRtcSpl_DivW32W16ResW16(temp32 * 1000, /* multiply by 1000 to get ms */ - (WebRtc_Word16) NetEqMainInst->MCUinst.fs); /* divide by fs in samples per second */ - - /* add number of samples yet to play in sync buffer */ - temp32 = (WebRtc_Word32) (NetEqMainInst->DSPinst.endPosition - - NetEqMainInst->DSPinst.curPosition); - *currentDelayMs += WebRtcSpl_DivW32W16ResW16(temp32 * 1000, /* multiply by 1000 to get ms */ - (WebRtc_Word16) NetEqMainInst->MCUinst.fs); /* divide by fs in samples per second */ - } - else - { - /* sample rate not initialized */ - *currentDelayMs = 0; - } - - return 0; -} - /**************************************************************************** * WebRtcNetEQ_SetVADInstance(...) * diff --git a/src/voice_engine/main/interface/voe_neteq_stats.h b/src/voice_engine/main/interface/voe_neteq_stats.h index 12526f08ed..4940bed592 100644 --- a/src/voice_engine/main/interface/voe_neteq_stats.h +++ b/src/voice_engine/main/interface/voe_neteq_stats.h @@ -35,11 +35,6 @@ public: // The statistics are reset after the query. virtual int GetNetworkStatistics(int channel, NetworkStatistics& stats) = 0; - // Get the optimal buffer size calculated for the current network - // conditions. - virtual int GetPreferredBufferSize( - int channel, unsigned short& preferredBufferSize) = 0; - protected: VoENetEqStats() {} virtual ~VoENetEqStats() {} diff --git a/src/voice_engine/main/source/channel.cc b/src/voice_engine/main/source/channel.cc index 940414e26c..a4b65eef6e 100644 --- a/src/voice_engine/main/source/channel.cc +++ b/src/voice_engine/main/source/channel.cc @@ -6134,15 +6134,6 @@ Channel::GetNetworkStatistics(NetworkStatistics& stats) (ACMNetworkStatistics &)stats); } -int -Channel::GetPreferredBufferSize(unsigned short& preferredBufferSize) -{ - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::GetPreferredBufferSize()"); - return _audioCodingModule.PreferredBufferSize( - (WebRtc_UWord16 &)preferredBufferSize); -} - int Channel::GetDelayEstimate(int& delayMs) const { diff --git a/src/voice_engine/main/source/channel.h b/src/voice_engine/main/source/channel.h index 25e410d963..e18ba77bdb 100644 --- a/src/voice_engine/main/source/channel.h +++ b/src/voice_engine/main/source/channel.h @@ -243,7 +243,6 @@ public: // VoENetEqStats int GetNetworkStatistics(NetworkStatistics& stats); - int GetPreferredBufferSize(unsigned short& preferredBufferSize); // VoEVideoSync int GetDelayEstimate(int& delayMs) const; diff --git a/src/voice_engine/main/source/voe_neteq_stats_impl.cc b/src/voice_engine/main/source/voe_neteq_stats_impl.cc index f77a73340f..a6c699a0ad 100644 --- a/src/voice_engine/main/source/voe_neteq_stats_impl.cc +++ b/src/voice_engine/main/source/voe_neteq_stats_impl.cc @@ -95,33 +95,6 @@ int VoENetEqStatsImpl::GetNetworkStatistics(int channel, return channelPtr->GetNetworkStatistics(stats); } -int VoENetEqStatsImpl::GetPreferredBufferSize( - int channel, - unsigned short& preferredBufferSize) -{ - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId,-1), - "GetPreferredBufferSize(channel=%i, ?)", channel); - ANDROID_NOT_SUPPORTED(); - IPHONE_NOT_SUPPORTED(); - - if (!_engineStatistics.Initialized()) - { - _engineStatistics.SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ScopedChannel sc(_channelManager, channel); - voe::Channel* channelPtr = sc.ChannelPtr(); - if (channelPtr == NULL) - { - _engineStatistics.SetLastError( - VE_CHANNEL_NOT_VALID, kTraceError, - "GetPreferredBufferSize() failed to locate channel"); - return -1; - } - - return channelPtr->GetPreferredBufferSize(preferredBufferSize); -} - #endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API } // namespace webrtc diff --git a/src/voice_engine/main/source/voe_neteq_stats_impl.h b/src/voice_engine/main/source/voe_neteq_stats_impl.h index 5bbcded392..47dd2f693e 100644 --- a/src/voice_engine/main/source/voe_neteq_stats_impl.h +++ b/src/voice_engine/main/source/voe_neteq_stats_impl.h @@ -28,9 +28,6 @@ public: virtual int GetNetworkStatistics(int channel, NetworkStatistics& stats); - virtual int GetPreferredBufferSize(int channel, - unsigned short& preferredBufferSize); - protected: VoENetEqStatsImpl(); virtual ~VoENetEqStatsImpl(); diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.cc b/src/voice_engine/main/test/auto_test/voe_standard_test.cc index d16757c127..f68bcaa510 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.cc @@ -3594,10 +3594,6 @@ int VoETestManager::DoStandardTest() nStats.currentPreemptiveRate); TEST_LOG(" preferredBufferSize = %hu \n", nStats.preferredBufferSize); - - unsigned short preferredBufferSize; - TEST_MUSTPASS(neteqst->GetPreferredBufferSize(0, preferredBufferSize)); - TEST_MUSTPASS(preferredBufferSize != nStats.preferredBufferSize); #else TEST_LOG("Skipping NetEQ statistics tests - " "WEBRTC_VOICE_ENGINE_NETEQ_STATS_API not defined \n");