objc2_av_foundation/generated/AVCaptureDataOutputSynchronizer.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-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// AVCaptureDataOutputSynchronizer synchronizes the delivery of data from multiple capture data outputs (AVCaptureVideoDataOutput, AVCaptureDepthDataOutput, AVCaptureMetadataOutput, AVCaptureAudioDataOutput) to a single delegate callback.
14 ///
15 ///
16 /// AVCaptureDataOutputSynchronizer is initialized with an array of data outputs (AVCaptureVideoDataOutput, AVCaptureDepthDataOutput, AVCaptureMetadataOutput, or AVCaptureAudioDataOutput) from which you'd like to receive a single, synchronized delegate callback. The first output in the array acts as the primary data output and determines when the synchronized callback is delivered. When data is received for the primary data output, it is held until all other data outputs have received data with an equal or later presentation time stamp, or it has been determined that there is no data for a particular output at the primary data output's pts. Once all other outputs are ready, a single delegate callback is sent with all the data aligned with the primary data output's data. Separate delegate callbacks are sent for any other data received with presentation time stamps earlier than the next primary data output time.
17 ///
18 /// For instance, if you specify a video data output as your first (primary) output and a metadata output for detected faces as your second output, your data callback will not be called until there is face data ready for a video frame, or it is assured that there is no face metadata for that particular video frame.
19 ///
20 /// Note that the AVCaptureDataOutputSynchronizer overrides each data output's -setSampleBufferDelegate:queue:, -setDepthDataDelegate:queue:, or -setMetadataObjectsDelegate:queue: method call. -[AVCaptureVideoDataOutput alwaysDiscardsLateVideoFrames] and -[AVCaptureDepthDataOutput alwaysDiscardsLateDepthData] properties are honored.
21 ///
22 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedataoutputsynchronizer?language=objc)
23 #[unsafe(super(NSObject))]
24 #[derive(Debug, PartialEq, Eq, Hash)]
25 pub struct AVCaptureDataOutputSynchronizer;
26);
27
28unsafe impl NSObjectProtocol for AVCaptureDataOutputSynchronizer {}
29
30impl AVCaptureDataOutputSynchronizer {
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 #[cfg(feature = "AVCaptureOutputBase")]
41 /// Instantiates an AVCaptureDataOutputSynchronizer from one or more capture data outputs.
42 ///
43 ///
44 /// Parameter `dataOutputs`: An array of capture data outputs where the first is the primary output.
45 ///
46 /// Returns: A newly initialized AVCaptureDataOutputSynchronizer instance.
47 #[unsafe(method(initWithDataOutputs:))]
48 #[unsafe(method_family = init)]
49 pub unsafe fn initWithDataOutputs(
50 this: Allocated<Self>,
51 data_outputs: &NSArray<AVCaptureOutput>,
52 ) -> Retained<Self>;
53
54 #[cfg(feature = "AVCaptureOutputBase")]
55 /// The data outputs provided in the initializer method.
56 #[unsafe(method(dataOutputs))]
57 #[unsafe(method_family = none)]
58 pub unsafe fn dataOutputs(&self) -> Retained<NSArray<AVCaptureOutput>>;
59
60 /// The receiver's delegate.
61 ///
62 ///
63 /// The value of this property is an object conforming to the AVCaptureDataOutputSynchronizerDelegate protocol that will receive synchronized data output. The delegate is set using the -setDelegate:queue: method. This property is key-value observable.
64 #[unsafe(method(delegate))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn delegate(
67 &self,
68 ) -> Option<Retained<ProtocolObject<dyn AVCaptureDataOutputSynchronizerDelegate>>>;
69 );
70}
71
72extern_protocol!(
73 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedataoutputsynchronizerdelegate?language=objc)
74 pub unsafe trait AVCaptureDataOutputSynchronizerDelegate: NSObjectProtocol {
75 /// Called when an AVCaptureDataOutputSynchronizer instance outputs synchronized data from one or more data outputs.
76 ///
77 ///
78 /// Parameter `synchronizer`: The AVCaptureDataOutputSynchronizer instance delivering synchronized data.
79 ///
80 /// Parameter `synchronizedDataCollection`: A collection of synchronized data objects indexed by data output.
81 ///
82 ///
83 /// The synchronized data collection only contains synchronized data for capture outputs with synchronized data ready.
84 #[unsafe(method(dataOutputSynchronizer:didOutputSynchronizedDataCollection:))]
85 #[unsafe(method_family = none)]
86 unsafe fn dataOutputSynchronizer_didOutputSynchronizedDataCollection(
87 &self,
88 synchronizer: &AVCaptureDataOutputSynchronizer,
89 synchronized_data_collection: &AVCaptureSynchronizedDataCollection,
90 );
91 }
92);
93
94extern_class!(
95 /// A collection of AVCaptureSynchronizedData objects.
96 ///
97 ///
98 /// AVCaptureDataOutputSynchronizer's -dataOutputSynchronizer:didOutputSynchronizedDataCollection: delegate method delivers a collection of AVCaptureSynchronizedData objects which can be iterated by AVCaptureOutput. AVCaptureSynchronizedDataCollection supports object subscripting and fast enumeration of the data outputs as keys.
99 ///
100 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddatacollection?language=objc)
101 #[unsafe(super(NSObject))]
102 #[derive(Debug, PartialEq, Eq, Hash)]
103 pub struct AVCaptureSynchronizedDataCollection;
104);
105
106unsafe impl NSFastEnumeration for AVCaptureSynchronizedDataCollection {}
107
108unsafe impl NSObjectProtocol for AVCaptureSynchronizedDataCollection {}
109
110impl AVCaptureSynchronizedDataCollection {
111 extern_methods!(
112 #[unsafe(method(init))]
113 #[unsafe(method_family = init)]
114 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
115
116 #[unsafe(method(new))]
117 #[unsafe(method_family = new)]
118 pub unsafe fn new() -> Retained<Self>;
119
120 #[cfg(feature = "AVCaptureOutputBase")]
121 /// Provides the synchronized data object for a given capture output.
122 ///
123 ///
124 /// Parameter `captureOutput`: The data output whose synchronized data you'd like to inspect.
125 ///
126 /// Returns: The synchronized data object associated with the provided output, or nil, if there is none.
127 #[unsafe(method(synchronizedDataForCaptureOutput:))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn synchronizedDataForCaptureOutput(
130 &self,
131 capture_output: &AVCaptureOutput,
132 ) -> Option<Retained<AVCaptureSynchronizedData>>;
133
134 #[cfg(feature = "AVCaptureOutputBase")]
135 /// Method that provides support for object subscripting.
136 ///
137 ///
138 /// Parameter `key`: The data output whose synchronized data you'd like to inspect.
139 ///
140 /// Returns: The synchronized data object associated with the provided output, or nil, if there is none.
141 ///
142 ///
143 /// AVCaptureSynchronizedDataCollection supports object subscripting. If you'd like to find the synchronized data for a given data output, simply:
144 /// AVCaptureSynchronizedData *synchronizedData = synchronizedDataCollection[dataOutput];
145 #[unsafe(method(objectForKeyedSubscript:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn objectForKeyedSubscript(
148 &self,
149 key: &AVCaptureOutput,
150 ) -> Option<Retained<AVCaptureSynchronizedData>>;
151
152 /// The number of items in the collection.
153 ///
154 ///
155 /// Returns the number of data output / synchronized data pairs present in the collection.
156 #[unsafe(method(count))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn count(&self) -> NSUInteger;
159 );
160}
161
162extern_class!(
163 /// An abstract base class representing the data delivered by a data output through the AVCaptureDataOutputSynchronizer interface.
164 ///
165 ///
166 /// AVCaptureDataOutputSynchronizer's -dataOutputSynchronizer:didOutputSynchronizedData: delegate callback delivers a dictionary of key/value pairs, with the keys being the AVCaptureOutput instances returning data, and the values being concrete subclasses of AVCaptureSynchronizedData.
167 ///
168 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddata?language=objc)
169 #[unsafe(super(NSObject))]
170 #[derive(Debug, PartialEq, Eq, Hash)]
171 pub struct AVCaptureSynchronizedData;
172);
173
174unsafe impl NSObjectProtocol for AVCaptureSynchronizedData {}
175
176impl AVCaptureSynchronizedData {
177 extern_methods!(
178 #[unsafe(method(init))]
179 #[unsafe(method_family = init)]
180 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
181
182 #[unsafe(method(new))]
183 #[unsafe(method_family = new)]
184 pub unsafe fn new() -> Retained<Self>;
185
186 #[cfg(feature = "objc2-core-media")]
187 /// The time at which this synchronized data was captured.
188 ///
189 ///
190 /// Synchronized data is always clocked to the synchronizationClock of the AVCaptureSession to which the data output is connected.
191 #[unsafe(method(timestamp))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn timestamp(&self) -> CMTime;
194 );
195}
196
197extern_class!(
198 /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureVideoDataOutput or AVCaptureAudioDataOutput.
199 ///
200 ///
201 /// Synchronized sample buffer data is valid for the duration of AVCaptureDataOutputSynchronizer's -dataOutputSynchronizer:didOutputSynchronizedData: delegate callback. To extend the sample buffer data beyond the callback, you must CFRetain it, and later call CFRelease when you're done with it.
202 ///
203 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizedsamplebufferdata?language=objc)
204 #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
205 #[derive(Debug, PartialEq, Eq, Hash)]
206 pub struct AVCaptureSynchronizedSampleBufferData;
207);
208
209unsafe impl NSObjectProtocol for AVCaptureSynchronizedSampleBufferData {}
210
211impl AVCaptureSynchronizedSampleBufferData {
212 extern_methods!(
213 #[cfg(feature = "objc2-core-media")]
214 /// A sample buffer containing video or audio data.
215 ///
216 ///
217 /// If sampleBufferWasDropped is YES, the returned sampleBuffer was dropped before it could be delivered to you, and thus this sample buffer is a shell containing metadata and format information, but no actual pixel data. This property is never NULL. If a data output has no data to return, it is simply not present in the dictionary of synchronized data returned by AVCaptureDataOutputSynchronizer's -dataOutputSynchronizer:didOutputSynchronizedData: delegate callback.
218 #[unsafe(method(sampleBuffer))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn sampleBuffer(&self) -> Retained<CMSampleBuffer>;
221
222 /// YES if the sample buffer was dropped.
223 ///
224 ///
225 /// AVCaptureVideoDataOutput has a delegate callback for dropped sample buffers. AVCaptureAudioDataOutput does not. Therefore, sampleBufferWasDropped may be YES for video, but never for audio.
226 #[unsafe(method(sampleBufferWasDropped))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn sampleBufferWasDropped(&self) -> bool;
229
230 #[cfg(feature = "AVCaptureOutputBase")]
231 /// If sampleBufferWasDropped is YES, the reason for the drop, otherwise AVCaptureOutputDataDroppedReasonNone.
232 ///
233 ///
234 /// AVCaptureOutputDataDroppedReasons are defined in AVCaptureOutputBase.h.
235 #[unsafe(method(droppedReason))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn droppedReason(&self) -> AVCaptureOutputDataDroppedReason;
238 );
239}
240
241/// Methods declared on superclass `AVCaptureSynchronizedData`.
242impl AVCaptureSynchronizedSampleBufferData {
243 extern_methods!(
244 #[unsafe(method(init))]
245 #[unsafe(method_family = init)]
246 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
247
248 #[unsafe(method(new))]
249 #[unsafe(method_family = new)]
250 pub unsafe fn new() -> Retained<Self>;
251 );
252}
253
254extern_class!(
255 /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureMetadataOutput.
256 ///
257 ///
258 /// A single AVCaptureMetadataOutput may be configured to deliver multiple kinds of metadata objects (such as QRCodes and detected faces). AVCaptureSynchronizedMetadataObjectData's -metadataObjects array may contain multiple AVMetadataObject subclasses, depending on how the AVCaptureMetadataOutput was configured. All synchronized metadata objects share a common timestamp.
259 ///
260 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizedmetadataobjectdata?language=objc)
261 #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
262 #[derive(Debug, PartialEq, Eq, Hash)]
263 pub struct AVCaptureSynchronizedMetadataObjectData;
264);
265
266unsafe impl NSObjectProtocol for AVCaptureSynchronizedMetadataObjectData {}
267
268impl AVCaptureSynchronizedMetadataObjectData {
269 extern_methods!(
270 #[cfg(feature = "AVMetadataObject")]
271 /// An array of AVMetadataObject subclasses.
272 ///
273 ///
274 /// -metadataObjects is never nil. If no metadata objects are present for a given time, an empty array is returned.
275 #[unsafe(method(metadataObjects))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn metadataObjects(&self) -> Retained<NSArray<AVMetadataObject>>;
278 );
279}
280
281/// Methods declared on superclass `AVCaptureSynchronizedData`.
282impl AVCaptureSynchronizedMetadataObjectData {
283 extern_methods!(
284 #[unsafe(method(init))]
285 #[unsafe(method_family = init)]
286 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
287
288 #[unsafe(method(new))]
289 #[unsafe(method_family = new)]
290 pub unsafe fn new() -> Retained<Self>;
291 );
292}
293
294extern_class!(
295 /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureDepthDataOutput.
296 ///
297 ///
298 /// Depth data, like video, may be dropped if not serviced in a timely fashion.
299 ///
300 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddepthdata?language=objc)
301 #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
302 #[derive(Debug, PartialEq, Eq, Hash)]
303 pub struct AVCaptureSynchronizedDepthData;
304);
305
306unsafe impl NSObjectProtocol for AVCaptureSynchronizedDepthData {}
307
308impl AVCaptureSynchronizedDepthData {
309 extern_methods!(
310 #[cfg(feature = "AVDepthData")]
311 /// An instance of AVDepthData.
312 ///
313 ///
314 /// If depthDataWasDropped is YES, the returned depthData was dropped before it could be delivered to you, and thus this AVDepthData is a shell containing format information and calibration data, but no actual pixel map data. This property is never nil. If a data output has no data to return, it is simply not present in the dictionary of synchronized data returned by AVCaptureDataOutputSynchronizer's -dataOutputSynchronizer:didOutputSynchronizedData: delegate callback.
315 #[unsafe(method(depthData))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn depthData(&self) -> Retained<AVDepthData>;
318
319 /// YES if the depth data was dropped.
320 ///
321 ///
322 /// If YES, inspect -droppedReason for the reason.
323 #[unsafe(method(depthDataWasDropped))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn depthDataWasDropped(&self) -> bool;
326
327 #[cfg(feature = "AVCaptureOutputBase")]
328 /// If depthDataWasDropped is YES, the reason for the drop, otherwise AVCaptureOutputDataDroppedReasonNone.
329 ///
330 ///
331 /// AVCaptureOutputDataDroppedReasons are defined in AVCaptureOutputBase.h.
332 #[unsafe(method(droppedReason))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn droppedReason(&self) -> AVCaptureOutputDataDroppedReason;
335 );
336}
337
338/// Methods declared on superclass `AVCaptureSynchronizedData`.
339impl AVCaptureSynchronizedDepthData {
340 extern_methods!(
341 #[unsafe(method(init))]
342 #[unsafe(method_family = init)]
343 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
344
345 #[unsafe(method(new))]
346 #[unsafe(method_family = new)]
347 pub unsafe fn new() -> Retained<Self>;
348 );
349}