/* * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Keep track of the last time data was produced - how much it was and how // much rate budget has been allocated since then.
DataSize data_allocated_for_last_data = DataSize::Zero();
DataSize size_of_last_data = DataSize::Zero();
RTC_DCHECK(!data_points_.front().produced_data.IsZero()); for (size_t i = 0; i < data_points_.size(); ++i) { const RateUsageUpdate& update = data_points_[i];
total_produced_data += update.produced_data;
if (update.produced_data.IsZero()) { // Just a rate update past the last seen produced data.
data_allocated_for_last_data =
std::min(size_of_last_data, data_allocated_for_last_data +
allocated_since_previous_data_point);
} else { // A newer data point with produced data, reset accumulator for rate // allocated past the last data point.
size_of_last_data = update.produced_data;
data_allocated_for_last_data = DataSize::Zero();
}
}
if (allocated_send_data_size.IsZero() && current_rate_.IsZero()) { // No allocated rate across all of the data points, ignore. return std::nullopt;
}
// Calculate the rate past the very last data point until the polling time. const RateUsageUpdate& last_update = data_points_.back();
DataSize allocated_since_last_data_point =
(time - last_update.time) * last_update.target_rate;
// If the last produced data packet is larger than the accumulated rate // allocation window since then, use that data point size instead (minus any // data rate accumulated in rate updates after that data point was produced).
allocated_send_data_size +=
std::max(allocated_since_last_data_point,
size_of_last_data - data_allocated_for_last_data);
void RateUtilizationTracker::CullOldData(Timestamp time) { // Remove data points that are either too old, exceed the limit of number of // data points - and make sure the first entry in the list contains actual // data produced since we calculate send usage since that time.
// We don't allow negative times so always start window at absolute time >= 0. const Timestamp oldest_included_time =
time.ms() > max_duration_.ms() ? time - max_duration_ : Timestamp::Zero();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.