tor-browser

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

video_encoder_factory_interface.h (3249B)


      1 /*
      2 *  Copyright (c) 2024 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 #ifndef API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_INTERFACE_H_
     12 #define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_INTERFACE_H_
     13 
     14 #include <map>
     15 #include <memory>
     16 #include <string>
     17 #include <utility>
     18 #include <variant>
     19 #include <vector>
     20 
     21 #include "api/units/time_delta.h"
     22 #include "api/video/resolution.h"
     23 #include "api/video/video_frame_buffer.h"
     24 #include "api/video_codecs/video_encoder_interface.h"
     25 #include "api/video_codecs/video_encoding_general.h"
     26 #include "rtc_base/numerics/rational.h"
     27 
     28 namespace webrtc {
     29 using FrameType = VideoEncoderInterface::FrameType;
     30 
     31 // NOTE: This class is still under development and may change without notice.
     32 class VideoEncoderFactoryInterface {
     33 public:
     34  enum class RateControlMode { kCqp, kCbr };
     35 
     36  struct Capabilities {
     37    struct PredictionConstraints {
     38      enum class BufferSpaceType {
     39        kMultiInstance,  // multiple independent sets of buffers
     40        kMultiKeyframe,  // single set of buffers, but can store multiple
     41                         // keyframes simultaneously.
     42        kSingleKeyframe  // single set of buffers, can only store one keyframe
     43                         // at a time.
     44      };
     45 
     46      int num_buffers;
     47      int max_references;
     48      int max_temporal_layers;
     49 
     50      BufferSpaceType buffer_space_type;
     51      int max_spatial_layers;
     52      std::vector<Rational> scaling_factors;
     53 
     54      std::vector<FrameType> supported_frame_types;
     55    } prediction_constraints;
     56 
     57    struct InputConstraints {
     58      Resolution min;
     59      Resolution max;
     60      int pixel_alignment;
     61      std::vector<VideoFrameBuffer::Type> input_formats;
     62    } input_constraints;
     63 
     64    std::vector<EncodingFormat> encoding_formats;
     65 
     66    struct BitrateControl {
     67      std::pair<int, int> qp_range;
     68      std::vector<RateControlMode> rc_modes;
     69    } rate_control;
     70 
     71    struct Performance {
     72      bool encode_on_calling_thread;
     73      std::pair<int, int> min_max_effort_level;
     74    } performance;
     75  };
     76 
     77  struct StaticEncoderSettings {
     78    struct Cqp {};
     79    struct Cbr {
     80      // TD: Should there be an intial buffer size?
     81      TimeDelta max_buffer_size;
     82      TimeDelta target_buffer_size;
     83    };
     84 
     85    Resolution max_encode_dimensions;
     86    EncodingFormat encoding_format;
     87    std::variant<Cqp, Cbr> rc_mode;
     88    int max_number_of_threads;
     89  };
     90 
     91  virtual ~VideoEncoderFactoryInterface() = default;
     92 
     93  virtual std::string CodecName() const = 0;
     94  virtual std::string ImplementationName() const = 0;
     95  virtual std::map<std::string, std::string> CodecSpecifics() const = 0;
     96 
     97  virtual Capabilities GetEncoderCapabilities() const = 0;
     98  virtual std::unique_ptr<VideoEncoderInterface> CreateEncoder(
     99      const StaticEncoderSettings& settings,
    100      const std::map<std::string, std::string>& encoder_specific_settings) = 0;
    101 };
    102 
    103 }  // namespace webrtc
    104 #endif  // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_INTERFACE_H_