encoder_bitrate_filter.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_CODEC_ENCODER_BITRATE_FILTER_H_
  5. #define REMOTING_CODEC_ENCODER_BITRATE_FILTER_H_
  6. #include "remoting/base/weighted_samples.h"
  7. namespace remoting {
  8. // Receives bandwidth estimations, frame size, etc and decide the best bitrate
  9. // for encoder.
  10. class EncoderBitrateFilter final {
  11. public:
  12. explicit EncoderBitrateFilter(int minimum_bitrate_kbps_per_megapixel);
  13. ~EncoderBitrateFilter();
  14. void SetBandwidthEstimateKbps(int bandwidth_kbps);
  15. void SetFrameSize(int width, int height);
  16. int GetTargetBitrateKbps() const;
  17. private:
  18. const int minimum_bitrate_kbps_per_megapixel_;
  19. // This is the minimum number to avoid returning unreasonable value from
  20. // GetTargetBitrateKbps(). It roughly equals to the minimum bitrate of a 780 x
  21. // 512 screen for VP8, or 1024 x 558 screen for H264.
  22. int minimum_bitrate_kbps_ = 1000;
  23. WeightedSamples bandwidth_kbps_;
  24. int bitrate_kbps_ = minimum_bitrate_kbps_;
  25. };
  26. } // namespace remoting
  27. #endif // REMOTING_CODEC_ENCODER_BITRATE_FILTER_H_