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
409
410
411
412
413
414
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// AVPlayerVideoOutput offers a way to attach to an AVPlayer and receive video frames and video-related data vended through CMTaggedBufferGroups.
///
/// AVPlayerVideoOutput can be attached to an AVPlayer using AVPlayer's method addVideoOutput:
/// Note: An AVPlayerVideoOutput can only be attached to a single player at a time, attempting to attach to multiple player will result in an exception being thrown.
/// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayervideooutput?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPlayerVideoOutput;
);
unsafe impl Send for AVPlayerVideoOutput {}
unsafe impl Sync for AVPlayerVideoOutput {}
extern_conformance!(
unsafe impl NSObjectProtocol for AVPlayerVideoOutput {}
);
impl AVPlayerVideoOutput {
extern_methods!(
#[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>;
/// Creates an instance of AVPlayerVideoOutput, initialized with the specified video output specification.
///
/// Parameter `specification`: An instance of AVVideoOutputSpecification, used to recommend data channels to the AVPlayer associated with this AVPlayerVideoOutput.
/// The tag collections owned by the AVVideoOutputSpecification will be given a priority based on their position in the array which they are held by AVVideoOutputSpecification, meaning position i takes priority over position i+1.
/// This means that the player will first check if the tag collection at index 0 matches the shape of the current item's data channels.
/// If the item's data channels would not be able satisfy the shape of the requested tag collection, it will fall back to the next collection and repeat this process.
/// This continues until a tag collection or set of tag collection can be selected, otherwise if no collections match the shape of the item’s data channels then samples cannot be vended for that item.
///
/// Returns: An instance of AVPlayerVideoOutput.
///
/// Output settings will be selected from the input AVVideoOutputSpecification based on the data channels selected for an item.
/// If no output settings were set for the selected tag collection, then the default output settings from the AVVideoOutputSpecification will be used if those were set.
#[unsafe(method(initWithSpecification:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithSpecification(
this: Allocated<Self>,
specification: &AVVideoOutputSpecification,
) -> Retained<Self>;
#[cfg(feature = "objc2-core-media")]
/// Retrieves a tagged buffer group that is appropriate for display at the specified host time.
///
/// Parameter `hostTime`: A CMTime that expresses a desired host time.
///
/// Parameter `presentationTimeStamp`: On return points to a CMTime whose value is the presentation time in terms of the corresponding AVPlayerItem's timebase for the copied tagged buffer group, or kCMTimeInvalid if no sample is available for the provided hostTime.
/// Note: This timestamp is in terms of the timebase of the AVPlayerItem for which this sample is associated.
///
/// Parameter `activeConfiguration`: On return points to the active configuration associated with the copied tagged buffer group, or nil, if no sample is available for the provided hostTime.
///
/// Returns: A tagged buffer group for the specified host time if a sample is available, and NULL otherwise.
///
/// The client is responsible for releasing the returned CMTaggedBufferGroup.
///
/// # Safety
///
/// `presentation_time_stamp_out` must be a valid pointer or null.
#[unsafe(method(copyTaggedBufferGroupForHostTime:presentationTimeStamp:activeConfiguration:))]
#[unsafe(method_family = copy)]
pub unsafe fn copyTaggedBufferGroupForHostTime_presentationTimeStamp_activeConfiguration(
&self,
host_time: CMTime,
presentation_time_stamp_out: *mut CMTime,
active_configuration_out: Option<
&mut Option<Retained<AVPlayerVideoOutputConfiguration>>,
>,
) -> Option<Retained<CMTaggedBufferGroup>>;
);
}
/// Video output presets supported by CMTagCollectionCreateWithVideoOutputPreset.
///
/// Used for video output where there is no stereo view, e.g. kCMTagStereoNone.
///
/// Used for video output where there are two stereo views, for both left and right eyes, e.g. kCMTagStereoLeftAndRight.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/cmtagcollectionvideooutputpreset?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMTagCollectionVideoOutputPreset(pub u32);
impl CMTagCollectionVideoOutputPreset {
#[doc(alias = "kCMTagCollectionVideoOutputPreset_Monoscopic")]
pub const Monoscopic: Self = Self(0);
#[doc(alias = "kCMTagCollectionVideoOutputPreset_Stereoscopic")]
pub const Stereoscopic: Self = Self(1);
}
unsafe impl Encode for CMTagCollectionVideoOutputPreset {
const ENCODING: Encoding = u32::ENCODING;
}
unsafe impl RefEncode for CMTagCollectionVideoOutputPreset {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C-unwind" {
/// Creates a CMTagCollection with the required tags to describe the specified video output requirements.
///
/// Convenience constructor to create a CMTagCollection with all of the required tags for use with video output interfaces.
///
/// Parameter `allocator`: CFAllocator to use to create the collection and internal data structures.
///
/// Parameter `preset`: CMTagCollectionVideoOutputPreset representing the desired video output scenario.
///
/// Parameter `newCollectionOut`: Address of a location to the newly created CMTagCollection. The client is responsible for releasing the returned CMTagCollection.
///
/// Returns: noErr if successful. Otherwise, an error describing why a tag collection could not be created.
///
/// # Safety
///
/// `new_collection_out` must be a valid pointer.
#[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
pub fn CMTagCollectionCreateWithVideoOutputPreset(
allocator: Option<&CFAllocator>,
preset: CMTagCollectionVideoOutputPreset,
new_collection_out: NonNull<*const CMTagCollection>,
) -> OSStatus;
}
extern_class!(
/// AVVideoOutputSpecification offers a way to package CMTagCollections together with output settings. Allowing for direct association between output settings and specific tag collections, as well as default output settings which can be associated with all tag collections which do not have a specified mapping.
///
/// For more information about working with CMTagCollections and CMTags first look at
/// <CoreMedia
/// /CMTagCollection.h>
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideooutputspecification?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVVideoOutputSpecification;
);
extern_conformance!(
unsafe impl NSCopying for AVVideoOutputSpecification {}
);
unsafe impl CopyingHelper for AVVideoOutputSpecification {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for AVVideoOutputSpecification {}
);
impl AVVideoOutputSpecification {
extern_methods!(
#[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>;
/// Creates an instance of AVVideoOutputSpecification initialized with the specified tag collections.
///
/// Parameter `tagCollections`: Expects a non-empty array of CMTagCollections. Tag collections are given priority based on their position in the array, where position i take priority over position i+1.
///
/// This method throws an exception for the following reasons:
/// - tagCollections is nil or has a count of 0.
/// - tagCollections contains elements that are not of the type CMTagCollection.
///
/// # Safety
///
/// `tag_collections` generic should be of the correct type.
#[unsafe(method(initWithTagCollections:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTagCollections(
this: Allocated<Self>,
tag_collections: &NSArray,
) -> Retained<Self>;
#[cfg(feature = "objc2-core-media")]
/// Specifies a mapping between a tag collection and a set of pixel buffer attributes.
///
/// Parameter `pixelBufferAttributes`: The client requirements for CVPixelBuffers related to the tags in tagCollection, expressed using the constants in
/// <CoreVideo
/// /CVPixelBuffer.h>.
///
/// Parameter `tagCollection`: A single tag collection for which these pixel buffer attributes should map to.
///
/// If this method is called twice on the same tag collection, the first requested pixel buffer attributes will be overridden.
///
/// Note: Pixel buffer attributes are translated into output settings, therefore, the rules of `-setOutputSettings:forTagCollection` apply to this method as well.
/// Namely, if you set pixel buffer attributes for a tag collection and then output settings for that same tag collection, your pixel buffer attributes will be overridden and vice-versa.
///
/// # Safety
///
/// `pixel_buffer_attributes` generic should be of the correct type.
#[deprecated]
#[unsafe(method(setOutputPixelBufferAttributes:forTagCollection:))]
#[unsafe(method_family = none)]
pub unsafe fn setOutputPixelBufferAttributes_forTagCollection(
&self,
pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
tag_collection: &CMTagCollection,
);
#[cfg(feature = "objc2-core-media")]
/// Specifies a mapping between a tag collection and a set of output settings.
///
/// Parameter `outputSettings`: The client requirements for output CVPixelBuffers related to the tags in tagCollection, expressed using the constants in AVVideoSettings.h.
/// For uncompressed video output, start with kCVPixelBuffer* keys in
/// <CoreVideo
/// /CVPixelBuffer.h>.
/// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
/// - AVVideoAllowWideColorKey
///
/// Parameter `tagCollection`: A single tag collection for which these output settings should map to.
///
/// If this method is called twice on the same tag collection, the first requested output settings will be overridden.
///
/// Note: This method throws an exception for any of the following reasons:
/// - The settings will yield compressed output
/// - The settings do not honor the requirements list above for outputSettings.
/// - tagCollection does not match with any tag collection in -preferredTagCollections.
///
/// # Safety
///
/// `output_settings` generic should be of the correct type.
#[unsafe(method(setOutputSettings:forTagCollection:))]
#[unsafe(method_family = none)]
pub unsafe fn setOutputSettings_forTagCollection(
&self,
output_settings: Option<&NSDictionary<NSString, AnyObject>>,
tag_collection: &CMTagCollection,
);
/// Tag collections held by AVVideoOutputSpecification.
///
/// Returns an array of CMTagCollections.
#[unsafe(method(preferredTagCollections))]
#[unsafe(method_family = none)]
pub unsafe fn preferredTagCollections(&self) -> Retained<NSArray>;
/// The default client requirements for CVPixelBuffers related to all tag collections not explicitly set with setOutputPixelBufferAttributes:forTagCollection:, expressed using the constants in
/// <CoreVideo
/// /CVPixelBuffer.h>.
///
/// NSDictionary where keys are of type NSString, values should match the type specified by the corresponding keys documentation in
/// <CoreVideo
/// /CVPixelBuffer.h>
///
/// Note: Pixel buffer attributes are translated into output settings, therefore, the rules of defaultOutputSettings apply to defaultPixelBufferAttributes as well. If defaultPixelBufferAttributes are set after setting defaultOutputSettings, the set output settings will be overridden and vice-versa.
#[deprecated]
#[unsafe(method(defaultPixelBufferAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn defaultPixelBufferAttributes(
&self,
) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
/// Setter for [`defaultPixelBufferAttributes`][Self::defaultPixelBufferAttributes].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `default_pixel_buffer_attributes` generic should be of the correct type.
#[deprecated]
#[unsafe(method(setDefaultPixelBufferAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultPixelBufferAttributes(
&self,
default_pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
);
/// The default client requirements for output CVPixelBuffers related to all tag collections not explicitly set with -setOutputSettings:forTagCollection, expressed using the constants in AVVideoSettings.h.
/// For uncompressed video output, start with kCVPixelBuffer* keys in
/// <CoreVideo
/// /CVPixelBuffer.h>.
/// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
/// - AVVideoAllowWideColorKey
///
/// NSDictionary where keys are of type NSString, values should match the type specified by the corresponding keys documentation in
/// <AVFoundation
/// /AVVideoSettings.h> and
/// <CoreVideo
/// /CVPixelBuffer.h>.
///
/// Note: The setter for this property throws an exception for any of the following reasons:
/// - The settings will yield compressed output
/// - The settings do not honor the requirements list above for outputSettings.
#[unsafe(method(defaultOutputSettings))]
#[unsafe(method_family = none)]
pub unsafe fn defaultOutputSettings(
&self,
) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
/// Setter for [`defaultOutputSettings`][Self::defaultOutputSettings].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `default_output_settings` generic should be of the correct type.
#[unsafe(method(setDefaultOutputSettings:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultOutputSettings(
&self,
default_output_settings: Option<&NSDictionary<NSString, AnyObject>>,
);
);
}
extern_class!(
/// An AVPlayerVideoOutputConfiguration carries an identifier for the AVPlayerItem the configuration is associated with as well as presentation settings for that item.
///
/// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayervideooutputconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPlayerVideoOutputConfiguration;
);
unsafe impl Send for AVPlayerVideoOutputConfiguration {}
unsafe impl Sync for AVPlayerVideoOutputConfiguration {}
extern_conformance!(
unsafe impl NSObjectProtocol for AVPlayerVideoOutputConfiguration {}
);
impl AVPlayerVideoOutputConfiguration {
extern_methods!(
#[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 = "AVPlayerItem")]
/// The AVPlayerItem which is the source of this configuration.
///
/// This AVPlayerItem can be seen as the source of all samples this configuration vended alongside.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(sourcePlayerItem))]
#[unsafe(method_family = none)]
pub unsafe fn sourcePlayerItem(
&self,
mtm: MainThreadMarker,
) -> Option<Retained<AVPlayerItem>>;
/// List of data channels, represented as CMTagCollections, selected for this configuration.
///
/// Returns an Array of CMTagCollections
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(dataChannelDescriptions))]
#[unsafe(method_family = none)]
pub unsafe fn dataChannelDescriptions(&self) -> Retained<NSArray>;
#[cfg(feature = "objc2-core-foundation")]
/// The preferred transformation of the visual media data vended with this configuration. This transformation is acquired from the AVAssetTrack that was used to source the media data accompanying this configuration.
///
/// If no transform was specified by the source track a default value of CGAffineTransformIdentity is returned.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(preferredTransform))]
#[unsafe(method_family = none)]
pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
#[cfg(feature = "objc2-core-media")]
/// Host time when this configuration became active on the player the vending output is attached to.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(activationTime))]
#[unsafe(method_family = none)]
pub unsafe fn activationTime(&self) -> CMTime;
);
}