objc2_av_foundation/generated/
AVPlayerOutput.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-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern_class!(
15    /// AVPlayerVideoOutput offers a way to attach to an AVPlayer and receive video frames and video-related data vended through CMTaggedBufferGroups.
16    ///
17    /// AVPlayerVideoOutput can be attached to an AVPlayer using AVPlayer's method addVideoOutput:
18    /// 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.
19    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayervideooutput?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct AVPlayerVideoOutput;
25);
26
27unsafe impl Send for AVPlayerVideoOutput {}
28
29unsafe impl Sync for AVPlayerVideoOutput {}
30
31extern_conformance!(
32    unsafe impl NSObjectProtocol for AVPlayerVideoOutput {}
33);
34
35impl AVPlayerVideoOutput {
36    extern_methods!(
37        #[unsafe(method(init))]
38        #[unsafe(method_family = init)]
39        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41        #[unsafe(method(new))]
42        #[unsafe(method_family = new)]
43        pub unsafe fn new() -> Retained<Self>;
44
45        /// Creates an instance of AVPlayerVideoOutput, initialized with the specified video output specification.
46        ///
47        /// Parameter `specification`: An instance of AVVideoOutputSpecification, used to recommend data channels to the AVPlayer associated with this AVPlayerVideoOutput.
48        /// 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.
49        /// 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.
50        /// 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.
51        /// 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.
52        ///
53        /// Returns: An instance of AVPlayerVideoOutput.
54        ///
55        /// Output settings will be selected from the input AVVideoOutputSpecification based on the data channels selected for an item.
56        /// 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.
57        #[unsafe(method(initWithSpecification:))]
58        #[unsafe(method_family = init)]
59        pub unsafe fn initWithSpecification(
60            this: Allocated<Self>,
61            specification: &AVVideoOutputSpecification,
62        ) -> Retained<Self>;
63
64        #[cfg(feature = "objc2-core-media")]
65        /// Retrieves a tagged buffer group that is appropriate for display at the specified host time.
66        ///
67        /// Parameter `hostTime`: A CMTime that expresses a desired host time.
68        ///
69        /// 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.
70        /// Note: This timestamp is in terms of the timebase of the AVPlayerItem for which this sample is associated.
71        ///
72        /// 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.
73        ///
74        /// Returns: A tagged buffer group for the specified host time if a sample is available, and NULL otherwise.
75        ///
76        /// The client is responsible for releasing the returned CMTaggedBufferGroup.
77        ///
78        /// # Safety
79        ///
80        /// `presentation_time_stamp_out` must be a valid pointer or null.
81        #[unsafe(method(copyTaggedBufferGroupForHostTime:presentationTimeStamp:activeConfiguration:))]
82        #[unsafe(method_family = copy)]
83        pub unsafe fn copyTaggedBufferGroupForHostTime_presentationTimeStamp_activeConfiguration(
84            &self,
85            host_time: CMTime,
86            presentation_time_stamp_out: *mut CMTime,
87            active_configuration_out: Option<
88                &mut Option<Retained<AVPlayerVideoOutputConfiguration>>,
89            >,
90        ) -> Option<Retained<CMTaggedBufferGroup>>;
91    );
92}
93
94/// Video output presets supported by CMTagCollectionCreateWithVideoOutputPreset.
95///
96/// Used for video output where there is no stereo view, e.g. kCMTagStereoNone.
97///
98/// Used for video output where there are two stereo views, for both left and right eyes, e.g. kCMTagStereoLeftAndRight.
99///
100/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/cmtagcollectionvideooutputpreset?language=objc)
101// NS_ENUM
102#[repr(transparent)]
103#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
104pub struct CMTagCollectionVideoOutputPreset(pub u32);
105impl CMTagCollectionVideoOutputPreset {
106    #[doc(alias = "kCMTagCollectionVideoOutputPreset_Monoscopic")]
107    pub const Monoscopic: Self = Self(0);
108    #[doc(alias = "kCMTagCollectionVideoOutputPreset_Stereoscopic")]
109    pub const Stereoscopic: Self = Self(1);
110}
111
112unsafe impl Encode for CMTagCollectionVideoOutputPreset {
113    const ENCODING: Encoding = u32::ENCODING;
114}
115
116unsafe impl RefEncode for CMTagCollectionVideoOutputPreset {
117    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
118}
119
120extern "C-unwind" {
121    /// Creates a CMTagCollection with the required tags to describe the specified video output requirements.
122    ///
123    /// Convenience constructor to create a CMTagCollection with all of the required tags for use with video output interfaces.
124    ///
125    /// Parameter `allocator`: CFAllocator to use to create the collection and internal data structures.
126    ///
127    /// Parameter `preset`: CMTagCollectionVideoOutputPreset representing the desired video output scenario.
128    ///
129    /// Parameter `newCollectionOut`: Address of a location to the newly created CMTagCollection.  The client is responsible for releasing the returned CMTagCollection.
130    ///
131    /// Returns: noErr if successful. Otherwise, an error describing why a tag collection could not be created.
132    ///
133    /// # Safety
134    ///
135    /// `new_collection_out` must be a valid pointer.
136    #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
137    pub fn CMTagCollectionCreateWithVideoOutputPreset(
138        allocator: Option<&CFAllocator>,
139        preset: CMTagCollectionVideoOutputPreset,
140        new_collection_out: NonNull<*const CMTagCollection>,
141    ) -> OSStatus;
142}
143
144extern_class!(
145    /// 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.
146    ///
147    /// For more information about working with CMTagCollections and CMTags first look at
148    /// <CoreMedia
149    /// /CMTagCollection.h>
150    ///
151    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvideooutputspecification?language=objc)
152    #[unsafe(super(NSObject))]
153    #[derive(Debug, PartialEq, Eq, Hash)]
154    pub struct AVVideoOutputSpecification;
155);
156
157extern_conformance!(
158    unsafe impl NSCopying for AVVideoOutputSpecification {}
159);
160
161unsafe impl CopyingHelper for AVVideoOutputSpecification {
162    type Result = Self;
163}
164
165extern_conformance!(
166    unsafe impl NSObjectProtocol for AVVideoOutputSpecification {}
167);
168
169impl AVVideoOutputSpecification {
170    extern_methods!(
171        #[unsafe(method(init))]
172        #[unsafe(method_family = init)]
173        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
174
175        #[unsafe(method(new))]
176        #[unsafe(method_family = new)]
177        pub unsafe fn new() -> Retained<Self>;
178
179        /// Creates an instance of AVVideoOutputSpecification initialized with the specified tag collections.
180        ///
181        /// 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.
182        ///
183        /// This method throws an exception for the following reasons:
184        /// - tagCollections is nil or has a count of 0.
185        /// - tagCollections contains elements that are not of the type CMTagCollection.
186        ///
187        /// # Safety
188        ///
189        /// `tag_collections` generic should be of the correct type.
190        #[unsafe(method(initWithTagCollections:))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn initWithTagCollections(
193            this: Allocated<Self>,
194            tag_collections: &NSArray,
195        ) -> Retained<Self>;
196
197        #[cfg(feature = "objc2-core-media")]
198        /// Specifies a mapping between a tag collection and a set of pixel buffer attributes.
199        ///
200        /// Parameter `pixelBufferAttributes`: The client requirements for CVPixelBuffers related to the tags in tagCollection, expressed using the constants in
201        /// <CoreVideo
202        /// /CVPixelBuffer.h>.
203        ///
204        /// Parameter `tagCollection`: A single tag collection for which these pixel buffer attributes should map to.
205        ///
206        /// If this method is called twice on the same tag collection, the first requested pixel buffer attributes will be overridden.
207        ///
208        /// Note: Pixel buffer attributes are translated into output settings, therefore, the rules of `-setOutputSettings:forTagCollection` apply to this method as well.
209        /// 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.
210        ///
211        /// # Safety
212        ///
213        /// `pixel_buffer_attributes` generic should be of the correct type.
214        #[deprecated]
215        #[unsafe(method(setOutputPixelBufferAttributes:forTagCollection:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setOutputPixelBufferAttributes_forTagCollection(
218            &self,
219            pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
220            tag_collection: &CMTagCollection,
221        );
222
223        #[cfg(feature = "objc2-core-media")]
224        /// Specifies a mapping between a tag collection and a set of output settings.
225        ///
226        /// Parameter `outputSettings`: The client requirements for output CVPixelBuffers related to the tags in tagCollection, expressed using the constants in AVVideoSettings.h.
227        /// For uncompressed video output, start with kCVPixelBuffer* keys in
228        /// <CoreVideo
229        /// /CVPixelBuffer.h>.
230        /// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
231        /// - AVVideoAllowWideColorKey
232        ///
233        /// Parameter `tagCollection`: A single tag collection for which these output settings should map to.
234        ///
235        /// If this method is called twice on the same tag collection, the first requested output settings will be overridden.
236        ///
237        /// Note: This method throws an exception for any of the following reasons:
238        /// - The settings will yield compressed output
239        /// - The settings do not honor the requirements list above for outputSettings.
240        /// - tagCollection does not match with any tag collection in -preferredTagCollections.
241        ///
242        /// # Safety
243        ///
244        /// `output_settings` generic should be of the correct type.
245        #[unsafe(method(setOutputSettings:forTagCollection:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setOutputSettings_forTagCollection(
248            &self,
249            output_settings: Option<&NSDictionary<NSString, AnyObject>>,
250            tag_collection: &CMTagCollection,
251        );
252
253        /// Tag collections held by AVVideoOutputSpecification.
254        ///
255        /// Returns an array of CMTagCollections.
256        #[unsafe(method(preferredTagCollections))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn preferredTagCollections(&self) -> Retained<NSArray>;
259
260        /// The default client requirements for CVPixelBuffers related to all tag collections not explicitly set with setOutputPixelBufferAttributes:forTagCollection:, expressed using the constants in
261        /// <CoreVideo
262        /// /CVPixelBuffer.h>.
263        ///
264        /// NSDictionary where keys are of type NSString, values should match the type specified by the corresponding keys documentation in
265        /// <CoreVideo
266        /// /CVPixelBuffer.h>
267        ///
268        /// 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.
269        #[deprecated]
270        #[unsafe(method(defaultPixelBufferAttributes))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn defaultPixelBufferAttributes(
273            &self,
274        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
275
276        /// Setter for [`defaultPixelBufferAttributes`][Self::defaultPixelBufferAttributes].
277        ///
278        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
279        ///
280        /// # Safety
281        ///
282        /// `default_pixel_buffer_attributes` generic should be of the correct type.
283        #[deprecated]
284        #[unsafe(method(setDefaultPixelBufferAttributes:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setDefaultPixelBufferAttributes(
287            &self,
288            default_pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
289        );
290
291        /// 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.
292        /// For uncompressed video output, start with kCVPixelBuffer* keys in
293        /// <CoreVideo
294        /// /CVPixelBuffer.h>.
295        /// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
296        /// - AVVideoAllowWideColorKey
297        ///
298        /// NSDictionary where keys are of type NSString, values should match the type specified by the corresponding keys documentation in
299        /// <AVFoundation
300        /// /AVVideoSettings.h> and
301        /// <CoreVideo
302        /// /CVPixelBuffer.h>.
303        ///
304        /// Note: The setter for this property throws an exception for any of the following reasons:
305        /// - The settings will yield compressed output
306        /// - The settings do not honor the requirements list above for outputSettings.
307        #[unsafe(method(defaultOutputSettings))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn defaultOutputSettings(
310            &self,
311        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
312
313        /// Setter for [`defaultOutputSettings`][Self::defaultOutputSettings].
314        ///
315        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
316        ///
317        /// # Safety
318        ///
319        /// `default_output_settings` generic should be of the correct type.
320        #[unsafe(method(setDefaultOutputSettings:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn setDefaultOutputSettings(
323            &self,
324            default_output_settings: Option<&NSDictionary<NSString, AnyObject>>,
325        );
326    );
327}
328
329extern_class!(
330    /// An AVPlayerVideoOutputConfiguration carries an identifier for the AVPlayerItem the configuration is associated with as well as presentation settings for that item.
331    ///
332    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
333    ///
334    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayervideooutputconfiguration?language=objc)
335    #[unsafe(super(NSObject))]
336    #[derive(Debug, PartialEq, Eq, Hash)]
337    pub struct AVPlayerVideoOutputConfiguration;
338);
339
340unsafe impl Send for AVPlayerVideoOutputConfiguration {}
341
342unsafe impl Sync for AVPlayerVideoOutputConfiguration {}
343
344extern_conformance!(
345    unsafe impl NSObjectProtocol for AVPlayerVideoOutputConfiguration {}
346);
347
348impl AVPlayerVideoOutputConfiguration {
349    extern_methods!(
350        #[unsafe(method(init))]
351        #[unsafe(method_family = init)]
352        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
353
354        #[unsafe(method(new))]
355        #[unsafe(method_family = new)]
356        pub unsafe fn new() -> Retained<Self>;
357
358        #[cfg(feature = "AVPlayerItem")]
359        /// The AVPlayerItem which is the source of this configuration.
360        ///
361        /// This AVPlayerItem can be seen as the source of all samples this configuration vended alongside.
362        ///
363        /// This property is not atomic.
364        ///
365        /// # Safety
366        ///
367        /// This might not be thread-safe.
368        #[unsafe(method(sourcePlayerItem))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn sourcePlayerItem(
371            &self,
372            mtm: MainThreadMarker,
373        ) -> Option<Retained<AVPlayerItem>>;
374
375        /// List of data channels, represented as CMTagCollections, selected for this configuration.
376        ///
377        /// Returns an Array of CMTagCollections
378        ///
379        /// This property is not atomic.
380        ///
381        /// # Safety
382        ///
383        /// This might not be thread-safe.
384        #[unsafe(method(dataChannelDescriptions))]
385        #[unsafe(method_family = none)]
386        pub unsafe fn dataChannelDescriptions(&self) -> Retained<NSArray>;
387
388        #[cfg(feature = "objc2-core-foundation")]
389        /// 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.
390        ///
391        /// If no transform was specified by the source track a default value of CGAffineTransformIdentity is returned.
392        ///
393        /// This property is not atomic.
394        ///
395        /// # Safety
396        ///
397        /// This might not be thread-safe.
398        #[unsafe(method(preferredTransform))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
401
402        #[cfg(feature = "objc2-core-media")]
403        /// Host time when this configuration became active on the player the vending output is attached to.
404        ///
405        /// This property is not atomic.
406        ///
407        /// # Safety
408        ///
409        /// This might not be thread-safe.
410        #[unsafe(method(activationTime))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn activationTime(&self) -> CMTime;
413    );
414}