objc2-video-toolbox 0.3.2

Bindings to the VideoToolbox framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;

use crate::*;

/// Configuration value you set to prioritize quality or performance.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframerateconversionconfigurationqualityprioritization?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTFrameRateConversionConfigurationQualityPrioritization(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTFrameRateConversionConfigurationQualityPrioritization {
    #[doc(alias = "VTFrameRateConversionConfigurationQualityPrioritizationNormal")]
    pub const Normal: Self = Self(1);
    #[doc(alias = "VTFrameRateConversionConfigurationQualityPrioritizationQuality")]
    pub const Quality: Self = Self(2);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTFrameRateConversionConfigurationQualityPrioritization {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTFrameRateConversionConfigurationQualityPrioritization {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Available algorithm revisions.
///
/// A new enum case with higher revision number is added when the processing algorithm is updated.
/// The ``VTFrameRateConversionConfiguration/defaultRevision`` property provides the default algorithm revision.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframerateconversionconfigurationrevision?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTFrameRateConversionConfigurationRevision(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTFrameRateConversionConfigurationRevision {
    #[doc(alias = "VTFrameRateConversionConfigurationRevision1")]
    pub const Revision1: Self = Self(1);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTFrameRateConversionConfigurationRevision {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTFrameRateConversionConfigurationRevision {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Indicates the order of input frames.
///
/// When submitting ``VTFrameRateConversionParameters`` to the processor, you need to provide one of these values based on
/// how the input frames are related to each other.
///
/// Use ``VTFrameRateConversionParametersSubmissionModeSequential`` to indicate that the current submission follows
/// presentation time order without jump or skip, when compared to previous submissions. This value provides better
/// processor performance than other values.
///
/// Use ``VTFrameRateConversionParametersSubmissionModeRandom`` to indicate that the current submission has no relation
/// to the previous submission. Typically, this indicates a jump or a skip in the frame sequence. The processor clears
/// internal caches when it receives this value in ``VTFrameProcessor/processWithParameters`` function call.
///
/// Use ``VTFrameRateConversionParametersSubmissionModeSequentialReferencesUnchanged`` to indicate that the frames are
/// in sequential order however, the reference frames are unchanged.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframerateconversionparameterssubmissionmode?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTFrameRateConversionParametersSubmissionMode(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTFrameRateConversionParametersSubmissionMode {
    /// You are submitting frames in non-sequential order.
    #[doc(alias = "VTFrameRateConversionParametersSubmissionModeRandom")]
    pub const Random: Self = Self(1);
    /// You are submitting frames sequentially following presentation time order.
    #[doc(alias = "VTFrameRateConversionParametersSubmissionModeSequential")]
    pub const Sequential: Self = Self(2);
    /// You are submitting frames sequentially.
    ///
    /// This processing request uses the same source and next reference frames as the previous submission.
    #[doc(alias = "VTFrameRateConversionParametersSubmissionModeSequentialReferencesUnchanged")]
    pub const SequentialReferencesUnchanged: Self = Self(3);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTFrameRateConversionParametersSubmissionMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTFrameRateConversionParametersSubmissionMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "objc2")]
extern_class!(
    /// Configuration that you use to set up the frame rate conversion processor.
    ///
    /// This configuration enables the frame-rate conversion on a `VTFrameProcessor` session.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframerateconversionconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTFrameRateConversionConfiguration;
);

#[cfg(feature = "objc2")]
unsafe impl Send for VTFrameRateConversionConfiguration {}

#[cfg(feature = "objc2")]
unsafe impl Sync for VTFrameRateConversionConfiguration {}

#[cfg(feature = "objc2")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VTFrameRateConversionConfiguration {}
);

#[cfg(all(feature = "VTFrameProcessorConfiguration", feature = "objc2"))]
extern_conformance!(
    unsafe impl VTFrameProcessorConfiguration for VTFrameRateConversionConfiguration {}
);

#[cfg(feature = "objc2")]
impl VTFrameRateConversionConfiguration {
    extern_methods!(
        /// Creates a new frame-rate conversion configuration.
        ///
        /// Returns `nil` if dimensions are out of range or revision is unsupported.
        ///
        /// - Parameters:
        /// - frameWidth: Width of source frame in pixels; the maximum value is 8192 for macOS, and 4096 for iOS.
        /// - frameHeight: Height of source frame in pixels; the maximum value is 4320 for macOS, and 2160 for iOS.
        /// - usePrecomputedFlow: A Boolean value that indicates whether you are providing Optical Flow. If false, optical flow is computed on the fly.
        /// - qualityPrioritization: A level you use to prioritize quality or performance; for more information about supported levels, see ``VTFrameRateConversionConfigurationQualityPrioritization``.
        /// - revision: The specific algorithm or configuration revision you use to perform the request.
        #[unsafe(method(initWithFrameWidth:frameHeight:usePrecomputedFlow:qualityPrioritization:revision:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrameWidth_frameHeight_usePrecomputedFlow_qualityPrioritization_revision(
            this: Allocated<Self>,
            frame_width: NSInteger,
            frame_height: NSInteger,
            use_precomputed_flow: bool,
            quality_prioritization: VTFrameRateConversionConfigurationQualityPrioritization,
            revision: VTFrameRateConversionConfigurationRevision,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        /// Width of source frame in pixels.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameWidth(&self) -> NSInteger;

        /// Height of source frame in pixels.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameHeight))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameHeight(&self) -> NSInteger;

        /// Indicates that caller provides optical flow.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(usePrecomputedFlow))]
        #[unsafe(method_family = none)]
        pub unsafe fn usePrecomputedFlow(&self) -> bool;

        /// A parameter you use to control quality and performance levels.
        ///
        /// For more information about supported levels, see ``VTFrameRateConversionConfigurationQualityPrioritization``.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(qualityPrioritization))]
        #[unsafe(method_family = none)]
        pub unsafe fn qualityPrioritization(
            &self,
        ) -> VTFrameRateConversionConfigurationQualityPrioritization;

        /// The specific algorithm or configuration revision you use to perform the request.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(revision))]
        #[unsafe(method_family = none)]
        pub unsafe fn revision(&self) -> VTFrameRateConversionConfigurationRevision;

        #[cfg(feature = "objc2-foundation")]
        /// Provides the collection of currently supported algorithms or configuration revisions for the class of configuration.
        ///
        /// A property you use to introspect at runtime which revisions are available for each configuration.
        #[unsafe(method(supportedRevisions))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedRevisions() -> Retained<NSIndexSet>;

        /// Provides the default revision of a specific algorithm or configuration.
        #[unsafe(method(defaultRevision))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultRevision() -> VTFrameRateConversionConfigurationRevision;

        #[cfg(feature = "objc2-foundation")]
        /// Supported pixel formats available for source frames for current configuration.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameSupportedPixelFormats))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameSupportedPixelFormats(&self) -> Retained<NSArray<NSNumber>>;

        #[cfg(feature = "objc2-foundation")]
        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent source frames and reference frames.
        ///
        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(sourcePixelBufferAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourcePixelBufferAttributes(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        #[cfg(feature = "objc2-foundation")]
        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent destination frames.
        ///
        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(destinationPixelBufferAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationPixelBufferAttributes(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        /// Reports whether the system supports this processor.
        #[unsafe(method(isSupported))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSupported() -> bool;

        #[deprecated]
        #[unsafe(method(processorSupported))]
        #[unsafe(method_family = none)]
        pub unsafe fn processorSupported() -> Boolean;
    );
}

#[cfg(feature = "objc2")]
extern_class!(
    /// An object that contains both input and output parameters, which the frame-rate conversion processor needs to process a frame.
    ///
    /// Use this object as a parameter to the ``VTFrameProcessor/processWithParameters`` method. The output parameter for
    /// this class is ``destinationFrame`` where the processor returns output frame (as mutable ``VTFrameProcessorFrame``)
    /// back to you once the `processWithParameters` completes.
    ///
    /// `VTFrameRateConversionParameters` are frame-level parameters.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframerateconversionparameters?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTFrameRateConversionParameters;
);

#[cfg(feature = "objc2")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VTFrameRateConversionParameters {}
);

#[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2"))]
extern_conformance!(
    unsafe impl VTFrameProcessorParameters for VTFrameRateConversionParameters {}
);

#[cfg(feature = "objc2")]
impl VTFrameRateConversionParameters {
    extern_methods!(
        #[cfg(all(feature = "VTFrameProcessorFrame", feature = "objc2-foundation"))]
        /// Creates new frame rate conversion parameters.
        ///
        /// Returns `nil` if `sourceFrame` or `nextFrame` is `nil`, if `sourceFrame` and reference frames don't have the same pixel format, or if `interpolationPhase` array count does not match `destinationFrames` array count.
        ///
        /// - Parameters:
        /// - sourceFrame: Current source frame; must be non `nil`.
        /// - nextFrame: Next source frame in presentation time order; must be non `nil`.
        /// - opticalFlow: Optional ``VTFrameProcessorOpticalFlow`` object that contains forward and backward optical flow with
        /// next frame. You only need to use this if the optical flow is pre-computed. For the first frame this is always `nil`.
        /// - interpolationPhase: Array of float numbers that indicate intervals at which the processor inserts a frame between
        /// current and next frame. The array size indicates how many frames to interpolate and this size must match
        /// `destinationFrames` size, with one interval for each destination frame. Use float number values between 0 and 1,
        /// for example, to insert one frame in the middle use a value of 0.5.
        /// - submissionMode: Provides a hint to let the processor know whether you are submitting frames in presentation
        /// sequence. For more information about supported modes see ``VTFrameRateConversionParametersSubmissionMode``.
        /// - destinationFrames: Caller-allocated array of ``VTFrameProcessorFrame`` that contains pixel buffers to receive the results. Must contain the same number of elements as `interpolationPhase`.
        #[unsafe(method(initWithSourceFrame:nextFrame:opticalFlow:interpolationPhase:submissionMode:destinationFrames:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSourceFrame_nextFrame_opticalFlow_interpolationPhase_submissionMode_destinationFrames(
            this: Allocated<Self>,
            source_frame: &VTFrameProcessorFrame,
            next_frame: &VTFrameProcessorFrame,
            optical_flow: Option<&VTFrameProcessorOpticalFlow>,
            interpolation_phase: &NSArray<NSNumber>,
            submission_mode: VTFrameRateConversionParametersSubmissionMode,
            destination_frame: &NSArray<VTFrameProcessorFrame>,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Current source frame, which must be non `nil`.
        #[unsafe(method(sourceFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourceFrame(&self) -> Retained<VTFrameProcessorFrame>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// The next source frame in presentation time order, which is `nil` for the last frame.
        #[unsafe(method(nextFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn nextFrame(&self) -> Option<Retained<VTFrameProcessorFrame>>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// An optional object that contains forward and backward optical flow with next frame.
        ///
        /// Only needed if optical flow is pre-computed. For the last frame this is `nil`.
        #[unsafe(method(opticalFlow))]
        #[unsafe(method_family = none)]
        pub unsafe fn opticalFlow(&self) -> Option<Retained<VTFrameProcessorOpticalFlow>>;

        #[cfg(feature = "objc2-foundation")]
        /// Array of float numbers that indicate intervals at which the processor inserts a frame between the current and next frame.
        ///
        /// Array size indicates how many frames to interpolate and must match `destinationFrames` size, one interval for each destination frame. Use float number values between 0 and 1, for example, to insert one frame in the middle use a value of 0.5.
        #[unsafe(method(interpolationPhase))]
        #[unsafe(method_family = none)]
        pub unsafe fn interpolationPhase(&self) -> Retained<NSArray<NSNumber>>;

        /// Ordering of the input frames in this submission relative to the previous submission.
        #[unsafe(method(submissionMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn submissionMode(&self) -> VTFrameRateConversionParametersSubmissionMode;

        #[cfg(all(feature = "VTFrameProcessorFrame", feature = "objc2-foundation"))]
        /// Caller-allocated array of video frame objects that contain pixel buffers to receive the results.
        ///
        /// Must contain the same number of elements as `interpolationPhase` NSArray.
        #[unsafe(method(destinationFrames))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationFrames(&self) -> Retained<NSArray<VTFrameProcessorFrame>>;
    );
}