blob: 9cbb5875bbbdb3d88c38b4378466a7fb141cb03d [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>
Sergey Silkina86b29b2021-03-05 13:29:19 +010045 GetDefaultSinglecastBitrateLimits(VideoCodecType codec_type);
46
Åsa Persson258e9892021-02-25 10:39:51 +010047 static absl::optional<VideoEncoder::ResolutionBitrateLimits>
Sergey Silkina86b29b2021-03-05 13:29:19 +010048 GetDefaultSinglecastBitrateLimitsForResolution(VideoCodecType codec_type,
49 int frame_size_pixels);
Åsa Persson258e9892021-02-25 10:39:51 +010050
Åsa Perssona7e34d32021-01-20 15:36:13 +010051 protected:
52 explicit EncoderInfoSettings(std::string name);
53
54 private:
55 FieldTrialOptional<int> requested_resolution_alignment_;
56 FieldTrialFlag apply_alignment_to_all_simulcast_layers_;
57 std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits_;
58};
59
60// EncoderInfo settings for SimulcastEncoderAdapter.
61class SimulcastEncoderAdapterEncoderInfoSettings : public EncoderInfoSettings {
62 public:
63 SimulcastEncoderAdapterEncoderInfoSettings();
64 ~SimulcastEncoderAdapterEncoderInfoSettings() override {}
65};
66
Åsa Persson9111bd12021-02-03 10:16:30 +010067// EncoderInfo settings for LibvpxVp8Encoder.
68class LibvpxVp8EncoderInfoSettings : public EncoderInfoSettings {
69 public:
70 LibvpxVp8EncoderInfoSettings();
71 ~LibvpxVp8EncoderInfoSettings() override {}
72};
73
Åsa Perssonc91c4232021-02-01 09:20:05 +010074// EncoderInfo settings for LibvpxVp9Encoder.
75class LibvpxVp9EncoderInfoSettings : public EncoderInfoSettings {
76 public:
77 LibvpxVp9EncoderInfoSettings();
78 ~LibvpxVp9EncoderInfoSettings() override {}
79};
80
Åsa Perssona7e34d32021-01-20 15:36:13 +010081} // namespace webrtc
82
83#endif // RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_