Expand description
Shared timeline — MediaTime, MediaDuration, MediaClock,
Timestamped<T> (M-MEDIA.2 / AUT-98).
Every audio chunk, video frame, cursor event, and visualization window in the recorder is stamped against a single timeline. This module is that timeline’s vocabulary.
§Why nanoseconds
Internal representation is i64 nanoseconds (signed so a
pre-origin offset is representable). i64::MAX nanoseconds is
≈ 292 years — comfortable headroom for any recorder session.
f64 seconds drops below 1 µs precision past ~10⁹ s; nanoseconds
stay exact through arithmetic.
§Conversion helpers
use media::clock::MediaTime;
// 30 fps, frame 90 → 3.0 s.
let t = MediaTime::from_frame(90, 30.0);
assert!((t.as_seconds() - 3.0).abs() < 1e-9);
// 48 kHz, sample 48 000 → 1.0 s.
let t = MediaTime::from_sample(48_000, 48_000);
assert!((t.as_seconds() - 1.0).abs() < 1e-9);§MediaClock modes
MediaClock::wall_clock— anchored toInstant::now(); production.MediaClock::manual— driven by explicitMediaClock::advance_by; tests + headless examples that need byte-exact reproducibility.
Structs§
- Media
Clock - Authoritative timeline source. Capture pipelines stamp their
chunks/frames against a single shared
MediaClockso audio, video, cursor, andwispoverlays all agree on “now.” - Media
Duration - An interval between two
MediaTimevalues. Resolution is nanoseconds. Can be negative (e.g., when measuring drift). - Media
Time - One point on the media timeline. Resolution is nanoseconds.
- Timestamped
- A value carried with its position on the media timeline.