objc2_av_foundation/generated/
AVCaptureVideoPreviewLayer.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::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15extern_class!(
16    /// A CoreAnimation layer subclass for previewing the visual output of an AVCaptureSession.
17    ///
18    ///
19    /// An AVCaptureVideoPreviewLayer instance is a subclass of CALayer and is therefore suitable for insertion in a layer hierarchy as part of a graphical interface. One creates an AVCaptureVideoPreviewLayer instance with the capture session to be previewed, using +layerWithSession: or -initWithSession:. Using the
20    /// "
21    /// videoGravity" property, one can influence how content is viewed relative to the layer bounds. On some hardware configurations, the orientation of the layer can be manipulated using @"orientation" and @"mirrored".
22    ///
23    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturevideopreviewlayer?language=objc)
24    #[unsafe(super(CALayer, NSObject))]
25    #[derive(Debug, PartialEq, Eq, Hash)]
26    #[cfg(feature = "objc2-quartz-core")]
27    #[cfg(not(target_os = "watchos"))]
28    pub struct AVCaptureVideoPreviewLayer;
29);
30
31#[cfg(feature = "objc2-quartz-core")]
32#[cfg(not(target_os = "watchos"))]
33extern_conformance!(
34    unsafe impl CAMediaTiming for AVCaptureVideoPreviewLayer {}
35);
36
37#[cfg(feature = "objc2-quartz-core")]
38#[cfg(not(target_os = "watchos"))]
39extern_conformance!(
40    unsafe impl NSCoding for AVCaptureVideoPreviewLayer {}
41);
42
43#[cfg(feature = "objc2-quartz-core")]
44#[cfg(not(target_os = "watchos"))]
45extern_conformance!(
46    unsafe impl NSObjectProtocol for AVCaptureVideoPreviewLayer {}
47);
48
49#[cfg(feature = "objc2-quartz-core")]
50#[cfg(not(target_os = "watchos"))]
51extern_conformance!(
52    unsafe impl NSSecureCoding for AVCaptureVideoPreviewLayer {}
53);
54
55#[cfg(feature = "objc2-quartz-core")]
56#[cfg(not(target_os = "watchos"))]
57impl AVCaptureVideoPreviewLayer {
58    extern_methods!(
59        #[cfg(feature = "AVCaptureSession")]
60        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
61        ///
62        ///
63        /// Parameter `session`: The AVCaptureSession instance to be previewed.
64        ///
65        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
66        #[unsafe(method(layerWithSession:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn layerWithSession(session: &AVCaptureSession) -> Retained<Self>;
69
70        #[cfg(feature = "AVCaptureSession")]
71        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
72        ///
73        ///
74        /// Parameter `session`: The AVCaptureSession instance to be previewed.
75        ///
76        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
77        #[unsafe(method(initWithSession:))]
78        #[unsafe(method_family = init)]
79        pub unsafe fn initWithSession(
80            this: Allocated<Self>,
81            session: &AVCaptureSession,
82        ) -> Retained<Self>;
83
84        #[cfg(feature = "AVCaptureSession")]
85        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession, but creates no connections to any of the session's eligible video inputs. Only use this initializer if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession's -addConnection: method.
86        ///
87        ///
88        /// Parameter `session`: The AVCaptureSession instance to be previewed.
89        ///
90        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
91        #[unsafe(method(layerWithSessionWithNoConnection:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn layerWithSessionWithNoConnection(
94            session: &AVCaptureSession,
95        ) -> Retained<Self>;
96
97        #[cfg(feature = "AVCaptureSession")]
98        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession, but creates no connections to any of the session's eligible video inputs. Only use this initializer if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession's -addConnection: method.
99        ///
100        ///
101        /// Parameter `session`: The AVCaptureSession instance to be previewed.
102        ///
103        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
104        #[unsafe(method(initWithSessionWithNoConnection:))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn initWithSessionWithNoConnection(
107            this: Allocated<Self>,
108            session: &AVCaptureSession,
109        ) -> Retained<Self>;
110
111        #[cfg(feature = "AVCaptureSession")]
112        /// The AVCaptureSession instance being previewed by the receiver.
113        ///
114        ///
115        /// The session is retained by the preview layer.
116        #[unsafe(method(session))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>;
119
120        #[cfg(feature = "AVCaptureSession")]
121        /// Setter for [`session`][Self::session].
122        #[unsafe(method(setSession:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setSession(&self, session: Option<&AVCaptureSession>);
125
126        #[cfg(feature = "AVCaptureSession")]
127        /// method setSessionWithNoConnection:
128        ///
129        /// Attaches the receiver to a given session without implicitly forming a connection to the first eligible video AVCaptureInputPort. Only use this setter if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession's -addConnection: method.
130        ///
131        ///
132        /// The session is retained by the preview layer.
133        #[unsafe(method(setSessionWithNoConnection:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setSessionWithNoConnection(&self, session: &AVCaptureSession);
136
137        #[cfg(feature = "AVCaptureSession")]
138        /// The AVCaptureConnection instance describing the AVCaptureInputPort to which the receiver is connected.
139        ///
140        ///
141        /// When calling initWithSession: or setSession: with a valid AVCaptureSession instance, a connection is formed to the first eligible video AVCaptureInput. If the receiver is detached from a session, the connection property becomes nil.
142        #[unsafe(method(connection))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn connection(&self) -> Option<Retained<AVCaptureConnection>>;
145
146        #[cfg(feature = "AVAnimation")]
147        /// A string defining how the video is displayed within an AVCaptureVideoPreviewLayer bounds rect.
148        ///
149        ///
150        /// Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default. See
151        /// <AVFoundation
152        /// /AVAnimation.h> for a description of these options.
153        #[unsafe(method(videoGravity))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;
156
157        #[cfg(feature = "AVAnimation")]
158        /// Setter for [`videoGravity`][Self::videoGravity].
159        ///
160        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
161        #[unsafe(method(setVideoGravity:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
164
165        /// A BOOL value indicating whether the receiver is currently rendering video frames from its source.
166        ///
167        ///
168        /// An AVCaptureVideoPreviewLayer begins previewing when -[AVCaptureSession startRunning] is called. When associated with an AVCaptureMultiCamSession, all video preview layers are guaranteed to be previewing by the time the blocking call to -startRunning or -commitConfiguration returns. While a session is running, you may enable or disable a video preview layer's connection to re-start or stop the flow of video to the layer. Once you've set enabled to YES, you can observe this property changing from NO to YES and synchronize any UI to take place precisely when the video resumes rendering to the video preview layer.
169        #[unsafe(method(isPreviewing))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn isPreviewing(&self) -> bool;
172
173        #[cfg(feature = "objc2-core-foundation")]
174        /// Converts a point in layer coordinates to a point of interest in the coordinate space of the capture device providing input to the layer.
175        ///
176        ///
177        /// Parameter `pointInLayer`: A CGPoint in layer coordinates.
178        ///
179        /// Returns: A CGPoint in the coordinate space of the capture device providing input to the layer.
180        ///
181        ///
182        /// AVCaptureDevice pointOfInterest is expressed as a CGPoint where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a point in the coordinate space of the receiver to a point of interest in the coordinate space of the AVCaptureDevice providing input to the receiver. The conversion takes frameSize and videoGravity into consideration.
183        #[unsafe(method(captureDevicePointOfInterestForPoint:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn captureDevicePointOfInterestForPoint(
186            &self,
187            point_in_layer: CGPoint,
188        ) -> CGPoint;
189
190        #[cfg(feature = "objc2-core-foundation")]
191        /// Converts a point of interest in the coordinate space of the capture device providing input to the layer to a point in layer coordinates.
192        ///
193        ///
194        /// Parameter `captureDevicePointOfInterest`: A CGPoint in the coordinate space of the capture device providing input to the layer.
195        ///
196        /// Returns: A CGPoint in layer coordinates.
197        ///
198        ///
199        /// AVCaptureDevice pointOfInterest is expressed as a CGPoint where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a point in the coordinate space of the AVCaptureDevice providing input to the coordinate space of the receiver. The conversion takes frame size and videoGravity into consideration.
200        #[unsafe(method(pointForCaptureDevicePointOfInterest:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn pointForCaptureDevicePointOfInterest(
203            &self,
204            capture_device_point_of_interest: CGPoint,
205        ) -> CGPoint;
206
207        #[cfg(feature = "objc2-core-foundation")]
208        /// Converts a rectangle in layer coordinates to a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the layer.
209        ///
210        ///
211        /// Parameter `rectInLayerCoordinates`: A CGRect in layer coordinates.
212        ///
213        /// Returns: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
214        ///
215        ///
216        /// AVCaptureMetadataOutput rectOfInterest is expressed as a CGRect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a rectangle in the coordinate space of the receiver to a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose AVCaptureDevice is providing input to the receiver. The conversion takes frame size and videoGravity into consideration.
217        #[unsafe(method(metadataOutputRectOfInterestForRect:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn metadataOutputRectOfInterestForRect(
220            &self,
221            rect_in_layer_coordinates: CGRect,
222        ) -> CGRect;
223
224        #[cfg(feature = "objc2-core-foundation")]
225        /// Converts a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the layer to a rectangle in layer coordinates.
226        ///
227        ///
228        /// Parameter `rectInMetadataOutputCoordinates`: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
229        ///
230        /// Returns: A CGRect in layer coordinates.
231        ///
232        ///
233        /// AVCaptureMetadataOutput rectOfInterest is expressed as a CGRect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a rectangle in the coordinate space of an AVCaptureMetadataOutput whose AVCaptureDevice is providing input to the coordinate space of the receiver. The conversion takes frame size and videoGravity into consideration.
234        #[unsafe(method(rectForMetadataOutputRectOfInterest:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn rectForMetadataOutputRectOfInterest(
237            &self,
238            rect_in_metadata_output_coordinates: CGRect,
239        ) -> CGRect;
240
241        #[cfg(feature = "AVMetadataObject")]
242        /// Converts an AVMetadataObject's visual properties to layer coordinates.
243        ///
244        ///
245        /// Parameter `metadataObject`: An AVMetadataObject originating from the same AVCaptureInput as the preview layer.
246        ///
247        /// Returns: An AVMetadataObject whose properties are in layer coordinates.
248        ///
249        ///
250        /// AVMetadataObject bounds may be expressed as a rect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. Face metadata objects likewise express yaw and roll angles with respect to an unrotated picture. -transformedMetadataObjectForMetadataObject: converts the visual properties in the coordinate space of the supplied AVMetadataObject to the coordinate space of the receiver. The conversion takes orientation, mirroring, layer bounds and videoGravity into consideration. If the provided metadata object originates from an input source other than the preview layer's, nil will be returned.
251        #[unsafe(method(transformedMetadataObjectForMetadataObject:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn transformedMetadataObjectForMetadataObject(
254            &self,
255            metadata_object: &AVMetadataObject,
256        ) -> Option<Retained<AVMetadataObject>>;
257
258        /// Specifies whether or not the preview layer supports orientation.
259        ///
260        ///
261        /// Changes in orientation are not supported on all hardware configurations. An application should check the value of
262        /// "
263        /// orientationSupported" before attempting to manipulate the orientation of the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoOrientationSupported instead.
264        #[deprecated = "Use AVCaptureConnection's isVideoOrientationSupported instead."]
265        #[unsafe(method(isOrientationSupported))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn isOrientationSupported(&self) -> bool;
268
269        #[cfg(feature = "AVCaptureSession")]
270        /// Specifies the orientation of the preview layer.
271        ///
272        ///
273        /// AVCaptureVideoOrientation and its constants are defined in AVCaptureSession.h. The value of
274        /// "
275        /// orientationSupported" must be YES in order to set @"orientation". An exception will be raised if this requirement is ignored. This property is deprecated. Use AVCaptureConnection's -videoOrientation instead.
276        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
277        #[unsafe(method(orientation))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn orientation(&self) -> AVCaptureVideoOrientation;
280
281        #[cfg(feature = "AVCaptureSession")]
282        /// Setter for [`orientation`][Self::orientation].
283        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
284        #[unsafe(method(setOrientation:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setOrientation(&self, orientation: AVCaptureVideoOrientation);
287
288        /// Specifies whether or not the preview layer supports mirroring.
289        ///
290        ///
291        /// Mirroring is not supported on all hardware configurations. An application should check the value of
292        /// "
293        /// mirroringSupported" before attempting to manipulate mirroring on the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoMirroringSupported instead.
294        #[deprecated = "Use AVCaptureConnection's isVideoMirroringSupported instead."]
295        #[unsafe(method(isMirroringSupported))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn isMirroringSupported(&self) -> bool;
298
299        /// Specifies whether or not the value of
300        /// "
301        /// mirrored" can change based on configuration of the session.
302        ///
303        ///
304        /// For some session configurations, preview will be mirrored by default. When the value of this property is YES, the value of
305        /// "
306        /// mirrored" may change depending on the configuration of the session, for example after switching to a different AVCaptureDeviceInput. The default value is YES. This property is deprecated. Use AVCaptureConnection's -automaticallyAdjustsVideoMirroring instead.
307        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
308        #[unsafe(method(automaticallyAdjustsMirroring))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn automaticallyAdjustsMirroring(&self) -> bool;
311
312        /// Setter for [`automaticallyAdjustsMirroring`][Self::automaticallyAdjustsMirroring].
313        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
314        #[unsafe(method(setAutomaticallyAdjustsMirroring:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn setAutomaticallyAdjustsMirroring(
317            &self,
318            automatically_adjusts_mirroring: bool,
319        );
320
321        /// Specifies whether or not the preview is flipped over a vertical axis.
322        ///
323        ///
324        /// For most applications, it is unnecessary to manipulate preview mirroring manually if
325        /// "
326        /// automaticallyAdjustsMirroring" is set to YES. The value of @"automaticallyAdjustsMirroring" must be NO in order to set @"mirrored". The value of @"mirroringSupported" must be YES in order to set @"mirrored". An exception will be raised if the value of @"mirrored" is mutated without respecting these requirements. This property is deprecated. Use AVCaptureConnection's -videoMirrored instead.
327        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
328        #[unsafe(method(isMirrored))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn isMirrored(&self) -> bool;
331
332        /// Setter for [`isMirrored`][Self::isMirrored].
333        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
334        #[unsafe(method(setMirrored:))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn setMirrored(&self, mirrored: bool);
337
338        /// A `BOOL` value that indicates whether the preview layer supports deferred start.
339        ///
340        /// You can only set the ``deferredStartEnabled`` property to `true` if the preview layer supports deferred start.
341        #[unsafe(method(isDeferredStartSupported))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn isDeferredStartSupported(&self) -> bool;
344
345        /// A `BOOL` value that indicates whether to defer starting this preview layer.
346        ///
347        /// When this value is `true`, the session does not prepare the output's resources until some time after ``AVCaptureSession/startRunning`` returns. You can start the visual parts of your user interface (e.g. preview) prior to other parts (e.g. photo/movie capture, metadata output, etc..) to improve startup performance. Set this value to `false` if your app needs video preview immediately for startup, and `true` if it does not.
348        ///
349        /// By default, this value is `false` for ``AVCaptureVideoPreviewLayer`` objects, since this object is used to display preview. For best session start performance, set ``deferredStartEnabled`` to `false` for preview layers. If your app contains multiple preview layers, you may want to display the main preview layer as soon as possible and allow the remaining layers to display subsequently. In this case, set ``deferredStartEnabled`` to `true` for the remaining layers.
350        ///
351        /// - Note: Setting this property to the same value for all outputs, including ``AVCaptureVideoPreviewLayer`` and ``AVCaptureOutput``, is equivalent to not using deferred start.
352        ///
353        /// If ``deferredStartSupported`` is `false`, setting this property value to `true` results in the session throwing an `NSInvalidArgumentException`.
354        ///
355        /// - Note: Set this value before calling ``AVCaptureSession/commitConfiguration`` as it requires a lengthy reconfiguration of the capture render pipeline.
356        #[unsafe(method(isDeferredStartEnabled))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn isDeferredStartEnabled(&self) -> bool;
359
360        /// Setter for [`isDeferredStartEnabled`][Self::isDeferredStartEnabled].
361        #[unsafe(method(setDeferredStartEnabled:))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn setDeferredStartEnabled(&self, deferred_start_enabled: bool);
364    );
365}
366
367/// Methods declared on superclass `CALayer`.
368#[cfg(feature = "objc2-quartz-core")]
369#[cfg(not(target_os = "watchos"))]
370impl AVCaptureVideoPreviewLayer {
371    extern_methods!(
372        /// Layer creation and initialization. *
373        #[unsafe(method(layer))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn layer() -> Retained<Self>;
376
377        #[unsafe(method(init))]
378        #[unsafe(method_family = init)]
379        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
380
381        /// # Safety
382        ///
383        /// `layer` should be of the correct type.
384        #[unsafe(method(initWithLayer:))]
385        #[unsafe(method_family = init)]
386        pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
387    );
388}
389
390/// Methods declared on superclass `NSObject`.
391#[cfg(feature = "objc2-quartz-core")]
392#[cfg(not(target_os = "watchos"))]
393impl AVCaptureVideoPreviewLayer {
394    extern_methods!(
395        #[unsafe(method(new))]
396        #[unsafe(method_family = new)]
397        pub unsafe fn new() -> Retained<Self>;
398    );
399}