Index: webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h |
diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h b/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h |
index 4998feac84bd866edc2b64f3f8b5fe9333782cc9..431632112ac7333bb3582409c2cdb8ce9d9199ae 100644 |
--- a/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h |
+++ b/webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h |
@@ -19,12 +19,31 @@ namespace webrtc { |
template <typename T> |
AudioDecoderIsacT<T>::AudioDecoderIsacT() |
- : AudioDecoderIsacT(nullptr) {} |
+ : AudioDecoderIsacT(rtc::Optional<int>(), nullptr) {} |
template <typename T> |
AudioDecoderIsacT<T>::AudioDecoderIsacT( |
const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo) |
- : bwinfo_(bwinfo), decoder_sample_rate_hz_(-1) { |
+ : AudioDecoderIsacT(rtc::Optional<int>(), bwinfo) {} |
+ |
+template <typename T> |
+AudioDecoderIsacT<T>::AudioDecoderIsacT(int sample_rate_hz) |
+ : AudioDecoderIsacT(rtc::Optional<int>(sample_rate_hz), nullptr) {} |
+ |
+template <typename T> |
+AudioDecoderIsacT<T>::AudioDecoderIsacT( |
+ int sample_rate_hz, |
+ const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo) |
+ : AudioDecoderIsacT(rtc::Optional<int>(sample_rate_hz), bwinfo) {} |
+ |
+template <typename T> |
+AudioDecoderIsacT<T>::AudioDecoderIsacT( |
+ rtc::Optional<int> sample_rate_hz, |
+ const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo) |
+ : sample_rate_hz_(sample_rate_hz), bwinfo_(bwinfo) { |
+ RTC_CHECK(!sample_rate_hz || *sample_rate_hz == 16000 || |
+ *sample_rate_hz == 32000) |
+ << "Unsupported sample rate " << *sample_rate_hz; |
RTC_CHECK_EQ(0, T::Create(&isac_state_)); |
T::DecoderInit(isac_state_); |
if (bwinfo_) { |
@@ -32,6 +51,9 @@ AudioDecoderIsacT<T>::AudioDecoderIsacT( |
T::GetBandwidthInfo(isac_state_, &bi); |
bwinfo_->Set(bi); |
} |
+ if (sample_rate_hz_) { |
+ RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, *sample_rate_hz_)); |
+ } |
} |
template <typename T> |
@@ -45,11 +67,13 @@ int AudioDecoderIsacT<T>::DecodeInternal(const uint8_t* encoded, |
int sample_rate_hz, |
int16_t* decoded, |
SpeechType* speech_type) { |
- RTC_CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000) |
- << "Unsupported sample rate " << sample_rate_hz; |
- if (sample_rate_hz != decoder_sample_rate_hz_) { |
- RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz)); |
- decoder_sample_rate_hz_ = sample_rate_hz; |
+ if (sample_rate_hz_) { |
+ RTC_CHECK_EQ(*sample_rate_hz_, sample_rate_hz); |
+ } else { |
+ RTC_CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000) |
+ << "Unsupported sample rate " << sample_rate_hz; |
+ sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz); |
+ RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, *sample_rate_hz_)); |
} |
int16_t temp_type = 1; // Default is speech. |
int ret = |
@@ -96,6 +120,12 @@ int AudioDecoderIsacT<T>::ErrorCode() { |
} |
template <typename T> |
+int AudioDecoderIsacT<T>::SampleRateHz() const { |
+ RTC_CHECK(sample_rate_hz_) << "Sample rate not set yet!"; |
+ return *sample_rate_hz_; |
+} |
+ |
+template <typename T> |
size_t AudioDecoderIsacT<T>::Channels() const { |
return 1; |
} |