Replace DataSize and DataRate factories with newer versions

This is search and replace change:
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataSize::Bytes<\(.*\)>()/DataSize::Bytes(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataSize::bytes/DataSize::Bytes/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::BitsPerSec<\(.*\)>()/DataRate::BitsPerSec(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::BytesPerSec<\(.*\)>()/DataRate::BytesPerSec(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::KilobitsPerSec<\(.*\)>()/DataRate::KilobitsPerSec(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::bps/DataRate::BitsPerSec/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::kbps/DataRate::KilobitsPerSec/g"
git cl format

Bug: webrtc:9709
Change-Id: I65aaca69474ba038c1fe2dd8dc30d3f8e7b94c29
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168647
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30545}
This commit is contained in:
Danil Chapovalov 2020-02-17 18:46:07 +01:00 committed by Commit Bot
parent 701bd172d8
commit cad3e0e2fa
102 changed files with 947 additions and 798 deletions

View File

@ -22,7 +22,7 @@ class FeedbackGenerator {
BuiltInNetworkBehaviorConfig send_link; BuiltInNetworkBehaviorConfig send_link;
BuiltInNetworkBehaviorConfig return_link; BuiltInNetworkBehaviorConfig return_link;
TimeDelta feedback_interval = TimeDelta::Millis(50); TimeDelta feedback_interval = TimeDelta::Millis(50);
DataSize feedback_packet_size = DataSize::bytes(20); DataSize feedback_packet_size = DataSize::Bytes(20);
}; };
virtual ~FeedbackGenerator() = default; virtual ~FeedbackGenerator() = default;
virtual Timestamp Now() = 0; virtual Timestamp Now() = 0;

View File

@ -15,8 +15,8 @@ namespace webrtc {
VideoBitrateAllocationParameters::VideoBitrateAllocationParameters( VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
uint32_t total_bitrate_bps, uint32_t total_bitrate_bps,
uint32_t framerate) uint32_t framerate)
: total_bitrate(DataRate::bps(total_bitrate_bps)), : total_bitrate(DataRate::BitsPerSec(total_bitrate_bps)),
stable_bitrate(DataRate::bps(total_bitrate_bps)), stable_bitrate(DataRate::BitsPerSec(total_bitrate_bps)),
framerate(static_cast<double>(framerate)) {} framerate(static_cast<double>(framerate)) {}
VideoBitrateAllocationParameters::VideoBitrateAllocationParameters( VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
@ -39,8 +39,8 @@ VideoBitrateAllocationParameters::~VideoBitrateAllocationParameters() = default;
VideoBitrateAllocation VideoBitrateAllocator::GetAllocation( VideoBitrateAllocation VideoBitrateAllocator::GetAllocation(
uint32_t total_bitrate_bps, uint32_t total_bitrate_bps,
uint32_t framerate) { uint32_t framerate) {
return Allocate({DataRate::bps(total_bitrate_bps), return Allocate({DataRate::BitsPerSec(total_bitrate_bps),
DataRate::bps(total_bitrate_bps), DataRate::BitsPerSec(total_bitrate_bps),
static_cast<double>(framerate)}); static_cast<double>(framerate)});
} }

View File

@ -218,7 +218,7 @@ VideoEncoder::RateControlParameters::RateControlParameters(
double framerate_fps) double framerate_fps)
: bitrate(bitrate), : bitrate(bitrate),
framerate_fps(framerate_fps), framerate_fps(framerate_fps),
bandwidth_allocation(DataRate::bps(bitrate.get_sum_bps())) {} bandwidth_allocation(DataRate::BitsPerSec(bitrate.get_sum_bps())) {}
VideoEncoder::RateControlParameters::RateControlParameters( VideoEncoder::RateControlParameters::RateControlParameters(
const VideoBitrateAllocation& bitrate, const VideoBitrateAllocation& bitrate,

View File

@ -804,12 +804,12 @@ void AudioSendStream::ConfigureBitrateObserver() {
constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12;
const TimeDelta kMinPacketDuration = TimeDelta::Millis(20); const TimeDelta kMinPacketDuration = TimeDelta::Millis(20);
DataRate max_overhead = DataRate max_overhead =
DataSize::bytes(kOverheadPerPacket) / kMinPacketDuration; DataSize::Bytes(kOverheadPerPacket) / kMinPacketDuration;
priority_bitrate += max_overhead; priority_bitrate += max_overhead;
} else { } else {
RTC_DCHECK(frame_length_range_); RTC_DCHECK(frame_length_range_);
const DataSize kOverheadPerPacket = const DataSize kOverheadPerPacket =
DataSize::bytes(total_packet_overhead_bytes_); DataSize::Bytes(total_packet_overhead_bytes_);
DataRate max_overhead = kOverheadPerPacket / frame_length_range_->first; DataRate max_overhead = kOverheadPerPacket / frame_length_range_->first;
priority_bitrate += max_overhead; priority_bitrate += max_overhead;
} }
@ -841,8 +841,8 @@ void AudioSendStream::RemoveBitrateObserver() {
AudioSendStream::TargetAudioBitrateConstraints AudioSendStream::TargetAudioBitrateConstraints
AudioSendStream::GetMinMaxBitrateConstraints() const { AudioSendStream::GetMinMaxBitrateConstraints() const {
TargetAudioBitrateConstraints constraints{ TargetAudioBitrateConstraints constraints{
DataRate::bps(config_.min_bitrate_bps), DataRate::BitsPerSec(config_.min_bitrate_bps),
DataRate::bps(config_.max_bitrate_bps)}; DataRate::BitsPerSec(config_.max_bitrate_bps)};
// If bitrates were explicitly overriden via field trial, use those values. // If bitrates were explicitly overriden via field trial, use those values.
if (allocation_settings_.min_bitrate) if (allocation_settings_.min_bitrate)
@ -856,7 +856,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const {
if (send_side_bwe_with_overhead_) { if (send_side_bwe_with_overhead_) {
if (use_legacy_overhead_calculation_) { if (use_legacy_overhead_calculation_) {
// OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12)
const DataSize kOverheadPerPacket = DataSize::bytes(20 + 8 + 10 + 12); const DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12);
const TimeDelta kMaxFrameLength = const TimeDelta kMaxFrameLength =
TimeDelta::Millis(60); // Based on Opus spec TimeDelta::Millis(60); // Based on Opus spec
const DataRate kMinOverhead = kOverheadPerPacket / kMaxFrameLength; const DataRate kMinOverhead = kOverheadPerPacket / kMaxFrameLength;
@ -865,7 +865,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const {
} else { } else {
RTC_DCHECK(frame_length_range_); RTC_DCHECK(frame_length_range_);
const DataSize kOverheadPerPacket = const DataSize kOverheadPerPacket =
DataSize::bytes(total_packet_overhead_bytes_); DataSize::Bytes(total_packet_overhead_bytes_);
constraints.min += kOverheadPerPacket / frame_length_range_->second; constraints.min += kOverheadPerPacket / frame_length_range_->second;
constraints.max += kOverheadPerPacket / frame_length_range_->first; constraints.max += kOverheadPerPacket / frame_length_range_->first;
} }

View File

@ -82,7 +82,7 @@ const AudioCodecSpec kCodecSpecs[] = {
// TODO(dklee): This mirrors calculation in audio_send_stream.cc, which // TODO(dklee): This mirrors calculation in audio_send_stream.cc, which
// should be made more precise in the future. This can be changed when that // should be made more precise in the future. This can be changed when that
// logic is more accurate. // logic is more accurate.
const DataSize kOverheadPerPacket = DataSize::bytes(20 + 8 + 10 + 12); const DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12);
const TimeDelta kMinFrameLength = TimeDelta::Millis(20); const TimeDelta kMinFrameLength = TimeDelta::Millis(20);
const TimeDelta kMaxFrameLength = TimeDelta::Millis(120); const TimeDelta kMaxFrameLength = TimeDelta::Millis(120);
const DataRate kMinOverheadRate = kOverheadPerPacket / kMaxFrameLength; const DataRate kMinOverheadRate = kOverheadPerPacket / kMaxFrameLength;
@ -549,11 +549,12 @@ TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) {
ConfigHelper helper(false, true); ConfigHelper helper(false, true);
auto send_stream = helper.CreateAudioSendStream(); auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation( OnBitrateAllocation(Field(
Field(&BitrateAllocationUpdate::target_bitrate, &BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::bps(helper.config().max_bitrate_bps))))); Eq(DataRate::BitsPerSec(helper.config().max_bitrate_bps)))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(helper.config().max_bitrate_bps + 5000); update.target_bitrate =
DataRate::BitsPerSec(helper.config().max_bitrate_bps + 5000);
update.packet_loss_ratio = 0; update.packet_loss_ratio = 0;
update.round_trip_time = TimeDelta::Millis(50); update.round_trip_time = TimeDelta::Millis(50);
update.bwe_period = TimeDelta::Millis(6000); update.bwe_period = TimeDelta::Millis(6000);
@ -565,12 +566,14 @@ TEST(AudioSendStreamTest, SSBweTargetInRangeRespected) {
ScopedFieldTrials field_trials("WebRTC-Audio-SendSideBwe/Enabled/"); ScopedFieldTrials field_trials("WebRTC-Audio-SendSideBwe/Enabled/");
ConfigHelper helper(true, true); ConfigHelper helper(true, true);
auto send_stream = helper.CreateAudioSendStream(); auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), EXPECT_CALL(
*helper.channel_send(),
OnBitrateAllocation(Field( OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, &BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::bps(helper.config().max_bitrate_bps - 5000))))); Eq(DataRate::BitsPerSec(helper.config().max_bitrate_bps - 5000)))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(helper.config().max_bitrate_bps - 5000); update.target_bitrate =
DataRate::BitsPerSec(helper.config().max_bitrate_bps - 5000);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); }, helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE); RTC_FROM_HERE);
} }
@ -584,9 +587,9 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) {
EXPECT_CALL( EXPECT_CALL(
*helper.channel_send(), *helper.channel_send(),
OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate, OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::kbps(6))))); Eq(DataRate::KilobitsPerSec(6)))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(1); update.target_bitrate = DataRate::KilobitsPerSec(1);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); }, helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE); RTC_FROM_HERE);
} }
@ -600,9 +603,9 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) {
EXPECT_CALL( EXPECT_CALL(
*helper.channel_send(), *helper.channel_send(),
OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate, OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::kbps(64))))); Eq(DataRate::KilobitsPerSec(64)))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(128); update.target_bitrate = DataRate::KilobitsPerSec(128);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); }, helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE); RTC_FROM_HERE);
} }
@ -617,7 +620,7 @@ TEST(AudioSendStreamTest, SSBweWithOverhead) {
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1); EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>()); send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>());
const DataRate bitrate = const DataRate bitrate =
DataRate::bps(helper.config().max_bitrate_bps) + kMaxOverheadRate; DataRate::BitsPerSec(helper.config().max_bitrate_bps) + kMaxOverheadRate;
EXPECT_CALL(*helper.channel_send(), EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(Field( OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate)))); &BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
@ -637,12 +640,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) {
auto send_stream = helper.CreateAudioSendStream(); auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1); EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>()); send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>());
const DataRate bitrate = DataRate::kbps(6) + kMinOverheadRate; const DataRate bitrate = DataRate::KilobitsPerSec(6) + kMinOverheadRate;
EXPECT_CALL(*helper.channel_send(), EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(Field( OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate)))); &BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(1); update.target_bitrate = DataRate::KilobitsPerSec(1);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); }, helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE); RTC_FROM_HERE);
} }
@ -657,12 +660,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMaxRespected) {
auto send_stream = helper.CreateAudioSendStream(); auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1); EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>()); send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>());
const DataRate bitrate = DataRate::kbps(64) + kMaxOverheadRate; const DataRate bitrate = DataRate::KilobitsPerSec(64) + kMaxOverheadRate;
EXPECT_CALL(*helper.channel_send(), EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(Field( OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate)))); &BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(128); update.target_bitrate = DataRate::KilobitsPerSec(128);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); }, helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE); RTC_FROM_HERE);
} }
@ -675,7 +678,8 @@ TEST(AudioSendStreamTest, ProbingIntervalOnBitrateUpdated) {
OnBitrateAllocation(Field(&BitrateAllocationUpdate::bwe_period, OnBitrateAllocation(Field(&BitrateAllocationUpdate::bwe_period,
Eq(TimeDelta::Millis(5000))))); Eq(TimeDelta::Millis(5000)))));
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(helper.config().max_bitrate_bps + 5000); update.target_bitrate =
DataRate::BitsPerSec(helper.config().max_bitrate_bps + 5000);
update.packet_loss_ratio = 0; update.packet_loss_ratio = 0;
update.round_trip_time = TimeDelta::Millis(50); update.round_trip_time = TimeDelta::Millis(50);
update.bwe_period = TimeDelta::Millis(5000); update.bwe_period = TimeDelta::Millis(5000);

View File

