tor-browser

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

builtin_audio_decoder_factory.cc (2142B)


      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/builtin_audio_decoder_factory.h"
     12 
     13 #include <memory>
     14 #include <optional>
     15 #include <vector>
     16 
     17 #include "api/audio_codecs/L16/audio_decoder_L16.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_decoder_factory.h"
     21 #include "api/audio_codecs/audio_decoder_factory_template.h"
     22 #include "api/audio_codecs/audio_format.h"
     23 #include "api/audio_codecs/g711/audio_decoder_g711.h"
     24 #include "api/audio_codecs/g722/audio_decoder_g722.h"
     25 #include "api/scoped_refptr.h"
     26 #if WEBRTC_USE_BUILTIN_OPUS
     27 #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
     28 #include "api/audio_codecs/opus/audio_decoder_opus.h"  // nogncheck
     29 #endif
     30 
     31 namespace webrtc {
     32 
     33 namespace {
     34 
     35 // Modify an audio decoder to not advertise support for anything.
     36 template <typename T>
     37 struct NotAdvertised {
     38  using Config = typename T::Config;
     39  static std::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
     40    return T::SdpToConfig(audio_format);
     41  }
     42  static void AppendSupportedDecoders(
     43      std::vector<AudioCodecSpec>* /* specs */) {
     44    // Don't advertise support for anything.
     45  }
     46  static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
     47      const Config& config,
     48      std::optional<AudioCodecPairId> codec_pair_id = std::nullopt) {
     49    return T::MakeAudioDecoder(config, codec_pair_id);
     50  }
     51 };
     52 
     53 }  // namespace
     54 
     55 scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
     56  return CreateAudioDecoderFactory<
     57 
     58 #if WEBRTC_USE_BUILTIN_OPUS
     59      AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>,
     60 #endif
     61 
     62      AudioDecoderG722, AudioDecoderG711, NotAdvertised<AudioDecoderL16>>();
     63 }
     64 
     65 }  // namespace webrtc