objc2_av_foundation/generated/AVSampleCursor.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::*;
5#[cfg(feature = "objc2-core-media")]
6use objc2_core_media::*;
7use objc2_foundation::*;
8
9use crate::*;
10
11extern_class!(
12 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursor?language=objc)
13 #[unsafe(super(NSObject))]
14 #[derive(Debug, PartialEq, Eq, Hash)]
15 pub struct AVSampleCursor;
16);
17
18unsafe impl Send for AVSampleCursor {}
19
20unsafe impl Sync for AVSampleCursor {}
21
22extern_conformance!(
23 unsafe impl NSCopying for AVSampleCursor {}
24);
25
26unsafe impl CopyingHelper for AVSampleCursor {
27 type Result = Self;
28}
29
30extern_conformance!(
31 unsafe impl NSObjectProtocol for AVSampleCursor {}
32);
33
34impl AVSampleCursor {
35 extern_methods!(
36 #[unsafe(method(init))]
37 #[unsafe(method_family = init)]
38 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
39
40 #[unsafe(method(new))]
41 #[unsafe(method_family = new)]
42 pub unsafe fn new() -> Retained<Self>;
43
44 /// Moves the cursor a given number of samples in decode order.
45 ///
46 /// Parameter `stepCount`: The number of samples to move across. If positive, step forward this many samples. If negative, step backward (-stepCount) samples.
47 ///
48 /// Returns: The number of samples the cursor traversed. If the beginning or the end of the sample sequence was reached before the requested number of samples was traversed, the absolute value of the result will be less than the absolute value of stepCount.
49 #[unsafe(method(stepInDecodeOrderByCount:))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn stepInDecodeOrderByCount(&self, step_count: i64) -> i64;
52
53 /// Moves the cursor a given number of samples in presentation order.
54 ///
55 /// Parameter `stepCount`: The number of samples to move across. If positive, step forward this many samples. If negative, step backward (-stepCount) samples.
56 ///
57 /// Returns: The number of samples the cursor traversed. If the beginning or the end of the sample sequence was reached before the requested number of samples was traversed, the absolute value of the result will be less than the absolute value of stepCount.
58 #[unsafe(method(stepInPresentationOrderByCount:))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn stepInPresentationOrderByCount(&self, step_count: i64) -> i64;
61
62 #[cfg(feature = "objc2-core-media")]
63 /// Moves the cursor by a given deltaTime on the decode timeline.
64 ///
65 /// Parameter `deltaDecodeTime`: The amount of time to move in the decode timeline.
66 ///
67 /// Parameter `outWasPinned`: If the beginning or the end of the sample sequence was reached before the requested deltaDecodeTime was traversed, the BOOL value at the address specified by outWasPinned will be set to YES. May be NULL if this information isn't desired.
68 ///
69 /// Returns: The amount of time the cursor was moved along the decode timeline. Because sample cursors snap to sample boundaries when stepped, this value may not be equal to deltaDecodeTime even if the cursor was not pinned.
70 #[unsafe(method(stepByDecodeTime:wasPinned:))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn stepByDecodeTime_wasPinned(
73 &self,
74 delta_decode_time: CMTime,
75 out_was_pinned: *mut Bool,
76 ) -> CMTime;
77
78 #[cfg(feature = "objc2-core-media")]
79 /// Moves the cursor by a given deltaTime on the presentation timeline.
80 ///
81 /// Parameter `deltaPresentationTime`: The amount of time to move in the presentation timeline.
82 ///
83 /// Parameter `outWasPinned`: If the beginning or the end of the sample sequence was reached before the requested deltaPresentationTime was traversed, the BOOL value at the address specified by outWasPinned will be set to YES. May be NULL if this information isn't desired.
84 ///
85 /// Returns: The amount of time the cursor was moved along the presentation timeline. Because sample cursors snap to sample boundaries when stepped, this value may not be equal to deltaPresentationTime even if the cursor was not pinned.
86 #[unsafe(method(stepByPresentationTime:wasPinned:))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn stepByPresentationTime_wasPinned(
89 &self,
90 delta_presentation_time: CMTime,
91 out_was_pinned: *mut Bool,
92 ) -> CMTime;
93 );
94}
95
96/// AVSampleCursorTemporalPosition.
97impl AVSampleCursor {
98 extern_methods!(
99 #[cfg(feature = "objc2-core-media")]
100 /// The presentation timestamp (PTS) of the sample at the current position of the cursor.
101 #[unsafe(method(presentationTimeStamp))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn presentationTimeStamp(&self) -> CMTime;
104
105 #[cfg(feature = "objc2-core-media")]
106 /// The decode timestamp (DTS) of the sample at the current position of the cursor.
107 #[unsafe(method(decodeTimeStamp))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn decodeTimeStamp(&self) -> CMTime;
110
111 /// Compares the relative positions of two AVSampleCursors.
112 ///
113 /// Parameter `cursor`: An instance of AVSampleCursor with which to compare positions.
114 ///
115 /// Returns: kCFCompareLessThan, kCFCompareEqualTo or kCFCompareGreaterThan, depending on whether the receiver points at a sample before, the same as, or after the sample pointed to by the specified AVSampleCursor.
116 ///
117 /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
118 #[unsafe(method(comparePositionInDecodeOrderWithPositionOfCursor:))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn comparePositionInDecodeOrderWithPositionOfCursor(
121 &self,
122 cursor: &AVSampleCursor,
123 ) -> NSComparisonResult;
124
125 /// This method tests a boundary in the reordering from decode order to presentation order, determining whether it's possible for any sample earlier in decode order than the sample at the position of the receiver can have a presentation timestamp later than that of the specified sample cursor.
126 ///
127 /// Parameter `cursor`: An instance of AVSampleCursor with which to test the sample reordering boundary.
128 ///
129 /// Returns: YES if it's possible for any sample earlier in decode order than the sample at the position of the receiver can have a presentation timestamp later than that of the specified sample cursor.
130 ///
131 /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
132 #[unsafe(method(samplesWithEarlierDecodeTimeStampsMayHaveLaterPresentationTimeStampsThanCursor:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn samplesWithEarlierDecodeTimeStampsMayHaveLaterPresentationTimeStampsThanCursor(
135 &self,
136 cursor: &AVSampleCursor,
137 ) -> bool;
138
139 /// This method tests a boundary in the reordering from decode order to presentation order, determining whether it's possible for any sample later in decode order than the sample at the position of the receiver can have a presentation timestamp earlier than that of the specified sample cursor.
140 ///
141 /// Parameter `cursor`: An instance of AVSampleCursor with which to test the sample reordering boundary.
142 ///
143 /// Returns: YES if it's possible for any sample later in decode order than the sample at the position of the receiver can have a presentation timestamp earlier than that of the specified sample cursor.
144 ///
145 /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
146 #[unsafe(method(samplesWithLaterDecodeTimeStampsMayHaveEarlierPresentationTimeStampsThanCursor:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn samplesWithLaterDecodeTimeStampsMayHaveEarlierPresentationTimeStampsThanCursor(
149 &self,
150 cursor: &AVSampleCursor,
151 ) -> bool;
152 );
153}
154
155/// A struct for describing attributes of a media sample for consideration when resynchronizing a decoder.
156/// Field: sampleIsFullSync
157/// Indicates whether the sample is a full sync sample, also known as an Instantaneous Decoder Refresh sample, and is sufficient in itself to completely resynchronize a decoder.
158/// Field: sampleIsPartialSync
159/// Indicates whether the sample is a partial sync sample.
160/// Field: sampleIsDroppable
161/// Indicates whether the sample is droppable.
162///
163/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorsyncinfo?language=objc)
164#[repr(C)]
165#[derive(Clone, Copy, Debug, PartialEq)]
166pub struct AVSampleCursorSyncInfo {
167 pub sampleIsFullSync: Bool,
168 pub sampleIsPartialSync: Bool,
169 pub sampleIsDroppable: Bool,
170}
171
172unsafe impl Encode for AVSampleCursorSyncInfo {
173 const ENCODING: Encoding =
174 Encoding::Struct("?", &[<Bool>::ENCODING, <Bool>::ENCODING, <Bool>::ENCODING]);
175}
176
177unsafe impl RefEncode for AVSampleCursorSyncInfo {
178 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
179}
180
181/// A struct for describing dependencies between a media sample and other media samples in the same sample sequence.
182/// Field: sampleIndicatesWhetherItHasDependentSamples
183/// Indicates whether the presence or absence of other samples that are dependent on the sample is known.
184/// Field: sampleHasDependentSamples
185/// If sampleIndicatesWhetherItHasDependentSamples is YES, indicates whether the sample has dependent samples.
186/// Field: sampleIndicatesWhetherItDependsOnOthers
187/// Indicates whether the sample's independency from other samples or dependency on other samples is known.
188/// Field: sampleDependsOnOthers
189/// If sampleIndicatesWhetherItDependsOnOthers is YES, indicates whether the sample depends on other media samples.
190/// Field: sampleIndicatesWhetherItHasRedundantCoding
191/// Indicates whether the presence of redundant coding of the sample is known.
192/// Field: sampleHasRedundantCoding
193/// If sampleIndicatesWhetherItHasRedundantCoding is YES, indicates whether the sample has redundant coding.
194///
195/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursordependencyinfo?language=objc)
196#[repr(C)]
197#[derive(Clone, Copy, Debug, PartialEq)]
198pub struct AVSampleCursorDependencyInfo {
199 pub sampleIndicatesWhetherItHasDependentSamples: Bool,
200 pub sampleHasDependentSamples: Bool,
201 pub sampleIndicatesWhetherItDependsOnOthers: Bool,
202 pub sampleDependsOnOthers: Bool,
203 pub sampleIndicatesWhetherItHasRedundantCoding: Bool,
204 pub sampleHasRedundantCoding: Bool,
205}
206
207unsafe impl Encode for AVSampleCursorDependencyInfo {
208 const ENCODING: Encoding = Encoding::Struct(
209 "?",
210 &[
211 <Bool>::ENCODING,
212 <Bool>::ENCODING,
213 <Bool>::ENCODING,
214 <Bool>::ENCODING,
215 <Bool>::ENCODING,
216 <Bool>::ENCODING,
217 ],
218 );
219}
220
221unsafe impl RefEncode for AVSampleCursorDependencyInfo {
222 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
223}
224
225/// A struct for describing the independent decodability of audio samples
226/// Field: audioSampleIsIndependentlyDecodable
227/// Indicates whether the sample is independently decodable. Will be YES for Immediate Playout Frames (IPFs) and Independent Frames (IFs).
228/// Field: audioSamplePacketRefreshCount
229/// If audioSampleIsIndependentlyDecodable is YES, indicates how many samples, starting at this sample, must be fed to the decoder to achieve full decoder refresh. Will be zero for Immediate Playout Frames (IPFs).
230///
231/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursoraudiodependencyinfo?language=objc)
232#[repr(C)]
233#[derive(Clone, Copy, Debug, PartialEq)]
234pub struct AVSampleCursorAudioDependencyInfo {
235 pub audioSampleIsIndependentlyDecodable: Bool,
236 pub audioSamplePacketRefreshCount: NSInteger,
237}
238
239unsafe impl Encode for AVSampleCursorAudioDependencyInfo {
240 const ENCODING: Encoding = Encoding::Struct("?", &[<Bool>::ENCODING, <NSInteger>::ENCODING]);
241}
242
243unsafe impl RefEncode for AVSampleCursorAudioDependencyInfo {
244 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
245}
246
247/// AVSampleCursorCurrentSampleInfo.
248impl AVSampleCursor {
249 extern_methods!(
250 #[cfg(feature = "objc2-core-media")]
251 /// Indicates the decode duration of the sample at the receiver's current position.
252 ///
253 /// If the receiver must be advanced past its current position in order to determine the decode duration of the current sample, the value of currentSampleDuration is equal to kCMTimeIndefinite. This can occur with streaming formats such as MPEG-2 transport streams.
254 #[unsafe(method(currentSampleDuration))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn currentSampleDuration(&self) -> CMTime;
257
258 #[cfg(feature = "objc2-core-media")]
259 /// Provides the format description of the sample at the receiver's current position.
260 #[unsafe(method(copyCurrentSampleFormatDescription))]
261 #[unsafe(method_family = copy)]
262 pub unsafe fn copyCurrentSampleFormatDescription(&self) -> Retained<CMFormatDescription>;
263
264 /// Provides information about the current sample for consideration when resynchronizing a decoder, as when scrubbing.
265 #[unsafe(method(currentSampleSyncInfo))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn currentSampleSyncInfo(&self) -> AVSampleCursorSyncInfo;
268
269 /// Provides information about dependencies between a media sample and other media samples in the same sample sequence, if known.
270 #[unsafe(method(currentSampleDependencyInfo))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn currentSampleDependencyInfo(&self) -> AVSampleCursorDependencyInfo;
273
274 /// Provides a dictionary containing dependency related sample buffer attachments, if known. See kCMSampleAttachmentKey_... in CoreMedia/CMSampleBuffer.h.
275 #[unsafe(method(currentSampleDependencyAttachments))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn currentSampleDependencyAttachments(&self) -> Option<Retained<NSDictionary>>;
278
279 /// Provides information about the independent decodability of an audio sample.
280 ///
281 /// In order to position a sample cursor at the first sample that the audio decoder requires for a full refresh, you will need to walk it back from
282 /// the current sample until you find a sample that is independently decodable, and whose audioSamplePacketRefreshCount is greater than or equal to
283 /// the number of steps back you have taken. This implies that if the current sample (before this walk) is independently decodable, with an
284 /// audioSampleRefreshCount of zero, no walk is required.
285 #[unsafe(method(currentSampleAudioDependencyInfo))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn currentSampleAudioDependencyInfo(&self) -> AVSampleCursorAudioDependencyInfo;
288
289 /// Count of samples prior to the current sample, in decode order, that the decoder requires in order to achieve fully coherent output at the current decode time, as after a seek. Zero will be returned if no samples are required for decoder refresh or if the track does not contain this information.
290 ///
291 /// Some sample sequences that do not indicate sample dependencies may instead indicate that in order for a specific sample to be decoded with all available accuracy, samples prior to that sample in decode order must be decoded before the specific sample is decoded.
292 ///
293 /// In order to position a sample cursor at the first sample that the decoder requires for a full refresh, you can use code like the following:
294 ///
295 /// NSInteger samplesPriorToCurrentSampleToFeedToDecoder = [mySampleCursor samplesRequiredForDecoderRefresh];
296 /// AVSampleCursor *cursorForObtainingRefreshSamples = [mySampleCursor copy];
297 /// [cursorForObtainingRefreshSamples stepInDecodeOrderByCount: -samplesPriorToCurrentSampleToFeedToDecoder ];
298 ///
299 /// // cursorForObtainingRefreshSamples is now positioned at the first sample that must be provided to the decoder
300 /// // in order to decode the sample at the position of mySampleCursor in full
301 #[unsafe(method(samplesRequiredForDecoderRefresh))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn samplesRequiredForDecoderRefresh(&self) -> NSInteger;
304 );
305}
306
307/// A struct for indicating the offset and length of storage occupied by a media sample or its chunk.
308/// Field: offset
309/// The offset of the first byte of storage occupied by a media sample or its chunk.
310/// Field: length
311/// The count of bytes of storage occupied by a media sample or its chunk.
312///
313/// Like NSRange, but rangier.
314///
315/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorstoragerange?language=objc)
316#[repr(C)]
317#[derive(Clone, Copy, Debug, PartialEq)]
318pub struct AVSampleCursorStorageRange {
319 pub offset: i64,
320 pub length: i64,
321}
322
323unsafe impl Encode for AVSampleCursorStorageRange {
324 const ENCODING: Encoding = Encoding::Struct("?", &[<i64>::ENCODING, <i64>::ENCODING]);
325}
326
327unsafe impl RefEncode for AVSampleCursorStorageRange {
328 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
329}
330
331/// Provides information about a chunk of media samples.
332/// Field: chunkSampleCount
333/// The count of media samples in the chunk.
334/// Field: chunkHasUniformSampleSizes
335/// YES if all of the samples in the chunk occupy the same number of bytes in storage.
336/// Field: currentChunkHasUniformSampleDurations
337/// YES if all of the samples in the chunk have the same duration.
338/// Field: currentChunkHasUniformFormatDescriptions
339/// YES if all of the samples in the chunk have the same format description.
340///
341/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorchunkinfo?language=objc)
342#[repr(C)]
343#[derive(Clone, Copy, Debug, PartialEq)]
344pub struct AVSampleCursorChunkInfo {
345 pub chunkSampleCount: i64,
346 pub chunkHasUniformSampleSizes: Bool,
347 pub chunkHasUniformSampleDurations: Bool,
348 pub chunkHasUniformFormatDescriptions: Bool,
349}
350
351unsafe impl Encode for AVSampleCursorChunkInfo {
352 const ENCODING: Encoding = Encoding::Struct(
353 "?",
354 &[
355 <i64>::ENCODING,
356 <Bool>::ENCODING,
357 <Bool>::ENCODING,
358 <Bool>::ENCODING,
359 ],
360 );
361}
362
363unsafe impl RefEncode for AVSampleCursorChunkInfo {
364 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
365}
366
367/// AVSampleCursorSampleStorageInfo.
368impl AVSampleCursor {
369 extern_methods!(
370 /// The URL of the storage container of the current sample, as well as other samples that are intended to be loaded in the same operation as a "chunk".
371 ///
372 /// May be nil; if nil, the storage location of the chunk is the URL of the sample cursor's track's asset, if it has one.
373 #[unsafe(method(currentChunkStorageURL))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn currentChunkStorageURL(&self) -> Option<Retained<NSURL>>;
376
377 /// The offset and length of samples in currentChunkStorageURL that are intended to be loaded together with the current sample as a "chunk".
378 ///
379 /// If the current chunk isn't stored contiguously in its storage container, currentChunkStorageRange.offset will be -1. In such cases you can use AVSampleBufferGenerator to obtain the sample data.
380 #[unsafe(method(currentChunkStorageRange))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn currentChunkStorageRange(&self) -> AVSampleCursorStorageRange;
383
384 /// Provides information about the "chunk" of samples to which the current sample belongs. If the media format that defines the sequence of samples does not signal "chunking" of samples in any way, each sample will be considered by the receiver as belonging to a chunk of one sample only.
385 #[unsafe(method(currentChunkInfo))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn currentChunkInfo(&self) -> AVSampleCursorChunkInfo;
388
389 /// The index of the current sample within the chunk to which it belongs.
390 #[unsafe(method(currentSampleIndexInChunk))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn currentSampleIndexInChunk(&self) -> i64;
393
394 /// The offset and length of the current sample in currentChunkStorageURL.
395 ///
396 /// If the current sample isn't stored contiguously in its storage container, currentSampleStorageRange.offset will be -1. In such cases you can use AVSampleBufferGenerator to obtain the sample data.
397 #[unsafe(method(currentSampleStorageRange))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn currentSampleStorageRange(&self) -> AVSampleCursorStorageRange;
400 );
401}