tor-browser

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

internal_encoder_factory.cc (2562B)


      1 /*
      2 *  Copyright (c) 2016 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 "media/engine/internal_encoder_factory.h"
     12 
     13 #include <memory>
     14 #include <optional>
     15 #include <string>
     16 #include <vector>
     17 
     18 #include "api/environment/environment.h"
     19 #include "api/video_codecs/sdp_video_format.h"
     20 #include "api/video_codecs/video_encoder.h"
     21 #include "api/video_codecs/video_encoder_factory.h"
     22 #include "api/video_codecs/video_encoder_factory_template.h"
     23 #if defined(RTC_USE_LIBAOM_AV1_ENCODER)
     24 #include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"  // nogncheck
     25 #endif
     26 #include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
     27 #include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
     28 #if defined(WEBRTC_USE_H264)
     29 #include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"  // nogncheck
     30 #endif
     31 
     32 namespace webrtc {
     33 namespace {
     34 
     35 using Factory = VideoEncoderFactoryTemplate<LibvpxVp8EncoderTemplateAdapter,
     36 #if defined(WEBRTC_USE_H264)
     37                                            OpenH264EncoderTemplateAdapter,
     38 #endif
     39 #if defined(RTC_USE_LIBAOM_AV1_ENCODER)
     40                                            LibaomAv1EncoderTemplateAdapter,
     41 #endif
     42                                            LibvpxVp9EncoderTemplateAdapter>;
     43 }  // namespace
     44 
     45 std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
     46    const {
     47  return Factory().GetSupportedFormats();
     48 }
     49 
     50 std::unique_ptr<VideoEncoder> InternalEncoderFactory::Create(
     51    const Environment& env,
     52    const SdpVideoFormat& format) {
     53  auto original_format =
     54      FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format);
     55  return original_format ? Factory().Create(env, *original_format) : nullptr;
     56 }
     57 
     58 VideoEncoderFactory::CodecSupport InternalEncoderFactory::QueryCodecSupport(
     59    const SdpVideoFormat& format,
     60    std::optional<std::string> scalability_mode) const {
     61  auto original_format =
     62      FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format);
     63  return original_format
     64             ? Factory().QueryCodecSupport(*original_format, scalability_mode)
     65             : VideoEncoderFactory::CodecSupport{.is_supported = false};
     66 }
     67 
     68 }  // namespace webrtc