objc2_av_foundation/generated/AVVideoComposition.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-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12use objc2_foundation::*;
13#[cfg(feature = "objc2-quartz-core")]
14#[cfg(not(target_os = "watchos"))]
15use objc2_quartz_core::*;
16
17use crate::*;
18
19/// Configures policy for per frame HDR display metadata
20///
21/// Determines what HDR display metadata should be attached to the rendered frame.
22///
23/// Default. Pass the HDR metadata through, if present on the composed frame.
24///
25/// AVVideoComposition may generate HDR metadata and attach it to the rendered frame. HDR metadata generation is influenced by the color space of the rendered frame, device, and HDR metadata format platform support. Any previously attached HDR metadata of the same metadata format will be overwritten.
26///
27/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositionperframehdrdisplaymetadatapolicy?language=objc)
28// NS_TYPED_ENUM
29pub type AVVideoCompositionPerFrameHDRDisplayMetadataPolicy = NSString;
30
31extern "C" {
32 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositionperframehdrdisplaymetadatapolicypropagate?language=objc)
33 pub static AVVideoCompositionPerFrameHDRDisplayMetadataPolicyPropagate:
34 &'static AVVideoCompositionPerFrameHDRDisplayMetadataPolicy;
35}
36
37extern "C" {
38 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositionperframehdrdisplaymetadatapolicygenerate?language=objc)
39 pub static AVVideoCompositionPerFrameHDRDisplayMetadataPolicyGenerate:
40 &'static AVVideoCompositionPerFrameHDRDisplayMetadataPolicy;
41}
42
43extern_class!(
44 /// The AVVideoCompositionRenderContext class defines the context within which custom compositors render new output pixels buffers.
45 ///
46 ///
47 /// An instance of AVVideoCompositionRenderContext provides size and scaling information and offers a service for efficiently providing pixel buffers from a managed pool of buffers.
48 ///
49 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocomposition?language=objc)
50 #[unsafe(super(NSObject))]
51 #[derive(Debug, PartialEq, Eq, Hash)]
52 pub struct AVVideoComposition;
53);
54
55extern_conformance!(
56 unsafe impl NSCopying for AVVideoComposition {}
57);
58
59unsafe impl CopyingHelper for AVVideoComposition {
60 type Result = Self;
61}
62
63extern_conformance!(
64 unsafe impl NSMutableCopying for AVVideoComposition {}
65);
66
67unsafe impl MutableCopyingHelper for AVVideoComposition {
68 type Result = AVMutableVideoComposition;
69}
70
71extern_conformance!(
72 unsafe impl NSObjectProtocol for AVVideoComposition {}
73);
74
75impl AVVideoComposition {
76 extern_methods!(
77 #[cfg(feature = "AVAsset")]
78 /// Returns a new instance of AVVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks.
79 ///
80 /// Parameter `asset`: An instance of AVAsset. Ensure that the duration and tracks properties of the asset are already loaded before invoking this method.
81 ///
82 /// Returns: An instance of AVVideoComposition.
83 ///
84 /// The returned AVVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks.
85 /// It will also have the following values for its properties:
86 ///
87 /// - If the asset has exactly one video track, the original timing of the source video track will be used. If the asset has more than one video track, and the nominal frame rate of any of video tracks is known, the reciprocal of the greatest known nominalFrameRate will be used as the value of frameDuration. Otherwise, a default framerate of 30fps is used.
88 /// - If the specified asset is an instance of AVComposition, the renderSize will be set to the naturalSize of the AVComposition; otherwise the renderSize will be set to a value that encompasses all of the asset's video tracks.
89 /// - A renderScale of 1.0.
90 /// - A nil animationTool.
91 ///
92 /// If the specified asset has no video tracks, this method will return an AVVideoComposition instance with an empty collection of instructions.
93 #[deprecated = "Use videoCompositionWithPropertiesOfAsset:completionHandler: instead"]
94 #[unsafe(method(videoCompositionWithPropertiesOfAsset:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn videoCompositionWithPropertiesOfAsset(
97 asset: &AVAsset,
98 ) -> Retained<AVVideoComposition>;
99
100 #[cfg(all(feature = "AVAsset", feature = "block2"))]
101 /// Vends a new instance of AVVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks.
102 ///
103 /// Parameter `asset`: An instance of AVAsset.
104 ///
105 /// Parameter `completionHandler`: A block that is invoked when the new video composition has finished being created. If the `videoComposition` parameter is nil, the `error` parameter describes the failure that occurred.
106 ///
107 /// The new AVVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks.
108 /// It will also have the following values for its properties:
109 ///
110 /// - If the asset has exactly one video track, the original timing of the source video track will be used. If the asset has more than one video track, and the nominal frame rate of any of video tracks is known, the reciprocal of the greatest known nominalFrameRate will be used as the value of frameDuration. Otherwise, a default framerate of 30fps is used.
111 /// - If the specified asset is an instance of AVComposition, the renderSize will be set to the naturalSize of the AVComposition; otherwise the renderSize will be set to a value that encompasses all of the asset's video tracks.
112 /// - A renderScale of 1.0.
113 /// - A nil animationTool.
114 ///
115 /// If the specified asset has no video tracks, this method will return an AVVideoComposition instance with an empty collection of instructions.
116 #[unsafe(method(videoCompositionWithPropertiesOfAsset:completionHandler:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn videoCompositionWithPropertiesOfAsset_completionHandler(
119 asset: &AVAsset,
120 completion_handler: &block2::DynBlock<dyn Fn(*mut AVVideoComposition, *mut NSError)>,
121 );
122
123 #[cfg(feature = "AVVideoCompositing")]
124 #[unsafe(method(customVideoCompositorClass))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn customVideoCompositorClass(&self) -> Option<&'static AnyClass>;
127
128 #[cfg(feature = "objc2-core-media")]
129 #[unsafe(method(frameDuration))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn frameDuration(&self) -> CMTime;
132
133 #[cfg(feature = "objc2-core-media")]
134 #[unsafe(method(sourceTrackIDForFrameTiming))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn sourceTrackIDForFrameTiming(&self) -> CMPersistentTrackID;
137
138 #[cfg(feature = "objc2-core-foundation")]
139 #[unsafe(method(renderSize))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn renderSize(&self) -> CGSize;
142
143 #[unsafe(method(renderScale))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn renderScale(&self) -> c_float;
146
147 #[cfg(feature = "AVVideoCompositing")]
148 #[unsafe(method(instructions))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn instructions(
151 &self,
152 ) -> Retained<NSArray<ProtocolObject<dyn AVVideoCompositionInstructionProtocol>>>;
153
154 #[unsafe(method(animationTool))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn animationTool(&self)
157 -> Option<Retained<AVVideoCompositionCoreAnimationTool>>;
158
159 #[unsafe(method(sourceSampleDataTrackIDs))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn sourceSampleDataTrackIDs(&self) -> Retained<NSArray<NSNumber>>;
162 );
163}
164
165/// Methods declared on superclass `NSObject`.
166impl AVVideoComposition {
167 extern_methods!(
168 #[unsafe(method(init))]
169 #[unsafe(method_family = init)]
170 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
171
172 #[unsafe(method(new))]
173 #[unsafe(method_family = new)]
174 pub unsafe fn new() -> Retained<Self>;
175 );
176}
177
178/// AVVideoCompositionColorimetery.
179impl AVVideoComposition {
180 extern_methods!(
181 #[unsafe(method(colorPrimaries))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn colorPrimaries(&self) -> Option<Retained<NSString>>;
184
185 #[unsafe(method(colorYCbCrMatrix))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn colorYCbCrMatrix(&self) -> Option<Retained<NSString>>;
188
189 #[unsafe(method(colorTransferFunction))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn colorTransferFunction(&self) -> Option<Retained<NSString>>;
192
193 #[unsafe(method(perFrameHDRDisplayMetadataPolicy))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn perFrameHDRDisplayMetadataPolicy(
196 &self,
197 ) -> Retained<AVVideoCompositionPerFrameHDRDisplayMetadataPolicy>;
198 );
199}
200
201/// AVVideoCompositionFiltering.
202impl AVVideoComposition {
203 extern_methods!(
204 #[cfg(all(
205 feature = "AVAsset",
206 feature = "AVVideoCompositing",
207 feature = "block2"
208 ))]
209 /// Returns a new instance of AVVideoComposition with values and instructions that will apply the specified handler block to video frames represented as instances of CIImage.
210 ///
211 /// Parameter `asset`: An instance of AVAsset. For best performance, ensure that the duration and tracks properties of the asset are already loaded before invoking this method.
212 ///
213 /// Returns: An instance of AVVideoComposition.
214 ///
215 /// The returned AVVideoComposition will cause the specified handler block to be called to filter each frame of the asset's first enabled video track. The handler block should use the properties of the provided AVAsynchronousCIImageFilteringRequest and respond using finishWithImage:context: with a "filtered" new CIImage (or the provided source image for no affect). In the event of an error, respond to the request using finishWithError:. The error can be observed via AVPlayerItemFailedToPlayToEndTimeNotification, see AVPlayerItemFailedToPlayToEndTimeErrorKey in notification payload.
216 ///
217 /// NOTE: The returned AVVideoComposition's properties are private and support only CIFilter-based operations. Mutations are not supported, either in the values of properties of the AVVideoComposition itself or in its private instructions. If rotations or other transformations are desired, they must be accomplished via the application of CIFilters during the execution of your specified handler.
218 ///
219 /// The video composition will also have the following values for its properties:
220 ///
221 /// - The original timing of the asset's first enabled video track will be used.
222 /// - A renderSize that encompasses the asset's first enabled video track respecting the track's preferredTransform.
223 /// - A renderScale of 1.0.
224 ///
225 /// The default CIContext has the following properties:
226 ///
227 /// - iOS: Device RGB color space
228 /// - macOS: sRGB color space
229 ///
230 /// Example usage:
231 ///
232 /// playerItem.videoComposition = [AVVideoComposition videoCompositionWithAsset:srcAsset applyingCIFiltersWithHandler:
233 /// ^(AVAsynchronousCIImageFilteringRequest *request)
234 /// {
235 /// NSError *err = nil;
236 /// CIImage *filtered = myRenderer(request,
237 /// &err
238 /// );
239 /// if (filtered)
240 /// [request finishWithImage:filtered context:nil];
241 /// else
242 /// [request finishWithError:err];
243 /// }];
244 #[deprecated = "Use videoCompositionWithAsset:applyingCIFiltersWithHandler:completionHandler: instead"]
245 #[unsafe(method(videoCompositionWithAsset:applyingCIFiltersWithHandler:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn videoCompositionWithAsset_applyingCIFiltersWithHandler(
248 asset: &AVAsset,
249 applier: &block2::DynBlock<dyn Fn(NonNull<AVAsynchronousCIImageFilteringRequest>)>,
250 ) -> Retained<AVVideoComposition>;
251
252 #[cfg(all(
253 feature = "AVAsset",
254 feature = "AVVideoCompositing",
255 feature = "block2"
256 ))]
257 /// Vends a new instance of AVVideoComposition with values and instructions that will apply the specified handler block to video frames represented as instances of CIImage.
258 ///
259 /// Parameter `asset`: An instance of AVAsset.
260 ///
261 /// Parameter `completionHandler`: A block that is invoked when the new video composition has finished being created. If the `videoComposition` parameter is nil, the `error` parameter describes the failure that occurred.
262 ///
263 /// The new AVVideoComposition will cause the specified handler block to be called to filter each frame of the asset's first enabled video track. The handler block should use the properties of the provided AVAsynchronousCIImageFilteringRequest and respond using finishWithImage:context: with a "filtered" new CIImage (or the provided source image for no affect). In the event of an error, respond to the request using finishWithError:. The error can be observed via AVPlayerItemFailedToPlayToEndTimeNotification, see AVPlayerItemFailedToPlayToEndTimeErrorKey in notification payload.
264 ///
265 /// NOTE: The returned AVVideoComposition's properties are private and support only CIFilter-based operations. Mutations are not supported, either in the values of properties of the AVVideoComposition itself or in its private instructions. If rotations or other transformations are desired, they must be accomplished via the application of CIFilters during the execution of your specified handler.
266 ///
267 /// The video composition will also have the following values for its properties:
268 ///
269 /// - The original timing of the asset's first enabled video track will be used.
270 /// - A renderSize that encompasses the asset's first enabled video track respecting the track's preferredTransform.
271 /// - A renderScale of 1.0.
272 ///
273 /// The default CIContext has the following properties:
274 ///
275 /// - iOS: Device RGB color space
276 /// - macOS: sRGB color space
277 ///
278 /// Example usage:
279 ///
280 /// [AVVideoComposition videoCompositionWithAsset:srcAsset applyingCIFiltersWithHandler:
281 /// ^(AVAsynchronousCIImageFilteringRequest *request)
282 /// {
283 /// NSError *err = nil;
284 /// CIImage *filtered = myRenderer(request,
285 /// &err
286 /// );
287 /// if (filtered)
288 /// [request finishWithImage:filtered context:nil];
289 /// else
290 /// [request finishWithError:err];
291 /// } completionHandler:
292 /// ^(AVVideoComposition * _Nullable videoComposition, NSError * _Nullable error)
293 /// {
294 /// if (videoComposition != nil) {
295 /// playerItem.videoComposition = videoComposition
296 /// else {
297 /// // handle error
298 /// }];
299 #[unsafe(method(videoCompositionWithAsset:applyingCIFiltersWithHandler:completionHandler:))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn videoCompositionWithAsset_applyingCIFiltersWithHandler_completionHandler(
302 asset: &AVAsset,
303 applier: &block2::DynBlock<dyn Fn(NonNull<AVAsynchronousCIImageFilteringRequest>)>,
304 completion_handler: &block2::DynBlock<dyn Fn(*mut AVVideoComposition, *mut NSError)>,
305 );
306 );
307}
308
309extern_class!(
310 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablevideocomposition?language=objc)
311 #[unsafe(super(AVVideoComposition, NSObject))]
312 #[derive(Debug, PartialEq, Eq, Hash)]
313 pub struct AVMutableVideoComposition;
314);
315
316extern_conformance!(
317 unsafe impl NSCopying for AVMutableVideoComposition {}
318);
319
320unsafe impl CopyingHelper for AVMutableVideoComposition {
321 type Result = AVVideoComposition;
322}
323
324extern_conformance!(
325 unsafe impl NSMutableCopying for AVMutableVideoComposition {}
326);
327
328unsafe impl MutableCopyingHelper for AVMutableVideoComposition {
329 type Result = Self;
330}
331
332extern_conformance!(
333 unsafe impl NSObjectProtocol for AVMutableVideoComposition {}
334);
335
336impl AVMutableVideoComposition {
337 extern_methods!(
338 #[unsafe(method(videoComposition))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn videoComposition() -> Retained<AVMutableVideoComposition>;
341
342 #[cfg(feature = "AVAsset")]
343 /// Returns a new instance of AVMutableVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks.
344 ///
345 /// Parameter `asset`: An instance of AVAsset. For best performance, ensure that the duration and tracks properties of the asset are already loaded before invoking this method.
346 ///
347 /// Returns: An instance of AVMutableVideoComposition.
348 ///
349 /// The returned AVMutableVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks. The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to an appropriate value in order to specify the maximum output frame rate independent of the source track timing.
350 /// It will also have the following values for its properties:
351 ///
352 /// - If the asset has exactly one video track, the original timing of the source video track will be used. If the asset has more than one video track, and the nominal frame rate of any of video tracks is known, the reciprocal of the greatest known nominalFrameRate will be used as the value of frameDuration. Otherwise, a default framerate of 30fps is used.
353 /// - If the specified asset is an instance of AVComposition, the renderSize will be set to the naturalSize of the AVComposition; otherwise the renderSize will be set to a value that encompasses all of the asset's video tracks.
354 /// - A renderScale of 1.0.
355 /// - A nil animationTool.
356 ///
357 /// If the specified asset has no video tracks, this method will return an AVMutableVideoComposition instance with an empty collection of instructions.
358 #[deprecated = "Use videoCompositionWithPropertiesOfAsset:completionHandler: instead"]
359 #[unsafe(method(videoCompositionWithPropertiesOfAsset:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn videoCompositionWithPropertiesOfAsset(
362 asset: &AVAsset,
363 ) -> Retained<AVMutableVideoComposition>;
364
365 #[cfg(all(feature = "AVAsset", feature = "block2"))]
366 /// Vends a new instance of AVMutableVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks.
367 ///
368 /// Parameter `asset`: An instance of AVAsset.
369 ///
370 /// Parameter `completionHandler`: A block that is invoked when the new video composition has finished being created. If the `videoComposition` parameter is nil, the `error` parameter describes the failure that occurred.
371 ///
372 /// The new AVMutableVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks. The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to an appropriate value in order to specify the maximum output frame rate independent of the source track timing.
373 /// It will also have the following values for its properties:
374 ///
375 /// - If the asset has exactly one video track, the original timing of the source video track will be used. If the asset has more than one video track, and the nominal frame rate of any of video tracks is known, the reciprocal of the greatest known nominalFrameRate will be used as the value of frameDuration. Otherwise, a default framerate of 30fps is used.
376 /// - If the specified asset is an instance of AVComposition, the renderSize will be set to the naturalSize of the AVComposition; otherwise the renderSize will be set to a value that encompasses all of the asset's video tracks.
377 /// - A renderScale of 1.0.
378 /// - A nil animationTool.
379 ///
380 /// If the specified asset has no video tracks, this method will return an AVMutableVideoComposition instance with an empty collection of instructions.
381 #[unsafe(method(videoCompositionWithPropertiesOfAsset:completionHandler:))]
382 #[unsafe(method_family = none)]
383 pub unsafe fn videoCompositionWithPropertiesOfAsset_completionHandler(
384 asset: &AVAsset,
385 completion_handler: &block2::DynBlock<
386 dyn Fn(*mut AVMutableVideoComposition, *mut NSError),
387 >,
388 );
389
390 #[cfg(feature = "AVAsset")]
391 /// Returns a new instance of AVMutableVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks, and also overrides default properties with those from a prototypeInstruction.
392 ///
393 /// Parameter `asset`: An instance of AVAsset. For best performance, ensure that the duration and tracks properties of the asset are already loaded before invoking this method.
394 ///
395 /// Parameter `prototypeInstruction`: Custom instructions that the client can choose to override.
396 ///
397 /// Returns: An instance of AVMutableVideoComposition.
398 ///
399 /// Also see videoCompositionWithPropertiesOfAsset:.
400 /// The returned AVVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks. Anything not pertaining to spatial layout and timing, such as background color for their composition or post-processing behaviors, is eligible to be specified via a prototype instruction.
401 /// Example: To add a background color,
402 /// myPrototypeInstruction = [[AVMutableVideoCompositionInstruction alloc] init];
403 /// myPrototypeInstruction.backgroundColor = myCGColorRef; // Do not use constant CGColorRef colors here.
404 /// myVideoComposition = [AVVideoComposition videoCompositionWithPropertiesOfAsset:myAsset prototypeInstruction:myPrototypeInstruction];
405 #[deprecated = "Use videoCompositionWithPropertiesOfAsset:prototypeInstruction:completionHandler: instead"]
406 #[unsafe(method(videoCompositionWithPropertiesOfAsset:prototypeInstruction:))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn videoCompositionWithPropertiesOfAsset_prototypeInstruction(
409 asset: &AVAsset,
410 prototype_instruction: &AVVideoCompositionInstruction,
411 ) -> Retained<AVMutableVideoComposition>;
412
413 #[cfg(all(feature = "AVAsset", feature = "block2"))]
414 /// Vends a new instance of AVMutableVideoComposition with values and instructions suitable for presenting the video tracks of the specified asset according to its temporal and geometric properties and those of its tracks, and also overrides default properties with those from a prototypeInstruction.
415 ///
416 /// Parameter `asset`: An instance of AVAsset.
417 ///
418 /// Parameter `prototypeInstruction`: Custom instructions that the client can choose to override.
419 ///
420 /// Parameter `completionHandler`: A block that is invoked when the new video composition has finished being created. If the `videoComposition` parameter is nil, the `error` parameter describes the failure that occurred.
421 ///
422 /// Also see videoCompositionWithPropertiesOfAsset:completionHandler:.
423 /// The new AVMutableVideoComposition will have instructions that respect the spatial properties and timeRanges of the specified asset's video tracks. Anything not pertaining to spatial layout and timing, such as background color for their composition or post-processing behaviors, is eligible to be specified via a prototype instruction.
424 /// Example: To add a background color,
425 /// myPrototypeInstruction = [[AVMutableVideoCompositionInstruction alloc] init];
426 /// myPrototypeInstruction.backgroundColor = myCGColorRef; // Do not use constant CGColorRef colors here.
427 /// myVideoComposition = [AVVideoComposition videoCompositionWithPropertiesOfAsset:myAsset prototypeInstruction:myPrototypeInstruction completionHandler:^(AVMutableVideoComposition * _Nullable myVideoComposition, NSError * _Nullable error) {
428 /// if (myVideoComposition != nil) {
429 /// // use myVideoComposition
430 /// }
431 /// else {
432 /// // handle error
433 /// }
434 /// }];
435 #[unsafe(method(videoCompositionWithPropertiesOfAsset:prototypeInstruction:completionHandler:))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn videoCompositionWithPropertiesOfAsset_prototypeInstruction_completionHandler(
438 asset: &AVAsset,
439 prototype_instruction: &AVVideoCompositionInstruction,
440 completion_handler: &block2::DynBlock<
441 dyn Fn(*mut AVMutableVideoComposition, *mut NSError),
442 >,
443 );
444
445 #[cfg(feature = "AVVideoCompositing")]
446 #[unsafe(method(customVideoCompositorClass))]
447 #[unsafe(method_family = none)]
448 pub unsafe fn customVideoCompositorClass(&self) -> Option<&'static AnyClass>;
449
450 #[cfg(feature = "AVVideoCompositing")]
451 /// Setter for [`customVideoCompositorClass`][Self::customVideoCompositorClass].
452 #[unsafe(method(setCustomVideoCompositorClass:))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn setCustomVideoCompositorClass(
455 &self,
456 custom_video_compositor_class: Option<&AnyClass>,
457 );
458
459 #[cfg(feature = "objc2-core-media")]
460 #[unsafe(method(frameDuration))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn frameDuration(&self) -> CMTime;
463
464 #[cfg(feature = "objc2-core-media")]
465 /// Setter for [`frameDuration`][Self::frameDuration].
466 #[unsafe(method(setFrameDuration:))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn setFrameDuration(&self, frame_duration: CMTime);
469
470 #[cfg(feature = "objc2-core-media")]
471 #[unsafe(method(sourceTrackIDForFrameTiming))]
472 #[unsafe(method_family = none)]
473 pub unsafe fn sourceTrackIDForFrameTiming(&self) -> CMPersistentTrackID;
474
475 #[cfg(feature = "objc2-core-media")]
476 /// Setter for [`sourceTrackIDForFrameTiming`][Self::sourceTrackIDForFrameTiming].
477 #[unsafe(method(setSourceTrackIDForFrameTiming:))]
478 #[unsafe(method_family = none)]
479 pub unsafe fn setSourceTrackIDForFrameTiming(
480 &self,
481 source_track_id_for_frame_timing: CMPersistentTrackID,
482 );
483
484 #[cfg(feature = "objc2-core-foundation")]
485 #[unsafe(method(renderSize))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn renderSize(&self) -> CGSize;
488
489 #[cfg(feature = "objc2-core-foundation")]
490 /// Setter for [`renderSize`][Self::renderSize].
491 #[unsafe(method(setRenderSize:))]
492 #[unsafe(method_family = none)]
493 pub unsafe fn setRenderSize(&self, render_size: CGSize);
494
495 #[unsafe(method(renderScale))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn renderScale(&self) -> c_float;
498
499 /// Setter for [`renderScale`][Self::renderScale].
500 #[unsafe(method(setRenderScale:))]
501 #[unsafe(method_family = none)]
502 pub unsafe fn setRenderScale(&self, render_scale: c_float);
503
504 #[cfg(feature = "AVVideoCompositing")]
505 #[unsafe(method(instructions))]
506 #[unsafe(method_family = none)]
507 pub unsafe fn instructions(
508 &self,
509 ) -> Retained<NSArray<ProtocolObject<dyn AVVideoCompositionInstructionProtocol>>>;
510
511 #[cfg(feature = "AVVideoCompositing")]
512 /// Setter for [`instructions`][Self::instructions].
513 #[unsafe(method(setInstructions:))]
514 #[unsafe(method_family = none)]
515 pub unsafe fn setInstructions(
516 &self,
517 instructions: &NSArray<ProtocolObject<dyn AVVideoCompositionInstructionProtocol>>,
518 );
519
520 #[unsafe(method(animationTool))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn animationTool(&self)
523 -> Option<Retained<AVVideoCompositionCoreAnimationTool>>;
524
525 /// Setter for [`animationTool`][Self::animationTool].
526 #[unsafe(method(setAnimationTool:))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn setAnimationTool(
529 &self,
530 animation_tool: Option<&AVVideoCompositionCoreAnimationTool>,
531 );
532
533 #[unsafe(method(sourceSampleDataTrackIDs))]
534 #[unsafe(method_family = none)]
535 pub unsafe fn sourceSampleDataTrackIDs(&self) -> Retained<NSArray<NSNumber>>;
536
537 /// Setter for [`sourceSampleDataTrackIDs`][Self::sourceSampleDataTrackIDs].
538 #[unsafe(method(setSourceSampleDataTrackIDs:))]
539 #[unsafe(method_family = none)]
540 pub unsafe fn setSourceSampleDataTrackIDs(
541 &self,
542 source_sample_data_track_i_ds: &NSArray<NSNumber>,
543 );
544 );
545}
546
547/// Methods declared on superclass `NSObject`.
548impl AVMutableVideoComposition {
549 extern_methods!(
550 #[unsafe(method(init))]
551 #[unsafe(method_family = init)]
552 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
553
554 #[unsafe(method(new))]
555 #[unsafe(method_family = new)]
556 pub unsafe fn new() -> Retained<Self>;
557 );
558}
559
560/// AVMutableVideoCompositionColorimetery.
561impl AVMutableVideoComposition {
562 extern_methods!(
563 #[unsafe(method(colorPrimaries))]
564 #[unsafe(method_family = none)]
565 pub unsafe fn colorPrimaries(&self) -> Option<Retained<NSString>>;
566
567 /// Setter for [`colorPrimaries`][Self::colorPrimaries].
568 #[unsafe(method(setColorPrimaries:))]
569 #[unsafe(method_family = none)]
570 pub unsafe fn setColorPrimaries(&self, color_primaries: Option<&NSString>);
571
572 #[unsafe(method(colorYCbCrMatrix))]
573 #[unsafe(method_family = none)]
574 pub unsafe fn colorYCbCrMatrix(&self) -> Option<Retained<NSString>>;
575
576 /// Setter for [`colorYCbCrMatrix`][Self::colorYCbCrMatrix].
577 #[unsafe(method(setColorYCbCrMatrix:))]
578 #[unsafe(method_family = none)]
579 pub unsafe fn setColorYCbCrMatrix(&self, color_y_cb_cr_matrix: Option<&NSString>);
580
581 #[unsafe(method(colorTransferFunction))]
582 #[unsafe(method_family = none)]
583 pub unsafe fn colorTransferFunction(&self) -> Option<Retained<NSString>>;
584
585 /// Setter for [`colorTransferFunction`][Self::colorTransferFunction].
586 #[unsafe(method(setColorTransferFunction:))]
587 #[unsafe(method_family = none)]
588 pub unsafe fn setColorTransferFunction(&self, color_transfer_function: Option<&NSString>);
589
590 #[unsafe(method(perFrameHDRDisplayMetadataPolicy))]
591 #[unsafe(method_family = none)]
592 pub unsafe fn perFrameHDRDisplayMetadataPolicy(
593 &self,
594 ) -> Retained<AVVideoCompositionPerFrameHDRDisplayMetadataPolicy>;
595
596 /// Setter for [`perFrameHDRDisplayMetadataPolicy`][Self::perFrameHDRDisplayMetadataPolicy].
597 #[unsafe(method(setPerFrameHDRDisplayMetadataPolicy:))]
598 #[unsafe(method_family = none)]
599 pub unsafe fn setPerFrameHDRDisplayMetadataPolicy(
600 &self,
601 per_frame_hdr_display_metadata_policy: &AVVideoCompositionPerFrameHDRDisplayMetadataPolicy,
602 );
603 );
604}
605
606/// AVMutableVideoCompositionFiltering.
607impl AVMutableVideoComposition {
608 extern_methods!(
609 #[cfg(all(
610 feature = "AVAsset",
611 feature = "AVVideoCompositing",
612 feature = "block2"
613 ))]
614 /// Returns a new instance of AVMutableVideoComposition with values and instructions that will apply the specified handler block to video frames represented as instances of CIImage.
615 ///
616 /// Parameter `asset`: An instance of AVAsset. For best performance, ensure that the duration and tracks properties of the asset are already loaded before invoking this method.
617 ///
618 /// Returns: An instance of AVMutableVideoComposition.
619 ///
620 /// The returned AVMutableVideoComposition will cause the specified handler block to be called to filter each frame of the asset's first enabled video track. The handler block should use the properties of the provided AVAsynchronousCIImageFilteringRequest and respond using finishWithImage:context: with a "filtered" new CIImage (or the provided source image for no affect). In the event of an error, respond to the request using finishWithError:. The error can be observed via AVPlayerItemFailedToPlayToEndTimeNotification, see AVPlayerItemFailedToPlayToEndTimeErrorKey in notification payload. The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to an appropriate value in order to specify the maximum output frame rate independent of the source track timing.
621 ///
622 /// The video composition will also have the following values for its properties:
623 ///
624 /// - The original timing of the asset's first enabled video track will be used.
625 /// - A renderSize that encompasses the asset's first enabled video track respecting the track's preferredTransform.
626 /// - A renderScale of 1.0.
627 ///
628 /// The default CIContext has the following properties:
629 ///
630 /// - iOS: Device RGB color space
631 /// - macOS: sRGB color space
632 ///
633 /// Example usage:
634 ///
635 /// playerItem.videoComposition = [AVMutableVideoComposition videoCompositionWithAsset:srcAsset applyingCIFiltersWithHandler:
636 /// ^(AVAsynchronousCIImageFilteringRequest *request)
637 /// {
638 /// NSError *err = nil;
639 /// CIImage *filtered = myRenderer(request,
640 /// &err
641 /// );
642 /// if (filtered)
643 /// [request finishWithImage:filtered context:nil];
644 /// else
645 /// [request finishWithError:err];
646 /// }];
647 #[deprecated = "Use videoCompositionWithAsset:applyingCIFiltersWithHandler:completionHandler: instead"]
648 #[unsafe(method(videoCompositionWithAsset:applyingCIFiltersWithHandler:))]
649 #[unsafe(method_family = none)]
650 pub unsafe fn videoCompositionWithAsset_applyingCIFiltersWithHandler(
651 asset: &AVAsset,
652 applier: &block2::DynBlock<dyn Fn(NonNull<AVAsynchronousCIImageFilteringRequest>)>,
653 ) -> Retained<AVMutableVideoComposition>;
654
655 #[cfg(all(
656 feature = "AVAsset",
657 feature = "AVVideoCompositing",
658 feature = "block2"
659 ))]
660 /// Vends a new instance of AVMutableVideoComposition with values and instructions that will apply the specified handler block to video frames represented as instances of CIImage.
661 ///
662 /// Parameter `asset`: An instance of AVAsset.
663 ///
664 /// Parameter `completionHandler`: A block that is invoked when the new video composition has finished being created. If the `videoComposition` parameter is nil, the `error` parameter describes the failure that occurred.
665 ///
666 /// The new AVMutableVideoComposition will cause the specified handler block to be called to filter each frame of the asset's first enabled video track. The handler block should use the properties of the provided AVAsynchronousCIImageFilteringRequest and respond using finishWithImage:context: with a "filtered" new CIImage (or the provided source image for no affect). In the event of an error, respond to the request using finishWithError:. The error can be observed via AVPlayerItemFailedToPlayToEndTimeNotification, see AVPlayerItemFailedToPlayToEndTimeErrorKey in notification payload. The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to an appropriate value in order to specify the maximum output frame rate independent of the source track timing.
667 ///
668 /// The video composition will also have the following values for its properties:
669 ///
670 /// - The original timing of the asset's first enabled video track will be used.
671 /// - A renderSize that encompasses the asset's first enabled video track respecting the track's preferredTransform.
672 /// - A renderScale of 1.0.
673 ///
674 /// The default CIContext has the following properties:
675 ///
676 /// - iOS: Device RGB color space
677 /// - macOS: sRGB color space
678 ///
679 /// Example usage:
680 ///
681 /// [AVMutableVideoComposition videoCompositionWithAsset:srcAsset applyingCIFiltersWithHandler:
682 /// ^(AVAsynchronousCIImageFilteringRequest *request)
683 /// {
684 /// NSError *err = nil;
685 /// CIImage *filtered = myRenderer(request,
686 /// &err
687 /// );
688 /// if (filtered)
689 /// [request finishWithImage:filtered context:nil];
690 /// else
691 /// [request finishWithError:err];
692 /// } completionHandler:
693 /// ^(AVMutableVideoComposition * _Nullable videoComposition, NSError * _Nullable error)
694 /// {
695 /// if (videoComposition != nil) {
696 /// playerItem.videoComposition = videoComposition
697 /// else {
698 /// // handle error
699 /// }];
700 #[unsafe(method(videoCompositionWithAsset:applyingCIFiltersWithHandler:completionHandler:))]
701 #[unsafe(method_family = none)]
702 pub unsafe fn videoCompositionWithAsset_applyingCIFiltersWithHandler_completionHandler(
703 asset: &AVAsset,
704 applier: &block2::DynBlock<dyn Fn(NonNull<AVAsynchronousCIImageFilteringRequest>)>,
705 completion_handler: &block2::DynBlock<
706 dyn Fn(*mut AVMutableVideoComposition, *mut NSError),
707 >,
708 );
709 );
710}
711
712extern_class!(
713 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositioninstruction?language=objc)
714 #[unsafe(super(NSObject))]
715 #[derive(Debug, PartialEq, Eq, Hash)]
716 pub struct AVVideoCompositionInstruction;
717);
718
719#[cfg(feature = "AVVideoCompositing")]
720extern_conformance!(
721 unsafe impl AVVideoCompositionInstructionProtocol for AVVideoCompositionInstruction {}
722);
723
724extern_conformance!(
725 unsafe impl NSCoding for AVVideoCompositionInstruction {}
726);
727
728extern_conformance!(
729 unsafe impl NSCopying for AVVideoCompositionInstruction {}
730);
731
732unsafe impl CopyingHelper for AVVideoCompositionInstruction {
733 type Result = Self;
734}
735
736extern_conformance!(
737 unsafe impl NSMutableCopying for AVVideoCompositionInstruction {}
738);
739
740unsafe impl MutableCopyingHelper for AVVideoCompositionInstruction {
741 type Result = AVMutableVideoCompositionInstruction;
742}
743
744extern_conformance!(
745 unsafe impl NSObjectProtocol for AVVideoCompositionInstruction {}
746);
747
748extern_conformance!(
749 unsafe impl NSSecureCoding for AVVideoCompositionInstruction {}
750);
751
752impl AVVideoCompositionInstruction {
753 extern_methods!(
754 #[cfg(feature = "objc2-core-media")]
755 #[unsafe(method(timeRange))]
756 #[unsafe(method_family = none)]
757 pub unsafe fn timeRange(&self) -> CMTimeRange;
758
759 #[cfg(feature = "objc2-core-graphics")]
760 #[unsafe(method(backgroundColor))]
761 #[unsafe(method_family = none)]
762 pub unsafe fn backgroundColor(&self) -> Option<Retained<CGColor>>;
763
764 #[unsafe(method(layerInstructions))]
765 #[unsafe(method_family = none)]
766 pub unsafe fn layerInstructions(
767 &self,
768 ) -> Retained<NSArray<AVVideoCompositionLayerInstruction>>;
769
770 #[unsafe(method(enablePostProcessing))]
771 #[unsafe(method_family = none)]
772 pub unsafe fn enablePostProcessing(&self) -> bool;
773
774 #[unsafe(method(requiredSourceTrackIDs))]
775 #[unsafe(method_family = none)]
776 pub unsafe fn requiredSourceTrackIDs(&self) -> Retained<NSArray<NSValue>>;
777
778 #[cfg(feature = "objc2-core-media")]
779 #[unsafe(method(passthroughTrackID))]
780 #[unsafe(method_family = none)]
781 pub unsafe fn passthroughTrackID(&self) -> CMPersistentTrackID;
782
783 #[unsafe(method(requiredSourceSampleDataTrackIDs))]
784 #[unsafe(method_family = none)]
785 pub unsafe fn requiredSourceSampleDataTrackIDs(&self) -> Retained<NSArray<NSNumber>>;
786 );
787}
788
789/// Methods declared on superclass `NSObject`.
790impl AVVideoCompositionInstruction {
791 extern_methods!(
792 #[unsafe(method(init))]
793 #[unsafe(method_family = init)]
794 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
795
796 #[unsafe(method(new))]
797 #[unsafe(method_family = new)]
798 pub unsafe fn new() -> Retained<Self>;
799 );
800}
801
802extern_class!(
803 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablevideocompositioninstruction?language=objc)
804 #[unsafe(super(AVVideoCompositionInstruction, NSObject))]
805 #[derive(Debug, PartialEq, Eq, Hash)]
806 pub struct AVMutableVideoCompositionInstruction;
807);
808
809#[cfg(feature = "AVVideoCompositing")]
810extern_conformance!(
811 unsafe impl AVVideoCompositionInstructionProtocol for AVMutableVideoCompositionInstruction {}
812);
813
814extern_conformance!(
815 unsafe impl NSCoding for AVMutableVideoCompositionInstruction {}
816);
817
818extern_conformance!(
819 unsafe impl NSCopying for AVMutableVideoCompositionInstruction {}
820);
821
822unsafe impl CopyingHelper for AVMutableVideoCompositionInstruction {
823 type Result = AVVideoCompositionInstruction;
824}
825
826extern_conformance!(
827 unsafe impl NSMutableCopying for AVMutableVideoCompositionInstruction {}
828);
829
830unsafe impl MutableCopyingHelper for AVMutableVideoCompositionInstruction {
831 type Result = Self;
832}
833
834extern_conformance!(
835 unsafe impl NSObjectProtocol for AVMutableVideoCompositionInstruction {}
836);
837
838extern_conformance!(
839 unsafe impl NSSecureCoding for AVMutableVideoCompositionInstruction {}
840);
841
842impl AVMutableVideoCompositionInstruction {
843 extern_methods!(
844 #[unsafe(method(videoCompositionInstruction))]
845 #[unsafe(method_family = none)]
846 pub unsafe fn videoCompositionInstruction() -> Retained<Self>;
847
848 #[cfg(feature = "objc2-core-media")]
849 #[unsafe(method(timeRange))]
850 #[unsafe(method_family = none)]
851 pub unsafe fn timeRange(&self) -> CMTimeRange;
852
853 #[cfg(feature = "objc2-core-media")]
854 /// Setter for [`timeRange`][Self::timeRange].
855 #[unsafe(method(setTimeRange:))]
856 #[unsafe(method_family = none)]
857 pub unsafe fn setTimeRange(&self, time_range: CMTimeRange);
858
859 #[cfg(feature = "objc2-core-graphics")]
860 #[unsafe(method(backgroundColor))]
861 #[unsafe(method_family = none)]
862 pub unsafe fn backgroundColor(&self) -> Option<Retained<CGColor>>;
863
864 #[cfg(feature = "objc2-core-graphics")]
865 /// Setter for [`backgroundColor`][Self::backgroundColor].
866 #[unsafe(method(setBackgroundColor:))]
867 #[unsafe(method_family = none)]
868 pub unsafe fn setBackgroundColor(&self, background_color: Option<&CGColor>);
869
870 #[unsafe(method(layerInstructions))]
871 #[unsafe(method_family = none)]
872 pub unsafe fn layerInstructions(
873 &self,
874 ) -> Retained<NSArray<AVVideoCompositionLayerInstruction>>;
875
876 /// Setter for [`layerInstructions`][Self::layerInstructions].
877 #[unsafe(method(setLayerInstructions:))]
878 #[unsafe(method_family = none)]
879 pub unsafe fn setLayerInstructions(
880 &self,
881 layer_instructions: &NSArray<AVVideoCompositionLayerInstruction>,
882 );
883
884 #[unsafe(method(enablePostProcessing))]
885 #[unsafe(method_family = none)]
886 pub unsafe fn enablePostProcessing(&self) -> bool;
887
888 /// Setter for [`enablePostProcessing`][Self::enablePostProcessing].
889 #[unsafe(method(setEnablePostProcessing:))]
890 #[unsafe(method_family = none)]
891 pub unsafe fn setEnablePostProcessing(&self, enable_post_processing: bool);
892
893 #[unsafe(method(requiredSourceSampleDataTrackIDs))]
894 #[unsafe(method_family = none)]
895 pub unsafe fn requiredSourceSampleDataTrackIDs(&self) -> Retained<NSArray<NSNumber>>;
896
897 /// Setter for [`requiredSourceSampleDataTrackIDs`][Self::requiredSourceSampleDataTrackIDs].
898 #[unsafe(method(setRequiredSourceSampleDataTrackIDs:))]
899 #[unsafe(method_family = none)]
900 pub unsafe fn setRequiredSourceSampleDataTrackIDs(
901 &self,
902 required_source_sample_data_track_i_ds: &NSArray<NSNumber>,
903 );
904 );
905}
906
907/// Methods declared on superclass `NSObject`.
908impl AVMutableVideoCompositionInstruction {
909 extern_methods!(
910 #[unsafe(method(init))]
911 #[unsafe(method_family = init)]
912 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
913
914 #[unsafe(method(new))]
915 #[unsafe(method_family = new)]
916 pub unsafe fn new() -> Retained<Self>;
917 );
918}
919
920extern_class!(
921 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositionlayerinstruction?language=objc)
922 #[unsafe(super(NSObject))]
923 #[derive(Debug, PartialEq, Eq, Hash)]
924 pub struct AVVideoCompositionLayerInstruction;
925);
926
927extern_conformance!(
928 unsafe impl NSCoding for AVVideoCompositionLayerInstruction {}
929);
930
931extern_conformance!(
932 unsafe impl NSCopying for AVVideoCompositionLayerInstruction {}
933);
934
935unsafe impl CopyingHelper for AVVideoCompositionLayerInstruction {
936 type Result = Self;
937}
938
939extern_conformance!(
940 unsafe impl NSMutableCopying for AVVideoCompositionLayerInstruction {}
941);
942
943unsafe impl MutableCopyingHelper for AVVideoCompositionLayerInstruction {
944 type Result = AVMutableVideoCompositionLayerInstruction;
945}
946
947extern_conformance!(
948 unsafe impl NSObjectProtocol for AVVideoCompositionLayerInstruction {}
949);
950
951extern_conformance!(
952 unsafe impl NSSecureCoding for AVVideoCompositionLayerInstruction {}
953);
954
955impl AVVideoCompositionLayerInstruction {
956 extern_methods!(
957 #[cfg(feature = "objc2-core-media")]
958 #[unsafe(method(trackID))]
959 #[unsafe(method_family = none)]
960 pub unsafe fn trackID(&self) -> CMPersistentTrackID;
961
962 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
963 #[unsafe(method(getTransformRampForTime:startTransform:endTransform:timeRange:))]
964 #[unsafe(method_family = none)]
965 pub unsafe fn getTransformRampForTime_startTransform_endTransform_timeRange(
966 &self,
967 time: CMTime,
968 start_transform: *mut CGAffineTransform,
969 end_transform: *mut CGAffineTransform,
970 time_range: *mut CMTimeRange,
971 ) -> bool;
972
973 #[cfg(feature = "objc2-core-media")]
974 #[unsafe(method(getOpacityRampForTime:startOpacity:endOpacity:timeRange:))]
975 #[unsafe(method_family = none)]
976 pub unsafe fn getOpacityRampForTime_startOpacity_endOpacity_timeRange(
977 &self,
978 time: CMTime,
979 start_opacity: *mut c_float,
980 end_opacity: *mut c_float,
981 time_range: *mut CMTimeRange,
982 ) -> bool;
983
984 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
985 #[unsafe(method(getCropRectangleRampForTime:startCropRectangle:endCropRectangle:timeRange:))]
986 #[unsafe(method_family = none)]
987 pub unsafe fn getCropRectangleRampForTime_startCropRectangle_endCropRectangle_timeRange(
988 &self,
989 time: CMTime,
990 start_crop_rectangle: *mut CGRect,
991 end_crop_rectangle: *mut CGRect,
992 time_range: *mut CMTimeRange,
993 ) -> bool;
994 );
995}
996
997/// Methods declared on superclass `NSObject`.
998impl AVVideoCompositionLayerInstruction {
999 extern_methods!(
1000 #[unsafe(method(init))]
1001 #[unsafe(method_family = init)]
1002 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1003
1004 #[unsafe(method(new))]
1005 #[unsafe(method_family = new)]
1006 pub unsafe fn new() -> Retained<Self>;
1007 );
1008}
1009
1010extern_class!(
1011 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablevideocompositionlayerinstruction?language=objc)
1012 #[unsafe(super(AVVideoCompositionLayerInstruction, NSObject))]
1013 #[derive(Debug, PartialEq, Eq, Hash)]
1014 pub struct AVMutableVideoCompositionLayerInstruction;
1015);
1016
1017extern_conformance!(
1018 unsafe impl NSCoding for AVMutableVideoCompositionLayerInstruction {}
1019);
1020
1021extern_conformance!(
1022 unsafe impl NSCopying for AVMutableVideoCompositionLayerInstruction {}
1023);
1024
1025unsafe impl CopyingHelper for AVMutableVideoCompositionLayerInstruction {
1026 type Result = AVVideoCompositionInstruction;
1027}
1028
1029extern_conformance!(
1030 unsafe impl NSMutableCopying for AVMutableVideoCompositionLayerInstruction {}
1031);
1032
1033unsafe impl MutableCopyingHelper for AVMutableVideoCompositionLayerInstruction {
1034 type Result = Self;
1035}
1036
1037extern_conformance!(
1038 unsafe impl NSObjectProtocol for AVMutableVideoCompositionLayerInstruction {}
1039);
1040
1041extern_conformance!(
1042 unsafe impl NSSecureCoding for AVMutableVideoCompositionLayerInstruction {}
1043);
1044
1045impl AVMutableVideoCompositionLayerInstruction {
1046 extern_methods!(
1047 #[cfg(feature = "AVAssetTrack")]
1048 #[unsafe(method(videoCompositionLayerInstructionWithAssetTrack:))]
1049 #[unsafe(method_family = none)]
1050 pub unsafe fn videoCompositionLayerInstructionWithAssetTrack(
1051 track: &AVAssetTrack,
1052 ) -> Retained<Self>;
1053
1054 #[unsafe(method(videoCompositionLayerInstruction))]
1055 #[unsafe(method_family = none)]
1056 pub unsafe fn videoCompositionLayerInstruction() -> Retained<Self>;
1057
1058 #[cfg(feature = "objc2-core-media")]
1059 #[unsafe(method(trackID))]
1060 #[unsafe(method_family = none)]
1061 pub unsafe fn trackID(&self) -> CMPersistentTrackID;
1062
1063 #[cfg(feature = "objc2-core-media")]
1064 /// Setter for [`trackID`][Self::trackID].
1065 #[unsafe(method(setTrackID:))]
1066 #[unsafe(method_family = none)]
1067 pub unsafe fn setTrackID(&self, track_id: CMPersistentTrackID);
1068
1069 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
1070 #[unsafe(method(setTransformRampFromStartTransform:toEndTransform:timeRange:))]
1071 #[unsafe(method_family = none)]
1072 pub unsafe fn setTransformRampFromStartTransform_toEndTransform_timeRange(
1073 &self,
1074 start_transform: CGAffineTransform,
1075 end_transform: CGAffineTransform,
1076 time_range: CMTimeRange,
1077 );
1078
1079 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
1080 #[unsafe(method(setTransform:atTime:))]
1081 #[unsafe(method_family = none)]
1082 pub unsafe fn setTransform_atTime(&self, transform: CGAffineTransform, time: CMTime);
1083
1084 #[cfg(feature = "objc2-core-media")]
1085 #[unsafe(method(setOpacityRampFromStartOpacity:toEndOpacity:timeRange:))]
1086 #[unsafe(method_family = none)]
1087 pub unsafe fn setOpacityRampFromStartOpacity_toEndOpacity_timeRange(
1088 &self,
1089 start_opacity: c_float,
1090 end_opacity: c_float,
1091 time_range: CMTimeRange,
1092 );
1093
1094 #[cfg(feature = "objc2-core-media")]
1095 #[unsafe(method(setOpacity:atTime:))]
1096 #[unsafe(method_family = none)]
1097 pub unsafe fn setOpacity_atTime(&self, opacity: c_float, time: CMTime);
1098
1099 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
1100 #[unsafe(method(setCropRectangleRampFromStartCropRectangle:toEndCropRectangle:timeRange:))]
1101 #[unsafe(method_family = none)]
1102 pub unsafe fn setCropRectangleRampFromStartCropRectangle_toEndCropRectangle_timeRange(
1103 &self,
1104 start_crop_rectangle: CGRect,
1105 end_crop_rectangle: CGRect,
1106 time_range: CMTimeRange,
1107 );
1108
1109 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
1110 #[unsafe(method(setCropRectangle:atTime:))]
1111 #[unsafe(method_family = none)]
1112 pub unsafe fn setCropRectangle_atTime(&self, crop_rectangle: CGRect, time: CMTime);
1113 );
1114}
1115
1116/// Methods declared on superclass `NSObject`.
1117impl AVMutableVideoCompositionLayerInstruction {
1118 extern_methods!(
1119 #[unsafe(method(init))]
1120 #[unsafe(method_family = init)]
1121 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1122
1123 #[unsafe(method(new))]
1124 #[unsafe(method_family = new)]
1125 pub unsafe fn new() -> Retained<Self>;
1126 );
1127}
1128
1129extern_class!(
1130 /// An AVVideoComposition object represents an immutable video composition.
1131 ///
1132 ///
1133 /// A video composition describes, for any time in the aggregate time range of its instructions, the number and IDs of video tracks that are to be used in order to produce a composed video frame corresponding to that time. When AVFoundation's built-in video compositor is used, the instructions an AVVideoComposition contain can specify a spatial transformation, an opacity value, and a cropping rectangle for each video source, and these can vary over time via simple linear ramping functions.
1134 ///
1135 /// A client can implement their own custom video compositor by implementing the AVVideoCompositing protocol; a custom video compositor is provided with pixel buffers for each of its video sources during playback and other operations and can perform arbitrary graphical operations on them in order to produce visual output.
1136 ///
1137 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositioncoreanimationtool?language=objc)
1138 #[unsafe(super(NSObject))]
1139 #[derive(Debug, PartialEq, Eq, Hash)]
1140 pub struct AVVideoCompositionCoreAnimationTool;
1141);
1142
1143extern_conformance!(
1144 unsafe impl NSObjectProtocol for AVVideoCompositionCoreAnimationTool {}
1145);
1146
1147impl AVVideoCompositionCoreAnimationTool {
1148 extern_methods!(
1149 #[cfg(all(feature = "objc2-core-media", feature = "objc2-quartz-core"))]
1150 #[cfg(not(target_os = "watchos"))]
1151 /// Add a Core Animation layer to the video composition
1152 ///
1153 /// Include a Core Animation layer as an individual track input in video composition.
1154 /// This layer should not come from, or be added to, another layer tree.
1155 /// trackID should not match any real trackID in the source. Use -[AVAsset unusedTrackID]
1156 /// to obtain a trackID that's guaranteed not to coincide with the trackID of any track of the asset.
1157 /// AVVideoCompositionInstructions should reference trackID where the rendered animation should be included.
1158 /// For best performance, no transform should be set in the AVVideoCompositionLayerInstruction for this trackID.
1159 /// Be aware that on iOS, CALayers backing a UIView usually have their content flipped (as defined by the
1160 /// -contentsAreFlipped method). It may be required to insert a CALayer with its geometryFlipped property set
1161 /// to YES in the layer hierarchy to get the same result when attaching a CALayer to a AVVideoCompositionCoreAnimationTool
1162 /// as when using it to back a UIView.
1163 #[unsafe(method(videoCompositionCoreAnimationToolWithAdditionalLayer:asTrackID:))]
1164 #[unsafe(method_family = none)]
1165 pub unsafe fn videoCompositionCoreAnimationToolWithAdditionalLayer_asTrackID(
1166 layer: &CALayer,
1167 track_id: CMPersistentTrackID,
1168 ) -> Retained<Self>;
1169
1170 #[cfg(feature = "objc2-quartz-core")]
1171 #[cfg(not(target_os = "watchos"))]
1172 /// Compose the composited video frames with the Core Animation layer
1173 ///
1174 /// Place composited video frames in videoLayer and render animationLayer
1175 /// to produce the final frame. Normally videoLayer should be in animationLayer's sublayer tree.
1176 /// The animationLayer should not come from, or be added to, another layer tree.
1177 /// Be aware that on iOS, CALayers backing a UIView usually have their content flipped (as defined by the
1178 /// -contentsAreFlipped method). It may be required to insert a CALayer with its geometryFlipped property set
1179 /// to YES in the layer hierarchy to get the same result when attaching a CALayer to a AVVideoCompositionCoreAnimationTool
1180 /// as when using it to back a UIView.
1181 #[unsafe(method(videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:inLayer:))]
1182 #[unsafe(method_family = none)]
1183 pub unsafe fn videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer_inLayer(
1184 video_layer: &CALayer,
1185 animation_layer: &CALayer,
1186 ) -> Retained<Self>;
1187
1188 #[cfg(feature = "objc2-quartz-core")]
1189 #[cfg(not(target_os = "watchos"))]
1190 /// Compose the composited video frames with the Core Animation layer
1191 ///
1192 /// Duplicate the composited video frames in each videoLayer and render animationLayer
1193 /// to produce the final frame. Normally videoLayers should be in animationLayer's sublayer tree.
1194 /// The animationLayer should not come from, or be added to, another layer tree.
1195 /// Be aware that on iOS, CALayers backing a UIView usually have their content flipped (as defined by the
1196 /// -contentsAreFlipped method). It may be required to insert a CALayer with its geometryFlipped property set
1197 /// to YES in the layer hierarchy to get the same result when attaching a CALayer to a AVVideoCompositionCoreAnimationTool
1198 /// as when using it to back a UIView.
1199 #[unsafe(method(videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayers:inLayer:))]
1200 #[unsafe(method_family = none)]
1201 pub unsafe fn videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayers_inLayer(
1202 video_layers: &NSArray<CALayer>,
1203 animation_layer: &CALayer,
1204 ) -> Retained<Self>;
1205 );
1206}
1207
1208/// Methods declared on superclass `NSObject`.
1209impl AVVideoCompositionCoreAnimationTool {
1210 extern_methods!(
1211 #[unsafe(method(init))]
1212 #[unsafe(method_family = init)]
1213 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1214
1215 #[unsafe(method(new))]
1216 #[unsafe(method_family = new)]
1217 pub unsafe fn new() -> Retained<Self>;
1218 );
1219}
1220
1221/// AVAssetVideoCompositionUtility.
1222#[cfg(feature = "AVAsset")]
1223impl AVAsset {
1224 extern_methods!(
1225 #[cfg(feature = "objc2-core-media")]
1226 #[deprecated = "Use findUnusedTrackIDWithCompletionHandler: instead"]
1227 #[unsafe(method(unusedTrackID))]
1228 #[unsafe(method_family = none)]
1229 pub unsafe fn unusedTrackID(&self) -> CMPersistentTrackID;
1230
1231 #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
1232 /// Loads a track ID that will not collide with any existing track
1233 ///
1234 /// Parameter `completionHandler`: A block that is invoked when loading is complete, vending the track ID or an error.
1235 #[unsafe(method(findUnusedTrackIDWithCompletionHandler:))]
1236 #[unsafe(method_family = none)]
1237 pub unsafe fn findUnusedTrackIDWithCompletionHandler(
1238 &self,
1239 completion_handler: &block2::DynBlock<dyn Fn(CMPersistentTrackID, *mut NSError)>,
1240 );
1241 );
1242}
1243
1244/// AVVideoCompositionValidation.
1245impl AVVideoComposition {
1246 extern_methods!(
1247 #[cfg(all(feature = "AVAsset", feature = "objc2-core-media"))]
1248 /// Indicates whether the timeRanges of the receiver's instructions conform to the requirements described for them immediately above (in connection with the instructions property) and also whether all of the layer instructions have a value for trackID that corresponds either to a track of the specified asset or to the receiver's animationTool.
1249 ///
1250 /// Parameter `asset`: Pass a reference to an AVAsset if you wish to validate the timeRanges of the instructions against the duration of the asset and the trackIDs of the layer instructions against the asset's tracks. Pass nil to skip that validation. Clients should ensure that the keys
1251 /// "
1252 /// tracks" and @"duration" are already loaded on the AVAsset before validation is attempted.
1253 ///
1254 /// Parameter `timeRange`: A CMTimeRange. Only those instructions with timeRanges that overlap with the specified timeRange will be validated. To validate all instructions that may be used for playback or other processing, regardless of timeRange, pass CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity).
1255 ///
1256 /// Parameter `validationDelegate`: Indicates an object implementing the AVVideoCompositionValidationHandling protocol to receive information about troublesome portions of a video composition during processing of -isValidForAsset:. May be nil.
1257 ///
1258 /// In the course of validation, the receiver will invoke its validationDelegate with reference to any trouble spots in the video composition.
1259 /// An exception will be raised if the delegate modifies the receiver's array of instructions or the array of layerInstructions of any AVVideoCompositionInstruction contained therein during validation.
1260 #[deprecated = "Use isValidForTracks:assetDuration:timeRange:validationDelegate: instead"]
1261 #[unsafe(method(isValidForAsset:timeRange:validationDelegate:))]
1262 #[unsafe(method_family = none)]
1263 pub unsafe fn isValidForAsset_timeRange_validationDelegate(
1264 &self,
1265 asset: Option<&AVAsset>,
1266 time_range: CMTimeRange,
1267 validation_delegate: Option<&ProtocolObject<dyn AVVideoCompositionValidationHandling>>,
1268 ) -> bool;
1269
1270 #[cfg(all(feature = "AVAsset", feature = "block2", feature = "objc2-core-media"))]
1271 /// Determines whether the timeRanges of the receiver's instructions conform to the requirements described for them immediately above (in connection with the instructions property) and also whether all of the layer instructions have a value for trackID that corresponds either to a track of the specified asset or to the receiver's animationTool.
1272 ///
1273 /// Parameter `asset`: Pass a reference to an AVAsset if you wish to validate the timeRanges of the instructions against the duration of the asset and the trackIDs of the layer instructions against the asset's tracks. Pass nil to skip that validation.
1274 ///
1275 /// Parameter `timeRange`: A CMTimeRange. Only those instructions with timeRanges that overlap with the specified timeRange will be validated. To validate all instructions that may be used for playback or other processing, regardless of timeRange, pass CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity).
1276 ///
1277 /// Parameter `validationDelegate`: Indicates an object implementing the AVVideoCompositionValidationHandling protocol to receive information about troublesome portions of a video composition during processing of -determineValidityForAsset:. May be nil.
1278 ///
1279 /// Parameter `completionHandler`: A block that is invoked when a determination is made about whether the video composition is valid. If the `isValid` parameter is NO, either the video composition is not valid, in which case the `error` parameter will be nil, or the answer could not be determined, in which case the `error` parameter will be non-nil and describe the failure that occurred.
1280 ///
1281 /// In the course of validation, the receiver will invoke its validationDelegate with reference to any trouble spots in the video composition.
1282 /// An exception will be raised if the delegate modifies the receiver's array of instructions or the array of layerInstructions of any AVVideoCompositionInstruction contained therein during validation.
1283 #[deprecated]
1284 #[unsafe(method(determineValidityForAsset:timeRange:validationDelegate:completionHandler:))]
1285 #[unsafe(method_family = none)]
1286 pub unsafe fn determineValidityForAsset_timeRange_validationDelegate_completionHandler(
1287 &self,
1288 asset: Option<&AVAsset>,
1289 time_range: CMTimeRange,
1290 validation_delegate: Option<&ProtocolObject<dyn AVVideoCompositionValidationHandling>>,
1291 completion_handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
1292 );
1293
1294 #[cfg(all(feature = "AVAssetTrack", feature = "objc2-core-media"))]
1295 /// Indicates whether the timeRanges of the receiver's instructions conform to the requirements described for them immediately above (in connection with the instructions property) and also whether all of the layer instructions have a value for trackID that corresponds either to a track of the specified asset or to the receiver's animationTool.
1296 ///
1297 /// Parameter `tracks`: Pass a reference to an AVAsset's tracks if you wish to validate the trackIDs of the layer instructions against the asset's tracks. Pass nil to skip that validation. This method throws an exception if the tracks are not all from the same asset.
1298 ///
1299 /// Parameter `duration`: Pass an AVAsset if you wish to validate the timeRanges of the instructions against the duration of the asset. Pass kCMTimeInvalid to skip that validation.
1300 ///
1301 /// Parameter `timeRange`: A CMTimeRange. Only those instructions with timeRanges that overlap with the specified timeRange will be validated. To validate all instructions that may be used for playback or other processing, regardless of timeRange, pass CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity).
1302 ///
1303 /// Parameter `validationDelegate`: Indicates an object implementing the AVVideoCompositionValidationHandling protocol to receive information about troublesome portions of a video composition during processing of -isValidForAsset:. May be nil.
1304 ///
1305 /// In the course of validation, the receiver will invoke its validationDelegate with reference to any trouble spots in the video composition.
1306 /// An exception will be raised if the delegate modifies the receiver's array of instructions or the array of layerInstructions of any AVVideoCompositionInstruction contained therein during validation.
1307 #[unsafe(method(isValidForTracks:assetDuration:timeRange:validationDelegate:))]
1308 #[unsafe(method_family = none)]
1309 pub unsafe fn isValidForTracks_assetDuration_timeRange_validationDelegate(
1310 &self,
1311 tracks: &NSArray<AVAssetTrack>,
1312 duration: CMTime,
1313 time_range: CMTimeRange,
1314 validation_delegate: Option<&ProtocolObject<dyn AVVideoCompositionValidationHandling>>,
1315 ) -> bool;
1316 );
1317}
1318
1319extern_protocol!(
1320 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideocompositionvalidationhandling?language=objc)
1321 pub unsafe trait AVVideoCompositionValidationHandling: NSObjectProtocol {
1322 /// Invoked by an instance of AVVideoComposition when validating an instance of AVVideoComposition, to report a key that has an invalid value.
1323 ///
1324 /// Returns: An indication of whether the AVVideoComposition should continue validation in order to report additional problems that may exist.
1325 #[optional]
1326 #[unsafe(method(videoComposition:shouldContinueValidatingAfterFindingInvalidValueForKey:))]
1327 #[unsafe(method_family = none)]
1328 unsafe fn videoComposition_shouldContinueValidatingAfterFindingInvalidValueForKey(
1329 &self,
1330 video_composition: &AVVideoComposition,
1331 key: &NSString,
1332 ) -> bool;
1333
1334 #[cfg(feature = "objc2-core-media")]
1335 /// Invoked by an instance of AVVideoComposition when validating an instance of AVVideoComposition, to report a timeRange that has no corresponding video composition instruction.
1336 ///
1337 /// Returns: An indication of whether the AVVideoComposition should continue validation in order to report additional problems that may exist.
1338 #[optional]
1339 #[unsafe(method(videoComposition:shouldContinueValidatingAfterFindingEmptyTimeRange:))]
1340 #[unsafe(method_family = none)]
1341 unsafe fn videoComposition_shouldContinueValidatingAfterFindingEmptyTimeRange(
1342 &self,
1343 video_composition: &AVVideoComposition,
1344 time_range: CMTimeRange,
1345 ) -> bool;
1346
1347 #[cfg(feature = "AVVideoCompositing")]
1348 /// Invoked by an instance of AVVideoComposition when validating an instance of AVVideoComposition, to report a video composition instruction with a timeRange that's invalid, that overlaps with the timeRange of a prior instruction, or that contains times earlier than the timeRange of a prior instruction.
1349 ///
1350 /// Use CMTIMERANGE_IS_INVALID, defined in CMTimeRange.h, to test whether the timeRange itself is invalid. Refer to headerdoc for AVVideoComposition.instructions for a discussion of how timeRanges for instructions must be formulated.
1351 ///
1352 /// Returns: An indication of whether the AVVideoComposition should continue validation in order to report additional problems that may exist.
1353 #[optional]
1354 #[unsafe(method(videoComposition:shouldContinueValidatingAfterFindingInvalidTimeRangeInInstruction:))]
1355 #[unsafe(method_family = none)]
1356 unsafe fn videoComposition_shouldContinueValidatingAfterFindingInvalidTimeRangeInInstruction(
1357 &self,
1358 video_composition: &AVVideoComposition,
1359 video_composition_instruction: &ProtocolObject<
1360 dyn AVVideoCompositionInstructionProtocol,
1361 >,
1362 ) -> bool;
1363
1364 #[cfg(all(feature = "AVAsset", feature = "AVVideoCompositing"))]
1365 /// Invoked by an instance of AVVideoComposition when validating an instance of AVVideoComposition, to report a video composition layer instruction with a trackID that does not correspond either to the trackID used for the composition's animationTool or to a track of the asset specified in -[AVVideoComposition isValidForAsset:timeRange:delegate:].
1366 ///
1367 /// Returns: An indication of whether the AVVideoComposition should continue validation in order to report additional problems that may exist.
1368 #[optional]
1369 #[unsafe(method(videoComposition:shouldContinueValidatingAfterFindingInvalidTrackIDInInstruction:layerInstruction:asset:))]
1370 #[unsafe(method_family = none)]
1371 unsafe fn videoComposition_shouldContinueValidatingAfterFindingInvalidTrackIDInInstruction_layerInstruction_asset(
1372 &self,
1373 video_composition: &AVVideoComposition,
1374 video_composition_instruction: &ProtocolObject<
1375 dyn AVVideoCompositionInstructionProtocol,
1376 >,
1377 layer_instruction: &AVVideoCompositionLayerInstruction,
1378 asset: &AVAsset,
1379 ) -> bool;
1380 }
1381);