Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 1 | /* |
| 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 Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 14 | #include <optional> |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 15 | #include <string> |
| 16 | |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 17 | #include "api/field_trials_view.h" |
Artem Titov | d15a575 | 2021-02-10 13:31:24 | [diff] [blame] | 18 | #include "api/sequence_checker.h" |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 19 | #include "call/adaptation/adaptation_constraint.h" |
| 20 | #include "call/adaptation/degradation_preference_provider.h" |
| 21 | #include "rtc_base/experiments/balanced_degradation_settings.h" |
Mirko Bonadei | 20e4c80 | 2020-11-23 10:07:42 | [diff] [blame] | 22 | #include "rtc_base/system/no_unique_address.h" |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
| 25 | |
Evan Shrubsole | 8572841 | 2020-08-25 11:12:12 | [diff] [blame] | 26 | class BalancedConstraint : public AdaptationConstraint { |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 27 | public: |
Jonas Oreland | c7f691a | 2022-03-09 14:12:07 | [diff] [blame] | 28 | BalancedConstraint( |
| 29 | DegradationPreferenceProvider* degradation_preference_provider, |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 30 | const FieldTrialsView& field_trials); |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 31 | ~BalancedConstraint() override = default; |
| 32 | |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 33 | void OnEncoderTargetBitrateUpdated( |
Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 34 | std::optional<uint32_t> encoder_target_bitrate_bps); |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 35 | |
| 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 Bonadei | 20e4c80 | 2020-11-23 10:07:42 | [diff] [blame] | 44 | RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_; |
Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 45 | std::optional<uint32_t> encoder_target_bitrate_bps_ |
Evan Shrubsole | 8572841 | 2020-08-25 11:12:12 | [diff] [blame] | 46 | RTC_GUARDED_BY(&sequence_checker_); |
| 47 | const BalancedDegradationSettings balanced_settings_; |
| 48 | const DegradationPreferenceProvider* degradation_preference_provider_; |
Evan Shrubsole | 00ea628 | 2020-08-13 11:46:06 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace webrtc |
| 52 | |
| 53 | #endif // VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_ |