Ring Daemon 16.0.0
Loading...
Searching...
No Matches
congestion_control.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
19#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
20
21#include <vector>
22#include <cstdint>
23
24#include "socket_pair.h"
25
26namespace jami {
27
29
30// Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
32{
33public:
36
37 uint64_t parseREMB(const rtcpREMBHeader& packet);
38 std::vector<uint8_t> createREMB(uint64_t bitrate_bps);
40 float update_thresh(float m, int deltaT);
41 float get_thresh();
43
44private:
45 using clock = std::chrono::steady_clock;
46 using time_point = clock::time_point;
47
48 float get_estimate_m(float k, int d_m);
49 float get_gain_k(float q, float dev_n);
50 float get_sys_var_p(float k, float q);
51 float get_var_n(int d_m);
52 float get_residual_z(float d_m);
53
54 float last_estimate_m_ {0.0f};
55 float last_var_p_ {0.1f};
56 float last_var_n_ {0.0f};
57
58 float last_thresh_y_ {2.0f};
59
60 unsigned overuse_counter_;
61 time_point t0_overuse {time_point::min()};
62
63 BandwidthUsage last_state_;
64};
65
66} // namespace jami
67#endif
float kalmanFilter(uint64_t gradiant_delay)
std::vector< uint8_t > createREMB(uint64_t bitrate_bps)
uint64_t parseREMB(const rtcpREMBHeader &packet)
BandwidthUsage get_bw_state(float estimation, float thresh)
float update_thresh(float m, int deltaT)
void emitSignal(Args... args)
Definition ring_signal.h:64