bitrate_controller.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifndef MODULES_CONGESTION_CONTROLLER_PCC_BITRATE_CONTROLLER_H_
  11. #define MODULES_CONGESTION_CONTROLLER_PCC_BITRATE_CONTROLLER_H_
  12. #include <stdint.h>
  13. #include <memory>
  14. #include <vector>
  15. #include "absl/types/optional.h"
  16. #include "api/units/data_rate.h"
  17. #include "modules/congestion_controller/pcc/monitor_interval.h"
  18. #include "modules/congestion_controller/pcc/utility_function.h"
  19. namespace webrtc {
  20. namespace pcc {
  21. class PccBitrateController {
  22. public:
  23. PccBitrateController(double initial_conversion_factor,
  24. double initial_dynamic_boundary,
  25. double dynamic_boundary_increment,
  26. double rtt_gradient_coefficient,
  27. double loss_coefficient,
  28. double throughput_coefficient,
  29. double throughput_power,
  30. double rtt_gradient_threshold,
  31. double delay_gradient_negative_bound);
  32. PccBitrateController(
  33. double initial_conversion_factor,
  34. double initial_dynamic_boundary,
  35. double dynamic_boundary_increment,
  36. std::unique_ptr<PccUtilityFunctionInterface> utility_function);
  37. absl::optional<DataRate> ComputeRateUpdateForSlowStartMode(
  38. const PccMonitorInterval& monitor_interval);
  39. DataRate ComputeRateUpdateForOnlineLearningMode(
  40. const std::vector<PccMonitorInterval>& block,
  41. DataRate bandwidth_estimate);
  42. ~PccBitrateController();
  43. private:
  44. double ApplyDynamicBoundary(double rate_change, double bitrate);
  45. double ComputeStepSize(double utility_gradient);
  46. // Dynamic boundary variables:
  47. int64_t consecutive_boundary_adjustments_number_;
  48. const double initial_dynamic_boundary_;
  49. const double dynamic_boundary_increment_;
  50. const std::unique_ptr<PccUtilityFunctionInterface> utility_function_;
  51. // Step Size variables:
  52. int64_t step_size_adjustments_number_;
  53. const double initial_conversion_factor_;
  54. absl::optional<double> previous_utility_;
  55. };
  56. } // namespace pcc
  57. } // namespace webrtc
  58. #endif // MODULES_CONGESTION_CONTROLLER_PCC_BITRATE_CONTROLLER_H_