Index: webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
index befb3558beb85ff8eb304fae5317bbe6f19cde52..1c386e0181a2e064ea4ee6b0db7db6c2e4bd913e 100644 |
--- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
+++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
@@ -77,10 +77,12 @@ AudioEncoderDecoderIsacT<T>::AudioEncoderDecoderIsacT(const Config& config) |
CHECK_EQ(0, T::SetEncSampRate(isac_state_, config.sample_rate_hz)); |
const int bit_rate = config.bit_rate == 0 ? kDefaultBitRate : config.bit_rate; |
if (config.adaptive_mode) { |
+ target_bitrate_bps_ = -1; |
CHECK_EQ(0, T::ControlBwe(isac_state_, bit_rate, |
config.frame_size_ms, config.enforce_frame_size)); |
} else { |
+ target_bitrate_bps_ = bit_rate; |
CHECK_EQ(0, T::Control(isac_state_, bit_rate, config.frame_size_ms)); |
} |
// When config.sample_rate_hz is set to 48000 Hz (iSAC-fb), the decoder is |
@@ -130,6 +132,22 @@ int AudioEncoderDecoderIsacT<T>::Max10MsFramesInAPacket() const { |
} |
template <typename T> |
+int AudioEncoderDecoderIsacT<T>::SetTargetBitrate(int bits_per_second) { |
+ CriticalSectionScoped cs_lock(lock_.get()); |
+ if (target_bitrate_bps_ == -1) { |
+ // Adaptive mode. Cannot change the target bitrate manually. |
+ return target_bitrate_bps_; |
kwiberg-webrtc
2015/06/16 19:22:54
Just "return -1" might be clearer. Also, document
|
+ } |
+ // Clamp to at minimum 10000 bps and maximum 32000 bps or 56000 bps for SWB. |
+ target_bitrate_bps_ = std::min(std::max(bits_per_second, 10000), |
+ SampleRateHz() == 16000 ? 32000 : 56000); |
+ CriticalSectionScoped cs(state_lock_.get()); |
+ CHECK_EQ(0, T::Control(isac_state_, target_bitrate_bps_, |
+ Num10MsFramesInNextPacket() * 10)); |
+ return target_bitrate_bps_; |
+} |
+ |
+template <typename T> |
AudioEncoder::EncodedInfo AudioEncoderDecoderIsacT<T>::EncodeInternal( |
uint32_t rtp_timestamp, |
const int16_t* audio, |