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