Skip to main content

Clock

Struct Clock 

Source
pub struct Clock { /* private fields */ }
Expand description

A 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.

It never runs backward, and runs at the host wall clock’s rate: each read nudges it toward the wall clock by at most 500 ppm, and it jumps forward across a suspend. Clones share the timeline and the wall mapping, so handing them to several producers keeps the broadcast on one clock. Two clocks are equal only when they are one timeline.

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 2305.

Source

pub fn new() -> Self

Start a clock that reads ten seconds now, so PTS zero is ten seconds ago on the wall.

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: Wall) -> Result<Self>

Start a clock at an explicit monotonic epoch and wall time: PTS zero at both.

The deterministic constructor: synthetic sources and fixtures pin both ends instead of sampling. epoch is an instant on the ambient clock, which the clock keeps reading wherever it is read from. Refuses an unrepresentable wall.

Source

pub fn now(&self) -> Timestamp

The current timestamp on this clock.

Source

pub fn capture(&self, at: Instant) -> Result<Timestamp>

Map the instant a payload was captured (a datagram’s arrival, a sensor read) onto this clock.

at is an instant on the ambient clock this one was created under, which is the host’s outside tests. Refuses an instant ahead of now, which would claim the payload reached the transport before it existed, and one before PTS zero, which no timestamp can name.

Source

pub fn timescale(&self) -> Timescale

Units per second for wall: TIMESCALE.

Source

pub fn wall(&self) -> Option<Clock>

The catalog root section advertising this clock, or None if the broadcast has no wall mapping: the host’s wall clock was unset, or the source advertised none.

Source

pub fn wall_clock(&self, pts: Timestamp) -> Result<Wall>

The wall-clock time of pts under this broadcast’s mapping.

Pure in the stored mapping: a system-clock adjustment after construction changes nothing. Exact down to the nanosecond; an instant finer than that (a 90 kHz tick) is floored. Refuses an unrepresentable result, and a clock without a mapping.

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 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
Source§

impl Eq for Clock

Source§

impl PartialEq for Clock

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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