| 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/L16/audio_decoder_L16.h" | 11 #include "webrtc/api/audio_codecs/L16/audio_decoder_L16.h" |
| 12 | 12 |
| 13 #include "webrtc/common_types.h" | 13 #include "webrtc/common_types.h" |
| 14 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" | 14 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" |
| 15 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b_common.h" | 15 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b_common.h" |
| 16 #include "webrtc/rtc_base/ptr_util.h" | 16 #include "webrtc/rtc_base/ptr_util.h" |
| 17 #include "webrtc/rtc_base/safe_conversions.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 | 20 |
| 20 rtc::Optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig( | 21 rtc::Optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig( |
| 21 const SdpAudioFormat& format) { | 22 const SdpAudioFormat& format) { |
| 22 Config config; | 23 Config config; |
| 23 config.sample_rate_hz = format.clockrate_hz; | 24 config.sample_rate_hz = format.clockrate_hz; |
| 24 config.num_channels = format.num_channels; | 25 config.num_channels = rtc::checked_cast<int>(format.num_channels); |
| 25 return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk() | 26 return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk() |
| 26 ? rtc::Optional<Config>(config) | 27 ? rtc::Optional<Config>(config) |
| 27 : rtc::Optional<Config>(); | 28 : rtc::Optional<Config>(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void AudioDecoderL16::AppendSupportedDecoders( | 31 void AudioDecoderL16::AppendSupportedDecoders( |
| 31 std::vector<AudioCodecSpec>* specs) { | 32 std::vector<AudioCodecSpec>* specs) { |
| 32 Pcm16BAppendSupportedCodecSpecs(specs); | 33 Pcm16BAppendSupportedCodecSpecs(specs); |
| 33 } | 34 } |
| 34 | 35 |
| 35 std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder( | 36 std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder( |
| 36 const Config& config) { | 37 const Config& config) { |
| 37 return config.IsOk() ? rtc::MakeUnique<AudioDecoderPcm16B>( | 38 return config.IsOk() ? rtc::MakeUnique<AudioDecoderPcm16B>( |
| 38 config.sample_rate_hz, config.num_channels) | 39 config.sample_rate_hz, config.num_channels) |
| 39 : nullptr; | 40 : nullptr; |
| 40 } | 41 } |
| 41 | 42 |
| 42 } // namespace webrtc | 43 } // namespace webrtc |
| OLD | NEW |