@(webrtc)[webrtc, congestion control]
Webrtc delay-base-bwe代码分析(1): RateStatistics模块
RateStatistics这个类的作用为记录一个时间窗口内的速率值,并返回当前时间区域内的码率值。单独开一个文章主要是用来描述其用来记录速率值的桶,一开始看的比较迷糊。
class RateStatistics {
// Counters are kept in buckets (circular buffer), with one bucket
// per millisecond.
// 每毫秒一个记录值。
struct Bucket {
size_t sum; // Sum of all samples in this bucket.
size_t samples; // Number of samples in this bucket.
};
std::unique_ptr<Bucket[]> buckets_;
// 统计总值,一个为总的传输字节数,一个为这个单位时间内,总的采样点数。
// Total count recorded in buckets.
size_t accumulated_count_;
// The total number of samples in the buckets.
size_t num_samples_;
// 某个采样时间内的时间起点。包括时间值和索引值。
// Oldest time recorded in buckets.
int64_t oldest_time_;
// Bucket index of oldest counter recorded in buckets.
uint32_t old