objc2_av_foundation/generated/AVAssetImageGenerator.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
14use crate::*;
15
16/// The type of an aperture mode.
17///
18/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratoraperturemode?language=objc)
19// NS_TYPED_ENUM
20pub type AVAssetImageGeneratorApertureMode = NSString;
21
22extern "C" {
23 /// Both pixel aspect ratio and clean aperture will be applied.
24 ///
25 /// An image's clean aperture is a region of video free from transition artifacts caused by the encoding of the signal.
26 ///
27 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratoraperturemodecleanaperture?language=objc)
28 pub static AVAssetImageGeneratorApertureModeCleanAperture:
29 &'static AVAssetImageGeneratorApertureMode;
30}
31
32extern "C" {
33 /// Only pixel aspect ratio will be applied.
34 ///
35 /// The image is not cropped to the clean aperture region, but it is scaled according to the pixel aspect ratio. Use this option when you want to see all the pixels in your video, including the edges.
36 ///
37 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratoraperturemodeproductionaperture?language=objc)
38 pub static AVAssetImageGeneratorApertureModeProductionAperture:
39 &'static AVAssetImageGeneratorApertureMode;
40}
41
42extern "C" {
43 /// Neither pixel aspect ratio nor clean aperture will be applied.
44 ///
45 /// The image is not cropped to the clean aperture region and is not scaled according to the pixel aspect ratio. The encoded dimensions of the image description are displayed.
46 ///
47 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratoraperturemodeencodedpixels?language=objc)
48 pub static AVAssetImageGeneratorApertureModeEncodedPixels:
49 &'static AVAssetImageGeneratorApertureMode;
50}
51
52/// Configures the video dynamic range for the output CGImage
53///
54/// Default. Force standard dynamic range by converting PQ or HLG transfer functions to 709, while maintaining color primaries and matrix.
55///
56/// SDR movies will vend SDR CGImages matching the source color parameters. HDR movies will vend HDR CGImages matching the source color parameters.
57/// HTTP Live Streaming assets will currently vend only SDR CGImages.
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratordynamicrangepolicy?language=objc)
60// NS_TYPED_ENUM
61pub type AVAssetImageGeneratorDynamicRangePolicy = NSString;
62
63extern "C" {
64 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratordynamicrangepolicyforcesdr?language=objc)
65 pub static AVAssetImageGeneratorDynamicRangePolicyForceSDR:
66 &'static AVAssetImageGeneratorDynamicRangePolicy;
67}
68
69extern "C" {
70 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratordynamicrangepolicymatchsource?language=objc)
71 pub static AVAssetImageGeneratorDynamicRangePolicyMatchSource:
72 &'static AVAssetImageGeneratorDynamicRangePolicy;
73}
74
75/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratorresult?language=objc)
76// NS_ENUM
77#[repr(transparent)]
78#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
79pub struct AVAssetImageGeneratorResult(pub NSInteger);
80impl AVAssetImageGeneratorResult {
81 #[doc(alias = "AVAssetImageGeneratorSucceeded")]
82 pub const Succeeded: Self = Self(0);
83 #[doc(alias = "AVAssetImageGeneratorFailed")]
84 pub const Failed: Self = Self(1);
85 #[doc(alias = "AVAssetImageGeneratorCancelled")]
86 pub const Cancelled: Self = Self(2);
87}
88
89unsafe impl Encode for AVAssetImageGeneratorResult {
90 const ENCODING: Encoding = NSInteger::ENCODING;
91}
92
93unsafe impl RefEncode for AVAssetImageGeneratorResult {
94 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
95}
96
97/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegeneratorcompletionhandler?language=objc)
98#[cfg(all(
99 feature = "block2",
100 feature = "objc2-core-graphics",
101 feature = "objc2-core-media"
102))]
103pub type AVAssetImageGeneratorCompletionHandler = *mut block2::Block<
104 dyn Fn(CMTime, *mut CGImage, CMTime, AVAssetImageGeneratorResult, *mut NSError),
105>;
106
107extern_class!(
108 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetimagegenerator?language=objc)
109 #[unsafe(super(NSObject))]
110 #[derive(Debug, PartialEq, Eq, Hash)]
111 pub struct AVAssetImageGenerator;
112);
113
114unsafe impl NSObjectProtocol for AVAssetImageGenerator {}
115
116impl AVAssetImageGenerator {
117 extern_methods!(
118 #[unsafe(method(init))]
119 #[unsafe(method_family = init)]
120 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122 #[unsafe(method(new))]
123 #[unsafe(method_family = new)]
124 pub unsafe fn new() -> Retained<Self>;
125
126 #[cfg(feature = "AVAsset")]
127 #[unsafe(method(asset))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn asset(&self) -> Retained<AVAsset>;
130
131 #[unsafe(method(appliesPreferredTrackTransform))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn appliesPreferredTrackTransform(&self) -> bool;
134
135 /// Setter for [`appliesPreferredTrackTransform`][Self::appliesPreferredTrackTransform].
136 #[unsafe(method(setAppliesPreferredTrackTransform:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn setAppliesPreferredTrackTransform(
139 &self,
140 applies_preferred_track_transform: bool,
141 );
142
143 #[cfg(feature = "objc2-core-foundation")]
144 #[unsafe(method(maximumSize))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn maximumSize(&self) -> CGSize;
147
148 #[cfg(feature = "objc2-core-foundation")]
149 /// Setter for [`maximumSize`][Self::maximumSize].
150 #[unsafe(method(setMaximumSize:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn setMaximumSize(&self, maximum_size: CGSize);
153
154 #[unsafe(method(apertureMode))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn apertureMode(&self) -> Option<Retained<AVAssetImageGeneratorApertureMode>>;
157
158 /// Setter for [`apertureMode`][Self::apertureMode].
159 #[unsafe(method(setApertureMode:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setApertureMode(
162 &self,
163 aperture_mode: Option<&AVAssetImageGeneratorApertureMode>,
164 );
165
166 /// Configures the video dynamic range for the output CGImage
167 ///
168 /// Default is AVAssetImageGeneratorDynamicRangePolicyForceSDR
169 #[unsafe(method(dynamicRangePolicy))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn dynamicRangePolicy(
172 &self,
173 ) -> Retained<AVAssetImageGeneratorDynamicRangePolicy>;
174
175 /// Setter for [`dynamicRangePolicy`][Self::dynamicRangePolicy].
176 #[unsafe(method(setDynamicRangePolicy:))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn setDynamicRangePolicy(
179 &self,
180 dynamic_range_policy: &AVAssetImageGeneratorDynamicRangePolicy,
181 );
182
183 #[cfg(feature = "AVVideoComposition")]
184 /// Specifies the video composition to use when extracting images from assets with multiple video tracks.
185 ///
186 /// If no videoComposition is specified, only the first enabled video track will be used.
187 /// If a videoComposition is specified, the value of appliesPreferredTrackTransform is ignored.
188 /// This property throws an exception if a video composition is set with any of the following property values:
189 /// - "renderScale" is not equal to one
190 /// - "renderSize" width or height is less than zero
191 /// - "frameDuration" is invalid or less than or equal to zero
192 /// - "sourceTrackIDForFrameTiming" is less than zero
193 #[unsafe(method(videoComposition))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn videoComposition(&self) -> Option<Retained<AVVideoComposition>>;
196
197 #[cfg(feature = "AVVideoComposition")]
198 /// Setter for [`videoComposition`][Self::videoComposition].
199 #[unsafe(method(setVideoComposition:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn setVideoComposition(&self, video_composition: Option<&AVVideoComposition>);
202
203 #[cfg(feature = "AVVideoCompositing")]
204 #[unsafe(method(customVideoCompositor))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn customVideoCompositor(
207 &self,
208 ) -> Option<Retained<ProtocolObject<dyn AVVideoCompositing>>>;
209
210 #[cfg(feature = "objc2-core-media")]
211 #[unsafe(method(requestedTimeToleranceBefore))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn requestedTimeToleranceBefore(&self) -> CMTime;
214
215 #[cfg(feature = "objc2-core-media")]
216 /// Setter for [`requestedTimeToleranceBefore`][Self::requestedTimeToleranceBefore].
217 #[unsafe(method(setRequestedTimeToleranceBefore:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setRequestedTimeToleranceBefore(
220 &self,
221 requested_time_tolerance_before: CMTime,
222 );
223
224 #[cfg(feature = "objc2-core-media")]
225 #[unsafe(method(requestedTimeToleranceAfter))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn requestedTimeToleranceAfter(&self) -> CMTime;
228
229 #[cfg(feature = "objc2-core-media")]
230 /// Setter for [`requestedTimeToleranceAfter`][Self::requestedTimeToleranceAfter].
231 #[unsafe(method(setRequestedTimeToleranceAfter:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setRequestedTimeToleranceAfter(&self, requested_time_tolerance_after: CMTime);
234
235 #[cfg(feature = "AVAsset")]
236 /// Returns an instance of AVAssetImageGenerator for use with the specified asset.
237 ///
238 /// Parameter `asset`: The asset from which images will be extracted.
239 ///
240 /// Returns: An instance of AVAssetImageGenerator
241 ///
242 /// This method may succeed even if the asset possesses no visual tracks at the time of initialization.
243 /// Clients may wish to test whether an asset has any tracks with the visual characteristic via
244 /// -[AVAsset tracksWithMediaCharacteristic:].
245 ///
246 /// Note also that assets that belong to a mutable subclass of AVAsset, AVMutableComposition or AVMutableMovie,
247 /// may gain visual tracks after initialization of an associated AVAssetImageGenerator.
248 ///
249 /// However, the results of image generation are undefined if mutations of the asset occur while images
250 /// are being generated.
251 ///
252 /// AVAssetImageGenerator will use the default enabled video track(s) to generate images.
253 #[unsafe(method(assetImageGeneratorWithAsset:))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn assetImageGeneratorWithAsset(asset: &AVAsset) -> Retained<Self>;
256
257 #[cfg(feature = "AVAsset")]
258 /// Initializes an instance of AVAssetImageGenerator for use with the specified asset.
259 ///
260 /// Parameter `asset`: The asset from which images will be extracted.
261 ///
262 /// Returns: An instance of AVAssetImageGenerator
263 ///
264 /// This method may succeed even if the asset possesses no visual tracks at the time of initialization.
265 /// Clients may wish to test whether an asset has any tracks with the visual characteristic via
266 /// -[AVAsset tracksWithMediaCharacteristic:].
267 ///
268 /// Note also that assets that belong to a mutable subclass of AVAsset, AVMutableComposition or AVMutableMovie,
269 /// may gain visual tracks after initialization of an associated AVAssetImageGenerator.
270 ///
271 /// However, the results of image generation are undefined if mutations of the asset occur while images
272 /// are being generated.
273 ///
274 /// AVAssetImageGenerator will use the default enabled video track(s) to generate images.
275 #[unsafe(method(initWithAsset:))]
276 #[unsafe(method_family = init)]
277 pub unsafe fn initWithAsset(this: Allocated<Self>, asset: &AVAsset) -> Retained<Self>;
278
279 #[cfg(all(
280 feature = "block2",
281 feature = "objc2-core-graphics",
282 feature = "objc2-core-media"
283 ))]
284 /// Returns a series of CGImageRefs for an asset at or near the specified times.
285 ///
286 /// Parameter `requestedTimes`: An NSArray of NSValues, each containing a CMTime, specifying the asset times at which an image is requested.
287 ///
288 /// Parameter `handler`: A block that will be called when an image request is complete.
289 ///
290 /// Employs an efficient "batch mode" for getting images in time order.
291 /// The client will receive exactly one handler callback for each requested time in requestedTimes.
292 /// Changes to generator properties (snap behavior, maximum size, etc...) will not affect outstanding asynchronous image generation requests.
293 /// The generated image is not retained. Clients should retain the image if they wish it to persist after the completion handler returns.
294 #[unsafe(method(generateCGImagesAsynchronouslyForTimes:completionHandler:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn generateCGImagesAsynchronouslyForTimes_completionHandler(
297 &self,
298 requested_times: &NSArray<NSValue>,
299 handler: AVAssetImageGeneratorCompletionHandler,
300 );
301
302 #[cfg(all(
303 feature = "block2",
304 feature = "objc2-core-graphics",
305 feature = "objc2-core-media"
306 ))]
307 /// Returns a CGImageRef for an asset at or near the specified time.
308 ///
309 /// Parameter `requestedTime`: A CMTime, specifying the asset time at which an image is requested.
310 ///
311 /// Parameter `handler`: A block that will be called when the image request is complete.
312 ///
313 /// The client will receive exactly one handler callback for requestedTime.
314 /// Changes to generator properties (snap behavior, maximum size, etc...) will not affect outstanding asynchronous image generation requests.
315 /// The generated image is not retained. Clients should retain the image if they wish it to persist after the completion handler returns.
316 /// If image generation succeeds, the `image` parameter to the completion handler will be non-NULL and the `error` parameter will be nil. If image generation fails or was cancelled, the `image` parameter will be NULL and the `error` parameter will describe what went wrong. For cancelled images, the returned error will be AVErrorOperationCancelled.
317 #[unsafe(method(generateCGImageAsynchronouslyForTime:completionHandler:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn generateCGImageAsynchronouslyForTime_completionHandler(
320 &self,
321 requested_time: CMTime,
322 handler: &block2::Block<dyn Fn(*mut CGImage, CMTime, *mut NSError)>,
323 );
324
325 /// Cancels all outstanding image generation requests.
326 ///
327 /// Calls the handler block with AVAssetImageGeneratorCancelled for each image time in every previous invocation of -generateCGImagesAsynchronouslyForTimes:completionHandler:
328 /// for which images have not yet been supplied.
329 #[unsafe(method(cancelAllCGImageGeneration))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn cancelAllCGImageGeneration(&self);
332 );
333}