objc2_cinematic/generated/
CNRenderingSession.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-av-foundation")]
7use objc2_av_foundation::*;
8#[cfg(feature = "objc2-core-foundation")]
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12#[cfg(feature = "objc2-core-video")]
13use objc2_core_video::*;
14use objc2_foundation::*;
15#[cfg(feature = "objc2-metal")]
16use objc2_metal::*;
17
18use crate::*;
19
20/// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingquality?language=objc)
21// NS_ENUM
22#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct CNRenderingQuality(pub NSInteger);
25impl CNRenderingQuality {
26    #[doc(alias = "CNRenderingQualityThumbnail")]
27    pub const Thumbnail: Self = Self(0);
28    #[doc(alias = "CNRenderingQualityPreview")]
29    pub const Preview: Self = Self(1);
30    #[doc(alias = "CNRenderingQualityExport")]
31    pub const Export: Self = Self(2);
32    #[doc(alias = "CNRenderingQualityExportHigh")]
33    pub const ExportHigh: Self = Self(3);
34}
35
36unsafe impl Encode for CNRenderingQuality {
37    const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for CNRenderingQuality {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44extern_class!(
45    /// Movie-wide information required by the rendering session.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsessionattributes?language=objc)
48    #[unsafe(super(NSObject))]
49    #[derive(Debug, PartialEq, Eq, Hash)]
50    pub struct CNRenderingSessionAttributes;
51);
52
53extern_conformance!(
54    unsafe impl NSObjectProtocol for CNRenderingSessionAttributes {}
55);
56
57impl CNRenderingSessionAttributes {
58    extern_methods!(
59        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
60        /// Load rendering session attributes from an asset asynchronously.
61        #[unsafe(method(loadFromAsset:completionHandler:))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn loadFromAsset_completionHandler(
64            asset: &AVAsset,
65            completion_handler: &block2::DynBlock<
66                dyn Fn(*mut CNRenderingSessionAttributes, *mut NSError),
67            >,
68        );
69
70        /// Rendering version used to render the original.
71        #[unsafe(method(renderingVersion))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn renderingVersion(&self) -> NSInteger;
74
75        #[unsafe(method(init))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
78
79        #[unsafe(method(new))]
80        #[unsafe(method_family = new)]
81        pub unsafe fn new() -> Retained<Self>;
82    );
83}
84
85extern_class!(
86    /// Frame-specific information required to render a frame in a rendering session.
87    ///
88    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsessionframeattributes?language=objc)
89    #[unsafe(super(NSObject))]
90    #[derive(Debug, PartialEq, Eq, Hash)]
91    pub struct CNRenderingSessionFrameAttributes;
92);
93
94extern_conformance!(
95    unsafe impl NSCopying for CNRenderingSessionFrameAttributes {}
96);
97
98unsafe impl CopyingHelper for CNRenderingSessionFrameAttributes {
99    type Result = Self;
100}
101
102extern_conformance!(
103    unsafe impl NSObjectProtocol for CNRenderingSessionFrameAttributes {}
104);
105
106impl CNRenderingSessionFrameAttributes {
107    extern_methods!(
108        #[cfg(feature = "objc2-core-media")]
109        /// Initialize rendering frame attributes from a sample buffer read from a cinematic metadata track.
110        /// - Parameters:
111        /// - sampleBuffer: A sample buffer read from the timed cinematic metadata track of a cinematic asset.
112        /// - sessionAttributes: Rendering session attributes loaded from a cinematic asset.
113        #[unsafe(method(initWithSampleBuffer:sessionAttributes:))]
114        #[unsafe(method_family = init)]
115        pub unsafe fn initWithSampleBuffer_sessionAttributes(
116            this: Allocated<Self>,
117            sample_buffer: &CMSampleBuffer,
118            session_attributes: &CNRenderingSessionAttributes,
119        ) -> Option<Retained<Self>>;
120
121        #[cfg(feature = "objc2-av-foundation")]
122        /// Initialize rendering frame attributes from a timed metadata group read from a cinematic metadata track.
123        /// - Parameters:
124        /// - metadataGroup: An AVTimedMetadataGroup read from the timed cinematic metadata track of a cinematic asset.
125        /// - sessionAttributes: Rendering session attributes loaded from a cinematic asset.
126        #[unsafe(method(initWithTimedMetadataGroup:sessionAttributes:))]
127        #[unsafe(method_family = init)]
128        pub unsafe fn initWithTimedMetadataGroup_sessionAttributes(
129            this: Allocated<Self>,
130            metadata_group: &AVTimedMetadataGroup,
131            session_attributes: &CNRenderingSessionAttributes,
132        ) -> Option<Retained<Self>>;
133
134        /// The disparity value which represents the focus plane at which the rendered image should be in focus.
135        ///
136        /// A larger disparity results in the focus plane being closer to the camera. The scale and offset of disparity is not defined.
137        /// It is best practice to obtain disparity values from detections or by interpolation between known disparity values.
138        #[unsafe(method(focusDisparity))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn focusDisparity(&self) -> c_float;
141
142        /// Setter for [`focusDisparity`][Self::focusDisparity].
143        #[unsafe(method(setFocusDisparity:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setFocusDisparity(&self, focus_disparity: c_float);
146
147        /// The f-stop value which inversely affects the aperture used to render the image.
148        ///
149        /// A smaller f/ number results in larger bokeh and a shallower depth of field in the rendered image.
150        #[unsafe(method(fNumber))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn fNumber(&self) -> c_float;
153
154        /// Setter for [`fNumber`][Self::fNumber].
155        #[unsafe(method(setFNumber:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setFNumber(&self, f_number: c_float);
158
159        #[unsafe(method(init))]
160        #[unsafe(method_family = init)]
161        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
162
163        #[unsafe(method(new))]
164        #[unsafe(method_family = new)]
165        pub unsafe fn new() -> Retained<Self>;
166    );
167}
168
169extern_class!(
170    /// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsession?language=objc)
171    #[unsafe(super(NSObject))]
172    #[derive(Debug, PartialEq, Eq, Hash)]
173    pub struct CNRenderingSession;
174);
175
176extern_conformance!(
177    unsafe impl NSObjectProtocol for CNRenderingSession {}
178);
179
180impl CNRenderingSession {
181    extern_methods!(
182        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-metal"))]
183        #[unsafe(method(initWithCommandQueue:sessionAttributes:preferredTransform:quality:))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn initWithCommandQueue_sessionAttributes_preferredTransform_quality(
186            this: Allocated<Self>,
187            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
188            session_attributes: &CNRenderingSessionAttributes,
189            preferred_transform: CGAffineTransform,
190            quality: CNRenderingQuality,
191        ) -> Retained<Self>;
192
193        #[cfg(feature = "objc2-metal")]
194        #[unsafe(method(commandQueue))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn commandQueue(&self) -> Retained<ProtocolObject<dyn MTLCommandQueue>>;
197
198        #[unsafe(method(sessionAttributes))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn sessionAttributes(&self) -> Retained<CNRenderingSessionAttributes>;
201
202        #[cfg(feature = "objc2-core-foundation")]
203        #[unsafe(method(preferredTransform))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
206
207        #[unsafe(method(quality))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn quality(&self) -> CNRenderingQuality;
210
211        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
212        /// Encode a command to render a shallow depth of field (SDoF) image to a pixel buffer.
213        /// - Parameters:
214        /// - commandBuffer: the metal command buffer on which to encode the command
215        /// - frameAttributes: controls the focus distance and aperture of the rendering
216        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
217        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
218        /// - destinationImage: the pixel buffer to which the SDoF image is rendered
219        /// - Returns: whether encoding the render command was successful
220        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationImage:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationImage(
223            &self,
224            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
225            frame_attributes: &CNRenderingSessionFrameAttributes,
226            source_image: &CVPixelBuffer,
227            source_disparity: &CVPixelBuffer,
228            destination_image: &CVPixelBuffer,
229        ) -> bool;
230
231        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
232        /// Encode a command to render a shallow depth of field (SDoF) image to a metal texture as RGBA.
233        /// - Parameters:
234        /// - commandBuffer: the metal command buffer on which to encode the command
235        /// - frameAttributes: controls the focus distance and aperture of the rendering
236        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
237        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
238        /// - destinationRGBA: a metal texture to which the SDoF image is rendered in RGBA format
239        /// - Returns: whether encoding the render command was successful
240        ///
241        /// # Safety
242        ///
243        /// - `destination_rgba` may need to be synchronized.
244        /// - `destination_rgba` may be unretained, you must ensure it is kept alive while in use.
245        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationRGBA(
248            &self,
249            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
250            frame_attributes: &CNRenderingSessionFrameAttributes,
251            source_image: &CVPixelBuffer,
252            source_disparity: &CVPixelBuffer,
253            destination_rgba: &ProtocolObject<dyn MTLTexture>,
254        ) -> bool;
255
256        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
257        /// Encode a command to render a shallow depth of field (SDoF) image to two metal textures as luma and chroma.
258        /// - Parameters:
259        /// - commandBuffer: the metal command buffer on which to encode the command
260        /// - frameAttributes: controls the focus distance and aperture of the rendering
261        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
262        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
263        /// - destinationLuma: a metal texture to which the luma of the SDoF image is rendered
264        /// - destinationChroma: a metal texture to which the chroma of the SDoF image is rendered
265        /// - Returns: whether encoding the render command was successful
266        ///
267        /// # Safety
268        ///
269        /// - `destination_luma` may need to be synchronized.
270        /// - `destination_luma` may be unretained, you must ensure it is kept alive while in use.
271        /// - `destination_chroma` may need to be synchronized.
272        /// - `destination_chroma` may be unretained, you must ensure it is kept alive while in use.
273        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationLuma:destinationChroma:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationLuma_destinationChroma(
276            &self,
277            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
278            frame_attributes: &CNRenderingSessionFrameAttributes,
279            source_image: &CVPixelBuffer,
280            source_disparity: &CVPixelBuffer,
281            destination_luma: &ProtocolObject<dyn MTLTexture>,
282            destination_chroma: &ProtocolObject<dyn MTLTexture>,
283        ) -> bool;
284
285        /// The pixel format types supported for the input source.
286        ///
287        /// Use with kCVPixelBufferPixelFormatTypeKey in the video compositor's sourcePixelBufferAttributes dictionary when implementing AVVideoCompositing.
288        #[unsafe(method(sourcePixelFormatTypes))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn sourcePixelFormatTypes() -> Retained<NSArray<NSNumber>>;
291
292        /// The pixel format types supported for the output destination.
293        ///
294        /// Use with kCVPixelBufferPixelFormatTypeKey in the video compositor's requiredPixelBufferAttributesForRenderContext dictionary when implementing AVVideoCompositing.
295        #[unsafe(method(destinationPixelFormatTypes))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn destinationPixelFormatTypes() -> Retained<NSArray<NSNumber>>;
298
299        #[unsafe(method(init))]
300        #[unsafe(method_family = init)]
301        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
302
303        #[unsafe(method(new))]
304        #[unsafe(method_family = new)]
305        pub unsafe fn new() -> Retained<Self>;
306    );
307}