objc2_av_foundation/generated/
AVMediaSelectionGroup.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmediaselectiongroup?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct AVMediaSelectionGroup;
14);
15
16unsafe impl NSCopying for AVMediaSelectionGroup {}
17
18unsafe impl CopyingHelper for AVMediaSelectionGroup {
19    type Result = Self;
20}
21
22unsafe impl NSObjectProtocol for AVMediaSelectionGroup {}
23
24impl AVMediaSelectionGroup {
25    extern_methods!(
26        /// A collection of mutually exclusive media selection options.
27        ///
28        /// An NSArray of AVMediaSelectionOption*.
29        #[unsafe(method(options))]
30        #[unsafe(method_family = none)]
31        pub unsafe fn options(&self) -> Retained<NSArray<AVMediaSelectionOption>>;
32
33        /// Indicates the default option in the group, i.e. the option that's intended for use in the absence of a specific end-user selection or preference.
34        ///
35        /// Can be nil, indicating that without a specific end-user selection or preference, no option in the group is intended to be selected.
36        #[unsafe(method(defaultOption))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn defaultOption(&self) -> Option<Retained<AVMediaSelectionOption>>;
39
40        /// Indicates whether it's possible to present none of the options in the group when an associated AVPlayerItem is played.
41        ///
42        /// If allowsEmptySelection is YES, all of the available media options in the group can be deselected by passing nil
43        /// as the specified AVMediaSelectionOption to -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:].
44        #[unsafe(method(allowsEmptySelection))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn allowsEmptySelection(&self) -> bool;
47
48        /// Returns the instance of AVMediaSelectionOption with properties that match the specified property list.
49        ///
50        /// Parameter `plist`: A property list previously obtained from an option in the group via -[AVMediaSelectionOption propertyList].
51        ///
52        /// Returns: If the specified properties match those of an option in the group, an instance of AVMediaSelectionOption. Otherwise nil.
53        #[unsafe(method(mediaSelectionOptionWithPropertyList:))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn mediaSelectionOptionWithPropertyList(
56            &self,
57            plist: &AnyObject,
58        ) -> Option<Retained<AVMediaSelectionOption>>;
59    );
60}
61
62/// Methods declared on superclass `NSObject`.
63impl AVMediaSelectionGroup {
64    extern_methods!(
65        #[unsafe(method(init))]
66        #[unsafe(method_family = init)]
67        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
68
69        #[unsafe(method(new))]
70        #[unsafe(method_family = new)]
71        pub unsafe fn new() -> Retained<Self>;
72    );
73}
74
75/// AVMediaSelectionOptionFiltering.
76/// Filtering of media selection options.
77///
78/// The AVMediaSelectionOptionFiltering category is provided for convenience in filtering the media selection options in a group
79/// according to playability, locale, and media characteristics.
80/// Note that it's possible to implement additional filtering behaviors by using -[NSArray indexesOfObjectsPassingTest:].
81impl AVMediaSelectionGroup {
82    extern_methods!(
83        /// Filters an array of AVMediaSelectionOptions according to whether they are playable.
84        ///
85        /// Parameter `mediaSelectionOptions`: An array of AVMediaSelectionOption to be filtered according to whether they are playable.
86        ///
87        /// Returns: An instance of NSArray containing the media selection options of the specified NSArray that are playable.
88        #[unsafe(method(playableMediaSelectionOptionsFromArray:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn playableMediaSelectionOptionsFromArray(
91            media_selection_options: &NSArray<AVMediaSelectionOption>,
92        ) -> Retained<NSArray<AVMediaSelectionOption>>;
93
94        /// Filters an array of AVMediaSelectionOptions according to whether their locales match any language identifier in the specified array of preferred languages. The returned array is sorted according to the order of preference of the language each matches.
95        ///
96        /// Parameter `mediaSelectionOptions`: An array of AVMediaSelectionOptions to be filtered and sorted.
97        ///
98        /// Parameter `preferredLanguages`: An array of language identifiers in order of preference, each of which is an IETF BCP 47 (RFC 4646) language identifier. Use +[NSLocale preferredLanguages] to obtain the user's list of preferred languages.
99        ///
100        /// Returns: An instance of NSArray containing media selection options of the specified NSArray that match a preferred language, sorted according to the order of preference of the language each matches.
101        #[unsafe(method(mediaSelectionOptionsFromArray:filteredAndSortedAccordingToPreferredLanguages:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn mediaSelectionOptionsFromArray_filteredAndSortedAccordingToPreferredLanguages(
104            media_selection_options: &NSArray<AVMediaSelectionOption>,
105            preferred_languages: &NSArray<NSString>,
106        ) -> Retained<NSArray<AVMediaSelectionOption>>;
107
108        /// Filters an array of AVMediaSelectionOptions according to locale.
109        ///
110        /// Parameter `mediaSelectionOptions`: An array of AVMediaSelectionOption to be filtered by locale.
111        ///
112        /// Parameter `locale`: The NSLocale that must be matched for a media selection option to be copied to the output array.
113        ///
114        /// Returns: An instance of NSArray containing the media selection options of the specified NSArray that match the specified locale.
115        #[unsafe(method(mediaSelectionOptionsFromArray:withLocale:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn mediaSelectionOptionsFromArray_withLocale(
118            media_selection_options: &NSArray<AVMediaSelectionOption>,
119            locale: &NSLocale,
120        ) -> Retained<NSArray<AVMediaSelectionOption>>;
121
122        #[cfg(feature = "AVMediaFormat")]
123        /// Filters an array of AVMediaSelectionOptions according to one or more media characteristics.
124        ///
125        /// Parameter `mediaSelectionOptions`: An array of AVMediaSelectionOptions to be filtered by media characteristic.
126        ///
127        /// Parameter `mediaCharacteristics`: The media characteristics that must be matched for a media selection option to be copied to the output array.
128        ///
129        /// Returns: An instance of NSArray containing the media selection options of the specified NSArray that match the specified
130        /// media characteristics.
131        #[unsafe(method(mediaSelectionOptionsFromArray:withMediaCharacteristics:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn mediaSelectionOptionsFromArray_withMediaCharacteristics(
134            media_selection_options: &NSArray<AVMediaSelectionOption>,
135            media_characteristics: &NSArray<AVMediaCharacteristic>,
136        ) -> Retained<NSArray<AVMediaSelectionOption>>;
137
138        #[cfg(feature = "AVMediaFormat")]
139        /// Filters an array of AVMediaSelectionOptions according to whether they lack one or more media characteristics.
140        ///
141        /// Parameter `mediaSelectionOptions`: An array of AVMediaSelectionOptions to be filtered by media characteristic.
142        ///
143        /// Parameter `mediaCharacteristics`: The media characteristics that must not be present for a media selection option to be copied to the output array.
144        ///
145        /// Returns: An instance of NSArray containing the media selection options of the specified NSArray that lack the specified
146        /// media characteristics.
147        #[unsafe(method(mediaSelectionOptionsFromArray:withoutMediaCharacteristics:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn mediaSelectionOptionsFromArray_withoutMediaCharacteristics(
150            media_selection_options: &NSArray<AVMediaSelectionOption>,
151            media_characteristics: &NSArray<AVMediaCharacteristic>,
152        ) -> Retained<NSArray<AVMediaSelectionOption>>;
153    );
154}
155
156extern_class!(
157    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmediaselectionoption?language=objc)
158    #[unsafe(super(NSObject))]
159    #[derive(Debug, PartialEq, Eq, Hash)]
160    pub struct AVMediaSelectionOption;
161);
162
163unsafe impl NSCopying for AVMediaSelectionOption {}
164
165unsafe impl CopyingHelper for AVMediaSelectionOption {
166    type Result = Self;
167}
168
169unsafe impl NSObjectProtocol for AVMediaSelectionOption {}
170
171impl AVMediaSelectionOption {
172    extern_methods!(
173        #[cfg(feature = "AVMediaFormat")]
174        /// The media type of the media data, e.g. AVMediaTypeAudio, AVMediaTypeSubtitle, etc.
175        #[unsafe(method(mediaType))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn mediaType(&self) -> Retained<AVMediaType>;
178
179        /// The mediaSubTypes of the media data associated with the option.
180        ///
181        /// An NSArray of NSNumbers carrying four character codes (of type FourCharCode) as defined in CoreAudioTypes.h for audio media and in CMFormatDescription.h for video media.
182        /// Also see CMFormatDescriptionGetMediaSubType in CMFormatDescription.h for more information about media subtypes.
183        ///
184        /// Note that if no information is available about the encoding of the media presented when a media option is selected, the value of mediaSubTypes will be an empty array. This can occur, for example, with streaming media. In these cases the value of mediaSubTypes should simply not be used as a criteria for selection.
185        #[unsafe(method(mediaSubTypes))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn mediaSubTypes(&self) -> Retained<NSArray<NSNumber>>;
188
189        #[cfg(feature = "AVMediaFormat")]
190        /// Reports whether the media selection option includes media with the specified media characteristic.
191        ///
192        /// Parameter `mediaCharacteristic`: The media characteristic of interest, e.g. AVMediaCharacteristicVisual, AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, etc.
193        ///
194        /// Returns: YES if the media selection option includes media with the specified characteristic, otherwise NO.
195        #[unsafe(method(hasMediaCharacteristic:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn hasMediaCharacteristic(
198            &self,
199            media_characteristic: &AVMediaCharacteristic,
200        ) -> bool;
201
202        /// Indicates whether a media selection option is playable.
203        ///
204        /// If the media data associated with the option cannot be decoded or otherwise rendered, playable is NO.
205        #[unsafe(method(isPlayable))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn isPlayable(&self) -> bool;
208
209        /// Indicates the RFC 4646 language tag associated with the option. May be nil.
210        #[unsafe(method(extendedLanguageTag))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn extendedLanguageTag(&self) -> Option<Retained<NSString>>;
213
214        /// Indicates the locale for which the media option was authored.
215        ///
216        /// Use -[NSLocale objectForKey:NSLocaleLanguageCode] to obtain the language code of the locale. See NSLocale.h for additional information.
217        #[unsafe(method(locale))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn locale(&self) -> Option<Retained<NSLocale>>;
220
221        #[cfg(feature = "AVMetadataItem")]
222        /// Provides an array of AVMetadataItems for each common metadata key for which a value is available.
223        ///
224        /// The array of AVMetadataItems can be filtered according to language via +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:], according to locale via +[AVMetadataItem metadataItemsFromArray:withLocale:],
225        /// or according to key via +[AVMetadataItem metadataItemsFromArray:withKey:keySpace:].
226        /// Example: to obtain the name (or title) of a media selection option in any of the user's preferred languages.
227        ///
228        /// NSString *title = nil;
229        /// NSArray *titles = [AVMetadataItem metadataItemsFromArray:[mediaSelectionOption commonMetadata] withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
230        /// if ([titles count] > 0)
231        /// {
232        /// // Try to get a title that matches one of the user's preferred languages.
233        /// NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles filteredAndSortedAccordingToPreferredLanguages:[NSLocale preferredLanguages]];
234        /// if ([titlesForPreferredLanguages count] > 0)
235        /// {
236        /// title = [[titlesForPreferredLanguages objectAtIndex:0] stringValue];
237        /// }
238        ///
239        /// // No matches in any of the preferred languages. Just use the primary title metadata we find.
240        /// if (title == nil)
241        /// {
242        /// title = [[titles objectAtIndex:0] stringValue];
243        /// }
244        /// }
245        #[unsafe(method(commonMetadata))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn commonMetadata(&self) -> Retained<NSArray<AVMetadataItem>>;
248
249        /// Provides an NSArray of NSStrings, each representing a metadata format that contains metadata associated with the option (e.g. ID3, iTunes metadata, etc.).
250        ///
251        /// Metadata formats are defined in AVMetadataFormat.h.
252        #[unsafe(method(availableMetadataFormats))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn availableMetadataFormats(&self) -> Retained<NSArray<NSString>>;
255
256        #[cfg(feature = "AVMetadataItem")]
257        /// Provides an NSArray of AVMetadataItems, one for each metadata item in the container of the specified format.
258        ///
259        /// Parameter `format`: The metadata format for which items are requested.
260        ///
261        /// Returns: An NSArray containing AVMetadataItems.
262        #[unsafe(method(metadataForFormat:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn metadataForFormat(
265            &self,
266            format: &NSString,
267        ) -> Retained<NSArray<AVMetadataItem>>;
268
269        /// If a media selection option in another group is associated with the specified option, returns a reference to the associated option.
270        ///
271        /// Parameter `mediaSelectionGroup`: A media selection group in which an associated option is to be sought.
272        ///
273        /// Returns: An instance of AVMediaSelectionOption.
274        ///
275        /// Audible media selection options often have associated legible media selection options; in particular, audible options are typically associated with forced-only subtitle options with the same locale. See AVMediaCharacteristicContainsOnlyForcedSubtitles in AVMediaFormat.h for a discussion of forced-only subtitles.
276        #[unsafe(method(associatedMediaSelectionOptionInMediaSelectionGroup:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn associatedMediaSelectionOptionInMediaSelectionGroup(
279            &self,
280            media_selection_group: &AVMediaSelectionGroup,
281        ) -> Option<Retained<AVMediaSelectionOption>>;
282
283        /// Returns a serializable property list that can be used to obtain an instance of AVMediaSelectionOption representing the same option as the receiver via -[AVMediaSelectionGroup mediaSelectionOptionWithPropertyList:].
284        ///
285        /// Returns: A serializable property list that's sufficient to identify the option within its group. For serialization utilities, see NSPropertyList.h.
286        #[unsafe(method(propertyList))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn propertyList(&self) -> Retained<AnyObject>;
289
290        /// Provides an NSString suitable for display.
291        ///
292        /// Parameter `locale`: Localize manufactured portions of the string using the specificed locale.
293        ///
294        /// May use this option's common metadata, media characteristics and locale properties in addition to the provided locale to formulate an NSString intended for display. Will only consider common metadata with the specified locale.
295        #[unsafe(method(displayNameWithLocale:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn displayNameWithLocale(&self, locale: &NSLocale) -> Retained<NSString>;
298
299        /// Provides an NSString suitable for display using the current system locale.
300        ///
301        /// May use this option's common metadata, media characteristics and locale properties in addition to the current system locale to formulate an NSString intended for display.
302        /// In the event that common metadata is not available in the specified locale, displayName will fall back to considering locales with the multilingual ("mul") then undetermined ("und") locale identifiers.
303        /// For a display name strictly with the specified locale use displayNameWithLocale: instead.
304        #[unsafe(method(displayName))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn displayName(&self) -> Retained<NSString>;
307    );
308}
309
310/// Methods declared on superclass `NSObject`.
311impl AVMediaSelectionOption {
312    extern_methods!(
313        #[unsafe(method(init))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
316
317        #[unsafe(method(new))]
318        #[unsafe(method_family = new)]
319        pub unsafe fn new() -> Retained<Self>;
320    );
321}