use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
pub const kCMTimeMaxTimescale: c_uint = 0x7fffffff;
pub type CMTimeValue = i64;
pub type CMTimeScale = i32;
pub type CMTimeEpoch = i64;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMTimeFlags(pub u32);
bitflags::bitflags! {
impl CMTimeFlags: u32 {
#[doc(alias = "kCMTimeFlags_Valid")]
const Valid = 1<<0;
#[doc(alias = "kCMTimeFlags_HasBeenRounded")]
const HasBeenRounded = 1<<1;
#[doc(alias = "kCMTimeFlags_PositiveInfinity")]
const PositiveInfinity = 1<<2;
#[doc(alias = "kCMTimeFlags_NegativeInfinity")]
const NegativeInfinity = 1<<3;
#[doc(alias = "kCMTimeFlags_Indefinite")]
const Indefinite = 1<<4;
#[doc(alias = "kCMTimeFlags_ImpliedValueFlagsMask")]
const ImpliedValueFlagsMask = CMTimeFlags::PositiveInfinity.0|CMTimeFlags::NegativeInfinity.0|CMTimeFlags::Indefinite.0;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMTimeFlags {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMTimeFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(C, packed(4))]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CMTime {
pub value: CMTimeValue,
pub timescale: CMTimeScale,
pub flags: CMTimeFlags,
pub epoch: CMTimeEpoch,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMTime {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<CMTimeValue>::ENCODING,
<CMTimeScale>::ENCODING,
<CMTimeFlags>::ENCODING,
<CMTimeEpoch>::ENCODING,
],
);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMTime {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static kCMTimeInvalid: CMTime;
}
extern "C" {
pub static kCMTimeIndefinite: CMTime;
}
extern "C" {
pub static kCMTimePositiveInfinity: CMTime;
}
extern "C" {
pub static kCMTimeNegativeInfinity: CMTime;
}
extern "C" {
pub static kCMTimeZero: CMTime;
}
impl CMTime {
#[doc(alias = "CMTimeMake")]
#[inline]
pub unsafe fn new(value: i64, timescale: i32) -> CMTime {
extern "C-unwind" {
fn CMTimeMake(value: i64, timescale: i32) -> CMTime;
}
unsafe { CMTimeMake(value, timescale) }
}
#[doc(alias = "CMTimeMakeWithEpoch")]
#[inline]
pub unsafe fn with_epoch(value: i64, timescale: i32, epoch: i64) -> CMTime {
extern "C-unwind" {
fn CMTimeMakeWithEpoch(value: i64, timescale: i32, epoch: i64) -> CMTime;
}
unsafe { CMTimeMakeWithEpoch(value, timescale, epoch) }
}
#[doc(alias = "CMTimeMakeWithSeconds")]
#[inline]
pub unsafe fn with_seconds(seconds: f64, preferred_timescale: i32) -> CMTime {
extern "C-unwind" {
fn CMTimeMakeWithSeconds(seconds: f64, preferred_timescale: i32) -> CMTime;
}
unsafe { CMTimeMakeWithSeconds(seconds, preferred_timescale) }
}
#[doc(alias = "CMTimeGetSeconds")]
#[inline]
pub unsafe fn seconds(self) -> f64 {
extern "C-unwind" {
fn CMTimeGetSeconds(time: CMTime) -> f64;
}
unsafe { CMTimeGetSeconds(self) }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMTimeRoundingMethod(pub u32);
impl CMTimeRoundingMethod {
#[doc(alias = "kCMTimeRoundingMethod_RoundHalfAwayFromZero")]
pub const RoundHalfAwayFromZero: Self = Self(1);
#[doc(alias = "kCMTimeRoundingMethod_RoundTowardZero")]
pub const RoundTowardZero: Self = Self(2);
#[doc(alias = "kCMTimeRoundingMethod_RoundAwayFromZero")]
pub const RoundAwayFromZero: Self = Self(3);
#[doc(alias = "kCMTimeRoundingMethod_QuickTime")]
pub const QuickTime: Self = Self(4);
#[doc(alias = "kCMTimeRoundingMethod_RoundTowardPositiveInfinity")]
pub const RoundTowardPositiveInfinity: Self = Self(5);
#[doc(alias = "kCMTimeRoundingMethod_RoundTowardNegativeInfinity")]
pub const RoundTowardNegativeInfinity: Self = Self(6);
#[doc(alias = "kCMTimeRoundingMethod_Default")]
pub const Default: Self = Self(CMTimeRoundingMethod::RoundHalfAwayFromZero.0);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMTimeRoundingMethod {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMTimeRoundingMethod {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CMTime {
#[doc(alias = "CMTimeConvertScale")]
#[inline]
pub unsafe fn convert_scale(self, new_timescale: i32, method: CMTimeRoundingMethod) -> CMTime {
extern "C-unwind" {
fn CMTimeConvertScale(
time: CMTime,
new_timescale: i32,
method: CMTimeRoundingMethod,
) -> CMTime;
}
unsafe { CMTimeConvertScale(self, new_timescale, method) }
}
#[doc(alias = "CMTimeAdd")]
#[inline]
pub unsafe fn add(self, rhs: CMTime) -> CMTime {
extern "C-unwind" {
fn CMTimeAdd(lhs: CMTime, rhs: CMTime) -> CMTime;
}
unsafe { CMTimeAdd(self, rhs) }
}
#[doc(alias = "CMTimeSubtract")]
#[inline]
pub unsafe fn subtract(self, rhs: CMTime) -> CMTime {
extern "C-unwind" {
fn CMTimeSubtract(lhs: CMTime, rhs: CMTime) -> CMTime;
}
unsafe { CMTimeSubtract(self, rhs) }
}
#[doc(alias = "CMTimeMultiply")]
#[inline]
pub unsafe fn multiply(self, multiplier: i32) -> CMTime {
extern "C-unwind" {
fn CMTimeMultiply(time: CMTime, multiplier: i32) -> CMTime;
}
unsafe { CMTimeMultiply(self, multiplier) }
}
#[doc(alias = "CMTimeMultiplyByFloat64")]
#[inline]
pub unsafe fn multiply_by_float64(self, multiplier: f64) -> CMTime {
extern "C-unwind" {
fn CMTimeMultiplyByFloat64(time: CMTime, multiplier: f64) -> CMTime;
}
unsafe { CMTimeMultiplyByFloat64(self, multiplier) }
}
#[doc(alias = "CMTimeMultiplyByRatio")]
#[inline]
pub unsafe fn multiply_by_ratio(self, multiplier: i32, divisor: i32) -> CMTime {
extern "C-unwind" {
fn CMTimeMultiplyByRatio(time: CMTime, multiplier: i32, divisor: i32) -> CMTime;
}
unsafe { CMTimeMultiplyByRatio(self, multiplier, divisor) }
}
#[doc(alias = "CMTimeCompare")]
#[inline]
pub unsafe fn compare(self, time2: CMTime) -> i32 {
extern "C-unwind" {
fn CMTimeCompare(time1: CMTime, time2: CMTime) -> i32;
}
unsafe { CMTimeCompare(self, time2) }
}
#[doc(alias = "CMTimeMinimum")]
#[inline]
pub unsafe fn minimum(self, time2: CMTime) -> CMTime {
extern "C-unwind" {
fn CMTimeMinimum(time1: CMTime, time2: CMTime) -> CMTime;
}
unsafe { CMTimeMinimum(self, time2) }
}
#[doc(alias = "CMTimeMaximum")]
#[inline]
pub unsafe fn maximum(self, time2: CMTime) -> CMTime {
extern "C-unwind" {
fn CMTimeMaximum(time1: CMTime, time2: CMTime) -> CMTime;
}
unsafe { CMTimeMaximum(self, time2) }
}
#[doc(alias = "CMTimeAbsoluteValue")]
#[inline]
pub unsafe fn absolute_value(self) -> CMTime {
extern "C-unwind" {
fn CMTimeAbsoluteValue(time: CMTime) -> CMTime;
}
unsafe { CMTimeAbsoluteValue(self) }
}
#[doc(alias = "CMTimeCopyAsDictionary")]
#[inline]
pub unsafe fn as_dictionary(
self,
allocator: Option<&CFAllocator>,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CMTimeCopyAsDictionary(
time: CMTime,
allocator: Option<&CFAllocator>,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CMTimeCopyAsDictionary(self, allocator) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "CMTimeMakeFromDictionary")]
#[inline]
pub unsafe fn from_dictionary(dictionary_representation: Option<&CFDictionary>) -> CMTime {
extern "C-unwind" {
fn CMTimeMakeFromDictionary(dictionary_representation: Option<&CFDictionary>)
-> CMTime;
}
unsafe { CMTimeMakeFromDictionary(dictionary_representation) }
}
}
extern "C" {
pub static kCMTimeValueKey: &'static CFString;
}
extern "C" {
pub static kCMTimeScaleKey: &'static CFString;
}
extern "C" {
pub static kCMTimeEpochKey: &'static CFString;
}
extern "C" {
pub static kCMTimeFlagsKey: &'static CFString;
}
impl CMTime {
#[doc(alias = "CMTimeCopyDescription")]
#[inline]
pub unsafe fn description(
allocator: Option<&CFAllocator>,
time: CMTime,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn CMTimeCopyDescription(
allocator: Option<&CFAllocator>,
time: CMTime,
) -> Option<NonNull<CFString>>;
}
let ret = unsafe { CMTimeCopyDescription(allocator, time) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[doc(alias = "CMTimeShow")]
#[inline]
pub unsafe fn show(self) {
extern "C-unwind" {
fn CMTimeShow(time: CMTime);
}
unsafe { CMTimeShow(self) }
}
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::new`"]
pub fn CMTimeMake(value: i64, timescale: i32) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::with_epoch`"]
pub fn CMTimeMakeWithEpoch(value: i64, timescale: i32, epoch: i64) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::with_seconds`"]
pub fn CMTimeMakeWithSeconds(seconds: f64, preferred_timescale: i32) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::seconds`"]
pub fn CMTimeGetSeconds(time: CMTime) -> f64;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::convert_scale`"]
pub fn CMTimeConvertScale(
time: CMTime,
new_timescale: i32,
method: CMTimeRoundingMethod,
) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::add`"]
pub fn CMTimeAdd(lhs: CMTime, rhs: CMTime) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::subtract`"]
pub fn CMTimeSubtract(lhs: CMTime, rhs: CMTime) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::multiply`"]
pub fn CMTimeMultiply(time: CMTime, multiplier: i32) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::multiply_by_float64`"]
pub fn CMTimeMultiplyByFloat64(time: CMTime, multiplier: f64) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::multiply_by_ratio`"]
pub fn CMTimeMultiplyByRatio(time: CMTime, multiplier: i32, divisor: i32) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::compare`"]
pub fn CMTimeCompare(time1: CMTime, time2: CMTime) -> i32;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::minimum`"]
pub fn CMTimeMinimum(time1: CMTime, time2: CMTime) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::maximum`"]
pub fn CMTimeMaximum(time1: CMTime, time2: CMTime) -> CMTime;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::absolute_value`"]
pub fn CMTimeAbsoluteValue(time: CMTime) -> CMTime;
}
#[deprecated = "renamed to `CMTime::as_dictionary`"]
#[inline]
pub unsafe extern "C-unwind" fn CMTimeCopyAsDictionary(
time: CMTime,
allocator: Option<&CFAllocator>,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CMTimeCopyAsDictionary(
time: CMTime,
allocator: Option<&CFAllocator>,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CMTimeCopyAsDictionary(time, allocator) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::from_dictionary`"]
pub fn CMTimeMakeFromDictionary(dictionary_representation: Option<&CFDictionary>) -> CMTime;
}
#[deprecated = "renamed to `CMTime::description`"]
#[inline]
pub unsafe extern "C-unwind" fn CMTimeCopyDescription(
allocator: Option<&CFAllocator>,
time: CMTime,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn CMTimeCopyDescription(
allocator: Option<&CFAllocator>,
time: CMTime,
) -> Option<NonNull<CFString>>;
}
let ret = unsafe { CMTimeCopyDescription(allocator, time) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
extern "C-unwind" {
#[deprecated = "renamed to `CMTime::show`"]
pub fn CMTimeShow(time: CMTime);
}