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#[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#[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#[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#[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#[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 #[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 #[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 #[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 #[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 #[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 #[deprecated = "Please use ScreenCaptureKit instead."]
262 pub static kCGDisplayStreamSourceRect: &'static CFString;
263}
264
265extern "C" {
266 #[deprecated = "Please use ScreenCaptureKit instead."]
273 pub static kCGDisplayStreamDestinationRect: &'static CFString;
274}
275
276extern "C" {
277 #[deprecated = "Please use ScreenCaptureKit instead."]
284 pub static kCGDisplayStreamPreserveAspectRatio: &'static CFString;
285}
286
287extern "C" {
288 #[deprecated = "Please use ScreenCaptureKit instead."]
292 pub static kCGDisplayStreamColorSpace: &'static CFString;
293}
294
295extern "C" {
296 #[deprecated = "Please use ScreenCaptureKit instead."]
300 pub static kCGDisplayStreamMinimumFrameTime: &'static CFString;
301}
302
303extern "C" {
304 #[deprecated = "Please use ScreenCaptureKit instead."]
308 pub static kCGDisplayStreamShowCursor: &'static CFString;
309}
310
311extern "C" {
312 #[deprecated = "Please use ScreenCaptureKit instead."]
316 pub static kCGDisplayStreamQueueDepth: &'static CFString;
317}
318
319extern "C" {
320 #[deprecated = "Please use ScreenCaptureKit instead."]
325 pub static kCGDisplayStreamYCbCrMatrix: &'static CFString;
326}
327
328extern "C" {
329 pub static kCGDisplayStreamYCbCrMatrix_ITU_R_709_2: &'static CFString;
331}
332
333extern "C" {
334 pub static kCGDisplayStreamYCbCrMatrix_ITU_R_601_4: &'static CFString;
336}
337
338extern "C" {
339 pub static kCGDisplayStreamYCbCrMatrix_SMPTE_240M_1995: &'static CFString;
341}
342
343unsafe impl ConcreteType for CGDisplayStream {
344 #[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 #[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 #[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 #[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 #[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 #[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}