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