Don't reset initial constraints in congestion controller.

This avoids crashing if an application resets the starting bitrate
before adding streams to the call.

Bug: webrtc:9586
Change-Id: I8d31aba1f4fee40c67c8930f5a32d17700ccadc3
Reviewed-on: https://webrtc-review.googlesource.com/101680
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24808}
This commit is contained in:
Sebastian Jansson
2018-09-24 17:28:00 +02:00
committed by Commit Bot
parent 380789761c
commit d5fe67f958
2 changed files with 12 additions and 2 deletions

View File

@ -158,6 +158,8 @@ class SendSideCongestionController
private: private:
void MaybeCreateControllers() RTC_RUN_ON(task_queue_); void MaybeCreateControllers() RTC_RUN_ON(task_queue_);
void MaybeRecreateControllers() RTC_RUN_ON(task_queue_); void MaybeRecreateControllers() RTC_RUN_ON(task_queue_);
void UpdateInitialConstraints(TargetRateConstraints new_contraints)
RTC_RUN_ON(task_queue_);
void StartProcessPeriodicTasks() RTC_RUN_ON(task_queue_); void StartProcessPeriodicTasks() RTC_RUN_ON(task_queue_);
void UpdateControllerWithTimeInterval() RTC_RUN_ON(task_queue_); void UpdateControllerWithTimeInterval() RTC_RUN_ON(task_queue_);

View File

@ -419,6 +419,14 @@ void SendSideCongestionController::MaybeRecreateControllers() {
RTC_DCHECK(controller_); RTC_DCHECK(controller_);
} }
void SendSideCongestionController::UpdateInitialConstraints(
TargetRateConstraints new_contraints) {
if (!new_contraints.starting_rate)
new_contraints.starting_rate = initial_config_.constraints.starting_rate;
RTC_DCHECK(new_contraints.starting_rate);
initial_config_.constraints = new_contraints;
}
SendSideCongestionController::~SendSideCongestionController() = default; SendSideCongestionController::~SendSideCongestionController() = default;
void SendSideCongestionController::RegisterPacketFeedbackObserver( void SendSideCongestionController::RegisterPacketFeedbackObserver(
@ -452,7 +460,7 @@ void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps,
control_handler_->PostUpdates( control_handler_->PostUpdates(
controller_->OnTargetRateConstraints(constraints)); controller_->OnTargetRateConstraints(constraints));
} else { } else {
initial_config_.constraints = constraints; UpdateInitialConstraints(constraints);
} }
}); });
} }
@ -490,7 +498,7 @@ void SendSideCongestionController::OnNetworkRouteChanged(
if (controller_) { if (controller_) {
control_handler_->PostUpdates(controller_->OnNetworkRouteChange(msg)); control_handler_->PostUpdates(controller_->OnNetworkRouteChange(msg));
} else { } else {
initial_config_.constraints = msg.constraints; UpdateInitialConstraints(msg.constraints);
} }
pacer_controller_->OnNetworkRouteChange(msg); pacer_controller_->OnNetworkRouteChange(msg);
}); });