32
32
#include " modules/remote_bitrate_estimator/test/bwe_test_logging.h"
33
33
#include " rtc_base/checks.h"
34
34
#include " rtc_base/logging.h"
35
+ #include " system_wrappers/include/field_trial.h"
35
36
#ifdef INTEL_GPRA
36
37
#include " gpra_bwe.h"
37
38
#endif
@@ -54,6 +55,39 @@ constexpr float kDefaultPaceMultiplier = 2.5f;
54
55
// However, if we actually are overusing, we want to drop to something slightly
55
56
// below the current throughput estimate to drain the network queues.
56
57
constexpr double kProbeDropThroughputFraction = 0.85 ;
58
+ }
59
+
60
+ bool AllowExternalBwe () {
61
+ #ifdef INTEL_GPRA
62
+ if (field_trial::IsEnabled (" OWT-ExternalBwe" )) {
63
+ return true ;
64
+ } else {
65
+ return false ;
66
+ }
67
+ #else
68
+ return false ;
69
+ #endif
70
+ }
71
+
72
+ bool GetExternalBweRateLimits (int * start_bitrate_kbps,
73
+ int * min_bitrate_kbps,
74
+ int * max_bitrate_kbps) {
75
+ std::string expr_str = webrtc::field_trial::FindFullName (" OWT-BweRateLimits" );
76
+ if (expr_str.empty ())
77
+ return false ;
78
+ int parsed_values =
79
+ sscanf_s (expr_str.c_str (), " Enabled-%u,%u,%u" , start_bitrate_kbps,
80
+ min_bitrate_kbps, max_bitrate_kbps);
81
+ if (parsed_values == 3 ) {
82
+ RTC_CHECK_GE (*start_bitrate_kbps, 0 )
83
+ << " start_bitrate_kbps must not be smaller than 0." ;
84
+ RTC_CHECK_GE (*min_bitrate_kbps, 0 )
85
+ << " min_bitrate_kbps must not be smaller than 0." ;
86
+ RTC_CHECK_GE (*max_bitrate_kbps, 0 )
87
+ << " max_bitrate_kbps must not be smaller than 0" ;
88
+ return true ;
89
+ }
90
+ return false ;
57
91
58
92
bool IsEnabled (const FieldTrialsView* config, absl::string_view key) {
59
93
return absl::StartsWith (config->Lookup (key), " Enabled" );
@@ -106,7 +140,13 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config,
106
140
network_state_predictor_(
107
141
std::move (goog_cc_config.network_state_predictor)),
108
142
#ifdef INTEL_GPRA
109
- delay_based_bwe_ (new GPRABwe()),
143
+ delay_based_bwe_ (AllowExternalBwe() ? new GPRABwe() : nullptr),
144
+ delay_based_bwe_gcc_(
145
+ AllowExternalBwe ()
146
+ ? nullptr
147
+ : new DelayBasedBwe(key_value_config_,
148
+ event_log_,
149
+ network_state_predictor_.get())),
110
150
#else
111
151
delay_based_bwe_ (new DelayBasedBwe(key_value_config_,
112
152
event_log_,
@@ -132,6 +172,25 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config,
132
172
key_value_config_->Lookup (" WebRTC-Bwe-SafeResetOnRouteChange" ));
133
173
if (delay_based_bwe_)
134
174
delay_based_bwe_->SetMinBitrate (kCongestionControllerMinBitrate );
175
+ if (delay_based_bwe_gcc_)
176
+ delay_based_bwe_gcc_->SetMinBitrate (congestion_controller::GetMinBitrate ());
177
+ if (AllowExternalBwe ()) {
178
+ if (GetExternalBweRateLimits (&external_start_bitrate_kbps_,
179
+ &external_min_bitrate_kbps_,
180
+ &external_max_bitrate_kbps_)) {
181
+ if (external_start_bitrate_kbps_ > 0 )
182
+ delay_based_bwe_->SetStartBitrate (
183
+ webrtc::DataRate::BitsPerSec (external_start_bitrate_kbps_ * 1024 ));
184
+ if (external_min_bitrate_kbps_ > 0 )
185
+ delay_based_bwe_->SetMinBitrate (
186
+ webrtc::DataRate::BitsPerSec (external_min_bitrate_kbps_ * 1024 ));
187
+ #ifdef INTEL_GPRA
188
+ // Only intel_gpra module allows setting maxbitrate.
189
+ if (external_max_bitrate_kbps_ > 0 )
190
+ delay_based_bwe_->SetMaxBitrate (external_max_bitrate_kbps_ * 1024 );
191
+ #endif
192
+ }
193
+ }
135
194
}
136
195
137
196
GoogCcNetworkController::~GoogCcNetworkController () {}
@@ -250,6 +309,10 @@ NetworkControlUpdate GoogCcNetworkController::OnRoundTripTimeUpdate(
250
309
RTC_DCHECK (!msg.round_trip_time .IsZero ());
251
310
if (delay_based_bwe_)
252
311
delay_based_bwe_->OnRttUpdate (msg.round_trip_time );
312
+ #ifdef INTEL_GPRA
313
+ if (delay_based_bwe_gcc_)
314
+ delay_based_bwe_gcc_->OnRttUpdate (msg.round_trip_time );
315
+ #endif
253
316
bandwidth_estimation_->UpdateRtt (msg.round_trip_time , msg.receive_time );
254
317
return NetworkControlUpdate ();
255
318
}
@@ -316,7 +379,12 @@ NetworkControlUpdate GoogCcNetworkController::OnStreamsConfig(
316
379
317
380
if (use_min_allocatable_as_lower_bound_) {
318
381
ClampConstraints ();
319
- delay_based_bwe_->SetMinBitrate (min_data_rate_);
382
+ if (delay_based_bwe_)
383
+ delay_based_bwe_->SetMinBitrate (min_data_rate_);
384
+ #ifdef INTEL_GPRA
385
+ if (delay_based_bwe_gcc_)
386
+ delay_based_bwe_gcc_->SetMinBitrate (min_data_rate_);
387
+ #endif
320
388
bandwidth_estimation_->SetMinMaxBitrate (min_data_rate_, max_data_rate_);
321
389
}
322
390
}
@@ -408,7 +476,8 @@ void GoogCcNetworkController::UpdateCongestionWindowSize() {
408
476
}
409
477
410
478
NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback (
411
- TransportPacketsFeedback report, int64_t current_offset_ms) {
479
+ TransportPacketsFeedback report,
480
+ int64_t current_offset_ms) {
412
481
if (report.packet_feedbacks .empty ()) {
413
482
// TODO(bugs.webrtc.org/10125): Design a better mechanism to safe-guard
414
483
// against building very large network queues.
@@ -453,6 +522,12 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
453
522
int64_t mean_rtt_ms = sum_rtt_ms / feedback_max_rtts_.size ();
454
523
if (delay_based_bwe_)
455
524
delay_based_bwe_->OnRttUpdate (TimeDelta::Millis (mean_rtt_ms));
525
+ else {
526
+ #ifdef INTEL_GPRA
527
+ if (delay_based_bwe_gcc_)
528
+ delay_based_bwe_gcc_->OnRttUpdate (TimeDelta::Millis (mean_rtt_ms));
529
+ #endif
530
+ }
456
531
}
457
532
458
533
TimeDelta feedback_min_rtt = TimeDelta::PlusInfinity ();
@@ -519,7 +594,6 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
519
594
absl::optional<DataRate> probe_bitrate =
520
595
probe_bitrate_estimator_->FetchAndResetLastEstimatedBitrate ();
521
596
#ifdef INTEL_GPRA
522
-
523
597
if (ignore_probes_lower_than_network_estimate_ && probe_bitrate &&
524
598
estimate_ && *probe_bitrate < estimate_->link_capacity_lower ) {
525
599
#else
@@ -549,10 +623,18 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback(
549
623
550
624
DelayBasedBwe::Result result;
551
625
#ifdef INTEL_GPRA
552
- delay_based_bwe_->SetCurrentOffsetMs (current_offset_ms);
553
- result = delay_based_bwe_->IncomingPacketFeedbackVector (
554
- report, acknowledged_bitrate, probe_bitrate, estimate_,
555
- alr_start_time.has_value ());
626
+ if (delay_based_bwe_) {
627
+ delay_based_bwe_->SetCurrentOffsetMs (current_offset_ms);
628
+ result = delay_based_bwe_->IncomingPacketFeedbackVector (
629
+ report, acknowledged_bitrate, probe_bitrate, estimate_,
630
+ alr_start_time.has_value ());
631
+ } else {
632
+ if (delay_based_bwe_gcc_) {
633
+ result = delay_based_bwe_gcc_->IncomingPacketFeedbackVector (
634
+ report, acknowledged_bitrate, probe_bitrate, estimate_,
635
+ alr_start_time.has_value ());
636
+ }
637
+ }
556
638
#else
557
639
result = delay_based_bwe_->IncomingPacketFeedbackVector (
558
640
report, acknowledged_bitrate, probe_bitrate, estimate_,
@@ -616,8 +698,16 @@ NetworkControlUpdate GoogCcNetworkController::GetNetworkState(
616
698
last_estimated_fraction_loss_.value_or (0 ) / 255.0 ;
617
699
update.target_rate ->network_estimate .round_trip_time =
618
700
last_estimated_round_trip_time_;
619
- update.target_rate ->network_estimate .bwe_period =
620
- delay_based_bwe_->GetExpectedBwePeriod ();
701
+ if (delay_based_bwe_)
702
+ update.target_rate ->network_estimate .bwe_period =
703
+ delay_based_bwe_->GetExpectedBwePeriod ();
704
+ else {
705
+ #ifdef INTEL_GPRA
706
+ if (delay_based_bwe_gcc_)
707
+ update.target_rate ->network_estimate .bwe_period =
708
+ delay_based_bwe_gcc_->GetExpectedBwePeriod ();
709
+ #endif
710
+ }
621
711
622
712
update.target_rate ->at_time = at_time;
623
713
update.target_rate ->target_rate = last_pushback_target_rate_;
@@ -681,10 +771,14 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
681
771
682
772
alr_detector_->SetEstimatedBitrate (loss_based_target_rate.bps ());
683
773
774
+ #ifndef INTEL_GPRA
684
775
TimeDelta bwe_period = delay_based_bwe_->GetExpectedBwePeriod ();
685
-
686
- #ifdef INTEL_GPRA
687
- delay_based_bwe_->SetCurrentPacketLossRate (fraction_loss);
776
+ #else
777
+ TimeDelta bwe_period = delay_based_bwe_.get ()
778
+ ? delay_based_bwe_->GetExpectedBwePeriod ()
779
+ : delay_based_bwe_gcc_->GetExpectedBwePeriod ();
780
+ if (delay_based_bwe_)
781
+ delay_based_bwe_->SetCurrentPacketLossRate (fraction_loss);
688
782
#endif
689
783
690
784
TargetTransferRate target_rate_msg;
0 commit comments