diff options
Diffstat (limited to 'webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h')
-rw-r--r-- | webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h | 54 |
1 files changed, 17 insertions, 37 deletions
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 a986bc4..2e43fd3 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 @@ -8,29 +8,26 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ +#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ +#define MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ -#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" - -#include "webrtc/base/checks.h" +#include "rtc_base/checks.h" namespace webrtc { template <typename T> -AudioDecoderIsacT<T>::AudioDecoderIsacT() - : AudioDecoderIsacT(nullptr) {} +bool AudioDecoderIsacT<T>::Config::IsOk() const { + return (sample_rate_hz == 16000 || sample_rate_hz == 32000); +} template <typename T> -AudioDecoderIsacT<T>::AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo) - : bwinfo_(bwinfo), decoder_sample_rate_hz_(-1) { +AudioDecoderIsacT<T>::AudioDecoderIsacT(const Config& config) + : sample_rate_hz_(config.sample_rate_hz) { + RTC_CHECK(config.IsOk()) << "Unsupported sample rate " + << config.sample_rate_hz; RTC_CHECK_EQ(0, T::Create(&isac_state_)); T::DecoderInit(isac_state_); - if (bwinfo_) { - IsacBandwidthInfo bi; - T::GetBandwidthInfo(isac_state_, &bi); - bwinfo_->Set(bi); - } + RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz_)); } template <typename T> @@ -44,12 +41,7 @@ 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; - } + RTC_CHECK_EQ(sample_rate_hz_, sample_rate_hz); int16_t temp_type = 1; // Default is speech. int ret = T::DecodeInternal(isac_state_, encoded, encoded_len, decoded, &temp_type); @@ -73,25 +65,13 @@ void AudioDecoderIsacT<T>::Reset() { } template <typename T> -int AudioDecoderIsacT<T>::IncomingPacket(const uint8_t* payload, - size_t payload_len, - uint16_t rtp_sequence_number, - uint32_t rtp_timestamp, - uint32_t arrival_timestamp) { - int ret = T::UpdateBwEstimate(isac_state_, payload, payload_len, - rtp_sequence_number, rtp_timestamp, - arrival_timestamp); - if (bwinfo_) { - IsacBandwidthInfo bwinfo; - T::GetBandwidthInfo(isac_state_, &bwinfo); - bwinfo_->Set(bwinfo); - } - return ret; +int AudioDecoderIsacT<T>::ErrorCode() { + return T::GetErrorCode(isac_state_); } template <typename T> -int AudioDecoderIsacT<T>::ErrorCode() { - return T::GetErrorCode(isac_state_); +int AudioDecoderIsacT<T>::SampleRateHz() const { + return sample_rate_hz_; } template <typename T> @@ -101,4 +81,4 @@ size_t AudioDecoderIsacT<T>::Channels() const { } // namespace webrtc -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ +#endif // MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_ |