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"))]
33unsafe impl CAMediaTiming for AVCaptureVideoPreviewLayer {}
34
35#[cfg(feature = "objc2-quartz-core")]
36#[cfg(not(target_os = "watchos"))]
37unsafe impl NSCoding for AVCaptureVideoPreviewLayer {}
38
39#[cfg(feature = "objc2-quartz-core")]
40#[cfg(not(target_os = "watchos"))]
41unsafe impl NSObjectProtocol for AVCaptureVideoPreviewLayer {}
42
43#[cfg(feature = "objc2-quartz-core")]
44#[cfg(not(target_os = "watchos"))]
45unsafe impl NSSecureCoding for AVCaptureVideoPreviewLayer {}
46
47#[cfg(feature = "objc2-quartz-core")]
48#[cfg(not(target_os = "watchos"))]
49impl AVCaptureVideoPreviewLayer {
50    extern_methods!(
51        #[cfg(feature = "AVCaptureSession")]
52        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
53        ///
54        ///
55        /// Parameter `session`: The AVCaptureSession instance to be previewed.
56        ///
57        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
58        #[unsafe(method(layerWithSession:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn layerWithSession(session: &AVCaptureSession) -> Retained<Self>;
61
62        #[cfg(feature = "AVCaptureSession")]
63        /// Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
64        ///
65        ///
66        /// Parameter `session`: The AVCaptureSession instance to be previewed.
67        ///
68        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
69        #[unsafe(method(initWithSession:))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn initWithSession(
72            this: Allocated<Self>,
73            session: &AVCaptureSession,
74        ) -> Retained<Self>;
75
76        #[cfg(feature = "AVCaptureSession")]
77        /// 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.
78        ///
79        ///
80        /// Parameter `session`: The AVCaptureSession instance to be previewed.
81        ///
82        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
83        #[unsafe(method(layerWithSessionWithNoConnection:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn layerWithSessionWithNoConnection(
86            session: &AVCaptureSession,
87        ) -> Retained<Self>;
88
89        #[cfg(feature = "AVCaptureSession")]
90        /// 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.
91        ///
92        ///
93        /// Parameter `session`: The AVCaptureSession instance to be previewed.
94        ///
95        /// Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
96        #[unsafe(method(initWithSessionWithNoConnection:))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn initWithSessionWithNoConnection(
99            this: Allocated<Self>,
100            session: &AVCaptureSession,
101        ) -> Retained<Self>;
102
103        #[cfg(feature = "AVCaptureSession")]
104        /// The AVCaptureSession instance being previewed by the receiver.
105        ///
106        ///
107        /// The session is retained by the preview layer.
108        #[unsafe(method(session))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>;
111
112        #[cfg(feature = "AVCaptureSession")]
113        /// Setter for [`session`][Self::session].
114        #[unsafe(method(setSession:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setSession(&self, session: Option<&AVCaptureSession>);
117
118        #[cfg(feature = "AVCaptureSession")]
119        /// method setSessionWithNoConnection:
120        ///
121        /// 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.
122        ///
123        ///
124        /// The session is retained by the preview layer.
125        #[unsafe(method(setSessionWithNoConnection:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setSessionWithNoConnection(&self, session: &AVCaptureSession);
128
129        #[cfg(feature = "AVCaptureSession")]
130        /// The AVCaptureConnection instance describing the AVCaptureInputPort to which the receiver is connected.
131        ///
132        ///
133        /// 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.
134        #[unsafe(method(connection))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn connection(&self) -> Option<Retained<AVCaptureConnection>>;
137
138        #[cfg(feature = "AVAnimation")]
139        /// A string defining how the video is displayed within an AVCaptureVideoPreviewLayer bounds rect.
140        ///
141        ///
142        /// Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default. See
143        /// <AVFoundation
144        /// /AVAnimation.h> for a description of these options.
145        #[unsafe(method(videoGravity))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;
148
149        #[cfg(feature = "AVAnimation")]
150        /// Setter for [`videoGravity`][Self::videoGravity].
151        #[unsafe(method(setVideoGravity:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
154
155        /// A BOOL value indicating whether the receiver is currently rendering video frames from its source.
156        ///
157        ///
158        /// 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.
159        #[unsafe(method(isPreviewing))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn isPreviewing(&self) -> bool;
162
163        #[cfg(feature = "objc2-core-foundation")]
164        /// Converts a point in layer coordinates to a point of interest in the coordinate space of the capture device providing input to the layer.
165        ///
166        ///
167        /// Parameter `pointInLayer`: A CGPoint in layer coordinates.
168        ///
169        /// Returns: A CGPoint in the coordinate space of the capture device providing input to the layer.
170        ///
171        ///
172        /// 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.
173        #[unsafe(method(captureDevicePointOfInterestForPoint:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn captureDevicePointOfInterestForPoint(
176            &self,
177            point_in_layer: CGPoint,
178        ) -> CGPoint;
179
180        #[cfg(feature = "objc2-core-foundation")]
181        /// Converts a point of interest in the coordinate space of the capture device providing input to the layer to a point in layer coordinates.
182        ///
183        ///
184        /// Parameter `captureDevicePointOfInterest`: A CGPoint in the coordinate space of the capture device providing input to the layer.
185        ///
186        /// Returns: A CGPoint in layer coordinates.
187        ///
188        ///
189        /// 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.
190        #[unsafe(method(pointForCaptureDevicePointOfInterest:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn pointForCaptureDevicePointOfInterest(
193            &self,
194            capture_device_point_of_interest: CGPoint,
195        ) -> CGPoint;
196
197        #[cfg(feature = "objc2-core-foundation")]
198        /// 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.
199        ///
200        ///
201        /// Parameter `rectInLayerCoordinates`: A CGRect in layer coordinates.
202        ///
203        /// Returns: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
204        ///
205        ///
206        /// 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.
207        #[unsafe(method(metadataOutputRectOfInterestForRect:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn metadataOutputRectOfInterestForRect(
210            &self,
211            rect_in_layer_coordinates: CGRect,
212        ) -> CGRect;
213
214        #[cfg(feature = "objc2-core-foundation")]
215        /// 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.
216        ///
217        ///
218        /// Parameter `rectInMetadataOutputCoordinates`: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
219        ///
220        /// Returns: A CGRect in layer coordinates.
221        ///
222        ///
223        /// 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.
224        #[unsafe(method(rectForMetadataOutputRectOfInterest:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn rectForMetadataOutputRectOfInterest(
227            &self,
228            rect_in_metadata_output_coordinates: CGRect,
229        ) -> CGRect;
230
231        #[cfg(feature = "AVMetadataObject")]
232        /// Converts an AVMetadataObject's visual properties to layer coordinates.
233        ///
234        ///
235        /// Parameter `metadataObject`: An AVMetadataObject originating from the same AVCaptureInput as the preview layer.
236        ///
237        /// Returns: An AVMetadataObject whose properties are in layer coordinates.
238        ///
239        ///
240        /// 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.
241        #[unsafe(method(transformedMetadataObjectForMetadataObject:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn transformedMetadataObjectForMetadataObject(
244            &self,
245            metadata_object: &AVMetadataObject,
246        ) -> Option<Retained<AVMetadataObject>>;
247
248        /// Specifies whether or not the preview layer supports orientation.
249        ///
250        ///
251        /// Changes in orientation are not supported on all hardware configurations. An application should check the value of
252        /// "
253        /// orientationSupported" before attempting to manipulate the orientation of the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoOrientationSupported instead.
254        #[deprecated = "Use AVCaptureConnection's isVideoOrientationSupported instead."]
255        #[unsafe(method(isOrientationSupported))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn isOrientationSupported(&self) -> bool;
258
259        #[cfg(feature = "AVCaptureSession")]
260        /// Specifies the orientation of the preview layer.
261        ///
262        ///
263        /// AVCaptureVideoOrientation and its constants are defined in AVCaptureSession.h. The value of
264        /// "
265        /// 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.
266        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
267        #[unsafe(method(orientation))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn orientation(&self) -> AVCaptureVideoOrientation;
270
271        #[cfg(feature = "AVCaptureSession")]
272        /// Setter for [`orientation`][Self::orientation].
273        #[deprecated = "Use AVCaptureConnection's videoOrientation instead."]
274        #[unsafe(method(setOrientation:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setOrientation(&self, orientation: AVCaptureVideoOrientation);
277
278        /// Specifies whether or not the preview layer supports mirroring.
279        ///
280        ///
281        /// Mirroring is not supported on all hardware configurations. An application should check the value of
282        /// "
283        /// mirroringSupported" before attempting to manipulate mirroring on the receiver. This property is deprecated. Use AVCaptureConnection's -isVideoMirroringSupported instead.
284        #[deprecated = "Use AVCaptureConnection's isVideoMirroringSupported instead."]
285        #[unsafe(method(isMirroringSupported))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn isMirroringSupported(&self) -> bool;
288
289        /// Specifies whether or not the value of
290        /// "
291        /// mirrored" can change based on configuration of the session.
292        ///
293        ///
294        /// For some session configurations, preview will be mirrored by default. When the value of this property is YES, the value of
295        /// "
296        /// 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.
297        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
298        #[unsafe(method(automaticallyAdjustsMirroring))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn automaticallyAdjustsMirroring(&self) -> bool;
301
302        /// Setter for [`automaticallyAdjustsMirroring`][Self::automaticallyAdjustsMirroring].
303        #[deprecated = "Use AVCaptureConnection's automaticallyAdjustsVideoMirroring instead."]
304        #[unsafe(method(setAutomaticallyAdjustsMirroring:))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn setAutomaticallyAdjustsMirroring(
307            &self,
308            automatically_adjusts_mirroring: bool,
309        );
310
311        /// Specifies whether or not the preview is flipped over a vertical axis.
312        ///
313        ///
314        /// For most applications, it is unnecessary to manipulate preview mirroring manually if
315        /// "
316        /// 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.
317        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
318        #[unsafe(method(isMirrored))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn isMirrored(&self) -> bool;
321
322        /// Setter for [`isMirrored`][Self::isMirrored].
323        #[deprecated = "Use AVCaptureConnection's videoMirrored instead."]
324        #[unsafe(method(setMirrored:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setMirrored(&self, mirrored: bool);
327    );
328}
329
330/// Methods declared on superclass `CALayer`.
331#[cfg(feature = "objc2-quartz-core")]
332#[cfg(not(target_os = "watchos"))]
333impl AVCaptureVideoPreviewLayer {
334    extern_methods!(
335        /// Layer creation and initialization. *
336        #[unsafe(method(layer))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn layer() -> Retained<Self>;
339
340        #[unsafe(method(init))]
341        #[unsafe(method_family = init)]
342        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
343
344        #[unsafe(method(initWithLayer:))]
345        #[unsafe(method_family = init)]
346        pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
347    );
348}
349
350/// Methods declared on superclass `NSObject`.
351#[cfg(feature = "objc2-quartz-core")]
352#[cfg(not(target_os = "watchos"))]
353impl AVCaptureVideoPreviewLayer {
354    extern_methods!(
355        #[unsafe(method(new))]
356        #[unsafe(method_family = new)]
357        pub unsafe fn new() -> Retained<Self>;
358    );
359}