tor-browser

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

opus_audio_encoder_factory.cc (2097B)


      1 /*
      2 *  Copyright (c) 2019 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/opus_audio_encoder_factory.h"
     12 
     13 #include <memory>
     14 #include <optional>
     15 #include <vector>
     16 
     17 #include "api/audio_codecs/audio_codec_pair_id.h"
     18 #include "api/audio_codecs/audio_encoder.h"
     19 #include "api/audio_codecs/audio_encoder_factory.h"
     20 #include "api/audio_codecs/audio_encoder_factory_template.h"
     21 #include "api/audio_codecs/audio_format.h"
     22 #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
     23 #include "api/audio_codecs/opus/audio_encoder_opus.h"
     24 #include "api/field_trials_view.h"
     25 #include "api/scoped_refptr.h"
     26 
     27 namespace webrtc {
     28 namespace {
     29 
     30 // Modify an audio encoder to not advertise support for anything.
     31 template <typename T>
     32 struct NotAdvertised {
     33  using Config = typename T::Config;
     34  static std::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
     35    return T::SdpToConfig(audio_format);
     36  }
     37  static void AppendSupportedEncoders(
     38      std::vector<AudioCodecSpec>* /* specs */) {
     39    // Don't advertise support for anything.
     40  }
     41  static AudioCodecInfo QueryAudioEncoder(const Config& config) {
     42    return T::QueryAudioEncoder(config);
     43  }
     44  static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
     45      const Config& config,
     46      int payload_type,
     47      std::optional<AudioCodecPairId> codec_pair_id = std::nullopt,
     48      const FieldTrialsView* field_trials = nullptr) {
     49    return T::MakeAudioEncoder(config, payload_type, codec_pair_id,
     50                               field_trials);
     51  }
     52 };
     53 
     54 }  // namespace
     55 
     56 scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() {
     57  return CreateAudioEncoderFactory<
     58      AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>>();
     59 }
     60 
     61 }  // namespace webrtc