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 14 #include <string> 15 16 #include "absl/types/optional.h" 17 #include "api/field_trials_view.h" 18 #include "api/sequence_checker.h" 19 #include "call/adaptation/adaptation_constraint.h" 20 #include "call/adaptation/degradation_preference_provider.h" 21 #include "rtc_base/experiments/balanced_degradation_settings.h" 22 #include "rtc_base/system/no_unique_address.h" 23 24 namespace webrtc { 25 26 class BalancedConstraint : public AdaptationConstraint { 27 public: 28 BalancedConstraint( 29 DegradationPreferenceProvider* degradation_preference_provider, 30 const FieldTrialsView& field_trials); 31 ~BalancedConstraint() override = default; 32 33 void OnEncoderTargetBitrateUpdated( 34 absl::optional<uint32_t> encoder_target_bitrate_bps); 35 36 // AdaptationConstraint implementation. Name()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: 44 RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_; 45 absl::optional<uint32_t> encoder_target_bitrate_bps_ 46 RTC_GUARDED_BY(&sequence_checker_); 47 const BalancedDegradationSettings balanced_settings_; 48 const DegradationPreferenceProvider* degradation_preference_provider_; 49 }; 50 51 } // namespace webrtc 52 53 #endif // VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_ 54