Change the type of PacedPacketInfo::send_bitrate_bps from int to strongly-typed DataRate.

Bug: webrtc:15532
Change-Id: I84a6b9860d582d68beccdcfde4a12923b2cdbe8b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/322181
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40865}
This commit is contained in:
Sergey Sukhanov 2023-10-04 13:45:02 +02:00 committed by WebRTC LUCI CQ
parent 532a11ee72
commit 4b84f01fe2
4 changed files with 8 additions and 10 deletions

View File

@ -97,7 +97,7 @@ PacedPacketInfo::PacedPacketInfo(int probe_cluster_id,
probe_cluster_min_bytes(probe_cluster_min_bytes) {}
bool PacedPacketInfo::operator==(const PacedPacketInfo& rhs) const {
return send_bitrate_bps == rhs.send_bitrate_bps &&
return send_bitrate == rhs.send_bitrate &&
probe_cluster_id == rhs.probe_cluster_id &&
probe_cluster_min_probes == rhs.probe_cluster_min_probes &&
probe_cluster_min_bytes == rhs.probe_cluster_min_bytes;

View File

@ -93,7 +93,7 @@ struct PacedPacketInfo {
// TODO(srte): Move probing info to a separate, optional struct.
static constexpr int kNotAProbe = -1;
int send_bitrate_bps = -1;
DataRate send_bitrate = DataRate::BitsPerSec(0);
int probe_cluster_id = kNotAProbe;
int probe_cluster_min_probes = -1;
int probe_cluster_min_bytes = -1;

View File

@ -97,7 +97,7 @@ void BitrateProber::CreateProbeCluster(
(cluster_config.target_data_rate * cluster_config.target_duration)
.bytes();
RTC_DCHECK_GE(cluster.pace_info.probe_cluster_min_bytes, 0);
cluster.pace_info.send_bitrate_bps = cluster_config.target_data_rate.bps();
cluster.pace_info.send_bitrate = cluster_config.target_data_rate;
cluster.pace_info.probe_cluster_id = cluster_config.id;
clusters_.push(cluster);
@ -109,7 +109,7 @@ void BitrateProber::CreateProbeCluster(
probing_state_ == ProbingState::kInactive);
RTC_LOG(LS_INFO) << "Probe cluster (bitrate_bps:min bytes:min packets): ("
<< cluster.pace_info.send_bitrate_bps << ":"
<< cluster.pace_info.send_bitrate << ":"
<< cluster.pace_info.probe_cluster_min_bytes << ":"
<< cluster.pace_info.probe_cluster_min_probes << ", "
<< (probing_state_ == ProbingState::kInactive ? "Inactive"
@ -153,8 +153,7 @@ DataSize BitrateProber::RecommendedMinProbeSize() const {
if (clusters_.empty()) {
return DataSize::Zero();
}
DataRate send_rate =
DataRate::BitsPerSec(clusters_.front().pace_info.send_bitrate_bps);
DataRate send_rate = clusters_.front().pace_info.send_bitrate;
return send_rate * config_.min_probe_delta;
}
@ -183,14 +182,13 @@ void BitrateProber::ProbeSent(Timestamp now, DataSize size) {
Timestamp BitrateProber::CalculateNextProbeTime(
const ProbeCluster& cluster) const {
RTC_CHECK_GT(cluster.pace_info.send_bitrate_bps, 0);
RTC_CHECK_GT(cluster.pace_info.send_bitrate.bps(), 0);
RTC_CHECK(cluster.started_at.IsFinite());
// 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::BitsPerSec(cluster.pace_info.send_bitrate_bps);
DataRate send_bitrate = cluster.pace_info.send_bitrate;
TimeDelta delta = sent_bytes / send_bitrate;
return cluster.started_at + delta;

View File

@ -72,7 +72,7 @@ void LogBasedNetworkControllerSimulation::OnPacketSent(
packet.media_type == LoggedMediaType::kVideo) {
auto& probe = pending_probes_.front();
probe_info.probe_cluster_id = probe.event.id;
probe_info.send_bitrate_bps = probe.event.bitrate_bps;
probe_info.send_bitrate = DataRate::BitsPerSec(probe.event.bitrate_bps);
probe_info.probe_cluster_min_bytes = probe.event.min_bytes;
probe_info.probe_cluster_min_probes = probe.event.min_packets;
probe.packets_sent++;