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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCStreamOutputType(pub NSInteger);
impl SCStreamOutputType {
    #[doc(alias = "SCStreamOutputTypeScreen")]
    pub const Screen: Self = Self(0);
    #[doc(alias = "SCStreamOutputTypeAudio")]
    pub const Audio: Self = Self(1);
}

unsafe impl Encode for SCStreamOutputType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SCStreamOutputType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCFrameStatus(pub NSInteger);
impl SCFrameStatus {
    #[doc(alias = "SCFrameStatusComplete")]
    pub const Complete: Self = Self(0);
    #[doc(alias = "SCFrameStatusIdle")]
    pub const Idle: Self = Self(1);
    #[doc(alias = "SCFrameStatusBlank")]
    pub const Blank: Self = Self(2);
    #[doc(alias = "SCFrameStatusSuspended")]
    pub const Suspended: Self = Self(3);
    #[doc(alias = "SCFrameStatusStarted")]
    pub const Started: Self = Self(4);
    #[doc(alias = "SCFrameStatusStopped")]
    pub const Stopped: Self = Self(5);
}

unsafe impl Encode for SCFrameStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SCFrameStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCPresenterOverlayAlertSetting(pub NSInteger);
impl SCPresenterOverlayAlertSetting {
    #[doc(alias = "SCPresenterOverlayAlertSettingSystem")]
    pub const System: Self = Self(0);
    #[doc(alias = "SCPresenterOverlayAlertSettingNever")]
    pub const Never: Self = Self(1);
    #[doc(alias = "SCPresenterOverlayAlertSettingAlways")]
    pub const Always: Self = Self(2);
}

unsafe impl Encode for SCPresenterOverlayAlertSetting {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SCPresenterOverlayAlertSetting {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCStreamType(pub NSInteger);
impl SCStreamType {
    #[doc(alias = "SCStreamTypeWindow")]
    pub const Window: Self = Self(0);
    #[doc(alias = "SCStreamTypeDisplay")]
    pub const Display: Self = Self(1);
}

unsafe impl Encode for SCStreamType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SCStreamType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCCaptureResolutionType(pub NSInteger);
impl SCCaptureResolutionType {
    pub const SCCaptureResolutionAutomatic: Self = Self(0);
    pub const SCCaptureResolutionBest: Self = Self(1);
    pub const SCCaptureResolutionNominal: Self = Self(2);
}

unsafe impl Encode for SCCaptureResolutionType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SCCaptureResolutionType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCContentFilter;

