| 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/base/ptr_util.h" | 16 #include "webrtc/base/ptr_util.h" |
| 17 #include "webrtc/base/safe_conversions.h" | 17 #include "webrtc/base/safe_conversions.h" |
| 18 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
| 19 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" | 19 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.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 ? rtc::Optional<Config>(Config()) | 27 (format.num_channels == 1 || format.num_channels == 2) |
| 28 ? rtc::Optional<Config>( |
| 29 Config{rtc::dchecked_cast<int>(format.num_channels)}) |
| 28 : rtc::Optional<Config>(); | 30 : rtc::Optional<Config>(); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void AudioDecoderG722::AppendSupportedDecoders( | 33 void AudioDecoderG722::AppendSupportedDecoders( |
| 32 std::vector<AudioCodecSpec>* specs) { | 34 std::vector<AudioCodecSpec>* specs) { |
| 33 specs->push_back({{"g722", 8000, 1}, {16000, 1, 64000}}); | 35 specs->push_back({{"g722", 8000, 1}, {16000, 1, 64000}}); |
| 34 } | 36 } |
| 35 | 37 |
| 36 std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder( | 38 std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder( |
| 37 Config config) { | 39 Config config) { |
| 38 return rtc::MakeUnique<AudioDecoderG722Impl>(); | 40 switch (config.num_channels) { |
| 41 case 1: |
| 42 return rtc::MakeUnique<AudioDecoderG722Impl>(); |
| 43 case 2: |
| 44 return rtc::MakeUnique<AudioDecoderG722StereoImpl>(); |
| 45 default: |
| 46 return nullptr; |
| 47 } |
| 39 } | 48 } |
| 40 | 49 |
| 41 } // namespace webrtc | 50 } // namespace webrtc |
| OLD | NEW |