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