objc2_core_graphics/generated/
CGDisplayStream.rs1use 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#[repr(C)]
26pub struct CGDisplayStream {
27 inner: [u8; 0],
28 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
29}
30
31cf_type!(
32 unsafe impl CGDisplayStream {}
33);
34#[cfg(feature = "objc2")]
35cf_objc2_type!(
36 unsafe impl RefEncode<"CGDisplayStream"> for CGDisplayStream {}
37);
38
39#[repr(C)]
48pub struct CGDisplayStreamUpdate {
49 inner: [u8; 0],
50 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
51}
52
53cf_type!(
54 unsafe impl CGDisplayStreamUpdate {}
55);
56#[cfg(feature = "objc2")]
57cf_objc2_type!(
58 unsafe impl RefEncode<"CGDisplayStreamUpdate"> for CGDisplayStreamUpdate {}
59);
60
61#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct CGDisplayStreamUpdateRectType(pub i32);
68impl CGDisplayStreamUpdateRectType {
69 #[doc(alias = "kCGDisplayStreamUpdateRefreshedRects")]
70 pub const RefreshedRects: Self = Self(0);
71 #[doc(alias = "kCGDisplayStreamUpdateMovedRects")]
72 pub const MovedRects: Self = Self(1);
73 #[doc(alias = "kCGDisplayStreamUpdateDirtyRects")]
74 pub const DirtyRects: Self = Self(2);
75 #[doc(alias = "kCGDisplayStreamUpdateReducedDirtyRects")]
76 pub const ReducedDirtyRects: Self = Self(3);
77}
78
79#[cfg(feature = "objc2")]
80unsafe impl Encode for CGDisplayStreamUpdateRectType {
81 const ENCODING: Encoding = i32::ENCODING;
82}
83
84#[cfg(feature = "objc2")]
85unsafe impl RefEncode for CGDisplayStreamUpdateRectType {
86 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89#[repr(transparent)]
94#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
95pub struct CGDisplayStreamFrameStatus(pub i32);
96impl CGDisplayStreamFrameStatus {
97 #[doc(alias = "kCGDisplayStreamFrameStatusFrameComplete")]
98 pub const FrameComplete: Self = Self(0);
99 #[doc(alias = "kCGDisplayStreamFrameStatusFrameIdle")]
100 pub const FrameIdle: Self = Self(1);
101 #[doc(alias = "kCGDisplayStreamFrameStatusFrameBlank")]
102 pub const FrameBlank: Self = Self(2);
103 #[doc(alias = "kCGDisplayStreamFrameStatusStopped")]
104 pub const Stopped: Self = Self(3);
105}
106
107#[cfg(feature = "objc2")]
108unsafe impl Encode for CGDisplayStreamFrameStatus {
109 const ENCODING: Encoding = i32::ENCODING;
110}
111
112#[cfg(feature = "objc2")]
113unsafe impl RefEncode for CGDisplayStreamFrameStatus {
114 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
115}
116
117#[cfg(all(feature = "block2", feature = "objc2-io-surface"))]
119#[cfg(not(target_os = "watchos"))]
120pub type CGDisplayStreamFrameAvailableHandler = *mut block2::DynBlock<
121 dyn Fn(CGDisplayStreamFrameStatus, u64, *mut IOSurfaceRef, *const CGDisplayStreamUpdate),
122>;
123
124unsafe impl ConcreteType for CGDisplayStreamUpdate {
125 #[doc(alias = "CGDisplayStreamUpdateGetTypeID")]
129 #[inline]
130 fn type_id() -> CFTypeID {
131 extern "C-unwind" {
132 fn CGDisplayStreamUpdateGetTypeID() -> CFTypeID;
133 }
134 unsafe { CGDisplayStreamUpdateGetTypeID() }
135 }
136}
137
138impl CGDisplayStreamUpdate {
139 #[doc(alias = "CGDisplayStreamUpdateGetRects")]
148 #[deprecated = "Please use ScreenCaptureKit instead."]
149 #[inline]
150 pub unsafe fn rects(
151 update_ref: Option<&CGDisplayStreamUpdate>,
152 rect_type: CGDisplayStreamUpdateRectType,
153 rect_count: NonNull<usize>,
154 ) -> *const CGRect {
155 extern "C-unwind" {
156 fn CGDisplayStreamUpdateGetRects(
157 update_ref: Option<&CGDisplayStreamUpdate>,
158 rect_type: CGDisplayStreamUpdateRectType,
159 rect_count: NonNull<usize>,
160 ) -> *const CGRect;
161 }
162 unsafe { CGDisplayStreamUpdateGetRects(update_ref, rect_type, rect_count) }
163 }
164
165 #[doc(alias = "CGDisplayStreamUpdateCreateMergedUpdate")]
179 #[deprecated = "Please use ScreenCaptureKit instead."]
180 #[inline]
181 pub unsafe fn new_merged_update(
182 first_update: Option<&CGDisplayStreamUpdate>,
183 second_update: Option<&CGDisplayStreamUpdate>,
184 ) -> Option<CFRetained<CGDisplayStreamUpdate>> {
185 extern "C-unwind" {
186 fn CGDisplayStreamUpdateCreateMergedUpdate(
187 first_update: Option<&CGDisplayStreamUpdate>,
188 second_update: Option<&CGDisplayStreamUpdate>,
189 ) -> Option<NonNull<CGDisplayStreamUpdate>>;
190 }
191 let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
192 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
193 }
194
195 #[doc(alias = "CGDisplayStreamUpdateGetMovedRectsDelta")]
205 #[deprecated = "Please use ScreenCaptureKit instead."]
206 #[inline]
207 pub unsafe fn moved_rects_delta(
208 update_ref: Option<&CGDisplayStreamUpdate>,
209 dx: NonNull<CGFloat>,
210 dy: NonNull<CGFloat>,
211 ) {
212 extern "C-unwind" {
213 fn CGDisplayStreamUpdateGetMovedRectsDelta(
214 update_ref: Option<&CGDisplayStreamUpdate>,
215 dx: NonNull<CGFloat>,
216 dy: NonNull<CGFloat>,
217 );
218 }
219 unsafe { CGDisplayStreamUpdateGetMovedRectsDelta(update_ref, dx, dy) }
220 }
221
222 #[doc(alias = "CGDisplayStreamUpdateGetDropCount")]
231 #[deprecated = "Please use ScreenCaptureKit instead."]
232 #[inline]
233 pub unsafe fn drop_count(update_ref: Option<&CGDisplayStreamUpdate>) -> usize {
234 extern "C-unwind" {
235 fn CGDisplayStreamUpdateGetDropCount(
236 update_ref: Option<&CGDisplayStreamUpdate>,
237 ) -> usize;
238 }
239 unsafe { CGDisplayStreamUpdateGetDropCount(update_ref) }
240 }
241}
242
243extern "C" {
244 pub static kCGDisplayStreamSourceRect: &'static CFString;
251}
252
253extern "C" {
254 pub static kCGDisplayStreamDestinationRect: &'static CFString;
261}
262
263extern "C" {
264 pub static kCGDisplayStreamPreserveAspectRatio: &'static CFString;
271}
272
273extern "C" {
274 pub static kCGDisplayStreamColorSpace: &'static CFString;
278}
279
280extern "C" {
281 pub static kCGDisplayStreamMinimumFrameTime: &'static CFString;
285}
286
287extern "C" {
288 pub static kCGDisplayStreamShowCursor: &'static CFString;
292}
293
294extern "C" {
295 pub static kCGDisplayStreamQueueDepth: &'static CFString;
299}
300
301extern "C" {
302 pub static kCGDisplayStreamYCbCrMatrix: &'static CFString;
307}
308
309extern "C" {
310 pub static kCGDisplayStreamYCbCrMatrix_ITU_R_709_2: &'static CFString;
312}
313
314extern "C" {
315 pub static kCGDisplayStreamYCbCrMatrix_ITU_R_601_4: &'static CFString;
317}
318
319extern "C" {
320 pub static kCGDisplayStreamYCbCrMatrix_SMPTE_240M_1995: &'static CFString;
322}
323
324unsafe impl ConcreteType for CGDisplayStream {
325 #[doc(alias = "CGDisplayStreamGetTypeID")]
329 #[inline]
330 fn type_id() -> CFTypeID {
331 extern "C-unwind" {
332 fn CGDisplayStreamGetTypeID() -> CFTypeID;
333 }
334 unsafe { CGDisplayStreamGetTypeID() }
335 }
336}
337
338impl CGDisplayStream {
339 #[doc(alias = "CGDisplayStreamCreate")]
365 #[cfg(all(
366 feature = "CGDirectDisplay",
367 feature = "block2",
368 feature = "objc2-io-surface"
369 ))]
370 #[cfg(not(target_os = "watchos"))]
371 #[deprecated = "Please use ScreenCaptureKit instead."]
372 #[inline]
373 pub unsafe fn new(
374 display: CGDirectDisplayID,
375 output_width: usize,
376 output_height: usize,
377 pixel_format: i32,
378 properties: Option<&CFDictionary>,
379 handler: CGDisplayStreamFrameAvailableHandler,
380 ) -> Option<CFRetained<CGDisplayStream>> {
381 extern "C-unwind" {
382 fn CGDisplayStreamCreate(
383 display: CGDirectDisplayID,
384 output_width: usize,
385 output_height: usize,
386 pixel_format: i32,
387 properties: Option<&CFDictionary>,
388 handler: CGDisplayStreamFrameAvailableHandler,
389 ) -> Option<NonNull<CGDisplayStream>>;
390 }
391 let ret = unsafe {
392 CGDisplayStreamCreate(
393 display,
394 output_width,
395 output_height,
396 pixel_format,
397 properties,
398 handler,
399 )
400 };
401 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
402 }
403
404 #[doc(alias = "CGDisplayStreamCreateWithDispatchQueue")]
425 #[cfg(all(
426 feature = "CGDirectDisplay",
427 feature = "block2",
428 feature = "dispatch2",
429 feature = "objc2-io-surface"
430 ))]
431 #[cfg(not(target_os = "watchos"))]
432 #[deprecated = "Please use ScreenCaptureKit instead."]
433 #[inline]
434 pub unsafe fn with_dispatch_queue(
435 display: CGDirectDisplayID,
436 output_width: usize,
437 output_height: usize,
438 pixel_format: i32,
439 properties: Option<&CFDictionary>,
440 queue: &DispatchQueue,
441 handler: CGDisplayStreamFrameAvailableHandler,
442 ) -> Option<CFRetained<CGDisplayStream>> {
443 extern "C-unwind" {
444 fn CGDisplayStreamCreateWithDispatchQueue(
445 display: CGDirectDisplayID,
446 output_width: usize,
447 output_height: usize,
448 pixel_format: i32,
449 properties: Option<&CFDictionary>,
450 queue: &DispatchQueue,
451 handler: CGDisplayStreamFrameAvailableHandler,
452 ) -> Option<NonNull<CGDisplayStream>>;
453 }
454 let ret = unsafe {
455 CGDisplayStreamCreateWithDispatchQueue(
456 display,
457 output_width,
458 output_height,
459 pixel_format,
460 properties,
461 queue,
462 handler,
463 )
464 };
465 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
466 }
467
468 #[doc(alias = "CGDisplayStreamStart")]
474 #[cfg(feature = "CGError")]
475 #[deprecated = "Please use ScreenCaptureKit instead."]
476 #[inline]
477 pub unsafe fn start(display_stream: Option<&CGDisplayStream>) -> CGError {
478 extern "C-unwind" {
479 fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
480 }
481 unsafe { CGDisplayStreamStart(display_stream) }
482 }
483
484 #[doc(alias = "CGDisplayStreamStop")]
494 #[cfg(feature = "CGError")]
495 #[deprecated = "Please use ScreenCaptureKit instead."]
496 #[inline]
497 pub unsafe fn stop(display_stream: Option<&CGDisplayStream>) -> CGError {
498 extern "C-unwind" {
499 fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
500 }
501 unsafe { CGDisplayStreamStop(display_stream) }
502 }
503
504 #[doc(alias = "CGDisplayStreamGetRunLoopSource")]
511 #[deprecated = "Please use ScreenCaptureKit instead."]
512 #[inline]
513 pub unsafe fn run_loop_source(
514 display_stream: Option<&CGDisplayStream>,
515 ) -> Option<CFRetained<CFRunLoopSource>> {
516 extern "C-unwind" {
517 fn CGDisplayStreamGetRunLoopSource(
518 display_stream: Option<&CGDisplayStream>,
519 ) -> Option<NonNull<CFRunLoopSource>>;
520 }
521 let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
522 ret.map(|ret| unsafe { CFRetained::retain(ret) })
523 }
524}
525
526extern "C-unwind" {
527 #[deprecated = "renamed to `CGDisplayStreamUpdate::rects`"]
528 pub fn CGDisplayStreamUpdateGetRects(
529 update_ref: Option<&CGDisplayStreamUpdate>,
530 rect_type: CGDisplayStreamUpdateRectType,
531 rect_count: NonNull<usize>,
532 ) -> *const CGRect;
533}
534
535#[deprecated = "renamed to `CGDisplayStreamUpdate::new_merged_update`"]
536#[inline]
537pub unsafe extern "C-unwind" fn CGDisplayStreamUpdateCreateMergedUpdate(
538 first_update: Option<&CGDisplayStreamUpdate>,
539 second_update: Option<&CGDisplayStreamUpdate>,
540) -> Option<CFRetained<CGDisplayStreamUpdate>> {
541 extern "C-unwind" {
542 fn CGDisplayStreamUpdateCreateMergedUpdate(
543 first_update: Option<&CGDisplayStreamUpdate>,
544 second_update: Option<&CGDisplayStreamUpdate>,
545 ) -> Option<NonNull<CGDisplayStreamUpdate>>;
546 }
547 let ret = unsafe { CGDisplayStreamUpdateCreateMergedUpdate(first_update, second_update) };
548 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
549}
550
551extern "C-unwind" {
552 #[deprecated = "renamed to `CGDisplayStreamUpdate::moved_rects_delta`"]
553 pub fn CGDisplayStreamUpdateGetMovedRectsDelta(
554 update_ref: Option<&CGDisplayStreamUpdate>,
555 dx: NonNull<CGFloat>,
556 dy: NonNull<CGFloat>,
557 );
558}
559
560extern "C-unwind" {
561 #[deprecated = "renamed to `CGDisplayStreamUpdate::drop_count`"]
562 pub fn CGDisplayStreamUpdateGetDropCount(update_ref: Option<&CGDisplayStreamUpdate>) -> usize;
563}
564
565#[cfg(all(
566 feature = "CGDirectDisplay",
567 feature = "block2",
568 feature = "objc2-io-surface"
569))]
570#[cfg(not(target_os = "watchos"))]
571#[deprecated = "renamed to `CGDisplayStream::new`"]
572#[inline]
573pub unsafe extern "C-unwind" fn CGDisplayStreamCreate(
574 display: CGDirectDisplayID,
575 output_width: usize,
576 output_height: usize,
577 pixel_format: i32,
578 properties: Option<&CFDictionary>,
579 handler: CGDisplayStreamFrameAvailableHandler,
580) -> Option<CFRetained<CGDisplayStream>> {
581 extern "C-unwind" {
582 fn CGDisplayStreamCreate(
583 display: CGDirectDisplayID,
584 output_width: usize,
585 output_height: usize,
586 pixel_format: i32,
587 properties: Option<&CFDictionary>,
588 handler: CGDisplayStreamFrameAvailableHandler,
589 ) -> Option<NonNull<CGDisplayStream>>;
590 }
591 let ret = unsafe {
592 CGDisplayStreamCreate(
593 display,
594 output_width,
595 output_height,
596 pixel_format,
597 properties,
598 handler,
599 )
600 };
601 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
602}
603
604#[cfg(all(
605 feature = "CGDirectDisplay",
606 feature = "block2",
607 feature = "dispatch2",
608 feature = "objc2-io-surface"
609))]
610#[cfg(not(target_os = "watchos"))]
611#[deprecated = "renamed to `CGDisplayStream::with_dispatch_queue`"]
612#[inline]
613pub unsafe extern "C-unwind" fn CGDisplayStreamCreateWithDispatchQueue(
614 display: CGDirectDisplayID,
615 output_width: usize,
616 output_height: usize,
617 pixel_format: i32,
618 properties: Option<&CFDictionary>,
619 queue: &DispatchQueue,
620 handler: CGDisplayStreamFrameAvailableHandler,
621) -> Option<CFRetained<CGDisplayStream>> {
622 extern "C-unwind" {
623 fn CGDisplayStreamCreateWithDispatchQueue(
624 display: CGDirectDisplayID,
625 output_width: usize,
626 output_height: usize,
627 pixel_format: i32,
628 properties: Option<&CFDictionary>,
629 queue: &DispatchQueue,
630 handler: CGDisplayStreamFrameAvailableHandler,
631 ) -> Option<NonNull<CGDisplayStream>>;
632 }
633 let ret = unsafe {
634 CGDisplayStreamCreateWithDispatchQueue(
635 display,
636 output_width,
637 output_height,
638 pixel_format,
639 properties,
640 queue,
641 handler,
642 )
643 };
644 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
645}
646
647extern "C-unwind" {
648 #[cfg(feature = "CGError")]
649 #[deprecated = "renamed to `CGDisplayStream::start`"]
650 pub fn CGDisplayStreamStart(display_stream: Option<&CGDisplayStream>) -> CGError;
651}
652
653extern "C-unwind" {
654 #[cfg(feature = "CGError")]
655 #[deprecated = "renamed to `CGDisplayStream::stop`"]
656 pub fn CGDisplayStreamStop(display_stream: Option<&CGDisplayStream>) -> CGError;
657}
658
659#[deprecated = "renamed to `CGDisplayStream::run_loop_source`"]
660#[inline]
661pub unsafe extern "C-unwind" fn CGDisplayStreamGetRunLoopSource(
662 display_stream: Option<&CGDisplayStream>,
663) -> Option<CFRetained<CFRunLoopSource>> {
664 extern "C-unwind" {
665 fn CGDisplayStreamGetRunLoopSource(
666 display_stream: Option<&CGDisplayStream>,
667 ) -> Option<NonNull<CFRunLoopSource>>;
668 }
669 let ret = unsafe { CGDisplayStreamGetRunLoopSource(display_stream) };
670 ret.map(|ret| unsafe { CFRetained::retain(ret) })
671}