objc2_av_foundation/generated/
AVCompositionTrack.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    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcompositiontrack?language=objc)
16    #[unsafe(super(AVAssetTrack, NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    #[cfg(feature = "AVAssetTrack")]
19    pub struct AVCompositionTrack;
20);
21
22#[cfg(all(feature = "AVAssetTrack", feature = "AVAsynchronousKeyValueLoading"))]
23unsafe impl AVAsynchronousKeyValueLoading for AVCompositionTrack {}
24
25#[cfg(feature = "AVAssetTrack")]
26unsafe impl NSCopying for AVCompositionTrack {}
27
28#[cfg(feature = "AVAssetTrack")]
29unsafe impl CopyingHelper for AVCompositionTrack {
30    type Result = Self;
31}
32
33#[cfg(feature = "AVAssetTrack")]
34unsafe impl NSObjectProtocol for AVCompositionTrack {}
35
36#[cfg(feature = "AVAssetTrack")]
37impl AVCompositionTrack {
38    extern_methods!(
39        #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
40        /// Provides read-only access to the array of track segments, each an instance of AVCompositionTrackSegment.
41        ///
42        /// Note that timeMapping.target.start of the first AVCompositionTrackSegment must be kCMTimeZero, and the timeMapping.target.start of each subsequent AVCompositionTrackSegment must equal CMTimeRangeGetEnd(the previous AVCompositionTrackSegment's timeMapping.target).
43        /// Use -validateTrackSegments:error: to perform a test to ensure that an array of AVCompositionTrackSegments conforms to this rule.
44        #[unsafe(method(segments))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn segments(&self) -> Retained<NSArray<AVCompositionTrackSegment>>;
47
48        #[cfg(all(
49            feature = "AVAssetTrackSegment",
50            feature = "AVCompositionTrackSegment",
51            feature = "objc2-core-media"
52        ))]
53        /// Supplies the AVCompositionTrackSegment from the segments array with a target timeRange that either contains the specified track time or is the closest to it among the target timeRanges of the track's segments.
54        ///
55        /// Parameter `trackTime`: The trackTime for which an AVCompositionTrackSegment is requested.
56        ///
57        /// Returns: An AVCompositionTrackSegment.
58        ///
59        /// If the trackTime does not map to a sample presentation time (e.g. it's outside the track's timeRange), the segment closest in time to the specified trackTime is returned.
60        #[unsafe(method(segmentForTrackTime:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn segmentForTrackTime(
63            &self,
64            track_time: CMTime,
65        ) -> Option<Retained<AVCompositionTrackSegment>>;
66
67        /// An array of AVCompositionTrackFormatDescriptionReplacement objects indicating original format descriptions and their replacements.
68        ///
69        /// The value of this property is an array of AVCompositionTrackFormatDescriptionReplacement objects, each of which specifies an original format description together with its replacement format description (as specified by a previous call to -replaceFormatDescription:withFormatDescription:). Only format descriptions that are to be replaced will occur as the originalFormatDescription elements in the AVCompositionTrackFormatDescriptionReplacement objects in this array.
70        #[unsafe(method(formatDescriptionReplacements))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn formatDescriptionReplacements(
73            &self,
74        ) -> Retained<NSArray<AVCompositionTrackFormatDescriptionReplacement>>;
75    );
76}
77
78/// Methods declared on superclass `AVAssetTrack`.
79#[cfg(feature = "AVAssetTrack")]
80impl AVCompositionTrack {
81    extern_methods!(
82        #[unsafe(method(init))]
83        #[unsafe(method_family = init)]
84        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
85
86        #[unsafe(method(new))]
87        #[unsafe(method_family = new)]
88        pub unsafe fn new() -> Retained<Self>;
89    );
90}
91
92extern_class!(
93    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablecompositiontrack?language=objc)
94    #[unsafe(super(AVCompositionTrack, AVAssetTrack, NSObject))]
95    #[derive(Debug, PartialEq, Eq, Hash)]
96    #[cfg(feature = "AVAssetTrack")]
97    pub struct AVMutableCompositionTrack;
98);
99
100#[cfg(all(feature = "AVAssetTrack", feature = "AVAsynchronousKeyValueLoading"))]
101unsafe impl AVAsynchronousKeyValueLoading for AVMutableCompositionTrack {}
102
103#[cfg(feature = "AVAssetTrack")]
104unsafe impl NSCopying for AVMutableCompositionTrack {}
105
106#[cfg(feature = "AVAssetTrack")]
107unsafe impl CopyingHelper for AVMutableCompositionTrack {
108    type Result = Self;
109}
110
111#[cfg(feature = "AVAssetTrack")]
112unsafe impl NSObjectProtocol for AVMutableCompositionTrack {}
113
114#[cfg(feature = "AVAssetTrack")]
115impl AVMutableCompositionTrack {
116    extern_methods!(
117        /// Specifies whether the track is enabled or disabled.  Default is YES.
118        #[unsafe(method(isEnabled))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn isEnabled(&self) -> bool;
121
122        /// Setter for [`isEnabled`][Self::isEnabled].
123        #[unsafe(method(setEnabled:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setEnabled(&self, enabled: bool);
126
127        #[cfg(feature = "objc2-core-media")]
128        /// Indicates a timescale in which time values for the track can be operated upon without extraneous numerical conversion.
129        ///
130        /// If not set, the value is the naturalTimeScale of the first non-empty edit, or 600 if there are no non-empty edits.
131        /// Set to 0 to revert to default behavior.
132        #[unsafe(method(naturalTimeScale))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn naturalTimeScale(&self) -> CMTimeScale;
135
136        #[cfg(feature = "objc2-core-media")]
137        /// Setter for [`naturalTimeScale`][Self::naturalTimeScale].
138        #[unsafe(method(setNaturalTimeScale:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setNaturalTimeScale(&self, natural_time_scale: CMTimeScale);
141
142        /// Indicates the language associated with the track, as an ISO 639-2/T language code.
143        ///
144        /// The default value is nil.
145        #[unsafe(method(languageCode))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn languageCode(&self) -> Option<Retained<NSString>>;
148
149        /// Setter for [`languageCode`][Self::languageCode].
150        #[unsafe(method(setLanguageCode:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setLanguageCode(&self, language_code: Option<&NSString>);
153
154        /// Indicates the language tag associated with the track, as an IETF BCP 47 (RFC 4646) language identifier.
155        ///
156        /// The default value is nil.
157        #[unsafe(method(extendedLanguageTag))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn extendedLanguageTag(&self) -> Option<Retained<NSString>>;
160
161        /// Setter for [`extendedLanguageTag`][Self::extendedLanguageTag].
162        #[unsafe(method(setExtendedLanguageTag:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setExtendedLanguageTag(&self, extended_language_tag: Option<&NSString>);
165
166        #[cfg(feature = "objc2-core-foundation")]
167        /// The preferred transformation of the visual media data for display purposes.
168        ///
169        /// The default value is CGAffineTransformIdentity.
170        #[unsafe(method(preferredTransform))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
173
174        #[cfg(feature = "objc2-core-foundation")]
175        /// Setter for [`preferredTransform`][Self::preferredTransform].
176        #[unsafe(method(setPreferredTransform:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setPreferredTransform(&self, preferred_transform: CGAffineTransform);
179
180        /// The preferred volume of the audible media data.
181        ///
182        /// The default value is 1.0.
183        #[unsafe(method(preferredVolume))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn preferredVolume(&self) -> c_float;
186
187        /// Setter for [`preferredVolume`][Self::preferredVolume].
188        #[unsafe(method(setPreferredVolume:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setPreferredVolume(&self, preferred_volume: c_float);
191
192        #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
193        /// Provides read/write access to the array of track segments, each an instance of AVCompositionTrackSegment.
194        ///
195        /// Note that timeMapping.target.start of the first AVCompositionTrackSegment must be kCMTimeZero, and the timeMapping.target.start of each subsequent AVCompositionTrackSegment must equal CMTimeRangeGetEnd(the previous AVCompositionTrackSegment's timeMapping.target).
196        /// Use -validateTrackSegments:error: to perform a test to ensure that an array of AVCompositionTrackSegments conforms to this rule.
197        #[unsafe(method(segments))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn segments(&self) -> Retained<NSArray<AVCompositionTrackSegment>>;
200
201        #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
202        /// Setter for [`segments`][Self::segments].
203        #[unsafe(method(setSegments:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setSegments(&self, segments: Option<&NSArray<AVCompositionTrackSegment>>);
206
207        #[cfg(feature = "objc2-core-media")]
208        /// Inserts a timeRange of a source track into a track of a composition.
209        ///
210        /// Parameter `timeRange`: Specifies the timeRange of the track to be inserted.
211        ///
212        /// Parameter `track`: Specifies the source track to be inserted. Only AVAssetTracks of AVURLAssets and AVCompositions are supported (AVCompositions starting in macOS 10.10 and iOS 8.0).
213        ///
214        /// Parameter `startTime`: Specifies the time at which the inserted track is to be presented by the composition track. You may pass kCMTimeInvalid for startTime to indicate that the timeRange should be appended to the end of the track.
215        ///
216        /// Parameter `error`: Describes failures that may be reported to the user, e.g. the asset that was selected for insertion in the composition is restricted by copy-protection.
217        ///
218        /// Returns: A BOOL value indicating the success of the insertion.
219        ///
220        /// You provide a reference to an AVAssetTrack and the timeRange within it that you want to insert. You specify the start time in the target composition track at which the timeRange should be inserted.
221        ///
222        /// Note that the inserted track timeRange will be presented at its natural duration and rate. It can be scaled to a different duration (and presented at a different rate) via -scaleTimeRange:toDuration:.
223        #[unsafe(method(insertTimeRange:ofTrack:atTime:error:_))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn insertTimeRange_ofTrack_atTime_error(
226            &self,
227            time_range: CMTimeRange,
228            track: &AVAssetTrack,
229            start_time: CMTime,
230        ) -> Result<(), Retained<NSError>>;
231
232        #[cfg(feature = "objc2-core-media")]
233        /// Inserts the timeRanges of multiple source tracks into a track of a composition.
234        ///
235        /// Parameter `timeRanges`: Specifies the timeRanges to be inserted. An NSArray of NSValues containing CMTimeRange. (See +[NSValue valueWithCMTimeRange:] in AVTime.h.)
236        ///
237        /// Parameter `tracks`: Specifies the source tracks to be inserted. Only AVAssetTracks of AVURLAssets and AVCompositions are supported (AVCompositions starting in macOS 10.10 and iOS 8.0).
238        ///
239        /// Parameter `startTime`: Specifies the time at which the inserted tracks are to be presented by the composition track. You may pass kCMTimeInvalid for startTime to indicate that the timeRanges should be appended to the end of the track.
240        ///
241        /// Parameter `error`: Describes failures that may be reported to the user, e.g. the asset that was selected for insertion in the composition is restricted by copy-protection.
242        ///
243        /// Returns: A BOOL value indicating the success of the insertion.
244        ///
245        /// This method is equivalent to (but more efficient than) calling -insertTimeRange:ofTrack:atTime:error: for each timeRange/track pair. If this method returns an error, none of the time ranges will be inserted into the composition track. To specify an empty time range, pass NSNull for the track and a time range of starting at kCMTimeInvalid with a duration of the desired empty edit.
246        /// This method throws an exception if time ranges and tracks to not have the same array count.
247        #[unsafe(method(insertTimeRanges:ofTracks:atTime:error:_))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn insertTimeRanges_ofTracks_atTime_error(
250            &self,
251            time_ranges: &NSArray<NSValue>,
252            tracks: &NSArray<AVAssetTrack>,
253            start_time: CMTime,
254        ) -> Result<(), Retained<NSError>>;
255
256        #[cfg(feature = "objc2-core-media")]
257        /// Adds or extends an empty timeRange within the composition track.
258        ///
259        /// Parameter `timeRange`: Specifies the empty timeRange to be inserted.
260        ///
261        /// If you insert an empty timeRange into the track, any media that was presented during that interval prior to the insertion will be presented instead immediately afterward.
262        /// The exact meaning of the term "empty timeRange" depends upon the mediaType of the track. For example, an empty timeRange in a sound track presents silence.
263        /// Note that you cannot add empty time ranges to the end of a composition track.
264        #[unsafe(method(insertEmptyTimeRange:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn insertEmptyTimeRange(&self, time_range: CMTimeRange);
267
268        #[cfg(feature = "objc2-core-media")]
269        /// Removes a specified timeRange from the track.
270        ///
271        /// Parameter `timeRange`: Specifies the timeRange to be removed.
272        ///
273        /// Removal of a timeRange does not cause the track to be removed from the composition. Instead it removes or truncates track segments that intersect with the timeRange.
274        #[unsafe(method(removeTimeRange:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn removeTimeRange(&self, time_range: CMTimeRange);
277
278        #[cfg(feature = "objc2-core-media")]
279        /// Changes the duration of a timeRange of the track.
280        ///
281        /// Parameter `timeRange`: Specifies the timeRange of the track to be scaled.
282        ///
283        /// Parameter `duration`: Specifies the new duration of the timeRange.
284        ///
285        /// Each trackSegment affected by the scaling operation will be presented at a rate equal to source.duration / target.duration of its resulting timeMapping.
286        #[unsafe(method(scaleTimeRange:toDuration:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn scaleTimeRange_toDuration(&self, time_range: CMTimeRange, duration: CMTime);
289
290        #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
291        /// Tests an array of AVCompositionTrackSegments to determine whether they conform to the timing rules noted above (see the property key
292        /// "
293        /// trackSegments").
294        ///
295        /// Parameter `trackSegments`: The array of AVCompositionTrackSegments to be validated.
296        ///
297        /// Parameter `error`: If validation fais, returns information about the failure.
298        ///
299        /// Returns: YES if validation suceeds, otherwise NO.
300        ///
301        /// The array is tested for suitability for setting as the value of the trackSegments property. If a portion of an existing trackSegments array is to be modified, the modification can be made via an instance of NSMutableArray, and the resulting array can be tested via -validateTrackSegments:error:.
302        #[unsafe(method(validateTrackSegments:error:_))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn validateTrackSegments_error(
305            &self,
306            track_segments: &NSArray<AVCompositionTrackSegment>,
307        ) -> Result<(), Retained<NSError>>;
308
309        /// Establishes a track association of a specific type between two tracks.
310        ///
311        /// Parameter `compositionTrack`: An AVCompositionTrack object that is to be associated with the receiver.
312        ///
313        /// Parameter `trackAssociationType`: The type of track association to add between the receiver and the specified compositionTrack (for instance, AVTrackAssociationTypeChapterList).
314        #[unsafe(method(addTrackAssociationToTrack:type:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn addTrackAssociationToTrack_type(
317            &self,
318            composition_track: &AVCompositionTrack,
319            track_association_type: &AVTrackAssociationType,
320        );
321
322        /// Removes a track association of a specific type between two tracks.
323        ///
324        /// Parameter `compositionTrack`: An AVCompositionTrack object that is associated with the receiver.
325        ///
326        /// Parameter `trackAssociationType`: The type of track association to remove between the receiver and the specified compositionTrack (for instance, AVTrackAssociationTypeChapterList).
327        #[unsafe(method(removeTrackAssociationToTrack:type:))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn removeTrackAssociationToTrack_type(
330            &self,
331            composition_track: &AVCompositionTrack,
332            track_association_type: &AVTrackAssociationType,
333        );
334    );
335}
336
337/// Methods declared on superclass `AVAssetTrack`.
338#[cfg(feature = "AVAssetTrack")]
339impl AVMutableCompositionTrack {
340    extern_methods!(
341        #[unsafe(method(init))]
342        #[unsafe(method_family = init)]
343        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
344
345        #[unsafe(method(new))]
346        #[unsafe(method_family = new)]
347        pub unsafe fn new() -> Retained<Self>;
348    );
349}
350
351extern_class!(
352    /// A format description and its replacement.
353    ///
354    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
355    ///
356    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcompositiontrackformatdescriptionreplacement?language=objc)
357    #[unsafe(super(NSObject))]
358    #[derive(Debug, PartialEq, Eq, Hash)]
359    pub struct AVCompositionTrackFormatDescriptionReplacement;
360);
361
362unsafe impl Send for AVCompositionTrackFormatDescriptionReplacement {}
363
364unsafe impl Sync for AVCompositionTrackFormatDescriptionReplacement {}
365
366unsafe impl NSCoding for AVCompositionTrackFormatDescriptionReplacement {}
367
368unsafe impl NSObjectProtocol for AVCompositionTrackFormatDescriptionReplacement {}
369
370unsafe impl NSSecureCoding for AVCompositionTrackFormatDescriptionReplacement {}
371
372impl AVCompositionTrackFormatDescriptionReplacement {
373    extern_methods!(
374        #[cfg(feature = "objc2-core-media")]
375        /// The original format description.
376        #[unsafe(method(originalFormatDescription))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn originalFormatDescription(&self) -> Retained<CMFormatDescription>;
379
380        #[cfg(feature = "objc2-core-media")]
381        /// The replacement format description.
382        #[unsafe(method(replacementFormatDescription))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn replacementFormatDescription(&self) -> Retained<CMFormatDescription>;
385    );
386}
387
388/// Methods declared on superclass `NSObject`.
389impl AVCompositionTrackFormatDescriptionReplacement {
390    extern_methods!(
391        #[unsafe(method(init))]
392        #[unsafe(method_family = init)]
393        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
394
395        #[unsafe(method(new))]
396        #[unsafe(method_family = new)]
397        pub unsafe fn new() -> Retained<Self>;
398    );
399}
400
401/// AVMutableCompositionTrackFormatDescriptionReplacement.
402#[cfg(feature = "AVAssetTrack")]
403impl AVMutableCompositionTrack {
404    extern_methods!(
405        #[cfg(feature = "objc2-core-media")]
406        /// Replaces one of the receiver's format descriptions with another format description or cancels a previous replacement.
407        ///
408        /// Parameter `originalFormatDescription`: A CMFormatDescription occurring in the underlying asset track.
409        ///
410        /// Parameter `replacementFormatDescription`: A CMFormatDescription to replace the specified format description or NULL to indicate that a previous replacement of originalFormatDescription should be cancelled.
411        ///
412        /// You can use this method to make surgical changes to a track's format descriptions, such as adding format description extensions to a format description or changing the audio channel layout of an audio track. You should note that a format description can have extensions of type kCMFormatDescriptionExtension_VerbatimSampleDescription and kCMFormatDescriptionExtension_VerbatimISOSampleEntry; if you modify a copy of a format description, you should delete those extensions from the copy or your changes might be ignored. Also note that format description replacements are not transferred when performing editing operations on AVMutableCompositionTrack objects; for instance, inserting a range of a composition track into another composition track does not transfer any replacement format descriptions.
413        /// This method throws an exception if the media type of the replacement does not match the original format description.
414        #[unsafe(method(replaceFormatDescription:withFormatDescription:))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn replaceFormatDescription_withFormatDescription(
417            &self,
418            original_format_description: &CMFormatDescription,
419            replacement_format_description: Option<&CMFormatDescription>,
420        );
421    );
422}
423
424/// SynchronousTrackInterface.
425/// Redeclarations of async-only AVAssetTrack interfaces to allow synchronous usage in the synchronous subclass.
426///
427/// See AVAssetTrack's interface for more information about these interfaces.
428#[cfg(feature = "AVAssetTrack")]
429impl AVCompositionTrack {
430    extern_methods!(
431        #[cfg(feature = "AVMediaFormat")]
432        #[unsafe(method(hasMediaCharacteristic:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn hasMediaCharacteristic(
435            &self,
436            media_characteristic: &AVMediaCharacteristic,
437        ) -> bool;
438
439        #[cfg(feature = "objc2-core-media")]
440        #[unsafe(method(samplePresentationTimeForTrackTime:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn samplePresentationTimeForTrackTime(&self, track_time: CMTime) -> CMTime;
443
444        #[cfg(all(feature = "AVMetadataFormat", feature = "AVMetadataItem"))]
445        #[unsafe(method(metadataForFormat:))]
446        #[unsafe(method_family = none)]
447        pub unsafe fn metadataForFormat(
448            &self,
449            format: &AVMetadataFormat,
450        ) -> Retained<NSArray<AVMetadataItem>>;
451
452        #[unsafe(method(associatedTracksOfType:))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn associatedTracksOfType(
455            &self,
456            track_association_type: &AVTrackAssociationType,
457        ) -> Retained<NSArray<AVAssetTrack>>;
458    );
459}