objc2_core_video/generated/
CVDisplayLink.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvdisplaylink?language=objc)
14#[repr(C)]
15pub struct CVDisplayLink {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    #[encoding_name = "__CVDisplayLink"]
22    unsafe impl CVDisplayLink {}
23);
24
25/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvdisplaylinkoutputcallback?language=objc)
26#[cfg(all(feature = "CVBase", feature = "CVReturn"))]
27pub type CVDisplayLinkOutputCallback = Option<
28    unsafe extern "C-unwind" fn(
29        NonNull<CVDisplayLink>,
30        NonNull<CVTimeStamp>,
31        NonNull<CVTimeStamp>,
32        CVOptionFlags,
33        NonNull<CVOptionFlags>,
34        *mut c_void,
35    ) -> CVReturn,
36>;
37
38/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvdisplaylinkoutputhandler?language=objc)
39#[cfg(all(feature = "CVBase", feature = "CVReturn", feature = "block2"))]
40pub type CVDisplayLinkOutputHandler = *mut block2::Block<
41    dyn Fn(
42        NonNull<CVDisplayLink>,
43        NonNull<CVTimeStamp>,
44        NonNull<CVTimeStamp>,
45        CVOptionFlags,
46        NonNull<CVOptionFlags>,
47    ) -> CVReturn,
48>;
49
50unsafe impl ConcreteType for CVDisplayLink {
51    #[doc(alias = "CVDisplayLinkGetTypeID")]
52    #[inline]
53    fn type_id() -> CFTypeID {
54        extern "C-unwind" {
55            fn CVDisplayLinkGetTypeID() -> CFTypeID;
56        }
57        unsafe { CVDisplayLinkGetTypeID() }
58    }
59}
60
61extern "C-unwind" {
62    /// General call to create a CVDisplayLink
63    ///
64    /// Use this call to create a CVDisplayLink for a set of displays indentified by the CGDirectDisplayIDs.
65    ///
66    /// Parameter `displayArray`: array of CGDirectDisplayIDs
67    ///
68    /// Parameter `count`: number of displays in the displayArray
69    ///
70    /// Parameter `displayLinkOut`: The new display link will be returned here
71    ///
72    /// Returns: returns kCVReturnSuccess on success.
73    #[cfg(all(feature = "CVReturn", feature = "objc2-core-graphics"))]
74    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
75    pub fn CVDisplayLinkCreateWithCGDisplays(
76        display_array: NonNull<CGDirectDisplayID>,
77        count: CFIndex,
78        display_link_out: NonNull<*mut CVDisplayLink>,
79    ) -> CVReturn;
80}
81
82extern "C-unwind" {
83    /// Convenience call to create a CVDisplayLink from an OpenGL display mask.
84    ///
85    /// Use this call to create a CVDisplayLink for a CGOpenGLDisplayMask.
86    ///
87    /// Parameter `mask`: CGOpenGLDisplayMask describing the display
88    ///
89    /// Parameter `displayLinkOut`: The new display link will be returned here
90    ///
91    /// Returns: returns kCVReturnSuccess on success.
92    #[cfg(all(feature = "CVReturn", feature = "objc2-core-graphics"))]
93    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
94    pub fn CVDisplayLinkCreateWithOpenGLDisplayMask(
95        mask: CGOpenGLDisplayMask,
96        display_link_out: NonNull<*mut CVDisplayLink>,
97    ) -> CVReturn;
98}
99
100extern "C-unwind" {
101    /// Convenience call to create a CVDisplayLink for a single CGDirectDisplay.
102    ///
103    /// Use this call to create a CVDisplayLink for a single CGDirectDisplay.
104    ///
105    /// Parameter `displayID`: CGDirectDisplayID of the target display
106    ///
107    /// Parameter `displayLinkOut`: The new display link will be returned here
108    ///
109    /// Returns: returns kCVReturnSuccess on success.
110    #[cfg(all(feature = "CVReturn", feature = "objc2-core-graphics"))]
111    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
112    pub fn CVDisplayLinkCreateWithCGDisplay(
113        display_id: CGDirectDisplayID,
114        display_link_out: NonNull<*mut CVDisplayLink>,
115    ) -> CVReturn;
116}
117
118extern "C-unwind" {
119    /// Convenience function to create a CVDisplayLink capable of being used with all active CGDisplays
120    ///
121    /// Parameter `displayLinkOut`: The newly created CVDisplayLink
122    ///
123    /// Returns: kCVReturnSuccess if the device was created, or failure
124    #[cfg(feature = "CVReturn")]
125    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
126    pub fn CVDisplayLinkCreateWithActiveCGDisplays(
127        display_link_out: NonNull<*mut CVDisplayLink>,
128    ) -> CVReturn;
129}
130
131extern "C-unwind" {
132    /// Sets the current display of a DisplayLink
133    ///
134    /// It is safe to call this with a running display link, but be aware that there will likely be a timestamp
135    /// discontinuity in the video time stamp
136    ///
137    /// Parameter `displayLink`: target CVDisplayLinkRef
138    ///
139    /// Parameter `displayID`: target CGDirectDisplayID
140    ///
141    /// Returns: CVReturn. kCVReturnSuccess if successfull.
142    #[cfg(all(feature = "CVReturn", feature = "objc2-core-graphics"))]
143    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
144    pub fn CVDisplayLinkSetCurrentCGDisplay(
145        display_link: &CVDisplayLink,
146        display_id: CGDirectDisplayID,
147    ) -> CVReturn;
148}
149
150extern "C-unwind" {
151    /// Gets the current display of a DisplayLink
152    ///
153    /// (description)
154    ///
155    /// Parameter `displayLink`: target CVDisplayLinkRef
156    ///
157    /// Returns: CGDirectDisplayID
158    #[cfg(feature = "objc2-core-graphics")]
159    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
160    pub fn CVDisplayLinkGetCurrentCGDisplay(display_link: &CVDisplayLink) -> CGDirectDisplayID;
161}
162
163extern "C-unwind" {
164    /// Set the renderer output callback function
165    ///
166    /// The DisplayLink will invoke this callback whenever it wants you to output a frame.
167    ///
168    /// Parameter `displayLink`: target CVDisplayLinkRef
169    ///
170    /// Parameter `callback`: CVDisplayLinkOutputCallback function
171    ///
172    /// Parameter `userInfo`: User data for the callback to identify the context.
173    ///
174    /// Returns: CVReturn. kCVReturnSuccess if successfull.
175    #[cfg(all(feature = "CVBase", feature = "CVReturn"))]
176    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
177    pub fn CVDisplayLinkSetOutputCallback(
178        display_link: &CVDisplayLink,
179        callback: CVDisplayLinkOutputCallback,
180        user_info: *mut c_void,
181    ) -> CVReturn;
182}
183
184extern "C-unwind" {
185    /// Set the renderer output callback block
186    ///
187    /// The DisplayLink will invoke this block whenever it wants you to output a frame. You can only have a block or a callback function; not both.
188    ///
189    /// Parameter `displayLink`: target CVDisplayLinkRef
190    ///
191    /// Parameter `handler`: CVDisplayLinkOutputHandler block
192    ///
193    /// Returns: CVReturn. kCVReturnSuccess if successful.
194    #[cfg(all(feature = "CVBase", feature = "CVReturn", feature = "block2"))]
195    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
196    pub fn CVDisplayLinkSetOutputHandler(
197        display_link: &CVDisplayLink,
198        handler: CVDisplayLinkOutputHandler,
199    ) -> CVReturn;
200}
201
202extern "C-unwind" {
203    /// Start timer for DisplayLink
204    ///
205    /// This call should not be made from inside the CVDisplayLinkOutputCallback
206    ///
207    /// Parameter `displayLink`: target CVDisplayLinkRef
208    ///
209    /// Returns: CVReturn. kCVReturnSuccess if successfull.
210    /// kCVReturnDisplayLinkCallbacksNotSet The DisplayLink cannot be started until the output callback is set.
211    #[cfg(feature = "CVReturn")]
212    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
213    pub fn CVDisplayLinkStart(display_link: &CVDisplayLink) -> CVReturn;
214}
215
216extern "C-unwind" {
217    /// Stop timer for DisplayLink
218    ///
219    /// (description)
220    ///
221    /// Parameter `displayLink`: target CVDisplayLinkRef
222    ///
223    /// Returns: CVReturn. kCVReturnSuccess if successfull.
224    #[cfg(feature = "CVReturn")]
225    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
226    pub fn CVDisplayLinkStop(display_link: &CVDisplayLink) -> CVReturn;
227}
228
229extern "C-unwind" {
230    /// Retrieves the nominal refresh period of a CVDisplayLink.
231    ///
232    /// This call allows one to retrieve the device's "ideal" refresh period.   For example, an NTSC output device might report 1001/60000 to represent the exact NTSC vertial refresh rate.
233    ///
234    /// Parameter `displayLink`: The CVDisplayLink to get the refresh period from.
235    ///
236    /// Returns: A CVTime struct that holds the nominal refresh period.    This value may be indefinite.
237    #[cfg(feature = "CVBase")]
238    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
239    pub fn CVDisplayLinkGetNominalOutputVideoRefreshPeriod(display_link: &CVDisplayLink) -> CVTime;
240}
241
242extern "C-unwind" {
243    /// Retrieves the nominal latency of a CVDisplayLink.
244    ///
245    /// This call allows one to retrieve the device's built in output latency. An NTSC device with one frame of latency might report back 1001/30000 or 2002/60000, for example.
246    ///
247    /// Parameter `displayLink`: The CVDisplayLink to get the latency period from.
248    ///
249    /// Returns: A CVTime struct that holds the latency.   This value may be indefinite.
250    #[cfg(feature = "CVBase")]
251    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
252    pub fn CVDisplayLinkGetOutputVideoLatency(display_link: &CVDisplayLink) -> CVTime;
253}
254
255extern "C-unwind" {
256    /// Retrieves the actual output refresh period of a display as measured by the host timebase.
257    ///
258    /// This call returns the actual output refresh period (in seconds) as computed relative to the host's timebase.
259    ///
260    /// Parameter `displayLink`: The CVDisplayLink to get the refresh period from.
261    ///
262    /// Returns: A double containing the actual refresh period.   This value may be zero if the device is not running, or is otherwise unavailable.
263    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
264    pub fn CVDisplayLinkGetActualOutputVideoRefreshPeriod(display_link: &CVDisplayLink)
265        -> c_double;
266}
267
268/// Retrieves the running state of a CVDisplayLink.
269///
270/// This call queries the running state of the given CVDisplayLink.
271///
272/// Parameter `displayLink`: The CVDisplayLink to get the running state from.
273///
274/// Returns: A boolean describing the running state. It returns true if it is running and false if it is not running or the CVDisplayLink is invalid.
275#[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
276#[inline]
277pub unsafe extern "C-unwind" fn CVDisplayLinkIsRunning(display_link: &CVDisplayLink) -> bool {
278    extern "C-unwind" {
279        fn CVDisplayLinkIsRunning(display_link: &CVDisplayLink) -> Boolean;
280    }
281    let ret = unsafe { CVDisplayLinkIsRunning(display_link) };
282    ret != 0
283}
284
285extern "C-unwind" {
286    /// Retrieves the current ("now") time of a given CVDisplayLink
287    ///
288    /// This call may be used to get the current time of a running CVDisplayLink, outside of the output callback.
289    ///
290    /// Parameter `displayLink`: The CVDisplayLink to get the current time from.
291    ///
292    /// Parameter `outTime`: A pointer to a CVTimeStamp struct.  This struct's version field must currently be set correctly (currently 0) to indicate which version of the timestamp struct is desired.
293    ///
294    /// Returns: kCVReturnSuccess if the current time could be retrieved, otherwise an error indicating why the operation failed.
295    #[cfg(all(feature = "CVBase", feature = "CVReturn"))]
296    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
297    pub fn CVDisplayLinkGetCurrentTime(
298        display_link: &CVDisplayLink,
299        out_time: NonNull<CVTimeStamp>,
300    ) -> CVReturn;
301}
302
303extern "C-unwind" {
304    /// Translates the time in the CVDisplayLink's time base from one representation to
305    /// another. Note that the device has to be running for this call to succeed.
306    ///
307    /// Parameter `displayLink`: The CVDisplayLink who's timebase should be used to do the translation.
308    ///
309    /// Parameter `inTime`: A CVTimeStamp containing the source time to be translated.
310    ///
311    /// Parameter `outTime`: A CVTimeStamp into which the target time will be written. This struct's version field must currently be set correctly
312    /// (currently 0) to indicate which version of the timestamp struct is desired.  As well, the flags field should be used to specify
313    /// which representations to translate to.
314    ///
315    /// Returns: kCVReturnSuccess if the time could be translated, otherwise an error indicating why the operation failed.
316    #[cfg(all(feature = "CVBase", feature = "CVReturn"))]
317    #[deprecated = "use NSView.displayLink(target:selector:), NSWindow.displayLink(target:selector:), or NSScreen.displayLink(target:selector:) "]
318    pub fn CVDisplayLinkTranslateTime(
319        display_link: &CVDisplayLink,
320        in_time: NonNull<CVTimeStamp>,
321        out_time: NonNull<CVTimeStamp>,
322    ) -> CVReturn;
323}