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 input_log;
14pub mod jitter;
15pub mod policy;
16pub mod stall_memory;
17pub mod tracks;
18pub mod window;
19
20pub use config::{ControllerConfig, JitterConfig, Micros, PolicyConfig, Ticks27, US_PER_S};
21pub use controller::BufferController;
22pub use error::{ConfigField, Error};
23pub use events::{Event, EventRecord, Hint, Reason, State, Stats, kind};
24pub use jitter::{DeliveryJitter, JitterEstimate, SampleOutcome};
25pub use stall_memory::StallMemorySnapshot;
26pub use tracks::{COALESCE_US, DEFAULT_TRACK, MAX_TRACKS};
27
28use broadcast_common::clock33::{PCR_EXT_MODULUS, WRAP_33BIT};
29
30/// C-ABI revision of the plain-data surface ([`EventRecord`], the `u32`
31/// codes of [`State`]/[`Reason`]/[`Hint`], the event [`kind`] codes). Bumped
32/// when any of them changes shape or meaning. Version 2 added the
33/// `track` / `track_valid` pair to [`EventRecord`] (40 bytes, was 32).
34pub const ABI_VERSION: u32 = 2;
35
36/// A 90 kHz PTS (33-bit, wrapped) as 27 MHz ticks in the playback domain:
37/// `PTS x 300`, exact and wrap-consistent (one PTS wrap is one
38/// `PCR_WRAP_27MHZ`).
39#[must_use]
40pub fn pts90k_to_27mhz(pts: u64) -> Ticks27 {
41    (pts % WRAP_33BIT) * PCR_EXT_MODULUS
42}