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;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern_class!(
15    /// AVCaptureDataOutputSynchronizer synchronizes the delivery of data from multiple capture data outputs (AVCaptureVideoDataOutput, AVCaptureDepthDataOutput, AVCaptureMetadataOutput, AVCaptureAudioDataOutput) to a single delegate callback.
16    ///
17    ///
18    /// 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.
19    ///
20    /// 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.
21    ///
22    /// 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.
23    ///
24    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedataoutputsynchronizer?language=objc)
25    #[unsafe(super(NSObject))]
26    #[derive(Debug, PartialEq, Eq, Hash)]
27    pub struct AVCaptureDataOutputSynchronizer;
28);
29
30extern_conformance!(
31    unsafe impl NSObjectProtocol for AVCaptureDataOutputSynchronizer {}
32);
33
34impl AVCaptureDataOutputSynchronizer {
35    extern_methods!(
36        #[unsafe(method(init))]
37        #[unsafe(method_family = init)]
38        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
39
40        #[unsafe(method(new))]
41        #[unsafe(method_family = new)]
42        pub unsafe fn new() -> Retained<Self>;
43
44        #[cfg(feature = "AVCaptureOutputBase")]
45        /// Instantiates an AVCaptureDataOutputSynchronizer from one or more capture data outputs.
46        ///
47        ///
48        /// Parameter `dataOutputs`: An array of capture data outputs where the first is the primary output.
49        ///
50        /// Returns: A newly initialized AVCaptureDataOutputSynchronizer instance.
51        #[unsafe(method(initWithDataOutputs:))]
52        #[unsafe(method_family = init)]
53        pub unsafe fn initWithDataOutputs(
54            this: Allocated<Self>,
55            data_outputs: &NSArray<AVCaptureOutput>,
56        ) -> Retained<Self>;
57
58        #[cfg(feature = "AVCaptureOutputBase")]
59        /// The data outputs provided in the initializer method.
60        #[unsafe(method(dataOutputs))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn dataOutputs(&self) -> Retained<NSArray<AVCaptureOutput>>;
63
64        #[cfg(feature = "dispatch2")]
65        /// Sets the receiver's delegate that will accept synchronized data and the dispatch queue on which the delegate will be called.
66        ///
67        ///
68        /// Parameter `delegate`: An object conforming to the AVCaptureDataOutputSynchronizerDelegate protocol that will receive synchronized data from the provided data outputs.
69        ///
70        /// Parameter `delegateCallbackQueue`: A dispatch queue on which all AVCaptureDataOutputSynchronizerDelegate methods will be called.
71        ///
72        ///
73        /// AVCaptureDataOutputSynchronizer gathers data from its dataOutputs, and when it determines that all data has been received for a given timestamp, it calls the specified delegate on the specified delegateCallbackQueue. AVCaptureDataOutputSynchronizer overrides all the data outputs' delegates and callbacks. Data outputs under the control of AVCaptureDataOutputSynchronizer do not fire delegate callbacks. Delegate callbacks are restored to individual data outputs when you call this method with nil as your delegate and NULL as your delegateCallbackQueue.
74        ///
75        /// A serial dispatch queue must be used to guarantee that synchronized data will be delivered in order. The delegateCallbackQueue parameter may not be NULL, except when setting the delegate to nil otherwise -setDelegate:queue: throws an NSInvalidArgumentException.
76        ///
77        /// # Safety
78        ///
79        /// `delegate_callback_queue` possibly has additional threading requirements.
80        #[unsafe(method(setDelegate:queue:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setDelegate_queue(
83            &self,
84            delegate: Option<&ProtocolObject<dyn AVCaptureDataOutputSynchronizerDelegate>>,
85            delegate_callback_queue: Option<&DispatchQueue>,
86        );
87
88        /// The receiver's delegate.
89        ///
90        ///
91        /// 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.
92        #[unsafe(method(delegate))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn delegate(
95            &self,
96        ) -> Option<Retained<ProtocolObject<dyn AVCaptureDataOutputSynchronizerDelegate>>>;
97
98        #[cfg(feature = "dispatch2")]
99        /// The dispatch queue on which all AVCaptureDataOutputSynchronizerDelegate methods will be called.
100        ///
101        ///
102        /// The value of this property is a dispatch_queue_t. The queue is set using the -setDelegate:queue: method.
103        #[unsafe(method(delegateCallbackQueue))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn delegateCallbackQueue(&self) -> Option<Retained<DispatchQueue>>;
106    );
107}
108
109extern_protocol!(
110    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedataoutputsynchronizerdelegate?language=objc)
111    pub unsafe trait AVCaptureDataOutputSynchronizerDelegate: NSObjectProtocol {
112        /// Called when an AVCaptureDataOutputSynchronizer instance outputs synchronized data from one or more data outputs.
113        ///
114        ///
115        /// Parameter `synchronizer`: The AVCaptureDataOutputSynchronizer instance delivering synchronized data.
116        ///
117        /// Parameter `synchronizedDataCollection`: A collection of synchronized data objects indexed by data output.
118        ///
119        ///
120        /// The synchronized data collection only contains synchronized data for capture outputs with synchronized data ready.
121        #[unsafe(method(dataOutputSynchronizer:didOutputSynchronizedDataCollection:))]
122        #[unsafe(method_family = none)]
123        unsafe fn dataOutputSynchronizer_didOutputSynchronizedDataCollection(
124            &self,
125            synchronizer: &AVCaptureDataOutputSynchronizer,
126            synchronized_data_collection: &AVCaptureSynchronizedDataCollection,
127        );
128    }
129);
130
131extern_class!(
132    /// A collection of AVCaptureSynchronizedData objects.
133    ///
134    ///
135    /// 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.
136    ///
137    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddatacollection?language=objc)
138    #[unsafe(super(NSObject))]
139    #[derive(Debug, PartialEq, Eq, Hash)]
140    pub struct AVCaptureSynchronizedDataCollection;
141);
142
143extern_conformance!(
144    unsafe impl NSFastEnumeration for AVCaptureSynchronizedDataCollection {}
145);
146
147extern_conformance!(
148    unsafe impl NSObjectProtocol for AVCaptureSynchronizedDataCollection {}
149);
150
151impl AVCaptureSynchronizedDataCollection {
152    extern_methods!(
153        #[unsafe(method(init))]
154        #[unsafe(method_family = init)]
155        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
156
157        #[unsafe(method(new))]
158        #[unsafe(method_family = new)]
159        pub unsafe fn new() -> Retained<Self>;
160
161        #[cfg(feature = "AVCaptureOutputBase")]
162        /// Provides the synchronized data object for a given capture output.
163        ///
164        ///
165        /// Parameter `captureOutput`: The data output whose synchronized data you'd like to inspect.
166        ///
167        /// Returns: The synchronized data object associated with the provided output, or nil, if there is none.
168        #[unsafe(method(synchronizedDataForCaptureOutput:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn synchronizedDataForCaptureOutput(
171            &self,
172            capture_output: &AVCaptureOutput,
173        ) -> Option<Retained<AVCaptureSynchronizedData>>;
174
175        #[cfg(feature = "AVCaptureOutputBase")]
176        /// Method that provides support for object subscripting.
177        ///
178        ///
179        /// Parameter `key`: The data output whose synchronized data you'd like to inspect.
180        ///
181        /// Returns: The synchronized data object associated with the provided output, or nil, if there is none.
182        ///
183        ///
184        /// AVCaptureSynchronizedDataCollection supports object subscripting. If you'd like to find the synchronized data for a given data output, simply:
185        /// AVCaptureSynchronizedData *synchronizedData = synchronizedDataCollection[dataOutput];
186        #[unsafe(method(objectForKeyedSubscript:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn objectForKeyedSubscript(
189            &self,
190            key: &AVCaptureOutput,
191        ) -> Option<Retained<AVCaptureSynchronizedData>>;
192
193        /// The number of items in the collection.
194        ///
195        ///
196        /// Returns the number of data output / synchronized data pairs present in the collection.
197        #[unsafe(method(count))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn count(&self) -> NSUInteger;
200    );
201}
202
203extern_class!(
204    /// An abstract base class representing the data delivered by a data output through the AVCaptureDataOutputSynchronizer interface.
205    ///
206    ///
207    /// 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.
208    ///
209    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddata?language=objc)
210    #[unsafe(super(NSObject))]
211    #[derive(Debug, PartialEq, Eq, Hash)]
212    pub struct AVCaptureSynchronizedData;
213);
214
215extern_conformance!(
216    unsafe impl NSObjectProtocol for AVCaptureSynchronizedData {}
217);
218
219impl AVCaptureSynchronizedData {
220    extern_methods!(
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
224
225        #[unsafe(method(new))]
226        #[unsafe(method_family = new)]
227        pub unsafe fn new() -> Retained<Self>;
228
229        #[cfg(feature = "objc2-core-media")]
230        /// The time at which this synchronized data was captured.
231        ///
232        ///
233        /// Synchronized data is always clocked to the synchronizationClock of the AVCaptureSession to which the data output is connected.
234        #[unsafe(method(timestamp))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn timestamp(&self) -> CMTime;
237    );
238}
239
240extern_class!(
241    /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureVideoDataOutput or AVCaptureAudioDataOutput.
242    ///
243    ///
244    /// 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.
245    ///
246    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizedsamplebufferdata?language=objc)
247    #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
248    #[derive(Debug, PartialEq, Eq, Hash)]
249    pub struct AVCaptureSynchronizedSampleBufferData;
250);
251
252extern_conformance!(
253    unsafe impl NSObjectProtocol for AVCaptureSynchronizedSampleBufferData {}
254);
255
256impl AVCaptureSynchronizedSampleBufferData {
257    extern_methods!(
258        #[cfg(feature = "objc2-core-media")]
259        /// A sample buffer containing video or audio data.
260        ///
261        ///
262        /// 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.
263        #[unsafe(method(sampleBuffer))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn sampleBuffer(&self) -> Retained<CMSampleBuffer>;
266
267        /// YES if the sample buffer was dropped.
268        ///
269        ///
270        /// AVCaptureVideoDataOutput has a delegate callback for dropped sample buffers. AVCaptureAudioDataOutput does not. Therefore, sampleBufferWasDropped may be YES for video, but never for audio.
271        #[unsafe(method(sampleBufferWasDropped))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn sampleBufferWasDropped(&self) -> bool;
274
275        #[cfg(feature = "AVCaptureOutputBase")]
276        /// If sampleBufferWasDropped is YES, the reason for the drop, otherwise AVCaptureOutputDataDroppedReasonNone.
277        ///
278        ///
279        /// AVCaptureOutputDataDroppedReasons are defined in AVCaptureOutputBase.h.
280        #[unsafe(method(droppedReason))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn droppedReason(&self) -> AVCaptureOutputDataDroppedReason;
283    );
284}
285
286/// Methods declared on superclass `AVCaptureSynchronizedData`.
287impl AVCaptureSynchronizedSampleBufferData {
288    extern_methods!(
289        #[unsafe(method(init))]
290        #[unsafe(method_family = init)]
291        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
292
293        #[unsafe(method(new))]
294        #[unsafe(method_family = new)]
295        pub unsafe fn new() -> Retained<Self>;
296    );
297}
298
299extern_class!(
300    /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureMetadataOutput.
301    ///
302    ///
303    /// 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.
304    ///
305    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizedmetadataobjectdata?language=objc)
306    #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
307    #[derive(Debug, PartialEq, Eq, Hash)]
308    pub struct AVCaptureSynchronizedMetadataObjectData;
309);
310
311extern_conformance!(
312    unsafe impl NSObjectProtocol for AVCaptureSynchronizedMetadataObjectData {}
313);
314
315impl AVCaptureSynchronizedMetadataObjectData {
316    extern_methods!(
317        #[cfg(feature = "AVMetadataObject")]
318        /// An array of AVMetadataObject subclasses.
319        ///
320        ///
321        /// -metadataObjects is never nil. If no metadata objects are present for a given time, an empty array is returned.
322        #[unsafe(method(metadataObjects))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn metadataObjects(&self) -> Retained<NSArray<AVMetadataObject>>;
325    );
326}
327
328/// Methods declared on superclass `AVCaptureSynchronizedData`.
329impl AVCaptureSynchronizedMetadataObjectData {
330    extern_methods!(
331        #[unsafe(method(init))]
332        #[unsafe(method_family = init)]
333        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
334
335        #[unsafe(method(new))]
336        #[unsafe(method_family = new)]
337        pub unsafe fn new() -> Retained<Self>;
338    );
339}
340
341extern_class!(
342    /// An concrete subclass of AVCaptureSynchronizedData representing the data delivered by an AVCaptureDepthDataOutput.
343    ///
344    ///
345    /// Depth data, like video, may be dropped if not serviced in a timely fashion.
346    ///
347    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturesynchronizeddepthdata?language=objc)
348    #[unsafe(super(AVCaptureSynchronizedData, NSObject))]
349    #[derive(Debug, PartialEq, Eq, Hash)]
350    pub struct AVCaptureSynchronizedDepthData;
351);
352
353extern_conformance!(
354    unsafe impl NSObjectProtocol for AVCaptureSynchronizedDepthData {}
355);
356
357impl AVCaptureSynchronizedDepthData {
358    extern_methods!(
359        #[cfg(feature = "AVDepthData")]
360        /// An instance of AVDepthData.
361        ///
362        ///
363        /// 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.
364        #[unsafe(method(depthData))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn depthData(&self) -> Retained<AVDepthData>;
367
368        /// YES if the depth data was dropped.
369        ///
370        ///
371        /// If YES, inspect -droppedReason for the reason.
372        #[unsafe(method(depthDataWasDropped))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn depthDataWasDropped(&self) -> bool;
375
376        #[cfg(feature = "AVCaptureOutputBase")]
377        /// If depthDataWasDropped is YES, the reason for the drop, otherwise AVCaptureOutputDataDroppedReasonNone.
378        ///
379        ///
380        /// AVCaptureOutputDataDroppedReasons are defined in AVCaptureOutputBase.h.
381        #[unsafe(method(droppedReason))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn droppedReason(&self) -> AVCaptureOutputDataDroppedReason;
384    );
385}
386
387/// Methods declared on superclass `AVCaptureSynchronizedData`.
388impl AVCaptureSynchronizedDepthData {
389    extern_methods!(
390        #[unsafe(method(init))]
391        #[unsafe(method_family = init)]
392        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
393
394        #[unsafe(method(new))]
395        #[unsafe(method_family = new)]
396        pub unsafe fn new() -> Retained<Self>;
397    );
398}