Skip to main content

jitter_buffer

Function jitter_buffer 

Source
pub fn jitter_buffer(
    source: Stream,
    clock: Symbol,
    max_late_packets: u32,
) -> Stream
Expand description

Reorders packets by clock tick within a bounded latency window.

The buffer keeps an online reordering window of max_late_packets + 1 packets: it pulls only enough of source to fill that window (never draining a live source to its end), then emits the lowest-tick packet, breaking ties by arrival order so equal ticks stay stable. A packet whose tick falls below the last emitted tick has arrived more than max_late_packets positions behind the highest accepted tick; it is dropped and counted rather than reordered. With max_late_packets of 0 the window is a single packet, so any out-of-order packet is dropped.