pub struct Clock { /* private fields */ }Expand description
A monotonic clock for stamping media frames so that tracks produced concurrently, e.g. an audio and a video capture running on separate threads, land on a single timeline.
Copies share the epoch and the fixed wall mapping, so handing them to several producers keeps the broadcast on one clock. The wall mapping is established at construction: sampling it when a delayed first frame arrives would pretend that frame is timestamp zero, so the epoch is pinned up front and that frame’s PTS converts into the mapping instead.
Implementations§
Source§impl Clock
impl Clock
Sourcepub const TIMESCALE: Timescale = moq_net::Timescale::MICRO
pub const TIMESCALE: Timescale = moq_net::Timescale::MICRO
Units per second for the broadcast clock: microseconds.
Matches the hang container timescale, so media timestamps convert without loss, and fine enough that the wall value stays within the JSON-safe integer range until the year 2255.
Sourcepub fn new() -> Self
pub fn new() -> Self
Start a clock at the current instant, with PTS zero ten seconds earlier on both the monotonic and the wall clock, so earlier-stamped frames of a source anchored now still map.
Without a wall mapping when the host’s wall clock is unset, or reads a time the mapping can’t name: media needs only the monotonic timeline.
Sourcepub fn at(epoch: Instant, wall: SystemTime) -> Result<Self>
pub fn at(epoch: Instant, wall: SystemTime) -> Result<Self>
Start a clock at an explicit monotonic epoch and wall time.
The deterministic constructor: synthetic sources and fixtures pin both ends instead of sampling. Refuses an unrepresentable wall.
Sourcepub fn wall_clock(&self, pts: Timestamp) -> Result<SystemTime>
pub fn wall_clock(&self, pts: Timestamp) -> Result<SystemTime>
The wall-clock time of pts under this broadcast’s fixed mapping.
Pure in the stored epoch: a system-clock adjustment after construction changes nothing. Refuses an unrepresentable result rather than truncating it, and a clock without a mapping.