OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" | 11 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
17 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" | 17 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" |
18 #include "webrtc/rtc_base/ptr_util.h" | 18 #include "webrtc/rtc_base/ptr_util.h" |
19 #include "webrtc/rtc_base/safe_conversions.h" | 19 #include "webrtc/rtc_base/safe_conversions.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 rtc::Optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig( | 23 rtc::Optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig( |
24 const SdpAudioFormat& format) { | 24 const SdpAudioFormat& format) { |
25 return STR_CASE_CMP(format.name.c_str(), "g722") == 0 && | 25 return STR_CASE_CMP(format.name.c_str(), "G722") == 0 && |
26 format.clockrate_hz == 8000 && | 26 format.clockrate_hz == 8000 && |
27 (format.num_channels == 1 || format.num_channels == 2) | 27 (format.num_channels == 1 || format.num_channels == 2) |
28 ? rtc::Optional<Config>( | 28 ? rtc::Optional<Config>( |
29 Config{rtc::dchecked_cast<int>(format.num_channels)}) | 29 Config{rtc::dchecked_cast<int>(format.num_channels)}) |
30 : rtc::Optional<Config>(); | 30 : rtc::Optional<Config>(); |
31 } | 31 } |
32 | 32 |
33 void AudioDecoderG722::AppendSupportedDecoders( | 33 void AudioDecoderG722::AppendSupportedDecoders( |
34 std::vector<AudioCodecSpec>* specs) { | 34 std::vector<AudioCodecSpec>* specs) { |
35 specs->push_back({{"g722", 8000, 1}, {16000, 1, 64000}}); | 35 specs->push_back({{"G722", 8000, 1}, {16000, 1, 64000}}); |
36 } | 36 } |
37 | 37 |
38 std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder( | 38 std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder( |
39 Config config) { | 39 Config config) { |
40 switch (config.num_channels) { | 40 switch (config.num_channels) { |
41 case 1: | 41 case 1: |
42 return rtc::MakeUnique<AudioDecoderG722Impl>(); | 42 return rtc::MakeUnique<AudioDecoderG722Impl>(); |
43 case 2: | 43 case 2: |
44 return rtc::MakeUnique<AudioDecoderG722StereoImpl>(); | 44 return rtc::MakeUnique<AudioDecoderG722StereoImpl>(); |
45 default: | 45 default: |
46 return nullptr; | 46 return nullptr; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 } // namespace webrtc | 50 } // namespace webrtc |
OLD | NEW |