objc2_av_foundation/generated/
AVCaptureDepthDataOutput.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::*;
10
11use crate::*;
12
13extern_class!(
14    /// AVCaptureDepthDataOutput is a concrete subclass of AVCaptureOutput that can be used to process depth data in a streaming fashion.
15    ///
16    ///
17    /// Instances of AVCaptureDepthDataOutput capture AVDepthData objects expressing disparity/depth. Applications can access the frames with the depthDataOutput:didOutputDepthData:fromConnection: delegate method.
18    ///
19    /// AVCaptureDepthDataOutput always provides depth data in the format expressed by its source's -[AVCaptureDevice activeDepthDataFormat] property. If you wish to receive depth data in another format, you may choose from the -[AVCaptureDevice activeFormat]'s -[AVCaptureDeviceFormat supportedDepthDataFormats], and set it using -[AVCaptureDevice setActiveDepthDataFormat:].
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedepthdataoutput?language=objc)
22    #[unsafe(super(AVCaptureOutput, NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    #[cfg(feature = "AVCaptureOutputBase")]
25    pub struct AVCaptureDepthDataOutput;
26);
27
28#[cfg(feature = "AVCaptureOutputBase")]
29extern_conformance!(
30    unsafe impl NSObjectProtocol for AVCaptureDepthDataOutput {}
31);
32
33#[cfg(feature = "AVCaptureOutputBase")]
34impl AVCaptureDepthDataOutput {
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 = "dispatch2")]
45        /// Sets the receiver's delegate that receives captured depth data and the dispatch queue on which the delegate is called.
46        ///
47        ///
48        /// Parameter `delegate`: An object conforming to the AVCaptureDepthDataOutputDelegate protocol that receives depth data in a streaming fashion.
49        ///
50        /// Parameter `callbackQueue`: A dispatch queue on which all delegate methods are called.
51        ///
52        ///
53        /// The depth data output vends captured depth data to its delegate using the methods specified in the AVCaptureDepthOutputDelegate protocol. All delegate methods are called on the specified dispatch queue. If the callback queue is blocked when new depth data is captured, that depth data is automatically dropped at a time determined by the value of the alwaysDiscardsLateDepthData property. This allows clients to process existing depth data on the same queue without having to manage the potential memory usage increases that would otherwise occur when that processing is unable to keep up with the rate of incoming depth data.
54        ///
55        /// Clients who need to minimize the chances of depth data being dropped should provide a dedicated queue and not share it with other data outputs. Processing of depth data may be deferred to another queue, but beware that the depth data pixel buffer maps may come from a finite buffer pool, which may be starved if your deferred processing fails to keep up.
56        ///
57        /// A serial dispatch queue must be used to guarantee that depth data will be delivered in order. The callbackQueue parameter may not be NULL, except when setting the delegate to nil otherwise -setDelegate:callbackQueue: throws an NSInvalidArgumentException.
58        ///
59        /// # Safety
60        ///
61        /// `callback_queue` possibly has additional threading requirements.
62        #[unsafe(method(setDelegate:callbackQueue:))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn setDelegate_callbackQueue(
65            &self,
66            delegate: Option<&ProtocolObject<dyn AVCaptureDepthDataOutputDelegate>>,
67            callback_queue: Option<&DispatchQueue>,
68        );
69
70        /// The receiver's delegate.
71        ///
72        ///
73        /// The value of this property is an object conforming to the AVCaptureDepthDataOutputDelegate protocol that receives depth data as it is captured. The delegate is set using the setDelegate:callbackQueue: method.
74        #[unsafe(method(delegate))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn delegate(
77            &self,
78        ) -> Option<Retained<ProtocolObject<dyn AVCaptureDepthDataOutputDelegate>>>;
79
80        #[cfg(feature = "dispatch2")]
81        /// The dispatch queue on which all delegate methods are called.
82        ///
83        ///
84        /// The value of this property is a dispatch_queue_t. The queue is set using the setDelegate:queue: method.
85        #[unsafe(method(delegateCallbackQueue))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn delegateCallbackQueue(&self) -> Option<Retained<DispatchQueue>>;
88
89        /// Specifies whether the receiver should always discard any depth data that is not processed before the next depth data is captured.
90        ///
91        ///
92        /// When the value of this property is YES, the receiver will immediately discard depth data that are captured while the delegateCallbackQueue is blocked. When the value of this property is NO, delegates will be allowed more time to process old depth data before new depth data are discarded, but application memory usage may increase as a result. The default value is YES.
93        #[unsafe(method(alwaysDiscardsLateDepthData))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn alwaysDiscardsLateDepthData(&self) -> bool;
96
97        /// Setter for [`alwaysDiscardsLateDepthData`][Self::alwaysDiscardsLateDepthData].
98        #[unsafe(method(setAlwaysDiscardsLateDepthData:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setAlwaysDiscardsLateDepthData(&self, always_discards_late_depth_data: bool);
101
102        /// Specifies whether the depth data output should filter depth data to smooth out noise and fill invalid values.
103        ///
104        ///
105        /// When the value of this property is YES, the receiver temporally filters the stream of AVDepthData objects to reduce noise, as well as fill invalid values. Invalid values (NaN) may be present in AVDepthData pixel buffer maps due to factors such as low light or lens occlusion. When filtering is enabled, the depth data output interpolates missing depth data values. Filtering should be disabled if you desire the raw depth data values. The default value is YES.
106        #[unsafe(method(isFilteringEnabled))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn isFilteringEnabled(&self) -> bool;
109
110        /// Setter for [`isFilteringEnabled`][Self::isFilteringEnabled].
111        #[unsafe(method(setFilteringEnabled:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setFilteringEnabled(&self, filtering_enabled: bool);
114    );
115}
116
117extern_protocol!(
118    /// Defines an interface for delegates of AVCaptureDepthDataOutput to receive captured depth data and be notified of late depth data that were dropped.
119    ///
120    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcapturedepthdataoutputdelegate?language=objc)
121    pub unsafe trait AVCaptureDepthDataOutputDelegate: NSObjectProtocol {
122        #[cfg(all(
123            feature = "AVCaptureOutputBase",
124            feature = "AVCaptureSession",
125            feature = "AVDepthData",
126            feature = "objc2-core-media"
127        ))]
128        /// Called whenever an AVCaptureDepthDataOutput instance outputs a new depth data object.
129        ///
130        ///
131        /// Parameter `output`: The AVCaptureDepthDataOutput instance vending the depth data.
132        ///
133        /// Parameter `depthData`: An AVDepthData object containing the depth/disparity data.
134        ///
135        /// Parameter `timestamp`: A CMTime indicating when the depth data was captured.
136        ///
137        /// Parameter `connection`: The AVCaptureConnection through which the depth data is received.
138        ///
139        ///
140        /// The delegate receives this message whenever the depth data output captures and outputs a new depth data object. This method is called on the dispatch queue specified by the output's delegateCallbackQueue property. This method is called frequently. Care must be taken to process the depth data quickly in order to prevent dropped depth data.
141        ///
142        /// Clients that need to reference the AVDepthData object outside of the scope of this method must retain it and then release it when they are finished with it (in a MRR app).
143        ///
144        /// Note that to maintain optimal performance, AVDepthData pixel buffer maps may be backed by a finite memory pool. If AVDepthData objects are held onto for too long, capture inputs will no longer be able to copy new depth data into memory, resulting in droppage. If your application is causing depth data drops by holding on to provided depth data objects for too long, consider copying the pixel buffer map data into a new pixel buffer so that the AVDepthData backing memory can be reused more quickly.
145        #[optional]
146        #[unsafe(method(depthDataOutput:didOutputDepthData:timestamp:connection:))]
147        #[unsafe(method_family = none)]
148        unsafe fn depthDataOutput_didOutputDepthData_timestamp_connection(
149            &self,
150            output: &AVCaptureDepthDataOutput,
151            depth_data: &AVDepthData,
152            timestamp: CMTime,
153            connection: &AVCaptureConnection,
154        );
155
156        #[cfg(all(
157            feature = "AVCaptureOutputBase",
158            feature = "AVCaptureSession",
159            feature = "AVDepthData",
160            feature = "objc2-core-media"
161        ))]
162        /// Called once for each depth data that is discarded.
163        ///
164        ///
165        /// Parameter `output`: The AVCaptureDepthDataOutput instance that dropped the depth data.
166        ///
167        /// Parameter `depthData`: A depth data object containing information about the dropped depth, such as its native depth type. This depth data object produces nil CVPixelBuffers for depth / disparity as it has no backing depth map.
168        ///
169        /// Parameter `timestamp`: A CMTime indicating when the depth data was captured.
170        ///
171        /// Parameter `connection`: The AVCaptureConnection from which the dropped depth data object was received.
172        ///
173        /// Parameter `reason`: The reason the depth data object was dropped.
174        ///
175        ///
176        /// Delegates receive this message whenever a depth data object is dropped. This method is called once for each dropped depth data. The object passed to this delegate method will contain a shell of an AVDepthData that contains no actual depth data backing pixel buffer, as well as a presentation time stamp and a reason for the drop. This method will be called on the dispatch queue specified by the output's delegateCallbackQueue property. Because this method is called on the same dispatch queue that outputs depth data, it must be efficient to prevent further capture performance problems, such as additional drops.
177        #[optional]
178        #[unsafe(method(depthDataOutput:didDropDepthData:timestamp:connection:reason:))]
179        #[unsafe(method_family = none)]
180        unsafe fn depthDataOutput_didDropDepthData_timestamp_connection_reason(
181            &self,
182            output: &AVCaptureDepthDataOutput,
183            depth_data: &AVDepthData,
184            timestamp: CMTime,
185            connection: &AVCaptureConnection,
186            reason: AVCaptureOutputDataDroppedReason,
187        );
188    }
189);