| 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 e4d58ae4d40e536fe25051167ea4401655206185..bbe40a4b196ab759560c7961b9e5f2cbeee29131 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
|
| @@ -12,6 +12,7 @@
|
| #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_
|
|
|
| #include "webrtc/base/checks.h"
|
| +#include "webrtc/base/string_to_number.h"
|
| #include "webrtc/common_types.h"
|
|
|
| namespace webrtc {
|
| @@ -33,6 +34,28 @@ typename AudioEncoderIsacT<T>::Config CreateIsacConfig(
|
| }
|
|
|
| template <typename T>
|
| +typename AudioEncoderIsacT<T>::Config CreateIsacConfig(
|
| + int payload_type,
|
| + const SdpAudioFormat& format) {
|
| + typename AudioEncoderIsacT<T>::Config config;
|
| + config.payload_type = payload_type;
|
| + config.sample_rate_hz = format.clockrate_hz;
|
| +
|
| + auto ptime_iter = format.parameters.find("ptime");
|
| + if (ptime_iter != format.parameters.end()) {
|
| + auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
|
| + if (ptime && *ptime > 0) {
|
| + config.frame_size_ms = *ptime;
|
| + }
|
| + }
|
| +
|
| + // TODO(ossu): These values are taken from ACMCodecDB. At this
|
| + // point, adaptive mode is not used by WebRTC.
|
| + config.bit_rate = (format.clockrate_hz == 32000) ? 56000 : 32000;
|
| + return config;
|
| +}
|
| +
|
| +template <typename T>
|
| bool AudioEncoderIsacT<T>::Config::IsOk() const {
|
| if (max_bit_rate < 32000 && max_bit_rate != -1)
|
| return false;
|
| @@ -73,6 +96,25 @@ AudioEncoderIsacT<T>::AudioEncoderIsacT(
|
| : AudioEncoderIsacT(CreateIsacConfig<T>(codec_inst, bwinfo)) {}
|
|
|
| template <typename T>
|
| +AudioEncoderIsacT<T>::AudioEncoderIsacT(int payload_type,
|
| + const SdpAudioFormat& format)
|
| + : AudioEncoderIsacT(CreateIsacConfig<T>(payload_type, format)) {}
|
| +
|
| +template <typename T>
|
| +rtc::Optional<AudioFormatInfo> AudioEncoderIsacT<T>::QueryAudioFormat(
|
| + const SdpAudioFormat& format) {
|
| + if (STR_CASE_CMP(format.name.c_str(), GetPayloadName()) == 0) {
|
| + Config config = CreateIsacConfig<T>(0, format);
|
| + if (config.IsOk()) {
|
| + return rtc::Optional<AudioFormatInfo>({
|
| + config.sample_rate_hz, 1, config.bit_rate, 10000,
|
| + (config.sample_rate_hz == 16000) ? 32000 : 56000});
|
| + }
|
| + }
|
| + return rtc::Optional<AudioFormatInfo>();
|
| +}
|
| +
|
| +template <typename T>
|
| AudioEncoderIsacT<T>::~AudioEncoderIsacT() {
|
| RTC_CHECK_EQ(0, T::Free(isac_state_));
|
| }
|
|
|