Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -114,7 +114,7 @@ bool AimdRateControl::TimeToReduceFurther(int64_t time_now,
|
||||
if (ValidEstimate()) {
|
||||
// TODO(terelius/holmer): Investigate consequences of increasing
|
||||
// the threshold to 0.95 * LatestEstimate().
|
||||
const uint32_t threshold = static_cast<uint32_t> (0.5 * LatestEstimate());
|
||||
const uint32_t threshold = static_cast<uint32_t>(0.5 * LatestEstimate());
|
||||
return incoming_bitrate_bps < threshold;
|
||||
}
|
||||
return false;
|
||||
@ -206,8 +206,8 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps,
|
||||
const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f;
|
||||
// Calculate the max bit rate std dev given the normalized
|
||||
// variance and the current incoming bit rate.
|
||||
const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ *
|
||||
avg_max_bitrate_kbps_);
|
||||
const float std_max_bit_rate =
|
||||
sqrt(var_max_bitrate_kbps_ * avg_max_bitrate_kbps_);
|
||||
switch (rate_control_state_) {
|
||||
case kRcHold:
|
||||
break;
|
||||
@ -295,15 +295,17 @@ uint32_t AimdRateControl::ClampBitrate(uint32_t new_bitrate_bps,
|
||||
}
|
||||
|
||||
uint32_t AimdRateControl::MultiplicativeRateIncrease(
|
||||
int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const {
|
||||
int64_t now_ms,
|
||||
int64_t last_ms,
|
||||
uint32_t current_bitrate_bps) const {
|
||||
double alpha = 1.08;
|
||||
if (last_ms > -1) {
|
||||
auto time_since_last_update_ms =
|
||||
rtc::SafeMin<int64_t>(now_ms - last_ms, 1000);
|
||||
alpha = pow(alpha, time_since_last_update_ms / 1000.0);
|
||||
alpha = pow(alpha, time_since_last_update_ms / 1000.0);
|
||||
}
|
||||
uint32_t multiplicative_increase_bps = std::max(
|
||||
current_bitrate_bps * (alpha - 1.0), 1000.0);
|
||||
uint32_t multiplicative_increase_bps =
|
||||
std::max(current_bitrate_bps * (alpha - 1.0), 1000.0);
|
||||
return multiplicative_increase_bps;
|
||||
}
|
||||
|
||||
@ -318,13 +320,14 @@ void AimdRateControl::UpdateMaxBitRateEstimate(float incoming_bitrate_kbps) {
|
||||
if (avg_max_bitrate_kbps_ == -1.0f) {
|
||||
avg_max_bitrate_kbps_ = incoming_bitrate_kbps;
|
||||
} else {
|
||||
avg_max_bitrate_kbps_ = (1 - alpha) * avg_max_bitrate_kbps_ +
|
||||
alpha * incoming_bitrate_kbps;
|
||||
avg_max_bitrate_kbps_ =
|
||||
(1 - alpha) * avg_max_bitrate_kbps_ + alpha * incoming_bitrate_kbps;
|
||||
}
|
||||
// Estimate the max bit rate variance and normalize the variance
|
||||
// with the average max bit rate.
|
||||
const float norm = std::max(avg_max_bitrate_kbps_, 1.0f);
|
||||
var_max_bitrate_kbps_ = (1 - alpha) * var_max_bitrate_kbps_ +
|
||||
var_max_bitrate_kbps_ =
|
||||
(1 - alpha) * var_max_bitrate_kbps_ +
|
||||
alpha * (avg_max_bitrate_kbps_ - incoming_bitrate_kbps) *
|
||||
(avg_max_bitrate_kbps_ - incoming_bitrate_kbps) / norm;
|
||||
// 0.4 ~= 14 kbit/s at 500 kbit/s
|
||||
|
||||
@ -64,7 +64,8 @@ class AimdRateControl {
|
||||
// large compared to the bitrate actually being received by the other end.
|
||||
uint32_t ClampBitrate(uint32_t new_bitrate_bps,
|
||||
uint32_t incoming_bitrate_bps) const;
|
||||
uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms,
|
||||
uint32_t MultiplicativeRateIncrease(int64_t now_ms,
|
||||
int64_t last_ms,
|
||||
uint32_t current_bitrate_bps) const;
|
||||
uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms) const;
|
||||
void UpdateChangePeriod(int64_t now_ms);
|
||||
|
||||
@ -551,4 +551,3 @@ TEST_P(BweSimulation, GoogCcComparisonChoke) {
|
||||
} // namespace bwe
|
||||
} // namespace testing
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
|
||||
} else if (NewTimestampGroup(arrival_time_ms, timestamp)) {
|
||||
// First packet of a later frame, the previous frame sample is ready.
|
||||
if (prev_timestamp_group_.complete_time_ms >= 0) {
|
||||
*timestamp_delta = current_timestamp_group_.timestamp -
|
||||
prev_timestamp_group_.timestamp;
|
||||
*timestamp_delta =
|
||||
current_timestamp_group_.timestamp - prev_timestamp_group_.timestamp;
|
||||
*arrival_time_delta_ms = current_timestamp_group_.complete_time_ms -
|
||||
prev_timestamp_group_.complete_time_ms;
|
||||
// Check system time differences to see if we have an unproportional jump
|
||||
@ -86,7 +86,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
|
||||
}
|
||||
assert(*arrival_time_delta_ms >= 0);
|
||||
*packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
|
||||
static_cast<int>(prev_timestamp_group_.size);
|
||||
static_cast<int>(prev_timestamp_group_.size);
|
||||
calculated_deltas = true;
|
||||
}
|
||||
prev_timestamp_group_ = current_timestamp_group_;
|
||||
@ -95,8 +95,8 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp,
|
||||
current_timestamp_group_.timestamp = timestamp;
|
||||
current_timestamp_group_.size = 0;
|
||||
} else {
|
||||
current_timestamp_group_.timestamp = LatestTimestamp(
|
||||
current_timestamp_group_.timestamp, timestamp);
|
||||
current_timestamp_group_.timestamp =
|
||||
LatestTimestamp(current_timestamp_group_.timestamp, timestamp);
|
||||
}
|
||||
// Accumulate the frame size.
|
||||
current_timestamp_group_.size += packet_size;
|
||||
@ -113,8 +113,8 @@ bool InterArrival::PacketInOrder(uint32_t timestamp) {
|
||||
// Assume that a diff which is bigger than half the timestamp interval
|
||||
// (32 bits) must be due to reordering. This code is almost identical to
|
||||
// that in IsNewerTimestamp() in module_common_types.h.
|
||||
uint32_t timestamp_diff = timestamp -
|
||||
current_timestamp_group_.first_timestamp;
|
||||
uint32_t timestamp_diff =
|
||||
timestamp - current_timestamp_group_.first_timestamp;
|
||||
return timestamp_diff < 0x80000000;
|
||||
}
|
||||
}
|
||||
@ -128,8 +128,8 @@ bool InterArrival::NewTimestampGroup(int64_t arrival_time_ms,
|
||||
} else if (BelongsToBurst(arrival_time_ms, timestamp)) {
|
||||
return false;
|
||||
} else {
|
||||
uint32_t timestamp_diff = timestamp -
|
||||
current_timestamp_group_.first_timestamp;
|
||||
uint32_t timestamp_diff =
|
||||
timestamp - current_timestamp_group_.first_timestamp;
|
||||
return timestamp_diff > kTimestampGroupLengthTicks;
|
||||
}
|
||||
}
|
||||
@ -140,15 +140,15 @@ bool InterArrival::BelongsToBurst(int64_t arrival_time_ms,
|
||||
return false;
|
||||
}
|
||||
assert(current_timestamp_group_.complete_time_ms >= 0);
|
||||
int64_t arrival_time_delta_ms = arrival_time_ms -
|
||||
current_timestamp_group_.complete_time_ms;
|
||||
int64_t arrival_time_delta_ms =
|
||||
arrival_time_ms - current_timestamp_group_.complete_time_ms;
|
||||
uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
|
||||
int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5;
|
||||
if (ts_delta_ms == 0)
|
||||
return true;
|
||||
int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms;
|
||||
return propagation_delta_ms < 0 &&
|
||||
arrival_time_delta_ms <= kBurstDeltaThresholdMs;
|
||||
arrival_time_delta_ms <= kBurstDeltaThresholdMs;
|
||||
}
|
||||
|
||||
void InterArrival::Reset() {
|
||||
|
||||
@ -54,14 +54,9 @@ class InterArrival {
|
||||
private:
|
||||
struct TimestampGroup {
|
||||
TimestampGroup()
|
||||
: size(0),
|
||||
first_timestamp(0),
|
||||
timestamp(0),
|
||||
complete_time_ms(-1) {}
|
||||
: size(0), first_timestamp(0), timestamp(0), complete_time_ms(-1) {}
|
||||
|
||||
bool IsFirstPacket() const {
|
||||
return complete_time_ms == -1;
|
||||
}
|
||||
bool IsFirstPacket() const { return complete_time_ms == -1; }
|
||||
|
||||
size_t size;
|
||||
uint32_t first_timestamp;
|
||||
|
||||
@ -36,18 +36,15 @@ class InterArrivalTest : public ::testing::Test {
|
||||
inter_arrival_.reset(
|
||||
new InterArrival(kTimestampGroupLengthUs / 1000, 1.0, true));
|
||||
inter_arrival_rtp_.reset(new InterArrival(
|
||||
MakeRtpTimestamp(kTimestampGroupLengthUs),
|
||||
kRtpTimestampToMs,
|
||||
true));
|
||||
MakeRtpTimestamp(kTimestampGroupLengthUs), kRtpTimestampToMs, true));
|
||||
inter_arrival_ast_.reset(new InterArrival(
|
||||
MakeAbsSendTime(kTimestampGroupLengthUs),
|
||||
kAstToMs,
|
||||
true));
|
||||
MakeAbsSendTime(kTimestampGroupLengthUs), kAstToMs, true));
|
||||
}
|
||||
|
||||
// Test that neither inter_arrival instance complete the timestamp group from
|
||||
// the given data.
|
||||
void ExpectFalse(int64_t timestamp_us, int64_t arrival_time_ms,
|
||||
void ExpectFalse(int64_t timestamp_us,
|
||||
int64_t arrival_time_ms,
|
||||
size_t packet_size) {
|
||||
InternalExpectFalse(inter_arrival_rtp_.get(),
|
||||
MakeRtpTimestamp(timestamp_us), arrival_time_ms,
|
||||
@ -60,8 +57,10 @@ class InterArrivalTest : public ::testing::Test {
|
||||
// the given data and that all returned deltas are as expected (except
|
||||
// timestamp delta, which is rounded from us to different ranges and must
|
||||
// match within an interval, given in |timestamp_near].
|
||||
void ExpectTrue(int64_t timestamp_us, int64_t arrival_time_ms,
|
||||
size_t packet_size, int64_t expected_timestamp_delta_us,
|
||||
void ExpectTrue(int64_t timestamp_us,
|
||||
int64_t arrival_time_ms,
|
||||
size_t packet_size,
|
||||
int64_t expected_timestamp_delta_us,
|
||||
int64_t expected_arrival_time_delta_ms,
|
||||
int expected_packet_size_delta,
|
||||
uint32_t timestamp_near) {
|
||||
@ -77,7 +76,8 @@ class InterArrivalTest : public ::testing::Test {
|
||||
expected_packet_size_delta, timestamp_near << 8);
|
||||
}
|
||||
|
||||
void WrapTestHelper(int64_t wrap_start_us, uint32_t timestamp_near,
|
||||
void WrapTestHelper(int64_t wrap_start_us,
|
||||
uint32_t timestamp_near,
|
||||
bool unorderly_within_group) {
|
||||
// Step through the range of a 32 bit int, 1/4 at a time to not cause
|
||||
// packets close to wraparound to be judged as out of order.
|
||||
@ -92,21 +92,21 @@ class InterArrivalTest : public ::testing::Test {
|
||||
|
||||
// G3
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(wrap_start_us / 2, arrival_time, 1,
|
||||
wrap_start_us / 4, 6, 0, // Delta G2-G1
|
||||
ExpectTrue(wrap_start_us / 2, arrival_time, 1, wrap_start_us / 4, 6,
|
||||
0, // Delta G2-G1
|
||||
0);
|
||||
|
||||
// G4
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
int64_t g4_arrival_time = arrival_time;
|
||||
ExpectTrue(wrap_start_us / 2 + wrap_start_us / 4, arrival_time, 1,
|
||||
wrap_start_us / 4, 6, 0, // Delta G3-G2
|
||||
wrap_start_us / 4, 6, 0, // Delta G3-G2
|
||||
timestamp_near);
|
||||
|
||||
// G5
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(wrap_start_us, arrival_time, 2,
|
||||
wrap_start_us / 4, 6, 0, // Delta G4-G3
|
||||
ExpectTrue(wrap_start_us, arrival_time, 2, wrap_start_us / 4, 6,
|
||||
0, // Delta G4-G3
|
||||
timestamp_near);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
// Slowly step across the wrap point.
|
||||
@ -141,12 +141,10 @@ class InterArrivalTest : public ::testing::Test {
|
||||
|
||||
// G7
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs,
|
||||
arrival_time, 100,
|
||||
ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs, arrival_time, 100,
|
||||
// Delta G6-G5
|
||||
kTriggerNewGroupUs - 9 * kMinStep,
|
||||
g6_arrival_time - g5_arrival_time,
|
||||
10 - (2 + 10),
|
||||
g6_arrival_time - g5_arrival_time, 10 - (2 + 10),
|
||||
timestamp_near);
|
||||
}
|
||||
|
||||
@ -158,13 +156,16 @@ class InterArrivalTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
static uint32_t MakeAbsSendTime(int64_t us) {
|
||||
uint32_t absolute_send_time = static_cast<uint32_t>(
|
||||
((static_cast<uint64_t>(us) << 18) + 500000) / 1000000) & 0x00FFFFFFul;
|
||||
uint32_t absolute_send_time =
|
||||
static_cast<uint32_t>(((static_cast<uint64_t>(us) << 18) + 500000) /
|
||||
1000000) &
|
||||
0x00FFFFFFul;
|
||||
return absolute_send_time << 8;
|
||||
}
|
||||
|
||||
static void InternalExpectFalse(InterArrival* inter_arrival,
|
||||
uint32_t timestamp, int64_t arrival_time_ms,
|
||||
uint32_t timestamp,
|
||||
int64_t arrival_time_ms,
|
||||
size_t packet_size) {
|
||||
uint32_t dummy_timestamp = 101;
|
||||
int64_t dummy_arrival_time_ms = 303;
|
||||
@ -179,7 +180,8 @@ class InterArrivalTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
static void InternalExpectTrue(InterArrival* inter_arrival,
|
||||
uint32_t timestamp, int64_t arrival_time_ms,
|
||||
uint32_t timestamp,
|
||||
int64_t arrival_time_ms,
|
||||
size_t packet_size,
|
||||
uint32_t expected_timestamp_delta,
|
||||
int64_t expected_arrival_time_delta_ms,
|
||||
@ -222,8 +224,7 @@ TEST_F(InterArrivalTest, FirstGroup) {
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
|
||||
// Delta G2-G1
|
||||
kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
|
||||
0);
|
||||
kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0);
|
||||
}
|
||||
|
||||
TEST_F(InterArrivalTest, SecondGroup) {
|
||||
@ -242,16 +243,14 @@ TEST_F(InterArrivalTest, SecondGroup) {
|
||||
int64_t g3_arrival_time = arrival_time;
|
||||
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
|
||||
// Delta G2-G1
|
||||
kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
|
||||
0);
|
||||
kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0);
|
||||
|
||||
// G4
|
||||
// First packet of 4th group yields deltas between group 2 and 3.
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(3 * kTriggerNewGroupUs, arrival_time, 2,
|
||||
// Delta G3-G2
|
||||
kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1,
|
||||
0);
|
||||
kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1, 0);
|
||||
}
|
||||
|
||||
TEST_F(InterArrivalTest, AccumulatedGroup) {
|
||||
@ -275,9 +274,9 @@ TEST_F(InterArrivalTest, AccumulatedGroup) {
|
||||
|
||||
// G3
|
||||
arrival_time = 500;
|
||||
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100,
|
||||
g2_timestamp, g2_arrival_time - g1_arrival_time,
|
||||
(2 + 10) - 1, // Delta G2-G1
|
||||
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100, g2_timestamp,
|
||||
g2_arrival_time - g1_arrival_time,
|
||||
(2 + 10) - 1, // Delta G2-G1
|
||||
0);
|
||||
}
|
||||
|
||||
@ -311,8 +310,7 @@ TEST_F(InterArrivalTest, OutOfOrderPacket) {
|
||||
ExpectTrue(timestamp, arrival_time, 100,
|
||||
// Delta G2-G1
|
||||
g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
|
||||
(2 + 10) - 1,
|
||||
0);
|
||||
(2 + 10) - 1, 0);
|
||||
}
|
||||
|
||||
TEST_F(InterArrivalTest, OutOfOrderWithinGroup) {
|
||||
@ -347,10 +345,8 @@ TEST_F(InterArrivalTest, OutOfOrderWithinGroup) {
|
||||
// G3
|
||||
timestamp = 2 * kTriggerNewGroupUs;
|
||||
arrival_time = 500;
|
||||
ExpectTrue(timestamp, arrival_time, 100,
|
||||
g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
|
||||
(2 + 10) - 1,
|
||||
0);
|
||||
ExpectTrue(timestamp, arrival_time, 100, g2_timestamp - g1_timestamp,
|
||||
g2_arrival_time - g1_arrival_time, (2 + 10) - 1, 0);
|
||||
}
|
||||
|
||||
TEST_F(InterArrivalTest, TwoBursts) {
|
||||
@ -373,13 +369,12 @@ TEST_F(InterArrivalTest, TwoBursts) {
|
||||
// G3
|
||||
timestamp += 30000;
|
||||
arrival_time += kBurstThresholdMs + 1;
|
||||
ExpectTrue(timestamp, arrival_time, 100,
|
||||
g2_timestamp, g2_arrival_time - g1_arrival_time,
|
||||
ExpectTrue(timestamp, arrival_time, 100, g2_timestamp,
|
||||
g2_arrival_time - g1_arrival_time,
|
||||
10 - 1, // Delta G2-G1
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(InterArrivalTest, NoBursts) {
|
||||
// G1
|
||||
ExpectFalse(0, 17, 1);
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#include "modules/remote_bitrate_estimator/overuse_detector.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@ -142,8 +142,7 @@ void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) {
|
||||
const double k = fabs(modified_offset) < threshold_ ? k_down_ : k_up_;
|
||||
const int64_t kMaxTimeDeltaMs = 100;
|
||||
int64_t time_delta_ms = std::min(now_ms - last_update_ms_, kMaxTimeDeltaMs);
|
||||
threshold_ +=
|
||||
k * (fabs(modified_offset) - threshold_) * time_delta_ms;
|
||||
threshold_ += k * (fabs(modified_offset) - threshold_) * time_delta_ms;
|
||||
threshold_ = rtc::SafeClamp(threshold_, 6.f, 600.f);
|
||||
last_update_ms_ = now_ms;
|
||||
}
|
||||
|
||||
@ -41,11 +41,11 @@ class OveruseDetectorTest : public ::testing::Test {
|
||||
random_(123456789) {}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
overuse_detector_.reset(new OveruseDetector());
|
||||
}
|
||||
void SetUp() override { overuse_detector_.reset(new OveruseDetector()); }
|
||||
|
||||
int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms,
|
||||
int Run100000Samples(int packets_per_frame,
|
||||
size_t packet_size,
|
||||
int mean_ms,
|
||||
int standard_deviation_ms) {
|
||||
int unique_overuse = 0;
|
||||
int last_overuse = -1;
|
||||
@ -69,8 +69,11 @@ class OveruseDetectorTest : public ::testing::Test {
|
||||
return unique_overuse;
|
||||
}
|
||||
|
||||
int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms,
|
||||
int standard_deviation_ms, int drift_per_frame_ms) {
|
||||
int RunUntilOveruse(int packets_per_frame,
|
||||
size_t packet_size,
|
||||
int mean_ms,
|
||||
int standard_deviation_ms,
|
||||
int drift_per_frame_ms) {
|
||||
// Simulate a higher send pace, that is too high.
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
for (int j = 0; j < packets_per_frame; ++j) {
|
||||
@ -89,7 +92,8 @@ class OveruseDetectorTest : public ::testing::Test {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms,
|
||||
void UpdateDetector(uint32_t rtp_timestamp,
|
||||
int64_t receive_time_ms,
|
||||
size_t packet_size) {
|
||||
uint32_t timestamp_delta;
|
||||
int64_t time_delta;
|
||||
@ -189,8 +193,9 @@ TEST_F(OveruseDetectorTest, SimpleOveruse2000Kbit30fps) {
|
||||
frame_duration_ms, sigma_ms);
|
||||
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(7, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -204,8 +209,9 @@ TEST_F(OveruseDetectorTest, SimpleOveruse100kbit10fps) {
|
||||
frame_duration_ms, sigma_ms);
|
||||
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(7, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -328,8 +334,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance30Kbit3fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(20, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -342,8 +349,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(4, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -356,8 +364,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -370,8 +379,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(4, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -390,8 +400,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit5fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(20, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -410,8 +421,9 @@ TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit5fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -430,8 +442,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit10fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(20, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -450,8 +463,9 @@ TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit10fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -470,8 +484,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance300Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(19, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -484,8 +499,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(5, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -498,8 +514,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -512,8 +529,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(10, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -532,8 +550,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance1000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(19, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -546,8 +565,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(5, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -560,8 +580,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -574,8 +595,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(10, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -594,8 +616,9 @@ TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance2000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(19, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -608,8 +631,9 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(5, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -622,8 +646,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(44, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -636,8 +661,9 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) {
|
||||
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms);
|
||||
EXPECT_EQ(0, unique_overuse);
|
||||
int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
|
||||
frame_duration_ms, sigma_ms, drift_per_frame_ms);
|
||||
int frames_until_overuse =
|
||||
RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
|
||||
sigma_ms, drift_per_frame_ms);
|
||||
EXPECT_EQ(10, frames_until_overuse);
|
||||
}
|
||||
|
||||
@ -648,9 +674,7 @@ class OveruseDetectorExperimentTest : public OveruseDetectorTest {
|
||||
"WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
overuse_detector_.reset(new OveruseDetector());
|
||||
}
|
||||
void SetUp() override { overuse_detector_.reset(new OveruseDetector()); }
|
||||
|
||||
test::ScopedFieldTrials override_field_trials_;
|
||||
};
|
||||
|
||||
@ -73,12 +73,12 @@ void OveruseEstimator::Update(int64_t t_delta,
|
||||
}
|
||||
|
||||
const double h[2] = {fs_delta, 1.0};
|
||||
const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1],
|
||||
E_[1][0]*h[0] + E_[1][1]*h[1]};
|
||||
const double Eh[2] = {E_[0][0] * h[0] + E_[0][1] * h[1],
|
||||
E_[1][0] * h[0] + E_[1][1] * h[1]};
|
||||
|
||||
BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_);
|
||||
|
||||
const double residual = t_ts_delta - slope_*h[0] - offset_;
|
||||
const double residual = t_ts_delta - slope_ * h[0] - offset_;
|
||||
|
||||
const bool in_stable_state =
|
||||
(current_hypothesis == BandwidthUsage::kBwNormal);
|
||||
@ -92,13 +92,12 @@ void OveruseEstimator::Update(int64_t t_delta,
|
||||
min_frame_period, in_stable_state);
|
||||
}
|
||||
|
||||
const double denom = var_noise_ + h[0]*Eh[0] + h[1]*Eh[1];
|
||||
const double denom = var_noise_ + h[0] * Eh[0] + h[1] * Eh[1];
|
||||
|
||||
const double K[2] = {Eh[0] / denom,
|
||||
Eh[1] / denom};
|
||||
const double K[2] = {Eh[0] / denom, Eh[1] / denom};
|
||||
|
||||
const double IKh[2][2] = {{1.0 - K[0]*h[0], -K[0]*h[1]},
|
||||
{-K[1]*h[0], 1.0 - K[1]*h[1]}};
|
||||
const double IKh[2][2] = {{1.0 - K[0] * h[0], -K[0] * h[1]},
|
||||
{-K[1] * h[0], 1.0 - K[1] * h[1]}};
|
||||
const double e00 = E_[0][0];
|
||||
const double e01 = E_[0][1];
|
||||
|
||||
@ -109,7 +108,8 @@ void OveruseEstimator::Update(int64_t t_delta,
|
||||
E_[1][1] = e01 * IKh[1][0] + E_[1][1] * IKh[1][1];
|
||||
|
||||
// The covariance matrix must be positive semi-definite.
|
||||
bool positive_semi_definite = E_[0][0] + E_[1][1] >= 0 &&
|
||||
bool positive_semi_definite =
|
||||
E_[0][0] + E_[1][1] >= 0 &&
|
||||
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0;
|
||||
assert(positive_semi_definite);
|
||||
if (!positive_semi_definite) {
|
||||
@ -150,16 +150,15 @@ void OveruseEstimator::UpdateNoiseEstimate(double residual,
|
||||
// of the network. |alpha| is tuned for 30 frames per second, but is scaled
|
||||
// according to |ts_delta|.
|
||||
double alpha = 0.01;
|
||||
if (num_of_deltas_ > 10*30) {
|
||||
if (num_of_deltas_ > 10 * 30) {
|
||||
alpha = 0.002;
|
||||
}
|
||||
// Only update the noise estimate if we're not over-using. |beta| is a
|
||||
// function of alpha and the time delta since the previous update.
|
||||
const double beta = pow(1 - alpha, ts_delta * 30.0 / 1000.0);
|
||||
avg_noise_ = beta * avg_noise_
|
||||
+ (1 - beta) * residual;
|
||||
var_noise_ = beta * var_noise_
|
||||
+ (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual);
|
||||
avg_noise_ = beta * avg_noise_ + (1 - beta) * residual;
|
||||
var_noise_ = beta * var_noise_ +
|
||||
(1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual);
|
||||
if (var_noise_ < 1) {
|
||||
var_noise_ = 1;
|
||||
}
|
||||
|
||||
@ -34,20 +34,14 @@ class OveruseEstimator {
|
||||
int64_t now_ms);
|
||||
|
||||
// Returns the estimated noise/jitter variance in ms^2.
|
||||
double var_noise() const {
|
||||
return var_noise_;
|
||||
}
|
||||
double var_noise() const { return var_noise_; }
|
||||
|
||||
// Returns the estimated inter-arrival time delta offset in ms.
|
||||
double offset() const {
|
||||
return offset_;
|
||||
}
|
||||
double offset() const { return offset_; }
|
||||
|
||||
// Returns the number of deltas which the current over-use estimator state is
|
||||
// based on.
|
||||
unsigned int num_of_deltas() const {
|
||||
return num_of_deltas_;
|
||||
}
|
||||
unsigned int num_of_deltas() const { return num_of_deltas_; }
|
||||
|
||||
private:
|
||||
double UpdateMinFramePeriod(double ts_delta);
|
||||
|
||||
@ -35,15 +35,15 @@ enum {
|
||||
kExpectedNumberOfProbes = 3
|
||||
};
|
||||
|
||||
static const double kTimestampToMs = 1000.0 /
|
||||
static_cast<double>(1 << kInterArrivalShift);
|
||||
static const double kTimestampToMs =
|
||||
1000.0 / static_cast<double>(1 << kInterArrivalShift);
|
||||
|
||||
template<typename K, typename V>
|
||||
template <typename K, typename V>
|
||||
std::vector<K> Keys(const std::map<K, V>& map) {
|
||||
std::vector<K> keys;
|
||||
keys.reserve(map.size());
|
||||
for (typename std::map<K, V>::const_iterator it = map.begin();
|
||||
it != map.end(); ++it) {
|
||||
it != map.end(); ++it) {
|
||||
keys.push_back(it->first);
|
||||
}
|
||||
return keys;
|
||||
@ -61,39 +61,38 @@ uint32_t ConvertMsTo24Bits(int64_t time_ms) {
|
||||
bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds(
|
||||
int send_delta_ms,
|
||||
const Cluster& cluster_aggregate) {
|
||||
if (cluster_aggregate.count == 0)
|
||||
return true;
|
||||
float cluster_mean = cluster_aggregate.send_mean_ms /
|
||||
static_cast<float>(cluster_aggregate.count);
|
||||
return fabs(static_cast<float>(send_delta_ms) - cluster_mean) < 2.5f;
|
||||
}
|
||||
if (cluster_aggregate.count == 0)
|
||||
return true;
|
||||
float cluster_mean = cluster_aggregate.send_mean_ms /
|
||||
static_cast<float>(cluster_aggregate.count);
|
||||
return fabs(static_cast<float>(send_delta_ms) - cluster_mean) < 2.5f;
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTime::AddCluster(
|
||||
std::list<Cluster>* clusters,
|
||||
Cluster* cluster) {
|
||||
cluster->send_mean_ms /= static_cast<float>(cluster->count);
|
||||
cluster->recv_mean_ms /= static_cast<float>(cluster->count);
|
||||
cluster->mean_size /= cluster->count;
|
||||
clusters->push_back(*cluster);
|
||||
}
|
||||
void RemoteBitrateEstimatorAbsSendTime::AddCluster(std::list<Cluster>* clusters,
|
||||
Cluster* cluster) {
|
||||
cluster->send_mean_ms /= static_cast<float>(cluster->count);
|
||||
cluster->recv_mean_ms /= static_cast<float>(cluster->count);
|
||||
cluster->mean_size /= cluster->count;
|
||||
clusters->push_back(*cluster);
|
||||
}
|
||||
|
||||
RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(
|
||||
RemoteBitrateObserver* observer,
|
||||
const Clock* clock)
|
||||
: clock_(clock),
|
||||
observer_(observer),
|
||||
inter_arrival_(),
|
||||
estimator_(),
|
||||
detector_(),
|
||||
incoming_bitrate_(kBitrateWindowMs, 8000),
|
||||
incoming_bitrate_initialized_(false),
|
||||
total_probes_received_(0),
|
||||
first_packet_time_ms_(-1),
|
||||
last_update_ms_(-1),
|
||||
uma_recorded_(false) {
|
||||
RTC_DCHECK(clock_);
|
||||
RTC_DCHECK(observer_);
|
||||
RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating.";
|
||||
RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(
|
||||
RemoteBitrateObserver* observer,
|
||||
const Clock* clock)
|
||||
: clock_(clock),
|
||||
observer_(observer),
|
||||
inter_arrival_(),
|
||||
estimator_(),
|
||||
detector_(),
|
||||
incoming_bitrate_(kBitrateWindowMs, 8000),
|
||||
incoming_bitrate_initialized_(false),
|
||||
total_probes_received_(0),
|
||||
first_packet_time_ms_(-1),
|
||||
last_update_ms_(-1),
|
||||
uma_recorded_(false) {
|
||||
RTC_DCHECK(clock_);
|
||||
RTC_DCHECK(observer_);
|
||||
RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating.";
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
|
||||
@ -102,8 +101,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
|
||||
int64_t prev_send_time = -1;
|
||||
int64_t prev_recv_time = -1;
|
||||
for (std::list<Probe>::const_iterator it = probes_.begin();
|
||||
it != probes_.end();
|
||||
++it) {
|
||||
it != probes_.end(); ++it) {
|
||||
if (prev_send_time >= 0) {
|
||||
int send_delta_ms = it->send_time_ms - prev_send_time;
|
||||
int recv_delta_ms = it->recv_time_ms - prev_recv_time;
|
||||
@ -111,8 +109,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
|
||||
++current.num_above_min_delta;
|
||||
}
|
||||
if (!IsWithinClusterBounds(send_delta_ms, current)) {
|
||||
if (current.count >= kMinClusterSize &&
|
||||
current.send_mean_ms > 0.0f &&
|
||||
if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f &&
|
||||
current.recv_mean_ms > 0.0f) {
|
||||
AddCluster(clusters, ¤t);
|
||||
}
|
||||
@ -126,8 +123,7 @@ void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
|
||||
prev_send_time = it->send_time_ms;
|
||||
prev_recv_time = it->recv_time_ms;
|
||||
}
|
||||
if (current.count >= kMinClusterSize &&
|
||||
current.send_mean_ms > 0.0f &&
|
||||
if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f &&
|
||||
current.recv_mean_ms > 0.0f) {
|
||||
AddCluster(clusters, ¤t);
|
||||
}
|
||||
@ -139,8 +135,7 @@ RemoteBitrateEstimatorAbsSendTime::FindBestProbe(
|
||||
int highest_probe_bitrate_bps = 0;
|
||||
std::list<Cluster>::const_iterator best_it = clusters.end();
|
||||
for (std::list<Cluster>::const_iterator it = clusters.begin();
|
||||
it != clusters.end();
|
||||
++it) {
|
||||
it != clusters.end(); ++it) {
|
||||
if (it->send_mean_ms == 0 || it->recv_mean_ms == 0)
|
||||
continue;
|
||||
if (it->num_above_min_delta > it->count / 2 &&
|
||||
|
||||
@ -14,14 +14,15 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RemoteBitrateEstimatorAbsSendTimeTest :
|
||||
public RemoteBitrateEstimatorTest {
|
||||
class RemoteBitrateEstimatorAbsSendTimeTest
|
||||
: public RemoteBitrateEstimatorTest {
|
||||
public:
|
||||
RemoteBitrateEstimatorAbsSendTimeTest() {}
|
||||
virtual void SetUp() {
|
||||
bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime(
|
||||
bitrate_observer_.get(), &clock_));
|
||||
}
|
||||
|
||||
protected:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorAbsSendTimeTest);
|
||||
};
|
||||
|
||||
@ -76,8 +76,8 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
uma_recorded_ = true;
|
||||
}
|
||||
uint32_t ssrc = header.ssrc;
|
||||
uint32_t rtp_timestamp = header.timestamp +
|
||||
header.extension.transmissionTimeOffset;
|
||||
uint32_t rtp_timestamp =
|
||||
header.timestamp + header.extension.transmissionTimeOffset;
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc);
|
||||
@ -152,7 +152,7 @@ int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() {
|
||||
rtc::CritScope cs_(&crit_sect_);
|
||||
RTC_DCHECK_GT(process_interval_ms_, 0);
|
||||
return last_process_time_ + process_interval_ms_ -
|
||||
clock_->TimeInMilliseconds();
|
||||
clock_->TimeInMilliseconds();
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
@ -184,10 +184,9 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
}
|
||||
AimdRateControl* remote_rate = GetRemoteRate();
|
||||
|
||||
double mean_noise_var = sum_var_noise /
|
||||
static_cast<double>(overuse_detectors_.size());
|
||||
const RateControlInput input(bw_state,
|
||||
incoming_bitrate_.Rate(now_ms),
|
||||
double mean_noise_var =
|
||||
sum_var_noise / static_cast<double>(overuse_detectors_.size());
|
||||
const RateControlInput input(bw_state, incoming_bitrate_.Rate(now_ms),
|
||||
mean_noise_var);
|
||||
uint32_t target_bitrate = remote_rate->Update(&input, now_ms);
|
||||
if (remote_rate->ValidEstimate()) {
|
||||
@ -237,7 +236,7 @@ void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
ssrcs->resize(overuse_detectors_.size());
|
||||
int i = 0;
|
||||
for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();
|
||||
it != overuse_detectors_.end(); ++it, ++i) {
|
||||
it != overuse_detectors_.end(); ++it, ++i) {
|
||||
(*ssrcs)[i] = it->first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,14 +14,14 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RemoteBitrateEstimatorSingleTest :
|
||||
public RemoteBitrateEstimatorTest {
|
||||
class RemoteBitrateEstimatorSingleTest : public RemoteBitrateEstimatorTest {
|
||||
public:
|
||||
RemoteBitrateEstimatorSingleTest() {}
|
||||
virtual void SetUp() {
|
||||
bitrate_estimator_.reset(new RemoteBitrateEstimatorSingleStream(
|
||||
bitrate_observer_.get(), &clock_));
|
||||
}
|
||||
|
||||
protected:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorSingleTest);
|
||||
};
|
||||
|
||||
@ -69,8 +69,10 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) {
|
||||
RtpPacket* packet = new RtpPacket;
|
||||
packet->send_time = time_now_us + kSendSideOffsetUs;
|
||||
packet->size = packet_size;
|
||||
packet->rtp_timestamp = rtp_timestamp_offset_ + static_cast<uint32_t>(
|
||||
((frequency_ / 1000) * packet->send_time + 500) / 1000);
|
||||
packet->rtp_timestamp =
|
||||
rtp_timestamp_offset_ +
|
||||
static_cast<uint32_t>(((frequency_ / 1000) * packet->send_time + 500) /
|
||||
1000);
|
||||
packet->ssrc = ssrc_;
|
||||
packets->push_back(packet);
|
||||
}
|
||||
@ -90,11 +92,12 @@ RtpStream::RtcpPacket* RtpStream::Rtcp(int64_t time_now_us) {
|
||||
}
|
||||
RtcpPacket* rtcp = new RtcpPacket;
|
||||
int64_t send_time_us = time_now_us + kSendSideOffsetUs;
|
||||
rtcp->timestamp = rtp_timestamp_offset_ + static_cast<uint32_t>(
|
||||
((frequency_ / 1000) * send_time_us + 500) / 1000);
|
||||
rtcp->timestamp =
|
||||
rtp_timestamp_offset_ +
|
||||
static_cast<uint32_t>(((frequency_ / 1000) * send_time_us + 500) / 1000);
|
||||
rtcp->ntp_secs = send_time_us / 1000000;
|
||||
rtcp->ntp_frac = static_cast<int64_t>((send_time_us % 1000000) *
|
||||
kNtpFracPerMs);
|
||||
rtcp->ntp_frac =
|
||||
static_cast<int64_t>((send_time_us % 1000000) * kNtpFracPerMs);
|
||||
rtcp->ssrc = ssrc_;
|
||||
next_rtcp_time_ = time_now_us + kRtcpIntervalUs;
|
||||
return rtcp;
|
||||
@ -119,12 +122,10 @@ bool RtpStream::Compare(const std::pair<uint32_t, RtpStream*>& left,
|
||||
}
|
||||
|
||||
StreamGenerator::StreamGenerator(int capacity, int64_t time_now)
|
||||
: capacity_(capacity),
|
||||
prev_arrival_time_us_(time_now) {}
|
||||
: capacity_(capacity), prev_arrival_time_us_(time_now) {}
|
||||
|
||||
StreamGenerator::~StreamGenerator() {
|
||||
for (StreamMap::iterator it = streams_.begin(); it != streams_.end();
|
||||
++it) {
|
||||
for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
streams_.clear();
|
||||
@ -153,8 +154,9 @@ void StreamGenerator::SetBitrateBps(int bitrate_bps) {
|
||||
int total_bitrate_after = 0;
|
||||
for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
bitrate_before += it->second->bitrate_bps();
|
||||
int64_t bitrate_after = (bitrate_before * bitrate_bps +
|
||||
total_bitrate_before / 2) / total_bitrate_before;
|
||||
int64_t bitrate_after =
|
||||
(bitrate_before * bitrate_bps + total_bitrate_before / 2) /
|
||||
total_bitrate_before;
|
||||
it->second->set_bitrate_bps(bitrate_after - total_bitrate_after);
|
||||
total_bitrate_after += it->second->bitrate_bps();
|
||||
}
|
||||
@ -174,17 +176,18 @@ int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets,
|
||||
assert(packets != NULL);
|
||||
assert(packets->empty());
|
||||
assert(capacity_ > 0);
|
||||
StreamMap::iterator it = std::min_element(streams_.begin(), streams_.end(),
|
||||
RtpStream::Compare);
|
||||
StreamMap::iterator it =
|
||||
std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
|
||||
(*it).second->GenerateFrame(time_now_us, packets);
|
||||
int i = 0;
|
||||
for (RtpStream::PacketList::iterator packet_it = packets->begin();
|
||||
packet_it != packets->end(); ++packet_it) {
|
||||
packet_it != packets->end(); ++packet_it) {
|
||||
int capacity_bpus = capacity_ / 1000;
|
||||
int64_t required_network_time_us =
|
||||
(8 * 1000 * (*packet_it)->size + capacity_bpus / 2) / capacity_bpus;
|
||||
prev_arrival_time_us_ = std::max(time_now_us + required_network_time_us,
|
||||
prev_arrival_time_us_ + required_network_time_us);
|
||||
prev_arrival_time_us_ =
|
||||
std::max(time_now_us + required_network_time_us,
|
||||
prev_arrival_time_us_ + required_network_time_us);
|
||||
(*packet_it)->arrival_time = prev_arrival_time_us_;
|
||||
++i;
|
||||
}
|
||||
@ -196,21 +199,21 @@ int64_t StreamGenerator::GenerateFrame(RtpStream::PacketList* packets,
|
||||
RemoteBitrateEstimatorTest::RemoteBitrateEstimatorTest()
|
||||
: clock_(100000000),
|
||||
bitrate_observer_(new testing::TestBitrateObserver),
|
||||
stream_generator_(new testing::StreamGenerator(
|
||||
1e6, // Capacity.
|
||||
clock_.TimeInMicroseconds())),
|
||||
stream_generator_(
|
||||
new testing::StreamGenerator(1e6, // Capacity.
|
||||
clock_.TimeInMicroseconds())),
|
||||
arrival_time_offset_ms_(0) {}
|
||||
|
||||
RemoteBitrateEstimatorTest::~RemoteBitrateEstimatorTest() {}
|
||||
|
||||
void RemoteBitrateEstimatorTest::AddDefaultStream() {
|
||||
stream_generator_->AddStream(new testing::RtpStream(
|
||||
30, // Frames per second.
|
||||
3e5, // Bitrate.
|
||||
1, // SSRC.
|
||||
90000, // RTP frequency.
|
||||
0xFFFFF000, // Timestamp offset.
|
||||
0)); // RTCP receive time.
|
||||
stream_generator_->AddStream(
|
||||
new testing::RtpStream(30, // Frames per second.
|
||||
3e5, // Bitrate.
|
||||
1, // SSRC.
|
||||
90000, // RTP frequency.
|
||||
0xFFFFF000, // Timestamp offset.
|
||||
0)); // RTCP receive time.
|
||||
}
|
||||
|
||||
uint32_t RemoteBitrateEstimatorTest::AbsSendTime(int64_t t, int64_t denom) {
|
||||
@ -250,8 +253,8 @@ bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(uint32_t ssrc,
|
||||
RTC_DCHECK_GT(bitrate_bps, 0);
|
||||
stream_generator_->SetBitrateBps(bitrate_bps);
|
||||
testing::RtpStream::PacketList packets;
|
||||
int64_t next_time_us = stream_generator_->GenerateFrame(
|
||||
&packets, clock_.TimeInMicroseconds());
|
||||
int64_t next_time_us =
|
||||
stream_generator_->GenerateFrame(&packets, clock_.TimeInMicroseconds());
|
||||
bool overuse = false;
|
||||
while (!packets.empty()) {
|
||||
testing::RtpStream::RtpPacket* packet = packets.front();
|
||||
@ -339,8 +342,8 @@ void RemoteBitrateEstimatorTest::InitialBehaviorTestHelper(
|
||||
absolute_send_time);
|
||||
clock_.AdvanceTimeMilliseconds(1000 / kFramerate);
|
||||
timestamp += 90 * kFrameIntervalMs;
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
|
||||
}
|
||||
bitrate_estimator_->Process();
|
||||
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||
@ -377,19 +380,18 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper(
|
||||
absolute_send_time);
|
||||
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
|
||||
timestamp += 90 * kFrameIntervalMs;
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
|
||||
}
|
||||
bitrate_estimator_->Process();
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
EXPECT_NEAR(expected_bitrate_bps,
|
||||
bitrate_observer_->latest_bitrate(),
|
||||
EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(),
|
||||
kAcceptedBitrateErrorBps);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
|
||||
timestamp += 2 * 90 * kFrameIntervalMs;
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
2 * kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, 2 * kFrameIntervalAbsSendTime);
|
||||
IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp,
|
||||
absolute_send_time);
|
||||
IncomingPacket(
|
||||
@ -400,8 +402,7 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper(
|
||||
}
|
||||
bitrate_estimator_->Process();
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
EXPECT_NEAR(expected_bitrate_bps,
|
||||
bitrate_observer_->latest_bitrate(),
|
||||
EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(),
|
||||
kAcceptedBitrateErrorBps);
|
||||
}
|
||||
|
||||
@ -472,7 +473,8 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
||||
ASSERT_EQ(bitrate_sum, kStartBitrate);
|
||||
}
|
||||
if (wrap_time_stamp) {
|
||||
stream_generator_->set_rtp_timestamp_offset(kDefaultSsrc,
|
||||
stream_generator_->set_rtp_timestamp_offset(
|
||||
kDefaultSsrc,
|
||||
std::numeric_limits<uint32_t>::max() - steady_state_time * 90000);
|
||||
}
|
||||
|
||||
@ -538,8 +540,8 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() {
|
||||
bitrate_estimator_->Process();
|
||||
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
|
||||
timestamp += 90 * kFrameIntervalMs;
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
|
||||
}
|
||||
EXPECT_TRUE(bitrate_observer_->updated());
|
||||
EXPECT_GE(bitrate_observer_->latest_bitrate(), 400000u);
|
||||
@ -558,8 +560,8 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() {
|
||||
absolute_send_time);
|
||||
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs / kTimestampGroupLength);
|
||||
timestamp += 1;
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kSingleRtpTickAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kSingleRtpTickAbsSendTime);
|
||||
}
|
||||
// Increase time until next batch to simulate over-use.
|
||||
clock_.AdvanceTimeMilliseconds(10);
|
||||
@ -575,8 +577,7 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() {
|
||||
EXPECT_LT(bitrate_observer_->latest_bitrate(), 400000u);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorTest::TestWrappingHelper(
|
||||
int silence_time_s) {
|
||||
void RemoteBitrateEstimatorTest::TestWrappingHelper(int silence_time_s) {
|
||||
const int kFramerate = 100;
|
||||
const int kFrameIntervalMs = 1000 / kFramerate;
|
||||
const uint32_t kFrameIntervalAbsSendTime = AbsSendTime(1, kFramerate);
|
||||
@ -588,8 +589,8 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper(
|
||||
absolute_send_time);
|
||||
timestamp += kFrameIntervalMs;
|
||||
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
|
||||
bitrate_estimator_->Process();
|
||||
}
|
||||
uint32_t bitrate_before = 0;
|
||||
@ -597,16 +598,16 @@ void RemoteBitrateEstimatorTest::TestWrappingHelper(
|
||||
bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_before);
|
||||
|
||||
clock_.AdvanceTimeMilliseconds(silence_time_s * 1000);
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
AbsSendTime(silence_time_s, 1));
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, AbsSendTime(silence_time_s, 1));
|
||||
bitrate_estimator_->Process();
|
||||
for (size_t i = 0; i < 21; ++i) {
|
||||
IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp,
|
||||
absolute_send_time);
|
||||
timestamp += kFrameIntervalMs;
|
||||
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
|
||||
absolute_send_time = AddAbsSendTime(absolute_send_time,
|
||||
kFrameIntervalAbsSendTime);
|
||||
absolute_send_time =
|
||||
AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
|
||||
bitrate_estimator_->Process();
|
||||
}
|
||||
uint32_t bitrate_after = 0;
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
|
||||
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/pacing/packet_router.h"
|
||||
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
|
||||
#include "modules/pacing/packet_router.h"
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "test/gmock.h"
|
||||
|
||||
@ -34,15 +34,13 @@ BweReceiver::BweReceiver(int flow_id)
|
||||
: flow_id_(flow_id),
|
||||
received_packets_(kSetCapacity),
|
||||
rate_counter_(),
|
||||
loss_account_() {
|
||||
}
|
||||
loss_account_() {}
|
||||
|
||||
BweReceiver::BweReceiver(int flow_id, int64_t window_size_ms)
|
||||
: flow_id_(flow_id),
|
||||
received_packets_(kSetCapacity),
|
||||
rate_counter_(window_size_ms),
|
||||
loss_account_() {
|
||||
}
|
||||
loss_account_() {}
|
||||
|
||||
void BweReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) {
|
||||
|
||||
@ -34,8 +34,7 @@ namespace testing {
|
||||
namespace bwe {
|
||||
|
||||
PacketProcessorRunner::PacketProcessorRunner(PacketProcessor* processor)
|
||||
: processor_(processor) {
|
||||
}
|
||||
: processor_(processor) {}
|
||||
|
||||
PacketProcessorRunner::~PacketProcessorRunner() {
|
||||
for (Packet* packet : queue_)
|
||||
@ -97,8 +96,7 @@ void PacketProcessorRunner::QueuePackets(Packets* batch,
|
||||
}
|
||||
|
||||
// Plot link capacity by default.
|
||||
BweTest::BweTest() : BweTest(true) {
|
||||
}
|
||||
BweTest::BweTest() : BweTest(true) {}
|
||||
|
||||
BweTest::BweTest(bool plot_capacity)
|
||||
: run_time_ms_(0),
|
||||
@ -117,9 +115,8 @@ BweTest::~BweTest() {
|
||||
void BweTest::SetUp() {
|
||||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
std::string test_name =
|
||||
std::string(test_info->test_case_name()) + "_" +
|
||||
std::string(test_info->name());
|
||||
std::string test_name = std::string(test_info->test_case_name()) + "_" +
|
||||
std::string(test_info->name());
|
||||
BWE_TEST_LOGGING_GLOBAL_CONTEXT(test_name);
|
||||
BWE_TEST_LOGGING_GLOBAL_ENABLE(false);
|
||||
}
|
||||
@ -769,8 +766,8 @@ void BweTest::RunLongTcpFairness(BandwidthEstimatorType bwe_type) {
|
||||
// max_delay_ms = 1000;
|
||||
|
||||
std::string title("5.6_Long_TCP_Fairness");
|
||||
std::string flow_name = std::string() +
|
||||
bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator];
|
||||
std::string flow_name =
|
||||
std::string() + bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator];
|
||||
|
||||
RunFairnessTest(bwe_type, kNumRmcatFlows, kNumTcpFlows, kRunTimeS,
|
||||
kCapacityKbps, max_delay_ms, rtt_ms, kMaxJitterMs, kOffSetsMs,
|
||||
|
||||
@ -133,8 +133,7 @@ class BweTest {
|
||||
Link uplink_;
|
||||
|
||||
private:
|
||||
void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in,
|
||||
Packets* out);
|
||||
void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in, Packets* out);
|
||||
void GiveFeedbackToAffectedSenders(PacketReceiver* receiver);
|
||||
|
||||
int64_t run_time_ms_;
|
||||
|
||||
@ -42,8 +42,7 @@ class BaseLineFileVerify : public BaseLineFileInterface {
|
||||
// the baseline file is missing. This is the default when verifying files, but
|
||||
// not when updating (i.e. we always write it out if missing).
|
||||
BaseLineFileVerify(const std::string& filepath, bool allow_missing_file)
|
||||
: reader_(),
|
||||
fail_to_read_response_(false) {
|
||||
: reader_(), fail_to_read_response_(false) {
|
||||
std::unique_ptr<ResourceFileReader> reader;
|
||||
reader.reset(ResourceFileReader::Create(filepath, "bin"));
|
||||
if (!reader.get()) {
|
||||
@ -72,7 +71,7 @@ class BaseLineFileVerify : public BaseLineFileInterface {
|
||||
reader_->Read(&read_bps) && read_bps == estimate_bps) {
|
||||
} else {
|
||||
printf("ERROR: Baseline differs starting at: %d ms (%d vs %d)!\n",
|
||||
static_cast<uint32_t>(time_ms), estimate_bps, read_bps);
|
||||
static_cast<uint32_t>(time_ms), estimate_bps, read_bps);
|
||||
reader_.reset(NULL);
|
||||
}
|
||||
}
|
||||
@ -101,9 +100,7 @@ class BaseLineFileUpdate : public BaseLineFileInterface {
|
||||
public:
|
||||
BaseLineFileUpdate(const std::string& filepath,
|
||||
BaseLineFileInterface* verifier)
|
||||
: verifier_(verifier),
|
||||
output_content_(),
|
||||
filepath_(filepath) {
|
||||
: verifier_(verifier), output_content_(), filepath_(filepath) {
|
||||
output_content_.push_back(kMagicMarker);
|
||||
output_content_.push_back(kFileVersion1);
|
||||
}
|
||||
@ -126,13 +123,13 @@ class BaseLineFileUpdate : public BaseLineFileInterface {
|
||||
writer.reset(OutputFileWriter::Create(filepath_, "bin"));
|
||||
if (!writer.get()) {
|
||||
printf("WARNING: Cannot create output file: %s.bin\n",
|
||||
filepath_.c_str());
|
||||
filepath_.c_str());
|
||||
return false;
|
||||
}
|
||||
printf("NOTE: Writing baseline file for BWE test: %s.bin\n",
|
||||
filepath_.c_str());
|
||||
for (std::vector<uint32_t>::iterator it = output_content_.begin();
|
||||
it != output_content_.end(); ++it) {
|
||||
it != output_content_.end(); ++it) {
|
||||
writer->Write(*it);
|
||||
}
|
||||
return true;
|
||||
@ -150,7 +147,8 @@ class BaseLineFileUpdate : public BaseLineFileInterface {
|
||||
};
|
||||
|
||||
BaseLineFileInterface* BaseLineFileInterface::Create(
|
||||
const std::string& filename, bool write_output_file) {
|
||||
const std::string& filename,
|
||||
bool write_output_file) {
|
||||
std::string filepath = filename;
|
||||
std::replace(filepath.begin(), filepath.end(), '/', '_');
|
||||
filepath = std::string(kResourceSubDir) + "/" + filepath;
|
||||
|
||||
@ -80,8 +80,8 @@ bool OutputFileWriter::Write(uint32_t value) {
|
||||
|
||||
OutputFileWriter* OutputFileWriter::Create(const std::string& filename,
|
||||
const std::string& extension) {
|
||||
std::string filepath = webrtc::test::OutputPath() + filename + "." +
|
||||
extension;
|
||||
std::string filepath =
|
||||
webrtc::test::OutputPath() + filename + "." + extension;
|
||||
FILE* file = fopen(filepath.c_str(), "wb");
|
||||
if (file == NULL) {
|
||||
BWE_TEST_LOGGING_CONTEXT("OutputFileWriter");
|
||||
|
||||
@ -39,9 +39,7 @@ class DelayCapHelper {
|
||||
return (max_delay_us_ == 0 || max_delay_us_ >= packet_delay_us);
|
||||
}
|
||||
|
||||
const Stats<double>& delay_stats() const {
|
||||
return delay_stats_;
|
||||
}
|
||||
const Stats<double>& delay_stats() const { return delay_stats_; }
|
||||
|
||||
private:
|
||||
int64_t max_delay_us_;
|
||||
@ -50,7 +48,7 @@ class DelayCapHelper {
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(DelayCapHelper);
|
||||
};
|
||||
|
||||
const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids) {
|
||||
const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids) {
|
||||
FlowIds flow_ids(&flow_ids_array[0], flow_ids_array + num_flow_ids);
|
||||
return flow_ids;
|
||||
}
|
||||
@ -109,8 +107,7 @@ Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size)
|
||||
sender_timestamp_us_(send_time_us),
|
||||
payload_size_(payload_size) {}
|
||||
|
||||
Packet::~Packet() {
|
||||
}
|
||||
Packet::~Packet() {}
|
||||
|
||||
bool Packet::operator<(const Packet& rhs) const {
|
||||
return send_time_us_ < rhs.send_time_us_;
|
||||
@ -138,8 +135,7 @@ MediaPacket::MediaPacket(int flow_id,
|
||||
int64_t send_time_us,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header)
|
||||
: Packet(flow_id, send_time_us, payload_size), header_(header) {
|
||||
}
|
||||
: Packet(flow_id, send_time_us, payload_size), header_(header) {}
|
||||
|
||||
MediaPacket::MediaPacket(int64_t send_time_us, uint16_t sequence_number)
|
||||
: Packet(0, send_time_us, 0) {
|
||||
@ -149,8 +145,9 @@ MediaPacket::MediaPacket(int64_t send_time_us, uint16_t sequence_number)
|
||||
|
||||
void MediaPacket::SetAbsSendTimeMs(int64_t abs_send_time_ms) {
|
||||
header_.extension.hasAbsoluteSendTime = true;
|
||||
header_.extension.absoluteSendTime = ((static_cast<int64_t>(abs_send_time_ms *
|
||||
(1 << 18)) + 500) / 1000) & 0x00fffffful;
|
||||
header_.extension.absoluteSendTime =
|
||||
((static_cast<int64_t>(abs_send_time_ms * (1 << 18)) + 500) / 1000) &
|
||||
0x00fffffful;
|
||||
}
|
||||
|
||||
BbrBweFeedback::BbrBweFeedback(
|
||||
@ -168,8 +165,7 @@ RembFeedback::RembFeedback(int flow_id,
|
||||
RTCPReportBlock report_block)
|
||||
: FeedbackPacket(flow_id, send_time_us, last_send_time_ms),
|
||||
estimated_bps_(estimated_bps),
|
||||
report_block_(report_block) {
|
||||
}
|
||||
report_block_(report_block) {}
|
||||
|
||||
SendSideBweFeedback::SendSideBweFeedback(
|
||||
int flow_id,
|
||||
@ -272,7 +268,6 @@ RateCounterFilter::~RateCounterFilter() {
|
||||
LogStats();
|
||||
}
|
||||
|
||||
|
||||
void RateCounterFilter::LogStats() {
|
||||
BWE_TEST_LOGGING_CONTEXT("RateCounterFilter");
|
||||
packets_per_second_stats_.Log("pps");
|
||||
@ -315,15 +310,13 @@ void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
|
||||
LossFilter::LossFilter(PacketProcessorListener* listener, int flow_id)
|
||||
: PacketProcessor(listener, flow_id, kRegular),
|
||||
random_(0x12345678),
|
||||
loss_fraction_(0.0f) {
|
||||
}
|
||||
loss_fraction_(0.0f) {}
|
||||
|
||||
LossFilter::LossFilter(PacketProcessorListener* listener,
|
||||
const FlowIds& flow_ids)
|
||||
: PacketProcessor(listener, flow_ids, kRegular),
|
||||
random_(0x12345678),
|
||||
loss_fraction_(0.0f) {
|
||||
}
|
||||
loss_fraction_(0.0f) {}
|
||||
|
||||
void LossFilter::SetLoss(float loss_percent) {
|
||||
BWE_TEST_LOGGING_ENABLE(false);
|
||||
@ -335,7 +328,7 @@ void LossFilter::SetLoss(float loss_percent) {
|
||||
|
||||
void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
|
||||
assert(in_out);
|
||||
for (PacketsIt it = in_out->begin(); it != in_out->end(); ) {
|
||||
for (PacketsIt it = in_out->begin(); it != in_out->end();) {
|
||||
if (random_.Rand<float>() < loss_fraction_) {
|
||||
delete *it;
|
||||
it = in_out->erase(it);
|
||||
@ -350,15 +343,13 @@ const int64_t kDefaultOneWayDelayUs = 0;
|
||||
DelayFilter::DelayFilter(PacketProcessorListener* listener, int flow_id)
|
||||
: PacketProcessor(listener, flow_id, kRegular),
|
||||
one_way_delay_us_(kDefaultOneWayDelayUs),
|
||||
last_send_time_us_(0) {
|
||||
}
|
||||
last_send_time_us_(0) {}
|
||||
|
||||
DelayFilter::DelayFilter(PacketProcessorListener* listener,
|
||||
const FlowIds& flow_ids)
|
||||
: PacketProcessor(listener, flow_ids, kRegular),
|
||||
one_way_delay_us_(kDefaultOneWayDelayUs),
|
||||
last_send_time_us_(0) {
|
||||
}
|
||||
last_send_time_us_(0) {}
|
||||
|
||||
void DelayFilter::SetOneWayDelayMs(int64_t one_way_delay_ms) {
|
||||
BWE_TEST_LOGGING_ENABLE(false);
|
||||
@ -381,8 +372,7 @@ JitterFilter::JitterFilter(PacketProcessorListener* listener, int flow_id)
|
||||
random_(0x89674523),
|
||||
stddev_jitter_us_(0),
|
||||
last_send_time_us_(0),
|
||||
reordering_(false) {
|
||||
}
|
||||
reordering_(false) {}
|
||||
|
||||
JitterFilter::JitterFilter(PacketProcessorListener* listener,
|
||||
const FlowIds& flow_ids)
|
||||
@ -390,8 +380,7 @@ JitterFilter::JitterFilter(PacketProcessorListener* listener,
|
||||
random_(0x89674523),
|
||||
stddev_jitter_us_(0),
|
||||
last_send_time_us_(0),
|
||||
reordering_(false) {
|
||||
}
|
||||
reordering_(false) {}
|
||||
|
||||
const int kN = 3; // Truncated N sigma gaussian.
|
||||
|
||||
@ -410,7 +399,7 @@ inline int64_t TruncatedNSigmaGaussian(Random* const random,
|
||||
const int64_t gaussian_random = random->Gaussian(mean, std_dev);
|
||||
return rtc::SafeClamp(gaussian_random, -kN * std_dev, kN * std_dev);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void JitterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
|
||||
assert(in_out);
|
||||
@ -448,15 +437,13 @@ int64_t JitterFilter::MeanUs() {
|
||||
ReorderFilter::ReorderFilter(PacketProcessorListener* listener, int flow_id)
|
||||
: PacketProcessor(listener, flow_id, kRegular),
|
||||
random_(0x27452389),
|
||||
reorder_fraction_(0.0f) {
|
||||
}
|
||||
reorder_fraction_(0.0f) {}
|
||||
|
||||
ReorderFilter::ReorderFilter(PacketProcessorListener* listener,
|
||||
const FlowIds& flow_ids)
|
||||
: PacketProcessor(listener, flow_ids, kRegular),
|
||||
random_(0x27452389),
|
||||
reorder_fraction_(0.0f) {
|
||||
}
|
||||
reorder_fraction_(0.0f) {}
|
||||
|
||||
void ReorderFilter::SetReorder(float reorder_percent) {
|
||||
BWE_TEST_LOGGING_ENABLE(false);
|
||||
@ -490,16 +477,14 @@ ChokeFilter::ChokeFilter(PacketProcessorListener* listener, int flow_id)
|
||||
: PacketProcessor(listener, flow_id, kRegular),
|
||||
capacity_kbps_(kDefaultKbps),
|
||||
last_send_time_us_(0),
|
||||
delay_cap_helper_(new DelayCapHelper()) {
|
||||
}
|
||||
delay_cap_helper_(new DelayCapHelper()) {}
|
||||
|
||||
ChokeFilter::ChokeFilter(PacketProcessorListener* listener,
|
||||
const FlowIds& flow_ids)
|
||||
: PacketProcessor(listener, flow_ids, kRegular),
|
||||
capacity_kbps_(kDefaultKbps),
|
||||
last_send_time_us_(0),
|
||||
delay_cap_helper_(new DelayCapHelper()) {
|
||||
}
|
||||
delay_cap_helper_(new DelayCapHelper()) {}
|
||||
|
||||
ChokeFilter::~ChokeFilter() {}
|
||||
|
||||
@ -515,7 +500,7 @@ uint32_t ChokeFilter::capacity_kbps() {
|
||||
|
||||
void ChokeFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
|
||||
assert(in_out);
|
||||
for (PacketsIt it = in_out->begin(); it != in_out->end(); ) {
|
||||
for (PacketsIt it = in_out->begin(); it != in_out->end();) {
|
||||
int64_t earliest_send_time_us =
|
||||
std::max(last_send_time_us_, (*it)->send_time_us());
|
||||
int64_t new_send_time_us =
|
||||
@ -556,8 +541,7 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
|
||||
name_(""),
|
||||
delay_cap_helper_(new DelayCapHelper()),
|
||||
packets_per_second_stats_(),
|
||||
kbps_stats_() {
|
||||
}
|
||||
kbps_stats_() {}
|
||||
|
||||
TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
|
||||
PacketProcessorListener* listener,
|
||||
@ -571,8 +555,7 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
|
||||
name_(""),
|
||||
delay_cap_helper_(new DelayCapHelper()),
|
||||
packets_per_second_stats_(),
|
||||
kbps_stats_() {
|
||||
}
|
||||
kbps_stats_() {}
|
||||
|
||||
TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
|
||||
PacketProcessorListener* listener,
|
||||
@ -587,11 +570,9 @@ TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
|
||||
name_(name),
|
||||
delay_cap_helper_(new DelayCapHelper()),
|
||||
packets_per_second_stats_(),
|
||||
kbps_stats_() {
|
||||
}
|
||||
kbps_stats_() {}
|
||||
|
||||
TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() {
|
||||
}
|
||||
TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() {}
|
||||
|
||||
bool TraceBasedDeliveryFilter::Init(const std::string& filename) {
|
||||
FILE* trace_file = fopen(filename.c_str(), "r");
|
||||
@ -769,8 +750,7 @@ AdaptiveVideoSource::AdaptiveVideoSource(int flow_id,
|
||||
uint32_t kbps,
|
||||
uint32_t ssrc,
|
||||
int64_t first_frame_offset_ms)
|
||||
: VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) {
|
||||
}
|
||||
: VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) {}
|
||||
|
||||
void AdaptiveVideoSource::SetBitrateBps(int bitrate_bps) {
|
||||
bits_per_second_ = bitrate_bps;
|
||||
@ -787,8 +767,7 @@ PeriodicKeyFrameSource::PeriodicKeyFrameSource(int flow_id,
|
||||
key_frame_interval_(key_frame_interval),
|
||||
frame_counter_(0),
|
||||
compensation_bytes_(0),
|
||||
compensation_per_frame_(0) {
|
||||
}
|
||||
compensation_per_frame_(0) {}
|
||||
|
||||
uint32_t PeriodicKeyFrameSource::NextFrameSize() {
|
||||
uint32_t payload_size = frame_size_bytes_;
|
||||
|
||||
@ -75,7 +75,7 @@ class RateCounter {
|
||||
};
|
||||
|
||||
typedef std::set<int> FlowIds;
|
||||
const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids);
|
||||
const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids);
|
||||
const FlowIds CreateFlowIdRange(int initial_value, int last_value);
|
||||
|
||||
template <typename T>
|
||||
@ -85,7 +85,8 @@ bool DereferencingComparator(const T* const& a, const T* const& b) {
|
||||
return *a < *b;
|
||||
}
|
||||
|
||||
template<typename T> class Stats {
|
||||
template <typename T>
|
||||
class Stats {
|
||||
public:
|
||||
Stats()
|
||||
: data_(),
|
||||
@ -95,12 +96,9 @@ template<typename T> class Stats {
|
||||
mean_(0),
|
||||
variance_(0),
|
||||
min_(0),
|
||||
max_(0) {
|
||||
}
|
||||
max_(0) {}
|
||||
|
||||
void Push(T data_point) {
|
||||
data_.push_back(data_point);
|
||||
}
|
||||
void Push(T data_point) { data_.push_back(data_point); }
|
||||
|
||||
T GetMean() {
|
||||
if (last_mean_count_ != data_.size()) {
|
||||
@ -125,9 +123,7 @@ template<typename T> class Stats {
|
||||
}
|
||||
return variance_;
|
||||
}
|
||||
T GetStdDev() {
|
||||
return sqrt(static_cast<double>(GetVariance()));
|
||||
}
|
||||
T GetStdDev() { return sqrt(static_cast<double>(GetVariance())); }
|
||||
T GetMin() {
|
||||
RefreshMinMax();
|
||||
return min_;
|
||||
@ -139,14 +135,14 @@ template<typename T> class Stats {
|
||||
|
||||
std::string AsString() {
|
||||
std::stringstream ss;
|
||||
ss << (GetMean() >= 0 ? GetMean() : -1) << ", " <<
|
||||
(GetStdDev() >= 0 ? GetStdDev() : -1);
|
||||
ss << (GetMean() >= 0 ? GetMean() : -1) << ", "
|
||||
<< (GetStdDev() >= 0 ? GetStdDev() : -1);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Log(const std::string& units) {
|
||||
BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]",
|
||||
GetMean(), units.c_str(), GetStdDev(), GetMin(), GetMax());
|
||||
BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]", GetMean(), units.c_str(),
|
||||
GetStdDev(), GetMin(), GetMax());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -153,8 +153,10 @@ class BweTestFramework_RateCounterFilterTest : public ::testing::Test {
|
||||
virtual ~BweTestFramework_RateCounterFilterTest() {}
|
||||
|
||||
protected:
|
||||
void TestRateCounter(int64_t run_for_ms, uint32_t payload_bits,
|
||||
uint32_t expected_pps, uint32_t expected_bps) {
|
||||
void TestRateCounter(int64_t run_for_ms,
|
||||
uint32_t payload_bits,
|
||||
uint32_t expected_pps,
|
||||
uint32_t expected_bps) {
|
||||
Packets packets;
|
||||
RTPHeader header;
|
||||
// "Send" a packet every 10 ms.
|
||||
@ -280,7 +282,8 @@ class BweTestFramework_DelayFilterTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
protected:
|
||||
void TestDelayFilter(int64_t run_for_ms, uint32_t in_packets,
|
||||
void TestDelayFilter(int64_t run_for_ms,
|
||||
uint32_t in_packets,
|
||||
uint32_t out_packets) {
|
||||
Packets packets;
|
||||
for (uint32_t i = 0; i < in_packets; ++i) {
|
||||
@ -301,7 +304,7 @@ class BweTestFramework_DelayFilterTest : public ::testing::Test {
|
||||
|
||||
void TestDelayFilter(int64_t delay_ms) {
|
||||
filter_.SetOneWayDelayMs(delay_ms);
|
||||
TestDelayFilter(1, 0, 0); // No input should yield no output
|
||||
TestDelayFilter(1, 0, 0); // No input should yield no output
|
||||
|
||||
// Single packet
|
||||
TestDelayFilter(0, 1, 1);
|
||||
@ -357,8 +360,8 @@ TEST_F(BweTestFramework_DelayFilterTest, Delay0) {
|
||||
TestDelayFilter(1, 10, 10); // Expect no delay (delay time is zero)
|
||||
TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
|
||||
filter_.SetOneWayDelayMs(0);
|
||||
TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero)
|
||||
TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
|
||||
TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero)
|
||||
TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
|
||||
}
|
||||
|
||||
TEST_F(BweTestFramework_DelayFilterTest, Delay1) {
|
||||
@ -580,11 +583,7 @@ TEST(BweTestFramework_ReorderFilterTest, Reorder100) {
|
||||
class BweTestFramework_ChokeFilterTest : public ::testing::Test {
|
||||
public:
|
||||
BweTestFramework_ChokeFilterTest()
|
||||
: now_ms_(0),
|
||||
sequence_number_(0),
|
||||
output_packets_(),
|
||||
send_times_us_() {
|
||||
}
|
||||
: now_ms_(0), sequence_number_(0), output_packets_(), send_times_us_() {}
|
||||
virtual ~BweTestFramework_ChokeFilterTest() {
|
||||
for (auto* packet : output_packets_)
|
||||
delete packet;
|
||||
|
||||
@ -41,12 +41,14 @@ Logging::Context::Context(uint32_t name, int64_t timestamp_ms, bool enabled) {
|
||||
Logging::GetInstance()->PushState(ToString(name), timestamp_ms, enabled);
|
||||
}
|
||||
|
||||
Logging::Context::Context(const std::string& name, int64_t timestamp_ms,
|
||||
Logging::Context::Context(const std::string& name,
|
||||
int64_t timestamp_ms,
|
||||
bool enabled) {
|
||||
Logging::GetInstance()->PushState(name, timestamp_ms, enabled);
|
||||
}
|
||||
|
||||
Logging::Context::Context(const char* name, int64_t timestamp_ms,
|
||||
Logging::Context::Context(const char* name,
|
||||
int64_t timestamp_ms,
|
||||
bool enabled) {
|
||||
Logging::GetInstance()->PushState(name, timestamp_ms, enabled);
|
||||
}
|
||||
@ -204,20 +206,16 @@ void Logging::PlotLabel(int figure,
|
||||
}
|
||||
}
|
||||
|
||||
Logging::Logging()
|
||||
: thread_map_() {
|
||||
}
|
||||
Logging::Logging() : thread_map_() {}
|
||||
|
||||
Logging::~Logging() = default;
|
||||
|
||||
Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {}
|
||||
|
||||
Logging::State::State(const std::string& tag, int64_t timestamp_ms,
|
||||
Logging::State::State(const std::string& tag,
|
||||
int64_t timestamp_ms,
|
||||
bool enabled)
|
||||
: tag(tag),
|
||||
timestamp_ms(timestamp_ms),
|
||||
enabled(enabled) {
|
||||
}
|
||||
: tag(tag), timestamp_ms(timestamp_ms), enabled(enabled) {}
|
||||
|
||||
void Logging::State::MergePrevious(const State& previous) {
|
||||
if (tag.empty()) {
|
||||
@ -229,7 +227,8 @@ void Logging::State::MergePrevious(const State& previous) {
|
||||
enabled = previous.enabled && enabled;
|
||||
}
|
||||
|
||||
void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms,
|
||||
void Logging::PushState(const std::string& append_to_tag,
|
||||
int64_t timestamp_ms,
|
||||
bool enabled) {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
State new_state(append_to_tag, timestamp_ms, enabled);
|
||||
|
||||
@ -132,57 +132,56 @@
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/criticalsection.h"
|
||||
|
||||
#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \
|
||||
do { \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \
|
||||
do { \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \
|
||||
} while (0)
|
||||
|
||||
#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \
|
||||
do { \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \
|
||||
do { \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \
|
||||
} while (0)
|
||||
|
||||
#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx ## line
|
||||
#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx##line
|
||||
#define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \
|
||||
webrtc::testing::bwe::Logging::Context \
|
||||
__BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line)(name, time, enabled)
|
||||
webrtc::testing::bwe::Logging::Context __BWE_TEST_LOGGING_CONTEXT_NAME( \
|
||||
ctx, line)(name, time, enabled)
|
||||
|
||||
#define BWE_TEST_LOGGING_CONTEXT(name) \
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true)
|
||||
#define BWE_TEST_LOGGING_ENABLE(enabled) \
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \
|
||||
static_cast<bool>(enabled))
|
||||
#define BWE_TEST_LOGGING_TIME(time) \
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \
|
||||
static_cast<int64_t>(time), true)
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true)
|
||||
#define BWE_TEST_LOGGING_ENABLE(enabled) \
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \
|
||||
static_cast<bool>(enabled))
|
||||
#define BWE_TEST_LOGGING_TIME(time) \
|
||||
__BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \
|
||||
static_cast<int64_t>(time), true)
|
||||
|
||||
#define BWE_TEST_LOGGING_LOG1(name, format, _1) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \
|
||||
_4); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \
|
||||
do {\
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \
|
||||
_4, _5); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG1(name, format, _1) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4); \
|
||||
} while (0)
|
||||
#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \
|
||||
do { \
|
||||
BWE_TEST_LOGGING_CONTEXT(name); \
|
||||
webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4, \
|
||||
_5); \
|
||||
} while (0)
|
||||
|
||||
#define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \
|
||||
do { \
|
||||
@ -266,6 +265,7 @@ class Logging {
|
||||
Context(const std::string& name, int64_t timestamp_ms, bool enabled);
|
||||
Context(const char* name, int64_t timestamp_ms, bool enabled);
|
||||
~Context();
|
||||
|
||||
private:
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Context);
|
||||
};
|
||||
@ -281,7 +281,8 @@ class Logging {
|
||||
// Note: Implicit |this| argument counts as the first argument.
|
||||
__attribute__((__format__(__printf__, 2, 3)))
|
||||
#endif
|
||||
void Log(const char format[], ...);
|
||||
void
|
||||
Log(const char format[], ...);
|
||||
void Plot(int figure, const std::string& name, double value);
|
||||
void Plot(int figure,
|
||||
const std::string& name,
|
||||
@ -340,7 +341,8 @@ class Logging {
|
||||
|
||||
Logging();
|
||||
~Logging();
|
||||
void PushState(const std::string& append_to_tag, int64_t timestamp_ms,
|
||||
void PushState(const std::string& append_to_tag,
|
||||
int64_t timestamp_ms,
|
||||
bool enabled);
|
||||
void PopState();
|
||||
|
||||
|
||||
@ -230,6 +230,7 @@ class BbrBweReceiver : public BweReceiver {
|
||||
void ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) override;
|
||||
FeedbackPacket* GetFeedback(int64_t now_ms) override;
|
||||
|
||||
private:
|
||||
SimulatedClock clock_;
|
||||
std::vector<uint16_t> packet_feedbacks_;
|
||||
|
||||
@ -46,11 +46,9 @@ NadaBweReceiver::NadaBweReceiver(int flow_id)
|
||||
last_congestion_signal_ms_(0),
|
||||
last_delays_index_(0),
|
||||
exp_smoothed_delay_ms_(-1),
|
||||
est_queuing_delay_signal_ms_(0) {
|
||||
}
|
||||
est_queuing_delay_signal_ms_(0) {}
|
||||
|
||||
NadaBweReceiver::~NadaBweReceiver() {
|
||||
}
|
||||
NadaBweReceiver::~NadaBweReceiver() {}
|
||||
|
||||
void NadaBweReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) {
|
||||
@ -162,8 +160,7 @@ NadaBweSender::NadaBweSender(int kbps, BitrateObserver* observer, Clock* clock)
|
||||
: BweSender(kbps), // Referred as "Reference Rate" = R_n.,
|
||||
clock_(clock),
|
||||
observer_(observer),
|
||||
original_operating_mode_(true) {
|
||||
}
|
||||
original_operating_mode_(true) {}
|
||||
|
||||
NadaBweSender::NadaBweSender(BitrateObserver* observer, Clock* clock)
|
||||
: BweSender(kMinNadaBitrateKbps), // Referred as "Reference Rate" = R_n.
|
||||
@ -171,8 +168,7 @@ NadaBweSender::NadaBweSender(BitrateObserver* observer, Clock* clock)
|
||||
observer_(observer),
|
||||
original_operating_mode_(true) {}
|
||||
|
||||
NadaBweSender::~NadaBweSender() {
|
||||
}
|
||||
NadaBweSender::~NadaBweSender() {}
|
||||
|
||||
int NadaBweSender::GetFeedbackIntervalMs() const {
|
||||
return 100;
|
||||
@ -243,8 +239,7 @@ int64_t NadaBweSender::TimeUntilNextProcess() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
void NadaBweSender::Process() {
|
||||
}
|
||||
void NadaBweSender::Process() {}
|
||||
|
||||
void NadaBweSender::AcceleratedRampUp(const NadaFeedback& fb) {
|
||||
const int kMaxRampUpQueuingDelayMs = 50; // Referred as T_th.
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
// Implementation of Network-Assisted Dynamic Adaptation's (NADA's) proposal
|
||||
// Version according to Draft Document (mentioned in references)
|
||||
|
||||
@ -426,8 +426,8 @@ TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) {
|
||||
// Raw delays are = [50 250 450 650 850 1050 1250 1450] ms.
|
||||
// Baseline delay will be 50 ms.
|
||||
// Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms.
|
||||
const int64_t kMedianFilteredDelaysMs[] = {
|
||||
0, 100, 200, 300, 400, 600, 800, 1000};
|
||||
const int64_t kMedianFilteredDelaysMs[] = {0, 100, 200, 300,
|
||||
400, 600, 800, 1000};
|
||||
const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
|
||||
const float kAlpha = 0.1f; // Used for exponential smoothing.
|
||||
|
||||
|
||||
@ -37,8 +37,7 @@ RembBweSender::RembBweSender(int kbps, BitrateObserver* observer, Clock* clock)
|
||||
1000 * kMaxBitrateKbps);
|
||||
}
|
||||
|
||||
RembBweSender::~RembBweSender() {
|
||||
}
|
||||
RembBweSender::~RembBweSender() {}
|
||||
|
||||
void RembBweSender::GiveFeedback(const FeedbackPacket& feedback) {
|
||||
const RembFeedback& remb_feedback =
|
||||
@ -80,8 +79,7 @@ RembReceiver::RembReceiver(int flow_id, bool plot)
|
||||
estimator_->SetMinBitrate(kRemoteBitrateEstimatorMinBitrateBps);
|
||||
}
|
||||
|
||||
RembReceiver::~RembReceiver() {
|
||||
}
|
||||
RembReceiver::~RembReceiver() {}
|
||||
|
||||
void RembReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) {
|
||||
|
||||
@ -143,11 +143,9 @@ void SendSideBweSender::Process() {
|
||||
}
|
||||
|
||||
SendSideBweReceiver::SendSideBweReceiver(int flow_id)
|
||||
: BweReceiver(flow_id), last_feedback_ms_(0) {
|
||||
}
|
||||
: BweReceiver(flow_id), last_feedback_ms_(0) {}
|
||||
|
||||
SendSideBweReceiver::~SendSideBweReceiver() {
|
||||
}
|
||||
SendSideBweReceiver::~SendSideBweReceiver() {}
|
||||
|
||||
void SendSideBweReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) {
|
||||
|
||||
@ -22,13 +22,9 @@ namespace testing {
|
||||
namespace bwe {
|
||||
|
||||
TcpBweReceiver::TcpBweReceiver(int flow_id)
|
||||
: BweReceiver(flow_id),
|
||||
last_feedback_ms_(0),
|
||||
latest_owd_ms_(0) {
|
||||
}
|
||||
: BweReceiver(flow_id), last_feedback_ms_(0), latest_owd_ms_(0) {}
|
||||
|
||||
TcpBweReceiver::~TcpBweReceiver() {
|
||||
}
|
||||
TcpBweReceiver::~TcpBweReceiver() {}
|
||||
|
||||
void TcpBweReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
const MediaPacket& media_packet) {
|
||||
|
||||
@ -27,13 +27,12 @@ template <typename T>
|
||||
double NormLp(T sum, size_t size, double p) {
|
||||
return pow(sum / size, 1.0 / p);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const double kP = 1.0; // Used for Norm Lp.
|
||||
|
||||
LinkShare::LinkShare(ChokeFilter* choke_filter)
|
||||
: choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) {
|
||||
}
|
||||
: choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) {}
|
||||
|
||||
void LinkShare::PauseFlow(int flow_id) {
|
||||
running_flows_.erase(flow_id);
|
||||
@ -288,10 +287,10 @@ void MetricRecorder::PlotThroughputHistogram(
|
||||
average_bitrate_kbps + pos_error + extra_error, "estimate_error",
|
||||
optimal_bitrate_per_flow_kbps, optimum_title, flow_id_);
|
||||
|
||||
BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Channel utilization : ",
|
||||
"%lf %%",
|
||||
100.0 * static_cast<double>(average_bitrate_kbps) /
|
||||
optimal_bitrate_per_flow_kbps);
|
||||
BWE_TEST_LOGGING_LOG1(
|
||||
"RESULTS >>> " + bwe_name + " Channel utilization : ", "%lf %%",
|
||||
100.0 * static_cast<double>(average_bitrate_kbps) /
|
||||
optimal_bitrate_per_flow_kbps);
|
||||
|
||||
RTC_UNUSED(pos_error);
|
||||
RTC_UNUSED(neg_error);
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace testing {
|
||||
|
||||
@ -68,11 +68,9 @@ PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
|
||||
bwe_type,
|
||||
plot_delay,
|
||||
plot_bwe,
|
||||
nullptr) {
|
||||
}
|
||||
nullptr) {}
|
||||
|
||||
PacketReceiver::~PacketReceiver() {
|
||||
}
|
||||
PacketReceiver::~PacketReceiver() {}
|
||||
|
||||
void PacketReceiver::RunFor(int64_t time_ms, Packets* in_out) {
|
||||
Packets feedback;
|
||||
|
||||
@ -86,8 +86,7 @@ VideoSender::VideoSender(PacketProcessorListener* listener,
|
||||
modules_.push_back(bwe_.get());
|
||||
}
|
||||
|
||||
VideoSender::~VideoSender() {
|
||||
}
|
||||
VideoSender::~VideoSender() {}
|
||||
|
||||
void VideoSender::Pause() {
|
||||
previous_sending_bitrate_ = TargetBitrateKbps();
|
||||
@ -338,8 +337,7 @@ const int kPacketSizeBytes = 1200;
|
||||
TcpSender::TcpSender(PacketProcessorListener* listener,
|
||||
int flow_id,
|
||||
int64_t offset_ms)
|
||||
: TcpSender(listener, flow_id, offset_ms, kNoLimit) {
|
||||
}
|
||||
: TcpSender(listener, flow_id, offset_ms, kNoLimit) {}
|
||||
|
||||
TcpSender::TcpSender(PacketProcessorListener* listener,
|
||||
int flow_id,
|
||||
@ -358,8 +356,7 @@ TcpSender::TcpSender(PacketProcessorListener* listener,
|
||||
send_limit_bytes_(send_limit_bytes),
|
||||
last_generated_packets_ms_(0),
|
||||
num_recent_sent_packets_(0),
|
||||
bitrate_kbps_(0) {
|
||||
}
|
||||
bitrate_kbps_(0) {}
|
||||
|
||||
void TcpSender::RunFor(int64_t time_ms, Packets* in_out) {
|
||||
if (clock_.TimeInMilliseconds() + time_ms < offset_ms_) {
|
||||
@ -477,8 +474,8 @@ Packets TcpSender::GeneratePackets(size_t num_packets) {
|
||||
generated.push_back(
|
||||
new MediaPacket(*flow_ids().begin(), 1000 * clock_.TimeInMilliseconds(),
|
||||
kPacketSizeBytes, next_sequence_number_++));
|
||||
generated.back()->set_sender_timestamp_us(
|
||||
1000 * clock_.TimeInMilliseconds());
|
||||
generated.back()->set_sender_timestamp_us(1000 *
|
||||
clock_.TimeInMilliseconds());
|
||||
|
||||
total_sent_bytes_ += kPacketSizeBytes;
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_
|
||||
#define MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_
|
||||
|
||||
#include <list>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
@ -128,13 +128,13 @@ bool ParseArgsAndSetupEstimator(int argc,
|
||||
new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock);
|
||||
*estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator";
|
||||
break;
|
||||
}
|
||||
}
|
||||
case webrtc::kRtpExtensionTransmissionTimeOffset: {
|
||||
*estimator =
|
||||
new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock);
|
||||
*estimator_used = "RemoteBitrateEstimator";
|
||||
break;
|
||||
}
|
||||
*estimator_used = "RemoteBitrateEstimator";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
@ -21,16 +21,15 @@ class RtpHeaderParser;
|
||||
namespace test {
|
||||
class RtpFileReader;
|
||||
}
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
bool ParseArgsAndSetupEstimator(
|
||||
int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
webrtc::test::RtpFileReader** rtp_reader,
|
||||
webrtc::RtpHeaderParser** parser,
|
||||
webrtc::RemoteBitrateEstimator** estimator,
|
||||
std::string* estimator_used);
|
||||
bool ParseArgsAndSetupEstimator(int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
webrtc::test::RtpFileReader** rtp_reader,
|
||||
webrtc::RtpHeaderParser** parser,
|
||||
webrtc::RemoteBitrateEstimator** estimator,
|
||||
std::string* estimator_used);
|
||||
|
||||
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
|
||||
|
||||
@ -104,10 +104,8 @@ int main(int argc, char* argv[]) {
|
||||
printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter,
|
||||
clock.TimeInMilliseconds());
|
||||
printf("Estimator used: %s\n", estimator_used.c_str());
|
||||
printf("Packets with absolute send time: %d\n",
|
||||
abs_send_time_count);
|
||||
printf("Packets with timestamp offset: %d\n",
|
||||
ts_offset_count);
|
||||
printf("Packets with absolute send time: %d\n", abs_send_time_count);
|
||||
printf("Packets with timestamp offset: %d\n", ts_offset_count);
|
||||
printf("Packets with no extension: %d\n",
|
||||
packet_counter - ts_offset_count - abs_send_time_count);
|
||||
return 0;
|
||||
|
||||
@ -29,7 +29,8 @@ int main(int argc, char* argv[]) {
|
||||
bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
|
||||
std::unique_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
|
||||
fprintf(stdout, "seqnum timestamp ts_offset abs_sendtime recvtime "
|
||||
fprintf(stdout,
|
||||
"seqnum timestamp ts_offset abs_sendtime recvtime "
|
||||
"markerbit ssrc size original_size\n");
|
||||
int packet_counter = 0;
|
||||
int non_zero_abs_send_time = 0;
|
||||
@ -47,24 +48,19 @@ int main(int argc, char* argv[]) {
|
||||
ss << static_cast<int64_t>(packet.time_ms) * 1000000;
|
||||
fprintf(stdout, "%s\n", ss.str().c_str());
|
||||
} else {
|
||||
fprintf(stdout,
|
||||
"%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n",
|
||||
header.sequenceNumber,
|
||||
header.timestamp,
|
||||
fprintf(stdout, "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n",
|
||||
header.sequenceNumber, header.timestamp,
|
||||
header.extension.transmissionTimeOffset,
|
||||
header.extension.absoluteSendTime,
|
||||
packet.time_ms,
|
||||
header.markerBit,
|
||||
header.ssrc,
|
||||
packet.length,
|
||||
header.extension.absoluteSendTime, packet.time_ms,
|
||||
header.markerBit, header.ssrc, packet.length,
|
||||
packet.original_length);
|
||||
}
|
||||
++packet_counter;
|
||||
}
|
||||
fprintf(stderr, "Parsed %d packets\n", packet_counter);
|
||||
fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
|
||||
non_zero_abs_send_time);
|
||||
non_zero_abs_send_time);
|
||||
fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
|
||||
non_zero_ts_offsets);
|
||||
non_zero_ts_offsets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user