Make a the decisions of ANA optional for the opus encoder.
BUG=webrtc:6936, webrtc:6303 Review-Url: https://codereview.webrtc.org/2592253004 Cr-Commit-Position: refs/heads/master@{#15807}
This commit is contained in:
@ -491,23 +491,21 @@ void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) {
|
||||
|
||||
void AudioEncoderOpus::ApplyAudioNetworkAdaptor() {
|
||||
auto config = audio_network_adaptor_->GetEncoderRuntimeConfig();
|
||||
// |audio_network_adaptor_| is supposed to be configured to output all
|
||||
// following parameters.
|
||||
RTC_DCHECK(config.bitrate_bps);
|
||||
RTC_DCHECK(config.frame_length_ms);
|
||||
RTC_DCHECK(config.uplink_packet_loss_fraction);
|
||||
RTC_DCHECK(config.enable_fec);
|
||||
RTC_DCHECK(config.enable_dtx);
|
||||
RTC_DCHECK(config.num_channels);
|
||||
RTC_DCHECK(!config.frame_length_ms || *config.frame_length_ms == 20 ||
|
||||
*config.frame_length_ms == 60);
|
||||
|
||||
RTC_DCHECK(*config.frame_length_ms == 20 || *config.frame_length_ms == 60);
|
||||
|
||||
SetTargetBitrate(*config.bitrate_bps);
|
||||
SetFrameLength(*config.frame_length_ms);
|
||||
SetFec(*config.enable_fec);
|
||||
SetProjectedPacketLossRate(*config.uplink_packet_loss_fraction);
|
||||
SetDtx(*config.enable_dtx);
|
||||
SetNumChannelsToEncode(*config.num_channels);
|
||||
if (config.bitrate_bps)
|
||||
SetTargetBitrate(*config.bitrate_bps);
|
||||
if (config.frame_length_ms)
|
||||
SetFrameLength(*config.frame_length_ms);
|
||||
if (config.enable_fec)
|
||||
SetFec(*config.enable_fec);
|
||||
if (config.uplink_packet_loss_fraction)
|
||||
SetProjectedPacketLossRate(*config.uplink_packet_loss_fraction);
|
||||
if (config.enable_dtx)
|
||||
SetDtx(*config.enable_dtx);
|
||||
if (config.num_channels)
|
||||
SetNumChannelsToEncode(*config.num_channels);
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioNetworkAdaptor>
|
||||
|
||||
@ -443,4 +443,25 @@ TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) {
|
||||
config.bitrate_bps = rtc::Optional<int>(14001);
|
||||
EXPECT_EQ(rtc::Optional<int>(6), config.GetNewComplexity());
|
||||
}
|
||||
|
||||
TEST(AudioEncoderOpusTest, EmptyConfigDontAffectEncoderSettings) {
|
||||
auto states = CreateCodec(2);
|
||||
states.encoder->EnableAudioNetworkAdaptor("", nullptr);
|
||||
|
||||
auto config = CreateEncoderRuntimeConfig();
|
||||
AudioNetworkAdaptor::EncoderRuntimeConfig empty_config;
|
||||
|
||||
EXPECT_CALL(**states.mock_audio_network_adaptor, GetEncoderRuntimeConfig())
|
||||
.WillOnce(Return(config))
|
||||
.WillOnce(Return(empty_config));
|
||||
|
||||
constexpr size_t kOverhead = 64;
|
||||
EXPECT_CALL(**states.mock_audio_network_adaptor, SetOverhead(kOverhead))
|
||||
.Times(2);
|
||||
states.encoder->OnReceivedOverhead(kOverhead);
|
||||
states.encoder->OnReceivedOverhead(kOverhead);
|
||||
|
||||
CheckEncoderRuntimeConfig(states.encoder.get(), config);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user