blob: faeb1d8fc4078bca71b30333539a716fdb8d58ce [file] [log] [blame]
tschumim82c55932017-07-11 06:56:04 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_PACING_INTERVAL_BUDGET_H_
12#define MODULES_PACING_INTERVAL_BUDGET_H_
tschumim82c55932017-07-11 06:56:04 -070013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stddef.h>
15#include <stdint.h>
tschumim82c55932017-07-11 06:56:04 -070016
17namespace webrtc {
18
19// TODO(tschumim): Reflector IntervalBudget so that we can set a under- and
20// over-use budget in ms.
21class 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 Olsson944dace2019-06-05 17:59:32 +020032 double budget_ratio() const;
tschumim82c55932017-07-11 06:56:04 -070033 int target_rate_kbps() const;
34
35 private:
36 int target_rate_kbps_;
Per Kjellanderb762b5b2019-06-18 16:59:04 +020037 int64_t max_bytes_in_budget_;
38 int64_t bytes_remaining_;
tschumim82c55932017-07-11 06:56:04 -070039 bool can_build_up_underuse_;
40};
41
42} // namespace webrtc
43
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020044#endif // MODULES_PACING_INTERVAL_BUDGET_H_