1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_VIDEO_VIDEO_ENCODER_INFO_H_ 6 #define MEDIA_VIDEO_VIDEO_ENCODER_INFO_H_ 7 8 #include <stdint.h> 9 #include <string> 10 #include <vector> 11 12 #include "base/optional.h" 13 #include "media/base/media_export.h" 14 #include "ui/gfx/geometry/size.h" 15 16 namespace media { 17 18 // These chromium classes are the corresponding classes in webrtc project. 19 // See third_party/webrtc/api/video_codecs/video_encoder.h for the detail. 20 21 struct MEDIA_EXPORT ScalingSettings { 22 ScalingSettings(); 23 ScalingSettings(int min_qp, int max_qp); 24 ScalingSettings(const ScalingSettings&); 25 ~ScalingSettings(); 26 27 // Quantization Parameter in ScalingSettings are codec specific. 28 // The range of qp is 0-51 (H264), 0-127 (VP8) and 0-255 (VP9 and AV1). 29 int min_qp = 0; 30 int max_qp = 255; 31 }; 32 33 struct MEDIA_EXPORT ResolutionBitrateLimit { 34 ResolutionBitrateLimit(); 35 ResolutionBitrateLimit(const ResolutionBitrateLimit&); 36 ResolutionBitrateLimit(const gfx::Size& frame_size, 37 int min_start_bitrate_bps, 38 int min_bitrate_bps, 39 int max_bitrate_bps); 40 ~ResolutionBitrateLimit(); 41 42 gfx::Size frame_size; 43 int min_start_bitrate_bps = 0; 44 int min_bitrate_bps = 0; 45 int max_bitrate_bps = 0; 46 }; 47 48 struct MEDIA_EXPORT VideoEncoderInfo { 49 static constexpr size_t kMaxSpatialLayers = 5; 50 51 VideoEncoderInfo(); 52 VideoEncoderInfo(const VideoEncoderInfo&); 53 ~VideoEncoderInfo(); 54 55 std::string implementation_name; 56 57 bool supports_native_handle = true; 58 bool has_trusted_rate_controller = false; 59 bool is_hardware_accelerated = true; 60 bool supports_simulcast = false; 61 62 base::Optional<ScalingSettings> scaling_settings; 63 std::vector<uint8_t> fps_allocation[kMaxSpatialLayers]; 64 std::vector<ResolutionBitrateLimit> resolution_bitrate_limits; 65 }; 66 67 MEDIA_EXPORT bool operator==(const ScalingSettings& l, 68 const ScalingSettings& r); 69 MEDIA_EXPORT bool operator==(const ResolutionBitrateLimit& l, 70 const ResolutionBitrateLimit& r); 71 MEDIA_EXPORT bool operator==(const VideoEncoderInfo& l, 72 const VideoEncoderInfo& r); 73 } // namespace media 74 75 #endif // MEDIA_VIDEO_VIDEO_ENCODER_INFO_H_ 76