Anastasia Koloskova | ea9249e | 2018-08-21 16:12:55 +0200 | [diff] [blame] | 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_PCC_BITRATE_CONTROLLER_H_ |
| 12 | #define MODULES_CONGESTION_CONTROLLER_PCC_BITRATE_CONTROLLER_H_ |
| 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 15 | |
Anastasia Koloskova | ea9249e | 2018-08-21 16:12:55 +0200 | [diff] [blame] | 16 | #include <memory> |
| 17 | #include <vector> |
| 18 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
| 20 | #include "api/units/data_rate.h" |
Anastasia Koloskova | ea9249e | 2018-08-21 16:12:55 +0200 | [diff] [blame] | 21 | #include "modules/congestion_controller/pcc/monitor_interval.h" |
| 22 | #include "modules/congestion_controller/pcc/utility_function.h" |
| 23 | |
| 24 | namespace webrtc { |
| 25 | namespace pcc { |
| 26 | |
| 27 | class PccBitrateController { |
| 28 | public: |
| 29 | PccBitrateController(double initial_conversion_factor, |
| 30 | double initial_dynamic_boundary, |
| 31 | double dynamic_boundary_increment, |
| 32 | double rtt_gradient_coefficient, |
| 33 | double loss_coefficient, |
| 34 | double throughput_coefficient, |
| 35 | double throughput_power, |
| 36 | double rtt_gradient_threshold, |
| 37 | double delay_gradient_negative_bound); |
| 38 | |
| 39 | PccBitrateController( |
| 40 | double initial_conversion_factor, |
| 41 | double initial_dynamic_boundary, |
| 42 | double dynamic_boundary_increment, |
| 43 | std::unique_ptr<PccUtilityFunctionInterface> utility_function); |
| 44 | |
| 45 | absl::optional<DataRate> ComputeRateUpdateForSlowStartMode( |
| 46 | const PccMonitorInterval& monitor_interval); |
| 47 | |
| 48 | DataRate ComputeRateUpdateForOnlineLearningMode( |
| 49 | const std::vector<PccMonitorInterval>& block, |
| 50 | DataRate bandwidth_estimate); |
| 51 | |
| 52 | ~PccBitrateController(); |
| 53 | |
| 54 | private: |
| 55 | double ApplyDynamicBoundary(double rate_change, double bitrate); |
| 56 | double ComputeStepSize(double utility_gradient); |
| 57 | |
| 58 | // Dynamic boundary variables: |
| 59 | int64_t consecutive_boundary_adjustments_number_; |
| 60 | const double initial_dynamic_boundary_; |
| 61 | const double dynamic_boundary_increment_; |
| 62 | |
| 63 | const std::unique_ptr<PccUtilityFunctionInterface> utility_function_; |
| 64 | // Step Size variables: |
| 65 | int64_t step_size_adjustments_number_; |
| 66 | const double initial_conversion_factor_; |
| 67 | |
| 68 | absl::optional<double> previous_utility_; |
| 69 | }; |
| 70 | |
| 71 | } // namespace pcc |
| 72 | } // namespace webrtc |
| 73 | |
| 74 | #endif // MODULES_CONGESTION_CONTROLLER_PCC_BITRATE_CONTROLLER_H_ |