pub struct Timestamp {
pub value: i64,
pub base: TimeBase,
}Expand description
A timestamp in a particular time base.
Fields§
§value: i64§base: TimeBaseImplementations§
Source§impl Timestamp
impl Timestamp
pub const fn new(value: i64, base: TimeBase) -> Self
Sourcepub fn from_seconds(seconds: f64, base: TimeBase) -> Self
pub fn from_seconds(seconds: f64, base: TimeBase) -> Self
Construct a timestamp at seconds in the given base, rounded
to the nearest tick. Sugar over Timestamp::new(base.ticks_of(s), base).
pub fn seconds(&self) -> f64
pub fn rescale(&self, target: TimeBase) -> Self
Sourcepub fn checked_add_ticks(&self, ticks: i64) -> Option<Self>
pub fn checked_add_ticks(&self, ticks: i64) -> Option<Self>
Advance the timestamp by ticks units in its own base. Returns
None on i64 overflow rather than wrapping silently — muxers
that compute a packet-end timestamp at the edge of the
representable range get a clean signal instead of a wrap.
Sourcepub fn checked_sub_ticks(&self, ticks: i64) -> Option<Self>
pub fn checked_sub_ticks(&self, ticks: i64) -> Option<Self>
Move the timestamp backwards by ticks units in its own base.
Returns None on i64 overflow.
Sourcepub fn checked_diff(&self, other: Timestamp) -> Option<i64>
pub fn checked_diff(&self, other: Timestamp) -> Option<i64>
Tick-difference self - other after rescaling other onto
self’s base. Returns None when the subtraction would overflow
i64 (rare in practice but easy to surface cleanly).
Use this to compute the duration between two Timestamps that
may have been produced by different sources (e.g. a packet from a
container demuxer minus a packet from a different demuxer in a
remux pipeline).