Skip to main content

Module clock

Module clock 

Source
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

Structs§

MediaClock
Authoritative timeline source. Capture pipelines stamp their chunks/frames against a single shared MediaClock so audio, video, cursor, and wisp overlays all agree on “now.”
MediaDuration
An interval between two MediaTime values. Resolution is nanoseconds. Can be negative (e.g., when measuring drift).
MediaTime
One point on the media timeline. Resolution is nanoseconds.
Timestamped
A value carried with its position on the media timeline.

Enums§

ClockInner 🔒

Functions§

index_as_f64 🔒
nanos_from_seconds 🔒