Propagating total_bitrate_bps from BitrateAllocator to ProbeController, part 3.

Trigger on total bitrate change.

Bug: webrtc:8955
Change-Id: I2373a1b7f139c7ea748a9641593e714d6895c8f6
Reviewed-on: https://webrtc-review.googlesource.com/59323
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22323}
This commit is contained in:
philipel 2018-03-06 18:29:22 +01:00 committed by Commit Bot
parent 7dbb701076
commit db4fa4b944
15 changed files with 85 additions and 4 deletions

View File

@ -65,8 +65,9 @@ const RtpKeepAliveConfig& RtpTransportControllerSend::keepalive_config() const {
void RtpTransportControllerSend::SetAllocatedSendBitrateLimits(
int min_send_bitrate_bps,
int max_padding_bitrate_bps,
int total_bitrate_bps) {
int max_total_bitrate_bps) {
pacer_.SetSendBitrateLimits(min_send_bitrate_bps, max_padding_bitrate_bps);
send_side_cc_->SetMaxTotalAllocatedBitrate(max_total_bitrate_bps);
}
void RtpTransportControllerSend::SetKeepAliveConfig(

View File

@ -46,7 +46,7 @@ class RtpTransportControllerSend : public RtpTransportControllerSendInterface {
void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
int max_padding_bitrate_bps,
int total_bitrate_bps) override;
int max_total_bitrate_bps) override;
void SetKeepAliveConfig(const RtpKeepAliveConfig& config);
void SetPacingFactor(float pacing_factor) override;

View File

@ -190,7 +190,12 @@ void GoogCcNetworkController::OnSentPacket(SentPacket sent_packet) {
void GoogCcNetworkController::OnStreamsConfig(StreamsConfig msg) {
probe_controller_->EnablePeriodicAlrProbing(msg.requests_alr_probing);
if (msg.max_total_allocated_bitrate &&
*msg.max_total_allocated_bitrate != max_total_allocated_bitrate_) {
probe_controller_->OnMaxTotalAllocatedBitrate(
msg.max_total_allocated_bitrate->bps(), msg.at_time.ms());
max_total_allocated_bitrate_ = *msg.max_total_allocated_bitrate;
}
bool pacing_changed = false;
if (msg.pacing_factor && *msg.pacing_factor != pacing_factor_) {
pacing_factor_ = *msg.pacing_factor;

View File

@ -80,6 +80,7 @@ class GoogCcNetworkController : public NetworkControllerInterface {
double pacing_factor_;
DataRate min_pacing_rate_;
DataRate max_padding_rate_;
DataRate max_total_allocated_bitrate_;
bool in_cwnd_experiment_;
int64_t accepted_queue_ms_;

View File

@ -133,6 +133,18 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps,
}
}
void ProbeController::OnMaxTotalAllocatedBitrate(
int64_t max_total_allocated_bitrate,
int64_t at_time_ms) {
// TODO(philipel): Should |max_total_allocated_bitrate| be used as a limit for
// ALR probing?
if (estimated_bitrate_bps_ != 0 &&
estimated_bitrate_bps_ < max_bitrate_bps_ &&
estimated_bitrate_bps_ < max_total_allocated_bitrate) {
InitiateProbing(at_time_ms, {max_total_allocated_bitrate}, false);
}
}
void ProbeController::OnNetworkAvailability(NetworkAvailability msg) {
network_available_ = msg.network_available;
if (network_available_ && state_ == State::kInit && start_bitrate_bps_ > 0)

View File

@ -37,6 +37,11 @@ class ProbeController {
int64_t max_bitrate_bps,
int64_t at_time_ms);
// The total bitrate, as opposed to the max bitrate, is the sum of the
// configured bitrates for all active streams.
void OnMaxTotalAllocatedBitrate(int64_t max_total_allocated_bitrate,
int64_t at_time_ms);
void OnNetworkAvailability(NetworkAvailability msg);
void SetEstimatedBitrate(int64_t bitrate_bps, int64_t at_time_ms);

View File

@ -67,6 +67,9 @@ class SendSideCongestionController
void SetBweBitrates(int min_bitrate_bps,
int start_bitrate_bps,
int max_bitrate_bps) override;
void SetMaxTotalAllocatedBitrate(int max_total_allocated_bitrate) override;
// Resets the BWE state. Note the first argument is the bitrate_bps.
void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
int bitrate_bps,

View File

@ -49,6 +49,7 @@ class SendSideCongestionControllerInterface : public CallStatsObserver,
virtual void SetBweBitrates(int min_bitrate_bps,
int start_bitrate_bps,
int max_bitrate_bps) = 0;
virtual void SetMaxTotalAllocatedBitrate(int total_bitrate_bps) = 0;
virtual void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
int bitrate_bps,
int min_bitrate_bps,

View File

@ -33,6 +33,7 @@ struct StreamsConfig {
rtc::Optional<double> pacing_factor;
rtc::Optional<DataRate> min_pacing_rate;
rtc::Optional<DataRate> max_padding_rate;
rtc::Optional<DataRate> max_total_allocated_bitrate;
};
struct TargetRateConstraints {

View File

@ -125,6 +125,19 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps,
}
}
void ProbeController::OnMaxTotalAllocatedBitrate(
int64_t max_total_allocated_bitrate) {
rtc::CritScope cs(&critsect_);
// TODO(philipel): Should |max_total_allocated_bitrate| be used as a limit for
// ALR probing?
if (estimated_bitrate_bps_ != 0 &&
estimated_bitrate_bps_ < max_bitrate_bps_ &&
estimated_bitrate_bps_ < max_total_allocated_bitrate) {
InitiateProbing(clock_->TimeInMilliseconds(), {max_total_allocated_bitrate},
false);
}
}
void ProbeController::OnNetworkStateChanged(NetworkState network_state) {
rtc::CritScope cs(&critsect_);
network_state_ = network_state;

View File

@ -32,6 +32,10 @@ class ProbeController {
int64_t start_bitrate_bps,
int64_t max_bitrate_bps);
// The total bitrate, as opposed to the max bitrate, is the sum of the
// configured bitrates for all active streams.
void OnMaxTotalAllocatedBitrate(int64_t max_total_allocated_bitrate);
void OnNetworkStateChanged(NetworkState state);
void SetEstimatedBitrate(int64_t bitrate_bps);

View File

@ -45,6 +45,7 @@ class LegacyProbeControllerTest : public ::testing::Test {
}
~LegacyProbeControllerTest() override {}
const int64_t kMbpsMultiplier = 1000000;
SimulatedClock clock_;
NiceMock<MockPacedSender> pacer_;
std::unique_ptr<ProbeController> probe_controller_;
@ -253,7 +254,6 @@ TEST_F(LegacyProbeControllerTest, PeriodicProbingAfterReset) {
}
TEST_F(LegacyProbeControllerTest, TestExponentialProbingOverflow) {
const int64_t kMbpsMultiplier = 1000000;
probe_controller_->SetBitrates(kMinBitrateBps, 10 * kMbpsMultiplier,
100 * kMbpsMultiplier);
@ -267,5 +267,23 @@ TEST_F(LegacyProbeControllerTest, TestExponentialProbingOverflow) {
probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier);
}
TEST_F(LegacyProbeControllerTest, TotalBitrateProbing) {
probe_controller_->SetBitrates(kMinBitrateBps, 1 * kMbpsMultiplier,
2 * kMbpsMultiplier);
EXPECT_CALL(pacer_, CreateProbeCluster(1 * kMbpsMultiplier));
probe_controller_->SetEstimatedBitrate(500000);
probe_controller_->OnMaxTotalAllocatedBitrate(1 * kMbpsMultiplier);
}
TEST_F(LegacyProbeControllerTest, TotalBitrateNoProbing) {
probe_controller_->SetBitrates(kMinBitrateBps, 1 * kMbpsMultiplier,
2 * kMbpsMultiplier);
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
probe_controller_->SetEstimatedBitrate(500000);
probe_controller_->OnMaxTotalAllocatedBitrate(250000);
}
} // namespace test
} // namespace webrtc

View File

@ -80,6 +80,9 @@ class SendSideCongestionController
void SetBweBitrates(int min_bitrate_bps,
int start_bitrate_bps,
int max_bitrate_bps) override;
void SetMaxTotalAllocatedBitrate(int max_total_allocated_bitrate) override;
// Resets the BWE state. Note the first argument is the bitrate_bps.
void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
int bitrate_bps,

View File

@ -340,6 +340,15 @@ void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps,
WaitOnTask([this, msg]() { controller_->OnTargetRateConstraints(msg); });
}
void SendSideCongestionController::SetMaxTotalAllocatedBitrate(
int max_total_allocated_bitrate) {
WaitOnTask([this, max_total_allocated_bitrate]() {
streams_config_.max_total_allocated_bitrate =
DataRate::bps(max_total_allocated_bitrate);
UpdateStreamsConfig();
});
}
// TODO(holmer): Split this up and use SetBweBitrates in combination with
// OnNetworkRouteChanged.
void SendSideCongestionController::OnNetworkRouteChanged(

View File

@ -190,6 +190,11 @@ void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps,
MaybeTriggerOnNetworkChanged();
}
void SendSideCongestionController::SetMaxTotalAllocatedBitrate(
int total_bitrate_bps) {
probe_controller_->OnMaxTotalAllocatedBitrate(total_bitrate_bps);
}
// TODO(holmer): Split this up and use SetBweBitrates in combination with
// OnNetworkRouteChanged.
void SendSideCongestionController::OnNetworkRouteChanged(