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 ///
163 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
164 #[unsafe(method(setLanguageCode:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn setLanguageCode(&self, language_code: Option<&NSString>);
167
168 /// Indicates the language tag associated with the track, as an IETF BCP 47 (RFC 4646) language identifier.
169 ///
170 /// The default value is nil.
171 #[unsafe(method(extendedLanguageTag))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn extendedLanguageTag(&self) -> Option<Retained<NSString>>;
174
175 /// Setter for [`extendedLanguageTag`][Self::extendedLanguageTag].
176 ///
177 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
178 #[unsafe(method(setExtendedLanguageTag:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn setExtendedLanguageTag(&self, extended_language_tag: Option<&NSString>);
181
182 #[cfg(feature = "objc2-core-foundation")]
183 /// The preferred transformation of the visual media data for display purposes.
184 ///
185 /// The default value is CGAffineTransformIdentity.
186 #[unsafe(method(preferredTransform))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
189
190 #[cfg(feature = "objc2-core-foundation")]
191 /// Setter for [`preferredTransform`][Self::preferredTransform].
192 #[unsafe(method(setPreferredTransform:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn setPreferredTransform(&self, preferred_transform: CGAffineTransform);
195
196 /// The preferred volume of the audible media data.
197 ///
198 /// The default value is 1.0.
199 #[unsafe(method(preferredVolume))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn preferredVolume(&self) -> c_float;
202
203 /// Setter for [`preferredVolume`][Self::preferredVolume].
204 #[unsafe(method(setPreferredVolume:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn setPreferredVolume(&self, preferred_volume: c_float);
207
208 #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
209 /// Provides read/write access to the array of track segments, each an instance of AVCompositionTrackSegment.
210 ///
211 /// 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).
212 /// Use -validateTrackSegments:error: to perform a test to ensure that an array of AVCompositionTrackSegments conforms to this rule.
213 #[unsafe(method(segments))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn segments(&self) -> Retained<NSArray<AVCompositionTrackSegment>>;
216
217 #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
218 /// Setter for [`segments`][Self::segments].
219 ///
220 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
221 #[unsafe(method(setSegments:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setSegments(&self, segments: Option<&NSArray<AVCompositionTrackSegment>>);
224
225 #[cfg(feature = "objc2-core-media")]
226 /// Inserts a timeRange of a source track into a track of a composition.
227 ///
228 /// Parameter `timeRange`: Specifies the timeRange of the track to be inserted.
229 ///
230 /// 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).
231 ///
232 /// 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.
233 ///
234 /// 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.
235 ///
236 /// Returns: A BOOL value indicating the success of the insertion.
237 ///
238 /// 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.
239 ///
240 /// 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:.
241 #[unsafe(method(insertTimeRange:ofTrack:atTime:error:_))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn insertTimeRange_ofTrack_atTime_error(
244 &self,
245 time_range: CMTimeRange,
246 track: &AVAssetTrack,
247 start_time: CMTime,
248 ) -> Result<(), Retained<NSError>>;
249
250 #[cfg(feature = "objc2-core-media")]
251 /// Inserts the timeRanges of multiple source tracks into a track of a composition.
252 ///
253 /// Parameter `timeRanges`: Specifies the timeRanges to be inserted. An NSArray of NSValues containing CMTimeRange. (See +[NSValue valueWithCMTimeRange:] in AVTime.h.)
254 ///
255 /// 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).
256 ///
257 /// 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.
258 ///
259 /// 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.
260 ///
261 /// Returns: A BOOL value indicating the success of the insertion.
262 ///
263 /// 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.
264 /// This method throws an exception if time ranges and tracks to not have the same array count.
265 #[unsafe(method(insertTimeRanges:ofTracks:atTime:error:_))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn insertTimeRanges_ofTracks_atTime_error(
268 &self,
269 time_ranges: &NSArray<NSValue>,
270 tracks: &NSArray<AVAssetTrack>,
271 start_time: CMTime,
272 ) -> Result<(), Retained<NSError>>;
273
274 #[cfg(feature = "objc2-core-media")]
275 /// Adds or extends an empty timeRange within the composition track.
276 ///
277 /// Parameter `timeRange`: Specifies the empty timeRange to be inserted.
278 ///
279 /// 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.
280 /// 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.
281 /// Note that you cannot add empty time ranges to the end of a composition track.
282 #[unsafe(method(insertEmptyTimeRange:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn insertEmptyTimeRange(&self, time_range: CMTimeRange);
285
286 #[cfg(feature = "objc2-core-media")]
287 /// Removes a specified timeRange from the track.
288 ///
289 /// Parameter `timeRange`: Specifies the timeRange to be removed.
290 ///
291 /// 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.
292 #[unsafe(method(removeTimeRange:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn removeTimeRange(&self, time_range: CMTimeRange);
295
296 #[cfg(feature = "objc2-core-media")]
297 /// Changes the duration of a timeRange of the track.
298 ///
299 /// Parameter `timeRange`: Specifies the timeRange of the track to be scaled.
300 ///
301 /// Parameter `duration`: Specifies the new duration of the timeRange.
302 ///
303 /// Each trackSegment affected by the scaling operation will be presented at a rate equal to source.duration / target.duration of its resulting timeMapping.
304 #[unsafe(method(scaleTimeRange:toDuration:))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn scaleTimeRange_toDuration(&self, time_range: CMTimeRange, duration: CMTime);
307
308 #[cfg(all(feature = "AVAssetTrackSegment", feature = "AVCompositionTrackSegment"))]
309 /// Tests an array of AVCompositionTrackSegments to determine whether they conform to the timing rules noted above (see the property key
310 /// "
311 /// trackSegments").
312 ///
313 /// Parameter `trackSegments`: The array of AVCompositionTrackSegments to be validated.
314 ///
315 /// Parameter `error`: If validation fais, returns information about the failure.
316 ///
317 /// Returns: YES if validation suceeds, otherwise NO.
318 ///
319 /// 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:.
320 #[unsafe(method(validateTrackSegments:error:_))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn validateTrackSegments_error(
323 &self,
324 track_segments: &NSArray<AVCompositionTrackSegment>,
325 ) -> Result<(), Retained<NSError>>;
326
327 /// Establishes a track association of a specific type between two tracks.
328 ///
329 /// Parameter `compositionTrack`: An AVCompositionTrack object that is to be associated with the receiver.
330 ///
331 /// Parameter `trackAssociationType`: The type of track association to add between the receiver and the specified compositionTrack (for instance, AVTrackAssociationTypeChapterList).
332 #[unsafe(method(addTrackAssociationToTrack:type:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn addTrackAssociationToTrack_type(
335 &self,
336 composition_track: &AVCompositionTrack,
337 track_association_type: &AVTrackAssociationType,
338 );
339
340 /// Removes a track association of a specific type between two tracks.
341 ///
342 /// Parameter `compositionTrack`: An AVCompositionTrack object that is associated with the receiver.
343 ///
344 /// Parameter `trackAssociationType`: The type of track association to remove between the receiver and the specified compositionTrack (for instance, AVTrackAssociationTypeChapterList).
345 #[unsafe(method(removeTrackAssociationToTrack:type:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn removeTrackAssociationToTrack_type(
348 &self,
349 composition_track: &AVCompositionTrack,
350 track_association_type: &AVTrackAssociationType,
351 );
352 );
353}
354
355/// Methods declared on superclass `AVAssetTrack`.
356#[cfg(feature = "AVAssetTrack")]
357impl AVMutableCompositionTrack {
358 extern_methods!(
359 #[unsafe(method(init))]
360 #[unsafe(method_family = init)]
361 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
362
363 #[unsafe(method(new))]
364 #[unsafe(method_family = new)]
365 pub unsafe fn new() -> Retained<Self>;
366 );
367}
368
369extern_class!(
370 /// A format description and its replacement.
371 ///
372 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
373 ///
374 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcompositiontrackformatdescriptionreplacement?language=objc)
375 #[unsafe(super(NSObject))]
376 #[derive(Debug, PartialEq, Eq, Hash)]
377 pub struct AVCompositionTrackFormatDescriptionReplacement;
378);
379
380unsafe impl Send for AVCompositionTrackFormatDescriptionReplacement {}
381
382unsafe impl Sync for AVCompositionTrackFormatDescriptionReplacement {}
383
384extern_conformance!(
385 unsafe impl NSCoding for AVCompositionTrackFormatDescriptionReplacement {}
386);
387
388extern_conformance!(
389 unsafe impl NSObjectProtocol for AVCompositionTrackFormatDescriptionReplacement {}
390);
391
392extern_conformance!(
393 unsafe impl NSSecureCoding for AVCompositionTrackFormatDescriptionReplacement {}
394);
395
396impl AVCompositionTrackFormatDescriptionReplacement {
397 extern_methods!(
398 #[cfg(feature = "objc2-core-media")]
399 /// The original format description.
400 #[unsafe(method(originalFormatDescription))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn originalFormatDescription(&self) -> Retained<CMFormatDescription>;
403
404 #[cfg(feature = "objc2-core-media")]
405 /// The replacement format description.
406 #[unsafe(method(replacementFormatDescription))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn replacementFormatDescription(&self) -> Retained<CMFormatDescription>;
409 );
410}
411
412/// Methods declared on superclass `NSObject`.
413impl AVCompositionTrackFormatDescriptionReplacement {
414 extern_methods!(
415 #[unsafe(method(init))]
416 #[unsafe(method_family = init)]
417 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
418
419 #[unsafe(method(new))]
420 #[unsafe(method_family = new)]
421 pub unsafe fn new() -> Retained<Self>;
422 );
423}
424
425/// AVMutableCompositionTrackFormatDescriptionReplacement.
426#[cfg(feature = "AVAssetTrack")]
427impl AVMutableCompositionTrack {
428 extern_methods!(
429 #[cfg(feature = "objc2-core-media")]
430 /// Replaces one of the receiver's format descriptions with another format description or cancels a previous replacement.
431 ///
432 /// Parameter `originalFormatDescription`: A CMFormatDescription occurring in the underlying asset track.
433 ///
434 /// Parameter `replacementFormatDescription`: A CMFormatDescription to replace the specified format description or NULL to indicate that a previous replacement of originalFormatDescription should be cancelled.
435 ///
436 /// 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.
437 /// This method throws an exception if the media type of the replacement does not match the original format description.
438 #[unsafe(method(replaceFormatDescription:withFormatDescription:))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn replaceFormatDescription_withFormatDescription(
441 &self,
442 original_format_description: &CMFormatDescription,
443 replacement_format_description: Option<&CMFormatDescription>,
444 );
445 );
446}
447
448/// SynchronousTrackInterface.
449///
450/// Redeclarations of async-only AVAssetTrack interfaces to allow synchronous usage in the synchronous subclass.
451///
452/// See AVAssetTrack's interface for more information about these interfaces.
453#[cfg(feature = "AVAssetTrack")]
454impl AVCompositionTrack {
455 extern_methods!(
456 #[cfg(feature = "AVMediaFormat")]
457 #[unsafe(method(hasMediaCharacteristic:))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn hasMediaCharacteristic(
460 &self,
461 media_characteristic: &AVMediaCharacteristic,
462 ) -> bool;
463
464 #[cfg(feature = "objc2-core-media")]
465 #[unsafe(method(samplePresentationTimeForTrackTime:))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn samplePresentationTimeForTrackTime(&self, track_time: CMTime) -> CMTime;
468
469 #[cfg(all(feature = "AVMetadataFormat", feature = "AVMetadataItem"))]
470 #[unsafe(method(metadataForFormat:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn metadataForFormat(
473 &self,
474 format: &AVMetadataFormat,
475 ) -> Retained<NSArray<AVMetadataItem>>;
476
477 #[unsafe(method(associatedTracksOfType:))]
478 #[unsafe(method_family = none)]
479 pub unsafe fn associatedTracksOfType(
480 &self,
481 track_association_type: &AVTrackAssociationType,
482 ) -> Retained<NSArray<AVAssetTrack>>;
483 );
484}