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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpcameraposition?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct RPCameraPosition(pub NSInteger);
impl RPCameraPosition {
#[doc(alias = "RPCameraPositionFront")]
pub const Front: Self = Self(1);
#[doc(alias = "RPCameraPositionBack")]
pub const Back: Self = Self(2);
}
unsafe impl Encode for RPCameraPosition {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for RPCameraPosition {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Singleton class used to control app recording.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpscreenrecorder?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct RPScreenRecorder;
);
extern_conformance!(
unsafe impl NSObjectProtocol for RPScreenRecorder {}
);
impl RPScreenRecorder {
extern_methods!(
#[unsafe(method(sharedRecorder))]
#[unsafe(method_family = none)]
pub unsafe fn sharedRecorder() -> Retained<RPScreenRecorder>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "block2")]
/// Deprecated. Use startRecordingWithHandler: instead.
///
///
/// Starts app recording with a completion handler. Note that before recording actually starts, the user may be prompted with UI to confirm recording.
///
/// Parameter `microphoneEnabled`: Determines whether the microphone input should be included in the recorded movie audio.
///
/// handler Called after user interactions are complete. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue starting the recording.
#[deprecated = "Use microphoneEnabled property"]
#[unsafe(method(startRecordingWithMicrophoneEnabled:handler:))]
#[unsafe(method_family = none)]
pub unsafe fn startRecordingWithMicrophoneEnabled_handler(
&self,
microphone_enabled: bool,
handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Starts app recording with a completion handler. Note that before recording actually starts, the user may be prompted with UI to confirm recording.
///
/// handler Called after user interactions are complete. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue starting the recording.
#[unsafe(method(startRecordingWithHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startRecordingWithHandler(
&self,
handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(all(
feature = "RPPreviewViewController",
feature = "block2",
feature = "objc2-app-kit"
))]
#[cfg(target_os = "macos")]
/// Stops app recording with a completion handler.
///
/// handler Called when the movie is ready. Will return an instance of RPPreviewViewController on success which should be presented using [UIViewController presentViewController:animated:completion:]. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue stopping the recording.
#[unsafe(method(stopRecordingWithHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn stopRecordingWithHandler(
&self,
handler: Option<&block2::DynBlock<dyn Fn(*mut RPPreviewViewController, *mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Stops app recording with output URL and completion handler.
///
/// Parameter `url`: Output URL for app recording movie.
///
/// handler Called when movie is written to specified output URL. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue stopping the recording and writing the output URL.
#[unsafe(method(stopRecordingWithOutputURL:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn stopRecordingWithOutputURL_completionHandler(
&self,
url: &NSURL,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Discards the current recording. This can only be called after the handler block in stopRecordingWithHandler: is executed.
#[unsafe(method(discardRecordingWithHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn discardRecordingWithHandler(&self, handler: &block2::DynBlock<dyn Fn()>);
#[cfg(all(
feature = "RPBroadcastExtension",
feature = "block2",
feature = "objc2-core-media"
))]
/// Starts screen and audio capture and continually calls the supplied handler with the current sampleBuffer and bufferType and passed it back to the application. Note that before recording actually starts, the user may be prompted with UI to confirm recording.
///
/// handler Called continually with sampleBuffers and the bufferType. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue starting the capture.
#[unsafe(method(startCaptureWithHandler:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startCaptureWithHandler_completionHandler(
&self,
capture_handler: Option<
&block2::DynBlock<
dyn Fn(NonNull<CMSampleBuffer>, RPSampleBufferType, *mut NSError),
>,
>,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Stops screen capture with a completion handler
///
/// handler Called after the screen capture has stopped. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue stopping the capture
#[unsafe(method(stopCaptureWithHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn stopCaptureWithHandler(
&self,
handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Start clip recording buffering with a completion handler. Note that before recording actually starts, the user may be prompted with UI to confirm recording.
///
/// handler Called after clip recording is started. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue starting clip record buffering.
#[unsafe(method(startClipBufferingWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startClipBufferingWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Stop clip recording buffering with a completion handler.
///
/// handler Called after clip recording session is stopped. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue stopping clip record buffering.
#[unsafe(method(stopClipBufferingWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn stopClipBufferingWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[cfg(feature = "block2")]
/// Exports clip recording
///
/// Parameter `url`: URL containing absolute path for where to save the clip
///
/// Parameter `duration`: Length of time in seconds for clip recording, capped at either the elapsed time, or a maximum of 15 seconds, depending on which is the shorter amount of time
///
/// Must be called after startClipBufferingWithCompletionHandler:, otherwise this will return an error. Exports clip recording from newest samples in buffer for duration. handler Will be called after asset is finished writing to output path. Will be passed an optional NSError in the RPRecordingErrorDomain domain if there was an issue generating the clip recording.
#[unsafe(method(exportClipToURL:duration:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn exportClipToURL_duration_completionHandler(
&self,
url: &NSURL,
duration: NSTimeInterval,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn RPScreenRecorderDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn RPScreenRecorderDelegate>>,
);
#[unsafe(method(isAvailable))]
#[unsafe(method_family = none)]
pub unsafe fn isAvailable(&self) -> bool;
#[unsafe(method(isRecording))]
#[unsafe(method_family = none)]
pub unsafe fn isRecording(&self) -> bool;
#[unsafe(method(isMicrophoneEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isMicrophoneEnabled(&self) -> bool;
/// Setter for [`isMicrophoneEnabled`][Self::isMicrophoneEnabled].
#[unsafe(method(setMicrophoneEnabled:))]
#[unsafe(method_family = none)]
pub unsafe fn setMicrophoneEnabled(&self, microphone_enabled: bool);
#[unsafe(method(isCameraEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isCameraEnabled(&self) -> bool;
/// Setter for [`isCameraEnabled`][Self::isCameraEnabled].
#[unsafe(method(setCameraEnabled:))]
#[unsafe(method_family = none)]
pub unsafe fn setCameraEnabled(&self, camera_enabled: bool);
#[unsafe(method(cameraPosition))]
#[unsafe(method_family = none)]
pub unsafe fn cameraPosition(&self) -> RPCameraPosition;
/// Setter for [`cameraPosition`][Self::cameraPosition].
#[unsafe(method(setCameraPosition:))]
#[unsafe(method_family = none)]
pub unsafe fn setCameraPosition(&self, camera_position: RPCameraPosition);
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
#[unsafe(method(cameraPreviewView))]
#[unsafe(method_family = none)]
pub unsafe fn cameraPreviewView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
);
}
/// Methods declared on superclass `NSObject`.
impl RPScreenRecorder {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/replaykit/rpscreenrecorderdelegate?language=objc)
pub unsafe trait RPScreenRecorderDelegate: NSObjectProtocol {
#[cfg(all(feature = "RPPreviewViewController", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
/// Called when recording has stopped due to an error.
///
/// Parameter `screenRecorder`: The instance of the screen recorder.
///
/// Parameter `error`: An NSError describing why recording has stopped in the RPRecordingErrorDomain.
///
/// Parameter `previewViewController`: If a partial movie is available before it was stopped, an instance of RPPreviewViewController will be returned.
#[deprecated = "No longer supported"]
#[optional]
#[unsafe(method(screenRecorder:didStopRecordingWithError:previewViewController:))]
#[unsafe(method_family = none)]
unsafe fn screenRecorder_didStopRecordingWithError_previewViewController(
&self,
screen_recorder: &RPScreenRecorder,
error: &NSError,
preview_view_controller: Option<&RPPreviewViewController>,
);
#[cfg(all(feature = "RPPreviewViewController", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
#[optional]
#[unsafe(method(screenRecorder:didStopRecordingWithPreviewViewController:error:))]
#[unsafe(method_family = none)]
unsafe fn screenRecorder_didStopRecordingWithPreviewViewController_error(
&self,
screen_recorder: &RPScreenRecorder,
preview_view_controller: Option<&RPPreviewViewController>,
error: Option<&NSError>,
);
/// Called when the recorder becomes available or stops being available. Check the screen recorder's availability property to check the current availability state. Possible reasons for the recorder to be unavailable include an in-progress Airplay/TVOut session or unsupported hardware.
///
/// Parameter `screenRecorder`: The instance of the screen recorder.
#[optional]
#[unsafe(method(screenRecorderDidChangeAvailability:))]
#[unsafe(method_family = none)]
unsafe fn screenRecorderDidChangeAvailability(&self, screen_recorder: &RPScreenRecorder);
}
);