@ -404,8 +404,9 @@ void BitrateAllocator::OnNetworkEstimateChanged(TargetTransferRate msg) {
uint32_t allocated_stable_target_rate = uint32_t allocated_stable_target_rate =
stable_bitrate_allocation[config.observer]; stable_bitrate_allocation[config.observer];
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate); update.target_bitrate = DataRate::BitsPerSec(allocated_bitrate);
update.stable_target_bitrate = DataRate::bps(allocated_stable_target_rate); update.stable_target_bitrate =
DataRate::BitsPerSec(allocated_stable_target_rate);
update.packet_loss_ratio = last_fraction_loss_ / 256.0; update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::Millis(last_rtt_); update.round_trip_time = TimeDelta::Millis(last_rtt_);
update.bwe_period = TimeDelta::Millis(last_bwe_period_ms_); update.bwe_period = TimeDelta::Millis(last_bwe_period_ms_);
@ -469,8 +470,9 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
uint32_t allocated_stable_bitrate = uint32_t allocated_stable_bitrate =
stable_bitrate_allocation[config.observer]; stable_bitrate_allocation[config.observer];
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate); update.target_bitrate = DataRate::BitsPerSec(allocated_bitrate);
update.stable_target_bitrate = DataRate::bps(allocated_stable_bitrate); update.stable_target_bitrate =
DataRate::BitsPerSec(allocated_stable_bitrate);
update.packet_loss_ratio = last_fraction_loss_ / 256.0; update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::Millis(last_rtt_); update.round_trip_time = TimeDelta::Millis(last_rtt_);
update.bwe_period = TimeDelta::Millis(last_bwe_period_ms_); update.bwe_period = TimeDelta::Millis(last_bwe_period_ms_);
@ -501,13 +503,14 @@ void BitrateAllocator::UpdateAllocationLimits() {
uint32_t stream_padding = config.config.pad_up_bitrate_bps; uint32_t stream_padding = config.config.pad_up_bitrate_bps;
if (config.config.enforce_min_bitrate) { if (config.config.enforce_min_bitrate) {
limits.min_allocatable_rate += limits.min_allocatable_rate +=
DataRate::bps(config.config.min_bitrate_bps); DataRate::BitsPerSec(config.config.min_bitrate_bps);
} else if (config.allocated_bitrate_bps == 0) { } else if (config.allocated_bitrate_bps == 0) {
stream_padding = stream_padding =
std::max(config.MinBitrateWithHysteresis(), stream_padding); std::max(config.MinBitrateWithHysteresis(), stream_padding);
} }
limits.max_padding_rate += DataRate::bps(stream_padding); limits.max_padding_rate += DataRate::BitsPerSec(stream_padding);
limits.max_allocatable_rate += DataRate::bps(config.config.max_bitrate_bps); limits.max_allocatable_rate +=
DataRate::BitsPerSec(config.config.max_bitrate_bps);
} }
if (limits.min_allocatable_rate == current_limits_.min_allocatable_rate && if (limits.min_allocatable_rate == current_limits_.min_allocatable_rate &&

View File

@ -30,19 +30,19 @@ auto AllocationLimitsEq(uint32_t min_allocatable_rate_bps,
uint32_t max_padding_rate_bps, uint32_t max_padding_rate_bps,
uint32_t max_allocatable_rate_bps) { uint32_t max_allocatable_rate_bps) {
return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate, return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate,
DataRate::bps(min_allocatable_rate_bps)), DataRate::BitsPerSec(min_allocatable_rate_bps)),
Field(&BitrateAllocationLimits::max_allocatable_rate, Field(&BitrateAllocationLimits::max_allocatable_rate,
DataRate::bps(max_allocatable_rate_bps)), DataRate::BitsPerSec(max_allocatable_rate_bps)),
Field(&BitrateAllocationLimits::max_padding_rate, Field(&BitrateAllocationLimits::max_padding_rate,
DataRate::bps(max_padding_rate_bps))); DataRate::BitsPerSec(max_padding_rate_bps)));
} }
auto AllocationLimitsEq(uint32_t min_allocatable_rate_bps, auto AllocationLimitsEq(uint32_t min_allocatable_rate_bps,
uint32_t max_padding_rate_bps) { uint32_t max_padding_rate_bps) {
return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate, return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate,
DataRate::bps(min_allocatable_rate_bps)), DataRate::BitsPerSec(min_allocatable_rate_bps)),
Field(&BitrateAllocationLimits::max_padding_rate, Field(&BitrateAllocationLimits::max_padding_rate,
DataRate::bps(max_padding_rate_bps))); DataRate::BitsPerSec(max_padding_rate_bps)));
} }
class MockLimitObserver : public BitrateAllocator::LimitObserver { class MockLimitObserver : public BitrateAllocator::LimitObserver {
@ -89,7 +89,7 @@ TargetTransferRate CreateTargetRateMessage(uint32_t target_bitrate_bps,
// The timestamp is just for log output, keeping it fixed just means fewer log // The timestamp is just for log output, keeping it fixed just means fewer log
// messages in the test. // messages in the test.
msg.at_time = Timestamp::Seconds(10000); msg.at_time = Timestamp::Seconds(10000);
msg.target_rate = DataRate::bps(target_bitrate_bps); msg.target_rate = DataRate::BitsPerSec(target_bitrate_bps);
msg.stable_target_rate = msg.target_rate; msg.stable_target_rate = msg.target_rate;
msg.network_estimate.bandwidth = msg.target_rate; msg.network_estimate.bandwidth = msg.target_rate;
msg.network_estimate.loss_rate_ratio = fraction_loss / 255.0; msg.network_estimate.loss_rate_ratio = fraction_loss / 255.0;

View File

@ -1351,7 +1351,7 @@ void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
packet.GetHeader(&header); packet.GetHeader(&header);
ReceivedPacket packet_msg; ReceivedPacket packet_msg;
packet_msg.size = DataSize::bytes(packet.payload_size()); packet_msg.size = DataSize::Bytes(packet.payload_size());
packet_msg.receive_time = Timestamp::Millis(packet.arrival_time_ms()); packet_msg.receive_time = Timestamp::Millis(packet.arrival_time_ms());
if (header.extension.hasAbsoluteSendTime) { if (header.extension.hasAbsoluteSendTime) {
packet_msg.send_time = header.extension.GetAbsoluteSendTimestamp(); packet_msg.send_time = header.extension.GetAbsoluteSendTimestamp();

View File

@ -40,12 +40,14 @@ TargetRateConstraints ConvertConstraints(int min_bitrate_bps,
Clock* clock) { Clock* clock) {
TargetRateConstraints msg; TargetRateConstraints msg;
msg.at_time = Timestamp::Millis(clock->TimeInMilliseconds()); msg.at_time = Timestamp::Millis(clock->TimeInMilliseconds());
msg.min_data_rate = msg.min_data_rate = min_bitrate_bps >= 0
min_bitrate_bps >= 0 ? DataRate::bps(min_bitrate_bps) : DataRate::Zero(); ? DataRate::BitsPerSec(min_bitrate_bps)
msg.max_data_rate = max_bitrate_bps > 0 ? DataRate::bps(max_bitrate_bps) : DataRate::Zero();
msg.max_data_rate = max_bitrate_bps > 0
? DataRate::BitsPerSec(max_bitrate_bps)
: DataRate::Infinity(); : DataRate::Infinity();
if (start_bitrate_bps > 0) if (start_bitrate_bps > 0)
msg.starting_rate = DataRate::bps(start_bitrate_bps); msg.starting_rate = DataRate::BitsPerSec(start_bitrate_bps);
return msg; return msg;
} }
@ -114,8 +116,8 @@ RtpTransportControllerSend::RtpTransportControllerSend(
initial_config_.key_value_config = trials; initial_config_.key_value_config = trials;
RTC_DCHECK(bitrate_config.start_bitrate_bps > 0); RTC_DCHECK(bitrate_config.start_bitrate_bps > 0);
pacer()->SetPacingRates(DataRate::bps(bitrate_config.start_bitrate_bps), pacer()->SetPacingRates(
DataRate::Zero()); DataRate::BitsPerSec(bitrate_config.start_bitrate_bps), DataRate::Zero());
if (!use_task_queue_pacer_) { if (!use_task_queue_pacer_) {
process_thread_->Start(); process_thread_->Start();
@ -426,7 +428,7 @@ void RtpTransportControllerSend::OnTransportOverheadChanged(
} }
pacer()->SetTransportOverhead( pacer()->SetTransportOverhead(
DataSize::bytes(transport_overhead_bytes_per_packet)); DataSize::Bytes(transport_overhead_bytes_per_packet));
// TODO(holmer): Call AudioRtpSenders when they have been moved to // TODO(holmer): Call AudioRtpSenders when they have been moved to
// RtpTransportControllerSend. // RtpTransportControllerSend.
@ -448,7 +450,7 @@ void RtpTransportControllerSend::IncludeOverheadInPacedSender() {
void RtpTransportControllerSend::OnReceivedEstimatedBitrate(uint32_t bitrate) { void RtpTransportControllerSend::OnReceivedEstimatedBitrate(uint32_t bitrate) {
RemoteBitrateReport msg; RemoteBitrateReport msg;
msg.receive_time = Timestamp::Millis(clock_->TimeInMilliseconds()); msg.receive_time = Timestamp::Millis(clock_->TimeInMilliseconds());
msg.bandwidth = DataRate::bps(bitrate); msg.bandwidth = DataRate::BitsPerSec(bitrate);
task_queue_.PostTask([this, msg]() { task_queue_.PostTask([this, msg]() {
RTC_DCHECK_RUN_ON(&task_queue_); RTC_DCHECK_RUN_ON(&task_queue_);
if (controller_) if (controller_)

View File

@ -695,9 +695,9 @@ void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
int framerate) { int framerate) {
// Substract overhead from bitrate. // Substract overhead from bitrate.
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
DataSize packet_overhead = DataSize::bytes( DataSize packet_overhead = DataSize::Bytes(
overhead_bytes_per_packet_ + transport_overhead_bytes_per_packet_); overhead_bytes_per_packet_ + transport_overhead_bytes_per_packet_);
DataSize max_total_packet_size = DataSize::bytes( DataSize max_total_packet_size = DataSize::Bytes(
rtp_config_.max_packet_size + transport_overhead_bytes_per_packet_); rtp_config_.max_packet_size + transport_overhead_bytes_per_packet_);
uint32_t payload_bitrate_bps = update.target_bitrate.bps(); uint32_t payload_bitrate_bps = update.target_bitrate.bps();
if (send_side_bwe_with_overhead_ && has_packet_feedback_) { if (send_side_bwe_with_overhead_ && has_packet_feedback_) {
@ -742,8 +742,8 @@ void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
// make sense to use different packet rates for different overhead // make sense to use different packet rates for different overhead
// calculations. // calculations.
DataRate encoder_overhead_rate = CalculateOverheadRate( DataRate encoder_overhead_rate = CalculateOverheadRate(
DataRate::bps(encoder_target_rate_bps_), DataRate::BitsPerSec(encoder_target_rate_bps_),
max_total_packet_size - DataSize::bytes(overhead_bytes_per_packet_), max_total_packet_size - DataSize::Bytes(overhead_bytes_per_packet_),
packet_overhead); packet_overhead);
encoder_overhead_rate_bps = std::min( encoder_overhead_rate_bps = std::min(
encoder_overhead_rate.bps<uint32_t>(), encoder_overhead_rate.bps<uint32_t>(),
@ -754,7 +754,7 @@ void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
const uint32_t media_rate = encoder_target_rate_bps_ + const uint32_t media_rate = encoder_target_rate_bps_ +
encoder_overhead_rate_bps + encoder_overhead_rate_bps +
packetization_rate_bps; packetization_rate_bps;
RTC_DCHECK_GE(update.target_bitrate, DataRate::bps(media_rate)); RTC_DCHECK_GE(update.target_bitrate, DataRate::BitsPerSec(media_rate));
protection_bitrate_bps_ = update.target_bitrate.bps() - media_rate; protection_bitrate_bps_ = update.target_bitrate.bps() - media_rate;
} }

View File

@ -502,10 +502,10 @@ TEST(RtpVideoSenderTest, RetransmitsOnTransportWideLossInfo) {
test::Scenario s(test_info_); test::Scenario s(test_info_);
test::CallClientConfig call_conf; test::CallClientConfig call_conf;
// Keeping the bitrate fixed to avoid RTX due to probing. // Keeping the bitrate fixed to avoid RTX due to probing.
call_conf.transport.rates.max_rate = DataRate::kbps(300); call_conf.transport.rates.max_rate = DataRate::KilobitsPerSec(300);
call_conf.transport.rates.start_rate = DataRate::kbps(300); call_conf.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
test::NetworkSimulationConfig net_conf; test::NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(300); net_conf.bandwidth = DataRate::KilobitsPerSec(300);
auto send_node = s.CreateSimulationNode(net_conf); auto send_node = s.CreateSimulationNode(net_conf);
auto* route = s.CreateRoutes(s.CreateClient("send", call_conf), {send_node}, auto* route = s.CreateRoutes(s.CreateClient("send", call_conf), {send_node},
s.CreateClient("return", call_conf), s.CreateClient("return", call_conf),

View File

@ -34,7 +34,7 @@ bool CoDelSimulation::DropDequeuedPacket(Timestamp now,
constexpr TimeDelta kWindow = TimeDelta::Millis(100); constexpr TimeDelta kWindow = TimeDelta::Millis(100);
constexpr TimeDelta kDelayThreshold = TimeDelta::Millis(5); constexpr TimeDelta kDelayThreshold = TimeDelta::Millis(5);
constexpr TimeDelta kDropCountMemory = TimeDelta::Millis(1600); constexpr TimeDelta kDropCountMemory = TimeDelta::Millis(1600);
constexpr DataSize kMaxPacketSize = DataSize::Bytes<1500>(); constexpr DataSize kMaxPacketSize = DataSize::Bytes(1500);
// Compensates for process interval in simulation; not part of standard CoDel. // Compensates for process interval in simulation; not part of standard CoDel.
TimeDelta queuing_time = now - enqueing_time - kDefaultProcessDelay; TimeDelta queuing_time = now - enqueing_time - kDefaultProcessDelay;
@ -193,8 +193,8 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state,
codel_controller_.DropDequeuedPacket( codel_controller_.DropDequeuedPacket(
Timestamp::Micros(time_us), Timestamp::Micros(time_us),
Timestamp::Micros(capacity_link_.front().packet.send_time_us), Timestamp::Micros(capacity_link_.front().packet.send_time_us),
DataSize::bytes(capacity_link_.front().packet.size), DataSize::Bytes(capacity_link_.front().packet.size),
DataSize::bytes(queue_size_bytes_))) { DataSize::Bytes(queue_size_bytes_))) {
PacketInfo dropped = capacity_link_.front(); PacketInfo dropped = capacity_link_.front();
capacity_link_.pop(); capacity_link_.pop();
queue_size_bytes_ -= dropped.packet.size; queue_size_bytes_ -= dropped.packet.size;

View File

@ -26,8 +26,8 @@ constexpr int kNotReceived = PacketDeliveryInfo::kNotReceived;
TEST(SimulatedNetworkTest, CodelDoesNothingAtCapacity) { TEST(SimulatedNetworkTest, CodelDoesNothingAtCapacity) {
const TimeDelta kRuntime = TimeDelta::Seconds(30); const TimeDelta kRuntime = TimeDelta::Seconds(30);
DataRate link_capacity = DataRate::kbps(1000); DataRate link_capacity = DataRate::KilobitsPerSec(1000);
const DataSize packet_size = DataSize::bytes(1000); const DataSize packet_size = DataSize::Bytes(1000);
SimulatedNetwork::Config config; SimulatedNetwork::Config config;
config.codel_active_queue_management = true; config.codel_active_queue_management = true;
@ -80,8 +80,8 @@ TEST(SimulatedNetworkTest, CodelLimitsDelayAndDropsPacketsOnOverload) {
const TimeDelta kRuntime = TimeDelta::Seconds(30); const TimeDelta kRuntime = TimeDelta::Seconds(30);
const TimeDelta kCheckInterval = TimeDelta::Millis(2000); const TimeDelta kCheckInterval = TimeDelta::Millis(2000);
DataRate link_capacity = DataRate::kbps(1000); DataRate link_capacity = DataRate::KilobitsPerSec(1000);
const DataSize rough_packet_size = DataSize::bytes(1500); const DataSize rough_packet_size = DataSize::Bytes(1500);
const double overload_rate = 1.5; const double overload_rate = 1.5;
SimulatedNetwork::Config config; SimulatedNetwork::Config config;

View File

@ -2407,14 +2407,14 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent(
if (proto.has_link_capacity_lower_kbps()) { if (proto.has_link_capacity_lower_kbps()) {
base_link_capacity_lower_kbps = proto.link_capacity_lower_kbps(); base_link_capacity_lower_kbps = proto.link_capacity_lower_kbps();
base_event.link_capacity_lower = base_event.link_capacity_lower =
DataRate::kbps(proto.link_capacity_lower_kbps()); DataRate::KilobitsPerSec(proto.link_capacity_lower_kbps());
} }
absl::optional<uint64_t> base_link_capacity_upper_kbps; absl::optional<uint64_t> base_link_capacity_upper_kbps;
if (proto.has_link_capacity_upper_kbps()) { if (proto.has_link_capacity_upper_kbps()) {
base_link_capacity_upper_kbps = proto.link_capacity_upper_kbps(); base_link_capacity_upper_kbps = proto.link_capacity_upper_kbps();
base_event.link_capacity_upper = base_event.link_capacity_upper =
DataRate::kbps(proto.link_capacity_upper_kbps()); DataRate::KilobitsPerSec(proto.link_capacity_upper_kbps());
} }
remote_estimate_events_.push_back(base_event); remote_estimate_events_.push_back(base_event);
@ -2452,10 +2452,10 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent(
event.timestamp_ms = *timestamp_ms_values[i]; event.timestamp_ms = *timestamp_ms_values[i];
if (link_capacity_lower_kbps_values[i]) if (link_capacity_lower_kbps_values[i])
event.link_capacity_lower = event.link_capacity_lower =
DataRate::kbps(*link_capacity_lower_kbps_values[i]); DataRate::KilobitsPerSec(*link_capacity_lower_kbps_values[i]);
if (link_capacity_upper_kbps_values[i]) if (link_capacity_upper_kbps_values[i])
event.link_capacity_upper = event.link_capacity_upper =
DataRate::kbps(*link_capacity_upper_kbps_values[i]); DataRate::KilobitsPerSec(*link_capacity_upper_kbps_values[i]);
remote_estimate_events_.push_back(event); remote_estimate_events_.push_back(event);
} }
return ParseStatus::Success(); return ParseStatus::Success();

View File

@ -358,8 +358,8 @@ std::unique_ptr<RtcEventRouteChange> EventGenerator::NewRouteChange() {
std::unique_ptr<RtcEventRemoteEstimate> EventGenerator::NewRemoteEstimate() { std::unique_ptr<RtcEventRemoteEstimate> EventGenerator::NewRemoteEstimate() {
return std::make_unique<RtcEventRemoteEstimate>( return std::make_unique<RtcEventRemoteEstimate>(
DataRate::kbps(prng_.Rand(0, 100000)), DataRate::KilobitsPerSec(prng_.Rand(0, 100000)),
DataRate::kbps(prng_.Rand(0, 100000))); DataRate::KilobitsPerSec(prng_.Rand(0, 100000)));
} }
std::unique_ptr<RtcEventRtcpPacketIncoming> std::unique_ptr<RtcEventRtcpPacketIncoming>

View File

@ -45,16 +45,16 @@ constexpr char kUseLegacySimulcastLayerLimitFieldTrial[] =
// Limits for legacy conference screensharing mode. Currently used for the // Limits for legacy conference screensharing mode. Currently used for the
// lower of the two simulcast streams. // lower of the two simulcast streams.
constexpr webrtc::DataRate kScreenshareDefaultTl0Bitrate = constexpr webrtc::DataRate kScreenshareDefaultTl0Bitrate =
webrtc::DataRate::kbps(200); webrtc::DataRate::KilobitsPerSec(200);
constexpr webrtc::DataRate kScreenshareDefaultTl1Bitrate = constexpr webrtc::DataRate kScreenshareDefaultTl1Bitrate =
webrtc::DataRate::kbps(1000); webrtc::DataRate::KilobitsPerSec(1000);
// Min/max bitrate for the higher one of the two simulcast stream used for // Min/max bitrate for the higher one of the two simulcast stream used for
// screen content. // screen content.
constexpr webrtc::DataRate kScreenshareHighStreamMinBitrate = constexpr webrtc::DataRate kScreenshareHighStreamMinBitrate =
webrtc::DataRate::kbps(600); webrtc::DataRate::KilobitsPerSec(600);
constexpr webrtc::DataRate kScreenshareHighStreamMaxBitrate = constexpr webrtc::DataRate kScreenshareHighStreamMaxBitrate =
webrtc::DataRate::kbps(1250); webrtc::DataRate::KilobitsPerSec(1250);
} // namespace } // namespace
@ -78,24 +78,28 @@ struct SimulcastFormat {
// These tables describe from which resolution we can use how many // These tables describe from which resolution we can use how many
// simulcast layers at what bitrates (maximum, target, and minimum). // simulcast layers at what bitrates (maximum, target, and minimum).
// Important!! Keep this table from high resolution to low resolution. // Important!! Keep this table from high resolution to low resolution.
// clang-format off
constexpr const SimulcastFormat kSimulcastFormats[] = { constexpr const SimulcastFormat kSimulcastFormats[] = {
{1920, 1080, 3, webrtc::DataRate::kbps(5000), webrtc::DataRate::kbps(4000), {1920, 1080, 3, webrtc::DataRate::KilobitsPerSec(5000),
webrtc::DataRate::kbps(800)}, webrtc::DataRate::KilobitsPerSec(4000),
{1280, 720, 3, webrtc::DataRate::kbps(2500), webrtc::DataRate::kbps(2500), webrtc::DataRate::KilobitsPerSec(800)},
webrtc::DataRate::kbps(600)}, {1280, 720, 3, webrtc::DataRate::KilobitsPerSec(2500),
{960, 540, 3, webrtc::DataRate::kbps(1200), webrtc::DataRate::kbps(1200), webrtc::DataRate::KilobitsPerSec(2500),
webrtc::DataRate::kbps(350)}, webrtc::DataRate::KilobitsPerSec(600)},
{640, 360, 2, webrtc::DataRate::kbps(700), webrtc::DataRate::kbps(500), {960, 540, 3, webrtc::DataRate::KilobitsPerSec(1200),
webrtc::DataRate::kbps(150)}, webrtc::DataRate::KilobitsPerSec(1200),
{480, 270, 2, webrtc::DataRate::kbps(450), webrtc::DataRate::kbps(350), webrtc::DataRate::KilobitsPerSec(350)},
webrtc::DataRate::kbps(150)}, {640, 360, 2, webrtc::DataRate::KilobitsPerSec(700),
{320, 180, 1, webrtc::DataRate::kbps(200), webrtc::DataRate::kbps(150), webrtc::DataRate::KilobitsPerSec(500),
webrtc::DataRate::kbps(30)}, webrtc::DataRate::KilobitsPerSec(150)},
{0, 0, 1, webrtc::DataRate::kbps(200), webrtc::DataRate::kbps(150), {480, 270, 2, webrtc::DataRate::KilobitsPerSec(450),
webrtc::DataRate::kbps(30)} webrtc::DataRate::KilobitsPerSec(350),
}; webrtc::DataRate::KilobitsPerSec(150)},
// clang-format on {320, 180, 1, webrtc::DataRate::KilobitsPerSec(200),
webrtc::DataRate::KilobitsPerSec(150),
webrtc::DataRate::KilobitsPerSec(30)},
{0, 0, 1, webrtc::DataRate::KilobitsPerSec(200),
webrtc::DataRate::KilobitsPerSec(150),
webrtc::DataRate::KilobitsPerSec(30)}};
const int kMaxScreenshareSimulcastLayers = 2; const int kMaxScreenshareSimulcastLayers = 2;
@ -222,7 +226,7 @@ webrtc::DataRate GetTotalMaxBitrate(
total_max_bitrate_bps += layers[s].target_bitrate_bps; total_max_bitrate_bps += layers[s].target_bitrate_bps;
} }
total_max_bitrate_bps += layers.back().max_bitrate_bps; total_max_bitrate_bps += layers.back().max_bitrate_bps;
return webrtc::DataRate::bps(total_max_bitrate_bps); return webrtc::DataRate::BitsPerSec(total_max_bitrate_bps);
} }
size_t LimitSimulcastLayerCount(int width, size_t LimitSimulcastLayerCount(int width,

View File

@ -508,14 +508,14 @@ void SimulcastEncoderAdapter::SetRates(
// Assign link allocation proportionally to spatial layer allocation. // Assign link allocation proportionally to spatial layer allocation.
if (parameters.bandwidth_allocation != DataRate::Zero()) { if (parameters.bandwidth_allocation != DataRate::Zero()) {
stream_parameters.bandwidth_allocation = stream_parameters.bandwidth_allocation =
DataRate::bps((parameters.bandwidth_allocation.bps() * DataRate::BitsPerSec((parameters.bandwidth_allocation.bps() *
stream_parameters.bitrate.get_sum_bps()) / stream_parameters.bitrate.get_sum_bps()) /
parameters.bitrate.get_sum_bps()); parameters.bitrate.get_sum_bps());
// Make sure we don't allocate bandwidth lower than target bitrate. // Make sure we don't allocate bandwidth lower than target bitrate.
if (stream_parameters.bandwidth_allocation.bps() < if (stream_parameters.bandwidth_allocation.bps() <
stream_parameters.bitrate.get_sum_bps()) { stream_parameters.bitrate.get_sum_bps()) {
stream_parameters.bandwidth_allocation = stream_parameters.bandwidth_allocation =
DataRate::bps(stream_parameters.bitrate.get_sum_bps()); DataRate::BitsPerSec(stream_parameters.bitrate.get_sum_bps());
} }
} }

View File

@ -1275,10 +1275,11 @@ TEST_F(TestSimulcastEncoderAdapterFake, SetRateDistributesBandwithAllocation) {
kVideoCodecVP8); kVideoCodecVP8);
codec_.numberOfSimulcastStreams = 3; codec_.numberOfSimulcastStreams = 3;
const DataRate target_bitrate = const DataRate target_bitrate =
DataRate::kbps(codec_.simulcastStream[0].targetBitrate + DataRate::KilobitsPerSec(codec_.simulcastStream[0].targetBitrate +
codec_.simulcastStream[1].targetBitrate + codec_.simulcastStream[1].targetBitrate +
codec_.simulcastStream[2].minBitrate); codec_.simulcastStream[2].minBitrate);
const DataRate bandwidth_allocation = target_bitrate + DataRate::kbps(600); const DataRate bandwidth_allocation =
target_bitrate + DataRate::KilobitsPerSec(600);
rate_allocator_.reset(new SimulcastRateAllocator(codec_)); rate_allocator_.reset(new SimulcastRateAllocator(codec_));
EXPECT_EQ(0, adapter_->InitEncode(&codec_, kSettings)); EXPECT_EQ(0, adapter_->InitEncode(&codec_, kSettings));
@ -1357,7 +1358,8 @@ TEST_F(TestSimulcastEncoderAdapterFake, SupportsFallback) {
// Make sure we have bitrate for all layers. // Make sure we have bitrate for all layers.
DataRate max_bitrate = DataRate::Zero(); DataRate max_bitrate = DataRate::Zero();
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
max_bitrate += DataRate::kbps(codec_.simulcastStream[i].maxBitrate); max_bitrate +=
DataRate::KilobitsPerSec(codec_.simulcastStream[i].maxBitrate);
} }
const auto rate_settings = VideoEncoder::RateControlParameters( const auto rate_settings = VideoEncoder::RateControlParameters(
rate_allocator_->Allocate( rate_allocator_->Allocate(

View File

@ -63,7 +63,7 @@ TEST(SimulcastTest, BandwidthAboveTotalMaxBitrateGivenToHighestStream) {
streams[1].target_bitrate_bps = 200000; streams[1].target_bitrate_bps = 200000;
streams[2].max_bitrate_bps = 400000; streams[2].max_bitrate_bps = 400000;
const webrtc::DataRate one_bps = webrtc::DataRate::bps(1); const webrtc::DataRate one_bps = webrtc::DataRate::BitsPerSec(1);
// No bitrate above the total max to give to the highest stream. // No bitrate above the total max to give to the highest stream.
const webrtc::DataRate max_total_bitrate = const webrtc::DataRate max_total_bitrate =

View File

@ -3349,7 +3349,7 @@ EncoderStreamFactory::CreateSimulcastOrConfereceModeScreenshareStreams(
// No application-configured maximum for the largest layer. // No application-configured maximum for the largest layer.
// If there is bitrate leftover, give it to the largest layer. // If there is bitrate leftover, give it to the largest layer.
BoostMaxSimulcastLayer( BoostMaxSimulcastLayer(
webrtc::DataRate::bps(encoder_config.max_bitrate_bps), &layers); webrtc::DataRate::BitsPerSec(encoder_config.max_bitrate_bps), &layers);
} }
return layers; return layers;
} }

View File

@ -36,7 +36,7 @@ const int64_t kRegularPacketSizeBytes = 1280;
static_assert((kRegularPacketSizeBytes & 31) == 0, static_assert((kRegularPacketSizeBytes & 31) == 0,
"kRegularPacketSizeBytes has to be five times divisible by 2"); "kRegularPacketSizeBytes has to be five times divisible by 2");
const DataSize kRegularPacketSize = DataSize::bytes(kRegularPacketSizeBytes); const DataSize kRegularPacketSize = DataSize::Bytes(kRegularPacketSizeBytes);
// A test fixture with utility methods for BandwidthSampler tests. // A test fixture with utility methods for BandwidthSampler tests.
class BandwidthSamplerTest : public ::testing::Test { class BandwidthSamplerTest : public ::testing::Test {

View File

@ -35,11 +35,11 @@ const double kProbeBWCongestionWindowGain = 2.0f;
// minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an // minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an
// additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
// max packet size is 1500 bytes, 1500 - 48 = 1452. // max packet size is 1500 bytes, 1500 - 48 = 1452.
const DataSize kMaxPacketSize = DataSize::Bytes<1452>(); const DataSize kMaxPacketSize = DataSize::Bytes(1452);
// Default maximum packet size used in the Linux TCP implementation. // Default maximum packet size used in the Linux TCP implementation.
// Used in QUIC for congestion window computations in bytes. // Used in QUIC for congestion window computations in bytes.
constexpr DataSize kDefaultTCPMSS = DataSize::Bytes<1460>(); constexpr DataSize kDefaultTCPMSS = DataSize::Bytes(1460);
// Constants based on TCP defaults. // Constants based on TCP defaults.
constexpr DataSize kMaxSegmentSize = kDefaultTCPMSS; constexpr DataSize kMaxSegmentSize = kDefaultTCPMSS;
@ -184,7 +184,7 @@ BbrNetworkController::BbrNetworkController(NetworkControllerConfig config)
last_sent_packet_(0), last_sent_packet_(0),
current_round_trip_end_(0), current_round_trip_end_(0),
max_bandwidth_(kBandwidthWindowSize, DataRate::Zero(), 0), max_bandwidth_(kBandwidthWindowSize, DataRate::Zero(), 0),
default_bandwidth_(DataRate::kbps(kInitialBandwidthKbps)), default_bandwidth_(DataRate::KilobitsPerSec(kInitialBandwidthKbps)),
max_ack_height_(kBandwidthWindowSize, DataSize::Zero(), 0), max_ack_height_(kBandwidthWindowSize, DataSize::Zero(), 0),
aggregation_epoch_start_time_(), aggregation_epoch_start_time_(),
aggregation_epoch_bytes_(DataSize::Zero()), aggregation_epoch_bytes_(DataSize::Zero()),

View File

@ -32,7 +32,7 @@ namespace webrtc {
namespace test { namespace test {
namespace { namespace {
const DataRate kInitialBitrate = DataRate::kbps(60); const DataRate kInitialBitrate = DataRate::KilobitsPerSec(60);
const Timestamp kDefaultStartTime = Timestamp::Millis(10000000); const Timestamp kDefaultStartTime = Timestamp::Millis(10000000);
constexpr double kDataRateMargin = 0.3; constexpr double kDataRateMargin = 0.3;
@ -51,9 +51,12 @@ NetworkControllerConfig InitialConfig(
int max_data_rate_kbps = 5 * kInitialBitrate.kbps()) { int max_data_rate_kbps = 5 * kInitialBitrate.kbps()) {
NetworkControllerConfig config; NetworkControllerConfig config;
config.constraints.at_time = kDefaultStartTime; config.constraints.at_time = kDefaultStartTime;
config.constraints.min_data_rate = DataRate::kbps(min_data_rate_kbps); config.constraints.min_data_rate =
config.constraints.max_data_rate = DataRate::kbps(max_data_rate_kbps); DataRate::KilobitsPerSec(min_data_rate_kbps);
config.constraints.starting_rate = DataRate::kbps(starting_bandwidth_kbps); config.constraints.max_data_rate =
DataRate::KilobitsPerSec(max_data_rate_kbps);
config.constraints.starting_rate =
DataRate::KilobitsPerSec(starting_bandwidth_kbps);
return config; return config;
} }
@ -105,7 +108,7 @@ TEST_F(BbrNetworkControllerTest, SendsConfigurationOnNetworkRouteChanged) {
EXPECT_TRUE(update.pacer_config.has_value()); EXPECT_TRUE(update.pacer_config.has_value());
EXPECT_TRUE(update.congestion_window.has_value()); EXPECT_TRUE(update.congestion_window.has_value());
DataRate new_bitrate = DataRate::bps(200000); DataRate new_bitrate = DataRate::BitsPerSec(200000);
update = controller_->OnNetworkRouteChange( update = controller_->OnNetworkRouteChange(
CreateRouteChange(kDefaultStartTime, new_bitrate)); CreateRouteChange(kDefaultStartTime, new_bitrate));
EXPECT_THAT(*update.target_rate, TargetRateCloseTo(new_bitrate)); EXPECT_THAT(*update.target_rate, TargetRateCloseTo(new_bitrate));
@ -121,18 +124,18 @@ TEST_F(BbrNetworkControllerTest, UpdatesTargetSendRate) {
Scenario s("bbr_unit/updates_rate", false); Scenario s("bbr_unit/updates_rate", false);
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
config.transport.rates.max_rate = DataRate::kbps(1500); config.transport.rates.max_rate = DataRate::KilobitsPerSec(1500);
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) { auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(500); c->bandwidth = DataRate::KilobitsPerSec(500);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
c->loss_rate = 0.0; c->loss_rate = 0.0;
}); });
auto ret_net = s.CreateMutableSimulationNode( auto ret_net = s.CreateMutableSimulationNode(
[](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(100); }); [](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(100); });
auto* client = s.CreateClient("send", config); auto* client = s.CreateClient("send", config);
const DataSize kOverhead = DataSize::bytes(38); // IPV4 + UDP + SRTP const DataSize kOverhead = DataSize::Bytes(38); // IPV4 + UDP + SRTP
auto routes = s.CreateRoutes(client, {send_net->node()}, kOverhead, auto routes = s.CreateRoutes(client, {send_net->node()}, kOverhead,
s.CreateClient("recv", CallClientConfig()), s.CreateClient("recv", CallClientConfig()),
{ret_net->node()}, kOverhead); {ret_net->node()}, kOverhead);
@ -142,7 +145,7 @@ TEST_F(BbrNetworkControllerTest, UpdatesTargetSendRate) {
EXPECT_NEAR(client->send_bandwidth().kbps(), 450, 100); EXPECT_NEAR(client->send_bandwidth().kbps(), 450, 100);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(800); c->bandwidth = DataRate::KilobitsPerSec(800);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
@ -150,7 +153,7 @@ TEST_F(BbrNetworkControllerTest, UpdatesTargetSendRate) {
EXPECT_NEAR(client->send_bandwidth().kbps(), 750, 150); EXPECT_NEAR(client->send_bandwidth().kbps(), 750, 150);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(200); c->bandwidth = DataRate::KilobitsPerSec(200);
c->delay = TimeDelta::Millis(200); c->delay = TimeDelta::Millis(200);
}); });
ret_net->UpdateConfig( ret_net->UpdateConfig(

View File

@ -26,7 +26,7 @@ struct ResultForTest {
class DataTransferTrackerForTest : public DataTransferTracker { class DataTransferTrackerForTest : public DataTransferTracker {
public: public:
void AddSample(int bytes, int send_time_ms, int ack_time_ms) { void AddSample(int bytes, int send_time_ms, int ack_time_ms) {
DataTransferTracker::AddSample(DataSize::bytes(bytes), DataTransferTracker::AddSample(DataSize::Bytes(bytes),
Timestamp::Millis(send_time_ms), Timestamp::Millis(send_time_ms),
Timestamp::Millis(ack_time_ms)); Timestamp::Millis(ack_time_ms));
} }

View File

@ -59,7 +59,7 @@ class WindowedFilterTest : public ::testing::Test {
// Third best = 600 bps, recorded at 100ms // Third best = 600 bps, recorded at 100ms
void InitializeMaxFilter() { void InitializeMaxFilter() {
int64_t now_ms = 0; int64_t now_ms = 0;
DataRate bw_sample = DataRate::bps(1000); DataRate bw_sample = DataRate::BitsPerSec(1000);
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << ToString(bw_sample) RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << ToString(bw_sample)
@ -69,11 +69,11 @@ class WindowedFilterTest : public ::testing::Test {
<< ToString(windowed_max_bw_.GetSecondBest()) << " " << ToString(windowed_max_bw_.GetSecondBest()) << " "
<< ToString(windowed_max_bw_.GetThirdBest()); << ToString(windowed_max_bw_.GetThirdBest());
now_ms += 25; now_ms += 25;
bw_sample = DataRate::bps(bw_sample.bps() - 100); bw_sample = DataRate::BitsPerSec(bw_sample.bps() - 100);
} }
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
EXPECT_EQ(DataRate::bps(700), windowed_max_bw_.GetSecondBest()); EXPECT_EQ(DataRate::BitsPerSec(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::bps(600), windowed_max_bw_.GetThirdBest()); EXPECT_EQ(DataRate::BitsPerSec(600), windowed_max_bw_.GetThirdBest());
} }
protected: protected:
@ -135,15 +135,15 @@ TEST_F(WindowedFilterTest, MonotonicallyIncreasingMin) {
TEST_F(WindowedFilterTest, MonotonicallyDecreasingMax) { TEST_F(WindowedFilterTest, MonotonicallyDecreasingMax) {
int64_t now_ms = 0; int64_t now_ms = 0;
DataRate bw_sample = DataRate::bps(1000); DataRate bw_sample = DataRate::BitsPerSec(1000);
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
EXPECT_EQ(DataRate::bps(1000), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(1000), windowed_max_bw_.GetBest());
// Gradually decrease the bw samples and ensure the windowed max bw starts // Gradually decrease the bw samples and ensure the windowed max bw starts
// decreasing. // decreasing.
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
now_ms += 25; now_ms += 25;
bw_sample = DataRate::bps(bw_sample.bps() - 100); bw_sample = DataRate::BitsPerSec(bw_sample.bps() - 100);
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << bw_sample.bps() RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << bw_sample.bps()
<< " maxs: " << " maxs: "
@ -152,11 +152,11 @@ TEST_F(WindowedFilterTest, MonotonicallyDecreasingMax) {
<< windowed_max_bw_.GetSecondBest().bps() << " " << windowed_max_bw_.GetSecondBest().bps() << " "
<< windowed_max_bw_.GetThirdBest().bps(); << windowed_max_bw_.GetThirdBest().bps();
if (i < 3) { if (i < 3) {
EXPECT_EQ(DataRate::bps(1000), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(1000), windowed_max_bw_.GetBest());
} else if (i == 3) { } else if (i == 3) {
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
} else if (i < 6) { } else if (i < 6) {
EXPECT_EQ(DataRate::bps(700), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(700), windowed_max_bw_.GetBest());
} }
} }
} }
@ -181,13 +181,13 @@ TEST_F(WindowedFilterTest, SampleChangesThirdBestMax) {
InitializeMaxFilter(); InitializeMaxFilter();
// BW sample higher than the third-choice max sets that, but nothing else. // BW sample higher than the third-choice max sets that, but nothing else.
DataRate bw_sample = DataRate bw_sample =
DataRate::bps(windowed_max_bw_.GetThirdBest().bps() + 50); DataRate::BitsPerSec(windowed_max_bw_.GetThirdBest().bps() + 50);
// Latest sample was recorded at 100ms. // Latest sample was recorded at 100ms.
int64_t now_ms = 101; int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest()); EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest());
EXPECT_EQ(DataRate::bps(700), windowed_max_bw_.GetSecondBest()); EXPECT_EQ(DataRate::BitsPerSec(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
} }
TEST_F(WindowedFilterTest, SampleChangesSecondBestMin) { TEST_F(WindowedFilterTest, SampleChangesSecondBestMin) {
@ -212,14 +212,14 @@ TEST_F(WindowedFilterTest, SampleChangesSecondBestMax) {
// BW sample higher than the second-choice max sets that and also // BW sample higher than the second-choice max sets that and also
// the third-choice max. // the third-choice max.
DataRate bw_sample = DataRate bw_sample =
DataRate::bps(windowed_max_bw_.GetSecondBest().bps() + 50); DataRate::BitsPerSec(windowed_max_bw_.GetSecondBest().bps() + 50);
// Latest sample was recorded at 100ms. // Latest sample was recorded at 100ms.
int64_t now_ms = 101; int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest()); EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest());
EXPECT_EQ(bw_sample, windowed_max_bw_.GetSecondBest()); EXPECT_EQ(bw_sample, windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest()); EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
} }
TEST_F(WindowedFilterTest, SampleChangesAllMins) { TEST_F(WindowedFilterTest, SampleChangesAllMins) {
@ -242,7 +242,8 @@ TEST_F(WindowedFilterTest, SampleChangesAllMaxs) {
InitializeMaxFilter(); InitializeMaxFilter();
// BW sample higher than the first-choice max sets that and also // BW sample higher than the first-choice max sets that and also
// the second and third-choice maxs. // the second and third-choice maxs.
DataRate bw_sample = DataRate::bps(windowed_max_bw_.GetBest().bps() + 50); DataRate bw_sample =
DataRate::BitsPerSec(windowed_max_bw_.GetBest().bps() + 50);
// Latest sample was recorded at 100ms. // Latest sample was recorded at 100ms.
int64_t now_ms = 101; int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
@ -268,7 +269,7 @@ TEST_F(WindowedFilterTest, ExpireBestMax) {
InitializeMaxFilter(); InitializeMaxFilter();
DataRate old_third_best = windowed_max_bw_.GetThirdBest(); DataRate old_third_best = windowed_max_bw_.GetThirdBest();
DataRate old_second_best = windowed_max_bw_.GetSecondBest(); DataRate old_second_best = windowed_max_bw_.GetSecondBest();
DataRate bw_sample = DataRate::bps(old_third_best.bps() - 50); DataRate bw_sample = DataRate::BitsPerSec(old_third_best.bps() - 50);
// Best max sample was recorded at 25ms, so expiry time is 124ms. // Best max sample was recorded at 25ms, so expiry time is 124ms.
int64_t now_ms = 125; int64_t now_ms = 125;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
@ -292,7 +293,7 @@ TEST_F(WindowedFilterTest, ExpireSecondBestMin) {
TEST_F(WindowedFilterTest, ExpireSecondBestMax) { TEST_F(WindowedFilterTest, ExpireSecondBestMax) {
InitializeMaxFilter(); InitializeMaxFilter();
DataRate old_third_best = windowed_max_bw_.GetThirdBest(); DataRate old_third_best = windowed_max_bw_.GetThirdBest();
DataRate bw_sample = DataRate::bps(old_third_best.bps() - 50); DataRate bw_sample = DataRate::BitsPerSec(old_third_best.bps() - 50);
// Second best max sample was recorded at 75ms, so expiry time is 174ms. // Second best max sample was recorded at 75ms, so expiry time is 174ms.
int64_t now_ms = 175; int64_t now_ms = 175;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);
@ -319,7 +320,7 @@ TEST_F(WindowedFilterTest, ExpireAllMins) {
TEST_F(WindowedFilterTest, ExpireAllMaxs) { TEST_F(WindowedFilterTest, ExpireAllMaxs) {
InitializeMaxFilter(); InitializeMaxFilter();
DataRate bw_sample = DataRate bw_sample =
DataRate::bps(windowed_max_bw_.GetThirdBest().bps() - 50); DataRate::BitsPerSec(windowed_max_bw_.GetThirdBest().bps() - 50);
// Third best max sample was recorded at 100ms, so expiry time is 199ms. // Third best max sample was recorded at 100ms, so expiry time is 199ms.
int64_t now_ms = 200; int64_t now_ms = 200;
windowed_max_bw_.Update(bw_sample, now_ms); windowed_max_bw_.Update(bw_sample, now_ms);

View File

@ -65,14 +65,14 @@ std::vector<PacketResult> CreateFeedbackVector() {
packet_feedback_vector[0].sent_packet.send_time = packet_feedback_vector[0].sent_packet.send_time =
Timestamp::Millis(kFirstSendTimeMs); Timestamp::Millis(kFirstSendTimeMs);
packet_feedback_vector[0].sent_packet.sequence_number = kSequenceNumber; packet_feedback_vector[0].sent_packet.sequence_number = kSequenceNumber;
packet_feedback_vector[0].sent_packet.size = DataSize::bytes(kPayloadSize); packet_feedback_vector[0].sent_packet.size = DataSize::Bytes(kPayloadSize);
packet_feedback_vector[1].receive_time = packet_feedback_vector[1].receive_time =
Timestamp::Millis(kFirstArrivalTimeMs + 10); Timestamp::Millis(kFirstArrivalTimeMs + 10);
packet_feedback_vector[1].sent_packet.send_time = packet_feedback_vector[1].sent_packet.send_time =
Timestamp::Millis(kFirstSendTimeMs + 10); Timestamp::Millis(kFirstSendTimeMs + 10);
packet_feedback_vector[1].sent_packet.sequence_number = kSequenceNumber; packet_feedback_vector[1].sent_packet.sequence_number = kSequenceNumber;
packet_feedback_vector[1].sent_packet.size = packet_feedback_vector[1].sent_packet.size =
DataSize::bytes(kPayloadSize + 10); DataSize::Bytes(kPayloadSize + 10);
return packet_feedback_vector; return packet_feedback_vector;
} }
@ -124,7 +124,7 @@ TEST(TestAcknowledgedBitrateEstimator, ExpectFastRateChangeWhenLeftAlr) {
TEST(TestAcknowledgedBitrateEstimator, ReturnBitrate) { TEST(TestAcknowledgedBitrateEstimator, ReturnBitrate) {
auto states = CreateTestStates(); auto states = CreateTestStates();
absl::optional<DataRate> return_value = DataRate::kbps(42); absl::optional<DataRate> return_value = DataRate::KilobitsPerSec(42);
EXPECT_CALL(*states.mock_bitrate_estimator, bitrate()) EXPECT_CALL(*states.mock_bitrate_estimator, bitrate())
.Times(1) .Times(1)
.WillOnce(Return(return_value)); .WillOnce(Return(return_value));

View File

@ -148,12 +148,12 @@ float BitrateEstimator::UpdateWindow(int64_t now_ms,
absl::optional<DataRate> BitrateEstimator::bitrate() const { absl::optional<DataRate> BitrateEstimator::bitrate() const {
if (bitrate_estimate_kbps_ < 0.f) if (bitrate_estimate_kbps_ < 0.f)
return absl::nullopt; return absl::nullopt;
return DataRate::kbps(bitrate_estimate_kbps_); return DataRate::KilobitsPerSec(bitrate_estimate_kbps_);
} }
absl::optional<DataRate> BitrateEstimator::PeekRate() const { absl::optional<DataRate> BitrateEstimator::PeekRate() const {
if (current_window_ms_ > 0) if (current_window_ms_ > 0)
return DataSize::bytes(sum_) / TimeDelta::Millis(current_window_ms_); return DataSize::Bytes(sum_) / TimeDelta::Millis(current_window_ms_);
return absl::nullopt; return absl::nullopt;
} }

View File

@ -37,20 +37,20 @@ class CongestionWindowPushbackControllerTest : public ::testing::Test {
TEST_F(CongestionWindowPushbackControllerTest, FullCongestionWindow) { TEST_F(CongestionWindowPushbackControllerTest, FullCongestionWindow) {
cwnd_controller_->UpdateOutstandingData(100000); cwnd_controller_->UpdateOutstandingData(100000);
cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(50000));
uint32_t bitrate_bps = 80000; uint32_t bitrate_bps = 80000;
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);
EXPECT_EQ(72000u, bitrate_bps); EXPECT_EQ(72000u, bitrate_bps);
cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(50000));
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);
EXPECT_EQ(static_cast<uint32_t>(72000 * 0.9 * 0.9), bitrate_bps); EXPECT_EQ(static_cast<uint32_t>(72000 * 0.9 * 0.9), bitrate_bps);
} }
TEST_F(CongestionWindowPushbackControllerTest, NormalCongestionWindow) { TEST_F(CongestionWindowPushbackControllerTest, NormalCongestionWindow) {
cwnd_controller_->UpdateOutstandingData(199999); cwnd_controller_->UpdateOutstandingData(199999);
cwnd_controller_->SetDataWindow(DataSize::bytes(200000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(200000));
uint32_t bitrate_bps = 80000; uint32_t bitrate_bps = 80000;
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);
@ -59,13 +59,13 @@ TEST_F(CongestionWindowPushbackControllerTest, NormalCongestionWindow) {
TEST_F(CongestionWindowPushbackControllerTest, LowBitrate) { TEST_F(CongestionWindowPushbackControllerTest, LowBitrate) {
cwnd_controller_->UpdateOutstandingData(100000); cwnd_controller_->UpdateOutstandingData(100000);
cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(50000));
uint32_t bitrate_bps = 35000; uint32_t bitrate_bps = 35000;
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);
EXPECT_EQ(static_cast<uint32_t>(35000 * 0.9), bitrate_bps); EXPECT_EQ(static_cast<uint32_t>(35000 * 0.9), bitrate_bps);
cwnd_controller_->SetDataWindow(DataSize::bytes(20000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(20000));
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);
EXPECT_EQ(30000u, bitrate_bps); EXPECT_EQ(30000u, bitrate_bps);
} }
@ -94,7 +94,7 @@ TEST_F(CongestionWindowPushbackControllerTest, PushbackDropFrame) {
cwnd_controller_.reset( cwnd_controller_.reset(
new CongestionWindowPushbackController(&field_trial_config_)); new CongestionWindowPushbackController(&field_trial_config_));
cwnd_controller_->UpdateOutstandingData(1e8); // Large number cwnd_controller_->UpdateOutstandingData(1e8); // Large number
cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); cwnd_controller_->SetDataWindow(DataSize::Bytes(50000));
uint32_t bitrate_bps = 80000; uint32_t bitrate_bps = 80000;
bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps);

View File

@ -174,8 +174,8 @@ TEST_F(DelayBasedBweTest, TestLongTimeoutAndWrap) {
} }
TEST_F(DelayBasedBweTest, TestInitialOveruse) { TEST_F(DelayBasedBweTest, TestInitialOveruse) {
const DataRate kStartBitrate = DataRate::kbps(300); const DataRate kStartBitrate = DataRate::KilobitsPerSec(300);
const DataRate kInitialCapacity = DataRate::kbps(200); const DataRate kInitialCapacity = DataRate::KilobitsPerSec(200);
const uint32_t kDummySsrc = 0; const uint32_t kDummySsrc = 0;
// High FPS to ensure that we send a lot of packets in a short time. // High FPS to ensure that we send a lot of packets in a short time.
const int kFps = 90; const int kFps = 90;
@ -222,8 +222,8 @@ class DelayBasedBweTestWithBackoffTimeoutExperiment : public DelayBasedBweTest {
// This test subsumes and improves DelayBasedBweTest.TestInitialOveruse above. // This test subsumes and improves DelayBasedBweTest.TestInitialOveruse above.
TEST_F(DelayBasedBweTestWithBackoffTimeoutExperiment, TestInitialOveruse) { TEST_F(DelayBasedBweTestWithBackoffTimeoutExperiment, TestInitialOveruse) {
const DataRate kStartBitrate = DataRate::kbps(300); const DataRate kStartBitrate = DataRate::KilobitsPerSec(300);
const DataRate kInitialCapacity = DataRate::kbps(200); const DataRate kInitialCapacity = DataRate::KilobitsPerSec(200);
const uint32_t kDummySsrc = 0; const uint32_t kDummySsrc = 0;
// High FPS to ensure that we send a lot of packets in a short time. // High FPS to ensure that we send a lot of packets in a short time.
const int kFps = 90; const int kFps = 90;

View File

@ -54,7 +54,7 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us,
PacketResult packet; PacketResult packet;
packet.sent_packet.send_time = packet.sent_packet.send_time =
Timestamp::Micros(time_now_us + kSendSideOffsetUs); Timestamp::Micros(time_now_us + kSendSideOffsetUs);
packet.sent_packet.size = DataSize::bytes(payload_size); packet.sent_packet.size = DataSize::Bytes(payload_size);
packets->push_back(packet); packets->push_back(packet);
} }
next_rtp_time_ = time_now_us + (1000000 + fps_ / 2) / fps_; next_rtp_time_ = time_now_us + (1000000 + fps_ / 2) / fps_;
@ -196,7 +196,7 @@ void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms,
packet.receive_time = packet.receive_time =
Timestamp::Millis(arrival_time_ms + arrival_time_offset_ms_); Timestamp::Millis(arrival_time_ms + arrival_time_offset_ms_);
packet.sent_packet.send_time = Timestamp::Millis(send_time_ms); packet.sent_packet.send_time = Timestamp::Millis(send_time_ms);
packet.sent_packet.size = DataSize::bytes(payload_size); packet.sent_packet.size = DataSize::Bytes(payload_size);
packet.sent_packet.pacing_info = pacing_info; packet.sent_packet.pacing_info = pacing_info;
if (packet.sent_packet.pacing_info.probe_cluster_id != if (packet.sent_packet.pacing_info.probe_cluster_id !=
PacedPacketInfo::kNotAProbe) PacedPacketInfo::kNotAProbe)

View File

@ -375,7 +375,7 @@ void GoogCcNetworkController::UpdateCongestionWindowSize() {
TimeDelta min_feedback_max_rtt = TimeDelta::Millis( TimeDelta min_feedback_max_rtt = TimeDelta::Millis(
*std::min_element(feedback_max_rtts_.begin(), feedback_max_rtts_.end())); *std::min_element(feedback_max_rtts_.begin(), feedback_max_rtts_.end()));
const DataSize kMinCwnd = DataSize::bytes(2 * 1500); const DataSize kMinCwnd = DataSize::Bytes(2 * 1500);
TimeDelta time_window = TimeDelta time_window =
min_feedback_max_rtt + min_feedback_max_rtt +
TimeDelta::Millis( TimeDelta::Millis(
@ -607,7 +607,7 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
loss_based_target_rate.bps()); loss_based_target_rate.bps());
pushback_rate = std::max<int64_t>(bandwidth_estimation_->GetMinBitrate(), pushback_rate = std::max<int64_t>(bandwidth_estimation_->GetMinBitrate(),
pushback_rate); pushback_rate);
pushback_target_rate = DataRate::bps(pushback_rate); pushback_target_rate = DataRate::BitsPerSec(pushback_rate);
if (rate_control_settings_.UseCongestionWindowDropFrameOnly()) { if (rate_control_settings_.UseCongestionWindowDropFrameOnly()) {
cwnd_reduce_ratio = static_cast<double>(loss_based_target_rate.bps() - cwnd_reduce_ratio = static_cast<double>(loss_based_target_rate.bps() -
pushback_target_rate.bps()) / pushback_target_rate.bps()) /

View File

@ -56,7 +56,7 @@ GoogCcNetworkControllerFactory CreateFeedbackOnlyFactory() {
} }
const uint32_t kInitialBitrateKbps = 60; const uint32_t kInitialBitrateKbps = 60;
const DataRate kInitialBitrate = DataRate::kbps(kInitialBitrateKbps); const DataRate kInitialBitrate = DataRate::KilobitsPerSec(kInitialBitrateKbps);
const float kDefaultPacingRate = 2.5f; const float kDefaultPacingRate = 2.5f;
CallClient* CreateVideoSendingClient( CallClient* CreateVideoSendingClient(
@ -78,11 +78,11 @@ void UpdatesTargetRateBasedOnLinkCapacity(std::string test_name = "") {
Scenario s("googcc_unit/target_capacity" + test_name, false); Scenario s("googcc_unit/target_capacity" + test_name, false);
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
config.transport.rates.max_rate = DataRate::kbps(1500); config.transport.rates.max_rate = DataRate::KilobitsPerSec(1500);
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) { auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(500); c->bandwidth = DataRate::KilobitsPerSec(500);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
c->loss_rate = 0.0; c->loss_rate = 0.0;
}); });
@ -100,7 +100,7 @@ void UpdatesTargetRateBasedOnLinkCapacity(std::string test_name = "") {
EXPECT_NEAR(client->target_rate().kbps(), 450, 100); EXPECT_NEAR(client->target_rate().kbps(), 450, 100);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(800); c->bandwidth = DataRate::KilobitsPerSec(800);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
@ -110,7 +110,7 @@ void UpdatesTargetRateBasedOnLinkCapacity(std::string test_name = "") {
EXPECT_NEAR(client->target_rate().kbps(), 750, 150); EXPECT_NEAR(client->target_rate().kbps(), 750, 150);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(100); c->bandwidth = DataRate::KilobitsPerSec(100);
c->delay = TimeDelta::Millis(200); c->delay = TimeDelta::Millis(200);
}); });
ret_net->UpdateConfig( ret_net->UpdateConfig(
@ -155,9 +155,12 @@ class GoogCcNetworkControllerTest : public ::testing::Test {
int max_data_rate_kbps = 5 * kInitialBitrateKbps) { int max_data_rate_kbps = 5 * kInitialBitrateKbps) {
NetworkControllerConfig config; NetworkControllerConfig config;
config.constraints.at_time = current_time_; config.constraints.at_time = current_time_;
config.constraints.min_data_rate = DataRate::kbps(min_data_rate_kbps); config.constraints.min_data_rate =
config.constraints.max_data_rate = DataRate::kbps(max_data_rate_kbps); DataRate::KilobitsPerSec(min_data_rate_kbps);
config.constraints.starting_rate = DataRate::kbps(starting_bandwidth_kbps); config.constraints.max_data_rate =
DataRate::KilobitsPerSec(max_data_rate_kbps);
config.constraints.starting_rate =
DataRate::KilobitsPerSec(starting_bandwidth_kbps);
config.event_log = &event_log_; config.event_log = &event_log_;
return config; return config;
} }
@ -179,7 +182,7 @@ class GoogCcNetworkControllerTest : public ::testing::Test {
PacketResult packet_result; PacketResult packet_result;
packet_result.sent_packet = SentPacket(); packet_result.sent_packet = SentPacket();
packet_result.sent_packet.send_time = Timestamp::Millis(send_time_ms); packet_result.sent_packet.send_time = Timestamp::Millis(send_time_ms);
packet_result.sent_packet.size = DataSize::bytes(payload_size); packet_result.sent_packet.size = DataSize::Bytes(payload_size);
packet_result.sent_packet.pacing_info = pacing_info; packet_result.sent_packet.pacing_info = pacing_info;
packet_result.receive_time = Timestamp::Millis(arrival_time_ms); packet_result.receive_time = Timestamp::Millis(arrival_time_ms);
return packet_result; return packet_result;
@ -263,7 +266,7 @@ TEST_F(GoogCcNetworkControllerTest, CongestionWindowPushbackOnNetworkDelay) {
Scenario s("googcc_unit/cwnd_on_delay", false); Scenario s("googcc_unit/cwnd_on_delay", false);
auto send_net = auto send_net =
s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) { s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(1000); c->bandwidth = DataRate::KilobitsPerSec(1000);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
auto ret_net = s.CreateSimulationNode( auto ret_net = s.CreateSimulationNode(
@ -271,9 +274,9 @@ TEST_F(GoogCcNetworkControllerTest, CongestionWindowPushbackOnNetworkDelay) {
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
// Start high so bandwidth drop has max effect. // Start high so bandwidth drop has max effect.
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
config.transport.rates.max_rate = DataRate::kbps(2000); config.transport.rates.max_rate = DataRate::KilobitsPerSec(2000);
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
auto* client = CreateVideoSendingClient(&s, std::move(config), auto* client = CreateVideoSendingClient(&s, std::move(config),
{send_net->node()}, {ret_net}); {send_net->node()}, {ret_net});
@ -298,7 +301,7 @@ TEST_F(GoogCcNetworkControllerTest,
Scenario s("googcc_unit/cwnd_on_delay", false); Scenario s("googcc_unit/cwnd_on_delay", false);
auto send_net = auto send_net =
s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) { s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(1000); c->bandwidth = DataRate::KilobitsPerSec(1000);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
auto ret_net = s.CreateSimulationNode( auto ret_net = s.CreateSimulationNode(
@ -306,9 +309,9 @@ TEST_F(GoogCcNetworkControllerTest,
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
// Start high so bandwidth drop has max effect. // Start high so bandwidth drop has max effect.
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
config.transport.rates.max_rate = DataRate::kbps(2000); config.transport.rates.max_rate = DataRate::KilobitsPerSec(2000);
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
auto* client = CreateVideoSendingClient(&s, std::move(config), auto* client = CreateVideoSendingClient(&s, std::move(config),
{send_net->node()}, {ret_net}); {send_net->node()}, {ret_net});
@ -325,7 +328,7 @@ TEST_F(GoogCcNetworkControllerTest,
TEST_F(GoogCcNetworkControllerTest, OnNetworkRouteChanged) { TEST_F(GoogCcNetworkControllerTest, OnNetworkRouteChanged) {
NetworkControlUpdate update; NetworkControlUpdate update;
DataRate new_bitrate = DataRate::bps(200000); DataRate new_bitrate = DataRate::BitsPerSec(200000);
update = controller_->OnNetworkRouteChange(CreateRouteChange(new_bitrate)); update = controller_->OnNetworkRouteChange(CreateRouteChange(new_bitrate));
EXPECT_EQ(update.target_rate->target_rate, new_bitrate); EXPECT_EQ(update.target_rate->target_rate, new_bitrate);
EXPECT_EQ(update.pacer_config->data_rate(), new_bitrate * kDefaultPacingRate); EXPECT_EQ(update.pacer_config->data_rate(), new_bitrate * kDefaultPacingRate);
@ -333,7 +336,7 @@ TEST_F(GoogCcNetworkControllerTest, OnNetworkRouteChanged) {
// If the bitrate is reset to -1, the new starting bitrate will be // If the bitrate is reset to -1, the new starting bitrate will be
// the minimum default bitrate. // the minimum default bitrate.
const DataRate kDefaultMinBitrate = DataRate::kbps(5); const DataRate kDefaultMinBitrate = DataRate::KilobitsPerSec(5);
update = controller_->OnNetworkRouteChange(CreateRouteChange()); update = controller_->OnNetworkRouteChange(CreateRouteChange());
EXPECT_EQ(update.target_rate->target_rate, kDefaultMinBitrate); EXPECT_EQ(update.target_rate->target_rate, kDefaultMinBitrate);
EXPECT_NEAR(update.pacer_config->data_rate().bps<double>(), EXPECT_NEAR(update.pacer_config->data_rate().bps<double>(),
@ -384,15 +387,15 @@ TEST_F(GoogCcNetworkControllerTest,
Scenario s("googcc_unit/padding_limited", false); Scenario s("googcc_unit/padding_limited", false);
auto send_net = auto send_net =
s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) { s.CreateMutableSimulationNode([=](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(1000); c->bandwidth = DataRate::KilobitsPerSec(1000);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
auto ret_net = s.CreateSimulationNode( auto ret_net = s.CreateSimulationNode(
[](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(100); }); [](NetworkSimulationConfig* c) { c->delay = TimeDelta::Millis(100); });
CallClientConfig config; CallClientConfig config;
// Start high so bandwidth drop has max effect. // Start high so bandwidth drop has max effect.
config.transport.rates.start_rate = DataRate::kbps(1000); config.transport.rates.start_rate = DataRate::KilobitsPerSec(1000);
config.transport.rates.max_rate = DataRate::kbps(2000); config.transport.rates.max_rate = DataRate::KilobitsPerSec(2000);
auto* client = s.CreateClient("send", config); auto* client = s.CreateClient("send", config);
auto* route = auto* route =
s.CreateRoutes(client, {send_net->node()}, s.CreateRoutes(client, {send_net->node()},
@ -417,13 +420,13 @@ TEST_F(GoogCcNetworkControllerTest, LimitsToFloorIfRttIsHighInTrial) {
// controller backs off until it reaches the minimum configured bitrate. This // controller backs off until it reaches the minimum configured bitrate. This
// allows the RTT to recover faster than the regular control mechanism would // allows the RTT to recover faster than the regular control mechanism would
// achieve. // achieve.
const DataRate kBandwidthFloor = DataRate::kbps(50); const DataRate kBandwidthFloor = DataRate::KilobitsPerSec(50);
ScopedFieldTrials trial("WebRTC-Bwe-MaxRttLimit/limit:2s,floor:" + ScopedFieldTrials trial("WebRTC-Bwe-MaxRttLimit/limit:2s,floor:" +
std::to_string(kBandwidthFloor.kbps()) + "kbps/"); std::to_string(kBandwidthFloor.kbps()) + "kbps/");
// In the test case, we limit the capacity and add a cross traffic packet // In the test case, we limit the capacity and add a cross traffic packet
// burst that blocks media from being sent. This causes the RTT to quickly // burst that blocks media from being sent. This causes the RTT to quickly
// increase above the threshold in the trial. // increase above the threshold in the trial.
const DataRate kLinkCapacity = DataRate::kbps(100); const DataRate kLinkCapacity = DataRate::KilobitsPerSec(100);
const TimeDelta kBufferBloatDuration = TimeDelta::Seconds(10); const TimeDelta kBufferBloatDuration = TimeDelta::Seconds(10);
Scenario s("googcc_unit/limit_trial", false); Scenario s("googcc_unit/limit_trial", false);
auto send_net = s.CreateSimulationNode([=](NetworkSimulationConfig* c) { auto send_net = s.CreateSimulationNode([=](NetworkSimulationConfig* c) {
@ -438,7 +441,7 @@ TEST_F(GoogCcNetworkControllerTest, LimitsToFloorIfRttIsHighInTrial) {
auto* client = CreateVideoSendingClient(&s, config, {send_net}, {ret_net}); auto* client = CreateVideoSendingClient(&s, config, {send_net}, {ret_net});
// Run for a few seconds to allow the controller to stabilize. // Run for a few seconds to allow the controller to stabilize.
s.RunFor(TimeDelta::Seconds(10)); s.RunFor(TimeDelta::Seconds(10));
const DataSize kBloatPacketSize = DataSize::bytes(1000); const DataSize kBloatPacketSize = DataSize::Bytes(1000);
const int kBloatPacketCount = const int kBloatPacketCount =
static_cast<int>(kBufferBloatDuration * kLinkCapacity / kBloatPacketSize); static_cast<int>(kBufferBloatDuration * kLinkCapacity / kBloatPacketSize);
// This will cause the RTT to be large for a while. // This will cause the RTT to be large for a while.
@ -459,7 +462,7 @@ TEST_F(GoogCcNetworkControllerTest, StableEstimateDoesNotVaryInSteadyState) {
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
NetworkSimulationConfig net_conf; NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(500); net_conf.bandwidth = DataRate::KilobitsPerSec(500);
net_conf.delay = TimeDelta::Millis(100); net_conf.delay = TimeDelta::Millis(100);
auto send_net = s.CreateSimulationNode(net_conf); auto send_net = s.CreateSimulationNode(net_conf);
auto ret_net = s.CreateSimulationNode(net_conf); auto ret_net = s.CreateSimulationNode(net_conf);
@ -502,11 +505,11 @@ TEST_F(GoogCcNetworkControllerTest,
ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/");
Scenario s("googcc_unit/high_loss_channel", false); Scenario s("googcc_unit/high_loss_channel", false);
CallClientConfig config; CallClientConfig config;
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
config.transport.rates.max_rate = DataRate::kbps(1500); config.transport.rates.max_rate = DataRate::KilobitsPerSec(1500);
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
auto send_net = s.CreateSimulationNode([](NetworkSimulationConfig* c) { auto send_net = s.CreateSimulationNode([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(2000); c->bandwidth = DataRate::KilobitsPerSec(2000);
c->delay = TimeDelta::Millis(200); c->delay = TimeDelta::Millis(200);
c->loss_rate = 0.1; c->loss_rate = 0.1;
}); });
@ -523,7 +526,7 @@ TEST_F(GoogCcNetworkControllerTest,
DataRate AverageBitrateAfterCrossInducedLoss(std::string name) { DataRate AverageBitrateAfterCrossInducedLoss(std::string name) {
Scenario s(name, false); Scenario s(name, false);
NetworkSimulationConfig net_conf; NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000); net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(100); net_conf.delay = TimeDelta::Millis(100);
// Short queue length means that we'll induce loss when sudden TCP traffic // Short queue length means that we'll induce loss when sudden TCP traffic
// spikes are induced. This corresponds to ca 200 ms for a packet size of 1000 // spikes are induced. This corresponds to ca 200 ms for a packet size of 1000
@ -550,7 +553,7 @@ DataRate AverageBitrateAfterCrossInducedLoss(std::string name) {
s.net()->StopCrossTraffic(tcp_traffic); s.net()->StopCrossTraffic(tcp_traffic);
s.RunFor(TimeDelta::Seconds(20)); s.RunFor(TimeDelta::Seconds(20));
} }
return DataSize::bytes(video->receive() return DataSize::Bytes(video->receive()
->GetStats() ->GetStats()
.rtp_stats.packet_counter.TotalBytes()) / .rtp_stats.packet_counter.TotalBytes()) /
s.TimeSinceStart(); s.TimeSinceStart();
@ -562,7 +565,7 @@ TEST_F(GoogCcNetworkControllerTest,
// trial, we have worse behavior. // trial, we have worse behavior.
DataRate average_bitrate = DataRate average_bitrate =
AverageBitrateAfterCrossInducedLoss("googcc_unit/no_cross_loss_based"); AverageBitrateAfterCrossInducedLoss("googcc_unit/no_cross_loss_based");
RTC_DCHECK_LE(average_bitrate, DataRate::kbps(650)); RTC_DCHECK_LE(average_bitrate, DataRate::KilobitsPerSec(650));
} }
TEST_F(GoogCcNetworkControllerTest, TEST_F(GoogCcNetworkControllerTest,
@ -572,19 +575,19 @@ TEST_F(GoogCcNetworkControllerTest,
ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/");
DataRate average_bitrate = DataRate average_bitrate =
AverageBitrateAfterCrossInducedLoss("googcc_unit/cross_loss_based"); AverageBitrateAfterCrossInducedLoss("googcc_unit/cross_loss_based");
RTC_DCHECK_GE(average_bitrate, DataRate::kbps(750)); RTC_DCHECK_GE(average_bitrate, DataRate::KilobitsPerSec(750));
} }
TEST_F(GoogCcNetworkControllerTest, LossBasedEstimatorCapsRateAtModerateLoss) { TEST_F(GoogCcNetworkControllerTest, LossBasedEstimatorCapsRateAtModerateLoss) {
ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/");
Scenario s("googcc_unit/moderate_loss_channel", false); Scenario s("googcc_unit/moderate_loss_channel", false);
CallClientConfig config; CallClientConfig config;
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
config.transport.rates.max_rate = DataRate::kbps(5000); config.transport.rates.max_rate = DataRate::KilobitsPerSec(5000);
config.transport.rates.start_rate = DataRate::kbps(1000); config.transport.rates.start_rate = DataRate::KilobitsPerSec(1000);
NetworkSimulationConfig network; NetworkSimulationConfig network;
network.bandwidth = DataRate::kbps(2000); network.bandwidth = DataRate::KilobitsPerSec(2000);
network.delay = TimeDelta::Millis(100); network.delay = TimeDelta::Millis(100);
// 3% loss rate is in the moderate loss rate region at 2000 kbps, limiting the // 3% loss rate is in the moderate loss rate region at 2000 kbps, limiting the
// bitrate increase. // bitrate increase.
@ -599,8 +602,9 @@ TEST_F(GoogCcNetworkControllerTest, LossBasedEstimatorCapsRateAtModerateLoss) {
s.RunFor(TimeDelta::Seconds(1)); s.RunFor(TimeDelta::Seconds(1));
// This increase in capacity would cause the target bitrate to increase to // This increase in capacity would cause the target bitrate to increase to
// over 4000 kbps without LossBasedControl. // over 4000 kbps without LossBasedControl.
send_net->UpdateConfig( send_net->UpdateConfig([](NetworkSimulationConfig* c) {
[](NetworkSimulationConfig* c) { c->bandwidth = DataRate::kbps(5000); }); c->bandwidth = DataRate::KilobitsPerSec(5000);
});
s.RunFor(TimeDelta::Seconds(20)); s.RunFor(TimeDelta::Seconds(20));
// Using LossBasedControl, the bitrate will not increase over 2500 kbps since // Using LossBasedControl, the bitrate will not increase over 2500 kbps since
// we have detected moderate loss. // we have detected moderate loss.
@ -608,8 +612,8 @@ TEST_F(GoogCcNetworkControllerTest, LossBasedEstimatorCapsRateAtModerateLoss) {
} }
TEST_F(GoogCcNetworkControllerTest, MaintainsLowRateInSafeResetTrial) { TEST_F(GoogCcNetworkControllerTest, MaintainsLowRateInSafeResetTrial) {
const DataRate kLinkCapacity = DataRate::kbps(200); const DataRate kLinkCapacity = DataRate::KilobitsPerSec(200);
const DataRate kStartRate = DataRate::kbps(300); const DataRate kStartRate = DataRate::KilobitsPerSec(300);
ScopedFieldTrials trial("WebRTC-Bwe-SafeResetOnRouteChange/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-SafeResetOnRouteChange/Enabled/");
Scenario s("googcc_unit/safe_reset_low"); Scenario s("googcc_unit/safe_reset_low");
@ -635,8 +639,8 @@ TEST_F(GoogCcNetworkControllerTest, MaintainsLowRateInSafeResetTrial) {
} }
TEST_F(GoogCcNetworkControllerTest, CutsHighRateInSafeResetTrial) { TEST_F(GoogCcNetworkControllerTest, CutsHighRateInSafeResetTrial) {
const DataRate kLinkCapacity = DataRate::kbps(1000); const DataRate kLinkCapacity = DataRate::KilobitsPerSec(1000);
const DataRate kStartRate = DataRate::kbps(300); const DataRate kStartRate = DataRate::KilobitsPerSec(300);
ScopedFieldTrials trial("WebRTC-Bwe-SafeResetOnRouteChange/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-SafeResetOnRouteChange/Enabled/");
Scenario s("googcc_unit/safe_reset_high_cut"); Scenario s("googcc_unit/safe_reset_high_cut");
@ -665,9 +669,9 @@ TEST_F(GoogCcNetworkControllerTest, DetectsHighRateInSafeResetTrial) {
ScopedFieldTrials trial( ScopedFieldTrials trial(
"WebRTC-Bwe-SafeResetOnRouteChange/Enabled,ack/" "WebRTC-Bwe-SafeResetOnRouteChange/Enabled,ack/"
"WebRTC-SendSideBwe-WithOverhead/Enabled/"); "WebRTC-SendSideBwe-WithOverhead/Enabled/");
const DataRate kInitialLinkCapacity = DataRate::kbps(200); const DataRate kInitialLinkCapacity = DataRate::KilobitsPerSec(200);
const DataRate kNewLinkCapacity = DataRate::kbps(800); const DataRate kNewLinkCapacity = DataRate::KilobitsPerSec(800);
const DataRate kStartRate = DataRate::kbps(300); const DataRate kStartRate = DataRate::KilobitsPerSec(300);
Scenario s("googcc_unit/safe_reset_high_detect"); Scenario s("googcc_unit/safe_reset_high_detect");
auto* initial_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) { auto* initial_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) {
@ -709,8 +713,8 @@ TEST_F(GoogCcNetworkControllerTest,
"WebRTC-Video-Pacing/factor:1.0/" "WebRTC-Video-Pacing/factor:1.0/"
"WebRTC-AddPacingToCongestionWindowPushback/Enabled/"); "WebRTC-AddPacingToCongestionWindowPushback/Enabled/");
const DataRate kLinkCapacity = DataRate::kbps(1000); const DataRate kLinkCapacity = DataRate::KilobitsPerSec(1000);
const DataRate kStartRate = DataRate::kbps(1000); const DataRate kStartRate = DataRate::KilobitsPerSec(1000);
Scenario s("googcc_unit/pacing_buffer_buildup"); Scenario s("googcc_unit/pacing_buffer_buildup");
auto* net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) { auto* net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) {
@ -735,13 +739,13 @@ TEST_F(GoogCcNetworkControllerTest, NoBandwidthTogglingInLossControlTrial) {
ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/"); ScopedFieldTrials trial("WebRTC-Bwe-LossBasedControl/Enabled/");
Scenario s("googcc_unit/no_toggling"); Scenario s("googcc_unit/no_toggling");
auto* send_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) { auto* send_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(2000); c->bandwidth = DataRate::KilobitsPerSec(2000);
c->loss_rate = 0.2; c->loss_rate = 0.2;
c->delay = TimeDelta::Millis(10); c->delay = TimeDelta::Millis(10);
}); });
auto* client = s.CreateClient("send", [&](CallClientConfig* c) { auto* client = s.CreateClient("send", [&](CallClientConfig* c) {
c->transport.rates.start_rate = DataRate::kbps(300); c->transport.rates.start_rate = DataRate::KilobitsPerSec(300);
}); });
auto* route = s.CreateRoutes( auto* route = s.CreateRoutes(
client, {send_net}, s.CreateClient("return", CallClientConfig()), client, {send_net}, s.CreateClient("return", CallClientConfig()),
@ -759,7 +763,9 @@ TEST_F(GoogCcNetworkControllerTest, NoBandwidthTogglingInLossControlTrial) {
if (bandwidth_history.size() >= window / step) if (bandwidth_history.size() >= window / step)
bandwidth_history.pop(); bandwidth_history.pop();
bandwidth_history.push(client->send_bandwidth()); bandwidth_history.push(client->send_bandwidth());
EXPECT_LT(CountBandwidthDips(bandwidth_history, DataRate::kbps(100)), 2); EXPECT_LT(
CountBandwidthDips(bandwidth_history, DataRate::KilobitsPerSec(100)),
2);
} }
} }
@ -767,12 +773,12 @@ TEST_F(GoogCcNetworkControllerTest, NoRttBackoffCollapseWhenVideoStops) {
ScopedFieldTrials trial("WebRTC-Bwe-MaxRttLimit/limit:2s/"); ScopedFieldTrials trial("WebRTC-Bwe-MaxRttLimit/limit:2s/");
Scenario s("googcc_unit/rttbackoff_video_stop"); Scenario s("googcc_unit/rttbackoff_video_stop");
auto* send_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) { auto* send_net = s.CreateSimulationNode([&](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(2000); c->bandwidth = DataRate::KilobitsPerSec(2000);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
auto* client = s.CreateClient("send", [&](CallClientConfig* c) { auto* client = s.CreateClient("send", [&](CallClientConfig* c) {
c->transport.rates.start_rate = DataRate::kbps(1000); c->transport.rates.start_rate = DataRate::KilobitsPerSec(1000);
}); });
auto* route = s.CreateRoutes( auto* route = s.CreateRoutes(
client, {send_net}, s.CreateClient("return", CallClientConfig()), client, {send_net}, s.CreateClient("return", CallClientConfig()),
@ -812,10 +818,10 @@ TEST_F(GoogCcNetworkControllerTest, NoCrashOnVeryLateFeedback) {
TEST_F(GoogCcNetworkControllerTest, IsFairToTCP) { TEST_F(GoogCcNetworkControllerTest, IsFairToTCP) {
Scenario s("googcc_unit/tcp_fairness"); Scenario s("googcc_unit/tcp_fairness");
NetworkSimulationConfig net_conf; NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000); net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(50); net_conf.delay = TimeDelta::Millis(50);
auto* client = s.CreateClient("send", [&](CallClientConfig* c) { auto* client = s.CreateClient("send", [&](CallClientConfig* c) {
c->transport.rates.start_rate = DataRate::kbps(1000); c->transport.rates.start_rate = DataRate::KilobitsPerSec(1000);
}); });
auto send_net = {s.CreateSimulationNode(net_conf)}; auto send_net = {s.CreateSimulationNode(net_conf)};
auto ret_net = {s.CreateSimulationNode(net_conf)}; auto ret_net = {s.CreateSimulationNode(net_conf)};

View File

@ -18,14 +18,14 @@ LinkCapacityEstimator::LinkCapacityEstimator() {}
DataRate LinkCapacityEstimator::UpperBound() const { DataRate LinkCapacityEstimator::UpperBound() const {
if (estimate_kbps_.has_value()) if (estimate_kbps_.has_value())
return DataRate::kbps(estimate_kbps_.value() + return DataRate::KilobitsPerSec(estimate_kbps_.value() +
3 * deviation_estimate_kbps()); 3 * deviation_estimate_kbps());
return DataRate::Infinity(); return DataRate::Infinity();
} }
DataRate LinkCapacityEstimator::LowerBound() const { DataRate LinkCapacityEstimator::LowerBound() const {
if (estimate_kbps_.has_value()) if (estimate_kbps_.has_value())
return DataRate::kbps( return DataRate::KilobitsPerSec(
std::max(0.0, estimate_kbps_.value() - 3 * deviation_estimate_kbps())); std::max(0.0, estimate_kbps_.value() - 3 * deviation_estimate_kbps()));
return DataRate::Zero(); return DataRate::Zero();
} }
@ -65,7 +65,7 @@ bool LinkCapacityEstimator::has_estimate() const {
} }
DataRate LinkCapacityEstimator::estimate() const { DataRate LinkCapacityEstimator::estimate() const {
return DataRate::kbps(*estimate_kbps_); return DataRate::KilobitsPerSec(*estimate_kbps_);
} }
double LinkCapacityEstimator::deviation_estimate_kbps() const { double LinkCapacityEstimator::deviation_estimate_kbps() const {

View File

@ -83,9 +83,11 @@ LossBasedControlConfig::LossBasedControlConfig()
loss_window("loss_win", TimeDelta::Millis(800)), loss_window("loss_win", TimeDelta::Millis(800)),
loss_max_window("loss_max_win", TimeDelta::Millis(800)), loss_max_window("loss_max_win", TimeDelta::Millis(800)),
acknowledged_rate_max_window("ackrate_max_win", TimeDelta::Millis(800)), acknowledged_rate_max_window("ackrate_max_win", TimeDelta::Millis(800)),
increase_offset("incr_offset", DataRate::bps(1000)), increase_offset("incr_offset", DataRate::BitsPerSec(1000)),
loss_bandwidth_balance_increase("balance_incr", DataRate::kbps(0.5)), loss_bandwidth_balance_increase("balance_incr",
loss_bandwidth_balance_decrease("balance_decr", DataRate::kbps(4)), DataRate::KilobitsPerSec(0.5)),
loss_bandwidth_balance_decrease("balance_decr",
DataRate::KilobitsPerSec(4)),
loss_bandwidth_balance_exponent("exponent", 0.5), loss_bandwidth_balance_exponent("exponent", 0.5),
allow_resets("resets", false), allow_resets("resets", false),
decrease_interval("decr_intvl", TimeDelta::Millis(300)), decrease_interval("decr_intvl", TimeDelta::Millis(300)),

View File

@ -94,7 +94,7 @@ absl::optional<DataRate> ProbeBitrateEstimator::HandleProbeAndEstimateBitrate(
packet_feedback.sent_packet.pacing_info.probe_cluster_min_probes * packet_feedback.sent_packet.pacing_info.probe_cluster_min_probes *
kMinReceivedProbesRatio; kMinReceivedProbesRatio;
DataSize min_size = DataSize min_size =
DataSize::bytes( DataSize::Bytes(
packet_feedback.sent_packet.pacing_info.probe_cluster_min_bytes) * packet_feedback.sent_packet.pacing_info.probe_cluster_min_bytes) *
kMinReceivedBytesRatio; kMinReceivedBytesRatio;
if (cluster->num_probes < min_probes || cluster->size_total < min_size) if (cluster->num_probes < min_probes || cluster->size_total < min_size)

View File

@ -39,7 +39,7 @@ class TestProbeBitrateEstimator : public ::testing::Test {
PacketResult feedback; PacketResult feedback;
feedback.sent_packet.send_time = feedback.sent_packet.send_time =
kReferenceTime + TimeDelta::Millis(send_time_ms); kReferenceTime + TimeDelta::Millis(send_time_ms);
feedback.sent_packet.size = DataSize::bytes(size_bytes); feedback.sent_packet.size = DataSize::Bytes(size_bytes);
feedback.sent_packet.pacing_info = feedback.sent_packet.pacing_info =
PacedPacketInfo(probe_cluster_id, min_probes, min_bytes); PacedPacketInfo(probe_cluster_id, min_probes, min_bytes);
feedback.receive_time = kReferenceTime + TimeDelta::Millis(arrival_time_ms); feedback.receive_time = kReferenceTime + TimeDelta::Millis(arrival_time_ms);

View File

@ -209,14 +209,15 @@ std::vector<ProbeClusterConfig> ProbeController::OnMaxTotalAllocatedBitrate(
if (!config_.first_allocation_probe_scale) if (!config_.first_allocation_probe_scale)
return std::vector<ProbeClusterConfig>(); return std::vector<ProbeClusterConfig>();
DataRate first_probe_rate = DataRate::bps(max_total_allocated_bitrate) * DataRate first_probe_rate =
DataRate::BitsPerSec(max_total_allocated_bitrate) *
config_.first_allocation_probe_scale.Value(); config_.first_allocation_probe_scale.Value();
DataRate probe_cap = config_.allocation_probe_max.Get(); DataRate probe_cap = config_.allocation_probe_max.Get();
first_probe_rate = std::min(first_probe_rate, probe_cap); first_probe_rate = std::min(first_probe_rate, probe_cap);
std::vector<int64_t> probes = {first_probe_rate.bps()}; std::vector<int64_t> probes = {first_probe_rate.bps()};
if (config_.second_allocation_probe_scale) { if (config_.second_allocation_probe_scale) {
DataRate second_probe_rate = DataRate second_probe_rate =
DataRate::bps(max_total_allocated_bitrate) * DataRate::BitsPerSec(max_total_allocated_bitrate) *
config_.second_allocation_probe_scale.Value(); config_.second_allocation_probe_scale.Value();
second_probe_rate = std::min(second_probe_rate, probe_cap); second_probe_rate = std::min(second_probe_rate, probe_cap);
if (second_probe_rate > first_probe_rate) if (second_probe_rate > first_probe_rate)
@ -425,7 +426,8 @@ std::vector<ProbeClusterConfig> ProbeController::InitiateProbing(
ProbeClusterConfig config; ProbeClusterConfig config;
config.at_time = Timestamp::Millis(now_ms); config.at_time = Timestamp::Millis(now_ms);
config.target_data_rate = DataRate::bps(rtc::dchecked_cast<int>(bitrate)); config.target_data_rate =
DataRate::BitsPerSec(rtc::dchecked_cast<int>(bitrate));
config.target_duration = TimeDelta::Millis(kMinProbeDurationMs); config.target_duration = TimeDelta::Millis(kMinProbeDurationMs);
config.target_probe_count = kMinProbePacketsSent; config.target_probe_count = kMinProbePacketsSent;
config.id = next_probe_cluster_id_; config.id = next_probe_cluster_id_;

View File

@ -73,7 +73,7 @@ absl::optional<DataRate> RobustThroughputEstimator::bitrate() const {
Timestamp max_send_time = window_[0].sent_packet.send_time; Timestamp max_send_time = window_[0].sent_packet.send_time;
Timestamp min_recv_time = window_[0].receive_time; Timestamp min_recv_time = window_[0].receive_time;
Timestamp max_recv_time = window_[0].receive_time; Timestamp max_recv_time = window_[0].receive_time;
DataSize data_size = DataSize::bytes(0); DataSize data_size = DataSize::Bytes(0);
for (const auto& packet : window_) { for (const auto& packet : window_) {
min_send_time = std::min(min_send_time, packet.sent_packet.send_time); min_send_time = std::min(min_send_time, packet.sent_packet.send_time);
max_send_time = std::max(max_send_time, packet.sent_packet.send_time); max_send_time = std::max(max_send_time, packet.sent_packet.send_time);

View File

@ -45,7 +45,7 @@ TEST(RobustThroughputEstimatorTest, SteadyRate) {
FieldTrialBasedConfig field_trial_config; FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config); RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings); RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000)); DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000)); Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000)); Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10)); TimeDelta send_increment(TimeDelta::Millis(10));
@ -75,7 +75,7 @@ TEST(RobustThroughputEstimatorTest, DelaySpike) {
FieldTrialBasedConfig field_trial_config; FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config); RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings); RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000)); DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000)); Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000)); Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10)); TimeDelta send_increment(TimeDelta::Millis(10));
@ -124,7 +124,7 @@ TEST(RobustThroughputEstimatorTest, CappedByReceiveRate) {
FieldTrialBasedConfig field_trial_config; FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config); RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings); RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000)); DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000)); Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000)); Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10)); TimeDelta send_increment(TimeDelta::Millis(10));
@ -148,7 +148,7 @@ TEST(RobustThroughputEstimatorTest, CappedBySendRate) {
FieldTrialBasedConfig field_trial_config; FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config); RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings); RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000)); DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000)); Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000)); Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(20)); TimeDelta send_increment(TimeDelta::Millis(20));

View File

@ -32,7 +32,7 @@ constexpr TimeDelta kBweDecreaseInterval = TimeDelta::Millis(300);
constexpr TimeDelta kStartPhase = TimeDelta::Millis(2000); constexpr TimeDelta kStartPhase = TimeDelta::Millis(2000);
constexpr TimeDelta kBweConverganceTime = TimeDelta::Millis(20000); constexpr TimeDelta kBweConverganceTime = TimeDelta::Millis(20000);
constexpr int kLimitNumPackets = 20; constexpr int kLimitNumPackets = 20;
constexpr DataRate kDefaultMaxBitrate = DataRate::BitsPerSec<1000000000>(); constexpr DataRate kDefaultMaxBitrate = DataRate::BitsPerSec(1000000000);
constexpr TimeDelta kLowBitrateLogPeriod = TimeDelta::Millis(10000); constexpr TimeDelta kLowBitrateLogPeriod = TimeDelta::Millis(10000);
constexpr TimeDelta kRtcEventLogPeriod = TimeDelta::Millis(5000); constexpr TimeDelta kRtcEventLogPeriod = TimeDelta::Millis(5000);
// Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals. // Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals.
@ -149,14 +149,14 @@ void LinkCapacityTracker::OnRttBackoff(DataRate backoff_rate,
} }
DataRate LinkCapacityTracker::estimate() const { DataRate LinkCapacityTracker::estimate() const {
return DataRate::bps(capacity_estimate_bps_); return DataRate::BitsPerSec(capacity_estimate_bps_);
} }
RttBasedBackoff::RttBasedBackoff() RttBasedBackoff::RttBasedBackoff()
: rtt_limit_("limit", TimeDelta::Seconds(3)), : rtt_limit_("limit", TimeDelta::Seconds(3)),
drop_fraction_("fraction", 0.8), drop_fraction_("fraction", 0.8),
drop_interval_("interval", TimeDelta::Seconds(1)), drop_interval_("interval", TimeDelta::Seconds(1)),
bandwidth_floor_("floor", DataRate::kbps(5)), bandwidth_floor_("floor", DataRate::KilobitsPerSec(5)),
// By initializing this to plus infinity, we make sure that we never // By initializing this to plus infinity, we make sure that we never
// trigger rtt backoff unless packet feedback is enabled. // trigger rtt backoff unless packet feedback is enabled.
last_propagation_rtt_update_(Timestamp::PlusInfinity()), last_propagation_rtt_update_(Timestamp::PlusInfinity()),
@ -191,7 +191,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
current_target_(DataRate::Zero()), current_target_(DataRate::Zero()),
last_logged_target_(DataRate::Zero()), last_logged_target_(DataRate::Zero()),
min_bitrate_configured_( min_bitrate_configured_(
DataRate::bps(congestion_controller::GetMinBitrateBps())), DataRate::BitsPerSec(congestion_controller::GetMinBitrateBps())),
max_bitrate_configured_(kDefaultMaxBitrate), max_bitrate_configured_(kDefaultMaxBitrate),
last_low_bitrate_log_(Timestamp::MinusInfinity()), last_low_bitrate_log_(Timestamp::MinusInfinity()),
has_decreased_since_last_fraction_loss_(false), has_decreased_since_last_fraction_loss_(false),
@ -223,7 +223,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
RTC_LOG(LS_INFO) << "Enabled BweLossExperiment with parameters " RTC_LOG(LS_INFO) << "Enabled BweLossExperiment with parameters "
<< low_loss_threshold_ << ", " << high_loss_threshold_ << low_loss_threshold_ << ", " << high_loss_threshold_
<< ", " << bitrate_threshold_kbps; << ", " << bitrate_threshold_kbps;
bitrate_threshold_ = DataRate::kbps(bitrate_threshold_kbps); bitrate_threshold_ = DataRate::KilobitsPerSec(bitrate_threshold_kbps);
} }
} }
} }
@ -235,7 +235,7 @@ void SendSideBandwidthEstimation::OnRouteChange() {
expected_packets_since_last_loss_update_ = 0; expected_packets_since_last_loss_update_ = 0;
current_target_ = DataRate::Zero(); current_target_ = DataRate::Zero();
min_bitrate_configured_ = min_bitrate_configured_ =
DataRate::bps(congestion_controller::GetMinBitrateBps()); DataRate::BitsPerSec(congestion_controller::GetMinBitrateBps());
max_bitrate_configured_ = kDefaultMaxBitrate; max_bitrate_configured_ = kDefaultMaxBitrate;
last_low_bitrate_log_ = Timestamp::MinusInfinity(); last_low_bitrate_log_ = Timestamp::MinusInfinity();
has_decreased_since_last_fraction_loss_ = false; has_decreased_since_last_fraction_loss_ = false;
@ -373,7 +373,8 @@ void SendSideBandwidthEstimation::UpdatePacketsLost(int packets_lost,
void SendSideBandwidthEstimation::UpdateUmaStatsPacketsLost(Timestamp at_time, void SendSideBandwidthEstimation::UpdateUmaStatsPacketsLost(Timestamp at_time,
int packets_lost) { int packets_lost) {
DataRate bitrate_kbps = DataRate::kbps((current_target_.bps() + 500) / 1000); DataRate bitrate_kbps =
DataRate::KilobitsPerSec((current_target_.bps() + 500) / 1000);
for (size_t i = 0; i < kNumUmaRampupMetrics; ++i) { for (size_t i = 0; i < kNumUmaRampupMetrics; ++i) {
if (!rampup_uma_stats_updated_[i] && if (!rampup_uma_stats_updated_[i] &&
bitrate_kbps.kbps() >= kUmaRampupMetrics[i].bitrate_kbps) { bitrate_kbps.kbps() >= kUmaRampupMetrics[i].bitrate_kbps) {
@ -490,13 +491,13 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
// If instead one would do: current_bitrate_ *= 1.08^(delta time), // If instead one would do: current_bitrate_ *= 1.08^(delta time),
// it would take over one second since the lower packet loss to achieve // it would take over one second since the lower packet loss to achieve
// 108kbps. // 108kbps.
DataRate new_bitrate = DataRate new_bitrate = DataRate::BitsPerSec(
DataRate::bps(min_bitrate_history_.front().second.bps() * 1.08 + 0.5); min_bitrate_history_.front().second.bps() * 1.08 + 0.5);
// Add 1 kbps extra, just to make sure that we do not get stuck // Add 1 kbps extra, just to make sure that we do not get stuck
// (gives a little extra increase at low rates, negligible at higher // (gives a little extra increase at low rates, negligible at higher
// rates). // rates).
new_bitrate += DataRate::bps(1000); new_bitrate += DataRate::BitsPerSec(1000);
UpdateTargetBitrate(new_bitrate, at_time); UpdateTargetBitrate(new_bitrate, at_time);
return; return;
} else if (current_target_ > bitrate_threshold_) { } else if (current_target_ > bitrate_threshold_) {
@ -513,8 +514,8 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
// Reduce rate: // Reduce rate:
// newRate = rate * (1 - 0.5*lossRate); // newRate = rate * (1 - 0.5*lossRate);
// where packetLoss = 256*lossRate; // where packetLoss = 256*lossRate;
DataRate new_bitrate = DataRate new_bitrate = DataRate::BitsPerSec(
DataRate::bps((current_target_.bps() * (current_target_.bps() *
static_cast<double>(512 - last_fraction_loss_)) / static_cast<double>(512 - last_fraction_loss_)) /
512.0); 512.0);
has_decreased_since_last_fraction_loss_ = true; has_decreased_since_last_fraction_loss_ = true;
@ -572,7 +573,7 @@ DataRate SendSideBandwidthEstimation::MaybeRampupOrBackoff(DataRate new_bitrate,
at_time - last_loss_packet_report_; at_time - last_loss_packet_report_;
if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) { if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) {
new_bitrate = min_bitrate_history_.front().second * 1.08; new_bitrate = min_bitrate_history_.front().second * 1.08;
new_bitrate += DataRate::bps(1000); new_bitrate += DataRate::BitsPerSec(1000);
} }
return new_bitrate; return new_bitrate;
} }

View File

@ -38,8 +38,9 @@ void TestProbing(bool use_delay_based) {
::testing::NiceMock<MockRtcEventLog> event_log; ::testing::NiceMock<MockRtcEventLog> event_log;
SendSideBandwidthEstimation bwe(&event_log); SendSideBandwidthEstimation bwe(&event_log);
int64_t now_ms = 0; int64_t now_ms = 0;
bwe.SetMinMaxBitrate(DataRate::bps(100000), DataRate::bps(1500000)); bwe.SetMinMaxBitrate(DataRate::BitsPerSec(100000),
bwe.SetSendBitrate(DataRate::bps(200000), Timestamp::Millis(now_ms)); DataRate::BitsPerSec(1500000));
bwe.SetSendBitrate(DataRate::BitsPerSec(200000), Timestamp::Millis(now_ms));
const int kRembBps = 1000000; const int kRembBps = 1000000;
const int kSecondRembBps = kRembBps + 500000; const int kSecondRembBps = kRembBps + 500000;
@ -51,10 +52,10 @@ void TestProbing(bool use_delay_based) {
// Initial REMB applies immediately. // Initial REMB applies immediately.
if (use_delay_based) { if (use_delay_based) {
bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms),
DataRate::bps(kRembBps)); DataRate::BitsPerSec(kRembBps));
} else { } else {
bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms), bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms),
DataRate::bps(kRembBps)); DataRate::BitsPerSec(kRembBps));
} }
bwe.UpdateEstimate(Timestamp::Millis(now_ms)); bwe.UpdateEstimate(Timestamp::Millis(now_ms));
EXPECT_EQ(kRembBps, bwe.target_rate().bps()); EXPECT_EQ(kRembBps, bwe.target_rate().bps());
@ -63,10 +64,10 @@ void TestProbing(bool use_delay_based) {
now_ms += 2001; now_ms += 2001;
if (use_delay_based) { if (use_delay_based) {
bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms),
DataRate::bps(kSecondRembBps)); DataRate::BitsPerSec(kSecondRembBps));
} else { } else {
bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms), bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms),
DataRate::bps(kSecondRembBps)); DataRate::BitsPerSec(kSecondRembBps));
} }
bwe.UpdateEstimate(Timestamp::Millis(now_ms)); bwe.UpdateEstimate(Timestamp::Millis(now_ms));
EXPECT_EQ(kRembBps, bwe.target_rate().bps()); EXPECT_EQ(kRembBps, bwe.target_rate().bps());
@ -91,8 +92,9 @@ TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) {
static const int kMinBitrateBps = 100000; static const int kMinBitrateBps = 100000;
static const int kInitialBitrateBps = 1000000; static const int kInitialBitrateBps = 1000000;
int64_t now_ms = 1000; int64_t now_ms = 1000;
bwe.SetMinMaxBitrate(DataRate::bps(kMinBitrateBps), DataRate::bps(1500000)); bwe.SetMinMaxBitrate(DataRate::BitsPerSec(kMinBitrateBps),
bwe.SetSendBitrate(DataRate::bps(kInitialBitrateBps), DataRate::BitsPerSec(1500000));
bwe.SetSendBitrate(DataRate::BitsPerSec(kInitialBitrateBps),
Timestamp::Millis(now_ms)); Timestamp::Millis(now_ms));
static const uint8_t kFractionLoss = 128; static const uint8_t kFractionLoss = 128;
@ -145,18 +147,18 @@ TEST(SendSideBweTest, SettingSendBitrateOverridesDelayBasedEstimate) {
int64_t now_ms = 0; int64_t now_ms = 0;
bwe.SetMinMaxBitrate(DataRate::bps(kMinBitrateBps), bwe.SetMinMaxBitrate(DataRate::BitsPerSec(kMinBitrateBps),
DataRate::bps(kMaxBitrateBps)); DataRate::BitsPerSec(kMaxBitrateBps));
bwe.SetSendBitrate(DataRate::bps(kInitialBitrateBps), bwe.SetSendBitrate(DataRate::BitsPerSec(kInitialBitrateBps),
Timestamp::Millis(now_ms)); Timestamp::Millis(now_ms));
bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms),
DataRate::bps(kDelayBasedBitrateBps)); DataRate::BitsPerSec(kDelayBasedBitrateBps));
bwe.UpdateEstimate(Timestamp::Millis(now_ms)); bwe.UpdateEstimate(Timestamp::Millis(now_ms));
EXPECT_GE(bwe.target_rate().bps(), kInitialBitrateBps); EXPECT_GE(bwe.target_rate().bps(), kInitialBitrateBps);
EXPECT_LE(bwe.target_rate().bps(), kDelayBasedBitrateBps); EXPECT_LE(bwe.target_rate().bps(), kDelayBasedBitrateBps);
bwe.SetSendBitrate(DataRate::bps(kForcedHighBitrate), bwe.SetSendBitrate(DataRate::BitsPerSec(kForcedHighBitrate),
Timestamp::Millis(now_ms)); Timestamp::Millis(now_ms));
EXPECT_EQ(bwe.target_rate().bps(), kForcedHighBitrate); EXPECT_EQ(bwe.target_rate().bps(), kForcedHighBitrate);
} }

View File

@ -70,7 +70,7 @@ GoogCcStatePrinter::GoogCcStatePrinter() {
std::deque<FieldLogger*> GoogCcStatePrinter::CreateLoggers() { std::deque<FieldLogger*> GoogCcStatePrinter::CreateLoggers() {
auto stable_estimate = [this] { auto stable_estimate = [this] {
return DataRate::kbps( return DataRate::KilobitsPerSec(
controller_->delay_based_bwe_->rate_control_.link_capacity_ controller_->delay_based_bwe_->rate_control_.link_capacity_
.estimate_kbps_.value_or(-INFINITY)); .estimate_kbps_.value_or(-INFINITY));
}; };

View File

@ -131,7 +131,7 @@ DataRate PccBitrateController::ComputeRateUpdateForOnlineLearningMode(
double rate_change_bps = gradient * ComputeStepSize(gradient); // delta_r double rate_change_bps = gradient * ComputeStepSize(gradient); // delta_r
rate_change_bps = rate_change_bps =
ApplyDynamicBoundary(rate_change_bps, bandwith_estimate.bps()); ApplyDynamicBoundary(rate_change_bps, bandwith_estimate.bps());
return DataRate::bps( return DataRate::BitsPerSec(
std::max(0.0, bandwith_estimate.bps() + rate_change_bps)); std::max(0.0, bandwith_estimate.bps() + rate_change_bps));
} }

View File

@ -32,13 +32,13 @@ constexpr double kThroughputPower = 0.99;
constexpr double kDelayGradientThreshold = 0.01; constexpr double kDelayGradientThreshold = 0.01;
constexpr double kDelayGradientNegativeBound = 10; constexpr double kDelayGradientNegativeBound = 10;
const DataRate kTargetSendingRate = DataRate::kbps(300); const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300);
const double kEpsilon = 0.05; const double kEpsilon = 0.05;
const Timestamp kStartTime = Timestamp::Micros(0); const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1); const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = TimeDelta::Millis(1000); const TimeDelta kIntervalDuration = TimeDelta::Millis(1000);
const TimeDelta kDefaultRtt = TimeDelta::Millis(1000); const TimeDelta kDefaultRtt = TimeDelta::Millis(1000);
const DataSize kDefaultDataSize = DataSize::bytes(100); const DataSize kDefaultDataSize = DataSize::Bytes(100);
std::vector<PacketResult> CreatePacketResults( std::vector<PacketResult> CreatePacketResults(
const std::vector<Timestamp>& packets_send_times, const std::vector<Timestamp>& packets_send_times,

View File

@ -18,12 +18,12 @@ namespace webrtc {
namespace pcc { namespace pcc {
namespace test { namespace test {
namespace { namespace {
const DataRate kTargetSendingRate = DataRate::kbps(300); const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300);
const Timestamp kStartTime = Timestamp::Micros(0); const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1); const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = TimeDelta::Millis(100); const TimeDelta kIntervalDuration = TimeDelta::Millis(100);
const TimeDelta kDefaultDelay = TimeDelta::Millis(100); const TimeDelta kDefaultDelay = TimeDelta::Millis(100);
const DataSize kDefaultPacketSize = DataSize::bytes(100); const DataSize kDefaultPacketSize = DataSize::Bytes(100);
constexpr double kDelayGradientThreshold = 0.01; constexpr double kDelayGradientThreshold = 0.01;
std::vector<PacketResult> CreatePacketResults( std::vector<PacketResult> CreatePacketResults(

View File

@ -57,7 +57,7 @@ PccNetworkController::PccNetworkController(NetworkControllerConfig config)
last_sent_packet_time_(Timestamp::PlusInfinity()), last_sent_packet_time_(Timestamp::PlusInfinity()),
smoothed_packets_sending_interval_(TimeDelta::Zero()), smoothed_packets_sending_interval_(TimeDelta::Zero()),
mode_(Mode::kStartup), mode_(Mode::kStartup),
default_bandwidth_(DataRate::kbps(kInitialBandwidthKbps)), default_bandwidth_(DataRate::KilobitsPerSec(kInitialBandwidthKbps)),
bandwidth_estimate_(default_bandwidth_), bandwidth_estimate_(default_bandwidth_),
rtt_tracker_(TimeDelta::Millis(kInitialRttMs), kAlphaForRtt), rtt_tracker_(TimeDelta::Millis(kInitialRttMs), kAlphaForRtt),
monitor_interval_timeout_(TimeDelta::Millis(kInitialRttMs) * monitor_interval_timeout_(TimeDelta::Millis(kInitialRttMs) *
@ -216,9 +216,9 @@ NetworkControlUpdate PccNetworkController::OnSentPacket(SentPacket msg) {
bandwidth_estimate_ * (1 - sign * sampling_step_)}; bandwidth_estimate_ * (1 - sign * sampling_step_)};
} else { } else {
monitor_intervals_bitrates_ = { monitor_intervals_bitrates_ = {
DataRate::bps(std::max<double>( DataRate::BitsPerSec(std::max<double>(
bandwidth_estimate_.bps() + sign * kMinRateChangeBps, 0)), bandwidth_estimate_.bps() + sign * kMinRateChangeBps, 0)),
DataRate::bps(std::max<double>( DataRate::BitsPerSec(std::max<double>(
bandwidth_estimate_.bps() - sign * kMinRateChangeBps, 0))}; bandwidth_estimate_.bps() - sign * kMinRateChangeBps, 0))};
} }
monitor_intervals_.emplace_back(monitor_intervals_bitrates_[0], monitor_intervals_.emplace_back(monitor_intervals_bitrates_[0],

View File

@ -28,7 +28,7 @@ namespace webrtc {
namespace test { namespace test {
namespace { namespace {
const DataRate kInitialBitrate = DataRate::kbps(60); const DataRate kInitialBitrate = DataRate::KilobitsPerSec(60);
const Timestamp kDefaultStartTime = Timestamp::Millis(10000000); const Timestamp kDefaultStartTime = Timestamp::Millis(10000000);
constexpr double kDataRateMargin = 0.20; constexpr double kDataRateMargin = 0.20;
@ -47,9 +47,12 @@ NetworkControllerConfig InitialConfig(
int max_data_rate_kbps = 5 * kInitialBitrate.kbps()) { int max_data_rate_kbps = 5 * kInitialBitrate.kbps()) {
NetworkControllerConfig config; NetworkControllerConfig config;
config.constraints.at_time = kDefaultStartTime; config.constraints.at_time = kDefaultStartTime;
config.constraints.min_data_rate = DataRate::kbps(min_data_rate_kbps); config.constraints.min_data_rate =
config.constraints.max_data_rate = DataRate::kbps(max_data_rate_kbps); DataRate::KilobitsPerSec(min_data_rate_kbps);
config.constraints.starting_rate = DataRate::kbps(starting_bandwidth_kbps); config.constraints.max_data_rate =
DataRate::KilobitsPerSec(max_data_rate_kbps);
config.constraints.starting_rate =
DataRate::KilobitsPerSec(starting_bandwidth_kbps);
return config; return config;
} }
@ -77,11 +80,11 @@ TEST(PccNetworkControllerTest, UpdatesTargetSendRate) {
Scenario s("pcc_unit/updates_rate", false); Scenario s("pcc_unit/updates_rate", false);
CallClientConfig config; CallClientConfig config;
config.transport.cc_factory = &factory; config.transport.cc_factory = &factory;
config.transport.rates.min_rate = DataRate::kbps(10); config.transport.rates.min_rate = DataRate::KilobitsPerSec(10);
config.transport.rates.max_rate = DataRate::kbps(1500); config.transport.rates.max_rate = DataRate::KilobitsPerSec(1500);
config.transport.rates.start_rate = DataRate::kbps(300); config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) { auto send_net = s.CreateMutableSimulationNode([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(500); c->bandwidth = DataRate::KilobitsPerSec(500);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
auto ret_net = s.CreateMutableSimulationNode( auto ret_net = s.CreateMutableSimulationNode(
@ -97,13 +100,13 @@ TEST(PccNetworkControllerTest, UpdatesTargetSendRate) {
s.RunFor(TimeDelta::Seconds(30)); s.RunFor(TimeDelta::Seconds(30));
EXPECT_NEAR(client->target_rate().kbps(), 450, 100); EXPECT_NEAR(client->target_rate().kbps(), 450, 100);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(800); c->bandwidth = DataRate::KilobitsPerSec(800);
c->delay = TimeDelta::Millis(100); c->delay = TimeDelta::Millis(100);
}); });
s.RunFor(TimeDelta::Seconds(20)); s.RunFor(TimeDelta::Seconds(20));
EXPECT_NEAR(client->target_rate().kbps(), 750, 150); EXPECT_NEAR(client->target_rate().kbps(), 750, 150);
send_net->UpdateConfig([](NetworkSimulationConfig* c) { send_net->UpdateConfig([](NetworkSimulationConfig* c) {
c->bandwidth = DataRate::kbps(200); c->bandwidth = DataRate::KilobitsPerSec(200);
c->delay = TimeDelta::Millis(200); c->delay = TimeDelta::Millis(200);
}); });
ret_net->UpdateConfig( ret_net->UpdateConfig(

View File

@ -35,9 +35,9 @@ constexpr double kDelayGradientNegativeBound = 10;
const Timestamp kStartTime = Timestamp::Micros(0); const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1); const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = TimeDelta::Millis(100); const TimeDelta kIntervalDuration = TimeDelta::Millis(100);
const DataRate kSendingBitrate = DataRate::bps(1000); const DataRate kSendingBitrate = DataRate::BitsPerSec(1000);
const DataSize kDefaultDataSize = DataSize::bytes(100); const DataSize kDefaultDataSize = DataSize::Bytes(100);
const TimeDelta kDefaultDelay = TimeDelta::Millis(100); const TimeDelta kDefaultDelay = TimeDelta::Millis(100);
std::vector<PacketResult> CreatePacketResults( std::vector<PacketResult> CreatePacketResults(

View File

@ -76,10 +76,10 @@ TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) {
TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) { TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) {
Scenario s("recieve_cc_unit/converge"); Scenario s("recieve_cc_unit/converge");
NetworkSimulationConfig net_conf; NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000); net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(50); net_conf.delay = TimeDelta::Millis(50);
auto* client = s.CreateClient("send", [&](CallClientConfig* c) { auto* client = s.CreateClient("send", [&](CallClientConfig* c) {
c->transport.rates.start_rate = DataRate::kbps(300); c->transport.rates.start_rate = DataRate::KilobitsPerSec(300);
}); });
auto* route = s.CreateRoutes(client, {s.CreateSimulationNode(net_conf)}, auto* route = s.CreateRoutes(client, {s.CreateSimulationNode(net_conf)},
@ -95,10 +95,10 @@ TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) {
TEST(ReceiveSideCongestionControllerTest, IsFairToTCP) { TEST(ReceiveSideCongestionControllerTest, IsFairToTCP) {
Scenario s("recieve_cc_unit/tcp_fairness"); Scenario s("recieve_cc_unit/tcp_fairness");
NetworkSimulationConfig net_conf; NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000); net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(50); net_conf.delay = TimeDelta::Millis(50);
auto* client = s.CreateClient("send", [&](CallClientConfig* c) { auto* client = s.CreateClient("send", [&](CallClientConfig* c) {
c->transport.rates.start_rate = DataRate::kbps(1000); c->transport.rates.start_rate = DataRate::KilobitsPerSec(1000);
}); });
auto send_net = {s.CreateSimulationNode(net_conf)}; auto send_net = {s.CreateSimulationNode(net_conf)};
auto ret_net = {s.CreateSimulationNode(net_conf)}; auto ret_net = {s.CreateSimulationNode(net_conf)};

View File

@ -74,7 +74,7 @@ void TransportFeedbackAdapter::AddPacket(const RtpPacketSendInfo& packet_info,
packet.creation_time = creation_time; packet.creation_time = creation_time;
packet.sent.sequence_number = packet.sent.sequence_number =
seq_num_unwrapper_.Unwrap(packet_info.transport_sequence_number); seq_num_unwrapper_.Unwrap(packet_info.transport_sequence_number);
packet.sent.size = DataSize::bytes(packet_info.length + overhead_bytes); packet.sent.size = DataSize::Bytes(packet_info.length + overhead_bytes);
packet.local_net_id = local_net_id_; packet.local_net_id = local_net_id_;
packet.remote_net_id = remote_net_id_; packet.remote_net_id = remote_net_id_;
packet.sent.pacing_info = packet_info.pacing_info; packet.sent.pacing_info = packet_info.pacing_info;
@ -122,7 +122,7 @@ absl::optional<SentPacket> TransportFeedbackAdapter::ProcessSentPacket(
RTC_LOG(LS_WARNING) << "ignoring untracked data for out of order packet."; RTC_LOG(LS_WARNING) << "ignoring untracked data for out of order packet.";
} }
pending_untracked_size_ += pending_untracked_size_ +=
DataSize::bytes(sent_packet.info.packet_size_bytes); DataSize::Bytes(sent_packet.info.packet_size_bytes);
last_untracked_send_time_ = std::max(last_untracked_send_time_, send_time); last_untracked_send_time_ = std::max(last_untracked_send_time_, send_time);
} }
return absl::nullopt; return absl::nullopt;

View File

@ -72,7 +72,7 @@ PacketResult CreatePacket(int64_t receive_time_ms,
res.receive_time = Timestamp::Millis(receive_time_ms); res.receive_time = Timestamp::Millis(receive_time_ms);
res.sent_packet.send_time = Timestamp::Millis(send_time_ms); res.sent_packet.send_time = Timestamp::Millis(send_time_ms);
res.sent_packet.sequence_number = sequence_number; res.sent_packet.sequence_number = sequence_number;
res.sent_packet.size = DataSize::bytes(payload_size); res.sent_packet.size = DataSize::Bytes(payload_size);
res.sent_packet.pacing_info = pacing_info; res.sent_packet.pacing_info = pacing_info;
return res; return res;
} }
@ -309,7 +309,7 @@ TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) {
packet_feedback.sent_packet.sequence_number = 1; packet_feedback.sent_packet.sequence_number = 1;
packet_feedback.sent_packet.send_time = Timestamp::Millis(100); packet_feedback.sent_packet.send_time = Timestamp::Millis(100);
packet_feedback.receive_time = Timestamp::Millis(200); packet_feedback.receive_time = Timestamp::Millis(200);
packet_feedback.sent_packet.size = DataSize::bytes(1500); packet_feedback.sent_packet.size = DataSize::Bytes(1500);
sent_packets.push_back(packet_feedback); sent_packets.push_back(packet_feedback);
// TODO(srte): This rounding maintains previous behavior, but should ot be // TODO(srte): This rounding maintains previous behavior, but should ot be

View File

@ -194,8 +194,9 @@ Timestamp BitrateProber::CalculateNextProbeTime(
// Compute the time delta from the cluster start to ensure probe bitrate stays // Compute the time delta from the cluster start to ensure probe bitrate stays
// close to the target bitrate. Result is in milliseconds. // close to the target bitrate. Result is in milliseconds.
DataSize sent_bytes = DataSize::bytes(cluster.sent_bytes); DataSize sent_bytes = DataSize::Bytes(cluster.sent_bytes);
DataRate send_bitrate = DataRate::bps(cluster.pace_info.send_bitrate_bps); DataRate send_bitrate =
DataRate::BitsPerSec(cluster.pace_info.send_bitrate_bps);
TimeDelta delta = sent_bytes / send_bitrate; TimeDelta delta = sent_bytes / send_bitrate;
return cluster.started_at + delta; return cluster.started_at + delta;
} }

View File

@ -25,8 +25,8 @@ TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
const Timestamp start_time = now; const Timestamp start_time = now;
EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity()); EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity());
const DataRate kTestBitrate1 = DataRate::kbps(900); const DataRate kTestBitrate1 = DataRate::KilobitsPerSec(900);
const DataRate kTestBitrate2 = DataRate::kbps(1800); const DataRate kTestBitrate2 = DataRate::KilobitsPerSec(1800);
const int kClusterSize = 5; const int kClusterSize = 5;
const int kProbeSize = 1000; const int kProbeSize = 1000;
const TimeDelta kMinProbeDuration = TimeDelta::Millis(15); const TimeDelta kMinProbeDuration = TimeDelta::Millis(15);
@ -52,7 +52,7 @@ TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
EXPECT_GE(now - start_time, kMinProbeDuration); EXPECT_GE(now - start_time, kMinProbeDuration);
// Verify that the actual bitrate is withing 10% of the target. // Verify that the actual bitrate is withing 10% of the target.
DataRate bitrate = DataRate bitrate =
DataSize::bytes(kProbeSize * (kClusterSize - 1)) / (now - start_time); DataSize::Bytes(kProbeSize * (kClusterSize - 1)) / (now - start_time);
EXPECT_GT(bitrate, kTestBitrate1 * 0.9); EXPECT_GT(bitrate, kTestBitrate1 * 0.9);
EXPECT_LT(bitrate, kTestBitrate1 * 1.1); EXPECT_LT(bitrate, kTestBitrate1 * 1.1);
@ -69,7 +69,7 @@ TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
// Verify that the actual bitrate is withing 10% of the target. // Verify that the actual bitrate is withing 10% of the target.
TimeDelta duration = now - probe2_started; TimeDelta duration = now - probe2_started;
EXPECT_GE(duration, kMinProbeDuration); EXPECT_GE(duration, kMinProbeDuration);
bitrate = DataSize::bytes(kProbeSize * (kClusterSize - 1)) / duration; bitrate = DataSize::Bytes(kProbeSize * (kClusterSize - 1)) / duration;
EXPECT_GT(bitrate, kTestBitrate2 * 0.9); EXPECT_GT(bitrate, kTestBitrate2 * 0.9);
EXPECT_LT(bitrate, kTestBitrate2 * 1.1); EXPECT_LT(bitrate, kTestBitrate2 * 1.1);
@ -84,7 +84,7 @@ TEST(BitrateProberTest, DoesntProbeWithoutRecentPackets) {
Timestamp now = Timestamp::Zero(); Timestamp now = Timestamp::Zero();
EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity()); EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity());
prober.CreateProbeCluster(DataRate::kbps(900), now, 0); prober.CreateProbeCluster(DataRate::KilobitsPerSec(900), now, 0);
EXPECT_FALSE(prober.IsProbing()); EXPECT_FALSE(prober.IsProbing());
prober.OnIncomingPacket(1000); prober.OnIncomingPacket(1000);
@ -115,7 +115,7 @@ TEST(BitrateProberTest, VerifyProbeSizeOnHighBitrate) {
const FieldTrialBasedConfig config; const FieldTrialBasedConfig config;
BitrateProber prober(config); BitrateProber prober(config);
const DataRate kHighBitrate = DataRate::kbps(10000); // 10 Mbps const DataRate kHighBitrate = DataRate::KilobitsPerSec(10000); // 10 Mbps
prober.CreateProbeCluster(kHighBitrate, Timestamp::Millis(0), prober.CreateProbeCluster(kHighBitrate, Timestamp::Millis(0),
/*cluster_id=*/0); /*cluster_id=*/0);
@ -129,7 +129,7 @@ TEST(BitrateProberTest, MinumumNumberOfProbingPackets) {
BitrateProber prober(config); BitrateProber prober(config);
// Even when probing at a low bitrate we expect a minimum number // Even when probing at a low bitrate we expect a minimum number
// of packets to be sent. // of packets to be sent.
const DataRate kBitrate = DataRate::kbps(100); const DataRate kBitrate = DataRate::KilobitsPerSec(100);
const int kPacketSizeBytes = 1000; const int kPacketSizeBytes = 1000;
Timestamp now = Timestamp::Millis(0); Timestamp now = Timestamp::Millis(0);
@ -146,7 +146,7 @@ TEST(BitrateProberTest, MinumumNumberOfProbingPackets) {
TEST(BitrateProberTest, ScaleBytesUsedForProbing) { TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
const FieldTrialBasedConfig config; const FieldTrialBasedConfig config;
BitrateProber prober(config); BitrateProber prober(config);
const DataRate kBitrate = DataRate::kbps(10000); // 10 Mbps. const DataRate kBitrate = DataRate::KilobitsPerSec(10000); // 10 Mbps.
const int kPacketSizeBytes = 1000; const int kPacketSizeBytes = 1000;
const int kExpectedBytesSent = (kBitrate * TimeDelta::Millis(15)).bytes(); const int kExpectedBytesSent = (kBitrate * TimeDelta::Millis(15)).bytes();
@ -166,7 +166,7 @@ TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
TEST(BitrateProberTest, HighBitrateProbing) { TEST(BitrateProberTest, HighBitrateProbing) {
const FieldTrialBasedConfig config; const FieldTrialBasedConfig config;
BitrateProber prober(config); BitrateProber prober(config);
const DataRate kBitrate = DataRate::kbps(1000000); // 1 Gbps. const DataRate kBitrate = DataRate::KilobitsPerSec(1000000); // 1 Gbps.
const int kPacketSizeBytes = 1000; const int kPacketSizeBytes = 1000;
const int kExpectedBytesSent = (kBitrate * TimeDelta::Millis(15)).bytes(); const int kExpectedBytesSent = (kBitrate * TimeDelta::Millis(15)).bytes();
@ -186,7 +186,7 @@ TEST(BitrateProberTest, HighBitrateProbing) {
TEST(BitrateProberTest, ProbeClusterTimeout) { TEST(BitrateProberTest, ProbeClusterTimeout) {
const FieldTrialBasedConfig config; const FieldTrialBasedConfig config;
BitrateProber prober(config); BitrateProber prober(config);
const DataRate kBitrate = DataRate::kbps(300); const DataRate kBitrate = DataRate::KilobitsPerSec(300);
const int kSmallPacketSize = 20; const int kSmallPacketSize = 20;
// Expecting two probe clusters of 5 packets each. // Expecting two probe clusters of 5 packets each.
const int kExpectedBytesSent = 20 * 2 * 5; const int kExpectedBytesSent = 20 * 2 * 5;

View File

@ -120,7 +120,8 @@ class PacedSenderTest
TEST_P(PacedSenderTest, PacesPackets) { TEST_P(PacedSenderTest, PacesPackets) {
// Insert a number of packets, covering one second. // Insert a number of packets, covering one second.
static constexpr size_t kPacketsToSend = 42; static constexpr size_t kPacketsToSend = 42;
pacer_->SetPacingRates(DataRate::bps(kDefaultPacketSize * 8 * kPacketsToSend), pacer_->SetPacingRates(
DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend),
DataRate::Zero()); DataRate::Zero());
std::vector<std::unique_ptr<RtpPacketToSend>> packets; std::vector<std::unique_ptr<RtpPacketToSend>> packets;
for (size_t i = 0; i < kPacketsToSend; ++i) { for (size_t i = 0; i < kPacketsToSend; ++i) {

View File

@ -32,7 +32,7 @@ constexpr TimeDelta kCongestedPacketInterval = TimeDelta::Millis(500);
// The maximum debt level, in terms of time, capped when sending packets. // The maximum debt level, in terms of time, capped when sending packets.
constexpr TimeDelta kMaxDebtInTime = TimeDelta::Millis(500); constexpr TimeDelta kMaxDebtInTime = TimeDelta::Millis(500);
constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2); constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2);
constexpr DataSize kDefaultPaddingTarget = DataSize::Bytes<50>(); constexpr DataSize kDefaultPaddingTarget = DataSize::Bytes(50);
// Upper cap on process interval, in case process has not been called in a long // Upper cap on process interval, in case process has not been called in a long
// time. // time.
@ -415,10 +415,10 @@ void PacingController::ProcessPackets() {
} else { } else {
DataSize keepalive_data_sent = DataSize::Zero(); DataSize keepalive_data_sent = DataSize::Zero();
std::vector<std::unique_ptr<RtpPacketToSend>> keepalive_packets = std::vector<std::unique_ptr<RtpPacketToSend>> keepalive_packets =
packet_sender_->GeneratePadding(DataSize::bytes(1)); packet_sender_->GeneratePadding(DataSize::Bytes(1));
for (auto& packet : keepalive_packets) { for (auto& packet : keepalive_packets) {
keepalive_data_sent += keepalive_data_sent +=
DataSize::bytes(packet->payload_size() + packet->padding_size()); DataSize::Bytes(packet->payload_size() + packet->padding_size());
packet_sender_->SendRtpPacket(std::move(packet), PacedPacketInfo()); packet_sender_->SendRtpPacket(std::move(packet), PacedPacketInfo());
} }
OnPaddingSent(keepalive_data_sent); OnPaddingSent(keepalive_data_sent);
@ -468,7 +468,7 @@ void PacingController::ProcessPackets() {
if (is_probing) { if (is_probing) {
pacing_info = prober_.CurrentCluster(); pacing_info = prober_.CurrentCluster();
first_packet_in_probe = pacing_info.probe_cluster_bytes_sent == 0; first_packet_in_probe = pacing_info.probe_cluster_bytes_sent == 0;
recommended_probe_size = DataSize::bytes(prober_.RecommendedMinProbeSize()); recommended_probe_size = DataSize::Bytes(prober_.RecommendedMinProbeSize());
} }
DataSize data_sent = DataSize::Zero(); DataSize data_sent = DataSize::Zero();
@ -479,7 +479,7 @@ void PacingController::ProcessPackets() {
if (small_first_probe_packet_ && first_packet_in_probe) { if (small_first_probe_packet_ && first_packet_in_probe) {
// If first packet in probe, insert a small padding packet so we have a // If first packet in probe, insert a small padding packet so we have a
// more reliable start window for the rate estimation. // more reliable start window for the rate estimation.
auto padding = packet_sender_->GeneratePadding(DataSize::bytes(1)); auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1));
// If no RTP modules sending media are registered, we may not get a // If no RTP modules sending media are registered, we may not get a
// padding packet back. // padding packet back.
if (!padding.empty()) { if (!padding.empty()) {
@ -531,11 +531,11 @@ void PacingController::ProcessPackets() {
RTC_DCHECK(rtp_packet); RTC_DCHECK(rtp_packet);
RTC_DCHECK(rtp_packet->packet_type().has_value()); RTC_DCHECK(rtp_packet->packet_type().has_value());
const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); const RtpPacketMediaType packet_type = *rtp_packet->packet_type();
DataSize packet_size = DataSize::bytes(rtp_packet->payload_size() + DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() +
rtp_packet->padding_size()); rtp_packet->padding_size());
if (include_overhead_) { if (include_overhead_) {
packet_size += DataSize::bytes(rtp_packet->headers_size()) + packet_size += DataSize::Bytes(rtp_packet->headers_size()) +
transport_overhead_per_packet_; transport_overhead_per_packet_;
} }
packet_sender_->SendRtpPacket(std::move(rtp_packet), pacing_info); packet_sender_->SendRtpPacket(std::move(rtp_packet), pacing_info);
@ -594,7 +594,7 @@ DataSize PacingController::PaddingToAdd(
} }
if (mode_ == ProcessMode::kPeriodic) { if (mode_ == ProcessMode::kPeriodic) {
return DataSize::bytes(padding_budget_.bytes_remaining()); return DataSize::Bytes(padding_budget_.bytes_remaining());
} else if (padding_rate_ > DataRate::Zero() && } else if (padding_rate_ > DataRate::Zero() &&
padding_debt_ == DataSize::Zero()) { padding_debt_ == DataSize::Zero()) {
return kDefaultPaddingTarget; return kDefaultPaddingTarget;

View File

@ -33,13 +33,13 @@ using ::testing::Return;
namespace webrtc { namespace webrtc {
namespace test { namespace test {
namespace { namespace {
constexpr DataRate kFirstClusterRate = DataRate::KilobitsPerSec<900>(); constexpr DataRate kFirstClusterRate = DataRate::KilobitsPerSec(900);
constexpr DataRate kSecondClusterRate = DataRate::KilobitsPerSec<1800>(); constexpr DataRate kSecondClusterRate = DataRate::KilobitsPerSec(1800);
// The error stems from truncating the time interval of probe packets to integer // The error stems from truncating the time interval of probe packets to integer
// values. This results in probing slightly higher than the target bitrate. // values. This results in probing slightly higher than the target bitrate.
// For 1.8 Mbps, this comes to be about 120 kbps with 1200 probe packets. // For 1.8 Mbps, this comes to be about 120 kbps with 1200 probe packets.
constexpr DataRate kProbingErrorMargin = DataRate::KilobitsPerSec<150>(); constexpr DataRate kProbingErrorMargin = DataRate::KilobitsPerSec(150);
const float kPaceMultiplier = 2.5f; const float kPaceMultiplier = 2.5f;
@ -48,7 +48,7 @@ constexpr uint32_t kVideoSsrc = 234565;
constexpr uint32_t kVideoRtxSsrc = 34567; constexpr uint32_t kVideoRtxSsrc = 34567;
constexpr uint32_t kFlexFecSsrc = 45678; constexpr uint32_t kFlexFecSsrc = 45678;
constexpr DataRate kTargetRate = DataRate::KilobitsPerSec<800>(); constexpr DataRate kTargetRate = DataRate::KilobitsPerSec(800);
std::unique_ptr<RtpPacketToSend> BuildPacket(RtpPacketMediaType type, std::unique_ptr<RtpPacketToSend> BuildPacket(RtpPacketMediaType type,
uint32_t ssrc, uint32_t ssrc,
@ -158,7 +158,7 @@ class PacingControllerProbing : public PacingController::PacketSender {
DataSize target_size) override { DataSize target_size) override {
// From RTPSender: // From RTPSender:
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
const DataSize kMaxPadding = DataSize::bytes(224); const DataSize kMaxPadding = DataSize::Bytes(224);
std::vector<std::unique_ptr<RtpPacketToSend>> packets; std::vector<std::unique_ptr<RtpPacketToSend>> packets;
while (target_size > DataSize::Zero()) { while (target_size > DataSize::Zero()) {
@ -370,8 +370,8 @@ TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) {
ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/"); ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/");
EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0);
PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam());
pacer.SetPacingRates(DataRate::kbps(10000), DataRate::Zero()); pacer.SetPacingRates(DataRate::KilobitsPerSec(10000), DataRate::Zero());
pacer.SetCongestionWindow(DataSize::bytes(video.packet_size - 100)); pacer.SetCongestionWindow(DataSize::Bytes(video.packet_size - 100));
pacer.UpdateOutstandingData(DataSize::Zero()); pacer.UpdateOutstandingData(DataSize::Zero());
// Video packet fills congestion window. // Video packet fills congestion window.
InsertPacket(&pacer, &video); InsertPacket(&pacer, &video);
@ -397,8 +397,8 @@ TEST_P(PacingControllerFieldTrialTest,
DefaultCongestionWindowDoesNotAffectAudio) { DefaultCongestionWindowDoesNotAffectAudio) {
EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0);
PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam());
pacer.SetPacingRates(DataRate::bps(10000000), DataRate::Zero()); pacer.SetPacingRates(DataRate::BitsPerSec(10000000), DataRate::Zero());
pacer.SetCongestionWindow(DataSize::bytes(800)); pacer.SetCongestionWindow(DataSize::Bytes(800));
pacer.UpdateOutstandingData(DataSize::Zero()); pacer.UpdateOutstandingData(DataSize::Zero());
// Video packet fills congestion window. // Video packet fills congestion window.
InsertPacket(&pacer, &video); InsertPacket(&pacer, &video);
@ -413,8 +413,8 @@ TEST_P(PacingControllerFieldTrialTest,
TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) {
ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/"); ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/");
PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam());
DataRate pacing_rate = DataRate pacing_rate = DataRate::BitsPerSec(video.packet_size / 3 * 8 *
DataRate::bps(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond); kProcessIntervalsPerSecond);
pacer.SetPacingRates(pacing_rate, DataRate::Zero()); pacer.SetPacingRates(pacing_rate, DataRate::Zero());
// Video fills budget for following process periods. // Video fills budget for following process periods.
InsertPacket(&pacer, &video); InsertPacket(&pacer, &video);
@ -432,7 +432,7 @@ TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) {
ProcessNext(&pacer); ProcessNext(&pacer);
} }
const TimeDelta expected_wait_time = const TimeDelta expected_wait_time =
DataSize::bytes(video.packet_size) / pacing_rate; DataSize::Bytes(video.packet_size) / pacing_rate;
// Verify delay is near expectation, within timing margin. // Verify delay is near expectation, within timing margin.
EXPECT_LT(((wait_end_time - wait_start_time) - expected_wait_time).Abs(), EXPECT_LT(((wait_end_time - wait_start_time) - expected_wait_time).Abs(),
GetParam() == PacingController::ProcessMode::kPeriodic GetParam() == PacingController::ProcessMode::kPeriodic
@ -443,8 +443,8 @@ TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) {
TEST_P(PacingControllerFieldTrialTest, DefaultBudgetDoesNotAffectAudio) { TEST_P(PacingControllerFieldTrialTest, DefaultBudgetDoesNotAffectAudio) {
EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0);
PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam());
pacer.SetPacingRates( pacer.SetPacingRates(DataRate::BitsPerSec(video.packet_size / 3 * 8 *
DataRate::bps(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond), kProcessIntervalsPerSecond),
DataRate::Zero()); DataRate::Zero());
// Video fills budget for following process periods. // Video fills budget for following process periods.
InsertPacket(&pacer, &video); InsertPacket(&pacer, &video);
@ -539,7 +539,7 @@ TEST_P(PacingControllerTest, QueueAndPacePackets) {
const uint32_t kSsrc = 12345; const uint32_t kSsrc = 12345;
uint16_t sequence_number = 1234; uint16_t sequence_number = 1234;
const DataSize kPackeSize = DataSize::bytes(250); const DataSize kPackeSize = DataSize::Bytes(250);
const TimeDelta kSendInterval = TimeDelta::Millis(5); const TimeDelta kSendInterval = TimeDelta::Millis(5);
// Due to the multiplicative factor we can send 5 packets during a 5ms send // Due to the multiplicative factor we can send 5 packets during a 5ms send
@ -609,7 +609,7 @@ TEST_P(PacingControllerTest, PaceQueuedPackets) {
EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, false)) EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, false))
.Times(pacer_->QueueSizePackets()); .Times(pacer_->QueueSizePackets());
const TimeDelta expected_pace_time = const TimeDelta expected_pace_time =
DataSize::bytes(pacer_->QueueSizePackets() * kPacketSize) / DataSize::Bytes(pacer_->QueueSizePackets() * kPacketSize) /
(kPaceMultiplier * kTargetRate); (kPaceMultiplier * kTargetRate);
Timestamp start_time = clock_.CurrentTime(); Timestamp start_time = clock_.CurrentTime();
while (pacer_->QueueSizePackets() > 0) { while (pacer_->QueueSizePackets() > 0) {
@ -718,7 +718,7 @@ TEST_P(PacingControllerTest, Padding) {
clock_.TimeInMilliseconds(), kPacketSize); clock_.TimeInMilliseconds(), kPacketSize);
} }
const TimeDelta expected_pace_time = const TimeDelta expected_pace_time =
DataSize::bytes(pacer_->QueueSizePackets() * kPacketSize) / DataSize::Bytes(pacer_->QueueSizePackets() * kPacketSize) /
(kPaceMultiplier * kTargetRate); (kPaceMultiplier * kTargetRate);
EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0);
// Only the media packets should be sent. // Only the media packets should be sent.
@ -754,7 +754,7 @@ TEST_P(PacingControllerTest, Padding) {
// Don't count bytes of last packet, instead just // Don't count bytes of last packet, instead just
// use this as the time the last packet finished // use this as the time the last packet finished
// sending. // sending.
padding_sent += DataSize::bytes(target_size); padding_sent += DataSize::Bytes(target_size);
} }
if (first_send_time.IsInfinite()) { if (first_send_time.IsInfinite()) {
first_send_time = clock_.CurrentTime(); first_send_time = clock_.CurrentTime();
@ -869,7 +869,7 @@ TEST_P(PacingControllerTest, VerifyAverageBitrateVaryingMediaPayload) {
EXPECT_NEAR( EXPECT_NEAR(
kTargetRate.bps(), kTargetRate.bps(),
(DataSize::bytes(callback.total_bytes_sent()) / kAveragingWindowLength) (DataSize::Bytes(callback.total_bytes_sent()) / kAveragingWindowLength)
.bps(), .bps(),
(kTargetRate * 0.01 /* 1% error marging */).bps()); (kTargetRate * 0.01 /* 1% error marging */).bps());
} }
@ -1021,7 +1021,7 @@ TEST_P(PacingControllerTest, HighPrioDoesntAffectBudget) {
// Measure pacing time. Expect only low-prio packets to affect this. // Measure pacing time. Expect only low-prio packets to affect this.
TimeDelta pacing_time = clock_.CurrentTime() - start_time; TimeDelta pacing_time = clock_.CurrentTime() - start_time;
TimeDelta expected_pacing_time = TimeDelta expected_pacing_time =
DataSize::bytes(kPacketsToSendPerInterval * kPacketSize) / DataSize::Bytes(kPacketsToSendPerInterval * kPacketSize) /
(kTargetRate * kPaceMultiplier); (kTargetRate * kPaceMultiplier);
EXPECT_NEAR(pacing_time.us<double>(), expected_pacing_time.us<double>(), EXPECT_NEAR(pacing_time.us<double>(), expected_pacing_time.us<double>(),
PeriodicProcess() ? 5000.0 PeriodicProcess() ? 5000.0
@ -1035,7 +1035,7 @@ TEST_P(PacingControllerTest, SendsOnlyPaddingWhenCongested) {
int kCongestionWindow = kPacketSize * 10; int kCongestionWindow = kPacketSize * 10;
pacer_->UpdateOutstandingData(DataSize::Zero()); pacer_->UpdateOutstandingData(DataSize::Zero());
pacer_->SetCongestionWindow(DataSize::bytes(kCongestionWindow)); pacer_->SetCongestionWindow(DataSize::Bytes(kCongestionWindow));
int sent_data = 0; int sent_data = 0;
while (sent_data < kCongestionWindow) { while (sent_data < kCongestionWindow) {
sent_data += kPacketSize; sent_data += kPacketSize;
@ -1073,9 +1073,10 @@ TEST_P(PacingControllerTest, DoesNotAllowOveruseAfterCongestion) {
EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0);
// The pacing rate is low enough that the budget should not allow two packets // The pacing rate is low enough that the budget should not allow two packets
// to be sent in a row. // to be sent in a row.
pacer_->SetPacingRates(DataRate::bps(400 * 8 * 1000 / 5), DataRate::Zero()); pacer_->SetPacingRates(DataRate::BitsPerSec(400 * 8 * 1000 / 5),
DataRate::Zero());
// The congestion window is small enough to only let one packet through. // The congestion window is small enough to only let one packet through.
pacer_->SetCongestionWindow(DataSize::bytes(800)); pacer_->SetCongestionWindow(DataSize::Bytes(800));
pacer_->UpdateOutstandingData(DataSize::Zero()); pacer_->UpdateOutstandingData(DataSize::Zero());
// Not yet budget limited or congested, packet is sent. // Not yet budget limited or congested, packet is sent.
Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size); Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size);
@ -1114,7 +1115,7 @@ TEST_P(PacingControllerTest, ResumesSendingWhenCongestionEnds) {
int64_t kCongestionTimeMs = 1000; int64_t kCongestionTimeMs = 1000;
pacer_->UpdateOutstandingData(DataSize::Zero()); pacer_->UpdateOutstandingData(DataSize::Zero());
pacer_->SetCongestionWindow(DataSize::bytes(kCongestionWindow)); pacer_->SetCongestionWindow(DataSize::Bytes(kCongestionWindow));
int sent_data = 0; int sent_data = 0;
while (sent_data < kCongestionWindow) { while (sent_data < kCongestionWindow) {
sent_data += kPacketSize; sent_data += kPacketSize;
@ -1140,7 +1141,7 @@ TEST_P(PacingControllerTest, ResumesSendingWhenCongestionEnds) {
int ack_count = kCongestionCount / 2; int ack_count = kCongestionCount / 2;
EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, _)).Times(ack_count); EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, _)).Times(ack_count);
pacer_->UpdateOutstandingData( pacer_->UpdateOutstandingData(
DataSize::bytes(kCongestionWindow - kPacketSize * ack_count)); DataSize::Bytes(kCongestionWindow - kPacketSize * ack_count));
for (int duration = 0; duration < kCongestionTimeMs; duration += 5) { for (int duration = 0; duration < kCongestionTimeMs; duration += 5) {
clock_.AdvanceTimeMilliseconds(5); clock_.AdvanceTimeMilliseconds(5);
@ -1324,7 +1325,7 @@ TEST_P(PacingControllerTest, ExpectedQueueTimeMs) {
const int32_t kMaxBitrate = kPaceMultiplier * 30000; const int32_t kMaxBitrate = kPaceMultiplier * 30000;
EXPECT_EQ(TimeDelta::Zero(), pacer_->OldestPacketWaitTime()); EXPECT_EQ(TimeDelta::Zero(), pacer_->OldestPacketWaitTime());
pacer_->SetPacingRates(DataRate::bps(30000 * kPaceMultiplier), pacer_->SetPacingRates(DataRate::BitsPerSec(30000 * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
for (size_t i = 0; i < kNumPackets; ++i) { for (size_t i = 0; i < kNumPackets; ++i) {
SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++,
@ -1357,7 +1358,7 @@ TEST_P(PacingControllerTest, QueueTimeGrowsOverTime) {
uint16_t sequence_number = 1234; uint16_t sequence_number = 1234;
EXPECT_EQ(TimeDelta::Zero(), pacer_->OldestPacketWaitTime()); EXPECT_EQ(TimeDelta::Zero(), pacer_->OldestPacketWaitTime());
pacer_->SetPacingRates(DataRate::bps(30000 * kPaceMultiplier), pacer_->SetPacingRates(DataRate::BitsPerSec(30000 * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number, SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number,
clock_.TimeInMilliseconds(), 1200); clock_.TimeInMilliseconds(), 1200);
@ -1381,7 +1382,8 @@ TEST_P(PacingControllerTest, ProbingWithInsertedPackets) {
/*cluster_id=*/0); /*cluster_id=*/0);
pacer_->CreateProbeCluster(kSecondClusterRate, pacer_->CreateProbeCluster(kSecondClusterRate,
/*cluster_id=*/1); /*cluster_id=*/1);
pacer_->SetPacingRates(DataRate::bps(kInitialBitrateBps * kPaceMultiplier), pacer_->SetPacingRates(
DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@ -1424,7 +1426,8 @@ TEST_P(PacingControllerTest, SkipsProbesWhenProcessIntervalTooLarge) {
PacingControllerProbing packet_sender; PacingControllerProbing packet_sender;
pacer_ = std::make_unique<PacingController>(&clock_, &packet_sender, nullptr, pacer_ = std::make_unique<PacingController>(&clock_, &packet_sender, nullptr,
nullptr, GetParam()); nullptr, GetParam());
pacer_->SetPacingRates(DataRate::bps(kInitialBitrateBps * kPaceMultiplier), pacer_->SetPacingRates(
DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@ -1437,7 +1440,7 @@ TEST_P(PacingControllerTest, SkipsProbesWhenProcessIntervalTooLarge) {
} }
// Probe at a very high rate. // Probe at a very high rate.
pacer_->CreateProbeCluster(DataRate::kbps(10000), // 10 Mbps. pacer_->CreateProbeCluster(DataRate::KilobitsPerSec(10000), // 10 Mbps.
/*cluster_id=*/3); /*cluster_id=*/3);
// We need one packet to start the probe. // We need one packet to start the probe.
Send(RtpPacketMediaType::kVideo, ssrc, sequence_number++, Send(RtpPacketMediaType::kVideo, ssrc, sequence_number++,
@ -1487,7 +1490,8 @@ TEST_P(PacingControllerTest, ProbingWithPaddingSupport) {
nullptr, GetParam()); nullptr, GetParam());
pacer_->CreateProbeCluster(kFirstClusterRate, pacer_->CreateProbeCluster(kFirstClusterRate,
/*cluster_id=*/0); /*cluster_id=*/0);
pacer_->SetPacingRates(DataRate::bps(kInitialBitrateBps * kPaceMultiplier), pacer_->SetPacingRates(
DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
@ -1520,7 +1524,7 @@ TEST_P(PacingControllerTest, PaddingOveruse) {
// Initially no padding rate. // Initially no padding rate.
pacer_->ProcessPackets(); pacer_->ProcessPackets();
pacer_->SetPacingRates(DataRate::bps(60000 * kPaceMultiplier), pacer_->SetPacingRates(DataRate::BitsPerSec(60000 * kPaceMultiplier),
DataRate::Zero()); DataRate::Zero());
SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++,
@ -1530,8 +1534,8 @@ TEST_P(PacingControllerTest, PaddingOveruse) {
// Add 30kbit padding. When increasing budget, media budget will increase from // Add 30kbit padding. When increasing budget, media budget will increase from
// negative (overuse) while padding budget will increase from 0. // negative (overuse) while padding budget will increase from 0.
clock_.AdvanceTimeMilliseconds(5); clock_.AdvanceTimeMilliseconds(5);
pacer_->SetPacingRates(DataRate::bps(60000 * kPaceMultiplier), pacer_->SetPacingRates(DataRate::BitsPerSec(60000 * kPaceMultiplier),
DataRate::bps(30000)); DataRate::BitsPerSec(30000));
SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++,
clock_.TimeInMilliseconds(), kPacketSize); clock_.TimeInMilliseconds(), kPacketSize);
@ -1662,7 +1666,7 @@ TEST_P(PacingControllerTest, SmallFirstProbePacket) {
pacer_->EnqueuePacket(BuildRtpPacket(RtpPacketMediaType::kAudio)); pacer_->EnqueuePacket(BuildRtpPacket(RtpPacketMediaType::kAudio));
// Expect small padding packet to be requested. // Expect small padding packet to be requested.
EXPECT_CALL(callback, GeneratePadding(DataSize::bytes(1))) EXPECT_CALL(callback, GeneratePadding(DataSize::Bytes(1)))
.WillOnce([&](DataSize padding_size) { .WillOnce([&](DataSize padding_size) {
std::vector<std::unique_ptr<RtpPacketToSend>> padding_packets; std::vector<std::unique_ptr<RtpPacketToSend>> padding_packets;
padding_packets.emplace_back( padding_packets.emplace_back(
@ -1699,7 +1703,7 @@ TEST_P(PacingControllerTest, TaskLate) {
} }
// Set a low send rate to more easily test timing issues. // Set a low send rate to more easily test timing issues.
DataRate kSendRate = DataRate::kbps(30); DataRate kSendRate = DataRate::KilobitsPerSec(30);
pacer_->SetPacingRates(kSendRate, DataRate::Zero()); pacer_->SetPacingRates(kSendRate, DataRate::Zero());
// Add four packets of equal size and priority. // Add four packets of equal size and priority.
@ -1748,7 +1752,7 @@ TEST_P(PacingControllerTest, NoProbingWhilePaused) {
} }
// Trigger probing. // Trigger probing.
pacer_->CreateProbeCluster(DataRate::kbps(10000), // 10 Mbps. pacer_->CreateProbeCluster(DataRate::KilobitsPerSec(10000), // 10 Mbps.
/*cluster_id=*/3); /*cluster_id=*/3);
// Time to next send time should be small. // Time to next send time should be small.

View File

@ -18,7 +18,7 @@
namespace webrtc { namespace webrtc {
namespace { namespace {
static constexpr DataSize kMaxLeadingSize = DataSize::Bytes<1400>(); static constexpr DataSize kMaxLeadingSize = DataSize::Bytes(1400);
} }
RoundRobinPacketQueue::QueuedPacket::QueuedPacket(const QueuedPacket& rhs) = RoundRobinPacketQueue::QueuedPacket::QueuedPacket(const QueuedPacket& rhs) =
@ -163,10 +163,10 @@ std::unique_ptr<RtpPacketToSend> RoundRobinPacketQueue::Pop() {
// rate. To avoid building a too large budget we limit |bytes| to be within // rate. To avoid building a too large budget we limit |bytes| to be within
// kMaxLeading bytes of the stream that has sent the most amount of bytes. // kMaxLeading bytes of the stream that has sent the most amount of bytes.
DataSize packet_size = DataSize packet_size =
DataSize::bytes(queued_packet.RtpPacket()->payload_size() + DataSize::Bytes(queued_packet.RtpPacket()->payload_size() +
queued_packet.RtpPacket()->padding_size()); queued_packet.RtpPacket()->padding_size());
if (include_overhead_) { if (include_overhead_) {
packet_size += DataSize::bytes(queued_packet.RtpPacket()->headers_size()) + packet_size += DataSize::Bytes(queued_packet.RtpPacket()->headers_size()) +
transport_overhead_per_packet_; transport_overhead_per_packet_;
} }
stream->size = stream->size =
@ -253,7 +253,7 @@ void RoundRobinPacketQueue::SetIncludeOverhead() {
// We need to update the size to reflect overhead for existing packets. // We need to update the size to reflect overhead for existing packets.
for (const auto& stream : streams_) { for (const auto& stream : streams_) {
for (const QueuedPacket& packet : stream.second.packet_queue) { for (const QueuedPacket& packet : stream.second.packet_queue) {
size_ += DataSize::bytes(packet.RtpPacket()->headers_size()) + size_ += DataSize::Bytes(packet.RtpPacket()->headers_size()) +
transport_overhead_per_packet_; transport_overhead_per_packet_;
} }
} }
@ -313,10 +313,10 @@ void RoundRobinPacketQueue::Push(QueuedPacket packet) {
packet.SubtractPauseTime(pause_time_sum_); packet.SubtractPauseTime(pause_time_sum_);
size_packets_ += 1; size_packets_ += 1;
size_ += DataSize::bytes(packet.RtpPacket()->payload_size() + size_ += DataSize::Bytes(packet.RtpPacket()->payload_size() +
packet.RtpPacket()->padding_size()); packet.RtpPacket()->padding_size());
if (include_overhead_) { if (include_overhead_) {
size_ += DataSize::bytes(packet.RtpPacket()->headers_size()) + size_ += DataSize::Bytes(packet.RtpPacket()->headers_size()) +
transport_overhead_per_packet_; transport_overhead_per_packet_;
} }

View File

@ -102,7 +102,8 @@ class TaskQueuePacedSenderTest : public ::testing::Test {
TEST_F(TaskQueuePacedSenderTest, PacesPackets) { TEST_F(TaskQueuePacedSenderTest, PacesPackets) {
// Insert a number of packets, covering one second. // Insert a number of packets, covering one second.
static constexpr size_t kPacketsToSend = 42; static constexpr size_t kPacketsToSend = 42;
pacer_.SetPacingRates(DataRate::bps(kDefaultPacketSize * 8 * kPacketsToSend), pacer_.SetPacingRates(
DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend),
DataRate::Zero()); DataRate::Zero());
pacer_.EnqueuePackets( pacer_.EnqueuePackets(
GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend));
@ -133,7 +134,7 @@ TEST_F(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) {
// Insert a number of packets to be sent 200ms apart. // Insert a number of packets to be sent 200ms apart.
const size_t kPacketsPerSecond = 5; const size_t kPacketsPerSecond = 5;
const DataRate kPacingRate = const DataRate kPacingRate =
DataRate::bps(kDefaultPacketSize * 8 * kPacketsPerSecond); DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsPerSecond);
pacer_.SetPacingRates(kPacingRate, DataRate::Zero()); pacer_.SetPacingRates(kPacingRate, DataRate::Zero());
// Send some initial packets to be rid of any probes. // Send some initial packets to be rid of any probes.

View File

@ -73,7 +73,7 @@ AimdRateControl::AimdRateControl(const WebRtcKeyValueConfig* key_value_config)
AimdRateControl::AimdRateControl(const WebRtcKeyValueConfig* key_value_config, AimdRateControl::AimdRateControl(const WebRtcKeyValueConfig* key_value_config,
bool send_side) bool send_side)
: min_configured_bitrate_(congestion_controller::GetMinBitrate()), : min_configured_bitrate_(congestion_controller::GetMinBitrate()),
max_configured_bitrate_(DataRate::kbps(30000)), max_configured_bitrate_(DataRate::KilobitsPerSec(30000)),
current_bitrate_(max_configured_bitrate_), current_bitrate_(max_configured_bitrate_),
latest_estimated_throughput_(current_bitrate_), latest_estimated_throughput_(current_bitrate_),
link_capacity_(), link_capacity_(),
@ -137,7 +137,7 @@ bool AimdRateControl::ValidEstimate() const {
TimeDelta AimdRateControl::GetFeedbackInterval() const { TimeDelta AimdRateControl::GetFeedbackInterval() const {
// Estimate how often we can send RTCP if we allocate up to 5% of bandwidth // Estimate how often we can send RTCP if we allocate up to 5% of bandwidth
// to feedback. // to feedback.
const DataSize kRtcpSize = DataSize::bytes(80); const DataSize kRtcpSize = DataSize::Bytes(80);
const DataRate rtcp_bitrate = current_bitrate_ * 0.05; const DataRate rtcp_bitrate = current_bitrate_ * 0.05;
const TimeDelta interval = kRtcpSize / rtcp_bitrate; const TimeDelta interval = kRtcpSize / rtcp_bitrate;
const TimeDelta kMinFeedbackInterval = TimeDelta::Millis(200); const TimeDelta kMinFeedbackInterval = TimeDelta::Millis(200);
@ -165,7 +165,7 @@ bool AimdRateControl::InitialTimeToReduceFurther(Timestamp at_time) const {
if (!initial_backoff_interval_) { if (!initial_backoff_interval_) {
return ValidEstimate() && return ValidEstimate() &&
TimeToReduceFurther(at_time, TimeToReduceFurther(at_time,
LatestEstimate() / 2 - DataRate::bps(1)); LatestEstimate() / 2 - DataRate::BitsPerSec(1));
} }
// TODO(terelius): We could use the RTT (clamped to suitable limits) instead // TODO(terelius): We could use the RTT (clamped to suitable limits) instead
// of a fixed bitrate_reduction_interval. // of a fixed bitrate_reduction_interval.
@ -232,7 +232,7 @@ double AimdRateControl::GetNearMaxIncreaseRateBpsPerSecond() const {
RTC_DCHECK(!current_bitrate_.IsZero()); RTC_DCHECK(!current_bitrate_.IsZero());
const TimeDelta kFrameInterval = TimeDelta::Seconds(1) / 30; const TimeDelta kFrameInterval = TimeDelta::Seconds(1) / 30;
DataSize frame_size = current_bitrate_ * kFrameInterval; DataSize frame_size = current_bitrate_ * kFrameInterval;
const DataSize kPacketSize = DataSize::bytes(1200); const DataSize kPacketSize = DataSize::Bytes(1200);
double packets_per_frame = std::ceil(frame_size / kPacketSize); double packets_per_frame = std::ceil(frame_size / kPacketSize);
DataSize avg_packet_size = frame_size / packets_per_frame; DataSize avg_packet_size = frame_size / packets_per_frame;
@ -380,7 +380,7 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate,
// We allow a bit more lag at very low rates to not too easily get stuck if // We allow a bit more lag at very low rates to not too easily get stuck if
// the encoder produces uneven outputs. // the encoder produces uneven outputs.
const DataRate max_bitrate = const DataRate max_bitrate =
1.5 * estimated_throughput + DataRate::kbps(10); 1.5 * estimated_throughput + DataRate::KilobitsPerSec(10);
if (new_bitrate > current_bitrate_ && new_bitrate > max_bitrate) { if (new_bitrate > current_bitrate_ && new_bitrate > max_bitrate) {
new_bitrate = std::max(current_bitrate_, max_bitrate); new_bitrate = std::max(current_bitrate_, max_bitrate);
} }
@ -404,7 +404,7 @@ DataRate AimdRateControl::MultiplicativeRateIncrease(
alpha = pow(alpha, std::min(time_since_last_update.seconds<double>(), 1.0)); alpha = pow(alpha, std::min(time_since_last_update.seconds<double>(), 1.0));
} }
DataRate multiplicative_increase = DataRate multiplicative_increase =
std::max(current_bitrate * (alpha - 1.0), DataRate::bps(1000)); std::max(current_bitrate * (alpha - 1.0), DataRate::BitsPerSec(1000));
return multiplicative_increase; return multiplicative_increase;
} }
@ -413,7 +413,7 @@ DataRate AimdRateControl::AdditiveRateIncrease(Timestamp at_time,
double time_period_seconds = (at_time - last_time).seconds<double>(); double time_period_seconds = (at_time - last_time).seconds<double>();
double data_rate_increase_bps = double data_rate_increase_bps =
GetNearMaxIncreaseRateBpsPerSecond() * time_period_seconds; GetNearMaxIncreaseRateBpsPerSecond() * time_period_seconds;
return DataRate::bps(data_rate_increase_bps); return DataRate::BitsPerSec(data_rate_increase_bps);
} }
void AimdRateControl::ChangeState(const RateControlInput& input, void AimdRateControl::ChangeState(const RateControlInput& input,

View File

@ -47,7 +47,7 @@ AimdRateControlStates CreateAimdRateControlStates(bool send_side = false) {
absl::optional<DataRate> OptionalRateFromOptionalBps( absl::optional<DataRate> OptionalRateFromOptionalBps(
absl::optional<int> bitrate_bps) { absl::optional<int> bitrate_bps) {
if (bitrate_bps) { if (bitrate_bps) {
return DataRate::bps(*bitrate_bps); return DataRate::BitsPerSec(*bitrate_bps);
} else { } else {
return absl::nullopt; return absl::nullopt;
} }
@ -61,7 +61,7 @@ void UpdateRateControl(const AimdRateControlStates& states,
states.aimd_rate_control->Update(&input, Timestamp::Millis(now_ms)); states.aimd_rate_control->Update(&input, Timestamp::Millis(now_ms));
} }
void SetEstimate(const AimdRateControlStates& states, int bitrate_bps) { void SetEstimate(const AimdRateControlStates& states, int bitrate_bps) {
states.aimd_rate_control->SetEstimate(DataRate::bps(bitrate_bps), states.aimd_rate_control->SetEstimate(DataRate::BitsPerSec(bitrate_bps),
states.simulated_clock->CurrentTime()); states.simulated_clock->CurrentTime());
} }
@ -161,7 +161,7 @@ TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) {
TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) { TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) {
// Smoothing experiment disabled // Smoothing experiment disabled
auto states = CreateAimdRateControlStates(); auto states = CreateAimdRateControlStates();
states.aimd_rate_control->SetStartBitrate(DataRate::kbps(300)); states.aimd_rate_control->SetStartBitrate(DataRate::KilobitsPerSec(300));
EXPECT_EQ(kDefaultPeriodMsNoSmoothingExp, EXPECT_EQ(kDefaultPeriodMsNoSmoothingExp,
states.aimd_rate_control->GetExpectedBandwidthPeriod().ms()); states.aimd_rate_control->GetExpectedBandwidthPeriod().ms());
states.simulated_clock->AdvanceTimeMilliseconds(100); states.simulated_clock->AdvanceTimeMilliseconds(100);
@ -175,7 +175,7 @@ TEST(AimdRateControlTest, MinPeriodUntilFirstOveruseSmoothingExp) {
// Smoothing experiment enabled // Smoothing experiment enabled
test::ScopedFieldTrials override_field_trials(kSmoothingExpFieldTrial); test::ScopedFieldTrials override_field_trials(kSmoothingExpFieldTrial);
auto states = CreateAimdRateControlStates(); auto states = CreateAimdRateControlStates();
states.aimd_rate_control->SetStartBitrate(DataRate::kbps(300)); states.aimd_rate_control->SetStartBitrate(DataRate::KilobitsPerSec(300));
EXPECT_EQ(kMinBwePeriodMsSmoothingExp, EXPECT_EQ(kMinBwePeriodMsSmoothingExp,
states.aimd_rate_control->GetExpectedBandwidthPeriod().ms()); states.aimd_rate_control->GetExpectedBandwidthPeriod().ms());
states.simulated_clock->AdvanceTimeMilliseconds(100); states.simulated_clock->AdvanceTimeMilliseconds(100);

View File

@ -23,7 +23,7 @@ int GetMinBitrateBps() {
} }
DataRate GetMinBitrate() { DataRate GetMinBitrate() {
return DataRate::bps(GetMinBitrateBps()); return DataRate::BitsPerSec(GetMinBitrateBps());
} }
} // namespace congestion_controller } // namespace congestion_controller

View File

@ -27,7 +27,7 @@ namespace {
absl::optional<DataRate> OptionalRateFromOptionalBps( absl::optional<DataRate> OptionalRateFromOptionalBps(
absl::optional<int> bitrate_bps) { absl::optional<int> bitrate_bps) {
if (bitrate_bps) { if (bitrate_bps) {
return DataRate::bps(*bitrate_bps); return DataRate::BitsPerSec(*bitrate_bps);
} else { } else {
return absl::nullopt; return absl::nullopt;
} }
@ -201,7 +201,7 @@ RemoteBitrateEstimatorAbsSendTime::ProcessClusters(int64_t now_ms) {
<< " bps. Mean send delta: " << best_it->send_mean_ms << " bps. Mean send delta: " << best_it->send_mean_ms
<< " ms, mean recv delta: " << best_it->recv_mean_ms << " ms, mean recv delta: " << best_it->recv_mean_ms
<< " ms, num probes: " << best_it->count; << " ms, num probes: " << best_it->count;
remote_rate_.SetEstimate(DataRate::bps(probe_bitrate_bps), remote_rate_.SetEstimate(DataRate::BitsPerSec(probe_bitrate_bps),
Timestamp::Millis(now_ms)); Timestamp::Millis(now_ms));
return ProbeResult::kBitrateUpdated; return ProbeResult::kBitrateUpdated;
} }
@ -335,9 +335,9 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacketInfo(
} else if (detector_.State() == BandwidthUsage::kBwOverusing) { } else if (detector_.State() == BandwidthUsage::kBwOverusing) {
absl::optional<uint32_t> incoming_rate = absl::optional<uint32_t> incoming_rate =
incoming_bitrate_.Rate(arrival_time_ms); incoming_bitrate_.Rate(arrival_time_ms);
if (incoming_rate && if (incoming_rate && remote_rate_.TimeToReduceFurther(
remote_rate_.TimeToReduceFurther(Timestamp::Millis(now_ms), Timestamp::Millis(now_ms),
DataRate::bps(*incoming_rate))) { DataRate::BitsPerSec(*incoming_rate))) {
update_estimate = true; update_estimate = true;
} }
} }
@ -426,6 +426,6 @@ void RemoteBitrateEstimatorAbsSendTime::SetMinBitrate(int min_bitrate_bps) {
// Called from both the configuration thread and the network thread. Shouldn't // Called from both the configuration thread and the network thread. Shouldn't
// be called from the network thread in the future. // be called from the network thread in the future.
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
remote_rate_.SetMinBitrate(DataRate::bps(min_bitrate_bps)); remote_rate_.SetMinBitrate(DataRate::BitsPerSec(min_bitrate_bps));
} }
} // namespace webrtc } // namespace webrtc

View File

@ -31,7 +31,7 @@ namespace {
absl::optional<DataRate> OptionalRateFromOptionalBps( absl::optional<DataRate> OptionalRateFromOptionalBps(
absl::optional<int> bitrate_bps) { absl::optional<int> bitrate_bps) {
if (bitrate_bps) { if (bitrate_bps) {
return DataRate::bps(*bitrate_bps); return DataRate::BitsPerSec(*bitrate_bps);
} else { } else {
return absl::nullopt; return absl::nullopt;
} }
@ -143,10 +143,11 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
if (estimator->detector.State() == BandwidthUsage::kBwOverusing) { if (estimator->detector.State() == BandwidthUsage::kBwOverusing) {
absl::optional<uint32_t> incoming_bitrate_bps = absl::optional<uint32_t> incoming_bitrate_bps =
incoming_bitrate_.Rate(now_ms); incoming_bitrate_.Rate(now_ms);
if (incoming_bitrate_bps && (prior_state != BandwidthUsage::kBwOverusing || if (incoming_bitrate_bps &&
(prior_state != BandwidthUsage::kBwOverusing ||
GetRemoteRate()->TimeToReduceFurther( GetRemoteRate()->TimeToReduceFurther(
Timestamp::Millis(now_ms), Timestamp::Millis(now_ms),
DataRate::bps(*incoming_bitrate_bps)))) { DataRate::BitsPerSec(*incoming_bitrate_bps)))) {
// The first overuse should immediately trigger a new estimate. // The first overuse should immediately trigger a new estimate.
// We also have to update the estimate immediately if we are overusing // We also have to update the estimate immediately if we are overusing
// and the target bitrate is too high compared to what we are receiving. // and the target bitrate is too high compared to what we are receiving.
@ -264,7 +265,7 @@ AimdRateControl* RemoteBitrateEstimatorSingleStream::GetRemoteRate() {
void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) { void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) {
rtc::CritScope cs(&crit_sect_); rtc::CritScope cs(&crit_sect_);
remote_rate_->SetMinBitrate(DataRate::bps(min_bitrate_bps)); remote_rate_->SetMinBitrate(DataRate::BitsPerSec(min_bitrate_bps));
} }
} // namespace webrtc } // namespace webrtc

View File

@ -122,7 +122,7 @@ void RemoteEstimatorProxy::IncomingPacket(int64_t arrival_time_ms,
packet_result.sent_packet.send_time = abs_send_timestamp_; packet_result.sent_packet.send_time = abs_send_timestamp_;
// TODO(webrtc:10742): Take IP header and transport overhead into account. // TODO(webrtc:10742): Take IP header and transport overhead into account.
packet_result.sent_packet.size = packet_result.sent_packet.size =
DataSize::bytes(header.headerLength + payload_size); DataSize::Bytes(header.headerLength + payload_size);
packet_result.sent_packet.sequence_number = seq; packet_result.sent_packet.sequence_number = seq;
network_state_estimator_->OnReceivedPacket(packet_result); network_state_estimator_->OnReceivedPacket(packet_result);
} }

View File

@ -25,7 +25,7 @@ namespace {
static constexpr int kFieldValueSize = 3; static constexpr int kFieldValueSize = 3;
static constexpr int kFieldSize = 1 + kFieldValueSize; static constexpr int kFieldSize = 1 + kFieldValueSize;
static constexpr DataRate kDataRateResolution = DataRate::KilobitsPerSec<1>(); static constexpr DataRate kDataRateResolution = DataRate::KilobitsPerSec(1);
constexpr int64_t kMaxEncoded = (1 << (kFieldValueSize * 8)) - 1; constexpr int64_t kMaxEncoded = (1 << (kFieldValueSize * 8)) - 1;
class DataRateSerializer { class DataRateSerializer {

View File

@ -15,8 +15,8 @@ namespace webrtc {
namespace rtcp { namespace rtcp {
TEST(RemoteEstimateTest, EncodesCapacityBounds) { TEST(RemoteEstimateTest, EncodesCapacityBounds) {
NetworkStateEstimate src; NetworkStateEstimate src;
src.link_capacity_lower = DataRate::kbps(10); src.link_capacity_lower = DataRate::KilobitsPerSec(10);
src.link_capacity_upper = DataRate::kbps(1000000); src.link_capacity_upper = DataRate::KilobitsPerSec(1000000);
rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src); rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src);
NetworkStateEstimate dst; NetworkStateEstimate dst;
EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst)); EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst));
@ -28,7 +28,7 @@ TEST(RemoteEstimateTest, ExpandsToPlusInfinity) {
NetworkStateEstimate src; NetworkStateEstimate src;
// White box testing: We know that the value is stored in an unsigned 24 int // White box testing: We know that the value is stored in an unsigned 24 int
// with kbps resolution. We expected it be represented as plus infinity. // with kbps resolution. We expected it be represented as plus infinity.
src.link_capacity_lower = DataRate::kbps(2 << 24); src.link_capacity_lower = DataRate::KilobitsPerSec(2 << 24);
src.link_capacity_upper = DataRate::PlusInfinity(); src.link_capacity_upper = DataRate::PlusInfinity();
rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src); rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src);
@ -46,10 +46,10 @@ TEST(RemoteEstimateTest, DoesNotEncodeNegative) {
// Since MinusInfinity can't be represented, the buffer should be empty. // Since MinusInfinity can't be represented, the buffer should be empty.
EXPECT_EQ(data.size(), 0u); EXPECT_EQ(data.size(), 0u);
NetworkStateEstimate dst; NetworkStateEstimate dst;
dst.link_capacity_lower = DataRate::kbps(300); dst.link_capacity_lower = DataRate::KilobitsPerSec(300);
EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst)); EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst));
// The fields will be left unchanged by the parser as they were not encoded. // The fields will be left unchanged by the parser as they were not encoded.
EXPECT_EQ(dst.link_capacity_lower, DataRate::kbps(300)); EXPECT_EQ(dst.link_capacity_lower, DataRate::KilobitsPerSec(300));
EXPECT_TRUE(dst.link_capacity_upper.IsMinusInfinity()); EXPECT_TRUE(dst.link_capacity_upper.IsMinusInfinity());
} }
} // namespace rtcp } // namespace rtcp

View File

@ -213,13 +213,13 @@ void RtpSenderEgress::ProcessBitrateAndNotifyObservers() {
DataRate RtpSenderEgress::SendBitrate() const { DataRate RtpSenderEgress::SendBitrate() const {
rtc::CritScope cs(&lock_); rtc::CritScope cs(&lock_);
return DataRate::bps( return DataRate::BitsPerSec(
total_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0)); total_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0));
} }
DataRate RtpSenderEgress::NackOverheadRate() const { DataRate RtpSenderEgress::NackOverheadRate() const {
rtc::CritScope cs(&lock_); rtc::CritScope cs(&lock_);
return DataRate::bps( return DataRate::BitsPerSec(
nack_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0)); nack_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0));
} }

View File

@ -295,7 +295,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,
SimulcastRateAllocator init_allocator(codec_); SimulcastRateAllocator init_allocator(codec_);
VideoBitrateAllocation allocation = VideoBitrateAllocation allocation =
init_allocator.Allocate(VideoBitrateAllocationParameters( init_allocator.Allocate(VideoBitrateAllocationParameters(
DataRate::kbps(codec_.startBitrate), codec_.maxFramerate)); DataRate::KilobitsPerSec(codec_.startBitrate), codec_.maxFramerate));
SetRates(RateControlParameters(allocation, codec_.maxFramerate)); SetRates(RateControlParameters(allocation, codec_.maxFramerate));
return WEBRTC_VIDEO_CODEC_OK; return WEBRTC_VIDEO_CODEC_OK;
} }

View File

@ -242,7 +242,7 @@ void MultiplexEncoderAdapter::SetRates(
bitrate_allocation, bitrate_allocation,
static_cast<uint32_t>(encoders_.size() * parameters.framerate_fps), static_cast<uint32_t>(encoders_.size() * parameters.framerate_fps),
parameters.bandwidth_allocation - parameters.bandwidth_allocation -
DataRate::bps(augmenting_data_size_))); DataRate::BitsPerSec(augmenting_data_size_)));
} }
} }

View File

@ -206,7 +206,7 @@ TEST_F(TestVp8Impl, DynamicSetRates) {
static_cast<double>(codec_settings_.maxFramerate); static_cast<double>(codec_settings_.maxFramerate);
// Set rates with no headroom. // Set rates with no headroom.
rate_settings.bandwidth_allocation = DataRate::bps(kBitrateBps); rate_settings.bandwidth_allocation = DataRate::BitsPerSec(kBitrateBps);
EXPECT_CALL( EXPECT_CALL(
*vpx, *vpx,
codec_enc_config_set( codec_enc_config_set(
@ -221,7 +221,7 @@ TEST_F(TestVp8Impl, DynamicSetRates) {
encoder.SetRates(rate_settings); encoder.SetRates(rate_settings);
// Set rates with max headroom. // Set rates with max headroom.
rate_settings.bandwidth_allocation = DataRate::bps(kBitrateBps * 2); rate_settings.bandwidth_allocation = DataRate::BitsPerSec(kBitrateBps * 2);
EXPECT_CALL( EXPECT_CALL(
*vpx, codec_enc_config_set( *vpx, codec_enc_config_set(
_, AllOf(Field(&vpx_codec_enc_cfg_t::rc_target_bitrate, _, AllOf(Field(&vpx_codec_enc_cfg_t::rc_target_bitrate,
@ -235,7 +235,8 @@ TEST_F(TestVp8Impl, DynamicSetRates) {
encoder.SetRates(rate_settings); encoder.SetRates(rate_settings);
// Set rates with headroom half way. // Set rates with headroom half way.
rate_settings.bandwidth_allocation = DataRate::bps((3 * kBitrateBps) / 2); rate_settings.bandwidth_allocation =
DataRate::BitsPerSec((3 * kBitrateBps) / 2);
EXPECT_CALL( EXPECT_CALL(
*vpx, *vpx,
codec_enc_config_set( codec_enc_config_set(

View File

@ -62,9 +62,9 @@ std::vector<DataRate> AdjustAndVerify(
// max bitrate constraint, try to pass it forward to the next one. // max bitrate constraint, try to pass it forward to the next one.
DataRate excess_rate = DataRate::Zero(); DataRate excess_rate = DataRate::Zero();
for (size_t sl_idx = 0; sl_idx < spatial_layer_rates.size(); ++sl_idx) { for (size_t sl_idx = 0; sl_idx < spatial_layer_rates.size(); ++sl_idx) {
DataRate min_rate = DataRate::kbps( DataRate min_rate = DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + sl_idx].minBitrate); codec.spatialLayers[first_active_layer + sl_idx].minBitrate);
DataRate max_rate = DataRate::kbps( DataRate max_rate = DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + sl_idx].maxBitrate); codec.spatialLayers[first_active_layer + sl_idx].maxBitrate);
DataRate layer_rate = spatial_layer_rates[sl_idx] + excess_rate; DataRate layer_rate = spatial_layer_rates[sl_idx] + excess_rate;
@ -125,7 +125,7 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec,
size_t first_active_layer, size_t first_active_layer,
size_t num_active_layers) { size_t num_active_layers) {
if (num_active_layers == 1) { if (num_active_layers == 1) {
return DataRate::kbps(codec.spatialLayers[0].minBitrate); return DataRate::KilobitsPerSec(codec.spatialLayers[0].minBitrate);
} }
if (codec.mode == VideoCodecMode::kRealtimeVideo) { if (codec.mode == VideoCodecMode::kRealtimeVideo) {
@ -133,19 +133,19 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec,
DataRate upper_bound = DataRate::Zero(); DataRate upper_bound = DataRate::Zero();
if (num_active_layers > 1) { if (num_active_layers > 1) {
for (size_t i = 0; i < num_active_layers - 1; ++i) { for (size_t i = 0; i < num_active_layers - 1; ++i) {
lower_bound += DataRate::kbps( lower_bound += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + i].minBitrate); codec.spatialLayers[first_active_layer + i].minBitrate);
upper_bound += DataRate::kbps( upper_bound += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + i].maxBitrate); codec.spatialLayers[first_active_layer + i].maxBitrate);
} }
} }
upper_bound += upper_bound += DataRate::KilobitsPerSec(
DataRate::kbps(codec.spatialLayers[num_active_layers - 1].minBitrate); codec.spatialLayers[num_active_layers - 1].minBitrate);
// Do a binary search until upper and lower bound is the highest bitrate for // Do a binary search until upper and lower bound is the highest bitrate for
// |num_active_layers| - 1 layers and lowest bitrate for |num_active_layers| // |num_active_layers| - 1 layers and lowest bitrate for |num_active_layers|
// layers respectively. // layers respectively.
while (upper_bound - lower_bound > DataRate::bps(1)) { while (upper_bound - lower_bound > DataRate::BitsPerSec(1)) {
DataRate try_rate = (lower_bound + upper_bound) / 2; DataRate try_rate = (lower_bound + upper_bound) / 2;
if (AdjustAndVerify(codec, first_active_layer, if (AdjustAndVerify(codec, first_active_layer,
SplitBitrate(num_active_layers, try_rate, SplitBitrate(num_active_layers, try_rate,
@ -160,10 +160,10 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec,
} else { } else {
DataRate toggling_rate = DataRate::Zero(); DataRate toggling_rate = DataRate::Zero();
for (size_t i = 0; i < num_active_layers - 1; ++i) { for (size_t i = 0; i < num_active_layers - 1; ++i) {
toggling_rate += DataRate::kbps( toggling_rate += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + i].targetBitrate); codec.spatialLayers[first_active_layer + i].targetBitrate);
} }
toggling_rate += DataRate::kbps( toggling_rate += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + num_active_layers - 1] codec.spatialLayers[first_active_layer + num_active_layers - 1]
.minBitrate); .minBitrate);
return toggling_rate; return toggling_rate;
@ -199,7 +199,8 @@ VideoBitrateAllocation SvcRateAllocator::Allocate(
VideoBitrateAllocationParameters parameters) { VideoBitrateAllocationParameters parameters) {
DataRate total_bitrate = parameters.total_bitrate; DataRate total_bitrate = parameters.total_bitrate;
if (codec_.maxBitrate != 0) { if (codec_.maxBitrate != 0) {
total_bitrate = std::min(total_bitrate, DataRate::kbps(codec_.maxBitrate)); total_bitrate =
std::min(total_bitrate, DataRate::KilobitsPerSec(codec_.maxBitrate));
} }
if (codec_.spatialLayers[0].targetBitrate == 0) { if (codec_.spatialLayers[0].targetBitrate == 0) {
@ -324,7 +325,8 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
if (num_spatial_layers == 0 || if (num_spatial_layers == 0 ||
total_bitrate < total_bitrate <
DataRate::kbps(codec_.spatialLayers[first_active_layer].minBitrate)) { DataRate::KilobitsPerSec(
codec_.spatialLayers[first_active_layer].minBitrate)) {
// Always enable at least one layer. // Always enable at least one layer.
bitrate_allocation.SetBitrate(first_active_layer, 0, total_bitrate.bps()); bitrate_allocation.SetBitrate(first_active_layer, 0, total_bitrate.bps());
return bitrate_allocation; return bitrate_allocation;
@ -336,9 +338,9 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
for (sl_idx = first_active_layer; for (sl_idx = first_active_layer;
sl_idx < first_active_layer + num_spatial_layers; ++sl_idx) { sl_idx < first_active_layer + num_spatial_layers; ++sl_idx) {
const DataRate min_rate = const DataRate min_rate =
DataRate::kbps(codec_.spatialLayers[sl_idx].minBitrate); DataRate::KilobitsPerSec(codec_.spatialLayers[sl_idx].minBitrate);
const DataRate target_rate = const DataRate target_rate =
DataRate::kbps(codec_.spatialLayers[sl_idx].targetBitrate); DataRate::KilobitsPerSec(codec_.spatialLayers[sl_idx].targetBitrate);
if (allocated_rate + min_rate > total_bitrate) { if (allocated_rate + min_rate > total_bitrate) {
// Use stable rate to determine if layer should be enabled. // Use stable rate to determine if layer should be enabled.
@ -352,9 +354,9 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
if (sl_idx > 0 && total_bitrate - allocated_rate > DataRate::Zero()) { if (sl_idx > 0 && total_bitrate - allocated_rate > DataRate::Zero()) {
// Add leftover to the last allocated layer. // Add leftover to the last allocated layer.
top_layer_rate = top_layer_rate = std::min(
std::min(top_layer_rate + (total_bitrate - allocated_rate), top_layer_rate + (total_bitrate - allocated_rate),
DataRate::kbps(codec_.spatialLayers[sl_idx - 1].maxBitrate)); DataRate::KilobitsPerSec(codec_.spatialLayers[sl_idx - 1].maxBitrate));
bitrate_allocation.SetBitrate(sl_idx - 1, 0, top_layer_rate.bps()); bitrate_allocation.SetBitrate(sl_idx - 1, 0, top_layer_rate.bps());
} }
@ -385,12 +387,13 @@ DataRate SvcRateAllocator::GetMaxBitrate(const VideoCodec& codec) {
DataRate max_bitrate = DataRate::Zero(); DataRate max_bitrate = DataRate::Zero();
for (size_t sl_idx = 0; sl_idx < num_spatial_layers; ++sl_idx) { for (size_t sl_idx = 0; sl_idx < num_spatial_layers; ++sl_idx) {
max_bitrate += DataRate::kbps( max_bitrate += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + sl_idx].maxBitrate); codec.spatialLayers[first_active_layer + sl_idx].maxBitrate);
} }
if (codec.maxBitrate != 0) { if (codec.maxBitrate != 0) {
max_bitrate = std::min(max_bitrate, DataRate::kbps(codec.maxBitrate)); max_bitrate =
std::min(max_bitrate, DataRate::KilobitsPerSec(codec.maxBitrate));
} }
return max_bitrate; return max_bitrate;

View File

@ -259,8 +259,8 @@ TEST(SvcRateAllocatorTest, FindLayerTogglingThreshold) {
// Predetermined constants indicating the min bitrate needed for two and three // Predetermined constants indicating the min bitrate needed for two and three
// layers to be enabled respectively, using the config from Configure() with // layers to be enabled respectively, using the config from Configure() with
// 1280x720 resolution and three spatial layers. // 1280x720 resolution and three spatial layers.
const DataRate kTwoLayerMinRate = DataRate::bps(299150); const DataRate kTwoLayerMinRate = DataRate::BitsPerSec(299150);
const DataRate kThreeLayerMinRate = DataRate::bps(891052); const DataRate kThreeLayerMinRate = DataRate::BitsPerSec(891052);
VideoCodec codec = Configure(1280, 720, 3, 1, false); VideoCodec codec = Configure(1280, 720, 3, 1, false);
absl::InlinedVector<DataRate, kMaxSpatialLayers> layer_start_bitrates = absl::InlinedVector<DataRate, kMaxSpatialLayers> layer_start_bitrates =
@ -283,14 +283,14 @@ class SvcRateAllocatorTestParametrizedContentType
TEST_P(SvcRateAllocatorTestParametrizedContentType, MaxBitrate) { TEST_P(SvcRateAllocatorTestParametrizedContentType, MaxBitrate) {
VideoCodec codec = Configure(1280, 720, 3, 1, is_screen_sharing_); VideoCodec codec = Configure(1280, 720, 3, 1, is_screen_sharing_);
EXPECT_EQ(SvcRateAllocator::GetMaxBitrate(codec), EXPECT_EQ(SvcRateAllocator::GetMaxBitrate(codec),
DataRate::kbps(codec.spatialLayers[0].maxBitrate + DataRate::KilobitsPerSec(codec.spatialLayers[0].maxBitrate +
codec.spatialLayers[1].maxBitrate + codec.spatialLayers[1].maxBitrate +
codec.spatialLayers[2].maxBitrate)); codec.spatialLayers[2].maxBitrate));
// Deactivate middle layer. This causes deactivation of top layer as well. // Deactivate middle layer. This causes deactivation of top layer as well.
codec.spatialLayers[1].active = false; codec.spatialLayers[1].active = false;
EXPECT_EQ(SvcRateAllocator::GetMaxBitrate(codec), EXPECT_EQ(SvcRateAllocator::GetMaxBitrate(codec),
DataRate::kbps(codec.spatialLayers[0].maxBitrate)); DataRate::KilobitsPerSec(codec.spatialLayers[0].maxBitrate));
} }
TEST_P(SvcRateAllocatorTestParametrizedContentType, PaddingBitrate) { TEST_P(SvcRateAllocatorTestParametrizedContentType, PaddingBitrate) {
@ -349,11 +349,12 @@ TEST_P(SvcRateAllocatorTestParametrizedContentType, StableBitrate) {
const DataRate min_rate_three_layers = start_rates[2]; const DataRate min_rate_three_layers = start_rates[2];
const DataRate max_rate_one_layer = const DataRate max_rate_one_layer =
DataRate::kbps(codec.spatialLayers[0].maxBitrate); DataRate::KilobitsPerSec(codec.spatialLayers[0].maxBitrate);
const DataRate max_rate_two_layers = const DataRate max_rate_two_layers =
is_screen_sharing_ ? DataRate::kbps(codec.spatialLayers[0].targetBitrate + is_screen_sharing_
? DataRate::KilobitsPerSec(codec.spatialLayers[0].targetBitrate +
codec.spatialLayers[1].maxBitrate) codec.spatialLayers[1].maxBitrate)
: DataRate::kbps(codec.spatialLayers[0].maxBitrate + : DataRate::KilobitsPerSec(codec.spatialLayers[0].maxBitrate +
codec.spatialLayers[1].maxBitrate); codec.spatialLayers[1].maxBitrate);
SvcRateAllocator allocator = SvcRateAllocator(codec); SvcRateAllocator allocator = SvcRateAllocator(codec);
@ -368,12 +369,12 @@ TEST_P(SvcRateAllocatorTestParametrizedContentType, StableBitrate) {
// Two layers, stable bitrate too low for two layers. // Two layers, stable bitrate too low for two layers.
allocation = allocator.Allocate(VideoBitrateAllocationParameters( allocation = allocator.Allocate(VideoBitrateAllocationParameters(
/*total_bitrate=*/min_rate_two_layers, /*total_bitrate=*/min_rate_two_layers,
/*stable_bitrate=*/min_rate_two_layers - DataRate::bps(1), /*stable_bitrate=*/min_rate_two_layers - DataRate::BitsPerSec(1),
/*fps=*/30.0)); /*fps=*/30.0));
EXPECT_FALSE(allocation.IsSpatialLayerUsed(1)); EXPECT_FALSE(allocation.IsSpatialLayerUsed(1));
EXPECT_EQ( EXPECT_EQ(DataRate::BitsPerSec(allocation.get_sum_bps()),
DataRate::bps(allocation.get_sum_bps()), std::min(min_rate_two_layers - DataRate::BitsPerSec(1),
std::min(min_rate_two_layers - DataRate::bps(1), max_rate_one_layer)); max_rate_one_layer));
// Three layers, stable and target equal. // Three layers, stable and target equal.
allocation = allocator.Allocate(VideoBitrateAllocationParameters( allocation = allocator.Allocate(VideoBitrateAllocationParameters(
@ -385,12 +386,12 @@ TEST_P(SvcRateAllocatorTestParametrizedContentType, StableBitrate) {
// Three layers, stable bitrate too low for three layers. // Three layers, stable bitrate too low for three layers.
allocation = allocator.Allocate(VideoBitrateAllocationParameters( allocation = allocator.Allocate(VideoBitrateAllocationParameters(
/*total_bitrate=*/min_rate_three_layers, /*total_bitrate=*/min_rate_three_layers,
/*stable_bitrate=*/min_rate_three_layers - DataRate::bps(1), /*stable_bitrate=*/min_rate_three_layers - DataRate::BitsPerSec(1),
/*fps=*/30.0)); /*fps=*/30.0));
EXPECT_FALSE(allocation.IsSpatialLayerUsed(2)); EXPECT_FALSE(allocation.IsSpatialLayerUsed(2));
EXPECT_EQ( EXPECT_EQ(DataRate::BitsPerSec(allocation.get_sum_bps()),
DataRate::bps(allocation.get_sum_bps()), std::min(min_rate_three_layers - DataRate::BitsPerSec(1),
std::min(min_rate_three_layers - DataRate::bps(1), max_rate_two_layers)); max_rate_two_layers));
} }
TEST_P(SvcRateAllocatorTestParametrizedContentType, TEST_P(SvcRateAllocatorTestParametrizedContentType,
@ -444,7 +445,8 @@ TEST_P(SvcRateAllocatorTestParametrizedContentType,
// Going below min for two layers, second layer should turn off again. // Going below min for two layers, second layer should turn off again.
allocation = allocator.Allocate(VideoBitrateAllocationParameters( allocation = allocator.Allocate(VideoBitrateAllocationParameters(
/*total_bitrate=*/max_bitrate, /*total_bitrate=*/max_bitrate,
/*stable_bitrate=*/min_rate_two_layers - DataRate::bps(1), /*fps=*/30.0)); /*stable_bitrate=*/min_rate_two_layers - DataRate::BitsPerSec(1),
/*fps=*/30.0));
EXPECT_TRUE(allocation.IsSpatialLayerUsed(0)); EXPECT_TRUE(allocation.IsSpatialLayerUsed(0));
EXPECT_FALSE(allocation.IsSpatialLayerUsed(1)); EXPECT_FALSE(allocation.IsSpatialLayerUsed(1));
EXPECT_FALSE(allocation.IsSpatialLayerUsed(2)); EXPECT_FALSE(allocation.IsSpatialLayerUsed(2));
@ -476,7 +478,7 @@ TEST_P(SvcRateAllocatorTestParametrizedContentType,
// Going below min for three layers, third layer should turn off again. // Going below min for three layers, third layer should turn off again.
allocation = allocator.Allocate(VideoBitrateAllocationParameters( allocation = allocator.Allocate(VideoBitrateAllocationParameters(
/*total_bitrate=*/max_bitrate, /*total_bitrate=*/max_bitrate,
/*stable_bitrate=*/min_rate_three_layers - DataRate::bps(1), /*stable_bitrate=*/min_rate_three_layers - DataRate::BitsPerSec(1),
/*fps=*/30.0)); /*fps=*/30.0));
EXPECT_TRUE(allocation.IsSpatialLayerUsed(0)); EXPECT_TRUE(allocation.IsSpatialLayerUsed(0));
EXPECT_TRUE(allocation.IsSpatialLayerUsed(1)); EXPECT_TRUE(allocation.IsSpatialLayerUsed(1));

View File

@ -1667,7 +1667,7 @@ TEST_F(TestVp9Impl, EncodeWithDynamicRate) {
// Set 300kbps target with 100% headroom. // Set 300kbps target with 100% headroom.
VideoEncoder::RateControlParameters params; VideoEncoder::RateControlParameters params;
params.bandwidth_allocation = DataRate::bps(300000); params.bandwidth_allocation = DataRate::BitsPerSec(300000);
params.bitrate.SetBitrate(0, 0, params.bandwidth_allocation.bps()); params.bitrate.SetBitrate(0, 0, params.bandwidth_allocation.bps());
params.framerate_fps = 30.0; params.framerate_fps = 30.0;

View File

@ -87,7 +87,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
DataRate left_in_stable_allocation = stable_bitrate; DataRate left_in_stable_allocation = stable_bitrate;
if (codec_.maxBitrate) { if (codec_.maxBitrate) {
DataRate max_rate = DataRate::kbps(codec_.maxBitrate); DataRate max_rate = DataRate::KilobitsPerSec(codec_.maxBitrate);
left_in_total_allocation = std::min(left_in_total_allocation, max_rate); left_in_total_allocation = std::min(left_in_total_allocation, max_rate);
left_in_stable_allocation = std::min(left_in_stable_allocation, max_rate); left_in_stable_allocation = std::min(left_in_stable_allocation, max_rate);
} }
@ -97,7 +97,8 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
if (codec_.active) { if (codec_.active) {
allocated_bitrates->SetBitrate( allocated_bitrates->SetBitrate(
0, 0, 0, 0,
std::max(DataRate::kbps(codec_.minBitrate), left_in_total_allocation) std::max(DataRate::KilobitsPerSec(codec_.minBitrate),
left_in_total_allocation)
.bps()); .bps());
} }
return; return;
@ -129,7 +130,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
// Always allocate enough bitrate for the minimum bitrate of the first // Always allocate enough bitrate for the minimum bitrate of the first
// active layer. Suspending below min bitrate is controlled outside the // active layer. Suspending below min bitrate is controlled outside the
// codec implementation and is not overridden by this. // codec implementation and is not overridden by this.
DataRate min_rate = DataRate::kbps( DataRate min_rate = DataRate::KilobitsPerSec(
codec_.simulcastStream[layer_index[active_layer]].minBitrate); codec_.simulcastStream[layer_index[active_layer]].minBitrate);
left_in_total_allocation = std::max(left_in_total_allocation, min_rate); left_in_total_allocation = std::max(left_in_total_allocation, min_rate);
left_in_stable_allocation = std::max(left_in_stable_allocation, min_rate); left_in_stable_allocation = std::max(left_in_stable_allocation, min_rate);
@ -157,8 +158,8 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
} }
// If we can't allocate to the current layer we can't allocate to higher // If we can't allocate to the current layer we can't allocate to higher
// layers because they require a higher minimum bitrate. // layers because they require a higher minimum bitrate.
DataRate min_bitrate = DataRate::kbps(stream.minBitrate); DataRate min_bitrate = DataRate::KilobitsPerSec(stream.minBitrate);
DataRate target_bitrate = DataRate::kbps(stream.targetBitrate); DataRate target_bitrate = DataRate::KilobitsPerSec(stream.targetBitrate);
double hysteresis_factor = double hysteresis_factor =
codec_.mode == VideoCodecMode::kRealtimeVideo codec_.mode == VideoCodecMode::kRealtimeVideo
? stable_rate_settings_.GetVideoHysteresisFactor() ? stable_rate_settings_.GetVideoHysteresisFactor()
@ -193,11 +194,11 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
// better idea of possible performance implications. // better idea of possible performance implications.
if (left_in_total_allocation > DataRate::Zero()) { if (left_in_total_allocation > DataRate::Zero()) {
const SimulcastStream& stream = codec_.simulcastStream[top_active_layer]; const SimulcastStream& stream = codec_.simulcastStream[top_active_layer];
DataRate initial_layer_rate = DataRate initial_layer_rate = DataRate::BitsPerSec(
DataRate::bps(allocated_bitrates->GetSpatialLayerSum(top_active_layer)); allocated_bitrates->GetSpatialLayerSum(top_active_layer));
DataRate additional_allocation = DataRate additional_allocation = std::min(
std::min(left_in_total_allocation, left_in_total_allocation,
DataRate::kbps(stream.maxBitrate) - initial_layer_rate); DataRate::KilobitsPerSec(stream.maxBitrate) - initial_layer_rate);
allocated_bitrates->SetBitrate( allocated_bitrates->SetBitrate(
top_active_layer, 0, top_active_layer, 0,
(initial_layer_rate + additional_allocation).bps()); (initial_layer_rate + additional_allocation).bps());

View File

@ -133,7 +133,7 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
VideoBitrateAllocation GetAllocation(uint32_t target_bitrate) { VideoBitrateAllocation GetAllocation(uint32_t target_bitrate) {
return allocator_->Allocate(VideoBitrateAllocationParameters( return allocator_->Allocate(VideoBitrateAllocationParameters(
DataRate::kbps(target_bitrate), kDefaultFrameRate)); DataRate::KilobitsPerSec(target_bitrate), kDefaultFrameRate));
} }
VideoBitrateAllocation GetAllocation(DataRate target_rate, VideoBitrateAllocation GetAllocation(DataRate target_rate,
@ -143,15 +143,18 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
} }
DataRate MinRate(size_t layer_index) const { DataRate MinRate(size_t layer_index) const {
return DataRate::kbps(codec_.simulcastStream[layer_index].minBitrate); return DataRate::KilobitsPerSec(
codec_.simulcastStream[layer_index].minBitrate);
} }
DataRate TargetRate(size_t layer_index) const { DataRate TargetRate(size_t layer_index) const {
return DataRate::kbps(codec_.simulcastStream[layer_index].targetBitrate); return DataRate::KilobitsPerSec(
codec_.simulcastStream[layer_index].targetBitrate);
} }
DataRate MaxRate(size_t layer_index) const { DataRate MaxRate(size_t layer_index) const {
return DataRate::kbps(codec_.simulcastStream[layer_index].maxBitrate); return DataRate::KilobitsPerSec(
codec_.simulcastStream[layer_index].maxBitrate);
} }
protected: protected:
@ -590,8 +593,8 @@ TEST_F(SimulcastRateAllocatorTest, StableRate) {
// Let stable rate go to a bitrate below what is needed for two streams. // Let stable rate go to a bitrate below what is needed for two streams.
uint32_t expected[] = {MaxRate(0).kbps<uint32_t>(), 0}; uint32_t expected[] = {MaxRate(0).kbps<uint32_t>(), 0};
ExpectEqual(expected, ExpectEqual(expected,
GetAllocation(volatile_rate, GetAllocation(volatile_rate, TargetRate(0) + MinRate(1) -
TargetRate(0) + MinRate(1) - DataRate::bps(1))); DataRate::BitsPerSec(1)));
} }
{ {

View File

@ -364,9 +364,12 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
call_config.audio_state = call_config.audio_state =
channel_manager_->media_engine()->voice().GetAudioState(); channel_manager_->media_engine()->voice().GetAudioState();
FieldTrialParameter<DataRate> min_bandwidth("min", DataRate::kbps(30)); FieldTrialParameter<DataRate> min_bandwidth("min",
FieldTrialParameter<DataRate> start_bandwidth("start", DataRate::kbps(300)); DataRate::KilobitsPerSec(30));
FieldTrialParameter<DataRate> max_bandwidth("max", DataRate::kbps(2000)); FieldTrialParameter<DataRate> start_bandwidth("start",
DataRate::KilobitsPerSec(300));
FieldTrialParameter<DataRate> max_bandwidth("max",
DataRate::KilobitsPerSec(2000));
ParseFieldTrial({&min_bandwidth, &start_bandwidth, &max_bandwidth}, ParseFieldTrial({&min_bandwidth, &start_bandwidth, &max_bandwidth},
trials_->Lookup("WebRTC-PcFactoryDefaultBitrates")); trials_->Lookup("WebRTC-PcFactoryDefaultBitrates"));

View File

@ -51,9 +51,9 @@ absl::optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
absl::optional<ValueWithUnit> result = ParseValueWithUnit(str); absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
if (result) { if (result) {
if (result->unit.empty() || result->unit == "kbps") { if (result->unit.empty() || result->unit == "kbps") {
return DataRate::kbps(result->value); return DataRate::KilobitsPerSec(result->value);
} else if (result->unit == "bps") { } else if (result->unit == "bps") {
return DataRate::bps(result->value); return DataRate::BitsPerSec(result->value);
} }
} }
return absl::nullopt; return absl::nullopt;
@ -64,7 +64,7 @@ absl::optional<DataSize> ParseTypedParameter<DataSize>(std::string str) {
absl::optional<ValueWithUnit> result = ParseValueWithUnit(str); absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
if (result) { if (result) {
if (result->unit.empty() || result->unit == "bytes") if (result->unit.empty() || result->unit == "bytes")
return DataSize::bytes(result->value); return DataSize::Bytes(result->value);
} }
return absl::nullopt; return absl::nullopt;
} }

View File

@ -19,7 +19,7 @@ namespace webrtc {
namespace { namespace {
struct DummyExperiment { struct DummyExperiment {
FieldTrialParameter<DataRate> target_rate = FieldTrialParameter<DataRate> target_rate =
FieldTrialParameter<DataRate>("t", DataRate::kbps(100)); FieldTrialParameter<DataRate>("t", DataRate::KilobitsPerSec(100));
FieldTrialParameter<TimeDelta> period = FieldTrialParameter<TimeDelta> period =
FieldTrialParameter<TimeDelta>("p", TimeDelta::Millis(100)); FieldTrialParameter<TimeDelta>("p", TimeDelta::Millis(100));
FieldTrialOptional<DataSize> max_buffer = FieldTrialOptional<DataSize> max_buffer =
@ -33,20 +33,20 @@ struct DummyExperiment {
TEST(FieldTrialParserUnitsTest, FallsBackToDefaults) { TEST(FieldTrialParserUnitsTest, FallsBackToDefaults) {
DummyExperiment exp(""); DummyExperiment exp("");
EXPECT_EQ(exp.target_rate.Get(), DataRate::kbps(100)); EXPECT_EQ(exp.target_rate.Get(), DataRate::KilobitsPerSec(100));
EXPECT_FALSE(exp.max_buffer.GetOptional().has_value()); EXPECT_FALSE(exp.max_buffer.GetOptional().has_value());
EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(100)); EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(100));
} }
TEST(FieldTrialParserUnitsTest, ParsesUnitParameters) { TEST(FieldTrialParserUnitsTest, ParsesUnitParameters) {
DummyExperiment exp("t:300kbps,b:5bytes,p:300ms"); DummyExperiment exp("t:300kbps,b:5bytes,p:300ms");
EXPECT_EQ(exp.target_rate.Get(), DataRate::kbps(300)); EXPECT_EQ(exp.target_rate.Get(), DataRate::KilobitsPerSec(300));
EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::bytes(5)); EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::Bytes(5));
EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300)); EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300));
} }
TEST(FieldTrialParserUnitsTest, ParsesDefaultUnitParameters) { TEST(FieldTrialParserUnitsTest, ParsesDefaultUnitParameters) {
DummyExperiment exp("t:300,b:5,p:300"); DummyExperiment exp("t:300,b:5,p:300");
EXPECT_EQ(exp.target_rate.Get(), DataRate::kbps(300)); EXPECT_EQ(exp.target_rate.Get(), DataRate::KilobitsPerSec(300));
EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::bytes(5)); EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::Bytes(5));
EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300)); EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300));
} }
TEST(FieldTrialParserUnitsTest, ParsesInfinityParameter) { TEST(FieldTrialParserUnitsTest, ParsesInfinityParameter) {
@ -56,18 +56,19 @@ TEST(FieldTrialParserUnitsTest, ParsesInfinityParameter) {
} }
TEST(FieldTrialParserUnitsTest, ParsesOtherUnitParameters) { TEST(FieldTrialParserUnitsTest, ParsesOtherUnitParameters) {
DummyExperiment exp("t:300bps,p:0.3 seconds,b:8 bytes"); DummyExperiment exp("t:300bps,p:0.3 seconds,b:8 bytes");
EXPECT_EQ(exp.target_rate.Get(), DataRate::bps(300)); EXPECT_EQ(exp.target_rate.Get(), DataRate::BitsPerSec(300));
EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::bytes(8)); EXPECT_EQ(*exp.max_buffer.GetOptional(), DataSize::Bytes(8));
EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300)); EXPECT_EQ(exp.period.Get(), TimeDelta::Millis(300));
} }
TEST(FieldTrialParserUnitsTest, IgnoresOutOfRange) { TEST(FieldTrialParserUnitsTest, IgnoresOutOfRange) {
FieldTrialConstrained<DataRate> rate("r", DataRate::kbps(30), FieldTrialConstrained<DataRate> rate("r", DataRate::KilobitsPerSec(30),
DataRate::kbps(10), DataRate::kbps(100)); DataRate::KilobitsPerSec(10),
DataRate::KilobitsPerSec(100));
FieldTrialConstrained<TimeDelta> delta("d", TimeDelta::Millis(30), FieldTrialConstrained<TimeDelta> delta("d", TimeDelta::Millis(30),
TimeDelta::Millis(10), TimeDelta::Millis(10),
TimeDelta::Millis(100)); TimeDelta::Millis(100));
FieldTrialConstrained<DataSize> size( FieldTrialConstrained<DataSize> size(
"s", DataSize::bytes(30), DataSize::bytes(10), DataSize::bytes(100)); "s", DataSize::Bytes(30), DataSize::Bytes(10), DataSize::Bytes(100));
ParseFieldTrial({&rate, &delta, &size}, "r:0,d:0,s:0"); ParseFieldTrial({&rate, &delta, &size}, "r:0,d:0,s:0");
EXPECT_EQ(rate->kbps(), 30); EXPECT_EQ(rate->kbps(), 30);
EXPECT_EQ(delta->ms(), 30); EXPECT_EQ(delta->ms(), 30);

View File

@ -61,7 +61,7 @@ absl::optional<DataRate> GetExperimentalMinVideoBitrate(VideoCodecType type) {
const absl::optional<int> fallback_min_bitrate_bps = const absl::optional<int> fallback_min_bitrate_bps =
GetFallbackMinBpsFromFieldTrial(type); GetFallbackMinBpsFromFieldTrial(type);
if (fallback_min_bitrate_bps) { if (fallback_min_bitrate_bps) {
return DataRate::bps(*fallback_min_bitrate_bps); return DataRate::BitsPerSec(*fallback_min_bitrate_bps);
} }
if (webrtc::field_trial::IsEnabled(kMinVideoBitrateExperiment)) { if (webrtc::field_trial::IsEnabled(kMinVideoBitrateExperiment)) {

View File

@ -59,16 +59,16 @@ TEST(GetExperimentalMinVideoBitrateTest, BrForAllCodecsIfDefined) {
"WebRTC-Video-MinVideoBitrate/Enabled,br:123kbps/"); "WebRTC-Video-MinVideoBitrate/Enabled,br:123kbps/");
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ( EXPECT_EQ(
GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex), GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
} }
TEST(GetExperimentalMinVideoBitrateTest, BrTrumpsSpecificCodecConfigs) { TEST(GetExperimentalMinVideoBitrateTest, BrTrumpsSpecificCodecConfigs) {
@ -77,16 +77,16 @@ TEST(GetExperimentalMinVideoBitrateTest, BrTrumpsSpecificCodecConfigs) {
"Enabled,br:123kbps,vp8_br:100kbps,vp9_br:200kbps,h264_br:300kbps/"); "Enabled,br:123kbps,vp8_br:100kbps,vp9_br:200kbps,h264_br:300kbps/");
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
EXPECT_EQ( EXPECT_EQ(
GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex), GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex),
absl::make_optional(DataRate::kbps(123))); absl::make_optional(DataRate::KilobitsPerSec(123)));
} }
TEST(GetExperimentalMinVideoBitrateTest, TEST(GetExperimentalMinVideoBitrateTest,
@ -116,11 +116,11 @@ TEST(GetExperimentalMinVideoBitrateTest, SpecificCodecConfigsUsedIfExpEnabled) {
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric),
absl::nullopt); absl::nullopt);
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8),
absl::make_optional(DataRate::kbps(100))); absl::make_optional(DataRate::KilobitsPerSec(100)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9),
absl::make_optional(DataRate::kbps(200))); absl::make_optional(DataRate::KilobitsPerSec(200)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264),
absl::make_optional(DataRate::kbps(300))); absl::make_optional(DataRate::KilobitsPerSec(300)));
EXPECT_EQ( EXPECT_EQ(
GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex), GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex),
absl::nullopt); absl::nullopt);
@ -135,7 +135,7 @@ TEST(GetExperimentalMinVideoBitrateTest,
"Enabled-444444,555555,666666/"); "Enabled-444444,555555,666666/");
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP8),
absl::make_optional(DataRate::bps(666666))); absl::make_optional(DataRate::BitsPerSec(666666)));
} }
TEST(GetExperimentalMinVideoBitrateTest, TEST(GetExperimentalMinVideoBitrateTest,
@ -149,9 +149,9 @@ TEST(GetExperimentalMinVideoBitrateTest,
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecGeneric),
absl::nullopt); absl::nullopt);
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecVP9),
absl::make_optional(DataRate::kbps(200))); absl::make_optional(DataRate::KilobitsPerSec(200)));
EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264), EXPECT_EQ(GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecH264),
absl::make_optional(DataRate::kbps(300))); absl::make_optional(DataRate::KilobitsPerSec(300)));
EXPECT_EQ( EXPECT_EQ(
GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex), GetExperimentalMinVideoBitrate(VideoCodecType::kVideoCodecMultiplex),
absl::nullopt); absl::nullopt);

View File

@ -118,11 +118,11 @@ bool SampleStats<DataRate>::IsEmpty() {
} }
DataRate SampleStats<DataRate>::Max() { DataRate SampleStats<DataRate>::Max() {
return DataRate::bps(stats_.Max()); return DataRate::BitsPerSec(stats_.Max());
} }
DataRate SampleStats<DataRate>::Mean() { DataRate SampleStats<DataRate>::Mean() {
return DataRate::bps(stats_.Mean()); return DataRate::BitsPerSec(stats_.Mean());
} }
DataRate SampleStats<DataRate>::Median() { DataRate SampleStats<DataRate>::Median() {
@ -130,19 +130,19 @@ DataRate SampleStats<DataRate>::Median() {
} }
DataRate SampleStats<DataRate>::Quantile(double quantile) { DataRate SampleStats<DataRate>::Quantile(double quantile) {
return DataRate::bps(stats_.Quantile(quantile)); return DataRate::BitsPerSec(stats_.Quantile(quantile));
} }
DataRate SampleStats<DataRate>::Min() { DataRate SampleStats<DataRate>::Min() {
return DataRate::bps(stats_.Min()); return DataRate::BitsPerSec(stats_.Min());
} }
DataRate SampleStats<DataRate>::Variance() { DataRate SampleStats<DataRate>::Variance() {
return DataRate::bps(stats_.Variance()); return DataRate::BitsPerSec(stats_.Variance());
} }
DataRate SampleStats<DataRate>::StandardDeviation() { DataRate SampleStats<DataRate>::StandardDeviation() {
return DataRate::bps(stats_.StandardDeviation()); return DataRate::BitsPerSec(stats_.StandardDeviation());
} }
int SampleStats<DataRate>::Count() { int SampleStats<DataRate>::Count() {

View File

@ -1229,7 +1229,8 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) {
static const uint32_t kDefaultStartBitrateBps = 300000; static const uint32_t kDefaultStartBitrateBps = 300000;
NetworkControllerConfig cc_config; NetworkControllerConfig cc_config;
cc_config.constraints.at_time = Timestamp::Micros(clock.TimeInMicroseconds()); cc_config.constraints.at_time = Timestamp::Micros(clock.TimeInMicroseconds());
cc_config.constraints.starting_rate = DataRate::bps(kDefaultStartBitrateBps); cc_config.constraints.starting_rate =
DataRate::BitsPerSec(kDefaultStartBitrateBps);
cc_config.event_log = &null_event_log; cc_config.event_log = &null_event_log;
auto goog_cc = factory.Create(cc_config); auto goog_cc = factory.Create(cc_config);

View File

@ -33,8 +33,8 @@ void LogBasedNetworkControllerSimulation::ProcessUntil(Timestamp to_time) {
if (last_process_.IsInfinite()) { if (last_process_.IsInfinite()) {
NetworkControllerConfig config; NetworkControllerConfig config;
config.constraints.at_time = to_time; config.constraints.at_time = to_time;
config.constraints.min_data_rate = DataRate::kbps(30); config.constraints.min_data_rate = DataRate::KilobitsPerSec(30);
config.constraints.starting_rate = DataRate::kbps(300); config.constraints.starting_rate = DataRate::KilobitsPerSec(300);
config.event_log = &null_event_log_; config.event_log = &null_event_log_;
controller_ = factory_->Create(config); controller_ = factory_->Create(config);
} }
@ -168,8 +168,8 @@ void LogBasedNetworkControllerSimulation::OnIceConfig(
ProcessUntil(log_time); ProcessUntil(log_time);
NetworkRouteChange msg; NetworkRouteChange msg;
msg.at_time = log_time; msg.at_time = log_time;
msg.constraints.min_data_rate = DataRate::kbps(30); msg.constraints.min_data_rate = DataRate::KilobitsPerSec(30);
msg.constraints.starting_rate = DataRate::kbps(300); msg.constraints.starting_rate = DataRate::KilobitsPerSec(300);
msg.constraints.at_time = log_time; msg.constraints.at_time = log_time;
HandleStateUpdate(controller_->OnNetworkRouteChange(msg)); HandleStateUpdate(controller_->OnNetworkRouteChange(msg));
} }

View File

@ -29,8 +29,8 @@ namespace test {
struct RandomWalkConfig { struct RandomWalkConfig {
int random_seed = 1; int random_seed = 1;
DataRate peak_rate = DataRate::kbps(100); DataRate peak_rate = DataRate::KilobitsPerSec(100);
DataSize min_packet_size = DataSize::bytes(200); DataSize min_packet_size = DataSize::Bytes(200);
TimeDelta min_packet_interval = TimeDelta::Millis(1); TimeDelta min_packet_interval = TimeDelta::Millis(1);
TimeDelta update_interval = TimeDelta::Millis(200); TimeDelta update_interval = TimeDelta::Millis(200);
double variance = 0.6; double variance = 0.6;
@ -63,8 +63,8 @@ class RandomWalkCrossTraffic {
}; };
struct PulsedPeaksConfig { struct PulsedPeaksConfig {
DataRate peak_rate = DataRate::kbps(100); DataRate peak_rate = DataRate::KilobitsPerSec(100);
DataSize min_packet_size = DataSize::bytes(200); DataSize min_packet_size = DataSize::Bytes(200);
TimeDelta min_packet_interval = TimeDelta::Millis(1); TimeDelta min_packet_interval = TimeDelta::Millis(1);
TimeDelta send_duration = TimeDelta::Millis(100); TimeDelta send_duration = TimeDelta::Millis(100);
TimeDelta hold_duration = TimeDelta::Millis(2000); TimeDelta hold_duration = TimeDelta::Millis(2000);
@ -150,7 +150,7 @@ class TcpMessageRouteImpl final : public TcpMessageRoute {
}; };
struct FakeTcpConfig { struct FakeTcpConfig {
DataSize packet_size = DataSize::bytes(1200); DataSize packet_size = DataSize::Bytes(1200);
DataSize send_limit = DataSize::PlusInfinity(); DataSize send_limit = DataSize::PlusInfinity();
TimeDelta process_interval = TimeDelta::Millis(200); TimeDelta process_interval = TimeDelta::Millis(200);
TimeDelta packet_timeout = TimeDelta::Seconds(1); TimeDelta packet_timeout = TimeDelta::Seconds(1);

View File

@ -70,8 +70,8 @@ TEST(CrossTrafficTest, PulsedPeaksCrossTraffic) {
TrafficRoute traffic(&fixture.clock, &fixture.counter, &fixture.endpoint); TrafficRoute traffic(&fixture.clock, &fixture.counter, &fixture.endpoint);
PulsedPeaksConfig config; PulsedPeaksConfig config;
config.peak_rate = DataRate::kbps(1000); config.peak_rate = DataRate::KilobitsPerSec(1000);
config.min_packet_size = DataSize::bytes(1); config.min_packet_size = DataSize::Bytes(1);
config.min_packet_interval = TimeDelta::Millis(25); config.min_packet_interval = TimeDelta::Millis(25);
config.send_duration = TimeDelta::Millis(500); config.send_duration = TimeDelta::Millis(500);
config.hold_duration = TimeDelta::Millis(250); config.hold_duration = TimeDelta::Millis(250);
@ -95,8 +95,8 @@ TEST(CrossTrafficTest, RandomWalkCrossTraffic) {
TrafficRoute traffic(&fixture.clock, &fixture.counter, &fixture.endpoint); TrafficRoute traffic(&fixture.clock, &fixture.counter, &fixture.endpoint);
RandomWalkConfig config; RandomWalkConfig config;
config.peak_rate = DataRate::kbps(1000); config.peak_rate = DataRate::KilobitsPerSec(1000);
config.min_packet_size = DataSize::bytes(1); config.min_packet_size = DataSize::Bytes(1);
config.min_packet_interval = TimeDelta::Millis(25); config.min_packet_interval = TimeDelta::Millis(25);
config.update_interval = TimeDelta::Millis(500); config.update_interval = TimeDelta::Millis(500);
config.variance = 0.0; config.variance = 0.0;

View File

@ -37,7 +37,7 @@ void FeedbackGeneratorImpl::Sleep(TimeDelta duration) {
void FeedbackGeneratorImpl::SendPacket(size_t size) { void FeedbackGeneratorImpl::SendPacket(size_t size) {
SentPacket sent; SentPacket sent;
sent.send_time = Now(); sent.send_time = Now();
sent.size = DataSize::bytes(size); sent.size = DataSize::Bytes(size);
sent.sequence_number = sequence_number_++; sent.sequence_number = sequence_number_++;
route_.SendRequest(size, sent); route_.SendRequest(size, sent);
} }

View File

@ -215,11 +215,11 @@ void EmulatedEndpointImpl::SendPacket(const rtc::SocketAddress& from,
Timestamp current_time = clock_->CurrentTime(); Timestamp current_time = clock_->CurrentTime();
if (stats_.first_packet_sent_time.IsInfinite()) { if (stats_.first_packet_sent_time.IsInfinite()) {
stats_.first_packet_sent_time = current_time; stats_.first_packet_sent_time = current_time;
stats_.first_sent_packet_size = DataSize::bytes(packet.ip_packet_size()); stats_.first_sent_packet_size = DataSize::Bytes(packet.ip_packet_size());
} }
stats_.last_packet_sent_time = current_time; stats_.last_packet_sent_time = current_time;
stats_.packets_sent++; stats_.packets_sent++;
stats_.bytes_sent += DataSize::bytes(packet.ip_packet_size()); stats_.bytes_sent += DataSize::Bytes(packet.ip_packet_size());
router_.OnPacketReceived(std::move(packet)); router_.OnPacketReceived(std::move(packet));
}); });
@ -291,7 +291,7 @@ void EmulatedEndpointImpl::OnPacketReceived(EmulatedIpPacket packet) {
RTC_LOG(INFO) << "Drop packet: no receiver registered in " << id_ RTC_LOG(INFO) << "Drop packet: no receiver registered in " << id_
<< " on port " << packet.to.port(); << " on port " << packet.to.port();
stats_.packets_dropped++; stats_.packets_dropped++;
stats_.bytes_dropped += DataSize::bytes(packet.ip_packet_size()); stats_.bytes_dropped += DataSize::Bytes(packet.ip_packet_size());
return; return;
} }
// Endpoint assumes frequent calls to bind and unbind methods, so it holds // Endpoint assumes frequent calls to bind and unbind methods, so it holds
@ -328,11 +328,11 @@ void EmulatedEndpointImpl::UpdateReceiveStats(const EmulatedIpPacket& packet) {
if (stats_.first_packet_received_time.IsInfinite()) { if (stats_.first_packet_received_time.IsInfinite()) {
stats_.first_packet_received_time = current_time; stats_.first_packet_received_time = current_time;
stats_.first_received_packet_size = stats_.first_received_packet_size =
DataSize::bytes(packet.ip_packet_size()); DataSize::Bytes(packet.ip_packet_size());
} }
stats_.last_packet_received_time = current_time; stats_.last_packet_received_time = current_time;
stats_.packets_received++; stats_.packets_received++;
stats_.bytes_received += DataSize::bytes(packet.ip_packet_size()); stats_.bytes_received += DataSize::Bytes(packet.ip_packet_size());
} }
EndpointsContainer::EndpointsContainer( EndpointsContainer::EndpointsContainer(

View File

@ -104,7 +104,7 @@ class CallClient : public EmulatedNetworkReceiverInterface {
ColumnPrinter StatsPrinter(); ColumnPrinter StatsPrinter();
Call::Stats GetStats(); Call::Stats GetStats();
DataRate send_bandwidth() { DataRate send_bandwidth() {
return DataRate::bps(GetStats().send_bandwidth_bps); return DataRate::BitsPerSec(GetStats().send_bandwidth_bps);
} }
DataRate target_rate() const; DataRate target_rate() const;
DataRate stable_target_rate() const; DataRate stable_target_rate() const;

View File

@ -131,8 +131,8 @@ CallClientPair* Scenario::CreateRoutes(
CallClient* second, CallClient* second,
std::vector<EmulatedNetworkNode*> return_link) { std::vector<EmulatedNetworkNode*> return_link) {
return CreateRoutes(first, send_link, return CreateRoutes(first, send_link,
DataSize::bytes(PacketOverhead::kDefault), second, DataSize::Bytes(PacketOverhead::kDefault), second,
return_link, DataSize::bytes(PacketOverhead::kDefault)); return_link, DataSize::Bytes(PacketOverhead::kDefault));
} }
CallClientPair* Scenario::CreateRoutes( CallClientPair* Scenario::CreateRoutes(
@ -151,7 +151,7 @@ CallClientPair* Scenario::CreateRoutes(
void Scenario::ChangeRoute(std::pair<CallClient*, CallClient*> clients, void Scenario::ChangeRoute(std::pair<CallClient*, CallClient*> clients,
std::vector<EmulatedNetworkNode*> over_nodes) { std::vector<EmulatedNetworkNode*> over_nodes) {
ChangeRoute(clients, over_nodes, DataSize::bytes(PacketOverhead::kDefault)); ChangeRoute(clients, over_nodes, DataSize::Bytes(PacketOverhead::kDefault));
} }
void Scenario::ChangeRoute(std::pair<CallClient*, CallClient*> clients, void Scenario::ChangeRoute(std::pair<CallClient*, CallClient*> clients,

View File

@ -42,9 +42,9 @@ struct TransportControllerConfig {
Rates(); Rates();
Rates(const Rates&); Rates(const Rates&);
~Rates(); ~Rates();
DataRate min_rate = DataRate::kbps(30); DataRate min_rate = DataRate::KilobitsPerSec(30);
DataRate max_rate = DataRate::kbps(3000); DataRate max_rate = DataRate::KilobitsPerSec(3000);
DataRate start_rate = DataRate::kbps(300); DataRate start_rate = DataRate::KilobitsPerSec(300);
} rates; } rates;
NetworkControllerFactoryInterface* cc_factory = nullptr; NetworkControllerFactoryInterface* cc_factory = nullptr;
TimeDelta state_log_interval = TimeDelta::Millis(100); TimeDelta state_log_interval = TimeDelta::Millis(100);
@ -61,10 +61,10 @@ struct PacketStreamConfig {
~PacketStreamConfig(); ~PacketStreamConfig();
int frame_rate = 30; int frame_rate = 30;
DataRate max_data_rate = DataRate::Infinity(); DataRate max_data_rate = DataRate::Infinity();
DataSize max_packet_size = DataSize::bytes(1400); DataSize max_packet_size = DataSize::Bytes(1400);
DataSize min_frame_size = DataSize::bytes(100); DataSize min_frame_size = DataSize::Bytes(100);
double keyframe_multiplier = 1; double keyframe_multiplier = 1;
DataSize packet_overhead = DataSize::bytes(PacketOverhead::kDefault); DataSize packet_overhead = DataSize::Bytes(PacketOverhead::kDefault);
}; };
struct VideoStreamConfig { struct VideoStreamConfig {

View File

@ -40,7 +40,7 @@ struct CallTestConfig {
Scenario() Scenario()
: random_seed("rs", 1), : random_seed("rs", 1),
return_traffic("ret"), return_traffic("ret"),
capacity("bw", DataRate::kbps(300)), capacity("bw", DataRate::KilobitsPerSec(300)),
propagation_delay("dl", TimeDelta::Millis(100)), propagation_delay("dl", TimeDelta::Millis(100)),
cross_traffic("ct", DataRate::Zero()), cross_traffic("ct", DataRate::Zero()),
delay_noise("dn", TimeDelta::Zero()), delay_noise("dn", TimeDelta::Zero()),
@ -60,7 +60,7 @@ struct CallTestConfig {
Tuning() Tuning()
: use_bbr("bbr"), : use_bbr("bbr"),
bbr_no_target_rate("notr"), bbr_no_target_rate("notr"),
bbr_initial_window("iw", DataSize::bytes(8000)), bbr_initial_window("iw", DataSize::Bytes(8000)),
bbr_encoder_gain("eg", 0.8) {} bbr_encoder_gain("eg", 0.8) {}
void Parse(std::string config_str) { void Parse(std::string config_str) {
ParseFieldTrial( ParseFieldTrial(
@ -151,8 +151,8 @@ TEST_P(BbrScenarioTest, ReceivesVideo) {
if (conf_.tuning.use_bbr) { if (conf_.tuning.use_bbr) {
call_config.transport.cc_factory = &bbr_factory; call_config.transport.cc_factory = &bbr_factory;
} }
call_config.transport.rates.min_rate = DataRate::kbps(30); call_config.transport.rates.min_rate = DataRate::KilobitsPerSec(30);
call_config.transport.rates.max_rate = DataRate::kbps(1800); call_config.transport.rates.max_rate = DataRate::KilobitsPerSec(1800);
CallClient* alice = s.CreateClient("send", call_config); CallClient* alice = s.CreateClient("send", call_config);
CallClient* bob = s.CreateClient("return", call_config); CallClient* bob = s.CreateClient("return", call_config);
@ -168,12 +168,12 @@ TEST_P(BbrScenarioTest, ReceivesVideo) {
VideoStreamPair* alice_video = VideoStreamPair* alice_video =
s.CreateVideoStream(route->forward(), [&](VideoStreamConfig* c) { s.CreateVideoStream(route->forward(), [&](VideoStreamConfig* c) {
c->encoder.fake.max_rate = DataRate::kbps(1800); c->encoder.fake.max_rate = DataRate::KilobitsPerSec(1800);
}); });
s.CreateAudioStream(route->forward(), [&](AudioStreamConfig* c) { s.CreateAudioStream(route->forward(), [&](AudioStreamConfig* c) {
if (conf_.tuning.use_bbr) { if (conf_.tuning.use_bbr) {
c->stream.in_bandwidth_estimation = true; c->stream.in_bandwidth_estimation = true;
c->encoder.fixed_rate = DataRate::kbps(31); c->encoder.fixed_rate = DataRate::KilobitsPerSec(31);
} }
}); });
@ -181,12 +181,12 @@ TEST_P(BbrScenarioTest, ReceivesVideo) {
if (conf_.scenario.return_traffic) { if (conf_.scenario.return_traffic) {
bob_video = bob_video =
s.CreateVideoStream(route->reverse(), [&](VideoStreamConfig* c) { s.CreateVideoStream(route->reverse(), [&](VideoStreamConfig* c) {
c->encoder.fake.max_rate = DataRate::kbps(1800); c->encoder.fake.max_rate = DataRate::KilobitsPerSec(1800);
}); });
s.CreateAudioStream(route->reverse(), [&](AudioStreamConfig* c) { s.CreateAudioStream(route->reverse(), [&](AudioStreamConfig* c) {
if (conf_.tuning.use_bbr) { if (conf_.tuning.use_bbr) {
c->stream.in_bandwidth_estimation = true; c->stream.in_bandwidth_estimation = true;
c->encoder.fixed_rate = DataRate::kbps(31); c->encoder.fixed_rate = DataRate::KilobitsPerSec(31);
} }
}); });
} }

View File

@ -22,7 +22,7 @@ TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
std::atomic<bool> bitrate_changed(false); std::atomic<bool> bitrate_changed(false);
Scenario s; Scenario s;
CallClientConfig call_client_config; CallClientConfig call_client_config;
call_client_config.transport.rates.start_rate = DataRate::kbps(300); call_client_config.transport.rates.start_rate = DataRate::KilobitsPerSec(300);
auto* alice = s.CreateClient("alice", call_client_config); auto* alice = s.CreateClient("alice", call_client_config);
auto* bob = s.CreateClient("bob", call_client_config); auto* bob = s.CreateClient("bob", call_client_config);
NetworkSimulationConfig network_config; NetworkSimulationConfig network_config;
@ -35,8 +35,8 @@ TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
s.CreateVideoStream(route->reverse(), video_stream_config); s.CreateVideoStream(route->reverse(), video_stream_config);
AudioStreamConfig audio_stream_config; AudioStreamConfig audio_stream_config;
audio_stream_config.encoder.min_rate = DataRate::kbps(6); audio_stream_config.encoder.min_rate = DataRate::KilobitsPerSec(6);
audio_stream_config.encoder.max_rate = DataRate::kbps(64); audio_stream_config.encoder.max_rate = DataRate::KilobitsPerSec(64);
audio_stream_config.encoder.allocate_bitrate = true; audio_stream_config.encoder.allocate_bitrate = true;
audio_stream_config.stream.in_bandwidth_estimation = false; audio_stream_config.stream.in_bandwidth_estimation = false;
s.CreateAudioStream(route->forward(), audio_stream_config); s.CreateAudioStream(route->forward(), audio_stream_config);
@ -66,7 +66,7 @@ void SetupVideoCall(Scenario& s, VideoQualityAnalyzer* analyzer) {
auto* alice = s.CreateClient("alice", call_config); auto* alice = s.CreateClient("alice", call_config);
auto* bob = s.CreateClient("bob", call_config); auto* bob = s.CreateClient("bob", call_config);
NetworkSimulationConfig network_config; NetworkSimulationConfig network_config;
network_config.bandwidth = DataRate::kbps(1000); network_config.bandwidth = DataRate::KilobitsPerSec(1000);
network_config.delay = TimeDelta::Millis(50); network_config.delay = TimeDelta::Millis(50);
auto alice_net = s.CreateSimulationNode(network_config); auto alice_net = s.CreateSimulationNode(network_config);
auto bob_net = s.CreateSimulationNode(network_config); auto bob_net = s.CreateSimulationNode(network_config);

View File

@ -167,7 +167,7 @@ void VideoSendStatsCollector::AddStats(VideoSendStream::Stats sample,
kv.second.rtp_stats.fec.padding_bytes; kv.second.rtp_stats.fec.padding_bytes;
} }
if (last_update_.IsFinite()) { if (last_update_.IsFinite()) {
auto fec_delta = DataSize::bytes(fec_bytes - last_fec_bytes_); auto fec_delta = DataSize::Bytes(fec_bytes - last_fec_bytes_);
auto time_delta = at_time - last_update_; auto time_delta = at_time - last_update_;
stats_.fec_bitrate.AddSample(fec_delta / time_delta); stats_.fec_bitrate.AddSample(fec_delta / time_delta);
} }

View File

@ -46,7 +46,7 @@ TEST(ScenarioAnalyzerTest, PsnrIsHighWhenNetworkIsGood) {
{ {
Scenario s; Scenario s;
NetworkSimulationConfig good_network; NetworkSimulationConfig good_network;
good_network.bandwidth = DataRate::kbps(1000); good_network.bandwidth = DataRate::KilobitsPerSec(1000);
CreateAnalyzedStream(&s, good_network, &analyzer, &stats); CreateAnalyzedStream(&s, good_network, &analyzer, &stats);
s.RunFor(TimeDelta::Seconds(3)); s.RunFor(TimeDelta::Seconds(3));
} }
@ -67,7 +67,7 @@ TEST(ScenarioAnalyzerTest, PsnrIsLowWhenNetworkIsBad) {
{ {
Scenario s; Scenario s;
NetworkSimulationConfig bad_network; NetworkSimulationConfig bad_network;
bad_network.bandwidth = DataRate::kbps(100); bad_network.bandwidth = DataRate::KilobitsPerSec(100);
bad_network.loss_rate = 0.02; bad_network.loss_rate = 0.02;
CreateAnalyzedStream(&s, bad_network, &analyzer, &stats); CreateAnalyzedStream(&s, bad_network, &analyzer, &stats);
s.RunFor(TimeDelta::Seconds(3)); s.RunFor(TimeDelta::Seconds(3));

View File

@ -256,7 +256,8 @@ VideoEncoderConfig CreateVideoEncoderConfig(VideoStreamConfig config) {
// TODO(srte): Base this on encoder capabilities. // TODO(srte): Base this on encoder capabilities.
encoder_config.max_bitrate_bps = encoder_config.max_bitrate_bps =
config.encoder.max_data_rate.value_or(DataRate::kbps(10000)).bps(); config.encoder.max_data_rate.value_or(DataRate::KilobitsPerSec(10000))
.bps();
encoder_config.encoder_specific_settings = encoder_config.encoder_specific_settings =
CreateEncoderSpecificSettings(config); CreateEncoderSpecificSettings(config);

View File

@ -109,7 +109,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
LayerRateInfo& layer_info = layer_infos.back(); LayerRateInfo& layer_info = layer_infos.back();
layer_info.target_rate = layer_info.target_rate =
DataRate::bps(rates.bitrate.GetSpatialLayerSum(si)); DataRate::BitsPerSec(rates.bitrate.GetSpatialLayerSum(si));
// Adjustment is done per spatial layer only (not per temporal layer). // Adjustment is done per spatial layer only (not per temporal layer).
if (frames_since_layout_change_ < kMinFramesSinceLayoutChange) { if (frames_since_layout_change_ < kMinFramesSinceLayoutChange) {
@ -186,8 +186,8 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
// Available link headroom that can be used to fill wanted overshoot. // Available link headroom that can be used to fill wanted overshoot.
DataRate available_headroom = DataRate::Zero(); DataRate available_headroom = DataRate::Zero();
if (utilize_bandwidth_headroom_) { if (utilize_bandwidth_headroom_) {
available_headroom = available_headroom = rates.bandwidth_allocation -
rates.bandwidth_allocation - DataRate::bps(rates.bitrate.get_sum_bps()); DataRate::BitsPerSec(rates.bitrate.get_sum_bps());
} }
// All wanted overshoots are satisfied in the same proportion based on // All wanted overshoots are satisfied in the same proportion based on
@ -214,7 +214,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
if (min_bitrates_bps_[si] > 0 && if (min_bitrates_bps_[si] > 0 &&
layer_info.target_rate > DataRate::Zero() && layer_info.target_rate > DataRate::Zero() &&
DataRate::bps(min_bitrates_bps_[si]) < layer_info.target_rate) { DataRate::BitsPerSec(min_bitrates_bps_[si]) < layer_info.target_rate) {
// Make sure rate adjuster doesn't push target bitrate below minimum. // Make sure rate adjuster doesn't push target bitrate below minimum.
utilization_factor = utilization_factor =
std::min(utilization_factor, layer_info.target_rate.bps<double>() / std::min(utilization_factor, layer_info.target_rate.bps<double>() /
@ -236,7 +236,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
// Populate the adjusted allocation with determined utilization factor. // Populate the adjusted allocation with determined utilization factor.
if (active_tls_[si] == 1 && if (active_tls_[si] == 1 &&
layer_info.target_rate > layer_info.target_rate >
DataRate::bps(rates.bitrate.GetBitrate(si, 0))) { DataRate::BitsPerSec(rates.bitrate.GetBitrate(si, 0))) {
// Bitrate allocation indicates temporal layer usage, but encoder // Bitrate allocation indicates temporal layer usage, but encoder
// does not seem to support it. Pipe all bitrate into a single // does not seem to support it. Pipe all bitrate into a single
// overshoot detector. // overshoot detector.
@ -283,7 +283,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
VideoEncoder::EncoderInfo::kMaxFramerateFraction; VideoEncoder::EncoderInfo::kMaxFramerateFraction;
overshoot_detectors_[si][ti]->SetTargetRate( overshoot_detectors_[si][ti]->SetTargetRate(
DataRate::bps(layer_bitrate_bps), DataRate::BitsPerSec(layer_bitrate_bps),
fps_fraction * rates.framerate_fps, now_ms); fps_fraction * rates.framerate_fps, now_ms);
} }
} }

View File

@ -34,7 +34,7 @@ class EncoderBitrateAdjusterTest : public ::testing::Test {
static_assert(kSequenceLength % 2 == 0, "Sequence length must be even."); static_assert(kSequenceLength % 2 == 0, "Sequence length must be even.");
EncoderBitrateAdjusterTest() EncoderBitrateAdjusterTest()
: target_bitrate_(DataRate::bps(kDefaultBitrateBps)), : target_bitrate_(DataRate::BitsPerSec(kDefaultBitrateBps)),
target_framerate_fps_(kDefaultFrameRateFps), target_framerate_fps_(kDefaultFrameRateFps),
tl_pattern_idx_{}, tl_pattern_idx_{},
sequence_idx_{} {} sequence_idx_{} {}
@ -478,7 +478,8 @@ TEST_F(EncoderBitrateAdjusterTest, HeadroomAllowsOvershootToMediaRate) {
current_adjusted_allocation_ = current_adjusted_allocation_ =
adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters( adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters(
current_input_allocation_, target_framerate_fps_, current_input_allocation_, target_framerate_fps_,
DataRate::bps(current_input_allocation_.get_sum_bps() * 1.1))); DataRate::BitsPerSec(current_input_allocation_.get_sum_bps() *
1.1)));
ExpectNear(current_input_allocation_, current_adjusted_allocation_, 0.01); ExpectNear(current_input_allocation_, current_adjusted_allocation_, 0.01);
} }
} }
@ -520,7 +521,7 @@ TEST_F(EncoderBitrateAdjusterTest, DontExceedMediaRateEvenWithHeadroom) {
current_adjusted_allocation_ = current_adjusted_allocation_ =
adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters( adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters(
current_input_allocation_, target_framerate_fps_, current_input_allocation_, target_framerate_fps_,
DataRate::bps(current_input_allocation_.get_sum_bps() * 2))); DataRate::BitsPerSec(current_input_allocation_.get_sum_bps() * 2)));
ExpectNear(MultiplyAllocation(current_input_allocation_, 1 / 1.1), ExpectNear(MultiplyAllocation(current_input_allocation_, 1 / 1.1),
current_adjusted_allocation_, 0.015); current_adjusted_allocation_, 0.015);
} }

View File

@ -23,7 +23,7 @@ class EncoderOvershootDetectorTest : public ::testing::Test {
static constexpr double kDefaultFrameRateFps = 15; static constexpr double kDefaultFrameRateFps = 15;
EncoderOvershootDetectorTest() EncoderOvershootDetectorTest()
: detector_(kWindowSizeMs), : detector_(kWindowSizeMs),
target_bitrate_(DataRate::bps(kDefaultBitrateBps)), target_bitrate_(DataRate::BitsPerSec(kDefaultBitrateBps)),
target_framerate_fps_(kDefaultFrameRateFps) {} target_framerate_fps_(kDefaultFrameRateFps) {}
protected: protected:
@ -111,7 +111,7 @@ TEST_F(EncoderOvershootDetectorTest, ConstantOvershootVaryingRates) {
RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs); RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs);
target_framerate_fps_ /= 2; target_framerate_fps_ /= 2;
RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs / 2); RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs / 2);
target_bitrate_ = DataRate::bps(target_bitrate_.bps() / 2); target_bitrate_ = DataRate::BitsPerSec(target_bitrate_.bps() / 2);
RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs / 2); RunConstantUtilizationTest(1.2, 1.2, 0.01, kWindowSizeMs / 2);
} }

View File

@ -624,24 +624,25 @@ uint32_t VideoSendStreamImpl::OnBitrateUpdated(BitrateAllocationUpdate update) {
DataRate link_allocation = DataRate::Zero(); DataRate link_allocation = DataRate::Zero();
if (encoder_target_rate_bps_ > protection_bitrate_bps) { if (encoder_target_rate_bps_ > protection_bitrate_bps) {
link_allocation = link_allocation =
DataRate::bps(encoder_target_rate_bps_ - protection_bitrate_bps); DataRate::BitsPerSec(encoder_target_rate_bps_ - protection_bitrate_bps);
} }
DataRate overhead = DataRate overhead =
update.target_bitrate - DataRate::bps(encoder_target_rate_bps_); update.target_bitrate - DataRate::BitsPerSec(encoder_target_rate_bps_);
DataRate encoder_stable_target_rate = update.stable_target_bitrate; DataRate encoder_stable_target_rate = update.stable_target_bitrate;
if (encoder_stable_target_rate > overhead) { if (encoder_stable_target_rate > overhead) {
encoder_stable_target_rate = encoder_stable_target_rate - overhead; encoder_stable_target_rate = encoder_stable_target_rate - overhead;
} else { } else {
encoder_stable_target_rate = DataRate::bps(encoder_target_rate_bps_); encoder_stable_target_rate = DataRate::BitsPerSec(encoder_target_rate_bps_);
} }
encoder_target_rate_bps_ = encoder_target_rate_bps_ =
std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_); std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_);
encoder_stable_target_rate = std::min(DataRate::bps(encoder_max_bitrate_bps_), encoder_stable_target_rate =
std::min(DataRate::BitsPerSec(encoder_max_bitrate_bps_),
encoder_stable_target_rate); encoder_stable_target_rate);
DataRate encoder_target_rate = DataRate::bps(encoder_target_rate_bps_); DataRate encoder_target_rate = DataRate::BitsPerSec(encoder_target_rate_bps_);
link_allocation = std::max(encoder_target_rate, link_allocation); link_allocation = std::max(encoder_target_rate, link_allocation);
video_stream_encoder_->OnBitrateUpdated( video_stream_encoder_->OnBitrateUpdated(
encoder_target_rate, encoder_stable_target_rate, link_allocation, encoder_target_rate, encoder_stable_target_rate, link_allocation,

View File

@ -88,7 +88,7 @@ class MockRtpVideoSender : public RtpVideoSenderInterface {
BitrateAllocationUpdate CreateAllocation(int bitrate_bps) { BitrateAllocationUpdate CreateAllocation(int bitrate_bps) {
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(bitrate_bps); update.target_bitrate = DataRate::BitsPerSec(bitrate_bps);
update.packet_loss_ratio = 0; update.packet_loss_ratio = 0;
update.round_trip_time = TimeDelta::Zero(); update.round_trip_time = TimeDelta::Zero();
return update; return update;
@ -695,7 +695,7 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) {
min_transmit_bitrate_bps); min_transmit_bitrate_bps);
const DataRate network_constrained_rate = const DataRate network_constrained_rate =
DataRate::bps(qvga_stream.target_bitrate_bps); DataRate::BitsPerSec(qvga_stream.target_bitrate_bps);
BitrateAllocationUpdate update; BitrateAllocationUpdate update;
update.target_bitrate = network_constrained_rate; update.target_bitrate = network_constrained_rate;
update.stable_target_bitrate = network_constrained_rate; update.stable_target_bitrate = network_constrained_rate;
@ -713,8 +713,8 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) {
// Test allocation where the link allocation is larger than the target, // Test allocation where the link allocation is larger than the target,
// meaning we have some headroom on the link. // meaning we have some headroom on the link.
const DataRate qvga_max_bitrate = const DataRate qvga_max_bitrate =
DataRate::bps(qvga_stream.max_bitrate_bps); DataRate::BitsPerSec(qvga_stream.max_bitrate_bps);
const DataRate headroom = DataRate::bps(50000); const DataRate headroom = DataRate::BitsPerSec(50000);
const DataRate rate_with_headroom = qvga_max_bitrate + headroom; const DataRate rate_with_headroom = qvga_max_bitrate + headroom;
update.target_bitrate = rate_with_headroom; update.target_bitrate = rate_with_headroom;
update.stable_target_bitrate = rate_with_headroom; update.stable_target_bitrate = rate_with_headroom;
@ -737,7 +737,7 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) {
EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps()) EXPECT_CALL(rtp_video_sender_, GetPayloadBitrateBps())
.WillOnce(Return(rate_with_headroom.bps())); .WillOnce(Return(rate_with_headroom.bps()));
const DataRate headroom_minus_protection = const DataRate headroom_minus_protection =
rate_with_headroom - DataRate::bps(protection_bitrate_bps); rate_with_headroom - DataRate::BitsPerSec(protection_bitrate_bps);
EXPECT_CALL(video_stream_encoder_, EXPECT_CALL(video_stream_encoder_,
OnBitrateUpdated(qvga_max_bitrate, qvga_max_bitrate, OnBitrateUpdated(qvga_max_bitrate, qvga_max_bitrate,
headroom_minus_protection, 0, _, 0)); headroom_minus_protection, 0, _, 0));

Some files were not shown because too many files have changed in this diff Show More