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 return_link;
TimeDelta feedback_interval = TimeDelta::Millis(50);
DataSize feedback_packet_size = DataSize::bytes(20);
DataSize feedback_packet_size = DataSize::Bytes(20);
};
virtual ~FeedbackGenerator() = default;
virtual Timestamp Now() = 0;

View file

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

View file

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

View file

@ -804,12 +804,12 @@ void AudioSendStream::ConfigureBitrateObserver() {
constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12;
const TimeDelta kMinPacketDuration = TimeDelta::Millis(20);
DataRate max_overhead =
DataSize::bytes(kOverheadPerPacket) / kMinPacketDuration;
DataSize::Bytes(kOverheadPerPacket) / kMinPacketDuration;
priority_bitrate += max_overhead;
} else {
RTC_DCHECK(frame_length_range_);
const DataSize kOverheadPerPacket =
DataSize::bytes(total_packet_overhead_bytes_);
DataSize::Bytes(total_packet_overhead_bytes_);
DataRate max_overhead = kOverheadPerPacket / frame_length_range_->first;
priority_bitrate += max_overhead;
}
@ -841,8 +841,8 @@ void AudioSendStream::RemoveBitrateObserver() {
AudioSendStream::TargetAudioBitrateConstraints
AudioSendStream::GetMinMaxBitrateConstraints() const {
TargetAudioBitrateConstraints constraints{
DataRate::bps(config_.min_bitrate_bps),
DataRate::bps(config_.max_bitrate_bps)};
DataRate::BitsPerSec(config_.min_bitrate_bps),
DataRate::BitsPerSec(config_.max_bitrate_bps)};
// If bitrates were explicitly overriden via field trial, use those values.
if (allocation_settings_.min_bitrate)
@ -856,7 +856,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const {
if (send_side_bwe_with_overhead_) {
if (use_legacy_overhead_calculation_) {
// 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 =
TimeDelta::Millis(60); // Based on Opus spec
const DataRate kMinOverhead = kOverheadPerPacket / kMaxFrameLength;
@ -865,7 +865,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const {
} else {
RTC_DCHECK(frame_length_range_);
const DataSize kOverheadPerPacket =
DataSize::bytes(total_packet_overhead_bytes_);
DataSize::Bytes(total_packet_overhead_bytes_);
constraints.min += kOverheadPerPacket / frame_length_range_->second;
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
// should be made more precise in the future. This can be changed when that
// 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 kMaxFrameLength = TimeDelta::Millis(120);
const DataRate kMinOverheadRate = kOverheadPerPacket / kMaxFrameLength;
@ -549,11 +549,12 @@ TEST(AudioSendStreamTest, DoesNotPassHigherBitrateThanMaxBitrate) {
ConfigHelper helper(false, true);
auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(
Field(&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::bps(helper.config().max_bitrate_bps)))));
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::BitsPerSec(helper.config().max_bitrate_bps)))));
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.round_trip_time = TimeDelta::Millis(50);
update.bwe_period = TimeDelta::Millis(6000);
@ -565,12 +566,14 @@ TEST(AudioSendStreamTest, SSBweTargetInRangeRespected) {
ScopedFieldTrials field_trials("WebRTC-Audio-SendSideBwe/Enabled/");
ConfigHelper helper(true, true);
auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::bps(helper.config().max_bitrate_bps - 5000)))));
EXPECT_CALL(
*helper.channel_send(),
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::BitsPerSec(helper.config().max_bitrate_bps - 5000)))));
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); },
RTC_FROM_HERE);
}
@ -584,9 +587,9 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) {
EXPECT_CALL(
*helper.channel_send(),
OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::kbps(6)))));
Eq(DataRate::KilobitsPerSec(6)))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(1);
update.target_bitrate = DataRate::KilobitsPerSec(1);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE);
}
@ -600,9 +603,9 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) {
EXPECT_CALL(
*helper.channel_send(),
OnBitrateAllocation(Field(&BitrateAllocationUpdate::target_bitrate,
Eq(DataRate::kbps(64)))));
Eq(DataRate::KilobitsPerSec(64)))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(128);
update.target_bitrate = DataRate::KilobitsPerSec(128);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE);
}
@ -617,7 +620,7 @@ TEST(AudioSendStreamTest, SSBweWithOverhead) {
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
send_stream->OnOverheadChanged(kOverheadPerPacket.bytes<size_t>());
const DataRate bitrate =
DataRate::bps(helper.config().max_bitrate_bps) + kMaxOverheadRate;
DataRate::BitsPerSec(helper.config().max_bitrate_bps) + kMaxOverheadRate;
EXPECT_CALL(*helper.channel_send(),
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
@ -637,12 +640,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) {
auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
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(),
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(1);
update.target_bitrate = DataRate::KilobitsPerSec(1);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE);
}
@ -657,12 +660,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMaxRespected) {
auto send_stream = helper.CreateAudioSendStream();
EXPECT_CALL(*helper.channel_send(), CallEncoder(_)).Times(1);
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(),
OnBitrateAllocation(Field(
&BitrateAllocationUpdate::target_bitrate, Eq(bitrate))));
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::kbps(128);
update.target_bitrate = DataRate::KilobitsPerSec(128);
helper.worker()->SendTask([&] { send_stream->OnBitrateUpdated(update); },
RTC_FROM_HERE);
}
@ -675,7 +678,8 @@ TEST(AudioSendStreamTest, ProbingIntervalOnBitrateUpdated) {
OnBitrateAllocation(Field(&BitrateAllocationUpdate::bwe_period,
Eq(TimeDelta::Millis(5000)))));
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.round_trip_time = TimeDelta::Millis(50);
update.bwe_period = TimeDelta::Millis(5000);

View file

