/* * Copyright 2018 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_RATE_CONTROLLER_H_ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_RATE_CONTROLLER_H_ #include #include "absl/types/optional.h" #include "api/transport/network_types.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "modules/congestion_controller/goog_cc/link_capacity_estimator.h" #include "modules/congestion_controller/goog_cc/packet_grouping.h" #include "modules/congestion_controller/goog_cc/trendline_estimator.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/experiments/field_trial_units.h" namespace webrtc { struct DelayBasedRateControllerConfig { FieldTrialFlag enabled; FieldTrialParameter no_ack_backoff_fraction; FieldTrialParameter no_ack_backoff_interval; FieldTrialParameter ack_backoff_fraction; FieldTrialParameter probe_backoff_fraction; FieldTrialParameter initial_increase_rate; FieldTrialParameter increase_rate; FieldTrialParameter first_period_increase_rate; FieldTrialParameter stop_increase_after; FieldTrialParameter min_increase_interval; FieldTrialParameter linear_increase_threshold; FieldTrialParameter reference_duration_offset; DelayBasedRateControllerConfig(); ~DelayBasedRateControllerConfig(); }; // Rate controller for GoogCC, increases the target rate based on a // fixed increase interval and an RTT dependent increase rate. class DelayBasedRateController { public: DelayBasedRateController(RtcEventLog* event_log, TargetRateConstraints constraints); ~DelayBasedRateController(); void OnRouteChange(); void UpdateConstraints(TargetRateConstraints constraints); void SetAcknowledgedRate(DataRate acknowledged_rate); void OnTransportPacketsFeedback(TransportPacketsFeedback msg, absl::optional probe_bitrate); void OnTimeUpdate(Timestamp at_time); void OnRemoteBitrateControl(RemoteBitrateReport msg); TimeDelta GetExpectedBandwidthPeriod() const; bool Enabled() const { return conf_.enabled; } DataRate target_rate() const; bool in_underuse() const; private: enum class ControllerSate { kHold, kExponentialIncrease, kLinearIncrease }; friend class GoogCcStatePrinter; void OnFeedbackUpdate(BandwidthUsage usage, absl::optional probe_bitrate, Timestamp at_time); void MaybeLog(); const DelayBasedRateControllerConfig conf_; RtcEventLog* event_log_; PacketDelayGrouper packet_grouper_; std::unique_ptr overuse_detector_; LinkCapacityEstimator link_capacity_; DataRate min_rate_ = DataRate::Zero(); DataRate max_rate_ = DataRate::Infinity(); absl::optional acknowledged_rate_; TimeDelta last_rtt_ = TimeDelta::seconds(1); Timestamp first_unacked_send_ = Timestamp::PlusInfinity(); Timestamp last_feedback_update_ = Timestamp::MinusInfinity(); DataRate target_rate_; Timestamp last_no_ack_backoff_ = Timestamp::MinusInfinity(); bool increasing_state_ = false; double accumulated_duration_ = 0; Timestamp last_increase_update_ = Timestamp::PlusInfinity(); DataRate increase_reference_ = DataRate::PlusInfinity(); absl::optional logged_state_; DataRate logged_target_ = DataRate::PlusInfinity(); }; } // namespace webrtc #endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_DELAY_BASED_RATE_CONTROLLER_H_