interval_budget.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2016 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 MODULES_PACING_INTERVAL_BUDGET_H_
  11. #define MODULES_PACING_INTERVAL_BUDGET_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. namespace webrtc {
  15. // TODO(tschumim): Reflector IntervalBudget so that we can set a under- and
  16. // over-use budget in ms.
  17. class IntervalBudget {
  18. public:
  19. explicit IntervalBudget(int initial_target_rate_kbps);
  20. IntervalBudget(int initial_target_rate_kbps, bool can_build_up_underuse);
  21. void set_target_rate_kbps(int target_rate_kbps);
  22. // TODO(tschumim): Unify IncreaseBudget and UseBudget to one function.
  23. void IncreaseBudget(int64_t delta_time_ms);
  24. void UseBudget(size_t bytes);
  25. size_t bytes_remaining() const;
  26. double budget_ratio() const;
  27. int target_rate_kbps() const;
  28. private:
  29. int target_rate_kbps_;
  30. int64_t max_bytes_in_budget_;
  31. int64_t bytes_remaining_;
  32. bool can_build_up_underuse_;
  33. };
  34. } // namespace webrtc
  35. #endif // MODULES_PACING_INTERVAL_BUDGET_H_