blob: 294fe6f70c25fb1e97a3092aad2996116f1d21e3 [file] [log] [blame]
Evan Shrubsole00ea6282020-08-13 11:46:061/*
2 * Copyright 2020 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 VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_
12#define VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_
13
Florent Castelli8037fc62024-08-29 13:00:4014#include <optional>
Evan Shrubsole00ea6282020-08-13 11:46:0615#include <string>
16
Jonas Orelande62c2f22022-03-29 09:04:4817#include "api/field_trials_view.h"
Artem Titovd15a5752021-02-10 13:31:2418#include "api/sequence_checker.h"
Evan Shrubsole00ea6282020-08-13 11:46:0619#include "call/adaptation/adaptation_constraint.h"
20#include "call/adaptation/degradation_preference_provider.h"
21#include "rtc_base/experiments/balanced_degradation_settings.h"
Mirko Bonadei20e4c802020-11-23 10:07:4222#include "rtc_base/system/no_unique_address.h"
Evan Shrubsole00ea6282020-08-13 11:46:0623
24namespace webrtc {
25
Evan Shrubsole85728412020-08-25 11:12:1226class BalancedConstraint : public AdaptationConstraint {
Evan Shrubsole00ea6282020-08-13 11:46:0627 public:
Jonas Orelandc7f691a2022-03-09 14:12:0728 BalancedConstraint(
29 DegradationPreferenceProvider* degradation_preference_provider,
Jonas Orelande62c2f22022-03-29 09:04:4830 const FieldTrialsView& field_trials);
Evan Shrubsole00ea6282020-08-13 11:46:0631 ~BalancedConstraint() override = default;
32
Evan Shrubsole00ea6282020-08-13 11:46:0633 void OnEncoderTargetBitrateUpdated(
Florent Castelli8037fc62024-08-29 13:00:4034 std::optional<uint32_t> encoder_target_bitrate_bps);
Evan Shrubsole00ea6282020-08-13 11:46:0635
36 // AdaptationConstraint implementation.
37 std::string Name() const override { return "BalancedConstraint"; }
38 bool IsAdaptationUpAllowed(
39 const VideoStreamInputState& input_state,
40 const VideoSourceRestrictions& restrictions_before,
41 const VideoSourceRestrictions& restrictions_after) const override;
42
43 private:
Mirko Bonadei20e4c802020-11-23 10:07:4244 RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
Florent Castelli8037fc62024-08-29 13:00:4045 std::optional<uint32_t> encoder_target_bitrate_bps_
Evan Shrubsole85728412020-08-25 11:12:1246 RTC_GUARDED_BY(&sequence_checker_);
47 const BalancedDegradationSettings balanced_settings_;
48 const DegradationPreferenceProvider* degradation_preference_provider_;
Evan Shrubsole00ea6282020-08-13 11:46:0649};
50
51} // namespace webrtc
52
53#endif // VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_