blob: 64bc88cbce9dbe7bd6126ae974c08c6479f2c806 [file] [log] [blame]
Åsa Perssona7e34d32021-01-20 15:36:13 +01001/*
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
21namespace webrtc {
22
23class 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
Åsa Persson258e9892021-02-25 10:39:51 +010044 static std::vector<VideoEncoder::ResolutionBitrateLimits>
45 GetDefaultSinglecastBitrateLimits();
46 static absl::optional<VideoEncoder::ResolutionBitrateLimits>
47 GetDefaultSinglecastBitrateLimitsForResolution(int frame_size_pixels);
48
Åsa Perssona7e34d32021-01-20 15:36:13 +010049 protected:
50 explicit EncoderInfoSettings(std::string name);
51
52 private:
53 FieldTrialOptional<int> requested_resolution_alignment_;
54 FieldTrialFlag apply_alignment_to_all_simulcast_layers_;
55 std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits_;
56};
57
58// EncoderInfo settings for SimulcastEncoderAdapter.
59class SimulcastEncoderAdapterEncoderInfoSettings : public EncoderInfoSettings {
60 public:
61 SimulcastEncoderAdapterEncoderInfoSettings();
62 ~SimulcastEncoderAdapterEncoderInfoSettings() override {}
63};
64
Åsa Persson9111bd12021-02-03 10:16:30 +010065// EncoderInfo settings for LibvpxVp8Encoder.
66class LibvpxVp8EncoderInfoSettings : public EncoderInfoSettings {
67 public:
68 LibvpxVp8EncoderInfoSettings();
69 ~LibvpxVp8EncoderInfoSettings() override {}
70};
71
Åsa Perssonc91c4232021-02-01 09:20:05 +010072// EncoderInfo settings for LibvpxVp9Encoder.
73class LibvpxVp9EncoderInfoSettings : public EncoderInfoSettings {
74 public:
75 LibvpxVp9EncoderInfoSettings();
76 ~LibvpxVp9EncoderInfoSettings() override {}
77};
78
Åsa Perssona7e34d32021-01-20 15:36:13 +010079} // namespace webrtc
80
81#endif // RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_