    unsafe impl ClassType for SCContentFilter {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for SCContentFilter {}

extern_methods!(
    unsafe impl SCContentFilter {
        #[deprecated = "Use style instead"]
        #[method(streamType)]
        pub unsafe fn streamType(&self) -> SCStreamType;

        #[cfg(feature = "SCShareableContent")]
        #[method(style)]
        pub unsafe fn style(&self) -> SCShareableContentStyle;

        #[method(pointPixelScale)]
        pub unsafe fn pointPixelScale(&self) -> c_float;

        #[method(contentRect)]
        pub unsafe fn contentRect(&self) -> CGRect;

        #[method(includeMenuBar)]
        pub unsafe fn includeMenuBar(&self) -> bool;

        #[method(setIncludeMenuBar:)]
        pub unsafe fn setIncludeMenuBar(&self, include_menu_bar: bool);

        #[cfg(feature = "SCShareableContent")]
        #[method_id(@__retain_semantics Init initWithDesktopIndependentWindow:)]
        pub unsafe fn initWithDesktopIndependentWindow(
            this: Allocated<Self>,
            window: &SCWindow,
        ) -> Retained<Self>;

        #[cfg(feature = "SCShareableContent")]
        #[method_id(@__retain_semantics Init initWithDisplay:excludingWindows:)]
        pub unsafe fn initWithDisplay_excludingWindows(
            this: Allocated<Self>,
            display: &SCDisplay,
            excluded: &NSArray<SCWindow>,
        ) -> Retained<Self>;

        #[cfg(feature = "SCShareableContent")]
        #[method_id(@__retain_semantics Init initWithDisplay:includingWindows:)]
        pub unsafe fn initWithDisplay_includingWindows(
            this: Allocated<Self>,
            display: &SCDisplay,
            included_windows: &NSArray<SCWindow>,
        ) -> Retained<Self>;

        #[cfg(feature = "SCShareableContent")]
        #[method_id(@__retain_semantics Init initWithDisplay:includingApplications:exceptingWindows:)]
        pub unsafe fn initWithDisplay_includingApplications_exceptingWindows(
            this: Allocated<Self>,
            display: &SCDisplay,
            applications: &NSArray<SCRunningApplication>,
            excepting_windows: &NSArray<SCWindow>,
        ) -> Retained<Self>;

        #[cfg(feature = "SCShareableContent")]
        #[method_id(@__retain_semantics Init initWithDisplay:excludingApplications:exceptingWindows:)]
        pub unsafe fn initWithDisplay_excludingApplications_exceptingWindows(
            this: Allocated<Self>,
            display: &SCDisplay,
            applications: &NSArray<SCRunningApplication>,
            excepting_windows: &NSArray<SCWindow>,
        ) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl SCContentFilter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCStreamConfiguration;

    unsafe impl ClassType for SCStreamConfiguration {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for SCStreamConfiguration {}

extern_methods!(
    unsafe impl SCStreamConfiguration {
        #[method(width)]
        pub unsafe fn width(&self) -> usize;

        #[method(setWidth:)]
        pub unsafe fn setWidth(&self, width: usize);

        #[method(height)]
        pub unsafe fn height(&self) -> usize;

        #[method(setHeight:)]
        pub unsafe fn setHeight(&self, height: usize);

        #[method(pixelFormat)]
        pub unsafe fn pixelFormat(&self) -> OSType;

        #[method(setPixelFormat:)]
        pub unsafe fn setPixelFormat(&self, pixel_format: OSType);

        #[method(scalesToFit)]
        pub unsafe fn scalesToFit(&self) -> bool;

        #[method(setScalesToFit:)]
        pub unsafe fn setScalesToFit(&self, scales_to_fit: bool);

        #[method(preservesAspectRatio)]
        pub unsafe fn preservesAspectRatio(&self) -> bool;

        #[method(setPreservesAspectRatio:)]
        pub unsafe fn setPreservesAspectRatio(&self, preserves_aspect_ratio: bool);

        #[method_id(@__retain_semantics Other streamName)]
        pub unsafe fn streamName(&self) -> Option<Retained<NSString>>;

        #[method(setStreamName:)]
        pub unsafe fn setStreamName(&self, stream_name: Option<&NSString>);

        #[method(showsCursor)]
        pub unsafe fn showsCursor(&self) -> bool;

        #[method(setShowsCursor:)]
        pub unsafe fn setShowsCursor(&self, shows_cursor: bool);

        #[method(sourceRect)]
        pub unsafe fn sourceRect(&self) -> CGRect;

        #[method(setSourceRect:)]
        pub unsafe fn setSourceRect(&self, source_rect: CGRect);

        #[method(destinationRect)]
        pub unsafe fn destinationRect(&self) -> CGRect;

        #[method(setDestinationRect:)]
        pub unsafe fn setDestinationRect(&self, destination_rect: CGRect);

        #[method(queueDepth)]
        pub unsafe fn queueDepth(&self) -> NSInteger;

        #[method(setQueueDepth:)]
        pub unsafe fn setQueueDepth(&self, queue_depth: NSInteger);

        #[method(capturesAudio)]
        pub unsafe fn capturesAudio(&self) -> bool;

        #[method(setCapturesAudio:)]
        pub unsafe fn setCapturesAudio(&self, captures_audio: bool);

        #[method(sampleRate)]
        pub unsafe fn sampleRate(&self) -> NSInteger;

        #[method(setSampleRate:)]
        pub unsafe fn setSampleRate(&self, sample_rate: NSInteger);

        #[method(channelCount)]
        pub unsafe fn channelCount(&self) -> NSInteger;

        #[method(setChannelCount:)]
        pub unsafe fn setChannelCount(&self, channel_count: NSInteger);

        #[method(excludesCurrentProcessAudio)]
        pub unsafe fn excludesCurrentProcessAudio(&self) -> bool;

        #[method(setExcludesCurrentProcessAudio:)]
        pub unsafe fn setExcludesCurrentProcessAudio(&self, excludes_current_process_audio: bool);

        #[method(ignoreShadowsDisplay)]
        pub unsafe fn ignoreShadowsDisplay(&self) -> bool;

        #[method(setIgnoreShadowsDisplay:)]
        pub unsafe fn setIgnoreShadowsDisplay(&self, ignore_shadows_display: bool);

        #[method(ignoreShadowsSingleWindow)]
        pub unsafe fn ignoreShadowsSingleWindow(&self) -> bool;

        #[method(setIgnoreShadowsSingleWindow:)]
        pub unsafe fn setIgnoreShadowsSingleWindow(&self, ignore_shadows_single_window: bool);

        #[method(captureResolution)]
        pub unsafe fn captureResolution(&self) -> SCCaptureResolutionType;

        #[method(setCaptureResolution:)]
        pub unsafe fn setCaptureResolution(&self, capture_resolution: SCCaptureResolutionType);

        #[method(capturesShadowsOnly)]
        pub unsafe fn capturesShadowsOnly(&self) -> bool;

        #[method(setCapturesShadowsOnly:)]
        pub unsafe fn setCapturesShadowsOnly(&self, captures_shadows_only: bool);

        #[method(shouldBeOpaque)]
        pub unsafe fn shouldBeOpaque(&self) -> bool;

        #[method(setShouldBeOpaque:)]
        pub unsafe fn setShouldBeOpaque(&self, should_be_opaque: bool);

        #[method(ignoreGlobalClipDisplay)]
        pub unsafe fn ignoreGlobalClipDisplay(&self) -> bool;

        #[method(setIgnoreGlobalClipDisplay:)]
        pub unsafe fn setIgnoreGlobalClipDisplay(&self, ignore_global_clip_display: bool);

        #[method(ignoreGlobalClipSingleWindow)]
        pub unsafe fn ignoreGlobalClipSingleWindow(&self) -> bool;

        #[method(setIgnoreGlobalClipSingleWindow:)]
        pub unsafe fn setIgnoreGlobalClipSingleWindow(
            &self,
            ignore_global_clip_single_window: bool,
        );

        #[method(presenterOverlayPrivacyAlertSetting)]
        pub unsafe fn presenterOverlayPrivacyAlertSetting(&self) -> SCPresenterOverlayAlertSetting;

        #[method(setPresenterOverlayPrivacyAlertSetting:)]
        pub unsafe fn setPresenterOverlayPrivacyAlertSetting(
            &self,
            presenter_overlay_privacy_alert_setting: SCPresenterOverlayAlertSetting,
        );

        #[method(includeChildWindows)]
        pub unsafe fn includeChildWindows(&self) -> bool;

        #[method(setIncludeChildWindows:)]
        pub unsafe fn setIncludeChildWindows(&self, include_child_windows: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl SCStreamConfiguration {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

// NS_TYPED_ENUM
pub type SCStreamFrameInfo = NSString;

extern "C" {
    pub static SCStreamFrameInfoStatus: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoDisplayTime: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoScaleFactor: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoContentScale: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoContentRect: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoDirtyRects: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoScreenRect: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoBoundingRect: &'static SCStreamFrameInfo;
}

extern "C" {
    pub static SCStreamFrameInfoPresenterOverlayContentRect: &'static SCStreamFrameInfo;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCStream;

    unsafe impl ClassType for SCStream {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for SCStream {}

extern_methods!(
    unsafe impl SCStream {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithFilter:configuration:delegate:)]
        pub unsafe fn initWithFilter_configuration_delegate(
            this: Allocated<Self>,
            content_filter: &SCContentFilter,
            stream_config: &SCStreamConfiguration,
            delegate: Option<&ProtocolObject<dyn SCStreamDelegate>>,
        ) -> Retained<Self>;

        #[method(removeStreamOutput:type:error:_)]
        pub unsafe fn removeStreamOutput_type_error(
            &self,
            output: &ProtocolObject<dyn SCStreamOutput>,
            r#type: SCStreamOutputType,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "block2")]
        #[method(updateContentFilter:completionHandler:)]
        pub unsafe fn updateContentFilter_completionHandler(
            &self,
            content_filter: &SCContentFilter,
            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[method(updateConfiguration:completionHandler:)]
        pub unsafe fn updateConfiguration_completionHandler(
            &self,
            stream_config: &SCStreamConfiguration,
            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[method(startCaptureWithCompletionHandler:)]
        pub unsafe fn startCaptureWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
        );

        #[cfg(feature = "block2")]
        #[method(stopCaptureWithCompletionHandler:)]
        pub unsafe fn stopCaptureWithCompletionHandler(
            &self,
            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
        );
    }
);

extern_protocol!(
    pub unsafe trait SCStreamOutput: NSObjectProtocol {}

    unsafe impl ProtocolType for dyn SCStreamOutput {}
);

extern_protocol!(
    pub unsafe trait SCStreamDelegate: NSObjectProtocol {
        #[optional]
        #[method(stream:didStopWithError:)]
        unsafe fn stream_didStopWithError(&self, stream: &SCStream, error: &NSError);

        #[optional]
        #[method(userDidStopStream:)]
        unsafe fn userDidStopStream(&self, stream: &SCStream);

        #[optional]
        #[method(outputVideoEffectDidStartForStream:)]
        unsafe fn outputVideoEffectDidStartForStream(&self, stream: &SCStream);

        #[optional]
        #[method(outputVideoEffectDidStopForStream:)]
        unsafe fn outputVideoEffectDidStopForStream(&self, stream: &SCStream);
    }

    unsafe impl ProtocolType for dyn SCStreamDelegate {}
);