Skip to main content

buffering_runtime/
lib.rs

1#![no_std]
2#![forbid(unsafe_code)]
3#![doc = include_str!("../README.md")]
4// The README is the single text for crates.io and docs.rs (docs/DOC-STANDARD.md rule 1).
5
6extern crate alloc;
7
8pub mod config;
9pub mod controller;
10pub mod error;
11pub mod events;
12pub mod histogram;
13pub mod jitter;
14pub mod policy;
15pub mod stall_memory;
16pub mod tracks;
17pub mod window;
18
19pub use config::{ControllerConfig, JitterConfig, Micros, PolicyConfig, Ticks27, US_PER_S};
20pub use controller::BufferController;
21pub use error::{ConfigField, Error};
22pub use events::{Event, EventRecord, Hint, Reason, State, Stats, kind};
23pub use jitter::{DeliveryJitter, JitterEstimate, SampleOutcome};
24pub use stall_memory::StallMemorySnapshot;
25pub use tracks::{COALESCE_US, DEFAULT_TRACK, MAX_TRACKS};
26
27use broadcast_common::clock33::{PCR_EXT_MODULUS, WRAP_33BIT};
28
29/// C-ABI revision of the plain-data surface ([`EventRecord`], the `u32`
30/// codes of [`State`]/[`Reason`]/[`Hint`], the event [`kind`] codes). Bumped
31/// when any of them changes shape or meaning. Version 2 added the
32/// `track` / `track_valid` pair to [`EventRecord`] (40 bytes, was 32).
33pub const ABI_VERSION: u32 = 2;
34
35/// A 90 kHz PTS (33-bit, wrapped) as 27 MHz ticks in the playback domain:
36/// `PTS x 300`, exact and wrap-consistent (one PTS wrap is one
37/// `PCR_WRAP_27MHZ`).
38#[must_use]
39pub fn pts90k_to_27mhz(pts: u64) -> Ticks27 {
40    (pts % WRAP_33BIT) * PCR_EXT_MODULUS
41}