tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

audio_decoder_L16.cc (1819B)


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