blob: faeb1d8fc4078bca71b30333539a716fdb8d58ce [file] [log] [blame]
tschumim82c55932017-07-11 13:56:041/*
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 04:47:3111#ifndef MODULES_PACING_INTERVAL_BUDGET_H_
12#define MODULES_PACING_INTERVAL_BUDGET_H_
tschumim82c55932017-07-11 13:56:0413
Yves Gerey988cc082018-10-23 10:03:0114#include <stddef.h>
15#include <stdint.h>
tschumim82c55932017-07-11 13:56:0416
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 15:59:3232 double budget_ratio() const;
tschumim82c55932017-07-11 13:56:0433 int target_rate_kbps() const;
34
35 private:
36 int target_rate_kbps_;
Per Kjellanderb762b5b2019-06-18 14:59:0437 int64_t max_bytes_in_budget_;
38 int64_t bytes_remaining_;
tschumim82c55932017-07-11 13:56:0439 bool can_build_up_underuse_;
40};
41
42} // namespace webrtc
43
Mirko Bonadei92ea95e2017-09-15 04:47:3144#endif // MODULES_PACING_INTERVAL_BUDGET_H_