Improve probing by ignoring small packets which otherwise break the mechanism.
These small packets are common for H.264 where the first packet of an IDR contains the parameter sets. BUG=4806 Review URL: https://codereview.webrtc.org/1221943002 Cr-Commit-Position: refs/heads/master@{#9639}
This commit is contained in:
@ -29,6 +29,8 @@ int ComputeDeltaFromBitrate(size_t packet_size, int bitrate_bps) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const size_t BitrateProber::kMinProbePacketSize = 200;
|
||||
|
||||
BitrateProber::BitrateProber()
|
||||
: probing_state_(kDisabled),
|
||||
packet_size_last_send_(0),
|
||||
@ -88,7 +90,8 @@ int BitrateProber::TimeUntilNextProbe(int64_t now_ms) {
|
||||
// We will send the first probe packet immediately if no packet has been
|
||||
// sent before.
|
||||
int time_until_probe_ms = 0;
|
||||
if (packet_size_last_send_ > 0 && probing_state_ == kProbing) {
|
||||
if (packet_size_last_send_ > kMinProbePacketSize &&
|
||||
probing_state_ == kProbing) {
|
||||
int next_delta_ms = ComputeDeltaFromBitrate(packet_size_last_send_,
|
||||
probe_bitrates_.front());
|
||||
time_until_probe_ms = next_delta_ms - elapsed_time_ms;
|
||||
|
@ -22,6 +22,8 @@ namespace webrtc {
|
||||
// on being protected by the caller.
|
||||
class BitrateProber {
|
||||
public:
|
||||
static const size_t kMinProbePacketSize;
|
||||
|
||||
BitrateProber();
|
||||
|
||||
void SetEnabled(bool enable);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/pacing/bitrate_prober.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
@ -268,7 +269,10 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacketInfo(
|
||||
uint32_t ts_delta = 0;
|
||||
int64_t t_delta = 0;
|
||||
int size_delta = 0;
|
||||
// For now only try to detect probes while we don't have a valid estimate.
|
||||
// For now only try to detect probes while we don't have a valid estimate, and
|
||||
// make sure the packet was paced. We currently assume that only packets
|
||||
// larger than 200 bytes are paced by the sender.
|
||||
was_paced = was_paced && payload_size > BitrateProber::kMinProbePacketSize;
|
||||
if (was_paced &&
|
||||
(!remote_rate_.ValidEstimate() ||
|
||||
now_ms - first_packet_time_ms_ < kInitialProbingIntervalMs)) {
|
||||
|
@ -38,7 +38,7 @@ TEST_F(RemoteBitrateEstimatorAbsSendTimeTest, RateIncreaseReordering) {
|
||||
}
|
||||
|
||||
TEST_F(RemoteBitrateEstimatorAbsSendTimeTest, RateIncreaseRtpTimestamps) {
|
||||
RateIncreaseRtpTimestampsTestHelper(1089);
|
||||
RateIncreaseRtpTimestampsTestHelper(1240);
|
||||
}
|
||||
|
||||
TEST_F(RemoteBitrateEstimatorAbsSendTimeTest, CapacityDropOneStream) {
|
||||
@ -259,4 +259,36 @@ TEST_F(RemoteBitrateEstimatorAbsSendTimeTest,
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 4000000u, 10000);
|
||||
}
|
||||
|
||||
TEST_F(RemoteBitrateEstimatorAbsSendTimeTest, ProbingIgnoresSmallPackets) {
|
||||
const int kProbeLength = 5;
|
||||
int64_t now_ms = clock_.TimeInMilliseconds();
|
||||
// Probing with 200 bytes every 10 ms, should be ignored by the probe
|
||||
// detection.
|
||||
for (int i = 0; i < kProbeLength; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds(10);
|
||||
now_ms = clock_.TimeInMilliseconds();
|
||||
IncomingPacket(0, 200, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000),
|
||||
true);
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, bitrate_estimator_->Process());
|
||||
EXPECT_FALSE(bitrate_observer_->updated());
|
||||
|
||||
// Followed by a probe with 1000 bytes packets, should be detected as a
|
||||
// probe.
|
||||
for (int i = 0; i < kProbeLength; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds(10);
|
||||
now_ms = clock_.TimeInMilliseconds();
|
||||
IncomingPacket(0, 1000, now_ms, 90 * now_ms, AbsSendTime(now_ms, 1000),
|
||||
true);
|
||||
}
|
||||
|
||||
// Wait long enough so that we can call Process again.
|
||||
clock_.AdvanceTimeMilliseconds(1000);
|
||||
|
||||
EXPECT_EQ(0, bitrate_estimator_->Process());
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
EXPECT_NEAR(bitrate_observer_->latest_bitrate(), 800000u, 10000);
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user