Chromium Code Reviews| 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..9a980e4cea2ce9b9f36839bf1b94cb3f2aa2e568 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 { |
| +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 kHz. |
|
the sun
2017/03/20 20:53:40
That rate is *way* too high. :P
ossu
2017/03/21 16:15:31
:D
|
| + 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) { |
|
ossu
2017/03/20 18:18:53
The ptime parsers are based on the values found in
the sun
2017/03/20 20:53:40
Acknowledged.
|
| + 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_)); |
| } |