balanced_constraint.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_
  11. #define VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_
  12. #include <string>
  13. #include "absl/types/optional.h"
  14. #include "call/adaptation/adaptation_constraint.h"
  15. #include "call/adaptation/degradation_preference_provider.h"
  16. #include "rtc_base/experiments/balanced_degradation_settings.h"
  17. #include "rtc_base/synchronization/sequence_checker.h"
  18. #include "rtc_base/system/no_unique_address.h"
  19. namespace webrtc {
  20. class BalancedConstraint : public AdaptationConstraint {
  21. public:
  22. explicit BalancedConstraint(
  23. DegradationPreferenceProvider* degradation_preference_provider);
  24. ~BalancedConstraint() override = default;
  25. void OnEncoderTargetBitrateUpdated(
  26. absl::optional<uint32_t> encoder_target_bitrate_bps);
  27. // AdaptationConstraint implementation.
  28. std::string Name() const override { return "BalancedConstraint"; }
  29. bool IsAdaptationUpAllowed(
  30. const VideoStreamInputState& input_state,
  31. const VideoSourceRestrictions& restrictions_before,
  32. const VideoSourceRestrictions& restrictions_after) const override;
  33. private:
  34. RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
  35. absl::optional<uint32_t> encoder_target_bitrate_bps_
  36. RTC_GUARDED_BY(&sequence_checker_);
  37. const BalancedDegradationSettings balanced_settings_;
  38. const DegradationPreferenceProvider* degradation_preference_provider_;
  39. };
  40. } // namespace webrtc
  41. #endif // VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_