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