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/L16/audio_decoder_L16.h" 12 13 #include <memory> 14 15 #include "absl/strings/match.h" 16 #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" 17 #include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h" 18 #include "rtc_base/numerics/safe_conversions.h" 19 20 namespace webrtc { 21 SdpToConfig(const SdpAudioFormat & format)22absl::optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig( 23 const SdpAudioFormat& format) { 24 Config config; 25 config.sample_rate_hz = format.clockrate_hz; 26 config.num_channels = rtc::checked_cast<int>(format.num_channels); 27 if (absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk()) { 28 return config; 29 } 30 return absl::nullopt; 31 } 32 AppendSupportedDecoders(std::vector<AudioCodecSpec> * specs)33void AudioDecoderL16::AppendSupportedDecoders( 34 std::vector<AudioCodecSpec>* specs) { 35 Pcm16BAppendSupportedCodecSpecs(specs); 36 } 37 MakeAudioDecoder(const Config & config,absl::optional<AudioCodecPairId>,const FieldTrialsView * field_trials)38std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder( 39 const Config& config, 40 absl::optional<AudioCodecPairId> /*codec_pair_id*/, 41 const FieldTrialsView* field_trials) { 42 if (!config.IsOk()) { 43 return nullptr; 44 } 45 return std::make_unique<AudioDecoderPcm16B>(config.sample_rate_hz, 46 config.num_channels); 47 } 48 49 } // namespace webrtc 50