Skip to main content

Clock

Struct Clock 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn now(&self) -> Timestamp

The current timestamp since the clock’s epoch.

Source

pub fn timescale(&self) -> Timescale

Units per second for wall: TIMESCALE.

Source

pub fn wall(&self) -> Clock

The catalog root section advertising this clock.

§Panics

If the host’s wall clock was unset (before 2020) when this clock was created by new, leaving no mapping to advertise.

Source

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.

Source

pub fn source(&self) -> SourceMap

Translate a source with its own zero onto this broadcast’s mapping.

Each adapter owns one per source; see SourceMap. The mapping itself is untouched.

Trait Implementations§

Source§

impl Clone for Clock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Clock

Source§

impl Debug for Clock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Clock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Clock

§

impl RefUnwindSafe for Clock

§

impl Send for Clock

§

impl Sync for Clock

§

impl Unpin for Clock

§

impl UnsafeUnpin for Clock

§

impl UnwindSafe for Clock

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more