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