webrtc_cc_rate (webrtc v0.1.0)

View Source

Bit rate over a sliding time window, in one-millisecond buckets.

add/3 records bytes at a time in milliseconds and rate/2 returns the bit rate over the window ending at a time. A sample older than the newest bucket is merged into it (reordering by a few milliseconds does not matter at the window scale). The rate is undefined until the first sample is a whole window old, so a short burst at start is not reported as a high rate. Memory is bounded by the window length: at most one bucket per millisecond.

Summary

Functions

Bytes recorded in (T - window, T].

Bits per second over (T - window, T].

Types

rate/0

-opaque rate()

Functions

add(T, Bytes, Rate)

-spec add(integer(), non_neg_integer(), rate()) -> rate().

bytes(T, R)

-spec bytes(integer(), rate()) -> non_neg_integer().

Bytes recorded in (T - window, T].

new(WindowMs)

-spec new(pos_integer()) -> rate().

rate(T, Rate)

-spec rate(integer(), rate()) -> non_neg_integer() | undefined.

Bits per second over (T - window, T].