objc2_core_graphics/generated/
CGDisplayStream.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;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12#[cfg(feature = "objc2-io-surface")]
13#[cfg(not(target_os = "watchos"))]
14use objc2_io_surface::*;
15
16use crate::*;
17
18/// An opaque reference to a CGDisplayStream object
19///
20/// A CGDisplayStream provides a streaming API for capturing display updates in a realtime manner.  It can also provide
21/// scaling and color space conversion services, as well as allow capturing sub regions of the display.   Callbacks can be targetted
22/// at either a traditional CFRunLoop, or at a dispatch queue.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystream?language=objc)
25#[doc(alias = "CGDisplayStreamRef")]
26#[repr(C)]
27pub struct CGDisplayStream {
28    inner: [u8; 0],
29    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
30}
31
32cf_type!(
33    unsafe impl CGDisplayStream {}
34);
35#[cfg(feature = "objc2")]
36cf_objc2_type!(
37    unsafe impl RefEncode<"CGDisplayStream"> for CGDisplayStream {}
38);
39
40/// An opaque reference to a single frame's extra metadata that describes useful frame delta information
41///
42/// A CGDisplayStreamUpdate encapsulates information about what portions of a frame have changed relative to
43/// a previously delivered frame.   This includes regions that were changed in any way, which ones were actually redrawn, and which
44/// regions were merely copied from one place to another.   A routine is provided to merge two update refs together in cases
45/// where apps need to coalesce the values because they decided to skip processing for one or more frames.
46///
47/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamupdate?language=objc)
48#[doc(alias = "CGDisplayStreamUpdateRef")]
49#[repr(C)]
50pub struct CGDisplayStreamUpdate {
51    inner: [u8; 0],
52    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
53}
54
55cf_type!(
56    unsafe impl CGDisplayStreamUpdate {}
57);
58#[cfg(feature = "objc2")]
59cf_objc2_type!(
60    unsafe impl RefEncode<"CGDisplayStreamUpdate"> for CGDisplayStreamUpdate {}
61);
62
63/// Used to select which array of rectangles to be returned by CGDisplayUpdateGetRects
64///
65/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamupdaterecttype?language=objc)
66// NS_ENUM
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct CGDisplayStreamUpdateRectType(pub i32);
70impl CGDisplayStreamUpdateRectType {
71    #[doc(alias = "kCGDisplayStreamUpdateRefreshedRects")]
72    pub const RefreshedRects: Self = Self(0);
73    #[doc(alias = "kCGDisplayStreamUpdateMovedRects")]
74    pub const MovedRects: Self = Self(1);
75    #[doc(alias = "kCGDisplayStreamUpdateDirtyRects")]
76    pub const DirtyRects: Self = Self(2);
77    #[doc(alias = "kCGDisplayStreamUpdateReducedDirtyRects")]
78    pub const ReducedDirtyRects: Self = Self(3);
79}
80
81#[cfg(feature = "objc2")]
82unsafe impl Encode for CGDisplayStreamUpdateRectType {
83    const ENCODING: Encoding = i32::ENCODING;
84}
85
86#[cfg(feature = "objc2")]
87unsafe impl RefEncode for CGDisplayStreamUpdateRectType {
88    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
89}
90
91/// Provides information about incoming frame updates
92///
93/// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamframestatus?language=objc)
94// NS_ENUM
95#[repr(transparent)]
96#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
97pub struct CGDisplayStreamFrameStatus(pub i32);
98impl CGDisplayStreamFrameStatus {
99    #[doc(alias = "kCGDisplayStreamFrameStatusFrameComplete")]
100    pub const FrameComplete: Self = Self(0);
101    #[doc(alias = "kCGDisplayStreamFrameStatusFrameIdle")]
102    pub const FrameIdle: Self = Self(1);
103    #[doc(alias = "kCGDisplayStreamFrameStatusFrameBlank")]
104    pub const FrameBlank: Self = Self(2);
105    #[doc(alias = "kCGDisplayStreamFrameStatusStopped")]
106    pub const Stopped: Self = Self(3);
107}
108
109#[cfg(feature = "objc2")]
110unsafe impl Encode for CGDisplayStreamFrameStatus {
111    const ENCODING: Encoding = i32::ENCODING;
112}
113
114#[cfg(feature = "objc2")]
115unsafe impl RefEncode for CGDisplayStreamFrameStatus {
116    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
117}
118
119/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplaystreamframeavailablehandler?language=objc)
120#[cfg(all(feature = "block2", feature = "objc2-io-surface"))]
121#[cfg(not(target_os = "watchos"))]
122pub type CGDisplayStreamFrameAvailableHandler = *mut block2::DynBlock<
123    dyn Fn(CGDisplayStreamFrameStatus, u64, *mut IOSurfaceRef, *const CGDisplayStreamUpdate),
124>;
125
126unsafe impl ConcreteType for CGDisplayStreamUpdate {
127    /// Returns the CF "class" ID for CGDisplayStreamUpdate
128    ///
129    /// Returns: The CFTypeID of the CGDisplayStreamUpdate class.
130    #[doc(alias = "CGDisplayStreamUpdateGetTypeID")]
131    #[inline]
132    fn type_id() -> CFTypeID {
133        extern "C-unwind" {
134            fn CGDisplayStreamUpdateGetTypeID() -> CFTypeID;
135        }
136        unsafe { CGDisplayStreamUpdateGetTypeID() }
137    }
138}
139
140impl CGDisplayStreamUpdate {
141    /// Returns a pointer to an array of CGRect structs that describe what parts of the frame have changed relative
142    /// to the previously delivered frame.   This rectangle list encapsulates both the update rectangles and movement rectangles.
143    ///
144    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
145    ///
146    /// Parameter `rectCount`: A pointer to where the count of the number of rectangles in the array is to be returned. Must not be NULL.
147    ///
148    /// Returns: A pointer to the array of CGRectangles.  This array should not be freed by the caller.
149    ///
150    /// # Safety
151    ///
152    /// `rect_count` must be a valid pointer.
153    #[doc(alias = "CGDisplayStreamUpdateGetRects")]
154    #[deprecated = "Please use ScreenCaptureKit instead."]
155    #[inline]
156    pub unsafe fn rects(
157        update_ref: Option<&CGDisplayStreamUpdate>,
158        rect_type: CGDisplayStreamUpdateRectType,
159        rect_count: NonNull<usize>,
160    ) -> *const CGRect {
161        extern "C-unwind" {
162            fn CGDisplayStreamUpdateGetRects(
163                update_ref: Option<&CGDisplayStreamUpdate>,
164                rect_type: CGDisplayStreamUpdateRectType,
165                rect_count: NonNull<usize>,
166            ) -> *const CGRect;
167        }
168        unsafe { CGDisplayStreamUpdateGetRects(update_ref, rect_type, rect_count) }
169    }
170
171    /// Merge two CGDisplayUpdateRefs into a new one.
172    ///
173    /// In cases where the client wishes to drop certain frame updates, this function may be used to merge two
174    /// CGDisplayUpdateRefs together.  The core bit of functionality here is generating a new set of refresh/move/dirty
175    /// rectangle arrays that properly represent the union of the deltas between the two frames.  Note that the ordering of
176    /// the two refs is important.
177    ///
178    ///
179    /// Parameter `firstUpdate`: The first update (in a temporal sense)
180    ///
181    /// Parameter `secondUpdate`: The second update (in a temporal sense)
182    ///
183    /// Returns: The new CGDisplayStreamUpdateRef
184    #[doc(alias = "CGDisplayStreamUpdateCreateMergedUpdate")]
185    #[deprecated = "Please use ScreenCaptureKit instead."]
186    #[inline]
187    pub fn new_merged_update(
188        first_update: Option<&CGDisplayStreamUpdate>,
189        second_update: Option<&CGDisplayStreamUpdate>,
190    ) -> Option<CFRetained<CGDisplayStreamUpdate>> {
191        extern "C-unwind" {
192            fn CGDisplayStreamUpdateCreateMergedUpdate(
193                first_update: Option<&CGDisplayStreamUpdate>,
194                second_update: Option<&CGDisplayStreamUpdate>,
195            ) -> Option<NonNull<CGDisplayStreamUpdate>>;
196        }
197        let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
198        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
199    }
200
201    /// Return the movement dx and dy values for a single update
202    ///
203    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
204    ///
205    /// Parameter `dx`: A pointer to a CGFloat to store the x component of the movement delta
206    ///
207    /// Parameter `dy`: A pointer to a CGFloat to store the y component of the movement delta
208    ///
209    /// The delta values describe the offset from the moved rectangles back to the source location.
210    ///
211    /// # Safety
212    ///
213    /// - `dx` must be a valid pointer.
214    /// - `dy` must be a valid pointer.
215    #[doc(alias = "CGDisplayStreamUpdateGetMovedRectsDelta")]
216    #[deprecated = "Please use ScreenCaptureKit instead."]
217    #[inline]
218    pub unsafe fn moved_rects_delta(
219        update_ref: Option<&CGDisplayStreamUpdate>,
220        dx: NonNull<CGFloat>,
221        dy: NonNull<CGFloat>,
222    ) {
223        extern "C-unwind" {
224            fn CGDisplayStreamUpdateGetMovedRectsDelta(
225                update_ref: Option<&CGDisplayStreamUpdate>,
226                dx: NonNull<CGFloat>,
227                dy: NonNull<CGFloat>,
228            );
229        }
230        unsafe { CGDisplayStreamUpdateGetMovedRectsDelta(update_ref, dx, dy) }
231    }
232
233    /// Return how many frames (if any) have been dropped since the last call to the handler.
234    ///
235    /// Parameter `updateRef`: The CGDisplayStreamUpdateRef
236    ///
237    /// Returns: The number of dropped frames
238    ///
239    /// This call is primarily useful for performance measurement to determine if the client is keeping up with
240    /// all WindowServer updates.
241    #[doc(alias = "CGDisplayStreamUpdateGetDropCount")]
242    #[deprecated = "Please use ScreenCaptureKit instead."]
243    #[inline]
244    pub fn drop_count(update_ref: Option<&CGDisplayStreamUpdate>) -> usize {
245        extern "C-unwind" {
246            fn CGDisplayStreamUpdateGetDropCount(
247                update_ref: Option<&CGDisplayStreamUpdate>,
248            ) -> usize;
249        }
250        unsafe { CGDisplayStreamUpdateGetDropCount(update_ref) }
251    }
252}
253
254extern "C" {
255    /// This may be used to request a subregion of the display to be provided as the source of the display stream.  Use
256    /// CGRectCreateDictionaryRepresentation to convert from a CGRect to the value used here.   Note: The coordinate system for the
257    /// source rectangle is specified in display logical coordinates and not in pixels, in order to match the normal convention on
258    /// HiDPI displays.
259    ///
260    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamsourcerect?language=objc)
261    #[deprecated = "Please use ScreenCaptureKit instead."]
262    pub static kCGDisplayStreamSourceRect: &'static CFString;
263}
264
265extern "C" {
266    /// This may be used to request where within the destination buffer the display updates should be placed. Use
267    /// CGRectCreateDictionaryRepresentation to convert from a CGRect to the value used here.   Note: The coordinate system for
268    /// the destination rectangle is always specified in output pixels to match the fact that the output buffer size is also
269    /// specified in terms of pixels.
270    ///
271    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamdestinationrect?language=objc)
272    #[deprecated = "Please use ScreenCaptureKit instead."]
273    pub static kCGDisplayStreamDestinationRect: &'static CFString;
274}
275
276extern "C" {
277    /// Enable/disable the work the Window Server will do to preserve the display aspect ratio.  By default the Window Server will
278    /// assume that it should preserve the original aspect ratio of the source display rect.  If the aspect ratio of the source display and
279    /// the display stream destination rect are not the same, black borders will be inserted at the top/bottom or right/left sides of the destination
280    /// in order to preserve the source aspect ratio.
281    ///
282    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreampreserveaspectratio?language=objc)
283    #[deprecated = "Please use ScreenCaptureKit instead."]
284    pub static kCGDisplayStreamPreserveAspectRatio: &'static CFString;
285}
286
287extern "C" {
288    /// Set the desired CGColorSpace of the output frames.  By default the color space will be that of the display.
289    ///
290    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamcolorspace?language=objc)
291    #[deprecated = "Please use ScreenCaptureKit instead."]
292    pub static kCGDisplayStreamColorSpace: &'static CFString;
293}
294
295extern "C" {
296    /// Request that the delta between frame updates be at least as much specified by this value.
297    ///
298    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamminimumframetime?language=objc)
299    #[deprecated = "Please use ScreenCaptureKit instead."]
300    pub static kCGDisplayStreamMinimumFrameTime: &'static CFString;
301}
302
303extern "C" {
304    /// Controls whether the cursor is embedded within the provided buffers or not.
305    ///
306    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamshowcursor?language=objc)
307    #[deprecated = "Please use ScreenCaptureKit instead."]
308    pub static kCGDisplayStreamShowCursor: &'static CFString;
309}
310
311extern "C" {
312    /// Controls how many frames deep the frame queue will be.  Defaults to N.
313    ///
314    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamqueuedepth?language=objc)
315    #[deprecated = "Please use ScreenCaptureKit instead."]
316    pub static kCGDisplayStreamQueueDepth: &'static CFString;
317}
318
319extern "C" {
320    /// When outputting frames in 420v or 420f format, this key may be used to control which YCbCr matrix is used
321    /// The value should be one of the three kCGDisplayStreamYCbCrMatrix values specified below.
322    ///
323    /// See also [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix?language=objc)
324    #[deprecated = "Please use ScreenCaptureKit instead."]
325    pub static kCGDisplayStreamYCbCrMatrix: &'static CFString;
326}
327
328extern "C" {
329    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_itu_r_709_2?language=objc)
330    pub static kCGDisplayStreamYCbCrMatrix_ITU_R_709_2: &'static CFString;
331}
332
333extern "C" {
334    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_itu_r_601_4?language=objc)
335    pub static kCGDisplayStreamYCbCrMatrix_ITU_R_601_4: &'static CFString;
336}
337
338extern "C" {
339    /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplaystreamycbcrmatrix_smpte_240m_1995?language=objc)
340    pub static kCGDisplayStreamYCbCrMatrix_SMPTE_240M_1995: &'static CFString;
341}
342
343unsafe impl ConcreteType for CGDisplayStream {
344    /// Returns the CF "class" ID for CGDisplayStream
345    ///
346    /// Returns: The CFTypeID of the CGDisplayStream class.
347    #[doc(alias = "CGDisplayStreamGetTypeID")]
348    #[inline]
349    fn type_id() -> CFTypeID {
350        extern "C-unwind" {
351            fn CGDisplayStreamGetTypeID() -> CFTypeID;
352        }
353        unsafe { CGDisplayStreamGetTypeID() }
354    }
355}
356
357impl CGDisplayStream {
358    /// Creates a new CGDisplayStream intended to be used with a CFRunLoop
359    ///
360    /// This function creates a new CGDisplayStream that is to be used to get a stream of frame updates
361    /// from a particular display.
362    ///
363    /// Parameter `display`: The CGDirectDisplayID to use as the source for generated frames
364    ///
365    /// Parameter `outputWidth`: The output width (in pixels, not points) of the frames to be generated.  Must not be zero.
366    ///
367    /// Parameter `outputHeight`: The output height (in pixels, not points) of the frames to be generated.  Must not be zero.
368    ///
369    /// Parameter `pixelFormat`: The desired CoreVideo/CoreMedia-style pixel format of the output IOSurfaces.  The currently
370    /// supported values are:
371    ///
372    /// 'BGRA' Packed Little Endian ARGB8888
373    /// 'l10r' Packed Little Endian ARGB2101010
374    /// '420v' 2-plane "video" range YCbCr 4:2:0
375    /// '420f' 2-plane "full" range YCbCr 4:2:0
376    ///
377    ///
378    /// Parameter `properties`: Any optional properties of the CGDisplayStream
379    ///
380    /// Parameter `handler`: A block that will be called for frame deliver.
381    ///
382    /// Returns: The new CGDisplayStream object.
383    ///
384    /// # Safety
385    ///
386    /// - `properties` generics must be of the correct type.
387    /// - `handler` must be a valid pointer or null.
388    #[doc(alias = "CGDisplayStreamCreate")]
389    #[cfg(all(
390        feature = "CGDirectDisplay",
391        feature = "block2",
392        feature = "objc2-io-surface"
393    ))]
394    #[cfg(not(target_os = "watchos"))]
395    #[deprecated = "Please use ScreenCaptureKit instead."]
396    #[inline]
397    pub unsafe fn new(
398        display: CGDirectDisplayID,
399        output_width: usize,
400        output_height: usize,
401        pixel_format: i32,
402        properties: Option<&CFDictionary>,
403        handler: CGDisplayStreamFrameAvailableHandler,
404    ) -> Option<CFRetained<CGDisplayStream>> {
405        extern "C-unwind" {
406            fn CGDisplayStreamCreate(
407                display: CGDirectDisplayID,
408                output_width: usize,
409                output_height: usize,
410                pixel_format: i32,
411                properties: Option<&CFDictionary>,
412                handler: CGDisplayStreamFrameAvailableHandler,
413            ) -> Option<NonNull<CGDisplayStream>>;
414        }
415        let ret = unsafe {
416            CGDisplayStreamCreate(
417                display,
418                output_width,
419                output_height,
420                pixel_format,
421                properties,
422                handler,
423            )
424        };
425        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
426    }
427
428    /// Creates a new CGDisplayStream intended to be serviced by a block handler
429    ///
430    /// This function creates a new CGDisplayStream that is to be used to get a stream of frame updates
431    /// from a particular display.
432    ///
433    /// Parameter `display`: The CGDirectDisplayID to use as the source for generated frames
434    ///
435    /// Parameter `outputWidth`: The output width (in pixels, not points) of the frames to be generated.  Must not be zero.
436    ///
437    /// Parameter `outputHeight`: The output height (in pixels, not points) of the frames to be generated.  Must not be zero.
438    ///
439    /// Parameter `pixelFormat`: The desired CoreVideo/CoreMedia-style pixel format of the output IOSurfaces
440    ///
441    /// Parameter `properties`: Any optional properties of the CGDisplayStream
442    ///
443    /// Parameter `queue`: The dispatch_queue_t that will be used to invoke the callback handler.
444    ///
445    /// Parameter `handler`: A block that will be called for frame deliver.
446    ///
447    /// Returns: The new CGDisplayStream object.
448    ///
449    /// # Safety
450    ///
451    /// - `properties` generics must be of the correct type.
452    /// - `queue` possibly has additional threading requirements.
453    /// - `handler` must be a valid pointer or null.
454    #[doc(alias = "CGDisplayStreamCreateWithDispatchQueue")]
455    #[cfg(all(
456        feature = "CGDirectDisplay",
457        feature = "block2",
458        feature = "dispatch2",
459        feature = "objc2-io-surface"
460    ))]
461    #[cfg(not(target_os = "watchos"))]
462    #[deprecated = "Please use ScreenCaptureKit instead."]
463    #[inline]
464    pub unsafe fn with_dispatch_queue(
465        display: CGDirectDisplayID,
466        output_width: usize,
467        output_height: usize,
468        pixel_format: i32,
469        properties: Option<&CFDictionary>,
470        queue: &DispatchQueue,
471        handler: CGDisplayStreamFrameAvailableHandler,
472    ) -> Option<CFRetained<CGDisplayStream>> {
473        extern "C-unwind" {
474            fn CGDisplayStreamCreateWithDispatchQueue(
475                display: CGDirectDisplayID,
476                output_width: usize,
477                output_height: usize,
478                pixel_format: i32,
479                properties: Option<&CFDictionary>,
480                queue: &DispatchQueue,
481                handler: CGDisplayStreamFrameAvailableHandler,
482            ) -> Option<NonNull<CGDisplayStream>>;
483        }
484        let ret = unsafe {
485            CGDisplayStreamCreateWithDispatchQueue(
486                display,
487                output_width,
488                output_height,
489                pixel_format,
490                properties,
491                queue,
492                handler,
493            )
494        };
495        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
496    }
497
498    /// Begin delivering frame updates to the handler block.
499    ///
500    /// Parameter `displayStream`: to be started
501    ///
502    /// Returns: kCGErrorSuccess If the display stream was started, otherwise an error.
503    #[doc(alias = "CGDisplayStreamStart")]
504    #[cfg(feature = "CGError")]
505    #[deprecated = "Please use ScreenCaptureKit instead."]
506    #[inline]
507    pub fn start(display_stream: Option<&CGDisplayStream>) -> CGError {
508        extern "C-unwind" {
509            fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
510        }
511        unsafe { CGDisplayStreamStart(display_stream) }
512    }
513
514    /// End delivery of frame updates to the handler block.
515    ///
516    /// Parameter `displayStream`: to be stopped
517    ///
518    /// Returns: kCGErrorSuccess If the display stream was stopped, otherwise an error.
519    ///
520    /// After this call returns, the CGDisplayStream callback function will eventually be called with a
521    /// status of kCGDisplayStreamFrameStatusStopped.  After that point it is safe to release the CGDisplayStream.
522    /// It is safe to call this function from within the handler block, but the previous caveat still applies.
523    #[doc(alias = "CGDisplayStreamStop")]
524    #[cfg(feature = "CGError")]
525    #[deprecated = "Please use ScreenCaptureKit instead."]
526    #[inline]
527    pub fn stop(display_stream: Option<&CGDisplayStream>) -> CGError {
528        extern "C-unwind" {
529            fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
530        }
531        unsafe { CGDisplayStreamStop(display_stream) }
532    }
533
534    /// Return the singleton CFRunLoopSourceRef for a CGDisplayStream.
535    ///
536    /// Parameter `displayStream`: The CGDisplayStream object
537    ///
538    /// Returns: The CFRunLoopSource for this displayStream.  Note: This function will return NULL if the
539    /// display stream was created via  CGDisplayStreamCreateWithDispatchQueue().
540    #[doc(alias = "CGDisplayStreamGetRunLoopSource")]
541    #[deprecated = "Please use ScreenCaptureKit instead."]
542    #[inline]
543    pub unsafe fn run_loop_source(
544        display_stream: Option<&CGDisplayStream>,
545    ) -> Option<CFRetained<CFRunLoopSource>> {
546        extern "C-unwind" {
547            fn CGDisplayStreamGetRunLoopSource(
548                display_stream: Option<&CGDisplayStream>,
549            ) -> Option<NonNull<CFRunLoopSource>>;
550        }
551        let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
552        ret.map(|ret| unsafe { CFRetained::retain(ret) })
553    }
554}
555
556extern "C-unwind" {
557    #[deprecated = "renamed to `CGDisplayStreamUpdate::rects`"]
558    pub fn CGDisplayStreamUpdateGetRects(
559        update_ref: Option<&CGDisplayStreamUpdate>,
560        rect_type: CGDisplayStreamUpdateRectType,
561        rect_count: NonNull<usize>,
562    ) -> *const CGRect;
563}
564
565#[deprecated = "renamed to `CGDisplayStreamUpdate::new_merged_update`"]
566#[inline]
567pub extern "C-unwind" fn CGDisplayStreamUpdateCreateMergedUpdate(
568    first_update: Option<&CGDisplayStreamUpdate>,
569    second_update: Option<&CGDisplayStreamUpdate>,
570) -> Option<CFRetained<CGDisplayStreamUpdate>> {
571    extern "C-unwind" {
572        fn CGDisplayStreamUpdateCreateMergedUpdate(
573            first_update: Option<&CGDisplayStreamUpdate>,
574            second_update: Option<&CGDisplayStreamUpdate>,
575        ) -> Option<NonNull<CGDisplayStreamUpdate>>;
576    }
577    let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
578    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
579}
580
581extern "C-unwind" {
582    #[deprecated = "renamed to `CGDisplayStreamUpdate::moved_rects_delta`"]
583    pub fn CGDisplayStreamUpdateGetMovedRectsDelta(
584        update_ref: Option<&CGDisplayStreamUpdate>,
585        dx: NonNull<CGFloat>,
586        dy: NonNull<CGFloat>,
587    );
588}
589
590#[deprecated = "renamed to `CGDisplayStreamUpdate::drop_count`"]
591#[inline]
592pub extern "C-unwind" fn CGDisplayStreamUpdateGetDropCount(
593    update_ref: Option<&CGDisplayStreamUpdate>,
594) -> usize {
595    extern "C-unwind" {
596        fn CGDisplayStreamUpdateGetDropCount(update_ref: Option<&CGDisplayStreamUpdate>) -> usize;
597    }
598    unsafe { CGDisplayStreamUpdateGetDropCount(update_ref) }
599}
600
601#[cfg(all(
602    feature = "CGDirectDisplay",
603    feature = "block2",
604    feature = "objc2-io-surface"
605))]
606#[cfg(not(target_os = "watchos"))]
607#[deprecated = "renamed to `CGDisplayStream::new`"]
608#[inline]
609pub unsafe extern "C-unwind" fn CGDisplayStreamCreate(
610    display: CGDirectDisplayID,
611    output_width: usize,
612    output_height: usize,
613    pixel_format: i32,
614    properties: Option<&CFDictionary>,
615    handler: CGDisplayStreamFrameAvailableHandler,
616) -> Option<CFRetained<CGDisplayStream>> {
617    extern "C-unwind" {
618        fn CGDisplayStreamCreate(
619            display: CGDirectDisplayID,
620            output_width: usize,
621            output_height: usize,
622            pixel_format: i32,
623            properties: Option<&CFDictionary>,
624            handler: CGDisplayStreamFrameAvailableHandler,
625        ) -> Option<NonNull<CGDisplayStream>>;
626    }
627    let ret = unsafe {
628        CGDisplayStreamCreate(
629            display,
630            output_width,
631            output_height,
632            pixel_format,
633            properties,
634            handler,
635        )
636    };
637    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
638}
639
640#[cfg(all(
641    feature = "CGDirectDisplay",
642    feature = "block2",
643    feature = "dispatch2",
644    feature = "objc2-io-surface"
645))]
646#[cfg(not(target_os = "watchos"))]
647#[deprecated = "renamed to `CGDisplayStream::with_dispatch_queue`"]
648#[inline]
649pub unsafe extern "C-unwind" fn CGDisplayStreamCreateWithDispatchQueue(
650    display: CGDirectDisplayID,
651    output_width: usize,
652    output_height: usize,
653    pixel_format: i32,
654    properties: Option<&CFDictionary>,
655    queue: &DispatchQueue,
656    handler: CGDisplayStreamFrameAvailableHandler,
657) -> Option<CFRetained<CGDisplayStream>> {
658    extern "C-unwind" {
659        fn CGDisplayStreamCreateWithDispatchQueue(
660            display: CGDirectDisplayID,
661            output_width: usize,
662            output_height: usize,
663            pixel_format: i32,
664            properties: Option<&CFDictionary>,
665            queue: &DispatchQueue,
666            handler: CGDisplayStreamFrameAvailableHandler,
667        ) -> Option<NonNull<CGDisplayStream>>;
668    }
669    let ret = unsafe {
670        CGDisplayStreamCreateWithDispatchQueue(
671            display,
672            output_width,
673            output_height,
674            pixel_format,
675            properties,
676            queue,
677            handler,
678        )
679    };
680    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
681}
682
683#[cfg(feature = "CGError")]
684#[deprecated = "renamed to `CGDisplayStream::start`"]
685#[inline]
686pub extern "C-unwind" fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError {
687    extern "C-unwind" {
688        fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
689    }
690    unsafe { CGDisplayStreamStart(display_stream) }
691}
692
693#[cfg(feature = "CGError")]
694#[deprecated = "renamed to `CGDisplayStream::stop`"]
695#[inline]
696pub extern "C-unwind" fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError {
697    extern "C-unwind" {
698        fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
699    }
700    unsafe { CGDisplayStreamStop(display_stream) }
701}
702
703#[deprecated = "renamed to `CGDisplayStream::run_loop_source`"]
704#[inline]
705pub unsafe extern "C-unwind" fn CGDisplayStreamGetRunLoopSource(
706    display_stream: Option<&CGDisplayStream>,
707) -> Option<CFRetained<CFRunLoopSource>> {
708    extern "C-unwind" {
709        fn CGDisplayStreamGetRunLoopSource(
710            display_stream: Option<&CGDisplayStream>,
711        ) -> Option<NonNull<CFRunLoopSource>>;
712    }
713    let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
714    ret.map(|ret| unsafe { CFRetained::retain(ret) })
715}