bitrate_constraint.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_BITRATE_CONSTRAINT_H_
  11. #define VIDEO_ADAPTATION_BITRATE_CONSTRAINT_H_
  12. #include <string>
  13. #include "absl/types/optional.h"
  14. #include "call/adaptation/adaptation_constraint.h"
  15. #include "call/adaptation/encoder_settings.h"
  16. #include "call/adaptation/video_source_restrictions.h"
  17. #include "call/adaptation/video_stream_input_state.h"
  18. #include "rtc_base/synchronization/sequence_checker.h"
  19. #include "rtc_base/system/no_unique_address.h"
  20. namespace webrtc {
  21. class BitrateConstraint : public AdaptationConstraint {
  22. public:
  23. BitrateConstraint();
  24. ~BitrateConstraint() override = default;
  25. void OnEncoderSettingsUpdated(
  26. absl::optional<EncoderSettings> encoder_settings);
  27. void OnEncoderTargetBitrateUpdated(
  28. absl::optional<uint32_t> encoder_target_bitrate_bps);
  29. // AdaptationConstraint implementation.
  30. std::string Name() const override { return "BitrateConstraint"; }
  31. bool IsAdaptationUpAllowed(
  32. const VideoStreamInputState& input_state,
  33. const VideoSourceRestrictions& restrictions_before,
  34. const VideoSourceRestrictions& restrictions_after) const override;
  35. private:
  36. RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
  37. absl::optional<EncoderSettings> encoder_settings_
  38. RTC_GUARDED_BY(&sequence_checker_);
  39. absl::optional<uint32_t> encoder_target_bitrate_bps_
  40. RTC_GUARDED_BY(&sequence_checker_);
  41. };
  42. } // namespace webrtc
  43. #endif // VIDEO_ADAPTATION_BITRATE_CONSTRAINT_H_