Skip to main content

audio_frame_grid

Function audio_frame_grid 

Source
pub fn audio_frame_grid(
    timestamps: &[i64],
    num: i64,
    den: i64,
    sample_rate: u32,
) -> Option<AudioFrameGrid>
Expand description

The frame grid shown by an audio stream’s first packet timestamps (any order, in num / den second units) at sample_rate, or None.

The rounding unit is rounding_quantum, or one time-base unit when none shows. Every timestamp must lie within half a unit of the grid. Among whole-sample periods that fit, the one with the most slack wins (shortest on ties), and the anchor is the middle of its feasible range.

Returns None when half a unit is under a sample (timestamps are already exact), when fewer than three distinct timestamps are given or none fits (variable frame sizes, a missing packet), when no period exceeds twice the trimmed tolerance, or when an argument is not positive.