| 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..ebe4d6a0e264607c6266ac119fade2ec2e21fb5d 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,9 +12,15 @@
|
| #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 {
|
| +namespace { // NOLINT (not a "regular" header file)
|
| +int GetIsacMaxBitrate(int clockrate_hz) {
|
| + return (clockrate_hz == 32000) ? 56000 : 32000;
|
| +}
|
| +} // namespace
|
|
|
| template <typename T>
|
| typename AudioEncoderIsacT<T>::Config CreateIsacConfig(
|
| @@ -33,6 +39,33 @@ 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;
|
| +
|
| + // We only support different frame sizes at 16000 Hz.
|
| + if (config.sample_rate_hz == 16000) {
|
| + auto ptime_iter = format.parameters.find("ptime");
|
| + if (ptime_iter != format.parameters.end()) {
|
| + auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
|
| + if (ptime && *ptime >= 60) {
|
| + config.frame_size_ms = 60;
|
| + } else {
|
| + config.frame_size_ms = 30;
|
| + }
|
| + }
|
| + }
|
| +
|
| + // Set the default bitrate for ISAC to the maximum bitrate allowed at this
|
| + // clockrate. At this point, adaptive mode is not used by WebRTC.
|
| + config.bit_rate = GetIsacMaxBitrate(format.clockrate_hz);
|
| + return config;
|
| +}
|
| +
|
| +template <typename T>
|
| bool AudioEncoderIsacT<T>::Config::IsOk() const {
|
| if (max_bit_rate < 32000 && max_bit_rate != -1)
|
| return false;
|
| @@ -73,6 +106,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<AudioCodecInfo> AudioEncoderIsacT<T>::QueryAudioEncoder(
|
| + 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<AudioCodecInfo>(
|
| + {config.sample_rate_hz, 1, config.bit_rate, 10000,
|
| + GetIsacMaxBitrate(format.clockrate_hz)});
|
| + }
|
| + }
|
| + return rtc::Optional<AudioCodecInfo>();
|
| +}
|
| +
|
| +template <typename T>
|
| AudioEncoderIsacT<T>::~AudioEncoderIsacT() {
|
| RTC_CHECK_EQ(0, T::Free(isac_state_));
|
| }
|
|
|