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