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        #[unsafe(method(setVideoGravity:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
162
163        /// A BOOL value indicating whether the receiver is currently rendering video frames from its source.
164        ///
165        ///
166        /// 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.
167        #[unsafe(method(isPreviewing))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn isPreviewing(&self) -> bool;
170
171        #[cfg(feature = "objc2-core-foundation")]
172        /// Converts a point in layer coordinates to a point of interest in the coordinate space of the capture device providing input to the layer.
173        ///
174        ///
175        /// Parameter `pointInLayer`: A CGPoint in layer coordinates.
176        ///
177        /// Returns: A CGPoint in the coordinate space of the capture device providing input to the layer.
178        ///
179        ///
180        /// 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.
181        #[unsafe(method(captureDevicePointOfInterestForPoint:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn captureDevicePointOfInterestForPoint(
184            &self,
185            point_in_layer: CGPoint,
186        ) -> CGPoint;
187
188        #[cfg(feature = "objc2-core-foundation")]
189        /// Converts a point of interest in the coordinate space of the capture device providing input to the layer to a point in layer coordinates.
190        ///
191        ///
192        /// Parameter `captureDevicePointOfInterest`: A CGPoint in the coordinate space of the capture device providing input to the layer.
193        ///
194        /// Returns: A CGPoint in layer coordinates.
195        ///
196        ///
197        /// 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.
198        #[unsafe(method(pointForCaptureDevicePointOfInterest:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn pointForCaptureDevicePointOfInterest(
201            &self,
202            capture_device_point_of_interest: CGPoint,
203        ) -> CGPoint;
204
205        #[cfg(feature = "objc2-core-foundation")]
206        /// 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.
207        ///
208        ///
209        /// Parameter `rectInLayerCoordinates`: A CGRect in layer coordinates.
210        ///
211        /// Returns: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
212        ///
213        ///
214        /// 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.
215        #[unsafe(method(metadataOutputRectOfInterestForRect:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn metadataOutputRectOfInterestForRect(
218            &self,
219            rect_in_layer_coordinates: CGRect,
220        ) -> CGRect;
221
222        #[cfg(feature = "objc2-core-foundation")]
223        /// 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.
224        ///
225        ///
226        /// Parameter `rectInMetadataOutputCoordinates`: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
227        ///
228        /// Returns: A CGRect in layer coordinates.
229        ///
230        ///
231        /// 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.
232        #[unsafe(method(rectForMetadataOutputRectOfInterest:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn rectForMetadataOutputRectOfInterest(
235            &self,
236            rect_in_metadata_output_coordinates: CGRect,
237        ) -> CGRect;
238
239        #[cfg(feature = "AVMetadataObject")]
240        /// Converts an AVMetadataObject's visual properties to layer coordinates.
241        ///
242        ///
243        /// Parameter `metadataObject`: An AVMetadataObject originating from the same AVCaptureInput as the preview layer.
244        ///
245        /// Returns: An AVMetadataObject whose properties are in layer coordinates.
246        ///
247        ///
248        /// 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.
249        #[unsafe(method(transformedMetadataObjectForMetadataObject:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn transformedMetadataObjectForMetadataObject(
252            &self,
253            metadata_object: &AVMetadataObject,
254        ) -> Option<Retained<AVMetadataObject>>;
255
256        /// Specifies whether or not the preview layer supports orientation.
257        ///
258        ///
259        /// Changes in orientation are not supported on all hardware configurations. An application should check the value of
260        /// "
261        /// orientationSupported" before attempting to manipulate the orientation of the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoOrientationSupported instead.
262        #[deprecated = "Use AVCaptureConnection's isVideoOrientationSupported instead."]
263        #[unsafe(method(isOrientationSupported))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn isOrientationSupported(&self) -> bool;
266
267        #[cfg(feature = "AVCaptureSession")]
268        /// Specifies the orientation of the preview layer.
269        ///
270        ///
271        /// AVCaptureVideoOrientation and its constants are defined in AVCaptureSession.h. The value of
272        /// "
273        /// 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.
274        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
275        #[unsafe(method(orientation))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn orientation(&self) -> AVCaptureVideoOrientation;
278
279        #[cfg(feature = "AVCaptureSession")]
280        /// Setter for [`orientation`][Self::orientation].
281        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
282        #[unsafe(method(setOrientation:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn setOrientation(&self, orientation: AVCaptureVideoOrientation);
285
286        /// Specifies whether or not the preview layer supports mirroring.
287        ///
288        ///
289        /// Mirroring is not supported on all hardware configurations. An application should check the value of
290        /// "
291        /// mirroringSupported" before attempting to manipulate mirroring on the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoMirroringSupported instead.
292        #[deprecated = "Use AVCaptureConnection's isVideoMirroringSupported instead."]
293        #[unsafe(method(isMirroringSupported))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn isMirroringSupported(&self) -> bool;
296
297        /// Specifies whether or not the value of
298        /// "
299        /// mirrored" can change based on configuration of the session.
300        ///
301        ///
302        /// For some session configurations, preview will be mirrored by default. When the value of this property is YES, the value of
303        /// "
304        /// 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.
305        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
306        #[unsafe(method(automaticallyAdjustsMirroring))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn automaticallyAdjustsMirroring(&self) -> bool;
309
310        /// Setter for [`automaticallyAdjustsMirroring`][Self::automaticallyAdjustsMirroring].
311        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
312        #[unsafe(method(setAutomaticallyAdjustsMirroring:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn setAutomaticallyAdjustsMirroring(
315            &self,
316            automatically_adjusts_mirroring: bool,
317        );
318
319        /// Specifies whether or not the preview is flipped over a vertical axis.
320        ///
321        ///
322        /// For most applications, it is unnecessary to manipulate preview mirroring manually if
323        /// "
324        /// 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.
325        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
326        #[unsafe(method(isMirrored))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn isMirrored(&self) -> bool;
329
330        /// Setter for [`isMirrored`][Self::isMirrored].
331        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
332        #[unsafe(method(setMirrored:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn setMirrored(&self, mirrored: bool);
335    );
336}
337
338/// Methods declared on superclass `CALayer`.
339#[cfg(feature = "objc2-quartz-core")]
340#[cfg(not(target_os = "watchos"))]
341impl AVCaptureVideoPreviewLayer {
342    extern_methods!(
343        /// Layer creation and initialization. *
344        #[unsafe(method(layer))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn layer() -> Retained<Self>;
347
348        #[unsafe(method(init))]
349        #[unsafe(method_family = init)]
350        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
351
352        #[unsafe(method(initWithLayer:))]
353        #[unsafe(method_family = init)]
354        pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
355    );
356}
357
358/// Methods declared on superclass `NSObject`.
359#[cfg(feature = "objc2-quartz-core")]
360#[cfg(not(target_os = "watchos"))]
361impl AVCaptureVideoPreviewLayer {
362    extern_methods!(
363        #[unsafe(method(new))]
364        #[unsafe(method_family = new)]
365        pub unsafe fn new() -> Retained<Self>;
366    );
367}