mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Include protection bitrate in total max allocated bitrate
This way we make sure we take fec into account when deciding how high we probe. Bug: webrtc:10070 Change-Id: I5286c82fc32dd99f7b9d79c9e5fc4465e1c6c259 Reviewed-on: https://webrtc-review.googlesource.com/c/113429 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25930}
This commit is contained in:
parent
120469086a
commit
d1d7b23f89
2 changed files with 53 additions and 23 deletions
|
@ -227,7 +227,12 @@ void BitrateAllocator::UpdateAllocationLimits() {
|
||||||
std::max(config.MinBitrateWithHysteresis(), stream_padding);
|
std::max(config.MinBitrateWithHysteresis(), stream_padding);
|
||||||
}
|
}
|
||||||
total_requested_padding_bitrate += stream_padding;
|
total_requested_padding_bitrate += stream_padding;
|
||||||
total_requested_max_bitrate += config.max_bitrate_bps;
|
uint32_t max_bitrate_bps = config.max_bitrate_bps;
|
||||||
|
if (config.media_ratio > 0) {
|
||||||
|
max_bitrate_bps =
|
||||||
|
static_cast<uint32_t>(max_bitrate_bps / config.media_ratio);
|
||||||
|
}
|
||||||
|
total_requested_max_bitrate += max_bitrate_bps;
|
||||||
if (config.allocated_bitrate_bps > 0 && config.has_packet_feedback)
|
if (config.allocated_bitrate_bps > 0 && config.has_packet_feedback)
|
||||||
has_packet_feedback = true;
|
has_packet_feedback = true;
|
||||||
// TODO(srte): Remove field trial check.
|
// TODO(srte): Remove field trial check.
|
||||||
|
|
|
@ -335,12 +335,17 @@ TEST_F(BitrateAllocatorTestNoEnforceMin, ThreeBitrateObservers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) {
|
TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) {
|
||||||
TestBitrateObserver bitrate_observer;
|
const uint32_t kMinBitrateBps = 100000;
|
||||||
|
const uint32_t kMaxBitrateBps = 400000;
|
||||||
|
// Hysteresis adds another 10% or 20kbps to min bitrate.
|
||||||
|
const uint32_t kMinStartBitrateBps =
|
||||||
|
kMinBitrateBps + std::max(20000u, kMinBitrateBps / 10);
|
||||||
|
|
||||||
// Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since
|
// Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since
|
||||||
// AddObserver is called with |enforce_min_bitrate| = false.
|
// AddObserver is called with |enforce_min_bitrate| = false.
|
||||||
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, _));
|
TestBitrateObserver bitrate_observer;
|
||||||
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 168000, _));
|
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, kMaxBitrateBps));
|
||||||
AddObserver(&bitrate_observer, 100000, 400000, 0, false, "",
|
AddObserver(&bitrate_observer, kMinBitrateBps, kMaxBitrateBps, 0, false, "",
|
||||||
kDefaultBitratePriority);
|
kDefaultBitratePriority);
|
||||||
EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer));
|
EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer));
|
||||||
|
|
||||||
|
@ -349,38 +354,58 @@ TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) {
|
||||||
EXPECT_EQ(150000u, bitrate_observer.last_bitrate_bps_);
|
EXPECT_EQ(150000u, bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
// Add loss and use a part of the bitrate for protection.
|
// Add loss and use a part of the bitrate for protection.
|
||||||
double protection_ratio = 0.4;
|
const double kProtectionRatio = 0.4;
|
||||||
uint8_t fraction_loss = protection_ratio * 256;
|
uint32_t target_bitrate_bps = 200000;
|
||||||
bitrate_observer.SetBitrateProtectionRatio(protection_ratio);
|
const uint32_t kMaxBitrateWithProtectionBps =
|
||||||
allocator_->OnNetworkChanged(200000, 0, fraction_loss,
|
static_cast<uint32_t>(kMaxBitrateBps / (1 - kProtectionRatio));
|
||||||
|
uint8_t fraction_loss = kProtectionRatio * 256;
|
||||||
|
bitrate_observer.SetBitrateProtectionRatio(kProtectionRatio);
|
||||||
|
EXPECT_CALL(limit_observer_,
|
||||||
|
OnAllocationLimitsChanged(0, 0, kMaxBitrateWithProtectionBps));
|
||||||
|
allocator_->OnNetworkChanged(target_bitrate_bps, 0, fraction_loss,
|
||||||
kDefaultProbingIntervalMs);
|
kDefaultProbingIntervalMs);
|
||||||
EXPECT_EQ(200000u, bitrate_observer.last_bitrate_bps_);
|
EXPECT_EQ(target_bitrate_bps, bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
// Above the min threshold, but not enough given the protection used.
|
// Above the min threshold, but not enough given the protection used.
|
||||||
allocator_->OnNetworkChanged(139000, 0, fraction_loss,
|
// Limits changed, as we will video is now off and we need to pad up to the
|
||||||
|
// start bitrate.
|
||||||
|
target_bitrate_bps = kMinStartBitrateBps + 1000;
|
||||||
|
// Verify the hysteresis is added for the protection.
|
||||||
|
const uint32_t kMinStartBitrateWithProtectionBps =
|
||||||
|
static_cast<uint32_t>(kMinStartBitrateBps * (1 + kProtectionRatio));
|
||||||
|
EXPECT_CALL(limit_observer_,
|
||||||
|
OnAllocationLimitsChanged(0, kMinStartBitrateWithProtectionBps,
|
||||||
|
kMaxBitrateWithProtectionBps));
|
||||||
|
allocator_->OnNetworkChanged(kMinStartBitrateBps + 1000, 0, fraction_loss,
|
||||||
kDefaultProbingIntervalMs);
|
kDefaultProbingIntervalMs);
|
||||||
EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
|
EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
// Verify the hysteresis is added for the protection.
|
allocator_->OnNetworkChanged(kMinStartBitrateWithProtectionBps - 1000, 0,
|
||||||
allocator_->OnNetworkChanged(150000, 0, fraction_loss,
|
fraction_loss, kDefaultProbingIntervalMs);
|
||||||
kDefaultProbingIntervalMs);
|
|
||||||
EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
|
EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
// Just enough to enable video again.
|
// Just enough to enable video again.
|
||||||
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, _));
|
target_bitrate_bps = kMinStartBitrateWithProtectionBps;
|
||||||
allocator_->OnNetworkChanged(168000, 0, fraction_loss,
|
EXPECT_CALL(limit_observer_,
|
||||||
kDefaultProbingIntervalMs);
|
OnAllocationLimitsChanged(0, 0, kMaxBitrateWithProtectionBps));
|
||||||
EXPECT_EQ(168000u, bitrate_observer.last_bitrate_bps_);
|
allocator_->OnNetworkChanged(kMinStartBitrateWithProtectionBps, 0,
|
||||||
|
fraction_loss, kDefaultProbingIntervalMs);
|
||||||
|
EXPECT_EQ(kMinStartBitrateWithProtectionBps,
|
||||||
|
bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
// Remove all protection and make sure video is not paused as earlier.
|
// Remove all protection and make sure video is not paused as earlier.
|
||||||
bitrate_observer.SetBitrateProtectionRatio(0.0);
|
bitrate_observer.SetBitrateProtectionRatio(0.0);
|
||||||
allocator_->OnNetworkChanged(140000, 0, 0, kDefaultProbingIntervalMs);
|
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, kMaxBitrateBps));
|
||||||
EXPECT_EQ(140000u, bitrate_observer.last_bitrate_bps_);
|
allocator_->OnNetworkChanged(kMinStartBitrateWithProtectionBps - 1000, 0, 0,
|
||||||
|
kDefaultProbingIntervalMs);
|
||||||
|
EXPECT_EQ(kMinStartBitrateWithProtectionBps - 1000,
|
||||||
|
bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
allocator_->OnNetworkChanged(139000, 0, 0, kDefaultProbingIntervalMs);
|
allocator_->OnNetworkChanged(kMinStartBitrateBps, 0, 0,
|
||||||
EXPECT_EQ(139000u, bitrate_observer.last_bitrate_bps_);
|
kDefaultProbingIntervalMs);
|
||||||
|
EXPECT_EQ(kMinStartBitrateBps, bitrate_observer.last_bitrate_bps_);
|
||||||
|
|
||||||
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, _));
|
EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0, 0));
|
||||||
allocator_->RemoveObserver(&bitrate_observer);
|
allocator_->RemoveObserver(&bitrate_observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue