@@ -272,6 +272,22 @@ std::vector<ProbeClusterConfig> ProbeController::OnNetworkAvailability(
272272 return std::vector<ProbeClusterConfig>();
273273}
274274
275+ void ProbeController::UpdateState (State new_state) {
276+ switch (new_state) {
277+ case State::kInit :
278+ state_ = State::kInit ;
279+ break ;
280+ case State::kWaitingForProbingResult :
281+ state_ = State::kWaitingForProbingResult ;
282+ break ;
283+ case State::kProbingComplete :
284+ state_ = State::kProbingComplete ;
285+ waiting_for_initial_probe_result_ = false ;
286+ min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
287+ break ;
288+ }
289+ }
290+
275291std::vector<ProbeClusterConfig> ProbeController::InitiateExponentialProbing (
276292 Timestamp at_time) {
277293 RTC_DCHECK (network_available_);
@@ -287,6 +303,8 @@ std::vector<ProbeClusterConfig> ProbeController::InitiateExponentialProbing(
287303 probes.push_back (config_.second_exponential_probe_scale .Value () *
288304 start_bitrate_);
289305 }
306+ waiting_for_initial_probe_result_ = true ;
307+
290308 return InitiateProbing (at_time, probes, true );
291309}
292310
@@ -307,6 +325,7 @@ std::vector<ProbeClusterConfig> ProbeController::SetEstimatedBitrate(
307325 if (config_.abort_further_probe_if_max_lower_than_current &&
308326 (bitrate > max_bitrate_ ||
309327 (!max_total_allocated_bitrate_.IsZero () &&
328+ !(waiting_for_initial_probe_result_ && first_probe_to_max_bitrate_) &&
310329 bitrate > 2 * max_total_allocated_bitrate_))) {
311330 // No need to continue probing.
312331 min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
@@ -335,6 +354,11 @@ void ProbeController::EnablePeriodicAlrProbing(bool enable) {
335354 enable_periodic_alr_probing_ = enable;
336355}
337356
357+ void ProbeController::SetFirstProbeToMaxBitrate (
358+ bool first_probe_to_max_bitrate) {
359+ first_probe_to_max_bitrate_ = first_probe_to_max_bitrate;
360+ }
361+
338362void ProbeController::SetAlrStartTimeMs (
339363 absl::optional<int64_t > alr_start_time_ms) {
340364 if (alr_start_time_ms) {
@@ -391,6 +415,7 @@ void ProbeController::SetNetworkStateEstimate(
391415void ProbeController::Reset (Timestamp at_time) {
392416 bandwidth_limited_cause_ = BandwidthLimitedCause::kDelayBasedLimited ;
393417 state_ = State::kInit ;
418+ waiting_for_initial_probe_result_ = false ;
394419 min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
395420 time_last_probing_initiated_ = Timestamp::Zero ();
396421 estimated_bitrate_ = DataRate::Zero ();
@@ -452,8 +477,7 @@ std::vector<ProbeClusterConfig> ProbeController::Process(Timestamp at_time) {
452477 kMaxWaitingTimeForProbingResult ) {
453478 if (state_ == State::kWaitingForProbingResult ) {
454479 RTC_LOG (LS_INFO) << " kWaitingForProbingResult: timeout" ;
455- state_ = State::kProbingComplete ;
456- min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
480+ UpdateState (State::kProbingComplete );
457481 }
458482 }
459483 if (estimated_bitrate_.IsZero () || state_ != State::kProbingComplete ) {
@@ -480,14 +504,14 @@ std::vector<ProbeClusterConfig> ProbeController::InitiateProbing(
480504 : std::min (max_total_allocated_bitrate_, max_bitrate_);
481505 if (std::min (network_estimate, estimated_bitrate_) >
482506 config_.skip_if_estimate_larger_than_fraction_of_max * max_probe_rate) {
483- state_ = State::kProbingComplete ;
484- min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
507+ UpdateState (State::kProbingComplete );
485508 return {};
486509 }
487510 }
488511
489512 DataRate max_probe_bitrate = max_bitrate_;
490- if (max_total_allocated_bitrate_ > DataRate::Zero ()) {
513+ if (max_total_allocated_bitrate_ > DataRate::Zero () &&
514+ !waiting_for_initial_probe_result_) {
491515 // If a max allocated bitrate has been configured, allow probing up to 2x
492516 // that rate. This allows some overhead to account for bursty streams,
493517 // which otherwise would have to ramp up when the overshoot is already in
@@ -555,15 +579,14 @@ std::vector<ProbeClusterConfig> ProbeController::InitiateProbing(
555579 }
556580 time_last_probing_initiated_ = now;
557581 if (probe_further) {
558- state_ = State::kWaitingForProbingResult ;
582+ UpdateState ( State::kWaitingForProbingResult ) ;
559583 // Dont expect probe results to be larger than a fraction of the actual
560584 // probe rate.
561585 min_bitrate_to_probe_further_ =
562586 std::min (estimate_capped_bitrate, (*(bitrates_to_probe.end () - 1 ))) *
563587 config_.further_probe_threshold ;
564588 } else {
565- state_ = State::kProbingComplete ;
566- min_bitrate_to_probe_further_ = DataRate::PlusInfinity ();
589+ UpdateState (State::kProbingComplete );
567590 }
568591 return pending_probes;
569592}
0 commit comments