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 "api/audio_codecs/isac/audio_decoder_isac_float.h"
12
13 #include <memory>
14
15 #include "absl/strings/match.h"
16 #include "modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h"
17
18 namespace webrtc {
19
20 absl::optional<AudioDecoderIsacFloat::Config>
SdpToConfig(const SdpAudioFormat & format)21 AudioDecoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) {
22 if (absl::EqualsIgnoreCase(format.name, "ISAC") &&
23 (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) &&
24 format.num_channels == 1) {
25 Config config;
26 config.sample_rate_hz = format.clockrate_hz;
27 return config;
28 } else {
29 return absl::nullopt;
30 }
31 }
32
AppendSupportedDecoders(std::vector<AudioCodecSpec> * specs)33 void AudioDecoderIsacFloat::AppendSupportedDecoders(
34 std::vector<AudioCodecSpec>* specs) {
35 specs->push_back({{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}});
36 specs->push_back({{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}});
37 }
38
MakeAudioDecoder(Config config,absl::optional<AudioCodecPairId>)39 std::unique_ptr<AudioDecoder> AudioDecoderIsacFloat::MakeAudioDecoder(
40 Config config,
41 absl::optional<AudioCodecPairId> /*codec_pair_id*/) {
42 RTC_DCHECK(config.IsOk());
43 AudioDecoderIsacFloatImpl::Config c;
44 c.sample_rate_hz = config.sample_rate_hz;
45 return std::make_unique<AudioDecoderIsacFloatImpl>(c);
46 }
47
48 } // namespace webrtc
49