diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index 46980d3596..b88ad6189a 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -237,15 +237,6 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { // Sender // -// TODO(henrik.lundin): Remove this method; only used in tests. -int AudioCodingModuleImpl::ResetEncoder() { - CriticalSectionScoped lock(acm_crit_sect_); - if (!HaveValidEncoder("ResetEncoder")) { - return -1; - } - return 0; -} - // Can be called multiple times for Codec, CNG, RED. int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) { CriticalSectionScoped lock(acm_crit_sect_); @@ -279,31 +270,6 @@ int AudioCodingModuleImpl::SendFrequency() const { return codec_manager_.CurrentEncoder()->SampleRateHz(); } -// Get encode bitrate. -// Adaptive rate codecs return their current encode target rate, while other -// codecs return there longterm avarage or their fixed rate. -// TODO(henrik.lundin): Remove; not used. -int AudioCodingModuleImpl::SendBitrate() const { - FATAL() << "Deprecated"; - // This return statement is required to workaround a bug in VS2013 Update 4 - // when turning on the whole program optimizations. Without hit the linker - // will hang because it doesn't seem to find an exit path for this function. - // This is likely a bug in link.exe and would probably be fixed in VS2015. - return -1; - // CriticalSectionScoped lock(acm_crit_sect_); - // - // if (!codec_manager_.current_encoder()) { - // WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, - // "SendBitrate Failed, no codec is registered"); - // return -1; - // } - // - // WebRtcACMCodecParams encoder_param; - // codec_manager_.current_encoder()->EncoderParams(&encoder_param); - // - // return encoder_param.codec_inst.rate; -} - void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { CriticalSectionScoped lock(acm_crit_sect_); if (codec_manager_.CurrentEncoder()) { @@ -311,16 +277,6 @@ void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { } } -// Set available bandwidth, inform the encoder about the estimated bandwidth -// received from the remote party. -// TODO(henrik.lundin): Remove; not used. -int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) { - CriticalSectionScoped lock(acm_crit_sect_); - FATAL() << "Dead code?"; - return -1; -// return codecs_[current_send_codec_idx_]->SetEstimatedBandwidth(bw); -} - // Register a transport callback which will be called to deliver // the encoded buffers. int AudioCodingModuleImpl::RegisterTransportCallback( @@ -608,15 +564,6 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() { return 0; } -// TODO(turajs): If NetEq opens an API for reseting the state of decoders then -// implement this method. Otherwise it should be removed. I might be that by -// removing and registering a decoder we can achieve the effect of resetting. -// Reset the decoder state. -// TODO(henrik.lundin): Remove; only used in one test, and does nothing. -int AudioCodingModuleImpl::ResetDecoder() { - return 0; -} - // Get current receive frequency. int AudioCodingModuleImpl::ReceiveFrequency() const { WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, @@ -725,22 +672,6 @@ int AudioCodingModuleImpl::SetMaximumPlayoutDelay(int time_ms) { return receiver_.SetMaximumDelay(time_ms); } -// Estimate the Bandwidth based on the incoming stream, needed for one way -// audio where the RTCP send the BW estimate. -// This is also done in the RTP module. -int AudioCodingModuleImpl::DecoderEstimatedBandwidth() const { - // We can estimate far-end to near-end bandwidth if the iSAC are sent. Check - // if the last received packets were iSAC packet then retrieve the bandwidth. - int last_audio_codec_id = receiver_.last_audio_codec_id(); - if (last_audio_codec_id >= 0 && - STR_CASE_CMP("ISAC", ACMCodecDB::database_[last_audio_codec_id].plname)) { - CriticalSectionScoped lock(acm_crit_sect_); - FATAL() << "Dead code?"; -// return codecs_[last_audio_codec_id]->GetEstimatedBandwidth(); - } - return -1; -} - // Set playout mode for: voice, fax, streaming or off. int AudioCodingModuleImpl::SetPlayoutMode(AudioPlayoutMode mode) { receiver_.SetPlayoutMode(mode); @@ -813,38 +744,6 @@ int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload, return 0; } -int AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) { - CriticalSectionScoped lock(acm_crit_sect_); - - if (!HaveValidEncoder("ReplaceInternalDTXWithWebRtc")) { - WEBRTC_TRACE( - webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot replace codec internal DTX when no send codec is registered."); - return -1; - } - - FATAL() << "Dead code?"; -// int res = codecs_[current_send_codec_idx_]->ReplaceInternalDTX( -// use_webrtc_dtx); - // Check if VAD is turned on, or if there is any error. -// if (res == 1) { -// vad_enabled_ = true; -// } else if (res < 0) { -// WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, -// "Failed to set ReplaceInternalDTXWithWebRtc(%d)", -// use_webrtc_dtx); -// return res; -// } - - return 0; -} - -int AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc( - bool* uses_webrtc_dtx) { - *uses_webrtc_dtx = true; - return 0; -} - // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine. int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) { CriticalSectionScoped lock(acm_crit_sect_); @@ -869,23 +768,6 @@ int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) { return 0; } -// TODO(henrik.lundin): Remove? Only used in tests. -int AudioCodingModuleImpl::ConfigISACBandwidthEstimator( - int frame_size_ms, - int rate_bit_per_sec, - bool enforce_frame_size) { - CriticalSectionScoped lock(acm_crit_sect_); - - if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) { - return -1; - } - - FATAL() << "Dead code?"; - return -1; -// return codecs_[current_send_codec_idx_]->ConfigISACBandwidthEstimator( -// frame_size_ms, rate_bit_per_sec, enforce_frame_size); -} - int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) { CriticalSectionScoped lock(acm_crit_sect_); if (!HaveValidEncoder("SetOpusApplication")) { @@ -950,26 +832,6 @@ int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) { return receiver_.RemoveCodec(payload_type); } -// TODO(turajs): correct the type of |length_bytes| when it is corrected in -// GenericCodec. -int AudioCodingModuleImpl::REDPayloadISAC(int isac_rate, - int isac_bw_estimate, - uint8_t* payload, - int16_t* length_bytes) { - CriticalSectionScoped lock(acm_crit_sect_); - if (!HaveValidEncoder("EncodeData")) { - return -1; - } - FATAL() << "Dead code?"; - return -1; -// int status; -// status = codecs_[current_send_codec_idx_]->REDPayloadISAC(isac_rate, -// isac_bw_estimate, -// payload, -// length_bytes); -// return status; -} - int AudioCodingModuleImpl::SetInitialPlayoutDelay(int delay_ms) { { CriticalSectionScoped lock(acm_crit_sect_); diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h index c4518549ad..9c19dd2d09 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h @@ -31,7 +31,7 @@ namespace acm2 { class ACMDTMFDetection; -class AudioCodingModuleImpl : public AudioCodingModule { +class AudioCodingModuleImpl final : public AudioCodingModule { public: friend webrtc::AudioCodingImpl; @@ -42,9 +42,6 @@ class AudioCodingModuleImpl : public AudioCodingModule { // Sender // - // Reset send codec. - int ResetEncoder() override; - // Can be called multiple times for Codec, CNG, RED. int RegisterSendCodec(const CodecInst& send_codec) override; @@ -57,20 +54,11 @@ class AudioCodingModuleImpl : public AudioCodingModule { // Get current send frequency. int SendFrequency() const override; - // Get encode bit-rate. - // Adaptive rate codecs return their current encode target rate, while other - // codecs return there long-term average or their fixed rate. - int SendBitrate() const override; - // Sets the bitrate to the specified value in bits/sec. In case the codec does // not support the requested value it will choose an appropriate value // instead. void SetBitRate(int bitrate_bps) override; - // Set available bandwidth, inform the encoder about the - // estimated bandwidth received from the remote party. - int SetReceivedEstimatedBandwidth(int bw) override; - // Register a transport callback which will be // called to deliver the encoded buffers. int RegisterTransportCallback(AudioPacketizationCallback* transport) override; @@ -124,9 +112,6 @@ class AudioCodingModuleImpl : public AudioCodingModule { // Initialize receiver, resets codec database etc. int InitializeReceiver() override; - // Reset the decoder state. - int ResetDecoder() override; - // Get current receive frequency. int ReceiveFrequency() const override; @@ -180,11 +165,6 @@ class AudioCodingModuleImpl : public AudioCodingModule { // Get Dtmf playout status. bool DtmfPlayoutStatus() const override; - // Estimate the Bandwidth based on the incoming stream, needed - // for one way audio where the RTCP send the BW estimate. - // This is also done in the RTP module . - int DecoderEstimatedBandwidth() const override; - // Set playout mode voice, fax. int SetPlayoutMode(AudioPlayoutMode mode) override; @@ -204,26 +184,10 @@ class AudioCodingModuleImpl : public AudioCodingModule { int GetNetworkStatistics(NetworkStatistics* statistics) override; - // GET RED payload for iSAC. The method id called when 'this' ACM is - // the default ACM. - // TODO(henrik.lundin) Not used. Remove? - int REDPayloadISAC(int isac_rate, - int isac_bw_estimate, - uint8_t* payload, - int16_t* length_bytes); - - int ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) override; - - int IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx) override; - int SetISACMaxRate(int max_bit_per_sec) override; int SetISACMaxPayloadSize(int max_size_bytes) override; - int ConfigISACBandwidthEstimator(int frame_size_ms, - int rate_bit_per_sec, - bool enforce_frame_size = false) override; - int SetOpusApplication(OpusApplicationMode application) override; // If current send codec is Opus, informs it about the maximum playback rate diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h index 7357528132..f0d53dfe1a 100644 --- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h +++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h @@ -193,17 +193,6 @@ class AudioCodingModule { // Sender // - /////////////////////////////////////////////////////////////////////////// - // int32_t ResetEncoder() - // This API resets the states of encoder. All the encoder settings, such as - // send-codec or VAD/DTX, will be preserved. - // - // Return value: - // -1 if failed to initialize, - // 0 if succeeded. - // - virtual int32_t ResetEncoder() = 0; - /////////////////////////////////////////////////////////////////////////// // int32_t RegisterSendCodec() // Registers a codec, specified by |send_codec|, as sending codec. @@ -261,39 +250,11 @@ class AudioCodingModule { // virtual int32_t SendFrequency() const = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t Bitrate() - // Get encoding bit-rate in bits per second. - // - // Return value: - // positive; encoding rate in bits/sec, - // -1 if an error is happened. - // - virtual int32_t SendBitrate() const = 0; - /////////////////////////////////////////////////////////////////////////// // Sets the bitrate to the specified value in bits/sec. If the value is not // supported by the codec, it will choose another appropriate value. virtual void SetBitRate(int bitrate_bps) = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t SetReceivedEstimatedBandwidth() - // Set available bandwidth [bits/sec] of the up-link channel. - // This information is used for traffic shaping, and is currently only - // supported if iSAC is the send codec. - // - // Input: - // -bw : bandwidth in bits/sec estimated for - // up-link. - // Return value - // -1 if error occurred in setting the bandwidth, - // 0 bandwidth is set successfully. - // - // TODO(henrik.lundin) Unused. Remove? - virtual int32_t SetReceivedEstimatedBandwidth( - const int32_t bw) = 0; - - /////////////////////////////////////////////////////////////////////////// // int32_t RegisterTransportCallback() // Register a transport callback which will be called to deliver // the encoded buffers whenever Process() is called and a @@ -465,39 +426,6 @@ class AudioCodingModule { virtual int32_t VAD(bool* dtx_enabled, bool* vad_enabled, ACMVADMode* vad_mode) const = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t ReplaceInternalDTXWithWebRtc() - // Used to replace codec internal DTX scheme with WebRtc. - // - // Input: - // -use_webrtc_dtx : if false (default) the codec built-in DTX/VAD - // scheme is used, otherwise the internal DTX is - // replaced with WebRtc DTX/VAD. - // - // Return value: - // -1 if failed to replace codec internal DTX with WebRtc, - // 0 if succeeded. - // - virtual int32_t ReplaceInternalDTXWithWebRtc( - const bool use_webrtc_dtx = false) = 0; - - /////////////////////////////////////////////////////////////////////////// - // int32_t IsInternalDTXReplacedWithWebRtc() - // Get status if the codec internal DTX is replaced with WebRtc DTX. - // This should always be true if codec does not have an internal DTX. - // - // Output: - // -uses_webrtc_dtx : is set to true if the codec internal DTX is - // replaced with WebRtc DTX/VAD, otherwise it is set - // to false. - // - // Return value: - // -1 if failed to determine if codec internal DTX is replaced with WebRtc, - // 0 if succeeded. - // - virtual int32_t IsInternalDTXReplacedWithWebRtc( - bool* uses_webrtc_dtx) = 0; - /////////////////////////////////////////////////////////////////////////// // int32_t RegisterVADCallback() // Call this method to register a callback function which is called @@ -533,17 +461,6 @@ class AudioCodingModule { // virtual int32_t InitializeReceiver() = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t ResetDecoder() - // This API resets the states of decoders. ACM will not lose any - // decoder-related settings, such as registered codecs. - // - // Return value: - // -1 if failed to initialize, - // 0 if succeeded. - // - virtual int32_t ResetDecoder() = 0; - /////////////////////////////////////////////////////////////////////////// // int32_t ReceiveFrequency() // Get sampling frequency of the last received payload. @@ -738,19 +655,6 @@ class AudioCodingModule { // TODO(tlegrand): Change function to return the timestamp. virtual int32_t PlayoutTimestamp(uint32_t* timestamp) = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t DecoderEstimatedBandwidth() - // Get the estimate of the Bandwidth, in bits/second, based on the incoming - // stream. This API is useful in one-way communication scenarios, where - // the bandwidth information is sent in an out-of-band fashion. - // Currently only supported if iSAC is registered as a receiver. - // - // Return value: - // >0 bandwidth in bits/second. - // -1 if failed to get a bandwidth estimate. - // - virtual int32_t DecoderEstimatedBandwidth() const = 0; - /////////////////////////////////////////////////////////////////////////// // int32_t SetPlayoutMode() // Call this API to set the playout mode. Playout mode could be optimized @@ -849,35 +753,6 @@ class AudioCodingModule { // virtual int SetISACMaxPayloadSize(int max_payload_len_bytes) = 0; - /////////////////////////////////////////////////////////////////////////// - // int32_t ConfigISACBandwidthEstimator() - // Call this function to configure the bandwidth estimator of ISAC. - // During the adaptation of bit-rate, iSAC automatically adjusts the - // frame-size (either 30 or 60 ms) to save on RTP header. The initial - // frame-size can be specified by the first argument. The configuration also - // regards the initial estimate of bandwidths. The estimator starts from - // this point and converges to the actual bottleneck. This is given by the - // second parameter. Furthermore, it is also possible to control the - // adaptation of frame-size. This is specified by the last parameter. - // - // Input: - // -init_frame_size_ms : initial frame-size in milliseconds. For iSAC-wb - // 30 ms and 60 ms (default) are acceptable values, - // and for iSAC-swb 30 ms is the only acceptable - // value. Zero indicates default value. - // -init_rate_bps : initial estimate of the bandwidth. Values - // between 10000 and 58000 are acceptable. - // -enforce_srame_size : if true, the frame-size will not be adapted. - // - // Return value: - // -1 if failed to configure the bandwidth estimator, - // 0 if the configuration was successfully applied. - // - virtual int32_t ConfigISACBandwidthEstimator( - int init_frame_size_ms, - int init_rate_bps, - bool enforce_frame_size = false) = 0; - /////////////////////////////////////////////////////////////////////////// // int SetOpusApplication() // Sets the intended application if current send codec is Opus. Opus uses this diff --git a/webrtc/modules/audio_coding/main/test/APITest.cc b/webrtc/modules/audio_coding/main/test/APITest.cc index 1cdf6c753a..73f2d2adc7 100644 --- a/webrtc/modules/audio_coding/main/test/APITest.cc +++ b/webrtc/modules/audio_coding/main/test/APITest.cc @@ -1129,7 +1129,6 @@ void APITest::ChangeCodec(char side) { myChannel = _channel_B2A; } - myACM->ResetEncoder(); Wait(100); // Register the next codec diff --git a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc index d18479993c..0e42b9f8ae 100644 --- a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc +++ b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc @@ -137,7 +137,6 @@ void TestVadDtx::Run(std::string in_filename, int frequency, int channels, TestWebRtcVadDtx::TestWebRtcVadDtx() : vad_enabled_(false), dtx_enabled_(false), - use_webrtc_dtx_(false), output_file_num_(0) { } @@ -191,7 +190,7 @@ void TestWebRtcVadDtx::RunTestCases() { // Set the expectation and run the test. void TestWebRtcVadDtx::Test(bool new_outfile) { - int expects[] = {-1, 1, use_webrtc_dtx_, 0, 0}; + int expects[] = {-1, 1, dtx_enabled_, 0, 0}; if (new_outfile) { output_file_num_++; } @@ -219,17 +218,10 @@ void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad, EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected. - bool replaced = false; - acm_send_->IsInternalDTXReplacedWithWebRtc(&replaced); - - use_webrtc_dtx_ = dtx_enabled_ && replaced; - - if (use_webrtc_dtx_) { + if (dtx_enabled_) { EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD. - } - - if (!dtx_enabled_ || !use_webrtc_dtx_) { - // Using no DTX or codec Internal DTX should not affect setting of VAD. + } else { + // Using no DTX should not affect setting of VAD. EXPECT_EQ(enable_vad, vad_enabled_); } } diff --git a/webrtc/modules/audio_coding/main/test/TestVADDTX.h b/webrtc/modules/audio_coding/main/test/TestVADDTX.h index b664a9b4d4..8ef4228bd7 100644 --- a/webrtc/modules/audio_coding/main/test/TestVADDTX.h +++ b/webrtc/modules/audio_coding/main/test/TestVADDTX.h @@ -88,7 +88,6 @@ class TestWebRtcVadDtx final : public TestVadDtx { bool vad_enabled_; bool dtx_enabled_; - bool use_webrtc_dtx_; int output_file_num_; }; diff --git a/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc b/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc index 1014fc9d0a..860e7da52b 100644 --- a/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc +++ b/webrtc/modules/audio_coding/main/test/TwoWayCommunication.cc @@ -279,8 +279,8 @@ void TwoWayCommunication::Perform() { // In the following loop we tests that the code can handle misuse of the APIs. // In the middle of a session with data flowing between two sides, called A - // and B, APIs will be called, like ResetEncoder(), and the code should - // continue to run, and be able to recover. + // and B, APIs will be called, and the code should continue to run, and be + // able to recover. while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) { msecPassed += 10; EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0); @@ -305,21 +305,14 @@ void TwoWayCommunication::Perform() { msecPassed = 0; secPassed++; } - // Call RestEncoder for ACM on side A, and InitializeSender for ACM on - // side B. - if (((secPassed % 5) == 4) && (msecPassed == 0)) { - EXPECT_EQ(0, _acmA->ResetEncoder()); - } // Re-register send codec on side B. if (((secPassed % 5) == 4) && (msecPassed >= 990)) { EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B)); EXPECT_EQ(0, _acmB->SendCodec(&dummy)); } - // Reset decoder on side B, and initialize receiver on side A. - if (((secPassed % 7) == 6) && (msecPassed == 0)) { - EXPECT_EQ(0, _acmB->ResetDecoder()); + // Initialize receiver on side A. + if (((secPassed % 7) == 6) && (msecPassed == 0)) EXPECT_EQ(0, _acmA->InitializeReceiver()); - } // Re-register codec on side A. if (((secPassed % 7) == 6) && (msecPassed >= 990)) { EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B)); diff --git a/webrtc/modules/audio_coding/main/test/iSACTest.cc b/webrtc/modules/audio_coding/main/test/iSACTest.cc index 2469d1744d..cc41e3bc1b 100644 --- a/webrtc/modules/audio_coding/main/test/iSACTest.cc +++ b/webrtc/modules/audio_coding/main/test/iSACTest.cc @@ -75,13 +75,6 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm, // Set max payload size. EXPECT_EQ(0, acm->SetISACMaxPayloadSize(isacConfig.maxPayloadSizeByte)); } - if ((isacConfig.initFrameSizeInMsec != 0) - || (isacConfig.initRateBitPerSec != 0)) { - EXPECT_EQ(0, acm->ConfigISACBandwidthEstimator( - static_cast(isacConfig.initFrameSizeInMsec), - static_cast(isacConfig.initRateBitPerSec), - isacConfig.enforceFrameSize)); - } return 0; } @@ -215,8 +208,6 @@ void ISACTest::Perform() { testNr++; EncodeDecode(testNr, wbISACConfig, swbISACConfig); - _acmA->ResetEncoder(); - _acmB->ResetEncoder(); SetISACConfigDefault(wbISACConfig); SetISACConfigDefault(swbISACConfig);