Index: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc |
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc |
index 6f809e852e63b849519956dd1995554e40608cd9..0aa667effb156da2e9bd3ac9c6cf9dc26506924f 100644 |
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc |
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc |
@@ -197,23 +197,6 @@ void AudioEncoderOpus::SetMaxPlaybackRate(int frequency_hz) { |
RTC_CHECK(RecreateEncoderInstance(conf)); |
} |
-void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) { |
- double opt_loss_rate = OptimizePacketLossRate(fraction, packet_loss_rate_); |
- if (packet_loss_rate_ != opt_loss_rate) { |
- packet_loss_rate_ = opt_loss_rate; |
- RTC_CHECK_EQ( |
- 0, WebRtcOpus_SetPacketLossRate( |
- inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); |
- } |
-} |
- |
-void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) { |
- config_.bitrate_bps = rtc::Optional<int>( |
- std::max(std::min(bits_per_second, kMaxBitrateBps), kMinBitrateBps)); |
- RTC_DCHECK(config_.IsOk()); |
- RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.GetBitrateBps())); |
-} |
- |
bool AudioEncoderOpus::EnableAudioNetworkAdaptor( |
const std::string& config_string, |
const Clock* clock) { |
@@ -234,10 +217,8 @@ void AudioEncoderOpus::OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) { |
void AudioEncoderOpus::OnReceivedUplinkPacketLossFraction( |
float uplink_packet_loss_fraction) { |
- if (!audio_network_adaptor_) { |
- return AudioEncoder::OnReceivedTargetAudioBitrate( |
- uplink_packet_loss_fraction); |
- } |
+ if (!audio_network_adaptor_) |
+ SetProjectedPacketLossRate(uplink_packet_loss_fraction); |
kwiberg-webrtc
2016/10/20 21:46:23
Shouldn't there be an early retirn here? Or an els
minyue-webrtc
2016/11/08 13:37:24
Yes, it should early return :)
This is self-solve
|
audio_network_adaptor_->SetUplinkPacketLossFraction( |
uplink_packet_loss_fraction); |
ApplyAudioNetworkAdaptor(); |
@@ -246,7 +227,7 @@ void AudioEncoderOpus::OnReceivedUplinkPacketLossFraction( |
void AudioEncoderOpus::OnReceivedTargetAudioBitrate( |
int target_audio_bitrate_bps) { |
if (!audio_network_adaptor_) |
- return AudioEncoder::OnReceivedTargetAudioBitrate(target_audio_bitrate_bps); |
+ return SetTargetBitrate(target_audio_bitrate_bps); |
audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps); |
ApplyAudioNetworkAdaptor(); |
} |
@@ -381,6 +362,23 @@ void AudioEncoderOpus::SetNumChannelsToEncode(size_t num_channels_to_encode) { |
num_channels_to_encode_ = num_channels_to_encode; |
} |
+void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) { |
+ config_.bitrate_bps = rtc::Optional<int>( |
+ std::max(std::min(bits_per_second, kMaxBitrateBps), kMinBitrateBps)); |
+ RTC_DCHECK(config_.IsOk()); |
+ RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.GetBitrateBps())); |
+} |
+ |
+void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) { |
+ double opt_loss_rate = OptimizePacketLossRate(fraction, packet_loss_rate_); |
+ if (packet_loss_rate_ != opt_loss_rate) { |
+ packet_loss_rate_ = opt_loss_rate; |
+ RTC_CHECK_EQ( |
+ 0, WebRtcOpus_SetPacketLossRate( |
+ inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); |
+ } |
+} |
+ |
void AudioEncoderOpus::ApplyAudioNetworkAdaptor() { |
auto config = audio_network_adaptor_->GetEncoderRuntimeConfig(); |
// |audio_network_adaptor_| is supposed to be configured to output all |