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