diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 756e1cc16f..8f7bba7202 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -88,7 +88,6 @@ rtc_library("goog_cc") { "..:network_state_predictor_api", "../../api/units:time_delta", "../../modules/congestion_controller/goog_cc", - "../../rtc_base:checks", ] } diff --git a/api/transport/goog_cc_factory.cc b/api/transport/goog_cc_factory.cc index fa1c486dd2..036a399f5d 100644 --- a/api/transport/goog_cc_factory.cc +++ b/api/transport/goog_cc_factory.cc @@ -15,7 +15,6 @@ #include "api/units/time_delta.h" #include "modules/congestion_controller/goog_cc/goog_cc_network_control.h" -#include "rtc_base/checks.h" namespace webrtc { @@ -28,10 +27,9 @@ GoogCcNetworkControllerFactory::Create(NetworkControllerConfig config) { GoogCcConfig goog_cc_config; goog_cc_config.feedback_only = factory_config_.feedback_only; if (factory_config_.network_state_estimator_factory) { - RTC_DCHECK(config.key_value_config); goog_cc_config.network_state_estimator = factory_config_.network_state_estimator_factory->Create( - config.key_value_config); + &config.env.field_trials()); } if (factory_config_.network_state_predictor_factory) { goog_cc_config.network_state_predictor = diff --git a/api/transport/network_control.h b/api/transport/network_control.h index 3b76dff155..c7a7a981a5 100644 --- a/api/transport/network_control.h +++ b/api/transport/network_control.h @@ -36,11 +36,9 @@ class TargetTransferRateObserver { // Configuration sent to factory create function. The parameters here are // optional to use for a network controller implementation. struct NetworkControllerConfig { - // TODO: bugs.webrtc.org/42220378 - Delete the default constructor and - // thus make Environment (including field trials) a required parameter. - [[deprecated]] NetworkControllerConfig() = default; - explicit NetworkControllerConfig(const Environment& env) - : key_value_config(&env.field_trials()), event_log(&env.event_log()) {} + explicit NetworkControllerConfig(const Environment& env) : env(env) {} + + Environment env; // The initial constraints to start with, these can be changed at any later // time by calls to OnTargetRateConstraints. Note that the starting rate @@ -50,12 +48,6 @@ struct NetworkControllerConfig { // Initial stream specific configuration, these are changed at any later time // by calls to OnStreamsConfig. StreamsConfig stream_based_config; - - // Optional override of configuration of WebRTC internals. Using nullptr here - // indicates that the field trial API will be used. - const FieldTrialsView* key_value_config = nullptr; - // Optional override of event log. - RtcEventLog* event_log = nullptr; }; // NetworkControllerInterface is implemented by network controllers. A network diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 656ccdb7b2..dd7d2db244 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -33,8 +33,8 @@ rtc_library("goog_cc") { ":send_side_bwe", "../../../api:field_trials_view", "../../../api:network_state_predictor_api", + "../../../api/environment", "../../../api/rtc_event_log", - "../../../api/transport:field_trial_based_config", "../../../api/transport:network_control", "../../../api/units:data_rate", "../../../api/units:data_size", diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 7f958c9f24..cbaabfa75b 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -22,6 +22,7 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/network_state_predictor.h" #include "api/transport/network_control.h" @@ -93,46 +94,45 @@ BandwidthLimitedCause GetBandwidthLimitedCause(LossBasedState loss_based_state, GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config, GoogCcConfig goog_cc_config) - : key_value_config_(config.key_value_config ? config.key_value_config - : &trial_based_config_), - event_log_(config.event_log), + : env_(config.env), packet_feedback_only_(goog_cc_config.feedback_only), safe_reset_on_route_change_("Enabled"), safe_reset_acknowledged_rate_("ack"), use_min_allocatable_as_lower_bound_( - !key_value_config_->IsDisabled("WebRTC-Bwe-MinAllocAsLowerBound")), - ignore_probes_lower_than_network_estimate_(!key_value_config_->IsDisabled( - "WebRTC-Bwe-IgnoreProbesLowerThanNetworkStateEstimate")), + !env_.field_trials().IsDisabled("WebRTC-Bwe-MinAllocAsLowerBound")), + ignore_probes_lower_than_network_estimate_( + !env_.field_trials().IsDisabled( + "WebRTC-Bwe-IgnoreProbesLowerThanNetworkStateEstimate")), limit_probes_lower_than_throughput_estimate_( - !key_value_config_->IsDisabled( + !env_.field_trials().IsDisabled( "WebRTC-Bwe-LimitProbesLowerThanThroughputEstimate")), - rate_control_settings_(*key_value_config_), - pace_at_max_of_bwe_and_lower_link_capacity_(key_value_config_->IsEnabled( + rate_control_settings_(env_.field_trials()), + pace_at_max_of_bwe_and_lower_link_capacity_(env_.field_trials().IsEnabled( "WebRTC-Bwe-PaceAtMaxOfBweAndLowerLinkCapacity")), limit_pacingfactor_by_upper_link_capacity_estimate_( - key_value_config_->IsEnabled( + env_.field_trials().IsEnabled( "WebRTC-Bwe-LimitPacingFactorByUpperLinkCapacityEstimate")), probe_controller_( - new ProbeController(key_value_config_, config.event_log)), + new ProbeController(&env_.field_trials(), &env_.event_log())), congestion_window_pushback_controller_( rate_control_settings_.UseCongestionWindowPushback() ? std::make_unique( - *key_value_config_) + env_.field_trials()) : nullptr), bandwidth_estimation_( - std::make_unique(key_value_config_, - event_log_)), - alr_detector_( - std::make_unique(key_value_config_, config.event_log)), - probe_bitrate_estimator_(new ProbeBitrateEstimator(config.event_log)), + std::make_unique(&env_.field_trials(), + &env_.event_log())), + alr_detector_(std::make_unique(&env_.field_trials(), + &env_.event_log())), + probe_bitrate_estimator_(new ProbeBitrateEstimator(&env_.event_log())), network_estimator_(std::move(goog_cc_config.network_state_estimator)), network_state_predictor_( std::move(goog_cc_config.network_state_predictor)), - delay_based_bwe_(new DelayBasedBwe(key_value_config_, - event_log_, + delay_based_bwe_(new DelayBasedBwe(&env_.field_trials(), + &env_.event_log(), network_state_predictor_.get())), acknowledged_bitrate_estimator_( - AcknowledgedBitrateEstimatorInterface::Create(key_value_config_)), + AcknowledgedBitrateEstimatorInterface::Create(&env_.field_trials())), initial_config_(config), last_loss_based_target_rate_(*config.constraints.starting_rate), last_pushback_target_rate_(last_loss_based_target_rate_), @@ -148,7 +148,7 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config, RTC_DCHECK(config.constraints.at_time.IsFinite()); ParseFieldTrial( {&safe_reset_on_route_change_, &safe_reset_acknowledged_rate_}, - key_value_config_->Lookup("WebRTC-Bwe-SafeResetOnRouteChange")); + env_.field_trials().Lookup("WebRTC-Bwe-SafeResetOnRouteChange")); if (delay_based_bwe_) delay_based_bwe_->SetMinBitrate(kCongestionControllerMinBitrate); } @@ -184,12 +184,12 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkRouteChange( } acknowledged_bitrate_estimator_ = - AcknowledgedBitrateEstimatorInterface::Create(key_value_config_); - probe_bitrate_estimator_.reset(new ProbeBitrateEstimator(event_log_)); + AcknowledgedBitrateEstimatorInterface::Create(&env_.field_trials()); + probe_bitrate_estimator_.reset(new ProbeBitrateEstimator(&env_.event_log())); if (network_estimator_) network_estimator_->OnRouteChange(msg); - delay_based_bwe_.reset(new DelayBasedBwe(key_value_config_, event_log_, - network_state_predictor_.get())); + delay_based_bwe_.reset(new DelayBasedBwe( + &env_.field_trials(), &env_.event_log(), network_state_predictor_.get())); bandwidth_estimation_->OnRouteChange(); probe_controller_->Reset(msg.at_time); NetworkControlUpdate update; @@ -527,7 +527,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( // changed to avoid the need for this check. if (estimate_ && (!prev_estimate || estimate_->last_feed_time != prev_estimate->last_feed_time)) { - event_log_->Log(std::make_unique( + env_.event_log().Log(std::make_unique( estimate_->link_capacity_lower, estimate_->link_capacity_upper)); probe_controller_->SetNetworkStateEstimate(*estimate_); } diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.h b/modules/congestion_controller/goog_cc/goog_cc_network_control.h index 2b4fb6e35c..63691a7a28 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -20,8 +20,6 @@ #include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/network_state_predictor.h" -#include "api/rtc_event_log/rtc_event_log.h" -#include "api/transport/field_trial_based_config.h" #include "api/transport/network_control.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -84,10 +82,8 @@ class GoogCcNetworkController : public NetworkControllerInterface { Timestamp at_time); void UpdateCongestionWindowSize(); PacerConfig GetPacingRates(Timestamp at_time) const; - const FieldTrialBasedConfig trial_based_config_; - const FieldTrialsView* const key_value_config_; - RtcEventLog* const event_log_; + const Environment env_; const bool packet_feedback_only_; FieldTrialFlag safe_reset_on_route_change_; FieldTrialFlag safe_reset_acknowledged_rate_;