blob: f608590583bdb811f846a43ca9e3588745392488 [file] [log] [blame]
Ying Wange1d7b232018-07-17 16:01:25 +02001/*
2 * Copyright (c) 2018 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
11#ifndef MODULES_CONGESTION_CONTROLLER_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_
12#define MODULES_CONGESTION_CONTROLLER_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_
13
14#include "api/transport/network_types.h"
15#include "common_types.h" // NOLINT(build/include)
16#include "rtc_base/criticalsection.h"
17#include "rtc_base/format_macros.h"
18
19namespace webrtc {
20
21// This class enables pushback from congestion window directly to video encoder.
22// When the congestion window is filling up, the video encoder target bitrate
23// will be reduced accordingly to accommodate the network changes. To avoid
24// pausing video too frequently, a minimum encoder target bitrate threshold is
25// used to prevent video pause due to a full congestion window.
26class CongestionWindowPushbackController {
27 public:
28 CongestionWindowPushbackController();
29 void UpdateOutstandingData(size_t outstanding_bytes);
30 void UpdateMaxOutstandingData(size_t max_outstanding_bytes);
31 uint32_t UpdateTargetBitrate(uint32_t bitrate_bps);
32 void SetDataWindow(DataSize data_window);
33
34 private:
35 absl::optional<DataSize> current_data_window_;
36 size_t outstanding_bytes_ = 0;
37 uint32_t min_pushback_target_bitrate_bps_;
38 double encoding_rate_ratio_ = 1.0;
39};
40
41} // namespace webrtc
42
43#endif // MODULES_CONGESTION_CONTROLLER_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_