Delete obsolete method AudioCodingModule::SetBitRate

Bug: None
Change-Id: I2291f7b4b46d269592eacad67a126010b750fac2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148079
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28784}
This commit is contained in:
Niels Möller 2019-08-06 15:52:10 +02:00 committed by Commit Bot
parent e71edc5e0d
commit c653172e74
3 changed files with 0 additions and 142 deletions

View file

@ -45,11 +45,6 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
void ModifyEncoder(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> void ModifyEncoder(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)>
modifier) override; modifier) 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;
// Register a transport callback which will be // Register a transport callback which will be
// called to deliver the encoded buffers. // called to deliver the encoded buffers.
int RegisterTransportCallback(AudioPacketizationCallback* transport) override; int RegisterTransportCallback(AudioPacketizationCallback* transport) override;
@ -407,13 +402,6 @@ void AudioCodingModuleImpl::ModifyEncoder(
modifier(&encoder_stack_); modifier(&encoder_stack_);
} }
void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
rtc::CritScope lock(&acm_crit_sect_);
if (encoder_stack_) {
encoder_stack_->OnReceivedUplinkBandwidth(bitrate_bps, absl::nullopt);
}
}
// Register a transport callback which will be called to deliver // Register a transport callback which will be called to deliver
// the encoded buffers. // the encoded buffers.
int AudioCodingModuleImpl::RegisterTransportCallback( int AudioCodingModuleImpl::RegisterTransportCallback(

View file

@ -1675,19 +1675,6 @@ class AcmSetBitRateTest : public ::testing::Test {
std::unique_ptr<test::InputAudioFile> audio_source_; std::unique_ptr<test::InputAudioFile> audio_source_;
}; };
class AcmSetBitRateOldApi : public AcmSetBitRateTest {
protected:
// Runs the test. SetUpSender() must have been called and a codec must be set
// up before calling this method.
void Run(int target_bitrate_bps,
int min_expected_total_bits,
int max_expected_total_bits) {
ASSERT_TRUE(send_test_->acm());
send_test_->acm()->SetBitRate(target_bitrate_bps);
RunInner(min_expected_total_bits, max_expected_total_bits);
}
};
class AcmSetBitRateNewApi : public AcmSetBitRateTest { class AcmSetBitRateNewApi : public AcmSetBitRateTest {
protected: protected:
// Runs the test. SetUpSender() must have been called and a codec must be set // Runs the test. SetUpSender() must have been called and a codec must be set
@ -1697,11 +1684,6 @@ class AcmSetBitRateNewApi : public AcmSetBitRateTest {
} }
}; };
TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_10kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(10000, 8000, 12000);
}
TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_10kbps) { TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_10kbps) {
const auto config = AudioEncoderOpus::SdpToConfig( const auto config = AudioEncoderOpus::SdpToConfig(
SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "10000"}})); SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "10000"}}));
@ -1711,11 +1693,6 @@ TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_10kbps) {
RunInner(8000, 12000); RunInner(8000, 12000);
} }
TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_50kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(50000, 40000, 60000);
}
TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_50kbps) { TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_50kbps) {
const auto config = AudioEncoderOpus::SdpToConfig( const auto config = AudioEncoderOpus::SdpToConfig(
SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "50000"}})); SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "50000"}}));
@ -1728,19 +1705,12 @@ TEST_F(AcmSetBitRateNewApi, OpusFromFormat_48khz_20ms_50kbps) {
// The result on the Android platforms is inconsistent for this test case. // The result on the Android platforms is inconsistent for this test case.
// On android_rel the result is different from android and android arm64 rel. // On android_rel the result is different from android and android arm64 rel.
#if defined(WEBRTC_ANDROID) #if defined(WEBRTC_ANDROID)
#define MAYBE_Opus_48khz_20ms_100kbps DISABLED_Opus_48khz_20ms_100kbps
#define MAYBE_OpusFromFormat_48khz_20ms_100kbps \ #define MAYBE_OpusFromFormat_48khz_20ms_100kbps \
DISABLED_OpusFromFormat_48khz_20ms_100kbps DISABLED_OpusFromFormat_48khz_20ms_100kbps
#else #else
#define MAYBE_Opus_48khz_20ms_100kbps Opus_48khz_20ms_100kbps
#define MAYBE_OpusFromFormat_48khz_20ms_100kbps \ #define MAYBE_OpusFromFormat_48khz_20ms_100kbps \
OpusFromFormat_48khz_20ms_100kbps OpusFromFormat_48khz_20ms_100kbps
#endif #endif
TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_100kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(100000, 80000, 120000);
}
TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_100kbps) { TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_100kbps) {
const auto config = AudioEncoderOpus::SdpToConfig( const auto config = AudioEncoderOpus::SdpToConfig(
SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "100000"}})); SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "100000"}}));
@ -1750,98 +1720,6 @@ TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_100kbps) {
RunInner(80000, 120000); RunInner(80000, 120000);
} }
// These next 2 tests ensure that the SetBitRate function has no effect on PCM
TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_8kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
Run(8000, 128000, 128000);
}
TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_32kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
Run(32000, 128000, 128000);
}
// This test is for verifying the SetBitRate function. The bitrate is changed
// in the middle, and the number of generated bytes are before and after the
// change are checked.
class AcmChangeBitRateOldApi : public AcmSetBitRateOldApi {
protected:
AcmChangeBitRateOldApi() : sampling_freq_hz_(0), frame_size_samples_(0) {}
// Registers a send codec in the test::AcmSendTest object. Returns true on
// success, false on failure.
bool RegisterSendCodec(const char* payload_name,
int sampling_freq_hz,
int channels,
int payload_type,
int frame_size_samples,
int frame_size_rtp_timestamps) override {
frame_size_samples_ = frame_size_samples;
sampling_freq_hz_ = sampling_freq_hz;
return AcmSetBitRateOldApi::RegisterSendCodec(
payload_name, sampling_freq_hz, channels, payload_type,
frame_size_samples, frame_size_rtp_timestamps);
}
// Runs the test. SetUpSender() and RegisterSendCodec() must have been called
// before calling this method.
void Run(int target_bitrate_bps,
int expected_before_switch_bits,
int expected_after_switch_bits) {
ASSERT_TRUE(send_test_->acm());
int nr_packets =
sampling_freq_hz_ * kTestDurationMs / (frame_size_samples_ * 1000);
int nr_bytes_before = 0, nr_bytes_after = 0;
int packet_counter = 0;
while (std::unique_ptr<test::Packet> next_packet =
send_test_->NextPacket()) {
if (packet_counter == nr_packets / 2)
send_test_->acm()->SetBitRate(target_bitrate_bps);
if (packet_counter < nr_packets / 2)
nr_bytes_before +=
rtc::checked_cast<int>(next_packet->payload_length_bytes());
else
nr_bytes_after +=
rtc::checked_cast<int>(next_packet->payload_length_bytes());
packet_counter++;
}
// Check that bitrate is 80-120 percent of expected value.
EXPECT_GE(expected_before_switch_bits, nr_bytes_before * 8 * 8 / 10);
EXPECT_LE(expected_before_switch_bits, nr_bytes_before * 8 * 12 / 10);
EXPECT_GE(expected_after_switch_bits, nr_bytes_after * 8 * 8 / 10);
EXPECT_LE(expected_after_switch_bits, nr_bytes_after * 8 * 12 / 10);
}
uint32_t sampling_freq_hz_;
uint32_t frame_size_samples_;
};
TEST_F(AcmChangeBitRateOldApi, Opus_48khz_20ms_10kbps_2) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(10000, 14096, 4232);
}
TEST_F(AcmChangeBitRateOldApi, Opus_48khz_20ms_50kbps_2) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(50000, 14096, 22552);
}
TEST_F(AcmChangeBitRateOldApi, Opus_48khz_20ms_100kbps_2) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
Run(100000, 14096, 49472);
}
// These next 2 tests ensure that the SetBitRate function has no effect on PCM
TEST_F(AcmChangeBitRateOldApi, Pcm16_8khz_10ms_8kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
Run(8000, 64000, 64000);
}
TEST_F(AcmChangeBitRateOldApi, Pcm16_8khz_10ms_32kbps) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
Run(32000, 64000, 64000);
}
TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) {
AudioEncoderPcmU::Config config; AudioEncoderPcmU::Config config;
config.frame_size_ms = 20; config.frame_size_ms = 20;

View file

@ -92,14 +92,6 @@ class AudioCodingModule {
}); });
} }
///////////////////////////////////////////////////////////////////////////
// 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.
//
// This is only used in test code that rely on old ACM APIs.
// TODO(minyue): Remove it when possible.
virtual void SetBitRate(int bitrate_bps) = 0;
// int32_t RegisterTransportCallback() // int32_t RegisterTransportCallback()
// Register a transport callback which will be called to deliver // Register a transport callback which will be called to deliver
// the encoded buffers whenever Process() is called and a // the encoded buffers whenever Process() is called and a