#[repr(C)]pub struct CMTime {
pub value: i64,
pub timescale: i32,
pub flags: u32,
pub epoch: i64,
}cm only.Expand description
CMTime representation matching Core Media’s CMTime
Represents a rational time value with a 64-bit numerator and 32-bit denominator.
§Examples
use apple_cf::cm::CMTime;
// Create a time of 1 second (30/30)
let time = CMTime::new(30, 30);
assert_eq!(time.as_seconds(), Some(1.0));
// Create a time of 2.5 seconds at 1000 Hz timescale
let time = CMTime::new(2500, 1000);
assert_eq!(time.value, 2500);
assert_eq!(time.timescale, 1000);
assert_eq!(time.as_seconds(), Some(2.5));Fields§
§value: i64§timescale: i32§flags: u32§epoch: i64Implementations§
Source§impl CMTime
impl CMTime
pub const ZERO: Self
pub const INVALID: Self
pub const fn new(value: i64, timescale: i32) -> Self
pub const fn is_valid(&self) -> bool
Sourcepub const fn is_indefinite(&self) -> bool
pub const fn is_indefinite(&self) -> bool
Check if this time is indefinite
Sourcepub const fn is_positive_infinity(&self) -> bool
pub const fn is_positive_infinity(&self) -> bool
Check if this time is positive infinity
Sourcepub const fn is_negative_infinity(&self) -> bool
pub const fn is_negative_infinity(&self) -> bool
Check if this time is negative infinity
Sourcepub const fn has_been_rounded(&self) -> bool
pub const fn has_been_rounded(&self) -> bool
Check if this time has been rounded
Sourcepub const fn equals(&self, other: &Self) -> bool
pub const fn equals(&self, other: &Self) -> bool
Compare two times for equality (value and timescale)
Sourcepub const fn positive_infinity() -> Self
pub const fn positive_infinity() -> Self
Create a time representing positive infinity
Sourcepub const fn negative_infinity() -> Self
pub const fn negative_infinity() -> Self
Create a time representing negative infinity
Sourcepub const fn indefinite() -> Self
pub const fn indefinite() -> Self
Create an indefinite time
pub fn as_seconds(&self) -> Option<f64>
Sourcepub fn from_seconds(seconds: f64, preferred_timescale: i32) -> Self
pub fn from_seconds(seconds: f64, preferred_timescale: i32) -> Self
Construct a CMTime from a floating-point number of seconds
with the requested preferred_timescale (typically 600 for
video, 48000 / 44100 for audio). Wraps CMTimeMakeWithSeconds.
Sourcepub fn add(self, other: Self) -> Self
pub fn add(self, other: Self) -> Self
Add two times. Wraps CMTimeAdd. Returns
CMTime::INVALID if either operand is invalid.
Sourcepub fn multiply_by_f64(self, factor: f64) -> Self
pub fn multiply_by_f64(self, factor: f64) -> Self
Multiply by an f64 factor. Wraps CMTimeMultiplyByFloat64.
Sourcepub fn compare(self, other: Self) -> Ordering
pub fn compare(self, other: Self) -> Ordering
Compare two times. Returns Ordering::Less if self < other,
Greater if self > other, Equal otherwise. Wraps
CMTimeCompare.
Sourcepub fn convert_scale(self, new_timescale: i32) -> Self
pub fn convert_scale(self, new_timescale: i32) -> Self
Convert this time to a different new_timescale, applying
Apple’s default rounding (kCMTimeRoundingMethod_Default).
Wraps CMTimeConvertScale.