2021-01-20 15:36:13 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2021 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_
|
|
|
|
|
#define RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2022-03-17 15:47:49 +01:00
|
|
|
#include "absl/strings/string_view.h"
|
2021-01-20 15:36:13 +01:00
|
|
|
#include "absl/types/optional.h"
|
2024-04-25 12:02:27 +02:00
|
|
|
#include "api/field_trials_view.h"
|
2021-01-20 15:36:13 +01:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
|
|
|
|
#include "rtc_base/experiments/field_trial_parser.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class EncoderInfoSettings {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~EncoderInfoSettings();
|
|
|
|
|
|
|
|
|
|
// Bitrate limits per resolution.
|
|
|
|
|
struct BitrateLimit {
|
|
|
|
|
int frame_size_pixels = 0; // The video frame size.
|
|
|
|
|
int min_start_bitrate_bps = 0; // The minimum bitrate to start encoding.
|
|
|
|
|
int min_bitrate_bps = 0; // The minimum bitrate.
|
|
|
|
|
int max_bitrate_bps = 0; // The maximum bitrate.
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-06 23:56:33 +08:00
|
|
|
absl::optional<uint32_t> requested_resolution_alignment() const;
|
2021-01-20 15:36:13 +01:00
|
|
|
bool apply_alignment_to_all_simulcast_layers() const {
|
|
|
|
|
return apply_alignment_to_all_simulcast_layers_.Get();
|
|
|
|
|
}
|
|
|
|
|
std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits()
|
|
|
|
|
const {
|
|
|
|
|
return resolution_bitrate_limits_;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 10:39:51 +01:00
|
|
|
static std::vector<VideoEncoder::ResolutionBitrateLimits>
|
2021-03-05 13:29:19 +01:00
|
|
|
GetDefaultSinglecastBitrateLimits(VideoCodecType codec_type);
|
|
|
|
|
|
2021-02-25 10:39:51 +01:00
|
|
|
static absl::optional<VideoEncoder::ResolutionBitrateLimits>
|
2021-03-05 13:29:19 +01:00
|
|
|
GetDefaultSinglecastBitrateLimitsForResolution(VideoCodecType codec_type,
|
|
|
|
|
int frame_size_pixels);
|
2021-09-29 17:19:44 +08:00
|
|
|
|
|
|
|
|
static std::vector<VideoEncoder::ResolutionBitrateLimits>
|
|
|
|
|
GetDefaultSinglecastBitrateLimitsWhenQpIsUntrusted();
|
|
|
|
|
|
|
|
|
|
static absl::optional<VideoEncoder::ResolutionBitrateLimits>
|
|
|
|
|
GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted(
|
|
|
|
|
absl::optional<int> frame_size_pixels,
|
|
|
|
|
const std::vector<VideoEncoder::ResolutionBitrateLimits>&
|
|
|
|
|
resolution_bitrate_limits);
|
2021-02-25 10:39:51 +01:00
|
|
|
|
2021-01-20 15:36:13 +01:00
|
|
|
protected:
|
2024-04-25 12:02:27 +02:00
|
|
|
EncoderInfoSettings(const FieldTrialsView& field_trials,
|
|
|
|
|
absl::string_view name);
|
2021-01-20 15:36:13 +01:00
|
|
|
|
|
|
|
|
private:
|
2022-12-06 23:56:33 +08:00
|
|
|
FieldTrialOptional<uint32_t> requested_resolution_alignment_;
|
2021-01-20 15:36:13 +01:00
|
|
|
FieldTrialFlag apply_alignment_to_all_simulcast_layers_;
|
|
|
|
|
std::vector<VideoEncoder::ResolutionBitrateLimits> resolution_bitrate_limits_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// EncoderInfo settings for SimulcastEncoderAdapter.
|
|
|
|
|
class SimulcastEncoderAdapterEncoderInfoSettings : public EncoderInfoSettings {
|
|
|
|
|
public:
|
2024-04-25 12:02:27 +02:00
|
|
|
explicit SimulcastEncoderAdapterEncoderInfoSettings(
|
|
|
|
|
const FieldTrialsView& field_trials);
|
2021-01-20 15:36:13 +01:00
|
|
|
~SimulcastEncoderAdapterEncoderInfoSettings() override {}
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-03 10:16:30 +01:00
|
|
|
// EncoderInfo settings for LibvpxVp8Encoder.
|
|
|
|
|
class LibvpxVp8EncoderInfoSettings : public EncoderInfoSettings {
|
|
|
|
|
public:
|
2024-04-25 12:02:27 +02:00
|
|
|
explicit LibvpxVp8EncoderInfoSettings(const FieldTrialsView& field_trials);
|
2021-02-03 10:16:30 +01:00
|
|
|
~LibvpxVp8EncoderInfoSettings() override {}
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-01 09:20:05 +01:00
|
|
|
// EncoderInfo settings for LibvpxVp9Encoder.
|
|
|
|
|
class LibvpxVp9EncoderInfoSettings : public EncoderInfoSettings {
|
|
|
|
|
public:
|
2024-04-25 12:02:27 +02:00
|
|
|
explicit LibvpxVp9EncoderInfoSettings(const FieldTrialsView& field_trials);
|
2021-02-01 09:20:05 +01:00
|
|
|
~LibvpxVp9EncoderInfoSettings() override {}
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-28 09:59:50 -06:00
|
|
|
// EncoderInfo settings for LibaomAv1Encoder.
|
|
|
|
|
class LibaomAv1EncoderInfoSettings : public EncoderInfoSettings {
|
|
|
|
|
public:
|
2024-04-25 12:02:27 +02:00
|
|
|
explicit LibaomAv1EncoderInfoSettings(const FieldTrialsView& field_trials);
|
2023-02-28 09:59:50 -06:00
|
|
|
~LibaomAv1EncoderInfoSettings() override {}
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-20 15:36:13 +01:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_
|