Åsa Persson | a7e34d3 | 2021-01-20 15:36:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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 RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_ |
| 12 | #define RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "absl/types/optional.h" |
| 18 | #include "api/video_codecs/video_encoder.h" |
| 19 | #include "rtc_base/experiments/field_trial_parser.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class EncoderInfoSettings { |
| 24 | public: |
| 25 | virtual ~EncoderInfoSettings(); |
| 26 | |
| 27 | // Bitrate limits per resolution. |
| 28 | struct BitrateLimit { |
| 29 | int frame_size_pixels = 0; // The video frame size. |
| 30 | int min_start_bitrate_bps = 0; // The minimum bitrate to start encoding. |
| 31 | int min_bitrate_bps = 0; // The minimum bitrate. |
| 32 | int max_bitrate_bps = 0; // The maximum bitrate. |
| 33 | }; |
| 34 | |
| 35 | absl::optional<int> requested_resolution_alignment() const; |
| 36 | bool apply_alignment_to_all_simulcast_layers() const { |
| 37 | return apply_alignment_to_all_simulcast_layers_.Get(); |
| 38 | } |
| 39 | std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits() |
| 40 | const { |
| 41 | return resolution_bitrate_limits_; |
| 42 | } |
| 43 | |
| 44 | protected: |
| 45 | explicit EncoderInfoSettings(std::string name); |
| 46 | |
| 47 | private: |
| 48 | FieldTrialOptional<int> requested_resolution_alignment_; |
| 49 | FieldTrialFlag apply_alignment_to_all_simulcast_layers_; |
| 50 | std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits_; |
| 51 | }; |
| 52 | |
| 53 | // EncoderInfo settings for SimulcastEncoderAdapter. |
| 54 | class SimulcastEncoderAdapterEncoderInfoSettings : public EncoderInfoSettings { |
| 55 | public: |
| 56 | SimulcastEncoderAdapterEncoderInfoSettings(); |
| 57 | ~SimulcastEncoderAdapterEncoderInfoSettings() override {} |
| 58 | }; |
| 59 | |
Åsa Persson | 9111bd1 | 2021-02-03 10:16:30 +0100 | [diff] [blame] | 60 | // EncoderInfo settings for LibvpxVp8Encoder. |
| 61 | class LibvpxVp8EncoderInfoSettings : public EncoderInfoSettings { |
| 62 | public: |
| 63 | LibvpxVp8EncoderInfoSettings(); |
| 64 | ~LibvpxVp8EncoderInfoSettings() override {} |
| 65 | }; |
| 66 | |
Åsa Persson | c91c423 | 2021-02-01 09:20:05 +0100 | [diff] [blame] | 67 | // EncoderInfo settings for LibvpxVp9Encoder. |
| 68 | class LibvpxVp9EncoderInfoSettings : public EncoderInfoSettings { |
| 69 | public: |
| 70 | LibvpxVp9EncoderInfoSettings(); |
| 71 | ~LibvpxVp9EncoderInfoSettings() override {} |
| 72 | }; |
| 73 | |
Åsa Persson | a7e34d3 | 2021-01-20 15:36:13 +0100 | [diff] [blame] | 74 | } // namespace webrtc |
| 75 | |
| 76 | #endif // RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_ |