pub struct MediaTime(/* private fields */);
Expand description
Media timeline offset represented by a count (numerator) / frequency (denominator) in seconds.
The numerator is typically the packet time of an Rtp header. The denominator is the clock frequency of the media source (typically 90kHz for video and 48kHz for audio). The denominator is guaranteed to be a positive integer while the numerator could be positive, negative, or zero.
The frequency can be found in the negotiated payload parameters for a media writer.
// Obtain mid from Event::MediaAdded
let mid: Mid = todo!();
// Create a media writer for the mid.
let writer = rtc.writer(mid).unwrap();
// Get the payload type (pt) for the wanted codec.
let params = writer.payload_params().nth(0).unwrap();
// Obtain the frequency for the selected codec.
let freq = params.spec().clock_rate;
let mtime = MediaTime::new(2000, freq);
Implementations§
Source§impl MediaTime
impl MediaTime
Sourcepub const fn from_micros(v: i64) -> MediaTime
pub const fn from_micros(v: i64) -> MediaTime
Convenience constructor for numbers of microseconds (v/1_000_000).
Sourcepub const fn from_fixed_point_6_18(v: i64) -> MediaTime
pub const fn from_fixed_point_6_18(v: i64) -> MediaTime
Convenience constructor for numbers of 24-bit 6.18 fixed point units (v/2^18).
Sourcepub const fn from_90khz(v: i64) -> MediaTime
pub const fn from_90khz(v: i64) -> MediaTime
Convenience constructor for numbers of 90kHz units (v/90_000).
Sourcepub const fn from_millis(v: i64) -> MediaTime
pub const fn from_millis(v: i64) -> MediaTime
Convenience constructor for numbers of milliseconds (v/1000).
Sourcepub const fn from_hundredths(v: i64) -> MediaTime
pub const fn from_hundredths(v: i64) -> MediaTime
Convenience constructor for numbers of hundredths of seconds (v/100).
Sourcepub const fn from_secs(v: i64) -> MediaTime
pub const fn from_secs(v: i64) -> MediaTime
Convenience constructor for numbers of seconds (v/1).
Sourcepub fn from_seconds(v: impl Into<f64>) -> MediaTime
pub fn from_seconds(v: impl Into<f64>) -> MediaTime
Convenience constructor for floating point fractions of seconds as microsecond units.
Sourcepub fn as_seconds(&self) -> f64
pub fn as_seconds(&self) -> f64
A floating point fraction second representation.
Trait Implementations§
Source§impl AddAssign<MediaTime> for Instant
impl AddAssign<MediaTime> for Instant
Source§fn add_assign(&mut self, rhs: MediaTime)
fn add_assign(&mut self, rhs: MediaTime)
+=
operation. Read moreSource§impl AddAssign for MediaTime
impl AddAssign for MediaTime
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl Ord for MediaTime
impl Ord for MediaTime
Source§impl PartialOrd for MediaTime
impl PartialOrd for MediaTime
Source§impl SubAssign<MediaTime> for Instant
impl SubAssign<MediaTime> for Instant
Source§fn sub_assign(&mut self, rhs: MediaTime)
fn sub_assign(&mut self, rhs: MediaTime)
-=
operation. Read moreSource§impl SubAssign for MediaTime
impl SubAssign for MediaTime
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more