Remove no-op and unused methods from AudioCodingModule
This CL removes the following no-op and/or unused methods from
AudioCodingModule and AudioCodingModuleImpl:
ConfigISACBandwidthEstimator
DecoderEstimatedBandwidth
IsInternalDTXReplacedWithWebRtc
REDPayloadISAC
ReplaceInternalDTXWithWebRtc
ResetDecoder
ResetEncoder
SendBitrate
SetReceivedEstimatedBandwidth
R=henrik.lundin@webrtc.org
Review URL: https://codereview.webrtc.org/1308283003 .
Cr-Original-Commit-Position: refs/heads/master@{#9773}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: dd00f113a95e589c0e3386d1a3ad87348e28ab2d
diff --git a/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index 46980d3..b88ad61 100644
--- a/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -237,15 +237,6 @@
// 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 @@
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 @@
}
}
-// 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 @@
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 @@
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 @@
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 @@
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 @@
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/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/modules/audio_coding/main/acm2/audio_coding_module_impl.h
index c451854..9c19dd2 100644
--- a/modules/audio_coding/main/acm2/audio_coding_module_impl.h
+++ b/modules/audio_coding/main/acm2/audio_coding_module_impl.h
@@ -31,7 +31,7 @@
class ACMDTMFDetection;
-class AudioCodingModuleImpl : public AudioCodingModule {
+class AudioCodingModuleImpl final : public AudioCodingModule {
public:
friend webrtc::AudioCodingImpl;
@@ -42,9 +42,6 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
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/modules/audio_coding/main/interface/audio_coding_module.h b/modules/audio_coding/main/interface/audio_coding_module.h
index 7357528..f0d53df 100644
--- a/modules/audio_coding/main/interface/audio_coding_module.h
+++ b/modules/audio_coding/main/interface/audio_coding_module.h
@@ -194,17 +194,6 @@
//
///////////////////////////////////////////////////////////////////////////
- // 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.
// This API can be called multiple of times to register Codec. The last codec
@@ -262,38 +251,10 @@
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
@@ -466,39 +427,6 @@
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
// any time that ACM encounters an empty frame. That is a frame which is
@@ -534,17 +462,6 @@
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.
//
@@ -739,19 +656,6 @@
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
// for i) voice, ii) FAX or iii) streaming. In Voice mode, NetEQ is
@@ -850,35 +754,6 @@
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
// to optimize the encoding for applications like VOIP and music. Currently,
diff --git a/modules/audio_coding/main/test/APITest.cc b/modules/audio_coding/main/test/APITest.cc
index 1cdf6c7..73f2d2a 100644
--- a/modules/audio_coding/main/test/APITest.cc
+++ b/modules/audio_coding/main/test/APITest.cc
@@ -1129,7 +1129,6 @@
myChannel = _channel_B2A;
}
- myACM->ResetEncoder();
Wait(100);
// Register the next codec
diff --git a/modules/audio_coding/main/test/TestVADDTX.cc b/modules/audio_coding/main/test/TestVADDTX.cc
index d184799..0e42b9f 100644
--- a/modules/audio_coding/main/test/TestVADDTX.cc
+++ b/modules/audio_coding/main/test/TestVADDTX.cc
@@ -137,7 +137,6 @@
TestWebRtcVadDtx::TestWebRtcVadDtx()
: vad_enabled_(false),
dtx_enabled_(false),
- use_webrtc_dtx_(false),
output_file_num_(0) {
}
@@ -191,7 +190,7 @@
// 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 @@
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/modules/audio_coding/main/test/TestVADDTX.h b/modules/audio_coding/main/test/TestVADDTX.h
index b664a9b..8ef4228 100644
--- a/modules/audio_coding/main/test/TestVADDTX.h
+++ b/modules/audio_coding/main/test/TestVADDTX.h
@@ -88,7 +88,6 @@
bool vad_enabled_;
bool dtx_enabled_;
- bool use_webrtc_dtx_;
int output_file_num_;
};
diff --git a/modules/audio_coding/main/test/TwoWayCommunication.cc b/modules/audio_coding/main/test/TwoWayCommunication.cc
index 1014fc9..860e7da 100644
--- a/modules/audio_coding/main/test/TwoWayCommunication.cc
+++ b/modules/audio_coding/main/test/TwoWayCommunication.cc
@@ -279,8 +279,8 @@
// 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 @@
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/modules/audio_coding/main/test/iSACTest.cc b/modules/audio_coding/main/test/iSACTest.cc
index 2469d17..cc41e3b 100644
--- a/modules/audio_coding/main/test/iSACTest.cc
+++ b/modules/audio_coding/main/test/iSACTest.cc
@@ -75,13 +75,6 @@
// 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<uint8_t>(isacConfig.initFrameSizeInMsec),
- static_cast<uint16_t>(isacConfig.initRateBitPerSec),
- isacConfig.enforceFrameSize));
- }
return 0;
}
@@ -215,8 +208,6 @@
testNr++;
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
- _acmA->ResetEncoder();
- _acmB->ResetEncoder();
SetISACConfigDefault(wbISACConfig);
SetISACConfigDefault(swbISACConfig);