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        ///
71        /// # Safety
72        ///
73        /// `out_was_pinned` must be a valid pointer or null.
74        #[unsafe(method(stepByDecodeTime:wasPinned:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn stepByDecodeTime_wasPinned(
77            &self,
78            delta_decode_time: CMTime,
79            out_was_pinned: *mut Bool,
80        ) -> CMTime;
81
82        #[cfg(feature = "objc2-core-media")]
83        /// Moves the cursor by a given deltaTime on the presentation timeline.
84        ///
85        /// Parameter `deltaPresentationTime`: The amount of time to move in the presentation timeline.
86        ///
87        /// 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.
88        ///
89        /// 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.
90        ///
91        /// # Safety
92        ///
93        /// `out_was_pinned` must be a valid pointer or null.
94        #[unsafe(method(stepByPresentationTime:wasPinned:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn stepByPresentationTime_wasPinned(
97            &self,
98            delta_presentation_time: CMTime,
99            out_was_pinned: *mut Bool,
100        ) -> CMTime;
101    );
102}
103
104/// AVSampleCursorTemporalPosition.
105impl AVSampleCursor {
106    extern_methods!(
107        #[cfg(feature = "objc2-core-media")]
108        /// The presentation timestamp (PTS) of the sample at the current position of the cursor.
109        ///
110        /// This property is not atomic.
111        ///
112        /// # Safety
113        ///
114        /// This might not be thread-safe.
115        #[unsafe(method(presentationTimeStamp))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn presentationTimeStamp(&self) -> CMTime;
118
119        #[cfg(feature = "objc2-core-media")]
120        /// The decode timestamp (DTS) of the sample at the current position of the cursor.
121        ///
122        /// This property is not atomic.
123        ///
124        /// # Safety
125        ///
126        /// This might not be thread-safe.
127        #[unsafe(method(decodeTimeStamp))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn decodeTimeStamp(&self) -> CMTime;
130
131        /// Compares the relative positions of two AVSampleCursors.
132        ///
133        /// Parameter `cursor`: An instance of AVSampleCursor with which to compare positions.
134        ///
135        /// 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.
136        ///
137        /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
138        #[unsafe(method(comparePositionInDecodeOrderWithPositionOfCursor:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn comparePositionInDecodeOrderWithPositionOfCursor(
141            &self,
142            cursor: &AVSampleCursor,
143        ) -> NSComparisonResult;
144
145        /// 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.
146        ///
147        /// Parameter `cursor`: An instance of AVSampleCursor with which to test the sample reordering boundary.
148        ///
149        /// 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.
150        ///
151        /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
152        #[unsafe(method(samplesWithEarlierDecodeTimeStampsMayHaveLaterPresentationTimeStampsThanCursor:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn samplesWithEarlierDecodeTimeStampsMayHaveLaterPresentationTimeStampsThanCursor(
155            &self,
156            cursor: &AVSampleCursor,
157        ) -> bool;
158
159        /// 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.
160        ///
161        /// Parameter `cursor`: An instance of AVSampleCursor with which to test the sample reordering boundary.
162        ///
163        /// 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.
164        ///
165        /// If the receiver and cursor reference different sequences of samples, as when they're created by different instances of AVAssetTrack, results are undefined.
166        #[unsafe(method(samplesWithLaterDecodeTimeStampsMayHaveEarlierPresentationTimeStampsThanCursor:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn samplesWithLaterDecodeTimeStampsMayHaveEarlierPresentationTimeStampsThanCursor(
169            &self,
170            cursor: &AVSampleCursor,
171        ) -> bool;
172    );
173}
174
175/// A struct for describing attributes of a media sample for consideration when resynchronizing a decoder.
176/// Field: sampleIsFullSync
177/// 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.
178/// Field: sampleIsPartialSync
179/// Indicates whether the sample is a partial sync sample.
180/// Field: sampleIsDroppable
181/// Indicates whether the sample is droppable.
182///
183/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorsyncinfo?language=objc)
184#[repr(C)]
185#[derive(Clone, Copy, Debug, PartialEq)]
186pub struct AVSampleCursorSyncInfo {
187    pub sampleIsFullSync: Bool,
188    pub sampleIsPartialSync: Bool,
189    pub sampleIsDroppable: Bool,
190}
191
192unsafe impl Encode for AVSampleCursorSyncInfo {
193    const ENCODING: Encoding =
194        Encoding::Struct("?", &[<Bool>::ENCODING, <Bool>::ENCODING, <Bool>::ENCODING]);
195}
196
197unsafe impl RefEncode for AVSampleCursorSyncInfo {
198    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
199}
200
201/// A struct for describing dependencies between a media sample and other media samples in the same sample sequence.
202/// Field: sampleIndicatesWhetherItHasDependentSamples
203/// Indicates whether the presence or absence of other samples that are dependent on the sample is known.
204/// Field: sampleHasDependentSamples
205/// If sampleIndicatesWhetherItHasDependentSamples is YES, indicates whether the sample has dependent samples.
206/// Field: sampleIndicatesWhetherItDependsOnOthers
207/// Indicates whether the sample's independency from other samples or dependency on other samples is known.
208/// Field: sampleDependsOnOthers
209/// If sampleIndicatesWhetherItDependsOnOthers is YES, indicates whether the sample depends on other media samples.
210/// Field: sampleIndicatesWhetherItHasRedundantCoding
211/// Indicates whether the presence of redundant coding of the sample is known.
212/// Field: sampleHasRedundantCoding
213/// If sampleIndicatesWhetherItHasRedundantCoding is YES, indicates whether the sample has redundant coding.
214///
215/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursordependencyinfo?language=objc)
216#[repr(C)]
217#[derive(Clone, Copy, Debug, PartialEq)]
218pub struct AVSampleCursorDependencyInfo {
219    pub sampleIndicatesWhetherItHasDependentSamples: Bool,
220    pub sampleHasDependentSamples: Bool,
221    pub sampleIndicatesWhetherItDependsOnOthers: Bool,
222    pub sampleDependsOnOthers: Bool,
223    pub sampleIndicatesWhetherItHasRedundantCoding: Bool,
224    pub sampleHasRedundantCoding: Bool,
225}
226
227unsafe impl Encode for AVSampleCursorDependencyInfo {
228    const ENCODING: Encoding = Encoding::Struct(
229        "?",
230        &[
231            <Bool>::ENCODING,
232            <Bool>::ENCODING,
233            <Bool>::ENCODING,
234            <Bool>::ENCODING,
235            <Bool>::ENCODING,
236            <Bool>::ENCODING,
237        ],
238    );
239}
240
241unsafe impl RefEncode for AVSampleCursorDependencyInfo {
242    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
243}
244
245/// A struct for describing the independent decodability of audio samples
246/// Field: audioSampleIsIndependentlyDecodable
247/// Indicates whether the sample is independently decodable.  Will be YES for Immediate Playout Frames (IPFs) and Independent Frames (IFs).
248/// Field: audioSamplePacketRefreshCount
249/// 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).
250///
251/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursoraudiodependencyinfo?language=objc)
252#[repr(C)]
253#[derive(Clone, Copy, Debug, PartialEq)]
254pub struct AVSampleCursorAudioDependencyInfo {
255    pub audioSampleIsIndependentlyDecodable: Bool,
256    pub audioSamplePacketRefreshCount: NSInteger,
257}
258
259unsafe impl Encode for AVSampleCursorAudioDependencyInfo {
260    const ENCODING: Encoding = Encoding::Struct("?", &[<Bool>::ENCODING, <NSInteger>::ENCODING]);
261}
262
263unsafe impl RefEncode for AVSampleCursorAudioDependencyInfo {
264    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
265}
266
267/// AVSampleCursorCurrentSampleInfo.
268impl AVSampleCursor {
269    extern_methods!(
270        #[cfg(feature = "objc2-core-media")]
271        /// Indicates the decode duration of the sample at the receiver's current position.
272        ///
273        /// 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.
274        ///
275        /// This property is not atomic.
276        ///
277        /// # Safety
278        ///
279        /// This might not be thread-safe.
280        #[unsafe(method(currentSampleDuration))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn currentSampleDuration(&self) -> CMTime;
283
284        #[cfg(feature = "objc2-core-media")]
285        /// Provides the format description of the sample at the receiver's current position.
286        #[unsafe(method(copyCurrentSampleFormatDescription))]
287        #[unsafe(method_family = copy)]
288        pub unsafe fn copyCurrentSampleFormatDescription(&self) -> Retained<CMFormatDescription>;
289
290        /// Provides information about the current sample for consideration when resynchronizing a decoder, as when scrubbing.
291        ///
292        /// This property is not atomic.
293        ///
294        /// # Safety
295        ///
296        /// This might not be thread-safe.
297        #[unsafe(method(currentSampleSyncInfo))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn currentSampleSyncInfo(&self) -> AVSampleCursorSyncInfo;
300
301        /// Provides information about dependencies between a media sample and other media samples in the same sample sequence, if known.
302        ///
303        /// This property is not atomic.
304        ///
305        /// # Safety
306        ///
307        /// This might not be thread-safe.
308        #[unsafe(method(currentSampleDependencyInfo))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn currentSampleDependencyInfo(&self) -> AVSampleCursorDependencyInfo;
311
312        /// Provides a dictionary containing dependency related sample buffer attachments, if known.  See kCMSampleAttachmentKey_... in CoreMedia/CMSampleBuffer.h.
313        ///
314        /// This property is not atomic.
315        ///
316        /// # Safety
317        ///
318        /// This might not be thread-safe.
319        #[unsafe(method(currentSampleDependencyAttachments))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn currentSampleDependencyAttachments(&self) -> Option<Retained<NSDictionary>>;
322
323        /// Provides information about the independent decodability of an audio sample.
324        ///
325        /// 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
326        /// the current sample until you find a sample that is independently decodable, and whose audioSamplePacketRefreshCount is greater than or equal to
327        /// the number of steps back you have taken.  This implies that if the current sample (before this walk) is independently decodable, with an
328        /// audioSampleRefreshCount of zero, no walk is required.
329        ///
330        /// This property is not atomic.
331        ///
332        /// # Safety
333        ///
334        /// This might not be thread-safe.
335        #[unsafe(method(currentSampleAudioDependencyInfo))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn currentSampleAudioDependencyInfo(&self) -> AVSampleCursorAudioDependencyInfo;
338
339        /// 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.
340        ///
341        /// 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.
342        ///
343        /// 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:
344        ///
345        /// NSInteger samplesPriorToCurrentSampleToFeedToDecoder = [mySampleCursor samplesRequiredForDecoderRefresh];
346        /// AVSampleCursor *cursorForObtainingRefreshSamples = [mySampleCursor copy];
347        /// [cursorForObtainingRefreshSamples stepInDecodeOrderByCount: -samplesPriorToCurrentSampleToFeedToDecoder ];
348        ///
349        /// // cursorForObtainingRefreshSamples is now positioned at the first sample that must be provided to the decoder
350        /// // in order to decode the sample at the position of mySampleCursor in full
351        ///
352        /// This property is not atomic.
353        ///
354        /// # Safety
355        ///
356        /// This might not be thread-safe.
357        #[unsafe(method(samplesRequiredForDecoderRefresh))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn samplesRequiredForDecoderRefresh(&self) -> NSInteger;
360    );
361}
362
363/// A struct for indicating the offset and length of storage occupied by a media sample or its chunk.
364/// Field: offset
365/// The offset of the first byte of storage occupied by a media sample or its chunk.
366/// Field: length
367/// The count of bytes of storage occupied by a media sample or its chunk.
368///
369/// Like NSRange, but rangier.
370///
371/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorstoragerange?language=objc)
372#[repr(C)]
373#[derive(Clone, Copy, Debug, PartialEq)]
374pub struct AVSampleCursorStorageRange {
375    pub offset: i64,
376    pub length: i64,
377}
378
379unsafe impl Encode for AVSampleCursorStorageRange {
380    const ENCODING: Encoding = Encoding::Struct("?", &[<i64>::ENCODING, <i64>::ENCODING]);
381}
382
383unsafe impl RefEncode for AVSampleCursorStorageRange {
384    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
385}
386
387/// Provides information about a chunk of media samples.
388/// Field: chunkSampleCount
389/// The count of media samples in the chunk.
390/// Field: chunkHasUniformSampleSizes
391/// YES if all of the samples in the chunk occupy the same number of bytes in storage.
392/// Field: currentChunkHasUniformSampleDurations
393/// YES if all of the samples in the chunk have the same duration.
394/// Field: currentChunkHasUniformFormatDescriptions
395/// YES if all of the samples in the chunk have the same format description.
396///
397/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplecursorchunkinfo?language=objc)
398#[repr(C)]
399#[derive(Clone, Copy, Debug, PartialEq)]
400pub struct AVSampleCursorChunkInfo {
401    pub chunkSampleCount: i64,
402    pub chunkHasUniformSampleSizes: Bool,
403    pub chunkHasUniformSampleDurations: Bool,
404    pub chunkHasUniformFormatDescriptions: Bool,
405}
406
407unsafe impl Encode for AVSampleCursorChunkInfo {
408    const ENCODING: Encoding = Encoding::Struct(
409        "?",
410        &[
411            <i64>::ENCODING,
412            <Bool>::ENCODING,
413            <Bool>::ENCODING,
414            <Bool>::ENCODING,
415        ],
416    );
417}
418
419unsafe impl RefEncode for AVSampleCursorChunkInfo {
420    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
421}
422
423/// AVSampleCursorSampleStorageInfo.
424impl AVSampleCursor {
425    extern_methods!(
426        /// 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".
427        ///
428        /// 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.
429        ///
430        /// This property is not atomic.
431        ///
432        /// # Safety
433        ///
434        /// This might not be thread-safe.
435        #[unsafe(method(currentChunkStorageURL))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn currentChunkStorageURL(&self) -> Option<Retained<NSURL>>;
438
439        /// The offset and length of samples in currentChunkStorageURL that are intended to be loaded together with the current sample as a "chunk".
440        ///
441        /// 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.
442        ///
443        /// This property is not atomic.
444        ///
445        /// # Safety
446        ///
447        /// This might not be thread-safe.
448        #[unsafe(method(currentChunkStorageRange))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn currentChunkStorageRange(&self) -> AVSampleCursorStorageRange;
451
452        /// 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.
453        ///
454        /// This property is not atomic.
455        ///
456        /// # Safety
457        ///
458        /// This might not be thread-safe.
459        #[unsafe(method(currentChunkInfo))]
460        #[unsafe(method_family = none)]
461        pub unsafe fn currentChunkInfo(&self) -> AVSampleCursorChunkInfo;
462
463        /// The index of the current sample within the chunk to which it belongs.
464        ///
465        /// This property is not atomic.
466        ///
467        /// # Safety
468        ///
469        /// This might not be thread-safe.
470        #[unsafe(method(currentSampleIndexInChunk))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn currentSampleIndexInChunk(&self) -> i64;
473
474        /// The offset and length of the current sample in currentChunkStorageURL.
475        ///
476        /// 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.
477        ///
478        /// This property is not atomic.
479        ///
480        /// # Safety
481        ///
482        /// This might not be thread-safe.
483        #[unsafe(method(currentSampleStorageRange))]
484        #[unsafe(method_family = none)]
485        pub unsafe fn currentSampleStorageRange(&self) -> AVSampleCursorStorageRange;
486    );
487}