Don't initiate perodic probing if we don't have a bandwidth estimate.
BUG=webrtc:7582 Review-Url: https://codereview.webrtc.org/2861673006 Cr-Commit-Position: refs/heads/master@{#18018}
This commit is contained in:
@ -59,6 +59,7 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps,
|
||||
|
||||
if (start_bitrate_bps > 0) {
|
||||
start_bitrate_bps_ = start_bitrate_bps;
|
||||
estimated_bitrate_bps_ = start_bitrate_bps;
|
||||
} else if (start_bitrate_bps_ == 0) {
|
||||
start_bitrate_bps_ = min_bitrate_bps;
|
||||
}
|
||||
@ -212,7 +213,7 @@ void ProbeController::Process() {
|
||||
// Probe bandwidth periodically when in ALR state.
|
||||
rtc::Optional<int64_t> alr_start_time =
|
||||
pacer_->GetApplicationLimitedRegionStartTime();
|
||||
if (alr_start_time) {
|
||||
if (alr_start_time && estimated_bitrate_bps_ > 0) {
|
||||
int64_t next_probe_time_ms =
|
||||
std::max(*alr_start_time, time_last_probing_initiated_ms_) +
|
||||
kAlrPeriodicProbingIntervalMs;
|
||||
@ -227,6 +228,7 @@ void ProbeController::InitiateProbing(
|
||||
std::initializer_list<int64_t> bitrates_to_probe,
|
||||
bool probe_further) {
|
||||
for (int64_t bitrate : bitrates_to_probe) {
|
||||
RTC_DCHECK_GT(bitrate, 0);
|
||||
int64_t max_probe_bitrate_bps =
|
||||
max_bitrate_bps_ > 0 ? max_bitrate_bps_ : kDefaultMaxProbingBitrateBps;
|
||||
if (bitrate > max_probe_bitrate_bps) {
|
||||
|
||||
@ -175,6 +175,34 @@ TEST_F(ProbeControllerTest, PeriodicProbing) {
|
||||
testing::Mock::VerifyAndClearExpectations(&pacer_);
|
||||
}
|
||||
|
||||
TEST_F(ProbeControllerTest, PeriodicProbingAfterReset) {
|
||||
testing::StrictMock<MockPacedSender> local_pacer;
|
||||
probe_controller_.reset(new ProbeController(&local_pacer, &clock_));
|
||||
int64_t alr_start_time = clock_.TimeInMilliseconds();
|
||||
EXPECT_CALL(local_pacer, GetApplicationLimitedRegionStartTime())
|
||||
.WillRepeatedly(
|
||||
Return(rtc::Optional<int64_t>(alr_start_time)));
|
||||
|
||||
EXPECT_CALL(local_pacer, CreateProbeCluster(_)).Times(2);
|
||||
probe_controller_->EnablePeriodicAlrProbing(true);
|
||||
probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
|
||||
kMaxBitrateBps);
|
||||
probe_controller_->Reset();
|
||||
|
||||
clock_.AdvanceTimeMilliseconds(10000);
|
||||
probe_controller_->Process();
|
||||
|
||||
EXPECT_CALL(local_pacer, CreateProbeCluster(_)).Times(2);
|
||||
probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
|
||||
kMaxBitrateBps);
|
||||
|
||||
// Make sure we use |kStartBitrateBps| as the estimated bitrate
|
||||
// until SetEstimatedBitrate is called with an updated estimate.
|
||||
clock_.AdvanceTimeMilliseconds(10000);
|
||||
EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps*2));
|
||||
probe_controller_->Process();
|
||||
}
|
||||
|
||||
TEST_F(ProbeControllerTest, TestExponentialProbingOverflow) {
|
||||
const int64_t kMbpsMultiplier = 1000000;
|
||||
probe_controller_->SetBitrates(kMinBitrateBps, 10 * kMbpsMultiplier,
|
||||
|
||||
@ -86,6 +86,7 @@ void BitrateProber::OnIncomingPacket(size_t packet_size) {
|
||||
|
||||
void BitrateProber::CreateProbeCluster(int bitrate_bps, int64_t now_ms) {
|
||||
RTC_DCHECK(probing_state_ != ProbingState::kDisabled);
|
||||
RTC_DCHECK_GT(bitrate_bps, 0);
|
||||
while (!clusters_.empty() &&
|
||||
now_ms - clusters_.front().time_created_ms > kProbeClusterTimeoutMs) {
|
||||
clusters_.pop();
|
||||
@ -151,7 +152,7 @@ int BitrateProber::TimeUntilNextProbe(int64_t now_ms) {
|
||||
|
||||
PacedPacketInfo BitrateProber::CurrentCluster() const {
|
||||
RTC_DCHECK(!clusters_.empty());
|
||||
RTC_DCHECK(ProbingState::kActive == probing_state_);
|
||||
RTC_DCHECK(probing_state_ == ProbingState::kActive);
|
||||
return clusters_.front().pace_info;
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) {
|
||||
}
|
||||
cluster->sent_bytes += static_cast<int>(bytes);
|
||||
cluster->sent_probes += 1;
|
||||
next_probe_time_ms_ = GetNextProbeTime(clusters_.front());
|
||||
next_probe_time_ms_ = GetNextProbeTime(*cluster);
|
||||
if (cluster->sent_bytes >= cluster->pace_info.probe_cluster_min_bytes &&
|
||||
cluster->sent_probes >= cluster->pace_info.probe_cluster_min_probes) {
|
||||
clusters_.pop();
|
||||
|
||||
Reference in New Issue
Block a user