objc2_core_video/generated/
CVBase.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// Flags to be used for the display and render call back functions.
10///
11/// ***Values to be defined***
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvoptionflags?language=objc)
14pub type CVOptionFlags = u64;
15
16/// A structure for holding a SMPTE time.
17/// Field: subframes
18/// The number of subframes in the full message.
19/// Field: subframeDivisor
20/// The number of subframes per frame (typically 80).
21/// Field: counter
22/// The total number of messages received.
23/// Field: type
24/// The kind of SMPTE time using the SMPTE time type constants.
25/// Field: flags
26/// A set of flags that indicate the SMPTE state.
27/// Field: hours
28/// The number of hours in the full message.
29/// Field: minutes
30/// The number of minutes in the full message.
31/// Field: seconds
32/// The number of seconds in the full message.
33/// Field: frames
34/// The number of frames in the full message.
35///
36/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvsmptetime?language=objc)
37#[repr(C)]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub struct CVSMPTETime {
40    pub subframes: i16,
41    pub subframeDivisor: i16,
42    pub counter: u32,
43    pub r#type: u32,
44    pub flags: u32,
45    pub hours: i16,
46    pub minutes: i16,
47    pub seconds: i16,
48    pub frames: i16,
49}
50
51#[cfg(feature = "objc2")]
52unsafe impl Encode for CVSMPTETime {
53    const ENCODING: Encoding = Encoding::Struct(
54        "CVSMPTETime",
55        &[
56            <i16>::ENCODING,
57            <i16>::ENCODING,
58            <u32>::ENCODING,
59            <u32>::ENCODING,
60            <u32>::ENCODING,
61            <i16>::ENCODING,
62            <i16>::ENCODING,
63            <i16>::ENCODING,
64            <i16>::ENCODING,
65        ],
66    );
67}
68
69#[cfg(feature = "objc2")]
70unsafe impl RefEncode for CVSMPTETime {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74/// Constants that describe the type of SMPTE time.
75///
76/// 24 Frame
77///
78/// 25 Frame
79///
80/// 30 Drop Frame
81///
82/// 30 Frame
83///
84/// 29.97 Frame
85///
86/// 29.97 Drop Frame
87///
88/// 60 Frame
89///
90/// 59.94 Frame
91///
92/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvsmptetimetype?language=objc)
93// NS_ENUM
94#[repr(transparent)]
95#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
96pub struct CVSMPTETimeType(pub u32);
97impl CVSMPTETimeType {
98    #[doc(alias = "kCVSMPTETimeType24")]
99    pub const Type24: Self = Self(0);
100    #[doc(alias = "kCVSMPTETimeType25")]
101    pub const Type25: Self = Self(1);
102    #[doc(alias = "kCVSMPTETimeType30Drop")]
103    pub const Type30Drop: Self = Self(2);
104    #[doc(alias = "kCVSMPTETimeType30")]
105    pub const Type30: Self = Self(3);
106    #[doc(alias = "kCVSMPTETimeType2997")]
107    pub const Type2997: Self = Self(4);
108    #[doc(alias = "kCVSMPTETimeType2997Drop")]
109    pub const Type2997Drop: Self = Self(5);
110    #[doc(alias = "kCVSMPTETimeType60")]
111    pub const Type60: Self = Self(6);
112    #[doc(alias = "kCVSMPTETimeType5994")]
113    pub const Type5994: Self = Self(7);
114}
115
116#[cfg(feature = "objc2")]
117unsafe impl Encode for CVSMPTETimeType {
118    const ENCODING: Encoding = u32::ENCODING;
119}
120
121#[cfg(feature = "objc2")]
122unsafe impl RefEncode for CVSMPTETimeType {
123    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
124}
125
126/// Flags that describe the SMPTE time state.
127///
128/// The full time is valid.
129///
130/// Time is running.
131///
132/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvsmptetimeflags?language=objc)
133// NS_OPTIONS
134#[repr(transparent)]
135#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
136pub struct CVSMPTETimeFlags(pub u32);
137bitflags::bitflags! {
138    impl CVSMPTETimeFlags: u32 {
139        #[doc(alias = "kCVSMPTETimeValid")]
140        const Valid = 1<<0;
141        #[doc(alias = "kCVSMPTETimeRunning")]
142        const Running = 1<<1;
143    }
144}
145
146#[cfg(feature = "objc2")]
147unsafe impl Encode for CVSMPTETimeFlags {
148    const ENCODING: Encoding = u32::ENCODING;
149}
150
151#[cfg(feature = "objc2")]
152unsafe impl RefEncode for CVSMPTETimeFlags {
153    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
154}
155
156/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvtimeflags?language=objc)
157// NS_OPTIONS
158#[repr(transparent)]
159#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
160pub struct CVTimeFlags(pub i32);
161bitflags::bitflags! {
162    impl CVTimeFlags: i32 {
163        #[doc(alias = "kCVTimeIsIndefinite")]
164        const IsIndefinite = 1<<0;
165    }
166}
167
168#[cfg(feature = "objc2")]
169unsafe impl Encode for CVTimeFlags {
170    const ENCODING: Encoding = i32::ENCODING;
171}
172
173#[cfg(feature = "objc2")]
174unsafe impl RefEncode for CVTimeFlags {
175    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
176}
177
178/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvtime?language=objc)
179#[repr(C)]
180#[derive(Clone, Copy, Debug, PartialEq)]
181pub struct CVTime {
182    pub timeValue: i64,
183    pub timeScale: i32,
184    pub flags: i32,
185}
186
187#[cfg(feature = "objc2")]
188unsafe impl Encode for CVTime {
189    const ENCODING: Encoding =
190        Encoding::Struct("?", &[<i64>::ENCODING, <i32>::ENCODING, <i32>::ENCODING]);
191}
192
193#[cfg(feature = "objc2")]
194unsafe impl RefEncode for CVTime {
195    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
196}
197
198/// CoreVideo uses a CVTimeStamp structure to store video display time stamps.
199///
200/// This structure is purposely very similar to AudioTimeStamp defined in the CoreAudio framework.
201/// Most of the CVTimeStamp struct should be fairly self-explanatory. However, it is probably worth pointing out that unlike the audio time stamps, floats are not used to represent the video equivalent of sample times. This was done partly to avoid precision issues, and partly because QuickTime still uses integers for time values and time scales. In the actual implementation it has turned out to be very convenient to use integers, and we can represent framerates like NTSC (30000/1001 fps) exactly. The mHostTime structure field uses the same Mach absolute time base that is used in CoreAudio, so that clients of the CoreVideo API can synchronize between the two subsystems.
202/// Field: version The current CVTimeStamp is version 0.
203/// Field: videoTimeScale The scale (in units per second) of the videoTime and videoPeriod values
204/// Field: videoTime This represents the start of a frame (or field for interlaced)
205/// Field: hostTime Host root timebase time
206/// Field: rateScalar This is the current rate of the device as measured by the timestamps, divided by the nominal rate
207/// Field: videoRefreshPeriod This is the nominal update period of the current output device
208/// Field: smpteTime SMPTE time representation of the time stamp.
209/// Field: flags Possible values are:
210/// kCVTimeStampVideoTimeValid
211/// kCVTimeStampHostTimeValid
212/// kCVTimeStampSMPTETimeValid
213/// kCVTimeStampVideoPeriodValid
214/// kCVTimeStampRateScalarValid
215/// There are flags for each field to make it easier to detect interlaced vs progressive output
216/// kCVTimeStampTopField
217/// kCVTimeStampBottomField
218/// Some commonly used combinations of timestamp flags
219/// kCVTimeStampVideoHostTimeValid
220/// kCVTimeStampIsInterlaced
221/// Field: reserved Reserved. Do not use.
222///
223/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvtimestamp?language=objc)
224#[repr(C)]
225#[derive(Clone, Copy, Debug, PartialEq)]
226pub struct CVTimeStamp {
227    pub version: u32,
228    pub videoTimeScale: i32,
229    pub videoTime: i64,
230    pub hostTime: u64,
231    pub rateScalar: c_double,
232    pub videoRefreshPeriod: i64,
233    pub smpteTime: CVSMPTETime,
234    pub flags: u64,
235    pub reserved: u64,
236}
237
238#[cfg(feature = "objc2")]
239unsafe impl Encode for CVTimeStamp {
240    const ENCODING: Encoding = Encoding::Struct(
241        "?",
242        &[
243            <u32>::ENCODING,
244            <i32>::ENCODING,
245            <i64>::ENCODING,
246            <u64>::ENCODING,
247            <c_double>::ENCODING,
248            <i64>::ENCODING,
249            <CVSMPTETime>::ENCODING,
250            <u64>::ENCODING,
251            <u64>::ENCODING,
252        ],
253    );
254}
255
256#[cfg(feature = "objc2")]
257unsafe impl RefEncode for CVTimeStamp {
258    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
259}
260
261/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvtimestampflags?language=objc)
262// NS_OPTIONS
263#[repr(transparent)]
264#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
265pub struct CVTimeStampFlags(pub u64);
266bitflags::bitflags! {
267    impl CVTimeStampFlags: u64 {
268        #[doc(alias = "kCVTimeStampVideoTimeValid")]
269        const VideoTimeValid = 1<<0;
270        #[doc(alias = "kCVTimeStampHostTimeValid")]
271        const HostTimeValid = 1<<1;
272        #[doc(alias = "kCVTimeStampSMPTETimeValid")]
273        const SMPTETimeValid = 1<<2;
274        #[doc(alias = "kCVTimeStampVideoRefreshPeriodValid")]
275        const VideoRefreshPeriodValid = 1<<3;
276        #[doc(alias = "kCVTimeStampRateScalarValid")]
277        const RateScalarValid = 1<<4;
278        #[doc(alias = "kCVTimeStampTopField")]
279        const TopField = 1<<16;
280        #[doc(alias = "kCVTimeStampBottomField")]
281        const BottomField = 1<<17;
282        #[doc(alias = "kCVTimeStampVideoHostTimeValid")]
283        const VideoHostTimeValid = CVTimeStampFlags::VideoTimeValid.0|CVTimeStampFlags::HostTimeValid.0;
284        #[doc(alias = "kCVTimeStampIsInterlaced")]
285        const IsInterlaced = CVTimeStampFlags::TopField.0|CVTimeStampFlags::BottomField.0;
286    }
287}
288
289#[cfg(feature = "objc2")]
290unsafe impl Encode for CVTimeStampFlags {
291    const ENCODING: Encoding = u64::ENCODING;
292}
293
294#[cfg(feature = "objc2")]
295unsafe impl RefEncode for CVTimeStampFlags {
296    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
297}
298
299extern "C" {
300    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvzerotime?language=objc)
301    pub static kCVZeroTime: CVTime;
302}
303
304extern "C" {
305    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvindefinitetime?language=objc)
306    pub static kCVIndefiniteTime: CVTime;
307}