objc2_av_foundation/generated/AVCaptureOutputBase.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
10use crate::*;
11
12extern_class!(
13 /// AVCaptureOutput is an abstract class that defines an interface for an output destination of an AVCaptureSession.
14 ///
15 ///
16 /// AVCaptureOutput provides an abstract interface for connecting capture output destinations, such as files and video previews, to an AVCaptureSession.
17 ///
18 /// An AVCaptureOutput can have multiple connections represented by AVCaptureConnection objects, one for each stream of media that it receives from an AVCaptureInput. An AVCaptureOutput does not have any connections when it is first created. When an output is added to an AVCaptureSession, connections are created that map media data from that session's inputs to its outputs.
19 ///
20 /// Concrete AVCaptureOutput instances can be added to an AVCaptureSession using the -[AVCaptureSession addOutput:] and -[AVCaptureSession addOutputWithNoConnections:] methods.
21 ///
22 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureoutput?language=objc)
23 #[unsafe(super(NSObject))]
24 #[derive(Debug, PartialEq, Eq, Hash)]
25 pub struct AVCaptureOutput;
26);
27
28extern_conformance!(
29 unsafe impl NSObjectProtocol for AVCaptureOutput {}
30);
31
32impl AVCaptureOutput {
33 extern_methods!(
34 #[unsafe(method(init))]
35 #[unsafe(method_family = init)]
36 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
37
38 #[unsafe(method(new))]
39 #[unsafe(method_family = new)]
40 pub unsafe fn new() -> Retained<Self>;
41
42 #[cfg(feature = "AVCaptureSession")]
43 /// The connections that describe the flow of media data to the receiver from AVCaptureInputs.
44 ///
45 ///
46 /// The value of this property is an NSArray of AVCaptureConnection objects, each describing the mapping between the receiver and the AVCaptureInputPorts of one or more AVCaptureInputs.
47 #[unsafe(method(connections))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn connections(&self) -> Retained<NSArray<AVCaptureConnection>>;
50
51 #[cfg(all(feature = "AVCaptureSession", feature = "AVMediaFormat"))]
52 /// Returns the first connection in the connections array with an inputPort of the specified mediaType.
53 ///
54 ///
55 /// Parameter `mediaType`: An AVMediaType constant from AVMediaFormat.h, e.g. AVMediaTypeVideo.
56 ///
57 ///
58 /// This convenience method returns the first AVCaptureConnection in the receiver's connections array that has an AVCaptureInputPort of the specified mediaType. If no connection with the specified mediaType is found, nil is returned.
59 #[unsafe(method(connectionWithMediaType:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn connectionWithMediaType(
62 &self,
63 media_type: &AVMediaType,
64 ) -> Option<Retained<AVCaptureConnection>>;
65
66 #[cfg(all(feature = "AVCaptureSession", feature = "AVMetadataObject"))]
67 /// Converts an AVMetadataObject's visual properties to the receiver's coordinates.
68 ///
69 ///
70 /// Parameter `metadataObject`: An AVMetadataObject originating from the same AVCaptureInput as the receiver.
71 ///
72 /// Parameter `connection`: The receiver's connection whose AVCaptureInput matches that of the metadata object to be converted.
73 ///
74 /// Returns: An AVMetadataObject whose properties are in output coordinates.
75 ///
76 ///
77 /// 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:connection: converts the visual properties in the coordinate space of the supplied AVMetadataObject to the coordinate space of the receiver. The conversion takes orientation, mirroring, and scaling into consideration. If the provided metadata object originates from an input source other than the preview layer's, nil will be returned.
78 ///
79 /// If an AVCaptureVideoDataOutput instance's connection's videoOrientation or videoMirrored properties are set to non-default values, the output applies the desired mirroring and orientation by physically rotating and or flipping sample buffers as they pass through it. AVCaptureStillImageOutput, on the other hand, does not physically rotate its buffers. It attaches an appropriate kCGImagePropertyOrientation number to captured still image buffers (see ImageIO/CGImageProperties.h) indicating how the image should be displayed on playback. Likewise, AVCaptureMovieFileOutput does not physically apply orientation/mirroring to its sample buffers -- it uses a QuickTime track matrix to indicate how the buffers should be rotated and/or flipped on playback.
80 ///
81 /// transformedMetadataObjectForMetadataObject:connection: alters the visual properties of the provided metadata object to match the physical rotation / mirroring of the sample buffers provided by the receiver through the indicated connection. I.e., for video data output, adjusted metadata object coordinates are rotated/mirrored. For still image and movie file output, they are not.
82 #[unsafe(method(transformedMetadataObjectForMetadataObject:connection:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn transformedMetadataObjectForMetadataObject_connection(
85 &self,
86 metadata_object: &AVMetadataObject,
87 connection: &AVCaptureConnection,
88 ) -> Option<Retained<AVMetadataObject>>;
89
90 #[cfg(feature = "objc2-core-foundation")]
91 /// Converts a rectangle in the receiver's coordinate space to a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the receiver.
92 ///
93 ///
94 /// Parameter `rectInOutputCoordinates`: A CGRect in the receiver's coordinates.
95 ///
96 /// Returns: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the receiver.
97 ///
98 ///
99 /// 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 orientation, mirroring, and scaling into consideration. See -transformedMetadataObjectForMetadataObject:connection: for a full discussion of how orientation and mirroring are applied to sample buffers passing through the output.
100 #[unsafe(method(metadataOutputRectOfInterestForRect:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn metadataOutputRectOfInterestForRect(
103 &self,
104 rect_in_output_coordinates: CGRect,
105 ) -> CGRect;
106
107 #[cfg(feature = "objc2-core-foundation")]
108 /// Converts a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the receiver to a rectangle in the receiver's coordinates.
109 ///
110 ///
111 /// Parameter `rectInMetadataOutputCoordinates`: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the receiver.
112 ///
113 /// Returns: A CGRect in the receiver's coordinates.
114 ///
115 ///
116 /// 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 orientation, mirroring, and scaling into consideration. See -transformedMetadataObjectForMetadataObject:connection: for a full discussion of how orientation and mirroring are applied to sample buffers passing through the output.
117 #[unsafe(method(rectForMetadataOutputRectOfInterest:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn rectForMetadataOutputRectOfInterest(
120 &self,
121 rect_in_metadata_output_coordinates: CGRect,
122 ) -> CGRect;
123
124 /// A `BOOL` value that indicates whether the output supports deferred start.
125 ///
126 /// You can only set the ``deferredStartEnabled`` property value to `true` if the output supports deferred start.
127 #[unsafe(method(isDeferredStartSupported))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn isDeferredStartSupported(&self) -> bool;
130
131 /// A `BOOL` value that indicates whether to defer starting this capture output.
132 ///
133 /// 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` for outputs that your app needs for startup, and `true` for the ones it does not need to start immediately. For example, an ``AVCaptureVideoDataOutput`` that you intend to use for displaying preview should set this value to `false`, so that the frames are available as soon as possible.
134 ///
135 /// By default, for apps that are linked on or after iOS 26, this property value is `true` for ``AVCapturePhotoOutput`` and ``AVCaptureFileOutput`` subclasses if supported, and `false` otherwise. When set to `true` for ``AVCapturePhotoOutput``, if you want to support multiple capture requests before running deferred start, set ``AVCapturePhotoOutput/responsiveCaptureEnabled`` to `true` on that output.
136 ///
137 /// If ``deferredStartSupported`` is `false`, setting this property value to `true` results in the system throwing an `NSInvalidArgumentException`.
138 ///
139 /// - Note: Set this value before calling ``AVCaptureSession/commitConfiguration`` as it requires a lengthy reconfiguration of the capture render pipeline.
140 #[unsafe(method(isDeferredStartEnabled))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn isDeferredStartEnabled(&self) -> bool;
143
144 /// Setter for [`isDeferredStartEnabled`][Self::isDeferredStartEnabled].
145 #[unsafe(method(setDeferredStartEnabled:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setDeferredStartEnabled(&self, deferred_start_enabled: bool);
148 );
149}
150
151/// Constants indicating the reason a capture data output dropped data.
152///
153///
154/// No data was dropped.
155///
156/// Data was dropped because alwaysDiscardsLate{VideoFrames | DepthData} is YES and the client was still processing previous data when the current data needed to be delivered.
157///
158/// Data was dropped because its pool of buffers ran dry. This is usually indicative that the client is holding onto data objects too long.
159///
160/// Data was dropped because the device providing the data experienced a discontinuity, and an unknown number of data objects have been lost. This condition is typically caused by the system being too busy.
161///
162/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureoutputdatadroppedreason?language=objc)
163// NS_ENUM
164#[repr(transparent)]
165#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
166pub struct AVCaptureOutputDataDroppedReason(pub NSInteger);
167impl AVCaptureOutputDataDroppedReason {
168 #[doc(alias = "AVCaptureOutputDataDroppedReasonNone")]
169 pub const None: Self = Self(0);
170 #[doc(alias = "AVCaptureOutputDataDroppedReasonLateData")]
171 pub const LateData: Self = Self(1);
172 #[doc(alias = "AVCaptureOutputDataDroppedReasonOutOfBuffers")]
173 pub const OutOfBuffers: Self = Self(2);
174 #[doc(alias = "AVCaptureOutputDataDroppedReasonDiscontinuity")]
175 pub const Discontinuity: Self = Self(3);
176}
177
178unsafe impl Encode for AVCaptureOutputDataDroppedReason {
179 const ENCODING: Encoding = NSInteger::ENCODING;
180}
181
182unsafe impl RefEncode for AVCaptureOutputDataDroppedReason {
183 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
184}