@ -404,8 +404,9 @@ void BitrateAllocator::OnNetworkEstimateChanged(TargetTransferRate msg) {
uint32_t allocated_stable_target_rate =
stable_bitrate_allocation[config.observer];
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate);
update.stable_target_bitrate = DataRate::bps(allocated_stable_target_rate);
update.target_bitrate = DataRate::BitsPerSec(allocated_bitrate);
update.stable_target_bitrate =
DataRate::BitsPerSec(allocated_stable_target_rate);
update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::Millis(last_rtt_);
update.bwe_period = TimeDelta::Millis(last_bwe_period_ms_);
@ -469,8 +470,9 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
uint32_t allocated_stable_bitrate =
stable_bitrate_allocation[config.observer];
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate);
update.stable_target_bitrate = DataRate::bps(allocated_stable_bitrate);
update.target_bitrate = DataRate::BitsPerSec(allocated_bitrate);
update.stable_target_bitrate =
DataRate::BitsPerSec(allocated_stable_bitrate);
update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::Millis(last_rtt_);
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;
if (config.config.enforce_min_bitrate) {
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) {
stream_padding =
std::max(config.MinBitrateWithHysteresis(), stream_padding);
}
limits.max_padding_rate += DataRate::bps(stream_padding);
limits.max_allocatable_rate += DataRate::bps(config.config.max_bitrate_bps);
limits.max_padding_rate += DataRate::BitsPerSec(stream_padding);
limits.max_allocatable_rate +=
DataRate::BitsPerSec(config.config.max_bitrate_bps);
}
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_allocatable_rate_bps) {
return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate,
DataRate::bps(min_allocatable_rate_bps)),
DataRate::BitsPerSec(min_allocatable_rate_bps)),
Field(&BitrateAllocationLimits::max_allocatable_rate,
DataRate::bps(max_allocatable_rate_bps)),
DataRate::BitsPerSec(max_allocatable_rate_bps)),
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,
uint32_t max_padding_rate_bps) {
return AllOf(Field(&BitrateAllocationLimits::min_allocatable_rate,
DataRate::bps(min_allocatable_rate_bps)),
DataRate::BitsPerSec(min_allocatable_rate_bps)),
Field(&BitrateAllocationLimits::max_padding_rate,
DataRate::bps(max_padding_rate_bps)));
DataRate::BitsPerSec(max_padding_rate_bps)));
}
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
// messages in the test.
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.network_estimate.bandwidth = msg.target_rate;
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);
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());
if (header.extension.hasAbsoluteSendTime) {
packet_msg.send_time = header.extension.GetAbsoluteSendTimestamp();

View file

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

View file

@ -695,9 +695,9 @@ void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
int framerate) {
// Substract overhead from bitrate.
rtc::CritScope lock(&crit_);
DataSize packet_overhead = DataSize::bytes(
DataSize packet_overhead = DataSize::Bytes(
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_);
uint32_t payload_bitrate_bps = update.target_bitrate.bps();
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
// calculations.
DataRate encoder_overhead_rate = CalculateOverheadRate(
DataRate::bps(encoder_target_rate_bps_),
max_total_packet_size - DataSize::bytes(overhead_bytes_per_packet_),
DataRate::BitsPerSec(encoder_target_rate_bps_),
max_total_packet_size - DataSize::Bytes(overhead_bytes_per_packet_),
packet_overhead);
encoder_overhead_rate_bps = std::min(
encoder_overhead_rate.bps<uint32_t>(),
@ -754,7 +754,7 @@ void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
const uint32_t media_rate = encoder_target_rate_bps_ +
encoder_overhead_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;
}

View file

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

View file

@ -34,7 +34,7 @@ bool CoDelSimulation::DropDequeuedPacket(Timestamp now,
constexpr TimeDelta kWindow = TimeDelta::Millis(100);
constexpr TimeDelta kDelayThreshold = TimeDelta::Millis(5);
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.
TimeDelta queuing_time = now - enqueing_time - kDefaultProcessDelay;
@ -193,8 +193,8 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state,
codel_controller_.DropDequeuedPacket(
Timestamp::Micros(time_us),
Timestamp::Micros(capacity_link_.front().packet.send_time_us),
DataSize::bytes(capacity_link_.front().packet.size),
DataSize::bytes(queue_size_bytes_))) {
DataSize::Bytes(capacity_link_.front().packet.size),
DataSize::Bytes(queue_size_bytes_))) {
PacketInfo dropped = capacity_link_.front();
capacity_link_.pop();
queue_size_bytes_ -= dropped.packet.size;

View file

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

View file

@ -2407,14 +2407,14 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent(
if (proto.has_link_capacity_lower_kbps()) {
base_link_capacity_lower_kbps = proto.link_capacity_lower_kbps();
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;
if (proto.has_link_capacity_upper_kbps()) {
base_link_capacity_upper_kbps = proto.link_capacity_upper_kbps();
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);
@ -2452,10 +2452,10 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent(
event.timestamp_ms = *timestamp_ms_values[i];
if (link_capacity_lower_kbps_values[i])
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])
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);
}
return ParseStatus::Success();

View file

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

View file

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

View file

@ -508,14 +508,14 @@ void SimulcastEncoderAdapter::SetRates(
// Assign link allocation proportionally to spatial layer allocation.
if (parameters.bandwidth_allocation != DataRate::Zero()) {
stream_parameters.bandwidth_allocation =
DataRate::bps((parameters.bandwidth_allocation.bps() *
stream_parameters.bitrate.get_sum_bps()) /
parameters.bitrate.get_sum_bps());
DataRate::BitsPerSec((parameters.bandwidth_allocation.bps() *
stream_parameters.bitrate.get_sum_bps()) /
parameters.bitrate.get_sum_bps());
// Make sure we don't allocate bandwidth lower than target bitrate.
if (stream_parameters.bandwidth_allocation.bps() <
stream_parameters.bitrate.get_sum_bps()) {
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);
codec_.numberOfSimulcastStreams = 3;
const DataRate target_bitrate =
DataRate::kbps(codec_.simulcastStream[0].targetBitrate +
codec_.simulcastStream[1].targetBitrate +
codec_.simulcastStream[2].minBitrate);
const DataRate bandwidth_allocation = target_bitrate + DataRate::kbps(600);
DataRate::KilobitsPerSec(codec_.simulcastStream[0].targetBitrate +
codec_.simulcastStream[1].targetBitrate +
codec_.simulcastStream[2].minBitrate);
const DataRate bandwidth_allocation =
target_bitrate + DataRate::KilobitsPerSec(600);
rate_allocator_.reset(new SimulcastRateAllocator(codec_));
EXPECT_EQ(0, adapter_->InitEncode(&codec_, kSettings));
@ -1357,7 +1358,8 @@ TEST_F(TestSimulcastEncoderAdapterFake, SupportsFallback) {
// Make sure we have bitrate for all layers.
DataRate max_bitrate = DataRate::Zero();
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(
rate_allocator_->Allocate(

View file

@ -63,7 +63,7 @@ TEST(SimulcastTest, BandwidthAboveTotalMaxBitrateGivenToHighestStream) {
streams[1].target_bitrate_bps = 200000;
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.
const webrtc::DataRate max_total_bitrate =

View file

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

View file

@ -36,7 +36,7 @@ const int64_t kRegularPacketSizeBytes = 1280;
static_assert((kRegularPacketSizeBytes & 31) == 0,
"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.
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
// additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
// 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.
// 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.
constexpr DataSize kMaxSegmentSize = kDefaultTCPMSS;
@ -184,7 +184,7 @@ BbrNetworkController::BbrNetworkController(NetworkControllerConfig config)
last_sent_packet_(0),
current_round_trip_end_(0),
max_bandwidth_(kBandwidthWindowSize, DataRate::Zero(), 0),
default_bandwidth_(DataRate::kbps(kInitialBandwidthKbps)),
default_bandwidth_(DataRate::KilobitsPerSec(kInitialBandwidthKbps)),
max_ack_height_(kBandwidthWindowSize, DataSize::Zero(), 0),
aggregation_epoch_start_time_(),
aggregation_epoch_bytes_(DataSize::Zero()),

View file

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

View file

@ -26,7 +26,7 @@ struct ResultForTest {
class DataTransferTrackerForTest : public DataTransferTracker {
public:
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(ack_time_ms));
}

View file

@ -59,7 +59,7 @@ class WindowedFilterTest : public ::testing::Test {
// Third best = 600 bps, recorded at 100ms
void InitializeMaxFilter() {
int64_t now_ms = 0;
DataRate bw_sample = DataRate::bps(1000);
DataRate bw_sample = DataRate::BitsPerSec(1000);
for (int i = 0; i < 5; ++i) {
windowed_max_bw_.Update(bw_sample, now_ms);
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_.GetThirdBest());
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::bps(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::bps(600), windowed_max_bw_.GetThirdBest());
EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
EXPECT_EQ(DataRate::BitsPerSec(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::BitsPerSec(600), windowed_max_bw_.GetThirdBest());
}
protected:
@ -135,15 +135,15 @@ TEST_F(WindowedFilterTest, MonotonicallyIncreasingMin) {
TEST_F(WindowedFilterTest, MonotonicallyDecreasingMax) {
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);
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
// decreasing.
for (int i = 0; i < 6; ++i) {
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);
RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << bw_sample.bps()
<< " maxs: "
@ -152,11 +152,11 @@ TEST_F(WindowedFilterTest, MonotonicallyDecreasingMax) {
<< windowed_max_bw_.GetSecondBest().bps() << " "
<< windowed_max_bw_.GetThirdBest().bps();
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) {
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest());
EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
} 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();
// BW sample higher than the third-choice max sets that, but nothing else.
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.
int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms);
EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest());
EXPECT_EQ(DataRate::bps(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::bps(900), windowed_max_bw_.GetBest());
EXPECT_EQ(DataRate::BitsPerSec(700), windowed_max_bw_.GetSecondBest());
EXPECT_EQ(DataRate::BitsPerSec(900), windowed_max_bw_.GetBest());
}
TEST_F(WindowedFilterTest, SampleChangesSecondBestMin) {
@ -212,14 +212,14 @@ TEST_F(WindowedFilterTest, SampleChangesSecondBestMax) {
// BW sample higher than the second-choice max sets that and also
// the third-choice max.
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.
int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms);
EXPECT_EQ(bw_sample, windowed_max_bw_.GetThirdBest());
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) {
@ -242,7 +242,8 @@ TEST_F(WindowedFilterTest, SampleChangesAllMaxs) {
InitializeMaxFilter();
// BW sample higher than the first-choice max sets that and also
// 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.
int64_t now_ms = 101;
windowed_max_bw_.Update(bw_sample, now_ms);
@ -268,7 +269,7 @@ TEST_F(WindowedFilterTest, ExpireBestMax) {
InitializeMaxFilter();
DataRate old_third_best = windowed_max_bw_.GetThirdBest();
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.
int64_t now_ms = 125;
windowed_max_bw_.Update(bw_sample, now_ms);
@ -292,7 +293,7 @@ TEST_F(WindowedFilterTest, ExpireSecondBestMin) {
TEST_F(WindowedFilterTest, ExpireSecondBestMax) {
InitializeMaxFilter();
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.
int64_t now_ms = 175;
windowed_max_bw_.Update(bw_sample, now_ms);
@ -319,7 +320,7 @@ TEST_F(WindowedFilterTest, ExpireAllMins) {
TEST_F(WindowedFilterTest, ExpireAllMaxs) {
InitializeMaxFilter();
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.
int64_t now_ms = 200;
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 =
Timestamp::Millis(kFirstSendTimeMs);
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 =
Timestamp::Millis(kFirstArrivalTimeMs + 10);
packet_feedback_vector[1].sent_packet.send_time =
Timestamp::Millis(kFirstSendTimeMs + 10);
packet_feedback_vector[1].sent_packet.sequence_number = kSequenceNumber;
packet_feedback_vector[1].sent_packet.size =
DataSize::bytes(kPayloadSize + 10);
DataSize::Bytes(kPayloadSize + 10);
return packet_feedback_vector;
}
@ -124,7 +124,7 @@ TEST(TestAcknowledgedBitrateEstimator, ExpectFastRateChangeWhenLeftAlr) {
TEST(TestAcknowledgedBitrateEstimator, ReturnBitrate) {
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())
.Times(1)
.WillOnce(Return(return_value));

View file

@ -148,12 +148,12 @@ float BitrateEstimator::UpdateWindow(int64_t now_ms,
absl::optional<DataRate> BitrateEstimator::bitrate() const {
if (bitrate_estimate_kbps_ < 0.f)
return absl::nullopt;
return DataRate::kbps(bitrate_estimate_kbps_);
return DataRate::KilobitsPerSec(bitrate_estimate_kbps_);
}
absl::optional<DataRate> BitrateEstimator::PeekRate() const {
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;
}

View file

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

View file

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

View file

@ -54,7 +54,7 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us,
PacketResult packet;
packet.sent_packet.send_time =
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);
}
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 =
Timestamp::Millis(arrival_time_ms + arrival_time_offset_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;
if (packet.sent_packet.pacing_info.probe_cluster_id !=
PacedPacketInfo::kNotAProbe)

View file

@ -375,7 +375,7 @@ void GoogCcNetworkController::UpdateCongestionWindowSize() {
TimeDelta min_feedback_max_rtt = TimeDelta::Millis(
*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 =
min_feedback_max_rtt +
TimeDelta::Millis(
@ -607,7 +607,7 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged(
loss_based_target_rate.bps());
pushback_rate = std::max<int64_t>(bandwidth_estimation_->GetMinBitrate(),
pushback_rate);
pushback_target_rate = DataRate::bps(pushback_rate);
pushback_target_rate = DataRate::BitsPerSec(pushback_rate);
if (rate_control_settings_.UseCongestionWindowDropFrameOnly()) {
cwnd_reduce_ratio = static_cast<double>(loss_based_target_rate.bps() -
pushback_target_rate.bps()) /

View file

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

View file

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

View file

@ -83,9 +83,11 @@ LossBasedControlConfig::LossBasedControlConfig()
loss_window("loss_win", TimeDelta::Millis(800)),
loss_max_window("loss_max_win", TimeDelta::Millis(800)),
acknowledged_rate_max_window("ackrate_max_win", TimeDelta::Millis(800)),
increase_offset("incr_offset", DataRate::bps(1000)),
loss_bandwidth_balance_increase("balance_incr", DataRate::kbps(0.5)),
loss_bandwidth_balance_decrease("balance_decr", DataRate::kbps(4)),
increase_offset("incr_offset", DataRate::BitsPerSec(1000)),
loss_bandwidth_balance_increase("balance_incr",
DataRate::KilobitsPerSec(0.5)),
loss_bandwidth_balance_decrease("balance_decr",
DataRate::KilobitsPerSec(4)),
loss_bandwidth_balance_exponent("exponent", 0.5),
allow_resets("resets", false),
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 *
kMinReceivedProbesRatio;
DataSize min_size =
DataSize::bytes(
DataSize::Bytes(
packet_feedback.sent_packet.pacing_info.probe_cluster_min_bytes) *
kMinReceivedBytesRatio;
if (cluster->num_probes < min_probes || cluster->size_total < min_size)

View file

@ -39,7 +39,7 @@ class TestProbeBitrateEstimator : public ::testing::Test {
PacketResult feedback;
feedback.sent_packet.send_time =
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 =
PacedPacketInfo(probe_cluster_id, min_probes, min_bytes);
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)
return std::vector<ProbeClusterConfig>();
DataRate first_probe_rate = DataRate::bps(max_total_allocated_bitrate) *
config_.first_allocation_probe_scale.Value();
DataRate first_probe_rate =
DataRate::BitsPerSec(max_total_allocated_bitrate) *
config_.first_allocation_probe_scale.Value();
DataRate probe_cap = config_.allocation_probe_max.Get();
first_probe_rate = std::min(first_probe_rate, probe_cap);
std::vector<int64_t> probes = {first_probe_rate.bps()};
if (config_.second_allocation_probe_scale) {
DataRate second_probe_rate =
DataRate::bps(max_total_allocated_bitrate) *
DataRate::BitsPerSec(max_total_allocated_bitrate) *
config_.second_allocation_probe_scale.Value();
second_probe_rate = std::min(second_probe_rate, probe_cap);
if (second_probe_rate > first_probe_rate)
@ -425,7 +426,8 @@ std::vector<ProbeClusterConfig> ProbeController::InitiateProbing(
ProbeClusterConfig config;
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_probe_count = kMinProbePacketsSent;
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 min_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_) {
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);

View file

@ -45,7 +45,7 @@ TEST(RobustThroughputEstimatorTest, SteadyRate) {
FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000));
DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10));
@ -75,7 +75,7 @@ TEST(RobustThroughputEstimatorTest, DelaySpike) {
FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000));
DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10));
@ -124,7 +124,7 @@ TEST(RobustThroughputEstimatorTest, CappedByReceiveRate) {
FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000));
DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000));
TimeDelta send_increment(TimeDelta::Millis(10));
@ -148,7 +148,7 @@ TEST(RobustThroughputEstimatorTest, CappedBySendRate) {
FieldTrialBasedConfig field_trial_config;
RobustThroughputEstimatorSettings settings(&field_trial_config);
RobustThroughputEstimator throughput_estimator(settings);
DataSize packet_size(DataSize::bytes(1000));
DataSize packet_size(DataSize::Bytes(1000));
Timestamp send_clock(Timestamp::Millis(100000));
Timestamp recv_clock(Timestamp::Millis(10000));
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 kBweConverganceTime = TimeDelta::Millis(20000);
constexpr int kLimitNumPackets = 20;
constexpr DataRate kDefaultMaxBitrate = DataRate::BitsPerSec<1000000000>();
constexpr DataRate kDefaultMaxBitrate = DataRate::BitsPerSec(1000000000);
constexpr TimeDelta kLowBitrateLogPeriod = TimeDelta::Millis(10000);
constexpr TimeDelta kRtcEventLogPeriod = TimeDelta::Millis(5000);
// 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 {
return DataRate::bps(capacity_estimate_bps_);
return DataRate::BitsPerSec(capacity_estimate_bps_);
}
RttBasedBackoff::RttBasedBackoff()
: rtt_limit_("limit", TimeDelta::Seconds(3)),
drop_fraction_("fraction", 0.8),
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
// trigger rtt backoff unless packet feedback is enabled.
last_propagation_rtt_update_(Timestamp::PlusInfinity()),
@ -191,7 +191,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
current_target_(DataRate::Zero()),
last_logged_target_(DataRate::Zero()),
min_bitrate_configured_(
DataRate::bps(congestion_controller::GetMinBitrateBps())),
DataRate::BitsPerSec(congestion_controller::GetMinBitrateBps())),
max_bitrate_configured_(kDefaultMaxBitrate),
last_low_bitrate_log_(Timestamp::MinusInfinity()),
has_decreased_since_last_fraction_loss_(false),
@ -223,7 +223,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
RTC_LOG(LS_INFO) << "Enabled BweLossExperiment with parameters "
<< low_loss_threshold_ << ", " << high_loss_threshold_
<< ", " << 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;
current_target_ = DataRate::Zero();
min_bitrate_configured_ =
DataRate::bps(congestion_controller::GetMinBitrateBps());
DataRate::BitsPerSec(congestion_controller::GetMinBitrateBps());
max_bitrate_configured_ = kDefaultMaxBitrate;
last_low_bitrate_log_ = Timestamp::MinusInfinity();
has_decreased_since_last_fraction_loss_ = false;
@ -373,7 +373,8 @@ void SendSideBandwidthEstimation::UpdatePacketsLost(int packets_lost,
void SendSideBandwidthEstimation::UpdateUmaStatsPacketsLost(Timestamp at_time,
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) {
if (!rampup_uma_stats_updated_[i] &&
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),
// it would take over one second since the lower packet loss to achieve
// 108kbps.
DataRate new_bitrate =
DataRate::bps(min_bitrate_history_.front().second.bps() * 1.08 + 0.5);
DataRate new_bitrate = DataRate::BitsPerSec(
min_bitrate_history_.front().second.bps() * 1.08 + 0.5);
// 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
// rates).
new_bitrate += DataRate::bps(1000);
new_bitrate += DataRate::BitsPerSec(1000);
UpdateTargetBitrate(new_bitrate, at_time);
return;
} else if (current_target_ > bitrate_threshold_) {
@ -513,10 +514,10 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
// Reduce rate:
// newRate = rate * (1 - 0.5*lossRate);
// where packetLoss = 256*lossRate;
DataRate new_bitrate =
DataRate::bps((current_target_.bps() *
static_cast<double>(512 - last_fraction_loss_)) /
512.0);
DataRate new_bitrate = DataRate::BitsPerSec(
(current_target_.bps() *
static_cast<double>(512 - last_fraction_loss_)) /
512.0);
has_decreased_since_last_fraction_loss_ = true;
UpdateTargetBitrate(new_bitrate, at_time);
return;
@ -572,7 +573,7 @@ DataRate SendSideBandwidthEstimation::MaybeRampupOrBackoff(DataRate new_bitrate,
at_time - last_loss_packet_report_;
if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) {
new_bitrate = min_bitrate_history_.front().second * 1.08;
new_bitrate += DataRate::bps(1000);
new_bitrate += DataRate::BitsPerSec(1000);
}
return new_bitrate;
}

View file

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

View file

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

View file

@ -131,7 +131,7 @@ DataRate PccBitrateController::ComputeRateUpdateForOnlineLearningMode(
double rate_change_bps = gradient * ComputeStepSize(gradient); // delta_r
rate_change_bps =
ApplyDynamicBoundary(rate_change_bps, bandwith_estimate.bps());
return DataRate::bps(
return DataRate::BitsPerSec(
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 kDelayGradientNegativeBound = 10;
const DataRate kTargetSendingRate = DataRate::kbps(300);
const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300);
const double kEpsilon = 0.05;
const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = 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(
const std::vector<Timestamp>& packets_send_times,

View file

@ -18,12 +18,12 @@ namespace webrtc {
namespace pcc {
namespace test {
namespace {
const DataRate kTargetSendingRate = DataRate::kbps(300);
const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300);
const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
const TimeDelta kIntervalDuration = 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;
std::vector<PacketResult> CreatePacketResults(

View file

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

View file

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

View file

@ -35,9 +35,9 @@ constexpr double kDelayGradientNegativeBound = 10;
const Timestamp kStartTime = Timestamp::Micros(0);
const TimeDelta kPacketsDelta = TimeDelta::Millis(1);
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);
std::vector<PacketResult> CreatePacketResults(

View file

@ -76,10 +76,10 @@ TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) {
TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) {
Scenario s("recieve_cc_unit/converge");
NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000);
net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(50);
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)},
@ -95,10 +95,10 @@ TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) {
TEST(ReceiveSideCongestionControllerTest, IsFairToTCP) {
Scenario s("recieve_cc_unit/tcp_fairness");
NetworkSimulationConfig net_conf;
net_conf.bandwidth = DataRate::kbps(1000);
net_conf.bandwidth = DataRate::KilobitsPerSec(1000);
net_conf.delay = TimeDelta::Millis(50);
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 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.sent.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.remote_net_id = remote_net_id_;
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.";
}
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);
}
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.sent_packet.send_time = Timestamp::Millis(send_time_ms);
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;
return res;
}
@ -309,7 +309,7 @@ TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) {
packet_feedback.sent_packet.sequence_number = 1;
packet_feedback.sent_packet.send_time = Timestamp::Millis(100);
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);
// 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
// close to the target bitrate. Result is in milliseconds.
DataSize sent_bytes = DataSize::bytes(cluster.sent_bytes);
DataRate send_bitrate = DataRate::bps(cluster.pace_info.send_bitrate_bps);
DataSize sent_bytes = DataSize::Bytes(cluster.sent_bytes);
DataRate send_bitrate =
DataRate::BitsPerSec(cluster.pace_info.send_bitrate_bps);
TimeDelta delta = sent_bytes / send_bitrate;
return cluster.started_at + delta;
}

View file

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

View file

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

View file

@ -32,7 +32,7 @@ constexpr TimeDelta kCongestedPacketInterval = TimeDelta::Millis(500);
// The maximum debt level, in terms of time, capped when sending packets.
constexpr TimeDelta kMaxDebtInTime = TimeDelta::Millis(500);
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
// time.
@ -415,10 +415,10 @@ void PacingController::ProcessPackets() {
} else {
DataSize keepalive_data_sent = DataSize::Zero();
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) {
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());
}
OnPaddingSent(keepalive_data_sent);
@ -468,7 +468,7 @@ void PacingController::ProcessPackets() {
if (is_probing) {
pacing_info = prober_.CurrentCluster();
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();
@ -479,7 +479,7 @@ void PacingController::ProcessPackets() {
if (small_first_probe_packet_ && first_packet_in_probe) {
// If first packet in probe, insert a small padding packet so we have a
// 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
// padding packet back.
if (!padding.empty()) {
@ -531,11 +531,11 @@ void PacingController::ProcessPackets() {
RTC_DCHECK(rtp_packet);
RTC_DCHECK(rtp_packet->packet_type().has_value());
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());
if (include_overhead_) {
packet_size += DataSize::bytes(rtp_packet->headers_size()) +
packet_size += DataSize::Bytes(rtp_packet->headers_size()) +
transport_overhead_per_packet_;
}
packet_sender_->SendRtpPacket(std::move(rtp_packet), pacing_info);
@ -594,7 +594,7 @@ DataSize PacingController::PaddingToAdd(
}
if (mode_ == ProcessMode::kPeriodic) {
return DataSize::bytes(padding_budget_.bytes_remaining());
return DataSize::Bytes(padding_budget_.bytes_remaining());
} else if (padding_rate_ > DataRate::Zero() &&
padding_debt_ == DataSize::Zero()) {
return kDefaultPaddingTarget;

View file

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

View file

@ -18,7 +18,7 @@
namespace webrtc {
namespace {
static constexpr DataSize kMaxLeadingSize = DataSize::Bytes<1400>();
static constexpr DataSize kMaxLeadingSize = DataSize::Bytes(1400);
}
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
// kMaxLeading bytes of the stream that has sent the most amount of bytes.
DataSize packet_size =
DataSize::bytes(queued_packet.RtpPacket()->payload_size() +
DataSize::Bytes(queued_packet.RtpPacket()->payload_size() +
queued_packet.RtpPacket()->padding_size());
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_;
}
stream->size =
@ -253,7 +253,7 @@ void RoundRobinPacketQueue::SetIncludeOverhead() {
// We need to update the size to reflect overhead for existing packets.
for (const auto& stream : streams_) {
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_;
}
}
@ -313,10 +313,10 @@ void RoundRobinPacketQueue::Push(QueuedPacket packet) {
packet.SubtractPauseTime(pause_time_sum_);
size_packets_ += 1;
size_ += DataSize::bytes(packet.RtpPacket()->payload_size() +
size_ += DataSize::Bytes(packet.RtpPacket()->payload_size() +
packet.RtpPacket()->padding_size());
if (include_overhead_) {
size_ += DataSize::bytes(packet.RtpPacket()->headers_size()) +
size_ += DataSize::Bytes(packet.RtpPacket()->headers_size()) +
transport_overhead_per_packet_;
}

View file

@ -102,8 +102,9 @@ class TaskQueuePacedSenderTest : public ::testing::Test {
TEST_F(TaskQueuePacedSenderTest, PacesPackets) {
// Insert a number of packets, covering one second.
static constexpr size_t kPacketsToSend = 42;
pacer_.SetPacingRates(DataRate::bps(kDefaultPacketSize * 8 * kPacketsToSend),
DataRate::Zero());
pacer_.SetPacingRates(
DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend),
DataRate::Zero());
pacer_.EnqueuePackets(
GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend));
@ -133,7 +134,7 @@ TEST_F(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) {
// Insert a number of packets to be sent 200ms apart.
const size_t kPacketsPerSecond = 5;
const DataRate kPacingRate =
DataRate::bps(kDefaultPacketSize * 8 * kPacketsPerSecond);
DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsPerSecond);
pacer_.SetPacingRates(kPacingRate, DataRate::Zero());
// 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,
bool send_side)
: min_configured_bitrate_(congestion_controller::GetMinBitrate()),
max_configured_bitrate_(DataRate::kbps(30000)),
max_configured_bitrate_(DataRate::KilobitsPerSec(30000)),
current_bitrate_(max_configured_bitrate_),
latest_estimated_throughput_(current_bitrate_),
link_capacity_(),
@ -137,7 +137,7 @@ bool AimdRateControl::ValidEstimate() const {
TimeDelta AimdRateControl::GetFeedbackInterval() const {
// Estimate how often we can send RTCP if we allocate up to 5% of bandwidth
// to feedback.
const DataSize kRtcpSize = DataSize::bytes(80);
const DataSize kRtcpSize = DataSize::Bytes(80);
const DataRate rtcp_bitrate = current_bitrate_ * 0.05;
const TimeDelta interval = kRtcpSize / rtcp_bitrate;
const TimeDelta kMinFeedbackInterval = TimeDelta::Millis(200);
@ -165,7 +165,7 @@ bool AimdRateControl::InitialTimeToReduceFurther(Timestamp at_time) const {
if (!initial_backoff_interval_) {
return ValidEstimate() &&
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
// of a fixed bitrate_reduction_interval.
@ -232,7 +232,7 @@ double AimdRateControl::GetNearMaxIncreaseRateBpsPerSecond() const {
RTC_DCHECK(!current_bitrate_.IsZero());
const TimeDelta kFrameInterval = TimeDelta::Seconds(1) / 30;
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);
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
// the encoder produces uneven outputs.
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) {
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));
}
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;
}
@ -413,7 +413,7 @@ DataRate AimdRateControl::AdditiveRateIncrease(Timestamp at_time,
double time_period_seconds = (at_time - last_time).seconds<double>();
double data_rate_increase_bps =
GetNearMaxIncreaseRateBpsPerSecond() * time_period_seconds;
return DataRate::bps(data_rate_increase_bps);
return DataRate::BitsPerSec(data_rate_increase_bps);
}
void AimdRateControl::ChangeState(const RateControlInput& input,

View file

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

View file

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

View file

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

View file

@ -31,7 +31,7 @@ namespace {
absl::optional<DataRate> OptionalRateFromOptionalBps(
absl::optional<int> bitrate_bps) {
if (bitrate_bps) {
return DataRate::bps(*bitrate_bps);
return DataRate::BitsPerSec(*bitrate_bps);
} else {
return absl::nullopt;
}
@ -143,10 +143,11 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
if (estimator->detector.State() == BandwidthUsage::kBwOverusing) {
absl::optional<uint32_t> incoming_bitrate_bps =
incoming_bitrate_.Rate(now_ms);
if (incoming_bitrate_bps && (prior_state != BandwidthUsage::kBwOverusing ||
GetRemoteRate()->TimeToReduceFurther(
Timestamp::Millis(now_ms),
DataRate::bps(*incoming_bitrate_bps)))) {
if (incoming_bitrate_bps &&
(prior_state != BandwidthUsage::kBwOverusing ||
GetRemoteRate()->TimeToReduceFurther(
Timestamp::Millis(now_ms),
DataRate::BitsPerSec(*incoming_bitrate_bps)))) {
// The first overuse should immediately trigger a new estimate.
// 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.
@ -264,7 +265,7 @@ AimdRateControl* RemoteBitrateEstimatorSingleStream::GetRemoteRate() {
void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) {
rtc::CritScope cs(&crit_sect_);
remote_rate_->SetMinBitrate(DataRate::bps(min_bitrate_bps));
remote_rate_->SetMinBitrate(DataRate::BitsPerSec(min_bitrate_bps));
}
} // 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_;
// TODO(webrtc:10742): Take IP header and transport overhead into account.
packet_result.sent_packet.size =
DataSize::bytes(header.headerLength + payload_size);
DataSize::Bytes(header.headerLength + payload_size);
packet_result.sent_packet.sequence_number = seq;
network_state_estimator_->OnReceivedPacket(packet_result);
}

View file

@ -25,7 +25,7 @@ namespace {
static constexpr int kFieldValueSize = 3;
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;
class DataRateSerializer {

View file

@ -15,8 +15,8 @@ namespace webrtc {
namespace rtcp {
TEST(RemoteEstimateTest, EncodesCapacityBounds) {
NetworkStateEstimate src;
src.link_capacity_lower = DataRate::kbps(10);
src.link_capacity_upper = DataRate::kbps(1000000);
src.link_capacity_lower = DataRate::KilobitsPerSec(10);
src.link_capacity_upper = DataRate::KilobitsPerSec(1000000);
rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src);
NetworkStateEstimate dst;
EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst));
@ -28,7 +28,7 @@ TEST(RemoteEstimateTest, ExpandsToPlusInfinity) {
NetworkStateEstimate src;
// 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.
src.link_capacity_lower = DataRate::kbps(2 << 24);
src.link_capacity_lower = DataRate::KilobitsPerSec(2 << 24);
src.link_capacity_upper = DataRate::PlusInfinity();
rtc::Buffer data = GetRemoteEstimateSerializer()->Serialize(src);
@ -46,10 +46,10 @@ TEST(RemoteEstimateTest, DoesNotEncodeNegative) {
// Since MinusInfinity can't be represented, the buffer should be empty.
EXPECT_EQ(data.size(), 0u);
NetworkStateEstimate dst;
dst.link_capacity_lower = DataRate::kbps(300);
dst.link_capacity_lower = DataRate::KilobitsPerSec(300);
EXPECT_TRUE(GetRemoteEstimateSerializer()->Parse(data, &dst));
// 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());
}
} // namespace rtcp

View file

@ -213,13 +213,13 @@ void RtpSenderEgress::ProcessBitrateAndNotifyObservers() {
DataRate RtpSenderEgress::SendBitrate() const {
rtc::CritScope cs(&lock_);
return DataRate::bps(
return DataRate::BitsPerSec(
total_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0));
}
DataRate RtpSenderEgress::NackOverheadRate() const {
rtc::CritScope cs(&lock_);
return DataRate::bps(
return DataRate::BitsPerSec(
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_);
VideoBitrateAllocation allocation =
init_allocator.Allocate(VideoBitrateAllocationParameters(
DataRate::kbps(codec_.startBitrate), codec_.maxFramerate));
DataRate::KilobitsPerSec(codec_.startBitrate), codec_.maxFramerate));
SetRates(RateControlParameters(allocation, codec_.maxFramerate));
return WEBRTC_VIDEO_CODEC_OK;
}

View file

@ -242,7 +242,7 @@ void MultiplexEncoderAdapter::SetRates(
bitrate_allocation,
static_cast<uint32_t>(encoders_.size() * parameters.framerate_fps),
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);
// Set rates with no headroom.
rate_settings.bandwidth_allocation = DataRate::bps(kBitrateBps);
rate_settings.bandwidth_allocation = DataRate::BitsPerSec(kBitrateBps);
EXPECT_CALL(
*vpx,
codec_enc_config_set(
@ -221,7 +221,7 @@ TEST_F(TestVp8Impl, DynamicSetRates) {
encoder.SetRates(rate_settings);
// Set rates with max headroom.
rate_settings.bandwidth_allocation = DataRate::bps(kBitrateBps * 2);
rate_settings.bandwidth_allocation = DataRate::BitsPerSec(kBitrateBps * 2);
EXPECT_CALL(
*vpx, codec_enc_config_set(
_, AllOf(Field(&vpx_codec_enc_cfg_t::rc_target_bitrate,
@ -235,7 +235,8 @@ TEST_F(TestVp8Impl, DynamicSetRates) {
encoder.SetRates(rate_settings);
// 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(
*vpx,
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.
DataRate excess_rate = DataRate::Zero();
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);
DataRate max_rate = DataRate::kbps(
DataRate max_rate = DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + sl_idx].maxBitrate);
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 num_active_layers) {
if (num_active_layers == 1) {
return DataRate::kbps(codec.spatialLayers[0].minBitrate);
return DataRate::KilobitsPerSec(codec.spatialLayers[0].minBitrate);
}
if (codec.mode == VideoCodecMode::kRealtimeVideo) {
@ -133,19 +133,19 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec,
DataRate upper_bound = DataRate::Zero();
if (num_active_layers > 1) {
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);
upper_bound += DataRate::kbps(
upper_bound += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + i].maxBitrate);
}
}
upper_bound +=
DataRate::kbps(codec.spatialLayers[num_active_layers - 1].minBitrate);
upper_bound += DataRate::KilobitsPerSec(
codec.spatialLayers[num_active_layers - 1].minBitrate);
// 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|
// 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;
if (AdjustAndVerify(codec, first_active_layer,
SplitBitrate(num_active_layers, try_rate,
@ -160,10 +160,10 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec,
} else {
DataRate toggling_rate = DataRate::Zero();
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);
}
toggling_rate += DataRate::kbps(
toggling_rate += DataRate::KilobitsPerSec(
codec.spatialLayers[first_active_layer + num_active_layers - 1]
.minBitrate);
return toggling_rate;
@ -199,7 +199,8 @@ VideoBitrateAllocation SvcRateAllocator::Allocate(
VideoBitrateAllocationParameters parameters) {
DataRate total_bitrate = parameters.total_bitrate;
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) {
@ -324,7 +325,8 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
if (num_spatial_layers == 0 ||
total_bitrate <
DataRate::kbps(codec_.spatialLayers[first_active_layer].minBitrate)) {
DataRate::KilobitsPerSec(
codec_.spatialLayers[first_active_layer].minBitrate)) {
// Always enable at least one layer.
bitrate_allocation.SetBitrate(first_active_layer, 0, total_bitrate.bps());
return bitrate_allocation;
@ -336,9 +338,9 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
for (sl_idx = first_active_layer;
sl_idx < first_active_layer + num_spatial_layers; ++sl_idx) {
const DataRate min_rate =
DataRate::kbps(codec_.spatialLayers[sl_idx].minBitrate);
DataRate::KilobitsPerSec(codec_.spatialLayers[sl_idx].minBitrate);
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) {
// 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()) {
// Add leftover to the last allocated layer.
top_layer_rate =
std::min(top_layer_rate + (total_bitrate - allocated_rate),
DataRate::kbps(codec_.spatialLayers[sl_idx - 1].maxBitrate));
top_layer_rate = std::min(
top_layer_rate + (total_bitrate - allocated_rate),
DataRate::KilobitsPerSec(codec_.spatialLayers[sl_idx - 1].maxBitrate));
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();
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);
}
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;

View file

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

View file

@ -1667,7 +1667,7 @@ TEST_F(TestVp9Impl, EncodeWithDynamicRate) {
// Set 300kbps target with 100% headroom.
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.framerate_fps = 30.0;

View file

@ -87,7 +87,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
DataRate left_in_stable_allocation = stable_bitrate;
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_stable_allocation = std::min(left_in_stable_allocation, max_rate);
}
@ -97,7 +97,8 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
if (codec_.active) {
allocated_bitrates->SetBitrate(
0, 0,
std::max(DataRate::kbps(codec_.minBitrate), left_in_total_allocation)
std::max(DataRate::KilobitsPerSec(codec_.minBitrate),
left_in_total_allocation)
.bps());
}
return;
@ -129,7 +130,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
// Always allocate enough bitrate for the minimum bitrate of the first
// active layer. Suspending below min bitrate is controlled outside the
// 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);
left_in_total_allocation = std::max(left_in_total_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
// layers because they require a higher minimum bitrate.
DataRate min_bitrate = DataRate::kbps(stream.minBitrate);
DataRate target_bitrate = DataRate::kbps(stream.targetBitrate);
DataRate min_bitrate = DataRate::KilobitsPerSec(stream.minBitrate);
DataRate target_bitrate = DataRate::KilobitsPerSec(stream.targetBitrate);
double hysteresis_factor =
codec_.mode == VideoCodecMode::kRealtimeVideo
? stable_rate_settings_.GetVideoHysteresisFactor()
@ -193,11 +194,11 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
// better idea of possible performance implications.
if (left_in_total_allocation > DataRate::Zero()) {
const SimulcastStream& stream = codec_.simulcastStream[top_active_layer];
DataRate initial_layer_rate =
DataRate::bps(allocated_bitrates->GetSpatialLayerSum(top_active_layer));
DataRate additional_allocation =
std::min(left_in_total_allocation,
DataRate::kbps(stream.maxBitrate) - initial_layer_rate);
DataRate initial_layer_rate = DataRate::BitsPerSec(
allocated_bitrates->GetSpatialLayerSum(top_active_layer));
DataRate additional_allocation = std::min(
left_in_total_allocation,
DataRate::KilobitsPerSec(stream.maxBitrate) - initial_layer_rate);
allocated_bitrates->SetBitrate(
top_active_layer, 0,
(initial_layer_rate + additional_allocation).bps());

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1229,7 +1229,8 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) {
static const uint32_t kDefaultStartBitrateBps = 300000;
NetworkControllerConfig cc_config;
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;
auto goog_cc = factory.Create(cc_config);

View file

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

View file

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

View file

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

View file

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

View file

@ -215,11 +215,11 @@ void EmulatedEndpointImpl::SendPacket(const rtc::SocketAddress& from,
Timestamp current_time = clock_->CurrentTime();
if (stats_.first_packet_sent_time.IsInfinite()) {
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_.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));
});
@ -291,7 +291,7 @@ void EmulatedEndpointImpl::OnPacketReceived(EmulatedIpPacket packet) {
RTC_LOG(INFO) << "Drop packet: no receiver registered in " << id_
<< " on port " << packet.to.port();
stats_.packets_dropped++;
stats_.bytes_dropped += DataSize::bytes(packet.ip_packet_size());
stats_.bytes_dropped += DataSize::Bytes(packet.ip_packet_size());
return;
}
// 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()) {
stats_.first_packet_received_time = current_time;
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_.packets_received++;
stats_.bytes_received += DataSize::bytes(packet.ip_packet_size());
stats_.bytes_received += DataSize::Bytes(packet.ip_packet_size());
}
EndpointsContainer::EndpointsContainer(

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ struct CallTestConfig {
Scenario()
: random_seed("rs", 1),
return_traffic("ret"),
capacity("bw", DataRate::kbps(300)),
capacity("bw", DataRate::KilobitsPerSec(300)),
propagation_delay("dl", TimeDelta::Millis(100)),
cross_traffic("ct", DataRate::Zero()),
delay_noise("dn", TimeDelta::Zero()),
@ -60,7 +60,7 @@ struct CallTestConfig {
Tuning()
: use_bbr("bbr"),
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) {}
void Parse(std::string config_str) {
ParseFieldTrial(
@ -151,8 +151,8 @@ TEST_P(BbrScenarioTest, ReceivesVideo) {
if (conf_.tuning.use_bbr) {
call_config.transport.cc_factory = &bbr_factory;
}
call_config.transport.rates.min_rate = DataRate::kbps(30);
call_config.transport.rates.max_rate = DataRate::kbps(1800);
call_config.transport.rates.min_rate = DataRate::KilobitsPerSec(30);
call_config.transport.rates.max_rate = DataRate::KilobitsPerSec(1800);
CallClient* alice = s.CreateClient("send", call_config);
CallClient* bob = s.CreateClient("return", call_config);
@ -168,12 +168,12 @@ TEST_P(BbrScenarioTest, ReceivesVideo) {
VideoStreamPair* alice_video =
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) {
if (conf_.tuning.use_bbr) {
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) {
bob_video =
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) {
if (conf_.tuning.use_bbr) {
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);
Scenario s;
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* bob = s.CreateClient("bob", call_client_config);
NetworkSimulationConfig network_config;
@ -35,8 +35,8 @@ TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
s.CreateVideoStream(route->reverse(), video_stream_config);
AudioStreamConfig audio_stream_config;
audio_stream_config.encoder.min_rate = DataRate::kbps(6);
audio_stream_config.encoder.max_rate = DataRate::kbps(64);
audio_stream_config.encoder.min_rate = DataRate::KilobitsPerSec(6);
audio_stream_config.encoder.max_rate = DataRate::KilobitsPerSec(64);
audio_stream_config.encoder.allocate_bitrate = true;
audio_stream_config.stream.in_bandwidth_estimation = false;
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* bob = s.CreateClient("bob", call_config);
NetworkSimulationConfig network_config;
network_config.bandwidth = DataRate::kbps(1000);
network_config.bandwidth = DataRate::KilobitsPerSec(1000);
network_config.delay = TimeDelta::Millis(50);
auto alice_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;
}
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_;
stats_.fec_bitrate.AddSample(fec_delta / time_delta);
}

View file

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

View file

@ -256,7 +256,8 @@ VideoEncoderConfig CreateVideoEncoderConfig(VideoStreamConfig config) {
// TODO(srte): Base this on encoder capabilities.
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 =
CreateEncoderSpecificSettings(config);

View file

@ -109,7 +109,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
LayerRateInfo& layer_info = layer_infos.back();
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).
if (frames_since_layout_change_ < kMinFramesSinceLayoutChange) {
@ -186,8 +186,8 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
// Available link headroom that can be used to fill wanted overshoot.
DataRate available_headroom = DataRate::Zero();
if (utilize_bandwidth_headroom_) {
available_headroom =
rates.bandwidth_allocation - DataRate::bps(rates.bitrate.get_sum_bps());
available_headroom = rates.bandwidth_allocation -
DataRate::BitsPerSec(rates.bitrate.get_sum_bps());
}
// All wanted overshoots are satisfied in the same proportion based on
@ -214,7 +214,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
if (min_bitrates_bps_[si] > 0 &&
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.
utilization_factor =
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.
if (active_tls_[si] == 1 &&
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
// does not seem to support it. Pipe all bitrate into a single
// overshoot detector.
@ -283,7 +283,7 @@ VideoBitrateAllocation EncoderBitrateAdjuster::AdjustRateAllocation(
VideoEncoder::EncoderInfo::kMaxFramerateFraction;
overshoot_detectors_[si][ti]->SetTargetRate(
DataRate::bps(layer_bitrate_bps),
DataRate::BitsPerSec(layer_bitrate_bps),
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.");
EncoderBitrateAdjusterTest()
: target_bitrate_(DataRate::bps(kDefaultBitrateBps)),
: target_bitrate_(DataRate::BitsPerSec(kDefaultBitrateBps)),
target_framerate_fps_(kDefaultFrameRateFps),
tl_pattern_idx_{},
sequence_idx_{} {}
@ -478,7 +478,8 @@ TEST_F(EncoderBitrateAdjusterTest, HeadroomAllowsOvershootToMediaRate) {
current_adjusted_allocation_ =
adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters(
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);
}
}
@ -520,7 +521,7 @@ TEST_F(EncoderBitrateAdjusterTest, DontExceedMediaRateEvenWithHeadroom) {
current_adjusted_allocation_ =
adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters(
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),
current_adjusted_allocation_, 0.015);
}

View file

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

View file

@ -624,24 +624,25 @@ uint32_t VideoSendStreamImpl::OnBitrateUpdated(BitrateAllocationUpdate update) {
DataRate link_allocation = DataRate::Zero();
if (encoder_target_rate_bps_ > protection_bitrate_bps) {
link_allocation =
DataRate::bps(encoder_target_rate_bps_ - protection_bitrate_bps);
DataRate::BitsPerSec(encoder_target_rate_bps_ - protection_bitrate_bps);
}
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;
if (encoder_stable_target_rate > overhead) {
encoder_stable_target_rate = encoder_stable_target_rate - overhead;
} 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_ =
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);
encoder_stable_target_rate =
std::min(DataRate::BitsPerSec(encoder_max_bitrate_bps_),
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);
video_stream_encoder_->OnBitrateUpdated(
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 update;
update.target_bitrate = DataRate::bps(bitrate_bps);
update.target_bitrate = DataRate::BitsPerSec(bitrate_bps);
update.packet_loss_ratio = 0;
update.round_trip_time = TimeDelta::Zero();
return update;
@ -695,7 +695,7 @@ TEST_F(VideoSendStreamImplTest, CallsVideoStreamEncoderOnBitrateUpdate) {
min_transmit_bitrate_bps);
const DataRate network_constrained_rate =
DataRate::bps(qvga_stream.target_bitrate_bps);
DataRate::BitsPerSec(qvga_stream.target_bitrate_bps);
BitrateAllocationUpdate update;
update.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,
// meaning we have some headroom on the link.
const DataRate qvga_max_bitrate =
DataRate::bps(qvga_stream.max_bitrate_bps);
const DataRate headroom = DataRate::bps(50000);
DataRate::BitsPerSec(qvga_stream.max_bitrate_bps);
const DataRate headroom = DataRate::BitsPerSec(50000);
const DataRate rate_with_headroom = qvga_max_bitrate + headroom;
update.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())
.WillOnce(Return(rate_with_headroom.bps()));
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_,
OnBitrateUpdated(qvga_max_bitrate, qvga_max_bitrate,
headroom_minus_protection, 0, _, 0));

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