OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/api/audio_codecs/isac/audio_encoder_isac_float.h" | |
12 | |
13 #include "webrtc/common_types.h" | |
14 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h" | |
15 #include "webrtc/rtc_base/ptr_util.h" | |
16 | |
17 namespace webrtc { | |
18 | |
19 rtc::Optional<AudioEncoderIsacFloat::Config> AudioEncoderIsacFloat::SdpToConfig( | |
ossu
2017/08/15 14:04:19
This one should use (or at least be equivalent to)
kwiberg-webrtc
2017/08/17 13:32:40
Done.
| |
20 const SdpAudioFormat& format) { | |
21 if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 && | |
22 (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) && | |
23 format.num_channels == 1) { | |
24 Config config; | |
25 config.sample_rate_hz = format.clockrate_hz; | |
26 return rtc::Optional<Config>(config); | |
27 } else { | |
28 return rtc::Optional<Config>(); | |
29 } | |
30 } | |
31 | |
32 void AudioEncoderIsacFloat::AppendSupportedEncoders( | |
33 std::vector<AudioCodecSpec>* specs) { | |
34 for (int sample_rate_hz : {16000, 32000}) { | |
35 const SdpAudioFormat fmt = {"ISAC", sample_rate_hz, 1}; | |
36 const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt)); | |
37 specs->push_back({fmt, info}); | |
38 } | |
39 } | |
40 | |
41 AudioCodecInfo AudioEncoderIsacFloat::QueryAudioEncoder( | |
42 const AudioEncoderIsacFloat::Config& config) { | |
43 RTC_DCHECK(config.IsOk()); | |
44 constexpr int min_bitrate = 10000; | |
45 const int max_bitrate = config.sample_rate_hz == 16000 ? 32000 : 56000; | |
46 const int default_bitrate = max_bitrate; | |
47 return {config.sample_rate_hz, 1, default_bitrate, min_bitrate, max_bitrate}; | |
48 } | |
49 | |
50 std::unique_ptr<AudioEncoder> AudioEncoderIsacFloat::MakeAudioEncoder( | |
51 const AudioEncoderIsacFloat::Config& config, | |
52 int payload_type) { | |
53 RTC_DCHECK(config.IsOk()); | |
54 AudioEncoderIsacFloatImpl::Config c; | |
55 c.sample_rate_hz = config.sample_rate_hz; | |
56 c.frame_size_ms = config.frame_size_ms; | |
57 c.payload_type = payload_type; | |
58 return rtc::MakeUnique<AudioEncoderIsacFloatImpl>(c); | |
59 } | |
60 | |
61 } // namespace webrtc | |
OLD | NEW |