tschumim | 82c5593 | 2017-07-11 13:56:04 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #ifndef MODULES_PACING_INTERVAL_BUDGET_H_ |
| 12 | #define MODULES_PACING_INTERVAL_BUDGET_H_ |
tschumim | 82c5593 | 2017-07-11 13:56:04 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 10:03:01 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
tschumim | 82c5593 | 2017-07-11 13:56:04 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | // TODO(tschumim): Reflector IntervalBudget so that we can set a under- and |
| 20 | // over-use budget in ms. |
| 21 | class IntervalBudget { |
| 22 | public: |
| 23 | explicit IntervalBudget(int initial_target_rate_kbps); |
| 24 | IntervalBudget(int initial_target_rate_kbps, bool can_build_up_underuse); |
| 25 | void set_target_rate_kbps(int target_rate_kbps); |
| 26 | |
| 27 | // TODO(tschumim): Unify IncreaseBudget and UseBudget to one function. |
| 28 | void IncreaseBudget(int64_t delta_time_ms); |
| 29 | void UseBudget(size_t bytes); |
| 30 | |
| 31 | size_t bytes_remaining() const; |
Jonas Olsson | 944dace | 2019-06-05 15:59:32 | [diff] [blame] | 32 | double budget_ratio() const; |
tschumim | 82c5593 | 2017-07-11 13:56:04 | [diff] [blame] | 33 | int target_rate_kbps() const; |
| 34 | |
| 35 | private: |
| 36 | int target_rate_kbps_; |
Per Kjellander | b762b5b | 2019-06-18 14:59:04 | [diff] [blame] | 37 | int64_t max_bytes_in_budget_; |
| 38 | int64_t bytes_remaining_; |
tschumim | 82c5593 | 2017-07-11 13:56:04 | [diff] [blame] | 39 | bool can_build_up_underuse_; |
| 40 | }; |
| 41 | |
| 42 | } // namespace webrtc |
| 43 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 44 | #endif // MODULES_PACING_INTERVAL_BUDGET_H_ |