objc2_cinematic/generated/
CNScript.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-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern_class!(
15    /// Database of focus decisions with methods to change them.
16    /// Knows what has been detected in each frame and which detection is being focused on.
17    /// All operations are executed in a thread-safe manner, but that also means that a long-running update can stall a lookup.
18    /// Best practice is to lookup what you need up front (outside your critical code) and pass the immutable results to where it's needed.
19    /// That way, you're not blocked when you access the information, say inside the rendering portion of your code.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnscript?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct CNScript;
25);
26
27unsafe impl Send for CNScript {}
28
29unsafe impl Sync for CNScript {}
30
31extern_conformance!(
32    unsafe impl NSObjectProtocol for CNScript {}
33);
34
35impl CNScript {
36    extern_methods!(
37        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
38        /// Load cinematic script asynchronously from a cinematic asset.
39        /// - Parameters:
40        /// - asset: the cinematic asset to be loaded.
41        /// - changes: optional changes since asset was recorded. Can be obtained from a previous editing session. If `nil`, the asset is loaded as originally recorded.
42        /// - progress: optional progress object to track progress or cancel loading. Represents just the loading of this asset. Create with desired total unit count or use zero to have the unit count filled in automatically.  If `nil`, no progress is reported.
43        /// - completionHandler: called with the loaded cinematic script when done, or with with an error if it fails. If progress is canceled before it completes, the completion handler is called with an error.
44        #[unsafe(method(loadFromAsset:changes:progress:completionHandler:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn loadFromAsset_changes_progress_completionHandler(
47            asset: &AVAsset,
48            changes: Option<&CNScriptChanges>,
49            progress: Option<&NSProgress>,
50            completion_handler: &block2::DynBlock<dyn Fn(*mut CNScript, *mut NSError)>,
51        );
52
53        /// Reload the cinematic script with optional changes applied, removing any previous changes made.
54        /// This can be more efficient than loading the asset from scratch.
55        /// - Parameters:
56        /// - changes: optional changes since asset was recorded. Can be obtained from a previous editing session. If `nil`, the asset is reloaded as originally recorded.
57        #[unsafe(method(reloadWithChanges:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn reloadWithChanges(&self, changes: Option<&CNScriptChanges>);
60
61        /// Changes made since cinematic asset was recorded. Can be used to checkpoint and later restore changes made so far.
62        #[unsafe(method(changes))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn changes(&self) -> Retained<CNScriptChanges>;
65
66        #[cfg(feature = "objc2-core-media")]
67        /// Changes trimmed and time range shifted to start at zero — for use with a similarly trimmed cinematic asset.
68        #[unsafe(method(changesTrimmedByTimeRange:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn changesTrimmedByTimeRange(
71            &self,
72            time_range: CMTimeRange,
73        ) -> Retained<CNScriptChanges>;
74
75        #[cfg(feature = "objc2-core-media")]
76        /// The time range of the cinematic asset. All frames, decisions, and detections are within this time range.
77        #[unsafe(method(timeRange))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn timeRange(&self) -> CMTimeRange;
80
81        #[cfg(feature = "objc2-core-media")]
82        /// The closest frame to the given time within the given tolerance. Returns `nil` if there are none.
83        #[unsafe(method(frameAtTime:tolerance:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn frameAtTime_tolerance(
86            &self,
87            time: CMTime,
88            tolerance: CMTime,
89        ) -> Option<Retained<CNScriptFrame>>;
90
91        #[cfg(feature = "objc2-core-media")]
92        /// All frames within the given time range.
93        #[unsafe(method(framesInTimeRange:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn framesInTimeRange(
96            &self,
97            time_range: CMTimeRange,
98        ) -> Retained<NSArray<CNScriptFrame>>;
99
100        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
101        /// The closest decision to the given time within the given tolerance. Returns `nil` if there are none.
102        #[unsafe(method(decisionAtTime:tolerance:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn decisionAtTime_tolerance(
105            &self,
106            time: CMTime,
107            tolerance: CMTime,
108        ) -> Option<Retained<CNDecision>>;
109
110        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
111        /// All decisions within the given time range.
112        #[unsafe(method(decisionsInTimeRange:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn decisionsInTimeRange(
115            &self,
116            time_range: CMTimeRange,
117        ) -> Retained<NSArray<CNDecision>>;
118
119        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
120        /// The decision that occurs after the given time. Pass the time of an existing decision to find the next one.
121        #[unsafe(method(decisionAfterTime:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn decisionAfterTime(&self, time: CMTime) -> Option<Retained<CNDecision>>;
124
125        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
126        /// The decision that occurs before the given time. Pass the time of an existing decisions to find the previous one.
127        #[unsafe(method(decisionBeforeTime:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn decisionBeforeTime(&self, time: CMTime) -> Option<Retained<CNDecision>>;
130
131        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
132        /// The primary decision that is in effect at the specified time, unless if it's outside the time range of the cinematic script.
133        /// Also represents the decision that is being transitioned away from if the given time is during a focus transition.
134        #[unsafe(method(primaryDecisionAtTime:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn primaryDecisionAtTime(&self, time: CMTime) -> Option<Retained<CNDecision>>;
137
138        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
139        /// The secondary decision that is being transitioned towards if the given time is during a focus transition.
140        #[unsafe(method(secondaryDecisionAtTime:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn secondaryDecisionAtTime(&self, time: CMTime) -> Option<Retained<CNDecision>>;
143
144        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
145        /// The time range during which the focus transition away from the given decision occurs.
146        #[unsafe(method(timeRangeOfTransitionAfterDecision:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn timeRangeOfTransitionAfterDecision(
149            &self,
150            decision: &CNDecision,
151        ) -> CMTimeRange;
152
153        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
154        /// The time range during which the focus transition towards the given decision occurs.
155        #[unsafe(method(timeRangeOfTransitionBeforeDecision:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn timeRangeOfTransitionBeforeDecision(
158            &self,
159            decision: &CNDecision,
160        ) -> CMTimeRange;
161
162        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
163        /// All user decisions in the given time range. Includes user decisions made during recording or added to the script.
164        #[unsafe(method(userDecisionsInTimeRange:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn userDecisionsInTimeRange(
167            &self,
168            time_range: CMTimeRange,
169        ) -> Retained<NSArray<CNDecision>>;
170
171        #[cfg(all(feature = "CNDecision", feature = "objc2-core-media"))]
172        /// All base decisions made automatically during recording in the given time range. These apply if no user decision overrides them.
173        #[unsafe(method(baseDecisionsInTimeRange:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn baseDecisionsInTimeRange(
176            &self,
177            time_range: CMTimeRange,
178        ) -> Retained<NSArray<CNDecision>>;
179
180        #[cfg(all(feature = "CNDetection", feature = "CNDetectionTrack"))]
181        /// A detection track representing all detections with the given detectionID over the entire cinematic script.
182        #[unsafe(method(detectionTrackForID:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn detectionTrackForID(
185            &self,
186            detection_id: CNDetectionID,
187        ) -> Option<Retained<CNDetectionTrack>>;
188
189        #[cfg(all(feature = "CNDecision", feature = "CNDetectionTrack"))]
190        /// A detection track representing all detections that would be chosen by a given decision.
191        #[unsafe(method(detectionTrackForDecision:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn detectionTrackForDecision(
194            &self,
195            decision: &CNDecision,
196        ) -> Option<Retained<CNDetectionTrack>>;
197
198        /// The f/number to apply to the entire movie, initially set to that of the recorded movie.
199        ///
200        /// Pass this to the rendering session in the rendering frame attributes to match the selected aperture.
201        /// Change this property when the user selects a different aperture for the edited movie.
202        /// Changes to this property are reflected in the script changes for later restoration.
203        #[unsafe(method(fNumber))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn fNumber(&self) -> c_float;
206
207        /// Setter for [`fNumber`][Self::fNumber].
208        #[unsafe(method(setFNumber:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn setFNumber(&self, f_number: c_float);
211
212        #[cfg(feature = "CNDecision")]
213        /// Add a new user decision. Replaces an existing user decision if the times are identical.
214        ///
215        /// Adding a decision can fail if the decision focuses on an detection or group that does not exist or if its time is not within the time range of the cinematic script.
216        ///
217        /// - Returns: whether adding was successful
218        #[unsafe(method(addUserDecision:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn addUserDecision(&self, decision: &CNDecision) -> bool;
221
222        #[cfg(feature = "CNDecision")]
223        /// Remove an existing user decision.
224        ///
225        /// User decisions added to the script or those made at recording time (by tapping during recording) can be removed.
226        /// Decisions that are not user decisions cannot be removed.
227        ///
228        /// - Returns: whether removal was successful
229        #[unsafe(method(removeUserDecision:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn removeUserDecision(&self, decision: &CNDecision) -> bool;
232
233        /// Remove all user decisions and revert to base decisions only.
234        #[unsafe(method(removeAllUserDecisions))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn removeAllUserDecisions(&self);
237
238        #[cfg(all(feature = "CNDetection", feature = "CNDetectionTrack"))]
239        /// Add user created detection track.
240        ///
241        /// - Returns: the detectionID assigned to the added track, which can be used for later lookup or decision creation.
242        #[unsafe(method(addDetectionTrack:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn addDetectionTrack(&self, detection_track: &CNDetectionTrack)
245            -> CNDetectionID;
246
247        #[cfg(feature = "CNDetectionTrack")]
248        /// Remove user created detection track.
249        ///
250        /// Tracks created at recording time cannot be removed.
251        ///
252        /// - Returns: whether removal was successful
253        #[unsafe(method(removeDetectionTrack:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn removeDetectionTrack(&self, detection_track: &CNDetectionTrack) -> bool;
256
257        #[cfg(feature = "CNDetectionTrack")]
258        /// All detection tracks that have been added since recording.
259        #[unsafe(method(addedDetectionTracks))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn addedDetectionTracks(&self) -> Retained<NSArray<CNDetectionTrack>>;
262
263        #[unsafe(method(init))]
264        #[unsafe(method_family = init)]
265        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
266
267        #[unsafe(method(new))]
268        #[unsafe(method_family = new)]
269        pub unsafe fn new() -> Retained<Self>;
270    );
271}
272
273extern_class!(
274    /// Represents a snapshot of changes made to the cinematic script since recording.
275    /// Can be used as a snapshot to quickly revert to previously saved edits via `-[CNScript reloadWithChanges:]`
276    ///
277    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnscriptchanges?language=objc)
278    #[unsafe(super(NSObject))]
279    #[derive(Debug, PartialEq, Eq, Hash)]
280    pub struct CNScriptChanges;
281);
282
283extern_conformance!(
284    unsafe impl NSObjectProtocol for CNScriptChanges {}
285);
286
287impl CNScriptChanges {
288    extern_methods!(
289        /// Create from previously saved data representation
290        #[unsafe(method(initWithDataRepresentation:))]
291        #[unsafe(method_family = init)]
292        pub unsafe fn initWithDataRepresentation(
293            this: Allocated<Self>,
294            data_representation: &NSData,
295        ) -> Option<Retained<Self>>;
296
297        /// Get persistent data representation of these changes for later restoration.
298        ///
299        /// The changes can only be used with the original cinematic asset from which the CNScript was created.
300        #[unsafe(method(dataRepresentation))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn dataRepresentation(&self) -> Retained<NSData>;
303
304        /// The f/number to apply to the entire movie.
305        #[unsafe(method(fNumber))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn fNumber(&self) -> c_float;
308
309        #[cfg(feature = "CNDecision")]
310        /// All active user decisions, including those made at recording time, unless they have been removed.
311        #[unsafe(method(userDecisions))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn userDecisions(&self) -> Retained<NSArray<CNDecision>>;
314
315        #[cfg(feature = "CNDetectionTrack")]
316        /// All detection tracks that have been added. Does not include those created at recording time.
317        #[unsafe(method(addedDetectionTracks))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn addedDetectionTracks(&self) -> Retained<NSArray<CNDetectionTrack>>;
320
321        #[unsafe(method(init))]
322        #[unsafe(method_family = init)]
323        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
324
325        #[unsafe(method(new))]
326        #[unsafe(method_family = new)]
327        pub unsafe fn new() -> Retained<Self>;
328    );
329}
330
331extern_class!(
332    /// Represents focus
333    /// &
334    /// detection information at a particular time.
335    ///
336    /// Indicates where to focus (disparity) and what to focus on (detection) at a particular time in the movie.
337    /// It also provides access to all known detections that can be focused on at that time.
338    /// Utility methods support looking up a detection by detectionID or detectionGroupID.
339    ///
340    /// Frames are obtained from the cinematic script using `frame(at:tolerance:)` or `frames(in:)`.
341    ///
342    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnscriptframe?language=objc)
343    #[unsafe(super(NSObject))]
344    #[derive(Debug, PartialEq, Eq, Hash)]
345    pub struct CNScriptFrame;
346);
347
348unsafe impl Send for CNScriptFrame {}
349
350unsafe impl Sync for CNScriptFrame {}
351
352extern_conformance!(
353    unsafe impl NSCopying for CNScriptFrame {}
354);
355
356unsafe impl CopyingHelper for CNScriptFrame {
357    type Result = Self;
358}
359
360extern_conformance!(
361    unsafe impl NSObjectProtocol for CNScriptFrame {}
362);
363
364impl CNScriptFrame {
365    extern_methods!(
366        #[cfg(feature = "objc2-core-media")]
367        /// The presentation time associated with the remaining properties.
368        #[unsafe(method(time))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn time(&self) -> CMTime;
371
372        /// The disparity value representing the focus plane at which the script is focused in this frame.
373        ///
374        /// A larger disparity results in the focus plane being closer to the camera. The scale and offset of disparity is not defined.
375        ///
376        /// Pass this to the rendering session when rendering the corresponding frame of the movie to focus at the recommended depth.
377        #[unsafe(method(focusDisparity))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn focusDisparity(&self) -> c_float;
380
381        #[cfg(feature = "CNDetection")]
382        /// The detection on which the script is focused in this frame.
383        ///
384        /// The focusDisparity of the focusDetection can be different from that of the frame such as when a rack focus is in progress.
385        #[unsafe(method(focusDetection))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn focusDetection(&self) -> Retained<CNDetection>;
388
389        #[cfg(feature = "CNDetection")]
390        /// All detected objects in this frame.
391        #[unsafe(method(allDetections))]
392        #[unsafe(method_family = none)]
393        pub unsafe fn allDetections(&self) -> Retained<NSArray<CNDetection>>;
394
395        #[unsafe(method(init))]
396        #[unsafe(method_family = init)]
397        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
398
399        #[unsafe(method(new))]
400        #[unsafe(method_family = new)]
401        pub unsafe fn new() -> Retained<Self>;
402    );
403}
404
405/// CNExtensions.
406impl CNScriptFrame {
407    extern_methods!(
408        #[cfg(feature = "CNDetection")]
409        /// The detection in this frame with the given detection ID, if any.
410        #[unsafe(method(detectionForID:))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn detectionForID(
413            &self,
414            detection_id: CNDetectionID,
415        ) -> Option<Retained<CNDetection>>;
416
417        #[cfg(feature = "CNDetection")]
418        /// The best detection to focus on in this frame among those with the given detectionGroupID.
419        /// For example, a face is preferred to the corresponding torso, even though both have the same detectionGroupID.
420        #[unsafe(method(bestDetectionForGroupID:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn bestDetectionForGroupID(
423            &self,
424            detection_group_id: CNDetectionGroupID,
425        ) -> Option<Retained<CNDetection>>;
426    );
427}