kwiberg | 7ea6e59 | 2017-08-16 06:12:57 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "api/audio_codecs/L16/audio_decoder_L16.h" |
kwiberg | 7ea6e59 | 2017-08-16 06:12:57 -0700 | [diff] [blame] | 12 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame^] | 13 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" |
| 15 | #include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h" |
| 16 | #include "rtc_base/ptr_util.h" |
| 17 | #include "rtc_base/safe_conversions.h" |
kwiberg | 7ea6e59 | 2017-08-16 06:12:57 -0700 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | rtc::Optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig( |
| 22 | const SdpAudioFormat& format) { |
| 23 | Config config; |
| 24 | config.sample_rate_hz = format.clockrate_hz; |
kwiberg | 2a59654 | 2017-08-22 03:43:28 -0700 | [diff] [blame] | 25 | config.num_channels = rtc::checked_cast<int>(format.num_channels); |
kwiberg | 7ea6e59 | 2017-08-16 06:12:57 -0700 | [diff] [blame] | 26 | return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk() |
| 27 | ? rtc::Optional<Config>(config) |
| 28 | : rtc::Optional<Config>(); |
| 29 | } |
| 30 | |
| 31 | void AudioDecoderL16::AppendSupportedDecoders( |
| 32 | std::vector<AudioCodecSpec>* specs) { |
| 33 | Pcm16BAppendSupportedCodecSpecs(specs); |
| 34 | } |
| 35 | |
| 36 | std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder( |
| 37 | const Config& config) { |
| 38 | return config.IsOk() ? rtc::MakeUnique<AudioDecoderPcm16B>( |
| 39 | config.sample_rate_hz, config.num_channels) |
| 40 | : nullptr; |
| 41 | } |
| 42 | |
| 43 | } // namespace webrtc |