1 /* 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_GOOG_CC_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_ 12 #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include "absl/types/optional.h" 18 #include "api/transport/webrtc_key_value_config.h" 19 #include "api/units/data_size.h" 20 21 namespace webrtc { 22 23 // This class enables pushback from congestion window directly to video encoder. 24 // When the congestion window is filling up, the video encoder target bitrate 25 // will be reduced accordingly to accommodate the network changes. To avoid 26 // pausing video too frequently, a minimum encoder target bitrate threshold is 27 // used to prevent video pause due to a full congestion window. 28 class CongestionWindowPushbackController { 29 public: 30 explicit CongestionWindowPushbackController( 31 const WebRtcKeyValueConfig* key_value_config); 32 void UpdateOutstandingData(int64_t outstanding_bytes); 33 void UpdatePacingQueue(int64_t pacing_bytes); 34 uint32_t UpdateTargetBitrate(uint32_t bitrate_bps); 35 void SetDataWindow(DataSize data_window); 36 37 private: 38 const bool add_pacing_; 39 const uint32_t min_pushback_target_bitrate_bps_; 40 absl::optional<DataSize> current_data_window_; 41 int64_t outstanding_bytes_ = 0; 42 int64_t pacing_bytes_ = 0; 43 double encoding_rate_ratio_ = 1.0; 44 }; 45 46 } // namespace webrtc 47 48 #endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_CONGESTION_WINDOW_PUSHBACK_CONTROLLER_H_ 49