objc2_av_foundation/generated/AVCaptureInput.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12use objc2_foundation::*;
13
14use crate::*;
15
16extern_class!(
17 /// AVCaptureInput is an abstract class that provides an interface for connecting capture input sources to an AVCaptureSession.
18 ///
19 ///
20 /// Concrete instances of AVCaptureInput representing input sources such as cameras can be added to instances of AVCaptureSession using the -[AVCaptureSession addInput:] method. An AVCaptureInput vends one or more streams of media data. For example, input devices can provide both audio and video data. Each media stream provided by an input is represented by an AVCaptureInputPort object. Within a capture session, connections are made between AVCaptureInput instances and AVCaptureOutput instances via AVCaptureConnection objects that define the mapping between a set of AVCaptureInputPort objects and a single AVCaptureOutput.
21 ///
22 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureinput?language=objc)
23 #[unsafe(super(NSObject))]
24 #[derive(Debug, PartialEq, Eq, Hash)]
25 pub struct AVCaptureInput;
26);
27
28unsafe impl NSObjectProtocol for AVCaptureInput {}
29
30impl AVCaptureInput {
31 extern_methods!(
32 #[unsafe(method(init))]
33 #[unsafe(method_family = init)]
34 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
35
36 #[unsafe(method(new))]
37 #[unsafe(method_family = new)]
38 pub unsafe fn new() -> Retained<Self>;
39
40 /// The ports owned by the receiver.
41 ///
42 ///
43 /// The value of this property is an array of AVCaptureInputPort objects, each exposing an interface to a single stream of media data provided by an input.
44 #[unsafe(method(ports))]
45 #[unsafe(method_family = none)]
46 pub unsafe fn ports(&self) -> Retained<NSArray<AVCaptureInputPort>>;
47 );
48}
49
50extern "C" {
51 /// This notification is posted when the value of an AVCaptureInputPort instance's formatDescription property changes.
52 ///
53 ///
54 /// The notification object is the AVCaptureInputPort instance whose format description changed.
55 ///
56 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureinputportformatdescriptiondidchangenotification?language=objc)
57 pub static AVCaptureInputPortFormatDescriptionDidChangeNotification:
58 &'static NSNotificationName;
59}
60
61extern_class!(
62 /// An AVCaptureInputPort describes a single stream of media data provided by an AVCaptureInput and provides an interface for connecting that stream to AVCaptureOutput instances via AVCaptureConnection.
63 ///
64 ///
65 /// Instances of AVCaptureInputPort cannot be created directly. An AVCaptureInput exposes its input ports via its ports property. Input ports provide information about the format of their media data via the mediaType and formatDescription properties, and allow clients to control the flow of data via the enabled property. Input ports are used by an AVCaptureConnection to define the mapping between inputs and outputs in an AVCaptureSession.
66 ///
67 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureinputport?language=objc)
68 #[unsafe(super(NSObject))]
69 #[derive(Debug, PartialEq, Eq, Hash)]
70 pub struct AVCaptureInputPort;
71);
72
73unsafe impl NSObjectProtocol for AVCaptureInputPort {}
74
75impl AVCaptureInputPort {
76 extern_methods!(
77 #[unsafe(method(init))]
78 #[unsafe(method_family = init)]
79 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
80
81 #[unsafe(method(new))]
82 #[unsafe(method_family = new)]
83 pub unsafe fn new() -> Retained<Self>;
84
85 /// The input that owns the receiver.
86 ///
87 ///
88 /// The value of this property is an AVCaptureInput instance that owns the receiver.
89 #[unsafe(method(input))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn input(&self) -> Retained<AVCaptureInput>;
92
93 #[cfg(feature = "AVMediaFormat")]
94 /// The media type of the data provided by the receiver.
95 ///
96 ///
97 /// The value of this property is a constant describing the type of media, such as AVMediaTypeVideo or AVMediaTypeAudio, provided by the receiver. Media type constants are defined in AVMediaFormat.h.
98 #[unsafe(method(mediaType))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn mediaType(&self) -> Retained<AVMediaType>;
101
102 #[cfg(feature = "objc2-core-media")]
103 /// The format of the data provided by the receiver.
104 ///
105 ///
106 /// The value of this property is a CMFormatDescription that describes the format of the media data currently provided by the receiver. Clients can be notified of changes to the format by observing the AVCaptureInputPortFormatDescriptionDidChangeNotification.
107 #[unsafe(method(formatDescription))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn formatDescription(&self) -> Option<Retained<CMFormatDescription>>;
110
111 /// Whether the receiver should provide data.
112 ///
113 ///
114 /// The value of this property is a BOOL that determines whether the receiver should provide data to outputs when a session is running. Clients can set this property to fine tune which media streams from a given input will be used during capture. The default value is YES.
115 #[unsafe(method(isEnabled))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn isEnabled(&self) -> bool;
118
119 /// Setter for [`isEnabled`][Self::isEnabled].
120 #[unsafe(method(setEnabled:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn setEnabled(&self, enabled: bool);
123
124 #[cfg(feature = "objc2-core-media")]
125 /// Provides access to the "native" clock used by the input port.
126 ///
127 ///
128 /// The clock is read-only.
129 #[unsafe(method(clock))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn clock(&self) -> Option<Retained<CMClock>>;
132
133 #[cfg(feature = "AVCaptureDevice")]
134 /// The AVCaptureDeviceType of the source device providing input through this port.
135 ///
136 ///
137 /// All AVCaptureInputPorts contained in an AVCaptureDeviceInput's ports array have the same sourceDeviceType, which is equal to deviceInput.device.deviceType. All of these ports are legal for use in an AVCaptureSession. When working with virtual devices such as the DualCamera in an AVCaptureMultiCamSession, it is possible to stream media from the virtual device's constituent device streams by discovering and connecting hidden ports. In the case of the DualCamera, its constituent devices are the WideAngle camera and the Telephoto camera. By calling -[AVCaptureDeviceInput portsWithMediaType:sourceDeviceType:sourceDevicePosition:], you may discover ports originating from one or more of the virtual device's constituent devices and then make connections using those ports. Constituent device ports are never present in their owning virtual device input's ports array. As an example, to find the video port originating from the DualCamera's Telephoto camera constituent device, you call [dualCameraDeviceInput portsWithMediaType:AVMediaTypeVideo sourceDeviceType:AVCaptureDeviceTypeBuiltInTelephotoCamera sourceDevicePosition:dualCamera.position] and use the first port in the resulting array.
138 #[unsafe(method(sourceDeviceType))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn sourceDeviceType(&self) -> Option<Retained<AVCaptureDeviceType>>;
141
142 #[cfg(feature = "AVCaptureDevice")]
143 /// The AVCaptureDevicePosition of the source device providing input through this port.
144 ///
145 ///
146 /// All AVCaptureInputPorts contained in an AVCaptureDeviceInput's ports array have the same sourceDevicePosition, which is deviceInput.device.position. When working with microphone input in an AVCaptureMultiCamSession, it is possible to record multiple microphone directions simultaneously, for instance, to record front-facing microphone input to pair with video from the front facing camera, and back-facing microphone input to pair with the video from the back-facing camera. By calling -[AVCaptureDeviceInput portsWithMediaType:sourceDeviceType:sourceDevicePosition:], you may discover additional hidden ports originating from the source audio device. These ports represent individual microphones positioned to pick up audio from one particular direction. Examples follow.
147 ///
148 /// To discover the audio port that captures omnidirectional audio, use [microphoneDeviceInput portsWithMediaType:AVMediaTypeAudio sourceDeviceType:AVCaptureDeviceTypeMicrophone sourceDevicePosition:AVCaptureDevicePositionUnspecified].firstObject.
149 /// To discover the audio port that captures front-facing audio, use [microphoneDeviceInput portsWithMediaType:AVMediaTypeAudio sourceDeviceType:AVCaptureDeviceTypeMicrophone sourceDevicePosition:AVCaptureDevicePositionFront].firstObject.
150 /// To discover the audio port that captures back-facing audio, use [microphoneDeviceInput portsWithMediaType:AVMediaTypeAudio sourceDeviceType:AVCaptureDeviceTypeMicrophone sourceDevicePosition:AVCaptureDevicePositionBack].firstObject.
151 #[unsafe(method(sourceDevicePosition))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn sourceDevicePosition(&self) -> AVCaptureDevicePosition;
154 );
155}
156
157/// Constants indicating the modes of multichannel audio.
158///
159///
160/// Indicates that no multichannel audio should be used.
161///
162/// Indicates that the audio should be recorded using stereo.
163///
164/// Indicates that the audio should be recorded using first-order ambisonics. When recording a QuickTime movie file, a stereo audio track will be recorded alongside the FOA track for backward playback compatibility.
165///
166/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturemultichannelaudiomode?language=objc)
167// NS_ENUM
168#[repr(transparent)]
169#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
170pub struct AVCaptureMultichannelAudioMode(pub NSInteger);
171impl AVCaptureMultichannelAudioMode {
172 #[doc(alias = "AVCaptureMultichannelAudioModeNone")]
173 pub const None: Self = Self(0);
174 #[doc(alias = "AVCaptureMultichannelAudioModeStereo")]
175 pub const Stereo: Self = Self(1);
176 #[doc(alias = "AVCaptureMultichannelAudioModeFirstOrderAmbisonics")]
177 pub const FirstOrderAmbisonics: Self = Self(2);
178}
179
180unsafe impl Encode for AVCaptureMultichannelAudioMode {
181 const ENCODING: Encoding = NSInteger::ENCODING;
182}
183
184unsafe impl RefEncode for AVCaptureMultichannelAudioMode {
185 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
186}
187
188extern_class!(
189 /// AVCaptureDeviceInput is a concrete subclass of AVCaptureInput that provides an interface for capturing media from an AVCaptureDevice.
190 ///
191 ///
192 /// Instances of AVCaptureDeviceInput are input sources for AVCaptureSession that provide media data from devices connected to the system, represented by instances of AVCaptureDevice.
193 ///
194 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedeviceinput?language=objc)
195 #[unsafe(super(AVCaptureInput, NSObject))]
196 #[derive(Debug, PartialEq, Eq, Hash)]
197 pub struct AVCaptureDeviceInput;
198);
199
200unsafe impl NSObjectProtocol for AVCaptureDeviceInput {}
201
202impl AVCaptureDeviceInput {
203 extern_methods!(
204 #[cfg(feature = "AVCaptureDevice")]
205 /// Returns an AVCaptureDeviceInput instance that provides media data from the given device.
206 ///
207 ///
208 /// Parameter `device`: An AVCaptureDevice instance to be used for capture.
209 ///
210 /// Parameter `outError`: On return, if the given device cannot be used for capture, points to an NSError describing the problem.
211 ///
212 /// Returns: An AVCaptureDeviceInput instance that provides data from the given device, or nil, if the device could not be used for capture.
213 ///
214 ///
215 /// This method returns an instance of AVCaptureDeviceInput that can be used to capture data from an AVCaptureDevice in an AVCaptureSession. This method attempts to open the device for capture, taking exclusive control of it if necessary. If the device cannot be opened because it is no longer available or because it is in use, for example, this method returns nil, and the optional outError parameter points to an NSError describing the problem.
216 #[unsafe(method(deviceInputWithDevice:error:_))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn deviceInputWithDevice_error(
219 device: &AVCaptureDevice,
220 ) -> Result<Retained<Self>, Retained<NSError>>;
221
222 #[cfg(feature = "AVCaptureDevice")]
223 /// Creates an AVCaptureDeviceInput instance that provides media data from the given device.
224 ///
225 ///
226 /// Parameter `device`: An AVCaptureDevice instance to be used for capture.
227 ///
228 /// Parameter `outError`: On return, if the given device cannot be used for capture, points to an NSError describing the problem.
229 ///
230 /// Returns: An AVCaptureDeviceInput instance that provides data from the given device, or nil, if the device could not be used for capture.
231 ///
232 ///
233 /// This method creates an instance of AVCaptureDeviceInput that can be used to capture data from an AVCaptureDevice in an AVCaptureSession. This method attempts to open the device for capture, taking exclusive control of it if necessary. If the device cannot be opened because it is no longer available or because it is in use, for example, this method returns nil, and the optional outError parameter points to an NSError describing the problem.
234 #[unsafe(method(initWithDevice:error:_))]
235 #[unsafe(method_family = init)]
236 pub unsafe fn initWithDevice_error(
237 this: Allocated<Self>,
238 device: &AVCaptureDevice,
239 ) -> Result<Retained<Self>, Retained<NSError>>;
240
241 #[cfg(feature = "AVCaptureDevice")]
242 /// The device from which the receiver provides data.
243 ///
244 ///
245 /// The value of this property is the AVCaptureDevice instance that was used to create the receiver.
246 #[unsafe(method(device))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn device(&self) -> Retained<AVCaptureDevice>;
249
250 /// Specifies whether the source device should use the same default auto exposure behaviors for -[AVCaptureSession setSessionPreset:] and -[AVCaptureDevice setActiveFormat:].
251 ///
252 ///
253 /// AVCaptureDevice's activeFormat property may be set two different ways. 1) You set it directly using one of the formats in the device's -formats array, or 2) the AVCaptureSession sets it on your behalf when you set the AVCaptureSession's sessionPreset property. Depending on the device and format, the default auto exposure behavior may be configured differently when you use one method or the other, resulting in non-uniform auto exposure behavior. Auto exposure defaults include min frame rate, max frame rate, and max exposure duration. If you wish to ensure that consistent default behaviors are applied to the device regardless of the API you use to configure the activeFormat, you may set the device input's unifiedAutoExposureDefaultsEnabled property to YES. Default value for this property is NO.
254 ///
255 /// Note that if you manually set the device's min frame rate, max frame rate, or max exposure duration, your custom values will override the device defaults regardless of whether you've set this property to YES.
256 #[unsafe(method(unifiedAutoExposureDefaultsEnabled))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn unifiedAutoExposureDefaultsEnabled(&self) -> bool;
259
260 /// Setter for [`unifiedAutoExposureDefaultsEnabled`][Self::unifiedAutoExposureDefaultsEnabled].
261 #[unsafe(method(setUnifiedAutoExposureDefaultsEnabled:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn setUnifiedAutoExposureDefaultsEnabled(
264 &self,
265 unified_auto_exposure_defaults_enabled: bool,
266 );
267
268 #[cfg(all(feature = "AVCaptureDevice", feature = "AVMediaFormat"))]
269 /// An accessor method used to retrieve a virtual device's constituent device ports for use in an AVCaptureMultiCamSession.
270 ///
271 ///
272 /// Parameter `mediaType`: The AVMediaType of the port for which you're searching, or nil if all media types should be considered.
273 ///
274 /// Parameter `sourceDeviceType`: The AVCaptureDeviceType of the port for which you're searching, or nil if source device type is irrelevant.
275 ///
276 /// Parameter `sourceDevicePosition`: The AVCaptureDevicePosition of the port for which you're searching. AVCaptureDevicePositionUnspecified is germane to audio devices, indicating omnidirectional audio. For other types of capture devices (e.g. cameras), AVCaptureDevicePositionUnspecified means all positions should be considered in the search.
277 ///
278 ///
279 /// Returns: An array of AVCaptureInputPorts satisfying the search criteria, or an empty array could be found.
280 ///
281 ///
282 /// When using AVCaptureMultiCamSession, multiple devices may be run simultaneously. You may also run simultaneous streams from a virtual device such as the Dual Camera. By inspecting a virtual device's constituentDevices property, you can find its underlying physical devices and, using this method, search for ports originating from one of those constituent devices. Note that the AVCaptureInput.ports array does not include constituent device ports for virtual devices. You must use this accessor method to discover the ports for which you're specifically looking. These constituent device ports may be used to make connections to outputs for use with an AVCaptureMultiCamSession. Using the Dual Camera as an example, the AVCaptureInput.ports property exposes only those ports supported by the virtual device (it switches automatically between wide and telephoto cameras according to the zoom factor). You may use this method to find the video ports for the constituentDevices.
283 ///
284 /// AVCaptureInputPort *wideVideoPort = [dualCameraInput portsWithMediaType:AVMediaTypeVideo sourceDeviceType:AVCaptureDeviceTypeBuiltInWideAngleCamera sourceDevicePosition:AVCaptureDevicePositionBack].firstObject;
285 /// AVCaptureInputPort *teleVideoPort = [dualCameraInput portsWithMediaType:AVMediaTypeVideo sourceDeviceType:AVCaptureDeviceTypeBuiltInTelephotoCamera sourceDevicePosition:AVCaptureDevicePositionBack].firstObject;
286 ///
287 /// These ports may be used to create connections, say, to two AVCaptureVideoDataOutput instances, allowing for synchronized full frame rate delivery of both wide and telephoto streams.
288 ///
289 /// As of iOS 13, constituent device ports may not be connected to AVCapturePhotoOutput instances. Clients who wish to capture multiple photos from a virtual device should use AVCapturePhotoOutput's virtualDeviceConstituentPhotoDeliveryEnabled feature.
290 ///
291 /// When used in conjunction with an audio device, this method allows you to discover microphones in different AVCaptureDevicePositions. When you intend to work with an AVCaptureMultiCamSession, you may use these ports to make connections and simultaneously capture both front facing and back facing audio simultaneously to two different outputs. When used with an AVCaptureMultiCamSession, the audio device port whose sourceDevicePosition is AVCaptureDevicePositionUnspecified produces omnidirectional sound.
292 #[unsafe(method(portsWithMediaType:sourceDeviceType:sourceDevicePosition:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn portsWithMediaType_sourceDeviceType_sourceDevicePosition(
295 &self,
296 media_type: Option<&AVMediaType>,
297 source_device_type: Option<&AVCaptureDeviceType>,
298 source_device_position: AVCaptureDevicePosition,
299 ) -> Retained<NSArray<AVCaptureInputPort>>;
300
301 #[cfg(feature = "objc2-core-media")]
302 /// A property that acts as a modifier to the AVCaptureDevice's activeVideoMinFrameDuration property. Default value is kCMTimeInvalid.
303 ///
304 ///
305 /// An AVCaptureDevice's activeVideoMinFrameDuration property is the reciprocal of its active maximum frame rate. To limit the max frame rate of the capture device, clients may set the device's activeVideoMinFrameDuration to a value supported by the receiver's activeFormat (see AVCaptureDeviceFormat's videoSupportedFrameRateRanges property). Changes you make to the device's activeVideoMinFrameDuration property take effect immediately without disrupting preview. Therefore, the AVCaptureSession must always allocate sufficient resources to allow the device to run at its activeFormat's max allowable frame rate. If you wish to use a particular device format but only ever run it at lower frame rates (for instance, only run a 1080p240 fps format at a max frame rate of 60), you can set the AVCaptureDeviceInput's videoMinFrameDurationOverride property to the reciprocal of the max frame rate you intend to use before starting the session (or within a beginConfiguration / commitConfiguration block while running the session).
306 ///
307 /// When a device input is added to a session, this property reverts back to the default of kCMTimeInvalid (no override).
308 #[unsafe(method(videoMinFrameDurationOverride))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn videoMinFrameDurationOverride(&self) -> CMTime;
311
312 #[cfg(feature = "objc2-core-media")]
313 /// Setter for [`videoMinFrameDurationOverride`][Self::videoMinFrameDurationOverride].
314 #[unsafe(method(setVideoMinFrameDurationOverride:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn setVideoMinFrameDurationOverride(
317 &self,
318 video_min_frame_duration_override: CMTime,
319 );
320
321 /// Returns whether the receiver supports the given multichannel audio mode.
322 ///
323 ///
324 /// Parameter `multichannelAudioMode`: An AVCaptureMultichannelAudioMode to be checked.
325 ///
326 /// Returns: YES if the receiver supports the given multichannel audio mode, NO otherwise.
327 ///
328 ///
329 /// The receiver's multichannelAudioMode property can only be set to a certain mode if this method returns YES for that mode.
330 ///
331 /// Multichannel audio modes are not supported when used in conjunction with AVCaptureMultiCamSession.
332 #[unsafe(method(isMultichannelAudioModeSupported:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn isMultichannelAudioModeSupported(
335 &self,
336 multichannel_audio_mode: AVCaptureMultichannelAudioMode,
337 ) -> bool;
338
339 /// Indicates the multichannel audio mode to apply when recording audio.
340 ///
341 ///
342 /// This property only takes effect when audio is being routed through the built-in microphone, and is ignored if an external microphone is in use.
343 ///
344 /// The default value is AVCaptureMultichannelAudioModeNone, in which case the default single channel audio recording is used.
345 #[unsafe(method(multichannelAudioMode))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn multichannelAudioMode(&self) -> AVCaptureMultichannelAudioMode;
348
349 /// Setter for [`multichannelAudioMode`][Self::multichannelAudioMode].
350 #[unsafe(method(setMultichannelAudioMode:))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn setMultichannelAudioMode(
353 &self,
354 multichannel_audio_mode: AVCaptureMultichannelAudioMode,
355 );
356
357 /// Returns whether or not the device supports wind noise removal during audio capture.
358 ///
359 ///
360 /// YES if the device supports wind noise removal, NO otherwise.
361 #[unsafe(method(isWindNoiseRemovalSupported))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn isWindNoiseRemovalSupported(&self) -> bool;
364
365 /// Specifies whether or not wind noise is removed during audio capture.
366 ///
367 ///
368 /// Wind noise removal is available when the AVCaptureDeviceInput multichannelAudioMode property is set to any value other than AVCaptureMultichannelAudioModeNone.
369 #[unsafe(method(isWindNoiseRemovalEnabled))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn isWindNoiseRemovalEnabled(&self) -> bool;
372
373 /// Setter for [`isWindNoiseRemovalEnabled`][Self::isWindNoiseRemovalEnabled].
374 #[unsafe(method(setWindNoiseRemovalEnabled:))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn setWindNoiseRemovalEnabled(&self, wind_noise_removal_enabled: bool);
377 );
378}
379
380/// Methods declared on superclass `AVCaptureInput`.
381impl AVCaptureDeviceInput {
382 extern_methods!(
383 #[unsafe(method(init))]
384 #[unsafe(method_family = init)]
385 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
386
387 #[unsafe(method(new))]
388 #[unsafe(method_family = new)]
389 pub unsafe fn new() -> Retained<Self>;
390 );
391}
392
393extern_class!(
394 /// AVCaptureScreenInput is a concrete subclass of AVCaptureInput that provides an interface for capturing media from a screen or portion thereof.
395 ///
396 ///
397 /// Instances of AVCaptureScreenInput are input sources for AVCaptureSession that provide media data from one of the screens connected to the system, represented by CGDirectDisplayIDs.
398 ///
399 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturescreeninput?language=objc)
400 #[unsafe(super(AVCaptureInput, NSObject))]
401 #[derive(Debug, PartialEq, Eq, Hash)]
402 pub struct AVCaptureScreenInput;
403);
404
405unsafe impl NSObjectProtocol for AVCaptureScreenInput {}
406
407impl AVCaptureScreenInput {
408 extern_methods!(
409 /// Creates an AVCaptureScreenInput instance that provides media data from the main display.
410 ///
411 ///
412 /// This method creates an instance of AVCaptureScreenInput using the main display whose id is returned from CGMainDisplayID().
413 #[unsafe(method(init))]
414 #[unsafe(method_family = init)]
415 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
416
417 #[unsafe(method(new))]
418 #[unsafe(method_family = new)]
419 pub unsafe fn new() -> Retained<Self>;
420
421 #[cfg(feature = "objc2-core-graphics")]
422 /// Creates an AVCaptureScreenInput instance that provides media data from the given display.
423 ///
424 ///
425 /// Parameter `displayID`: The id of the display from which to capture video. CGDirectDisplayID is defined in
426 /// <CoreGraphics
427 /// /CGDirectDisplay.h>
428 ///
429 /// Returns: An AVCaptureScreenInput instance that provides data from the given screen, or nil, if the screen could not be used for capture.
430 ///
431 ///
432 /// This method creates an instance of AVCaptureScreenInput that can be used to capture data from a display in an AVCaptureSession. This method validates the displayID. If the display cannot be used because it is not available on the system, for example, this method returns nil.
433 #[unsafe(method(initWithDisplayID:))]
434 #[unsafe(method_family = init)]
435 pub unsafe fn initWithDisplayID(
436 this: Allocated<Self>,
437 display_id: CGDirectDisplayID,
438 ) -> Option<Retained<Self>>;
439
440 #[cfg(feature = "objc2-core-media")]
441 /// A property indicating the screen input's minimum frame duration.
442 ///
443 ///
444 /// An AVCaptureScreenInput's minFrameDuration is the reciprocal of its maximum frame rate. This property may be used to request a maximum frame rate at which the input produces video frames. The requested rate may not be achievable due to overall bandwidth, so actual frame rates may be lower.
445 #[unsafe(method(minFrameDuration))]
446 #[unsafe(method_family = none)]
447 pub unsafe fn minFrameDuration(&self) -> CMTime;
448
449 #[cfg(feature = "objc2-core-media")]
450 /// Setter for [`minFrameDuration`][Self::minFrameDuration].
451 #[unsafe(method(setMinFrameDuration:))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn setMinFrameDuration(&self, min_frame_duration: CMTime);
454
455 #[cfg(feature = "objc2-core-foundation")]
456 /// A property indicating the bounding rectangle of the screen area to be captured in points.
457 ///
458 ///
459 /// By default, AVCaptureScreenInput captures the entire area of the displayID with which it is associated. To limit the capture rectangle to a subsection of the screen, set the cropRect property, which defines a smaller section of the screen in the screen's coordinate system. The origin (0,0) is the bottom-left corner of the screen.
460 #[unsafe(method(cropRect))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn cropRect(&self) -> CGRect;
463
464 #[cfg(feature = "objc2-core-foundation")]
465 /// Setter for [`cropRect`][Self::cropRect].
466 #[unsafe(method(setCropRect:))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn setCropRect(&self, crop_rect: CGRect);
469
470 #[cfg(feature = "objc2-core-foundation")]
471 /// A property indicating the factor by which video buffers captured from the screen are to be scaled.
472 ///
473 ///
474 /// By default, AVCaptureScreenInput captures the video buffers from the display at a scale factor of 1.0 (no scaling). Set this property to scale the buffers by a given factor. For instance, a 320x240 capture area with a scaleFactor of 2.0f produces video buffers at 640x480.
475 #[unsafe(method(scaleFactor))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn scaleFactor(&self) -> CGFloat;
478
479 #[cfg(feature = "objc2-core-foundation")]
480 /// Setter for [`scaleFactor`][Self::scaleFactor].
481 #[unsafe(method(setScaleFactor:))]
482 #[unsafe(method_family = none)]
483 pub unsafe fn setScaleFactor(&self, scale_factor: CGFloat);
484
485 /// A property indicating whether mouse clicks should be highlighted in the captured output.
486 ///
487 ///
488 /// By default, AVCaptureScreenInput does not highlight mouse clicks in its captured output. If this property is set to YES, mouse clicks are highlighted (a circle is drawn around the mouse for the duration of the click) in the captured output.
489 #[unsafe(method(capturesMouseClicks))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn capturesMouseClicks(&self) -> bool;
492
493 /// Setter for [`capturesMouseClicks`][Self::capturesMouseClicks].
494 #[unsafe(method(setCapturesMouseClicks:))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn setCapturesMouseClicks(&self, captures_mouse_clicks: bool);
497
498 /// A property indicating whether the cursor should be rendered to the captured output.
499 ///
500 ///
501 /// By default, AVCaptureScreenInput draws the cursor in its captured output. If this property is set to NO, the captured output contains only the windows on the screen. Cursor is omitted. Note that cursor position and mouse button state at the time of capture is preserved in CMSampleBuffers emitted from AVCaptureScreenInput. See the inline documentation for kCMIOSampleBufferAttachmentKey_MouseAndKeyboardModifiers in
502 /// <CoreMediaIO
503 /// /CMIOSampleBuffer.h>
504 #[unsafe(method(capturesCursor))]
505 #[unsafe(method_family = none)]
506 pub unsafe fn capturesCursor(&self) -> bool;
507
508 /// Setter for [`capturesCursor`][Self::capturesCursor].
509 #[unsafe(method(setCapturesCursor:))]
510 #[unsafe(method_family = none)]
511 pub unsafe fn setCapturesCursor(&self, captures_cursor: bool);
512
513 /// A property indicating whether duplicate frames should be removed by the input.
514 ///
515 ///
516 /// If this property is set to YES, AVCaptureScreenInput performs frame differencing and when it detects duplicate frames, it drops them. If set to NO, the captured output receives all frames from the input. Prior to 10.9 this value defaulted to YES. In 10.9 and later, it defaults to NO, as modern platforms support frame differencing in hardware-based encoders.
517 ///
518 /// As of 10.10, this property has been deprecated and is ignored. Clients wishing to re-create this functionality can use an AVCaptureVideoDataOutput and compare frame contents in their own code. If they wish to write a movie file, they can then pass the unique frames to an AVAssetWriterInput.
519 #[deprecated = "No longer supported."]
520 #[unsafe(method(removesDuplicateFrames))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn removesDuplicateFrames(&self) -> bool;
523
524 /// Setter for [`removesDuplicateFrames`][Self::removesDuplicateFrames].
525 #[deprecated = "No longer supported."]
526 #[unsafe(method(setRemovesDuplicateFrames:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn setRemovesDuplicateFrames(&self, removes_duplicate_frames: bool);
529 );
530}
531
532extern_class!(
533 /// AVCaptureMetadataInput is a concrete subclass of AVCaptureInput that provides a way for clients to supply AVMetadataItems to an AVCaptureSession.
534 ///
535 ///
536 /// Instances of AVCaptureMetadataInput are input sources for AVCaptureSession that provide AVMetadataItems to an AVCaptureSession. AVCaptureMetadataInputs present one and only one AVCaptureInputPort, which currently may only be connected to an AVCaptureMovieFileOutput. The metadata supplied over the input port is provided by the client, and must conform to a client-supplied CMFormatDescription. The AVMetadataItems are supplied in an AVTimedMetadataGroup.
537 ///
538 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturemetadatainput?language=objc)
539 #[unsafe(super(AVCaptureInput, NSObject))]
540 #[derive(Debug, PartialEq, Eq, Hash)]
541 pub struct AVCaptureMetadataInput;
542);
543
544unsafe impl NSObjectProtocol for AVCaptureMetadataInput {}
545
546impl AVCaptureMetadataInput {
547 extern_methods!(
548 #[cfg(feature = "objc2-core-media")]
549 /// Returns an AVCaptureMetadataInput instance that allows a client to provide AVTimedMetadataGroups to an AVCaptureSession.
550 ///
551 ///
552 /// Parameter `desc`: A CMFormatDescription that defines the metadata to be supplied by the client. Throws an NSInvalidArgumentException if NULL is passed.
553 ///
554 /// Parameter `clock`: A CMClock that provided the timebase for the supplied samples. Throws an NSInvalidArgumentException if NULL is passed.
555 ///
556 /// Returns: An AVCaptureMetadataInput instance.
557 ///
558 ///
559 /// This method returns an instance of AVCaptureMetadataInput that can be used to capture AVTimedMetadataGroups supplied by the client to an AVCaptureSession.
560 #[unsafe(method(metadataInputWithFormatDescription:clock:))]
561 #[unsafe(method_family = none)]
562 pub unsafe fn metadataInputWithFormatDescription_clock(
563 desc: &CMMetadataFormatDescription,
564 clock: &CMClock,
565 ) -> Retained<Self>;
566
567 #[cfg(feature = "objc2-core-media")]
568 /// Creates an AVCaptureMetadataInput instance that allows a client to provide AVTimedMetadataGroups to an AVCaptureSession.
569 ///
570 ///
571 /// Parameter `desc`: A CMFormatDescription that defines the metadata to be supplied by the client. Throws NSInvalidArgumentException if NULL is passed.
572 ///
573 /// Parameter `clock`: A CMClock that provided the timebase for the supplied samples. Throws NSInvalidArgumentException if NULL is passed.
574 ///
575 /// Returns: An AVCaptureMetadataInput instance, or nil, if the device could not be used for capture.
576 ///
577 ///
578 /// This method creates an instance of AVCaptureMetadataInput that can be used to capture AVTimedMetadataGroups supplied by the client to an AVCaptureSession.
579 #[unsafe(method(initWithFormatDescription:clock:))]
580 #[unsafe(method_family = init)]
581 pub unsafe fn initWithFormatDescription_clock(
582 this: Allocated<Self>,
583 desc: &CMMetadataFormatDescription,
584 clock: &CMClock,
585 ) -> Retained<Self>;
586
587 #[cfg(feature = "AVTimedMetadataGroup")]
588 /// Provides metadata to the AVCaptureSession.
589 ///
590 ///
591 /// Parameter `metadata`: An AVTimedMetadataGroup of metadata. Will throw an exception if nil. In order to denote a period of no metadata, an empty AVTimedMetadataGroup should be passed.
592 ///
593 ///
594 /// The provided AVTimedMetadataGroup will be provided to the AVCaptureSession. The group's presentation timestamp is expressed in the context of the clock supplied to the initializer. It is not required that the AVTimedMetadataGroup have a duration; an empty AVTimedMetadataGroup can be supplied to denote a period of no metadata.
595 #[unsafe(method(appendTimedMetadataGroup:error:_))]
596 #[unsafe(method_family = none)]
597 pub unsafe fn appendTimedMetadataGroup_error(
598 &self,
599 metadata: &AVTimedMetadataGroup,
600 ) -> Result<(), Retained<NSError>>;
601 );
602}
603
604/// Methods declared on superclass `AVCaptureInput`.
605impl AVCaptureMetadataInput {
606 extern_methods!(
607 #[unsafe(method(init))]
608 #[unsafe(method_family = init)]
609 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
610
611 #[unsafe(method(new))]
612 #[unsafe(method_family = new)]
613 pub unsafe fn new() -> Retained<Self>;
614 );
615}