Fixed vs adaptive buffers
Fixed buffer: always holds N packets (e.g., 60 ms). Simple, deterministic latency, but bad in changing network conditions. Adaptive: tracks recent jitter statistics, grows buffer in bad networks, shrinks in good. WebRTC's NetEQ is the gold standard.
Advertisement
The math
Target buffer depth = mean + k × std-dev of last-N packet inter-arrival times. With k=2 you cover ~95% of jitter; with k=3, ~99%. Update mean/std every 100ms — too often and you chase noise, too rarely and you lag behind regime changes.
Advertisement
Late vs missing packet decision
def schedule_packet(seq, arrival_ms, play_ms):
if arrival_ms > play_ms:
if arrival_ms - play_ms < LATE_THRESHOLD_MS:
return 'PLAY_LATE' # better late than never
return 'DISCARD' # too late, would cause out-of-order
return 'BUFFER' # arrived in time