objc2_core_media/generated/
CMSampleBuffer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9#[cfg(feature = "objc2-core-audio-types")]
10use objc2_core_audio_types::*;
11use objc2_core_foundation::*;
12#[cfg(feature = "objc2-core-video")]
13use objc2_core_video::*;
14
15use crate::*;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_allocationfailed?language=objc)
18pub const kCMSampleBufferError_AllocationFailed: OSStatus = -12730;
19/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_requiredparametermissing?language=objc)
20pub const kCMSampleBufferError_RequiredParameterMissing: OSStatus = -12731;
21/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_alreadyhasdatabuffer?language=objc)
22pub const kCMSampleBufferError_AlreadyHasDataBuffer: OSStatus = -12732;
23/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_buffernotready?language=objc)
24pub const kCMSampleBufferError_BufferNotReady: OSStatus = -12733;
25/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_sampleindexoutofrange?language=objc)
26pub const kCMSampleBufferError_SampleIndexOutOfRange: OSStatus = -12734;
27/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_bufferhasnosamplesizes?language=objc)
28pub const kCMSampleBufferError_BufferHasNoSampleSizes: OSStatus = -12735;
29/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_bufferhasnosampletiminginfo?language=objc)
30pub const kCMSampleBufferError_BufferHasNoSampleTimingInfo: OSStatus = -12736;
31/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_arraytoosmall?language=objc)
32pub const kCMSampleBufferError_ArrayTooSmall: OSStatus = -12737;
33/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_invalidentrycount?language=objc)
34pub const kCMSampleBufferError_InvalidEntryCount: OSStatus = -12738;
35/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_cannotsubdivide?language=objc)
36pub const kCMSampleBufferError_CannotSubdivide: OSStatus = -12739;
37/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_sampletiminginfoinvalid?language=objc)
38pub const kCMSampleBufferError_SampleTimingInfoInvalid: OSStatus = -12740;
39/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_invalidmediatypeforoperation?language=objc)
40pub const kCMSampleBufferError_InvalidMediaTypeForOperation: OSStatus = -12741;
41/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_invalidsampledata?language=objc)
42pub const kCMSampleBufferError_InvalidSampleData: OSStatus = -12742;
43/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_invalidmediaformat?language=objc)
44pub const kCMSampleBufferError_InvalidMediaFormat: OSStatus = -12743;
45/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_invalidated?language=objc)
46pub const kCMSampleBufferError_Invalidated: OSStatus = -12744;
47/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_datafailed?language=objc)
48pub const kCMSampleBufferError_DataFailed: OSStatus = -16750;
49/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffererror_datacanceled?language=objc)
50pub const kCMSampleBufferError_DataCanceled: OSStatus = -16751;
51
52/// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferflag_audiobufferlist_assure16bytealignment?language=objc)
53pub const kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment: u32 = 1 << 0;
54
55/// A reference to a CMSampleBuffer, a CF object containing zero or more compressed (or uncompressed)
56/// samples of a particular media type (audio, video, muxed, etc).
57///
58/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsamplebuffer?language=objc)
59#[doc(alias = "CMSampleBufferRef")]
60#[repr(C)]
61pub struct CMSampleBuffer {
62    inner: [u8; 0],
63    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
64}
65
66cf_type!(
67    unsafe impl CMSampleBuffer {}
68);
69#[cfg(feature = "objc2")]
70cf_objc2_type!(
71    unsafe impl RefEncode<"opaqueCMSampleBuffer"> for CMSampleBuffer {}
72);
73
74/// Collection of timing info for a sample in a CMSampleBuffer. A single CMSampleTimingInfo struct can
75/// describe every individual sample in a CMSampleBuffer, if the samples all have the same duration and
76/// are in presentation order with no gaps.
77///
78/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsampletiminginfo?language=objc)
79#[cfg(feature = "CMTime")]
80#[repr(C)]
81#[derive(Clone, Copy, Debug, PartialEq)]
82pub struct CMSampleTimingInfo {
83    /// The duration of the sample. If a single struct applies to
84    /// each of the samples, they all will have this duration.
85    pub duration: CMTime,
86    /// The time at which the sample will be presented. If a single
87    /// struct applies to each of the samples, this is the presentationTime of the
88    /// first sample. The presentationTime of subsequent samples will be derived by
89    /// repeatedly adding the sample duration.
90    pub presentationTimeStamp: CMTime,
91    /// The time at which the sample will be decoded. If the samples
92    /// are in presentation order (eg. audio samples, or video samples from a codec
93    /// that doesn't support out-of-order samples), this can be set to kCMTimeInvalid.
94    pub decodeTimeStamp: CMTime,
95}
96
97#[cfg(all(feature = "CMTime", feature = "objc2"))]
98unsafe impl Encode for CMSampleTimingInfo {
99    const ENCODING: Encoding = Encoding::Struct(
100        "?",
101        &[<CMTime>::ENCODING, <CMTime>::ENCODING, <CMTime>::ENCODING],
102    );
103}
104
105#[cfg(all(feature = "CMTime", feature = "objc2"))]
106unsafe impl RefEncode for CMSampleTimingInfo {
107    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
108}
109
110extern "C" {
111    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmtiminginfoinvalid?language=objc)
112    #[cfg(feature = "CMTime")]
113    pub static kCMTimingInfoInvalid: CMSampleTimingInfo;
114}
115
116/// Client callback called by CMSampleBufferMakeDataReady (client provides it when calling CMSampleBufferCreate).
117///
118/// This callback must make the data ready (e.g. force a scheduled read to finish). If this callback
119/// succeeds and returns 0, the CMSampleBuffer will then be marked as "data ready".
120///
121/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsamplebuffermakedatareadycallback?language=objc)
122pub type CMSampleBufferMakeDataReadyCallback =
123    Option<unsafe extern "C-unwind" fn(NonNull<CMSampleBuffer>, *mut c_void) -> OSStatus>;
124
125/// Client block called by CMSampleBufferMakeDataReady (client provides it when calling CMSampleBufferCreateWithMakeDataReadyHandler).
126///
127/// This block must make the data ready (e.g. force a scheduled read to finish). If this block
128/// succeeds and returns 0, the CMSampleBuffer will then be marked as "data ready".
129///
130/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsamplebuffermakedatareadyhandler?language=objc)
131#[cfg(feature = "block2")]
132pub type CMSampleBufferMakeDataReadyHandler =
133    *mut block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>) -> OSStatus>;
134
135impl CMSampleBuffer {
136    /// Creates a CMSampleBuffer.
137    ///
138    /// Array parameters (sampleSizeArray, sampleTimingArray) should have only one element if that same
139    /// element applies to all samples. All parameters are copied; on return, the caller can release them,
140    /// free them, reuse them or whatever.  On return, the caller owns the returned CMSampleBuffer, and
141    /// must release it when done with it.
142    ///
143    /// Example of usage for in-display-order video frames:
144    /// <ul>
145    /// dataBuffer: contains 7 Motion JPEG frames
146    /// <li>
147    /// dataFormatDescription: describes Motion JPEG video
148    /// <li>
149    /// numSamples: 7
150    /// <li>
151    /// numSampleTimingEntries: 1
152    /// <li>
153    /// sampleTimingArray: one entry = {duration = 1001/30000, presentationTimeStamp = 0/30000, decodeTimeStamp = invalid }
154    /// <li>
155    /// numSampleSizeEntries: 7
156    /// <li>
157    /// sampleSizeArray: {105840, 104456, 103464, 116460, 100412, 94808, 120400}
158    /// </ul>
159    /// Example of usage for out-of-display-order video frames:
160    /// <ul>
161    /// dataBuffer: contains 6 H.264 frames in decode order (P2,B0,B1,I5,B3,B4)
162    /// <li>
163    /// dataFormatDescription: describes H.264 video
164    /// <li>
165    /// numSamples: 6
166    /// <li>
167    /// numSampleTimingEntries: 6
168    /// <li>
169    /// sampleTimingArray: 6 entries = {
170    /// <ul>
171    /// {duration = 1001/30000, presentationTimeStamp = 12012/30000, decodeTimeStamp = 10010/30000},
172    /// <li>
173    /// {duration = 1001/30000, presentationTimeStamp = 10010/30000, decodeTimeStamp = 11011/30000},
174    /// <li>
175    /// {duration = 1001/30000, presentationTimeStamp = 11011/30000, decodeTimeStamp = 12012/30000},
176    /// <li>
177    /// {duration = 1001/30000, presentationTimeStamp = 15015/30000, decodeTimeStamp = 13013/30000},
178    /// <li>
179    /// {duration = 1001/30000, presentationTimeStamp = 13013/30000, decodeTimeStamp = 14014/30000},
180    /// <li>
181    /// {duration = 1001/30000, presentationTimeStamp = 14014/30000, decodeTimeStamp = 15015/30000}}
182    /// </ul>
183    /// <li>
184    /// numSampleSizeEntries: 6
185    /// <li>
186    /// sampleSizeArray: {10580, 1234, 1364, 75660, 1012, 988}
187    /// </ul>
188    /// Example of usage for compressed audio:
189    /// <ul>
190    /// dataBuffer: contains 24 compressed AAC packets
191    /// <li>
192    /// dataFormatDescription: describes 44.1kHz AAC audio
193    /// <li>
194    /// numSamples: 24
195    /// <li>
196    /// numSampleTimingEntries: 1
197    /// <li>
198    /// sampleTimingArray: one entry = {
199    /// <ul>
200    /// {duration = 1024/44100, presentationTimeStamp = 0/44100, decodeTimeStamp = invalid }}
201    /// </ul>
202    /// <li>
203    /// numSampleSizeEntries: 24
204    /// <li>
205    /// sampleSizeArray:
206    /// <ul>
207    /// {191, 183, 208, 213, 202, 206, 209, 206, 204, 192, 202, 277,
208    /// <li>
209    /// 282, 240, 209, 194, 193, 197, 196, 198, 168, 199, 171, 194}
210    /// </ul>
211    /// </ul>
212    /// Example of usage for uncompressed interleaved audio:
213    /// <ul>
214    /// dataBuffer: contains 24000 uncompressed interleaved stereo frames, each containing 2 Float32s =
215    /// <ul>
216    /// {{L,R},
217    /// <li>
218    /// {L,R},
219    /// <li>
220    /// {L,R}, ...}
221    /// </ul>
222    /// <li>
223    /// dataFormatDescription: describes 48kHz Float32 interleaved audio
224    /// <li>
225    /// numSamples: 24000
226    /// <li>
227    /// numSampleTimingEntries: 1
228    /// <li>
229    /// sampleTimingArray: one entry = {
230    /// <ul>
231    /// {duration = 1/48000, presentationTimeStamp = 0/48000, decodeTimeStamp = invalid }}
232    /// </ul>
233    /// <li>
234    /// numSampleSizeEntries: 1
235    /// <li>
236    /// sampleSizeArray: {8}
237    /// </ul>
238    /// Example of usage for uncompressed non-interleaved audio:
239    /// <ul>
240    /// dataBuffer: contains 24000 uncompressed non-interleaved stereo frames, each containing 2 (non-contiguous) Float32s =
241    /// <ul>
242    /// {{L,L,L,L,L,...},
243    /// <li>
244    /// {R,R,R,R,R,...}}
245    /// </ul>
246    /// <li>
247    /// dataFormatDescription: describes 48kHz Float32 non-interleaved audio
248    /// <li>
249    /// numSamples: 24000
250    /// <li>
251    /// numSampleTimingEntries: 1
252    /// <li>
253    /// sampleTimingArray: one entry = {duration = 1/48000, presentationTimeStamp = 0/48000, decodeTimeStamp = invalid }
254    /// <li>
255    /// numSampleSizeEntries: 0
256    /// <li>
257    /// sampleSizeArray: NULL (because the samples are not contiguous)
258    /// </ul>
259    ///
260    /// # Safety
261    ///
262    /// - `make_data_ready_callback` must be implemented correctly.
263    /// - `make_data_ready_refcon` must be a valid pointer or null.
264    /// - `sample_timing_array` must be a valid pointer or null.
265    /// - `sample_size_array` must be a valid pointer or null.
266    /// - `sample_buffer_out` must be a valid pointer.
267    #[doc(alias = "CMSampleBufferCreate")]
268    #[cfg(all(
269        feature = "CMBase",
270        feature = "CMBlockBuffer",
271        feature = "CMFormatDescription",
272        feature = "CMTime"
273    ))]
274    #[inline]
275    pub unsafe fn create(
276        allocator: Option<&CFAllocator>,
277        data_buffer: Option<&CMBlockBuffer>,
278        data_ready: bool,
279        make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
280        make_data_ready_refcon: *mut c_void,
281        format_description: Option<&CMFormatDescription>,
282        num_samples: CMItemCount,
283        num_sample_timing_entries: CMItemCount,
284        sample_timing_array: *const CMSampleTimingInfo,
285        num_sample_size_entries: CMItemCount,
286        sample_size_array: *const usize,
287        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
288    ) -> OSStatus {
289        extern "C-unwind" {
290            fn CMSampleBufferCreate(
291                allocator: Option<&CFAllocator>,
292                data_buffer: Option<&CMBlockBuffer>,
293                data_ready: Boolean,
294                make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
295                make_data_ready_refcon: *mut c_void,
296                format_description: Option<&CMFormatDescription>,
297                num_samples: CMItemCount,
298                num_sample_timing_entries: CMItemCount,
299                sample_timing_array: *const CMSampleTimingInfo,
300                num_sample_size_entries: CMItemCount,
301                sample_size_array: *const usize,
302                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
303            ) -> OSStatus;
304        }
305        unsafe {
306            CMSampleBufferCreate(
307                allocator,
308                data_buffer,
309                data_ready as _,
310                make_data_ready_callback,
311                make_data_ready_refcon,
312                format_description,
313                num_samples,
314                num_sample_timing_entries,
315                sample_timing_array,
316                num_sample_size_entries,
317                sample_size_array,
318                sample_buffer_out,
319            )
320        }
321    }
322
323    /// Creates a CMSampleBuffer.
324    ///
325    /// See CMSampleBufferCreate; this variant allows for passing a block to make the data ready.
326    ///
327    /// # Safety
328    ///
329    /// - `sample_timing_array` must be a valid pointer or null.
330    /// - `sample_size_array` must be a valid pointer or null.
331    /// - `sample_buffer_out` must be a valid pointer.
332    /// - `make_data_ready_handler` must be a valid pointer or null.
333    #[doc(alias = "CMSampleBufferCreateWithMakeDataReadyHandler")]
334    #[cfg(all(
335        feature = "CMBase",
336        feature = "CMBlockBuffer",
337        feature = "CMFormatDescription",
338        feature = "CMTime",
339        feature = "block2"
340    ))]
341    #[inline]
342    pub unsafe fn create_with_make_data_ready_handler(
343        allocator: Option<&CFAllocator>,
344        data_buffer: Option<&CMBlockBuffer>,
345        data_ready: bool,
346        format_description: Option<&CMFormatDescription>,
347        num_samples: CMItemCount,
348        num_sample_timing_entries: CMItemCount,
349        sample_timing_array: *const CMSampleTimingInfo,
350        num_sample_size_entries: CMItemCount,
351        sample_size_array: *const usize,
352        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
353        make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
354    ) -> OSStatus {
355        extern "C-unwind" {
356            fn CMSampleBufferCreateWithMakeDataReadyHandler(
357                allocator: Option<&CFAllocator>,
358                data_buffer: Option<&CMBlockBuffer>,
359                data_ready: Boolean,
360                format_description: Option<&CMFormatDescription>,
361                num_samples: CMItemCount,
362                num_sample_timing_entries: CMItemCount,
363                sample_timing_array: *const CMSampleTimingInfo,
364                num_sample_size_entries: CMItemCount,
365                sample_size_array: *const usize,
366                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
367                make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
368            ) -> OSStatus;
369        }
370        unsafe {
371            CMSampleBufferCreateWithMakeDataReadyHandler(
372                allocator,
373                data_buffer,
374                data_ready as _,
375                format_description,
376                num_samples,
377                num_sample_timing_entries,
378                sample_timing_array,
379                num_sample_size_entries,
380                sample_size_array,
381                sample_buffer_out,
382                make_data_ready_handler,
383            )
384        }
385    }
386
387    /// Creates a CMSampleBuffer.
388    ///
389    /// Array parameters (sampleSizeArray, sampleTimingArray) should have only one element if that same
390    /// element applies to all samples. All parameters are copied; on return, the caller can release them,
391    /// free them, reuse them or whatever.  On return, the caller owns the returned CMSampleBuffer, and
392    /// must release it when done with it.
393    /// CMSampleBufferCreateReady is identical to CMSampleBufferCreate except that dataReady is always true,
394    /// and so no makeDataReadyCallback or refcon needs to be passed.
395    ///
396    /// Example of usage for in-display-order video frames:
397    /// <ul>
398    /// dataBuffer: contains 7 Motion JPEG frames
399    /// <li>
400    /// dataFormatDescription: describes Motion JPEG video
401    /// <li>
402    /// numSamples: 7
403    /// <li>
404    /// numSampleTimingEntries: 1
405    /// <li>
406    /// sampleTimingArray: one entry = {duration = 1001/30000, presentationTimeStamp = 0/30000, decodeTimeStamp = invalid }
407    /// <li>
408    /// numSampleSizeEntries: 7
409    /// <li>
410    /// sampleSizeArray: {105840, 104456, 103464, 116460, 100412, 94808, 120400}
411    /// </ul>
412    /// Example of usage for out-of-display-order video frames:
413    /// <ul>
414    /// dataBuffer: contains 6 H.264 frames in decode order (P2,B0,B1,I5,B3,B4)
415    /// <li>
416    /// dataFormatDescription: describes H.264 video
417    /// <li>
418    /// numSamples: 6
419    /// <li>
420    /// numSampleTimingEntries: 6
421    /// <li>
422    /// sampleTimingArray: 6 entries = {
423    /// <ul>
424    /// {duration = 1001/30000, presentationTimeStamp = 12012/30000, decodeTimeStamp = 10010/30000},
425    /// <li>
426    /// {duration = 1001/30000, presentationTimeStamp = 10010/30000, decodeTimeStamp = 11011/30000},
427    /// <li>
428    /// {duration = 1001/30000, presentationTimeStamp = 11011/30000, decodeTimeStamp = 12012/30000},
429    /// <li>
430    /// {duration = 1001/30000, presentationTimeStamp = 15015/30000, decodeTimeStamp = 13013/30000},
431    /// <li>
432    /// {duration = 1001/30000, presentationTimeStamp = 13013/30000, decodeTimeStamp = 14014/30000},
433    /// <li>
434    /// {duration = 1001/30000, presentationTimeStamp = 14014/30000, decodeTimeStamp = 15015/30000}}
435    /// </ul>
436    /// <li>
437    /// numSampleSizeEntries: 6
438    /// <li>
439    /// sampleSizeArray: {10580, 1234, 1364, 75660, 1012, 988}
440    /// </ul>
441    /// Example of usage for compressed audio:
442    /// <ul>
443    /// dataBuffer: contains 24 compressed AAC packets
444    /// <li>
445    /// dataFormatDescription: describes 44.1kHz AAC audio
446    /// <li>
447    /// numSamples: 24
448    /// <li>
449    /// numSampleTimingEntries: 1
450    /// <li>
451    /// sampleTimingArray: one entry = {
452    /// <ul>
453    /// {duration = 1024/44100, presentationTimeStamp = 0/44100, decodeTimeStamp = invalid }}
454    /// </ul>
455    /// <li>
456    /// numSampleSizeEntries: 24
457    /// <li>
458    /// sampleSizeArray:
459    /// <ul>
460    /// {191, 183, 208, 213, 202, 206, 209, 206, 204, 192, 202, 277,
461    /// <li>
462    /// 282, 240, 209, 194, 193, 197, 196, 198, 168, 199, 171, 194}
463    /// </ul>
464    /// </ul>
465    /// Example of usage for uncompressed interleaved audio:
466    /// <ul>
467    /// dataBuffer: contains 24000 uncompressed interleaved stereo frames, each containing 2 Float32s =
468    /// <ul>
469    /// {{L,R},
470    /// <li>
471    /// {L,R},
472    /// <li>
473    /// {L,R}, ...}
474    /// </ul>
475    /// <li>
476    /// dataFormatDescription: describes 48kHz Float32 interleaved audio
477    /// <li>
478    /// numSamples: 24000
479    /// <li>
480    /// numSampleTimingEntries: 1
481    /// <li>
482    /// sampleTimingArray: one entry = {
483    /// <ul>
484    /// {duration = 1/48000, presentationTimeStamp = 0/48000, decodeTimeStamp = invalid }}
485    /// </ul>
486    /// <li>
487    /// numSampleSizeEntries: 1
488    /// <li>
489    /// sampleSizeArray: {8}
490    /// </ul>
491    /// Example of usage for uncompressed non-interleaved audio:
492    /// <ul>
493    /// dataBuffer: contains 24000 uncompressed non-interleaved stereo frames, each containing 2 (non-contiguous) Float32s =
494    /// <ul>
495    /// {{L,L,L,L,L,...},
496    /// <li>
497    /// {R,R,R,R,R,...}}
498    /// </ul>
499    /// <li>
500    /// dataFormatDescription: describes 48kHz Float32 non-interleaved audio
501    /// <li>
502    /// numSamples: 24000
503    /// <li>
504    /// numSampleTimingEntries: 1
505    /// <li>
506    /// sampleTimingArray: one entry = {duration = 1/48000, presentationTimeStamp = 0/48000, decodeTimeStamp = invalid }
507    /// <li>
508    /// numSampleSizeEntries: 0
509    /// <li>
510    /// sampleSizeArray: NULL (because the samples are not contiguous)
511    /// </ul>
512    ///
513    /// # Safety
514    ///
515    /// - `sample_timing_array` must be a valid pointer or null.
516    /// - `sample_size_array` must be a valid pointer or null.
517    /// - `sample_buffer_out` must be a valid pointer.
518    #[doc(alias = "CMSampleBufferCreateReady")]
519    #[cfg(all(
520        feature = "CMBase",
521        feature = "CMBlockBuffer",
522        feature = "CMFormatDescription",
523        feature = "CMTime"
524    ))]
525    #[inline]
526    pub unsafe fn create_ready(
527        allocator: Option<&CFAllocator>,
528        data_buffer: Option<&CMBlockBuffer>,
529        format_description: Option<&CMFormatDescription>,
530        num_samples: CMItemCount,
531        num_sample_timing_entries: CMItemCount,
532        sample_timing_array: *const CMSampleTimingInfo,
533        num_sample_size_entries: CMItemCount,
534        sample_size_array: *const usize,
535        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
536    ) -> OSStatus {
537        extern "C-unwind" {
538            fn CMSampleBufferCreateReady(
539                allocator: Option<&CFAllocator>,
540                data_buffer: Option<&CMBlockBuffer>,
541                format_description: Option<&CMFormatDescription>,
542                num_samples: CMItemCount,
543                num_sample_timing_entries: CMItemCount,
544                sample_timing_array: *const CMSampleTimingInfo,
545                num_sample_size_entries: CMItemCount,
546                sample_size_array: *const usize,
547                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
548            ) -> OSStatus;
549        }
550        unsafe {
551            CMSampleBufferCreateReady(
552                allocator,
553                data_buffer,
554                format_description,
555                num_samples,
556                num_sample_timing_entries,
557                sample_timing_array,
558                num_sample_size_entries,
559                sample_size_array,
560                sample_buffer_out,
561            )
562        }
563    }
564}
565
566/// Creates an CMSampleBuffer containing audio given packetDescriptions instead of sizing and timing info
567///
568/// Provides an optimization over CMSampleBufferCreate() when the caller already has packetDescriptions for
569/// the audio data. This routine will use the packetDescriptions to create the sizing and timing arrays required
570/// to make the sample buffer if necessary.
571///
572/// # Safety
573///
574/// - `make_data_ready_callback` must be implemented correctly.
575/// - `make_data_ready_refcon` must be a valid pointer or null.
576/// - `packet_descriptions` must be a valid pointer or null.
577/// - `sample_buffer_out` must be a valid pointer.
578#[cfg(all(
579    feature = "CMBase",
580    feature = "CMBlockBuffer",
581    feature = "CMFormatDescription",
582    feature = "CMTime",
583    feature = "objc2-core-audio-types"
584))]
585#[inline]
586pub unsafe extern "C-unwind" fn CMAudioSampleBufferCreateWithPacketDescriptions(
587    allocator: Option<&CFAllocator>,
588    data_buffer: Option<&CMBlockBuffer>,
589    data_ready: bool,
590    make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
591    make_data_ready_refcon: *mut c_void,
592    format_description: &CMFormatDescription,
593    num_samples: CMItemCount,
594    presentation_time_stamp: CMTime,
595    packet_descriptions: *const AudioStreamPacketDescription,
596    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
597) -> OSStatus {
598    extern "C-unwind" {
599        fn CMAudioSampleBufferCreateWithPacketDescriptions(
600            allocator: Option<&CFAllocator>,
601            data_buffer: Option<&CMBlockBuffer>,
602            data_ready: Boolean,
603            make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
604            make_data_ready_refcon: *mut c_void,
605            format_description: &CMFormatDescription,
606            num_samples: CMItemCount,
607            presentation_time_stamp: CMTime,
608            packet_descriptions: *const AudioStreamPacketDescription,
609            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
610        ) -> OSStatus;
611    }
612    unsafe {
613        CMAudioSampleBufferCreateWithPacketDescriptions(
614            allocator,
615            data_buffer,
616            data_ready as _,
617            make_data_ready_callback,
618            make_data_ready_refcon,
619            format_description,
620            num_samples,
621            presentation_time_stamp,
622            packet_descriptions,
623            sample_buffer_out,
624        )
625    }
626}
627
628/// Creates an CMSampleBuffer containing audio given packetDescriptions instead of sizing and timing info
629///
630/// See CMAudioSampleBufferCreateWithPacketDescriptions; this variant allows for passing a block to make the data ready.
631///
632/// # Safety
633///
634/// - `packet_descriptions` must be a valid pointer or null.
635/// - `sample_buffer_out` must be a valid pointer.
636/// - `make_data_ready_handler` must be a valid pointer or null.
637#[cfg(all(
638    feature = "CMBase",
639    feature = "CMBlockBuffer",
640    feature = "CMFormatDescription",
641    feature = "CMTime",
642    feature = "block2",
643    feature = "objc2-core-audio-types"
644))]
645#[inline]
646pub unsafe extern "C-unwind" fn CMAudioSampleBufferCreateWithPacketDescriptionsAndMakeDataReadyHandler(
647    allocator: Option<&CFAllocator>,
648    data_buffer: Option<&CMBlockBuffer>,
649    data_ready: bool,
650    format_description: &CMFormatDescription,
651    num_samples: CMItemCount,
652    presentation_time_stamp: CMTime,
653    packet_descriptions: *const AudioStreamPacketDescription,
654    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
655    make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
656) -> OSStatus {
657    extern "C-unwind" {
658        fn CMAudioSampleBufferCreateWithPacketDescriptionsAndMakeDataReadyHandler(
659            allocator: Option<&CFAllocator>,
660            data_buffer: Option<&CMBlockBuffer>,
661            data_ready: Boolean,
662            format_description: &CMFormatDescription,
663            num_samples: CMItemCount,
664            presentation_time_stamp: CMTime,
665            packet_descriptions: *const AudioStreamPacketDescription,
666            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
667            make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
668        ) -> OSStatus;
669    }
670    unsafe {
671        CMAudioSampleBufferCreateWithPacketDescriptionsAndMakeDataReadyHandler(
672            allocator,
673            data_buffer,
674            data_ready as _,
675            format_description,
676            num_samples,
677            presentation_time_stamp,
678            packet_descriptions,
679            sample_buffer_out,
680            make_data_ready_handler,
681        )
682    }
683}
684
685extern "C-unwind" {
686    /// Creates an CMSampleBuffer containing audio given packetDescriptions instead of sizing and timing info
687    ///
688    /// Provides an optimization over CMSampleBufferCreate() when the caller already has packetDescriptions for
689    /// the audio data. This routine will use the packetDescriptions to create the sizing and timing arrays required
690    /// to make the sample buffer if necessary.
691    /// CMAudioSampleBufferCreateReadyWithPacketDescriptions is identical to CMAudioSampleBufferCreateWithPacketDescriptions
692    /// except that dataReady is always true, and so no makeDataReadyCallback or refcon needs to be passed.
693    ///
694    /// # Safety
695    ///
696    /// - `packet_descriptions` must be a valid pointer or null.
697    /// - `sample_buffer_out` must be a valid pointer.
698    #[cfg(all(
699        feature = "CMBase",
700        feature = "CMBlockBuffer",
701        feature = "CMFormatDescription",
702        feature = "CMTime",
703        feature = "objc2-core-audio-types"
704    ))]
705    pub fn CMAudioSampleBufferCreateReadyWithPacketDescriptions(
706        allocator: Option<&CFAllocator>,
707        data_buffer: &CMBlockBuffer,
708        format_description: &CMFormatDescription,
709        num_samples: CMItemCount,
710        presentation_time_stamp: CMTime,
711        packet_descriptions: *const AudioStreamPacketDescription,
712        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
713    ) -> OSStatus;
714}
715
716impl CMSampleBuffer {
717    /// Creates a CMSampleBuffer that contains a CVImageBuffer instead of a CMBlockBuffer.
718    ///
719    /// Unlike a CMBlockBuffer which can reference many samples, a CVImageBuffer is defined to
720    /// reference only one sample;  therefore this routine has fewer parameters then
721    /// CMSampleBufferCreate.
722    ///
723    /// Sample timing information, which is a vector for CMSampleBufferCreate,
724    /// consists of only one value for this routine.
725    ///
726    /// The concept of sample size does not apply to CVImageBuffers.  As such, CMSampleBufferGetSampleSizeArray
727    /// will return kCMSampleBufferError_BufferHasNoSampleSizes, and CMSampleBufferGetSampleSize
728    /// will return 0.
729    ///
730    /// Because CVImageBuffers hold visual data, the format description provided is a
731    /// CMVideoFormatDescription.  The format description must be consistent with the attributes
732    /// and formatting information attached to the CVImageBuffer. The width, height, and codecType must
733    /// match (for CVPixelBuffers the codec type is given by CVPixelBufferGetPixelFormatType(pixelBuffer);
734    /// for other CVImageBuffers, the codecType must be 0). The format description extensions must
735    /// match the image buffer attachments for all the keys in the list returned by
736    /// CMVideoFormatDescriptionGetExtensionKeysCommonWithImageBuffers (if absent in either they
737    /// must be absent in both).
738    ///
739    /// # Safety
740    ///
741    /// - `make_data_ready_callback` must be implemented correctly.
742    /// - `make_data_ready_refcon` must be a valid pointer or null.
743    /// - `sample_timing` must be a valid pointer.
744    /// - `sample_buffer_out` must be a valid pointer.
745    #[doc(alias = "CMSampleBufferCreateForImageBuffer")]
746    #[cfg(all(
747        feature = "CMFormatDescription",
748        feature = "CMTime",
749        feature = "objc2-core-video"
750    ))]
751    #[inline]
752    pub unsafe fn create_for_image_buffer(
753        allocator: Option<&CFAllocator>,
754        image_buffer: &CVImageBuffer,
755        data_ready: bool,
756        make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
757        make_data_ready_refcon: *mut c_void,
758        format_description: &CMVideoFormatDescription,
759        sample_timing: NonNull<CMSampleTimingInfo>,
760        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
761    ) -> OSStatus {
762        extern "C-unwind" {
763            fn CMSampleBufferCreateForImageBuffer(
764                allocator: Option<&CFAllocator>,
765                image_buffer: &CVImageBuffer,
766                data_ready: Boolean,
767                make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
768                make_data_ready_refcon: *mut c_void,
769                format_description: &CMVideoFormatDescription,
770                sample_timing: NonNull<CMSampleTimingInfo>,
771                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
772            ) -> OSStatus;
773        }
774        unsafe {
775            CMSampleBufferCreateForImageBuffer(
776                allocator,
777                image_buffer,
778                data_ready as _,
779                make_data_ready_callback,
780                make_data_ready_refcon,
781                format_description,
782                sample_timing,
783                sample_buffer_out,
784            )
785        }
786    }
787
788    /// Creates a CMSampleBuffer that contains a CVImageBuffer instead of a CMBlockBuffer.
789    ///
790    /// See CMSampleBufferCreateForImageBuffer; this variant allows for passing a block to make the data ready.
791    ///
792    /// # Safety
793    ///
794    /// - `sample_timing` must be a valid pointer.
795    /// - `sample_buffer_out` must be a valid pointer.
796    /// - `make_data_ready_handler` must be a valid pointer or null.
797    #[doc(alias = "CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler")]
798    #[cfg(all(
799        feature = "CMFormatDescription",
800        feature = "CMTime",
801        feature = "block2",
802        feature = "objc2-core-video"
803    ))]
804    #[inline]
805    pub unsafe fn create_for_image_buffer_with_make_data_ready_handler(
806        allocator: Option<&CFAllocator>,
807        image_buffer: &CVImageBuffer,
808        data_ready: bool,
809        format_description: &CMVideoFormatDescription,
810        sample_timing: NonNull<CMSampleTimingInfo>,
811        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
812        make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
813    ) -> OSStatus {
814        extern "C-unwind" {
815            fn CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(
816                allocator: Option<&CFAllocator>,
817                image_buffer: &CVImageBuffer,
818                data_ready: Boolean,
819                format_description: &CMVideoFormatDescription,
820                sample_timing: NonNull<CMSampleTimingInfo>,
821                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
822                make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
823            ) -> OSStatus;
824        }
825        unsafe {
826            CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(
827                allocator,
828                image_buffer,
829                data_ready as _,
830                format_description,
831                sample_timing,
832                sample_buffer_out,
833                make_data_ready_handler,
834            )
835        }
836    }
837
838    /// Creates a CMSampleBuffer that contains a CVImageBuffer instead of a CMBlockBuffer.
839    ///
840    /// Unlike a CMBlockBuffer which can reference many samples, a CVImageBuffer is defined to
841    /// reference only one sample;  therefore this routine has fewer parameters then
842    /// CMSampleBufferCreate.
843    ///
844    /// Sample timing information, which is a vector for CMSampleBufferCreate,
845    /// consists of only one value for this routine.
846    ///
847    /// The concept of sample size does not apply to CVImageBuffers.  As such, CMSampleBufferGetSampleSizeArray
848    /// will return kCMSampleBufferError_BufferHasNoSampleSizes, and CMSampleBufferGetSampleSize
849    /// will return 0.
850    ///
851    /// Because CVImageBuffers hold visual data, the format description provided is a
852    /// CMVideoFormatDescription.  The format description must be consistent with the attributes
853    /// and formatting information attached to the CVImageBuffer. The width, height, and codecType must
854    /// match (for CVPixelBuffers the codec type is given by CVPixelBufferGetPixelFormatType(pixelBuffer);
855    /// for other CVImageBuffers, the codecType must be 0). The format description extensions must
856    /// match the image buffer attachments for all the keys in the list returned by
857    /// CMVideoFormatDescriptionGetExtensionKeysCommonWithImageBuffers (if absent in either they
858    /// must be absent in both).
859    ///
860    /// CMSampleBufferCreateReadyWithImageBuffer is identical to CMSampleBufferCreateForImageBuffer except that
861    /// dataReady is always true, and so no makeDataReadyCallback or refcon needs to be passed.
862    ///
863    /// # Safety
864    ///
865    /// - `sample_timing` must be a valid pointer.
866    /// - `sample_buffer_out` must be a valid pointer.
867    #[doc(alias = "CMSampleBufferCreateReadyWithImageBuffer")]
868    #[cfg(all(
869        feature = "CMFormatDescription",
870        feature = "CMTime",
871        feature = "objc2-core-video"
872    ))]
873    #[inline]
874    pub unsafe fn create_ready_with_image_buffer(
875        allocator: Option<&CFAllocator>,
876        image_buffer: &CVImageBuffer,
877        format_description: &CMVideoFormatDescription,
878        sample_timing: NonNull<CMSampleTimingInfo>,
879        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
880    ) -> OSStatus {
881        extern "C-unwind" {
882            fn CMSampleBufferCreateReadyWithImageBuffer(
883                allocator: Option<&CFAllocator>,
884                image_buffer: &CVImageBuffer,
885                format_description: &CMVideoFormatDescription,
886                sample_timing: NonNull<CMSampleTimingInfo>,
887                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
888            ) -> OSStatus;
889        }
890        unsafe {
891            CMSampleBufferCreateReadyWithImageBuffer(
892                allocator,
893                image_buffer,
894                format_description,
895                sample_timing,
896                sample_buffer_out,
897            )
898        }
899    }
900
901    /// Creates a copy of a CMSampleBuffer.
902    ///
903    /// The copy is shallow: scalar properties (sizes and timing) are copied directly,
904    /// the data buffer and format description are retained, and
905    /// the propogatable attachments are retained by the copy's dictionary.
906    /// If sbuf's data is not ready, the copy will be set to track its readiness.
907    ///
908    /// # Safety
909    ///
910    /// `sample_buffer_out` must be a valid pointer.
911    #[doc(alias = "CMSampleBufferCreateCopy")]
912    #[inline]
913    pub unsafe fn create_copy(
914        allocator: Option<&CFAllocator>,
915        sbuf: &CMSampleBuffer,
916        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
917    ) -> OSStatus {
918        extern "C-unwind" {
919            fn CMSampleBufferCreateCopy(
920                allocator: Option<&CFAllocator>,
921                sbuf: &CMSampleBuffer,
922                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
923            ) -> OSStatus;
924        }
925        unsafe { CMSampleBufferCreateCopy(allocator, sbuf, sample_buffer_out) }
926    }
927
928    /// Creates a CMSampleBuffer with new timing information from another sample buffer.
929    ///
930    /// This emulates CMSampleBufferCreateCopy, but changes the timing.
931    /// Array parameters (sampleTimingArray) should have only one element if that same
932    /// element applies to all samples. All parameters are copied; on return, the caller can release them,
933    /// free them, reuse them or whatever.  Any outputPresentationTimestamp that has been set on the original Buffer
934    /// will not be copied because it is no longer relevant.    On return, the caller owns the returned
935    /// CMSampleBuffer, and must release it when done with it.
936    ///
937    /// # Safety
938    ///
939    /// - `sample_timing_array` must be a valid pointer or null.
940    /// - `sample_buffer_out` must be a valid pointer.
941    #[doc(alias = "CMSampleBufferCreateCopyWithNewTiming")]
942    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
943    #[inline]
944    pub unsafe fn create_copy_with_new_timing(
945        allocator: Option<&CFAllocator>,
946        original_s_buf: &CMSampleBuffer,
947        num_sample_timing_entries: CMItemCount,
948        sample_timing_array: *const CMSampleTimingInfo,
949        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
950    ) -> OSStatus {
951        extern "C-unwind" {
952            fn CMSampleBufferCreateCopyWithNewTiming(
953                allocator: Option<&CFAllocator>,
954                original_s_buf: &CMSampleBuffer,
955                num_sample_timing_entries: CMItemCount,
956                sample_timing_array: *const CMSampleTimingInfo,
957                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
958            ) -> OSStatus;
959        }
960        unsafe {
961            CMSampleBufferCreateCopyWithNewTiming(
962                allocator,
963                original_s_buf,
964                num_sample_timing_entries,
965                sample_timing_array,
966                sample_buffer_out,
967            )
968        }
969    }
970
971    /// Creates a CMSampleBuffer containing a range of samples from an existing CMSampleBuffer.
972    ///
973    /// Samples containing non-interleaved audio are currently not supported.
974    ///
975    /// # Safety
976    ///
977    /// `sample_buffer_out` must be a valid pointer.
978    #[doc(alias = "CMSampleBufferCopySampleBufferForRange")]
979    #[inline]
980    pub unsafe fn copy_sample_buffer_for_range(
981        allocator: Option<&CFAllocator>,
982        sbuf: &CMSampleBuffer,
983        sample_range: CFRange,
984        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
985    ) -> OSStatus {
986        extern "C-unwind" {
987            fn CMSampleBufferCopySampleBufferForRange(
988                allocator: Option<&CFAllocator>,
989                sbuf: &CMSampleBuffer,
990                sample_range: CFRange,
991                sample_buffer_out: NonNull<*mut CMSampleBuffer>,
992            ) -> OSStatus;
993        }
994        unsafe {
995            CMSampleBufferCopySampleBufferForRange(allocator, sbuf, sample_range, sample_buffer_out)
996        }
997    }
998}
999
1000unsafe impl ConcreteType for CMSampleBuffer {
1001    /// Returns the CFTypeID of CMSampleBuffer objects.
1002    ///
1003    /// You can check if a CFTypeRef object is actually a CMSampleBuffer by comparing CFGetTypeID(object) with CMSampleBufferGetTypeID().
1004    ///
1005    /// Returns: CFTypeID of CMSampleBuffer objects.
1006    #[doc(alias = "CMSampleBufferGetTypeID")]
1007    #[inline]
1008    fn type_id() -> CFTypeID {
1009        extern "C-unwind" {
1010            fn CMSampleBufferGetTypeID() -> CFTypeID;
1011        }
1012        unsafe { CMSampleBufferGetTypeID() }
1013    }
1014}
1015
1016impl CMSampleBuffer {
1017    /// Associates a CMSampleBuffer with its CMBlockBuffer of media data.
1018    ///
1019    /// If successful, this operation retains the dataBuffer thereafter, so the caller can release the dataBuffer
1020    /// after calling this API, if it has no further need to reference it. This is a write-once operation; it will fail if
1021    /// the CMSampleBuffer already has a dataBuffer. This API allows a CMSampleBuffer to exist, with timing and format
1022    /// information, before the associated data shows up. Example of usage: Some media services may have access to sample
1023    /// size, timing, and format information before the data is read.  Such services may create CMSampleBuffers with that
1024    /// information and insert them into queues early, and use this API to attach the CMBlockBuffers later, when the data
1025    /// becomes ready.
1026    #[doc(alias = "CMSampleBufferSetDataBuffer")]
1027    #[cfg(feature = "CMBlockBuffer")]
1028    #[inline]
1029    pub unsafe fn set_data_buffer(&self, data_buffer: &CMBlockBuffer) -> OSStatus {
1030        extern "C-unwind" {
1031            fn CMSampleBufferSetDataBuffer(
1032                sbuf: &CMSampleBuffer,
1033                data_buffer: &CMBlockBuffer,
1034            ) -> OSStatus;
1035        }
1036        unsafe { CMSampleBufferSetDataBuffer(self, data_buffer) }
1037    }
1038
1039    /// Returns a CMSampleBuffer's CMBlockBuffer of media data.
1040    ///
1041    /// The caller does not own the returned dataBuffer, and must retain it explicitly if the caller needs to maintain a reference to it.
1042    ///
1043    /// Returns: CMBlockBuffer of media data. The result will be NULL if the CMSampleBuffer does not contain a CMBlockBuffer, if the
1044    /// CMSampleBuffer contains a CVImageBuffer, or if there is some other error.
1045    #[doc(alias = "CMSampleBufferGetDataBuffer")]
1046    #[cfg(feature = "CMBlockBuffer")]
1047    #[inline]
1048    pub unsafe fn data_buffer(&self) -> Option<CFRetained<CMBlockBuffer>> {
1049        extern "C-unwind" {
1050            fn CMSampleBufferGetDataBuffer(sbuf: &CMSampleBuffer)
1051                -> Option<NonNull<CMBlockBuffer>>;
1052        }
1053        let ret = unsafe { CMSampleBufferGetDataBuffer(self) };
1054        ret.map(|ret| unsafe { CFRetained::retain(ret) })
1055    }
1056
1057    /// Returns a CMSampleBuffer's CVImageBuffer of media data.
1058    ///
1059    /// The caller does not own the returned dataBuffer, and must retain it explicitly if the caller needs to maintain a reference to it.
1060    ///
1061    /// Returns: CVImageBuffer of media data. The result will be NULL if the CMSampleBuffer does not contain a CVImageBuffer, if the
1062    /// CMSampleBuffer contains a CMBlockBuffer, or if there is some other error.
1063    #[doc(alias = "CMSampleBufferGetImageBuffer")]
1064    #[cfg(feature = "objc2-core-video")]
1065    #[inline]
1066    pub unsafe fn image_buffer(&self) -> Option<CFRetained<CVImageBuffer>> {
1067        extern "C-unwind" {
1068            fn CMSampleBufferGetImageBuffer(
1069                sbuf: &CMSampleBuffer,
1070            ) -> Option<NonNull<CVImageBuffer>>;
1071        }
1072        let ret = unsafe { CMSampleBufferGetImageBuffer(self) };
1073        ret.map(|ret| unsafe { CFRetained::retain(ret) })
1074    }
1075
1076    /// Creates a CMBlockBuffer containing a copy of the data from the AudioBufferList,
1077    /// and sets that as the CMSampleBuffer's data buffer. The resulting buffer(s) in the
1078    /// sample buffer will be 16-byte-aligned if
1079    /// kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment is passed in.
1080    ///
1081    /// # Safety
1082    ///
1083    /// `buffer_list` must be a valid pointer.
1084    #[doc(alias = "CMSampleBufferSetDataBufferFromAudioBufferList")]
1085    #[cfg(feature = "objc2-core-audio-types")]
1086    #[inline]
1087    pub unsafe fn set_data_buffer_from_audio_buffer_list(
1088        &self,
1089        block_buffer_structure_allocator: Option<&CFAllocator>,
1090        block_buffer_block_allocator: Option<&CFAllocator>,
1091        flags: u32,
1092        buffer_list: NonNull<AudioBufferList>,
1093    ) -> OSStatus {
1094        extern "C-unwind" {
1095            fn CMSampleBufferSetDataBufferFromAudioBufferList(
1096                sbuf: &CMSampleBuffer,
1097                block_buffer_structure_allocator: Option<&CFAllocator>,
1098                block_buffer_block_allocator: Option<&CFAllocator>,
1099                flags: u32,
1100                buffer_list: NonNull<AudioBufferList>,
1101            ) -> OSStatus;
1102        }
1103        unsafe {
1104            CMSampleBufferSetDataBufferFromAudioBufferList(
1105                self,
1106                block_buffer_structure_allocator,
1107                block_buffer_block_allocator,
1108                flags,
1109                buffer_list,
1110            )
1111        }
1112    }
1113
1114    /// Creates an AudioBufferList containing the data from the CMSampleBuffer,
1115    /// and a CMBlockBuffer which references (and manages the lifetime of) the
1116    /// data in that AudioBufferList.  The data may or may not be copied,
1117    /// depending on the contiguity and 16-byte alignment of the CMSampleBuffer's
1118    /// data. The buffers placed in the AudioBufferList are guaranteed to be contiguous.
1119    /// The buffers in the AudioBufferList will be 16-byte-aligned if
1120    /// kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment is passed in.
1121    ///
1122    /// # Safety
1123    ///
1124    /// - `buffer_list_size_needed_out` must be a valid pointer or null.
1125    /// - `buffer_list_out` must be a valid pointer or null.
1126    /// - `block_buffer_out` must be a valid pointer or null.
1127    #[doc(alias = "CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer")]
1128    #[cfg(all(feature = "CMBlockBuffer", feature = "objc2-core-audio-types"))]
1129    #[inline]
1130    pub unsafe fn audio_buffer_list_with_retained_block_buffer(
1131        &self,
1132        buffer_list_size_needed_out: *mut usize,
1133        buffer_list_out: *mut AudioBufferList,
1134        buffer_list_size: usize,
1135        block_buffer_structure_allocator: Option<&CFAllocator>,
1136        block_buffer_block_allocator: Option<&CFAllocator>,
1137        flags: u32,
1138        block_buffer_out: *mut *mut CMBlockBuffer,
1139    ) -> OSStatus {
1140        extern "C-unwind" {
1141            fn CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
1142                sbuf: &CMSampleBuffer,
1143                buffer_list_size_needed_out: *mut usize,
1144                buffer_list_out: *mut AudioBufferList,
1145                buffer_list_size: usize,
1146                block_buffer_structure_allocator: Option<&CFAllocator>,
1147                block_buffer_block_allocator: Option<&CFAllocator>,
1148                flags: u32,
1149                block_buffer_out: *mut *mut CMBlockBuffer,
1150            ) -> OSStatus;
1151        }
1152        unsafe {
1153            CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
1154                self,
1155                buffer_list_size_needed_out,
1156                buffer_list_out,
1157                buffer_list_size,
1158                block_buffer_structure_allocator,
1159                block_buffer_block_allocator,
1160                flags,
1161                block_buffer_out,
1162            )
1163        }
1164    }
1165
1166    /// Creates an array of AudioStreamPacketDescriptions for the
1167    /// variable bytes per packet or variable frames per packet
1168    /// audio data in the provided CMSampleBuffer.  Constant bitrate,
1169    /// constant frames-per-packet audio yields a return value of noErr
1170    /// and no packet descriptions.  This API is specific to audio format
1171    /// sample buffers, and will return kCMSampleBufferError_InvalidMediaTypeForOperation
1172    /// if called with a non-audio sample buffer.
1173    ///
1174    /// # Safety
1175    ///
1176    /// - `packet_descriptions_out` must be a valid pointer or null.
1177    /// - `packet_descriptions_size_needed_out` must be a valid pointer or null.
1178    #[doc(alias = "CMSampleBufferGetAudioStreamPacketDescriptions")]
1179    #[cfg(feature = "objc2-core-audio-types")]
1180    #[inline]
1181    pub unsafe fn audio_stream_packet_descriptions(
1182        &self,
1183        packet_descriptions_size: usize,
1184        packet_descriptions_out: *mut AudioStreamPacketDescription,
1185        packet_descriptions_size_needed_out: *mut usize,
1186    ) -> OSStatus {
1187        extern "C-unwind" {
1188            fn CMSampleBufferGetAudioStreamPacketDescriptions(
1189                sbuf: &CMSampleBuffer,
1190                packet_descriptions_size: usize,
1191                packet_descriptions_out: *mut AudioStreamPacketDescription,
1192                packet_descriptions_size_needed_out: *mut usize,
1193            ) -> OSStatus;
1194        }
1195        unsafe {
1196            CMSampleBufferGetAudioStreamPacketDescriptions(
1197                self,
1198                packet_descriptions_size,
1199                packet_descriptions_out,
1200                packet_descriptions_size_needed_out,
1201            )
1202        }
1203    }
1204
1205    /// Returns a pointer to (and size of) a constant array of
1206    /// AudioStreamPacketDescriptions for the variable bytes per
1207    /// packet or variable frames per packet audio data in the
1208    /// provided CMSampleBuffer.  The pointer will remain valid
1209    /// as long as the sbuf continues to be retained.
1210    /// Constant bitrate, constant frames-per-packet audio yields a
1211    /// return value of noErr and no packet descriptions.  This API is
1212    /// specific to audio format sample buffers, and will return
1213    /// kCMSampleBufferError_InvalidMediaTypeForOperation if called
1214    /// with a non-audio sample buffer.
1215    ///
1216    /// # Safety
1217    ///
1218    /// - `packet_descriptions_pointer_out` must be a valid pointer or null.
1219    /// - `packet_descriptions_size_out` must be a valid pointer or null.
1220    #[doc(alias = "CMSampleBufferGetAudioStreamPacketDescriptionsPtr")]
1221    #[cfg(feature = "objc2-core-audio-types")]
1222    #[inline]
1223    pub unsafe fn audio_stream_packet_descriptions_ptr(
1224        &self,
1225        packet_descriptions_pointer_out: *mut *const AudioStreamPacketDescription,
1226        packet_descriptions_size_out: *mut usize,
1227    ) -> OSStatus {
1228        extern "C-unwind" {
1229            fn CMSampleBufferGetAudioStreamPacketDescriptionsPtr(
1230                sbuf: &CMSampleBuffer,
1231                packet_descriptions_pointer_out: *mut *const AudioStreamPacketDescription,
1232                packet_descriptions_size_out: *mut usize,
1233            ) -> OSStatus;
1234        }
1235        unsafe {
1236            CMSampleBufferGetAudioStreamPacketDescriptionsPtr(
1237                self,
1238                packet_descriptions_pointer_out,
1239                packet_descriptions_size_out,
1240            )
1241        }
1242    }
1243
1244    /// Copies PCM audio data from the given CMSampleBuffer into
1245    /// a pre-populated AudioBufferList. The AudioBufferList must
1246    /// contain the same number of channels and its data buffers
1247    /// must be sized to hold the specified number of frames.
1248    /// This API is    specific to audio format sample buffers, and
1249    /// will return kCMSampleBufferError_InvalidMediaTypeForOperation
1250    /// if called with a non-audio sample buffer. It will return an
1251    /// error if the CMSampleBuffer does not contain PCM audio data
1252    /// or if its dataBuffer is not ready.
1253    ///
1254    /// # Safety
1255    ///
1256    /// `buffer_list` must be a valid pointer.
1257    #[doc(alias = "CMSampleBufferCopyPCMDataIntoAudioBufferList")]
1258    #[cfg(feature = "objc2-core-audio-types")]
1259    #[inline]
1260    pub unsafe fn copy_pcm_data_into_audio_buffer_list(
1261        &self,
1262        frame_offset: i32,
1263        num_frames: i32,
1264        buffer_list: NonNull<AudioBufferList>,
1265    ) -> OSStatus {
1266        extern "C-unwind" {
1267            fn CMSampleBufferCopyPCMDataIntoAudioBufferList(
1268                sbuf: &CMSampleBuffer,
1269                frame_offset: i32,
1270                num_frames: i32,
1271                buffer_list: NonNull<AudioBufferList>,
1272            ) -> OSStatus;
1273        }
1274        unsafe {
1275            CMSampleBufferCopyPCMDataIntoAudioBufferList(
1276                self,
1277                frame_offset,
1278                num_frames,
1279                buffer_list,
1280            )
1281        }
1282    }
1283
1284    /// Marks a CMSampleBuffer's data as "ready".
1285    ///
1286    /// There is no way to undo this operation.  The only way to get an "unready"
1287    /// CMSampleBuffer is to call CMSampleBufferCreate with the dataReady parameter
1288    /// set to false. Example of usage: in a read completion routine.
1289    #[doc(alias = "CMSampleBufferSetDataReady")]
1290    #[inline]
1291    pub unsafe fn set_data_ready(&self) -> OSStatus {
1292        extern "C-unwind" {
1293            fn CMSampleBufferSetDataReady(sbuf: &CMSampleBuffer) -> OSStatus;
1294        }
1295        unsafe { CMSampleBufferSetDataReady(self) }
1296    }
1297
1298    /// Returns whether or not a CMSampleBuffer's data is ready.
1299    ///
1300    /// Returns: Whether or not the CMSampleBuffer's data is ready.  True is returned for special marker buffers, even
1301    /// though they have no data. False is returned if there is an error.
1302    #[doc(alias = "CMSampleBufferDataIsReady")]
1303    #[inline]
1304    pub unsafe fn data_is_ready(&self) -> bool {
1305        extern "C-unwind" {
1306            fn CMSampleBufferDataIsReady(sbuf: &CMSampleBuffer) -> Boolean;
1307        }
1308        let ret = unsafe { CMSampleBufferDataIsReady(self) };
1309        ret != 0
1310    }
1311
1312    /// Marks a CMSampleBuffer's data as "failed", to indicate that the data will not become ready.
1313    #[doc(alias = "CMSampleBufferSetDataFailed")]
1314    #[inline]
1315    pub unsafe fn set_data_failed(&self, status: OSStatus) -> OSStatus {
1316        extern "C-unwind" {
1317            fn CMSampleBufferSetDataFailed(sbuf: &CMSampleBuffer, status: OSStatus) -> OSStatus;
1318        }
1319        unsafe { CMSampleBufferSetDataFailed(self, status) }
1320    }
1321
1322    /// Returns whether or not a CMSampleBuffer's data loading request has failed.
1323    ///
1324    /// # Safety
1325    ///
1326    /// `status_out` must be a valid pointer or null.
1327    #[doc(alias = "CMSampleBufferHasDataFailed")]
1328    #[inline]
1329    pub unsafe fn has_data_failed(&self, status_out: *mut OSStatus) -> bool {
1330        extern "C-unwind" {
1331            fn CMSampleBufferHasDataFailed(
1332                sbuf: &CMSampleBuffer,
1333                status_out: *mut OSStatus,
1334            ) -> Boolean;
1335        }
1336        let ret = unsafe { CMSampleBufferHasDataFailed(self, status_out) };
1337        ret != 0
1338    }
1339
1340    /// Makes a CMSampleBuffer's data ready, by calling the client's CMSampleBufferMakeDataReadyCallback.
1341    ///
1342    /// The CMSampleBufferMakeDataReadyCallback is passed in by the client during creation. It must return
1343    /// 0 if successful, and in that case, CMSampleBufferMakeDataReady will set the data readiness of
1344    /// the CMSampleBuffer to true. Example of usage: when it is time to actually use the data. Example of
1345    /// callback routine: a routine to force a scheduled read to complete.  If the CMSampleBuffer is not
1346    /// ready, and there is no CMSampleBufferMakeDataReadyCallback to call, kCMSampleBufferError_BufferNotReady
1347    /// will be returned. Similarly, if the CMSampleBuffer is not ready, and the CMSampleBufferMakeDataReadyCallback
1348    /// fails and returns an error, kCMSampleBufferError_BufferNotReady will be returned.
1349    #[doc(alias = "CMSampleBufferMakeDataReady")]
1350    #[inline]
1351    pub unsafe fn make_data_ready(&self) -> OSStatus {
1352        extern "C-unwind" {
1353            fn CMSampleBufferMakeDataReady(sbuf: &CMSampleBuffer) -> OSStatus;
1354        }
1355        unsafe { CMSampleBufferMakeDataReady(self) }
1356    }
1357
1358    /// Associates a CMSampleBuffer's data readiness with another CMSampleBuffer's data readiness.
1359    ///
1360    /// After calling this API, if CMSampleBufferDataIsReady(sbuf) is called, it will return sbufToTrack's data
1361    /// readiness. If CMSampleBufferMakeDataReady(sbuf) is called, it will do it by making sbufToTrack ready.
1362    /// Example of use: This allows bursting a multi-sample CMSampleBuffer into single-sample CMSampleBuffers
1363    /// before the data is ready. The single-sample CMSampleBuffers will all track the multi-sample
1364    /// CMSampleBuffer's data readiness.
1365    #[doc(alias = "CMSampleBufferTrackDataReadiness")]
1366    #[inline]
1367    pub unsafe fn track_data_readiness(&self, sample_buffer_to_track: &CMSampleBuffer) -> OSStatus {
1368        extern "C-unwind" {
1369            fn CMSampleBufferTrackDataReadiness(
1370                sbuf: &CMSampleBuffer,
1371                sample_buffer_to_track: &CMSampleBuffer,
1372            ) -> OSStatus;
1373        }
1374        unsafe { CMSampleBufferTrackDataReadiness(self, sample_buffer_to_track) }
1375    }
1376
1377    /// Makes the sample buffer invalid, calling any installed invalidation callback.
1378    ///
1379    /// An invalid sample buffer cannot be used -- all accessors will return kCMSampleBufferError_Invalidated.
1380    /// It is not a good idea to do this to a sample buffer that another module may be accessing concurrently.
1381    /// Example of use: the invalidation callback could cancel pending I/O.
1382    #[doc(alias = "CMSampleBufferInvalidate")]
1383    #[inline]
1384    pub unsafe fn invalidate(&self) -> OSStatus {
1385        extern "C-unwind" {
1386            fn CMSampleBufferInvalidate(sbuf: &CMSampleBuffer) -> OSStatus;
1387        }
1388        unsafe { CMSampleBufferInvalidate(self) }
1389    }
1390}
1391
1392/// Client callback called by CMSampleBufferInvalidate.
1393///
1394/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsamplebufferinvalidatecallback?language=objc)
1395pub type CMSampleBufferInvalidateCallback =
1396    Option<unsafe extern "C-unwind" fn(NonNull<CMSampleBuffer>, u64)>;
1397
1398impl CMSampleBuffer {
1399    /// Sets the sample buffer's invalidation callback, which is called during CMSampleBufferInvalidate.
1400    ///
1401    /// A sample buffer can only have one invalidation callback.
1402    /// The invalidation callback is NOT called during ordinary sample buffer finalization.
1403    ///
1404    /// # Safety
1405    ///
1406    /// `invalidate_callback` must be implemented correctly.
1407    #[doc(alias = "CMSampleBufferSetInvalidateCallback")]
1408    #[inline]
1409    pub unsafe fn set_invalidate_callback(
1410        &self,
1411        invalidate_callback: CMSampleBufferInvalidateCallback,
1412        invalidate_ref_con: u64,
1413    ) -> OSStatus {
1414        extern "C-unwind" {
1415            fn CMSampleBufferSetInvalidateCallback(
1416                sbuf: &CMSampleBuffer,
1417                invalidate_callback: CMSampleBufferInvalidateCallback,
1418                invalidate_ref_con: u64,
1419            ) -> OSStatus;
1420        }
1421        unsafe {
1422            CMSampleBufferSetInvalidateCallback(self, invalidate_callback, invalidate_ref_con)
1423        }
1424    }
1425}
1426
1427/// Client callback called by CMSampleBufferInvalidate.
1428///
1429/// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/cmsamplebufferinvalidatehandler?language=objc)
1430#[cfg(feature = "block2")]
1431pub type CMSampleBufferInvalidateHandler = *mut block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>)>;
1432
1433impl CMSampleBuffer {
1434    /// Sets the sample buffer's invalidation handler block, which is called during CMSampleBufferInvalidate.
1435    ///
1436    /// A sample buffer can only have one invalidation callback.
1437    /// The invalidation callback is NOT called during ordinary sample buffer finalization.
1438    ///
1439    /// # Safety
1440    ///
1441    /// `invalidate_handler` must be a valid pointer.
1442    #[doc(alias = "CMSampleBufferSetInvalidateHandler")]
1443    #[cfg(feature = "block2")]
1444    #[inline]
1445    pub unsafe fn set_invalidate_handler(
1446        &self,
1447        invalidate_handler: CMSampleBufferInvalidateHandler,
1448    ) -> OSStatus {
1449        extern "C-unwind" {
1450            fn CMSampleBufferSetInvalidateHandler(
1451                sbuf: &CMSampleBuffer,
1452                invalidate_handler: CMSampleBufferInvalidateHandler,
1453            ) -> OSStatus;
1454        }
1455        unsafe { CMSampleBufferSetInvalidateHandler(self, invalidate_handler) }
1456    }
1457
1458    /// Queries whether a sample buffer is still valid.
1459    ///
1460    /// Returns false if sbuf is NULL or CMSampleBufferInvalidate(sbuf) was called, true otherwise.
1461    /// Does not perform any kind of exhaustive validation of the sample buffer.
1462    #[doc(alias = "CMSampleBufferIsValid")]
1463    #[inline]
1464    pub unsafe fn is_valid(&self) -> bool {
1465        extern "C-unwind" {
1466            fn CMSampleBufferIsValid(sbuf: &CMSampleBuffer) -> Boolean;
1467        }
1468        let ret = unsafe { CMSampleBufferIsValid(self) };
1469        ret != 0
1470    }
1471}
1472
1473extern "C" {
1474    /// Posted on a CMSampleBuffer by CMSampleBufferSetDataReady when the buffer becomes ready.
1475    ///
1476    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffernotification_databecameready?language=objc)
1477    pub static kCMSampleBufferNotification_DataBecameReady: &'static CFString;
1478}
1479
1480extern "C" {
1481    /// Posted on a CMSampleBuffer by CMSampleBufferSetDataFailed to report that the buffer will never become ready.
1482    ///
1483    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffernotification_datafailed?language=objc)
1484    pub static kCMSampleBufferNotification_DataFailed: &'static CFString;
1485}
1486
1487extern "C" {
1488    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebuffernotificationparameter_osstatus?language=objc)
1489    pub static kCMSampleBufferNotificationParameter_OSStatus: &'static CFString;
1490}
1491
1492extern "C" {
1493    /// Posted on a conduit of CMSampleBuffers (eg, a CMBufferQueue) to announce a coming discontinuity and specify a tag value that will be attached to the first CMSampleBuffer following the discontinuity.
1494    ///
1495    /// The first CMSampleBuffer following the discontinuity should have
1496    /// a kCMSampleBufferAttachmentKey_ResumeOutput attachment with value containing
1497    /// the same CFNumber as this notification's payload's
1498    /// kCMSampleBufferConduitNotificationParameter_ResumeTag.
1499    /// The consumer should discard output data until it receives this CMSampleBuffer.
1500    /// If multiple kCMSampleBufferConduitNotification_InhibitOutputUntil notifications are
1501    /// received, the last one indicates the tag to trigger resuming.
1502    ///
1503    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotification_inhibitoutputuntil?language=objc)
1504    pub static kCMSampleBufferConduitNotification_InhibitOutputUntil: &'static CFString;
1505}
1506
1507extern "C" {
1508    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotificationparameter_resumetag?language=objc)
1509    pub static kCMSampleBufferConduitNotificationParameter_ResumeTag: &'static CFString;
1510}
1511
1512extern "C" {
1513    /// Posted on a conduit of CMSampleBuffers (eg, a CMBufferQueue) to request invalidation of pending output data.
1514    ///
1515    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotification_resetoutput?language=objc)
1516    pub static kCMSampleBufferConduitNotification_ResetOutput: &'static CFString;
1517}
1518
1519extern "C" {
1520    /// Posted on a conduit of video CMSampleBuffers (eg, a CMBufferQueue) to report information about the range of upcoming CMSampleBuffer output presentation timestamps.
1521    ///
1522    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotification_upcomingoutputptsrangechanged?language=objc)
1523    pub static kCMSampleBufferConduitNotification_UpcomingOutputPTSRangeChanged: &'static CFString;
1524}
1525
1526extern "C" {
1527    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotificationparameter_upcomingoutputptsrangemayoverlapqueuedoutputptsrange?language=objc)
1528    pub static kCMSampleBufferConduitNotificationParameter_UpcomingOutputPTSRangeMayOverlapQueuedOutputPTSRange:
1529        &'static CFString;
1530}
1531
1532extern "C" {
1533    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotificationparameter_minupcomingoutputpts?language=objc)
1534    pub static kCMSampleBufferConduitNotificationParameter_MinUpcomingOutputPTS: &'static CFString;
1535}
1536
1537extern "C" {
1538    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconduitnotificationparameter_maxupcomingoutputpts?language=objc)
1539    pub static kCMSampleBufferConduitNotificationParameter_MaxUpcomingOutputPTS: &'static CFString;
1540}
1541
1542extern "C" {
1543    /// Posted when a CMSampleBuffer that has kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed is consumed.
1544    ///
1545    /// After an object consumes a CMSampleBuffer that has a kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed
1546    /// attachment, it should post kCMSampleBufferConsumerNotification_BufferConsumed
1547    /// with itself as the notifyingObject and the attachment value as the payload.
1548    /// Such an attachment value must be a CFDictionary but the contents are client-defined.
1549    ///
1550    /// Note that a NULL refcon cannot be attached to a CMSampleBuffer.
1551    ///
1552    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferconsumernotification_bufferconsumed?language=objc)
1553    pub static kCMSampleBufferConsumerNotification_BufferConsumed: &'static CFString;
1554}
1555
1556impl CMSampleBuffer {
1557    /// Returns the number of media samples in a CMSampleBuffer.
1558    ///
1559    /// Returns: The number of media samples in the CMSampleBuffer. 0 is returned if there is an error.
1560    #[doc(alias = "CMSampleBufferGetNumSamples")]
1561    #[cfg(feature = "CMBase")]
1562    #[inline]
1563    pub unsafe fn num_samples(&self) -> CMItemCount {
1564        extern "C-unwind" {
1565            fn CMSampleBufferGetNumSamples(sbuf: &CMSampleBuffer) -> CMItemCount;
1566        }
1567        unsafe { CMSampleBufferGetNumSamples(self) }
1568    }
1569
1570    /// Returns the total duration of a CMSampleBuffer.
1571    ///
1572    /// If the buffer contains out-of-presentation-order samples, any gaps in the presentation timeline are not represented in the returned duration.
1573    /// The returned duration is simply the sum of all the individual sample durations.
1574    ///
1575    /// Returns: The duration of the CMSampleBuffer. kCMTimeInvalid is returned if there is an error.
1576    #[doc(alias = "CMSampleBufferGetDuration")]
1577    #[cfg(feature = "CMTime")]
1578    #[inline]
1579    pub unsafe fn duration(&self) -> CMTime {
1580        extern "C-unwind" {
1581            fn CMSampleBufferGetDuration(sbuf: &CMSampleBuffer) -> CMTime;
1582        }
1583        unsafe { CMSampleBufferGetDuration(self) }
1584    }
1585
1586    /// Returns the numerically earliest presentation timestamp of all the samples in a CMSampleBuffer.
1587    ///
1588    /// For in-presentation-order samples, this is the presentation timestamp of the first sample.
1589    /// For out-of-presentation-order samples, this is the presentation timestamp of the sample that
1590    /// will be presented first, which is not necessarily the first sample in the buffer.
1591    ///
1592    /// Returns: Numerically earliest sample presentation timestamp in the CMSampleBuffer.  kCMTimeInvalid is returned if there is an error.
1593    #[doc(alias = "CMSampleBufferGetPresentationTimeStamp")]
1594    #[cfg(feature = "CMTime")]
1595    #[inline]
1596    pub unsafe fn presentation_time_stamp(&self) -> CMTime {
1597        extern "C-unwind" {
1598            fn CMSampleBufferGetPresentationTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
1599        }
1600        unsafe { CMSampleBufferGetPresentationTimeStamp(self) }
1601    }
1602
1603    /// Returns the numerically earliest decode timestamp of all the samples in a CMSampleBuffer.
1604    ///
1605    /// The returned decode timestamp is always the decode timestamp of the first sample in the buffer,
1606    /// since even out-of-presentation-order samples are expected to be in decode order in the buffer.
1607    ///
1608    /// Returns: Numerically earliest sample decode timestamp in the CMSampleBuffer.  kCMTimeInvalid is returned if there is an error.
1609    #[doc(alias = "CMSampleBufferGetDecodeTimeStamp")]
1610    #[cfg(feature = "CMTime")]
1611    #[inline]
1612    pub unsafe fn decode_time_stamp(&self) -> CMTime {
1613        extern "C-unwind" {
1614            fn CMSampleBufferGetDecodeTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
1615        }
1616        unsafe { CMSampleBufferGetDecodeTimeStamp(self) }
1617    }
1618
1619    /// Returns the output duration of a CMSampleBuffer.
1620    ///
1621    /// The OutputDuration is the duration minus any trimmed duration, all divided by the SpeedMultiplier:
1622    /// (Duration - TrimDurationAtStart - TrimDurationAtEnd) / SpeedMultiplier
1623    ///
1624    /// Returns: The output duration of the CMSampleBuffer. kCMTimeInvalid is returned if there is an error.
1625    #[doc(alias = "CMSampleBufferGetOutputDuration")]
1626    #[cfg(feature = "CMTime")]
1627    #[inline]
1628    pub unsafe fn output_duration(&self) -> CMTime {
1629        extern "C-unwind" {
1630            fn CMSampleBufferGetOutputDuration(sbuf: &CMSampleBuffer) -> CMTime;
1631        }
1632        unsafe { CMSampleBufferGetOutputDuration(self) }
1633    }
1634
1635    /// Returns the output presentation timestamp of the CMSampleBuffer.
1636    ///
1637    /// The output presentation timestamp is the time at which the decoded, trimmed, stretched
1638    /// and possibly reversed samples should commence being presented.
1639    /// If CMSampleBufferSetOutputPresentationTimeStamp has been called to explicitly set the output PTS,
1640    /// CMSampleBufferGetOutputPresentationTimeStamp returns it.
1641    /// If not, CMSampleBufferGetOutputPresentationTimeStamp calculates its result as
1642    /// (PresentationTimeStamp + TrimDurationAtStart)
1643    /// unless kCMSampleBufferAttachmentKey_Reverse is kCFBooleanTrue, in which case it calculates the result as
1644    /// (PresentationTimeStamp + Duration - TrimDurationAtEnd).
1645    /// These are generally correct for un-stretched, un-shifted playback.
1646    /// For general forward playback in a scaled edit, the OutputPresentationTimeStamp should be set to:
1647    /// ((PresentationTimeStamp + TrimDurationAtStart - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime.
1648    /// For general reversed playback:
1649    /// ((PresentationTimeStamp + Duration - TrimDurationAtEnd - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime.
1650    ///
1651    /// Returns: kCMTimeInvalid is returned if there is an error.
1652    #[doc(alias = "CMSampleBufferGetOutputPresentationTimeStamp")]
1653    #[cfg(feature = "CMTime")]
1654    #[inline]
1655    pub unsafe fn output_presentation_time_stamp(&self) -> CMTime {
1656        extern "C-unwind" {
1657            fn CMSampleBufferGetOutputPresentationTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
1658        }
1659        unsafe { CMSampleBufferGetOutputPresentationTimeStamp(self) }
1660    }
1661
1662    /// Sets an output presentation timestamp to be used in place of a calculated value.
1663    ///
1664    /// The output presentation timestamp is the time at which the decoded, trimmed, stretched
1665    /// and possibly reversed samples should commence being presented.
1666    /// By default, this is calculated by CMSampleBufferGetOutputPresentationTimeStamp.
1667    /// Call CMSampleBufferSetOutputPresentationTimeStamp to explicitly set the value for
1668    /// CMSampleBufferGetOutputPresentationTimeStamp to return.
1669    /// For general forward playback in a scaled edit, the OutputPresentationTimeStamp should be set to:
1670    /// ((PresentationTimeStamp + TrimDurationAtStart - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime.
1671    /// For general reversed playback:
1672    /// ((PresentationTimeStamp + Duration - TrimDurationAtEnd - EditStartMediaTime) / EditSpeedMultiplier) + EditStartTrackTime.
1673    #[doc(alias = "CMSampleBufferSetOutputPresentationTimeStamp")]
1674    #[cfg(feature = "CMTime")]
1675    #[inline]
1676    pub unsafe fn set_output_presentation_time_stamp(
1677        &self,
1678        output_presentation_time_stamp: CMTime,
1679    ) -> OSStatus {
1680        extern "C-unwind" {
1681            fn CMSampleBufferSetOutputPresentationTimeStamp(
1682                sbuf: &CMSampleBuffer,
1683                output_presentation_time_stamp: CMTime,
1684            ) -> OSStatus;
1685        }
1686        unsafe {
1687            CMSampleBufferSetOutputPresentationTimeStamp(self, output_presentation_time_stamp)
1688        }
1689    }
1690
1691    /// Returns the output decode timestamp of the CMSampleBuffer.
1692    ///
1693    /// For consistency with CMSampleBufferGetOutputPresentationTimeStamp, this is calculated as:
1694    /// OutputPresentationTimeStamp + ((DecodeTimeStamp - PresentationTimeStamp) / SpeedMultiplier).
1695    ///
1696    /// Returns: CMInvalidTime is returned if there is an error.
1697    #[doc(alias = "CMSampleBufferGetOutputDecodeTimeStamp")]
1698    #[cfg(feature = "CMTime")]
1699    #[inline]
1700    pub unsafe fn output_decode_time_stamp(&self) -> CMTime {
1701        extern "C-unwind" {
1702            fn CMSampleBufferGetOutputDecodeTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
1703        }
1704        unsafe { CMSampleBufferGetOutputDecodeTimeStamp(self) }
1705    }
1706
1707    /// Returns an array of CMSampleTimingInfo structs, one for each sample in a CMSampleBuffer.
1708    ///
1709    /// If only one CMSampleTimingInfo struct is returned, it applies to all samples in the buffer.
1710    /// See documentation of CMSampleTimingInfo for details of how a single CMSampleTimingInfo struct can apply to multiple samples.
1711    /// The timingArrayOut must be allocated by the caller, and the number of entries allocated must be passed in timingArrayEntries.
1712    /// If timingArrayOut is NULL, timingArrayEntriesNeededOut will return the required number of entries.  Similarly,
1713    /// if timingArrayEntries is too small, kCMSampleBufferError_ArrayTooSmall will be returned, and timingArrayEntriesNeededOut
1714    /// will return the required number of entries. In either case, the caller can then make an appropriately-sized timingArrayOut and call again.
1715    /// For example, the caller might pass the address of a CMSampleTimingInfo struct on the stack (as timingArrayOut), and 1 (as
1716    /// timingArrayEntries). If all samples are describable with a single CMSampleTimingInfo struct (or there is only one sample
1717    /// in the CMSampleBuffer), this call will succeed. If not, it will fail, and will return the number of entries required in
1718    /// timingArrayEntriesNeededOut. Only in this case will the caller actually need to allocate an array.
1719    ///
1720    /// If there is no timingInfo in this CMSampleBuffer, kCMSampleBufferError_BufferHasNoSampleTimingInfo will be returned, and
1721    /// timingArrayEntriesNeededOut will be set to 0.
1722    ///
1723    /// # Safety
1724    ///
1725    /// - `timing_array_out` must be a valid pointer or null.
1726    /// - `timing_array_entries_needed_out` must be a valid pointer or null.
1727    #[doc(alias = "CMSampleBufferGetSampleTimingInfoArray")]
1728    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
1729    #[inline]
1730    pub unsafe fn sample_timing_info_array(
1731        &self,
1732        num_sample_timing_entries: CMItemCount,
1733        timing_array_out: *mut CMSampleTimingInfo,
1734        timing_array_entries_needed_out: *mut CMItemCount,
1735    ) -> OSStatus {
1736        extern "C-unwind" {
1737            fn CMSampleBufferGetSampleTimingInfoArray(
1738                sbuf: &CMSampleBuffer,
1739                num_sample_timing_entries: CMItemCount,
1740                timing_array_out: *mut CMSampleTimingInfo,
1741                timing_array_entries_needed_out: *mut CMItemCount,
1742            ) -> OSStatus;
1743        }
1744        unsafe {
1745            CMSampleBufferGetSampleTimingInfoArray(
1746                self,
1747                num_sample_timing_entries,
1748                timing_array_out,
1749                timing_array_entries_needed_out,
1750            )
1751        }
1752    }
1753
1754    /// Returns an array of output CMSampleTimingInfo structs, one for each sample in a CMSampleBuffer.
1755    ///
1756    /// If only one CMSampleTimingInfo struct is returned, it applies to all samples in the buffer.
1757    /// See documentation of CMSampleTimingInfo for details of how a single CMSampleTimingInfo struct can apply to multiple samples.
1758    /// The timingArrayOut must be allocated by the caller, and the number of entries allocated must be passed in timingArrayEntries.
1759    /// If timingArrayOut is NULL, timingArrayEntriesNeededOut will return the required number of entries.  Similarly,
1760    /// if timingArrayEntries is too small, kCMSampleBufferError_ArrayTooSmall will be returned, and timingArrayEntriesNeededOut
1761    /// will return the required number of entries. In either case, the caller can then make an appropriately-sized timingArrayOut and call again.
1762    /// For example, the caller might pass the address of a CMSampleTimingInfo struct on the stack (as timingArrayOut), and 1 (as
1763    /// timingArrayEntries). If all samples are describable with a single CMSampleTimingInfo struct (or there is only one sample
1764    /// in the CMSampleBuffer), this call will succeed. If not, it will fail, and will return the number of entries required in
1765    /// timingArrayEntriesNeededOut. Only in this case will the caller actually need to allocate an array.
1766    ///
1767    /// If there is no timingInfo in this CMSampleBuffer, kCMSampleBufferError_BufferHasNoSampleTimingInfo will be returned,
1768    /// and *timingArrayEntriesNeededOut will be set to 0.
1769    ///
1770    /// # Safety
1771    ///
1772    /// - `timing_array_out` must be a valid pointer or null.
1773    /// - `timing_array_entries_needed_out` must be a valid pointer or null.
1774    #[doc(alias = "CMSampleBufferGetOutputSampleTimingInfoArray")]
1775    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
1776    #[inline]
1777    pub unsafe fn output_sample_timing_info_array(
1778        &self,
1779        timing_array_entries: CMItemCount,
1780        timing_array_out: *mut CMSampleTimingInfo,
1781        timing_array_entries_needed_out: *mut CMItemCount,
1782    ) -> OSStatus {
1783        extern "C-unwind" {
1784            fn CMSampleBufferGetOutputSampleTimingInfoArray(
1785                sbuf: &CMSampleBuffer,
1786                timing_array_entries: CMItemCount,
1787                timing_array_out: *mut CMSampleTimingInfo,
1788                timing_array_entries_needed_out: *mut CMItemCount,
1789            ) -> OSStatus;
1790        }
1791        unsafe {
1792            CMSampleBufferGetOutputSampleTimingInfoArray(
1793                self,
1794                timing_array_entries,
1795                timing_array_out,
1796                timing_array_entries_needed_out,
1797            )
1798        }
1799    }
1800
1801    /// Returns a CMSampleTimingInfo struct describing a specified sample in a CMSampleBuffer.
1802    ///
1803    /// A sample-specific CMSampleTimingInfo struct will be returned (ie. with a sample-specific
1804    /// presentationTimeStamp and decodeTimeStamp), even if a single CMSampleTimingInfo struct was used
1805    /// during creation to describe all the samples in the buffer. The timingInfo struct must be
1806    /// allocated by the caller.  If the sample index is not in the range 0 .. numSamples-1,
1807    /// kCMSampleBufferError_SampleIndexOutOfRange will be returned.  If there is no timingInfo
1808    /// in this CMSampleBuffer, kCMSampleBufferError_BufferHasNoSampleTimingInfo will be returned.
1809    ///
1810    /// # Safety
1811    ///
1812    /// `timing_info_out` must be a valid pointer.
1813    #[doc(alias = "CMSampleBufferGetSampleTimingInfo")]
1814    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
1815    #[inline]
1816    pub unsafe fn sample_timing_info(
1817        &self,
1818        sample_index: CMItemIndex,
1819        timing_info_out: NonNull<CMSampleTimingInfo>,
1820    ) -> OSStatus {
1821        extern "C-unwind" {
1822            fn CMSampleBufferGetSampleTimingInfo(
1823                sbuf: &CMSampleBuffer,
1824                sample_index: CMItemIndex,
1825                timing_info_out: NonNull<CMSampleTimingInfo>,
1826            ) -> OSStatus;
1827        }
1828        unsafe { CMSampleBufferGetSampleTimingInfo(self, sample_index, timing_info_out) }
1829    }
1830
1831    /// Returns an array of sample sizes, one for each sample in a CMSampleBuffer.
1832    ///
1833    /// If only one size entry is returned, all samples in the buffer are of this size.
1834    /// The sizeArrayOut must be allocated by the caller, and the number of entries allocated must be passed in sizeArrayEntries.
1835    /// If sizeArrayOut is NULL, sizeArrayEntriesNeededOut will return the required number of entries.  Similarly, if sizeArrayEntries
1836    /// is too small, kCMSampleBufferError_ArrayTooSmall will be returned, and sizeArrayEntriesNeededOut will return the required number of entries.
1837    /// The caller can then make an appropriately-sized sizeArrayOut and call again. For example, the caller might pass the address
1838    /// of a size_t variable on the stack (as sizeArrayOut), and 1 (as sizeArrayEntries). If all samples are the same size (or there
1839    /// is only one sample in the CMSampleBuffer), this call would succeed. If not, it will fail, and will return the number of
1840    /// entries required in sizeArrayEntriesNeededOut. Only in this case (multiple samples of different sizes) will the caller
1841    /// need to allocate an array.  0 entries will be returned if the samples in the buffer are non-contiguous (eg. non-interleaved
1842    /// audio, where the channel values for a single sample are scattered through the buffer).
1843    ///
1844    /// If there are no sample sizes in this CMSampleBuffer, kCMSampleBufferError_BufferHasNoSampleSizes will be returned,
1845    /// and *sizeArrayEntriesNeededOut will be set to 0.  This will be true, for example,
1846    /// if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where
1847    /// the channel values for a single sample are scattered through the buffer), or if
1848    /// this CMSampleBuffer contains a CVImageBuffer.
1849    ///
1850    /// # Safety
1851    ///
1852    /// - `size_array_out` must be a valid pointer or null.
1853    /// - `size_array_entries_needed_out` must be a valid pointer or null.
1854    #[doc(alias = "CMSampleBufferGetSampleSizeArray")]
1855    #[cfg(feature = "CMBase")]
1856    #[inline]
1857    pub unsafe fn sample_size_array(
1858        &self,
1859        size_array_entries: CMItemCount,
1860        size_array_out: *mut usize,
1861        size_array_entries_needed_out: *mut CMItemCount,
1862    ) -> OSStatus {
1863        extern "C-unwind" {
1864            fn CMSampleBufferGetSampleSizeArray(
1865                sbuf: &CMSampleBuffer,
1866                size_array_entries: CMItemCount,
1867                size_array_out: *mut usize,
1868                size_array_entries_needed_out: *mut CMItemCount,
1869            ) -> OSStatus;
1870        }
1871        unsafe {
1872            CMSampleBufferGetSampleSizeArray(
1873                self,
1874                size_array_entries,
1875                size_array_out,
1876                size_array_entries_needed_out,
1877            )
1878        }
1879    }
1880
1881    /// Returns the size in bytes of a specified sample in a CMSampleBuffer.
1882    ///
1883    /// Returns: Size in bytes of the specified sample in the CMSampleBuffer.
1884    /// If the sample index is not in the range 0 .. numSamples-1,
1885    /// a size of 0 will be returned.  If there are no sample sizes
1886    /// in this CMSampleBuffer, a size of 0 will be returned.  This will be true, for example,
1887    /// if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where
1888    /// the channel values for a single sample are scattered through the buffer),
1889    /// or if this CMSampleBuffer contains a CVImageBuffer.
1890    #[doc(alias = "CMSampleBufferGetSampleSize")]
1891    #[cfg(feature = "CMBase")]
1892    #[inline]
1893    pub unsafe fn sample_size(&self, sample_index: CMItemIndex) -> usize {
1894        extern "C-unwind" {
1895            fn CMSampleBufferGetSampleSize(
1896                sbuf: &CMSampleBuffer,
1897                sample_index: CMItemIndex,
1898            ) -> usize;
1899        }
1900        unsafe { CMSampleBufferGetSampleSize(self, sample_index) }
1901    }
1902
1903    /// Returns the total size in bytes of sample data in a CMSampleBuffer.
1904    ///
1905    /// Returns: Total size in bytes of sample data in the CMSampleBuffer.
1906    /// If there are no sample sizes in this CMSampleBuffer, a size of 0 will be returned.
1907    #[doc(alias = "CMSampleBufferGetTotalSampleSize")]
1908    #[inline]
1909    pub unsafe fn total_sample_size(&self) -> usize {
1910        extern "C-unwind" {
1911            fn CMSampleBufferGetTotalSampleSize(sbuf: &CMSampleBuffer) -> usize;
1912        }
1913        unsafe { CMSampleBufferGetTotalSampleSize(self) }
1914    }
1915
1916    /// Returns the format description of the samples in a CMSampleBuffer.
1917    ///
1918    /// On return, the caller does not own the returned formatDesc, and must retain it explicitly if the caller needs to maintain a reference to it.
1919    ///
1920    /// Returns: The format description of the samples in the CMSampleBuffer.  NULL is returned if there is an error.
1921    #[doc(alias = "CMSampleBufferGetFormatDescription")]
1922    #[cfg(feature = "CMFormatDescription")]
1923    #[inline]
1924    pub unsafe fn format_description(&self) -> Option<CFRetained<CMFormatDescription>> {
1925        extern "C-unwind" {
1926            fn CMSampleBufferGetFormatDescription(
1927                sbuf: &CMSampleBuffer,
1928            ) -> Option<NonNull<CMFormatDescription>>;
1929        }
1930        let ret = unsafe { CMSampleBufferGetFormatDescription(self) };
1931        ret.map(|ret| unsafe { CFRetained::retain(ret) })
1932    }
1933
1934    /// Returns a reference to a CMSampleBuffer's immutable array of mutable sample attachments dictionaries (one dictionary
1935    /// per sample in the CMSampleBuffer).
1936    ///
1937    /// Attachments can then be added/removed directly by the caller, using CF APIs. On return, the caller does not
1938    /// own the returned array of attachments dictionaries, and must retain it if the caller needs to maintain a
1939    /// reference to it. If there are no sample attachments yet, and createIfNecessary is true, a new CFArray containing N empty
1940    /// CFMutableDictionaries is returned (where N is the number of samples in the CMSampleBuffer), so that
1941    /// attachments can be added directly by the caller. If there are no sample attachments yet, and createIfNecessary is
1942    /// false, NULL is returned.  Once the CFArray has been created, subsequent calls will return it, even if there are still
1943    /// no sample attachments in the array.
1944    ///
1945    /// Returns: A reference to the CMSampleBuffer's immutable array of mutable sample attachments dictionaries (one dictionary per sample
1946    /// in the CMSampleBuffer). NULL is returned if there is an error.
1947    #[doc(alias = "CMSampleBufferGetSampleAttachmentsArray")]
1948    #[inline]
1949    pub unsafe fn sample_attachments_array(
1950        &self,
1951        create_if_necessary: bool,
1952    ) -> Option<CFRetained<CFArray>> {
1953        extern "C-unwind" {
1954            fn CMSampleBufferGetSampleAttachmentsArray(
1955                sbuf: &CMSampleBuffer,
1956                create_if_necessary: Boolean,
1957            ) -> Option<NonNull<CFArray>>;
1958        }
1959        let ret =
1960            unsafe { CMSampleBufferGetSampleAttachmentsArray(self, create_if_necessary as _) };
1961        ret.map(|ret| unsafe { CFRetained::retain(ret) })
1962    }
1963}
1964
1965extern "C" {
1966    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_notsync?language=objc)
1967    pub static kCMSampleAttachmentKey_NotSync: &'static CFString;
1968}
1969
1970extern "C" {
1971    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_partialsync?language=objc)
1972    pub static kCMSampleAttachmentKey_PartialSync: &'static CFString;
1973}
1974
1975extern "C" {
1976    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hasredundantcoding?language=objc)
1977    pub static kCMSampleAttachmentKey_HasRedundantCoding: &'static CFString;
1978}
1979
1980extern "C" {
1981    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_isdependedonbyothers?language=objc)
1982    pub static kCMSampleAttachmentKey_IsDependedOnByOthers: &'static CFString;
1983}
1984
1985extern "C" {
1986    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_dependsonothers?language=objc)
1987    pub static kCMSampleAttachmentKey_DependsOnOthers: &'static CFString;
1988}
1989
1990extern "C" {
1991    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_earlierdisplaytimesallowed?language=objc)
1992    pub static kCMSampleAttachmentKey_EarlierDisplayTimesAllowed: &'static CFString;
1993}
1994
1995extern "C" {
1996    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_displayimmediately?language=objc)
1997    pub static kCMSampleAttachmentKey_DisplayImmediately: &'static CFString;
1998}
1999
2000extern "C" {
2001    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_donotdisplay?language=objc)
2002    pub static kCMSampleAttachmentKey_DoNotDisplay: &'static CFString;
2003}
2004
2005extern "C" {
2006    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_resetdecoderbeforedecoding?language=objc)
2007    pub static kCMSampleBufferAttachmentKey_ResetDecoderBeforeDecoding: &'static CFString;
2008}
2009
2010extern "C" {
2011    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_drainafterdecoding?language=objc)
2012    pub static kCMSampleBufferAttachmentKey_DrainAfterDecoding: &'static CFString;
2013}
2014
2015extern "C" {
2016    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_postnotificationwhenconsumed?language=objc)
2017    pub static kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed: &'static CFString;
2018}
2019
2020extern "C" {
2021    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_resumeoutput?language=objc)
2022    pub static kCMSampleBufferAttachmentKey_ResumeOutput: &'static CFString;
2023}
2024
2025extern "C" {
2026    /// Indicates a video frame's level within a hierarchical frame dependency structure.
2027    ///
2028    /// When present, the temporal level attachments among a group of video frames provide information about where inter-frame dependencies may and may not exist.
2029    /// The temporal level attachment, if present, is a positive CFNumber, and indicates that this video frame does not depend on any video frame with a greater temporal level.
2030    /// The attachment may be absent if no such information is available.
2031    ///
2032    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hevctemporallevelinfo?language=objc)
2033    pub static kCMSampleAttachmentKey_HEVCTemporalLevelInfo: &'static CFString;
2034}
2035
2036extern "C" {
2037    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_temporallevel?language=objc)
2038    pub static kCMHEVCTemporalLevelInfoKey_TemporalLevel: &'static CFString;
2039}
2040
2041extern "C" {
2042    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_profilespace?language=objc)
2043    pub static kCMHEVCTemporalLevelInfoKey_ProfileSpace: &'static CFString;
2044}
2045
2046extern "C" {
2047    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_tierflag?language=objc)
2048    pub static kCMHEVCTemporalLevelInfoKey_TierFlag: &'static CFString;
2049}
2050
2051extern "C" {
2052    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_profileindex?language=objc)
2053    pub static kCMHEVCTemporalLevelInfoKey_ProfileIndex: &'static CFString;
2054}
2055
2056extern "C" {
2057    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_profilecompatibilityflags?language=objc)
2058    pub static kCMHEVCTemporalLevelInfoKey_ProfileCompatibilityFlags: &'static CFString;
2059}
2060
2061extern "C" {
2062    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_constraintindicatorflags?language=objc)
2063    pub static kCMHEVCTemporalLevelInfoKey_ConstraintIndicatorFlags: &'static CFString;
2064}
2065
2066extern "C" {
2067    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmhevctemporallevelinfokey_levelindex?language=objc)
2068    pub static kCMHEVCTemporalLevelInfoKey_LevelIndex: &'static CFString;
2069}
2070
2071extern "C" {
2072    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hevctemporalsublayeraccess?language=objc)
2073    pub static kCMSampleAttachmentKey_HEVCTemporalSubLayerAccess: &'static CFString;
2074}
2075
2076extern "C" {
2077    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hevcstepwisetemporalsublayeraccess?language=objc)
2078    pub static kCMSampleAttachmentKey_HEVCStepwiseTemporalSubLayerAccess: &'static CFString;
2079}
2080
2081extern "C" {
2082    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hevcsyncsamplenalunittype?language=objc)
2083    pub static kCMSampleAttachmentKey_HEVCSyncSampleNALUnitType: &'static CFString;
2084}
2085
2086extern "C" {
2087    /// [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_audioindependentsampledecoderrefreshcount?language=objc)
2088    pub static kCMSampleAttachmentKey_AudioIndependentSampleDecoderRefreshCount: &'static CFString;
2089}
2090
2091extern "C" {
2092    /// Marks a transition from one source of buffers (eg. song) to another
2093    ///
2094    /// For example, during gapless playback of a list of songs, this attachment marks the first buffer from the next song.
2095    /// If this attachment is on a buffer containing no samples, the first following buffer that contains samples is the
2096    /// buffer that contains the first samples from the next song.  The value of this attachment is a CFTypeRef.  This
2097    /// transition identifier should be unique within a playlist, so each transition in a playlist is uniquely
2098    /// identifiable.  A CFNumberRef counter that increments with each transition is a simple example.
2099    ///
2100    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_transitionid?language=objc)
2101    pub static kCMSampleBufferAttachmentKey_TransitionID: &'static CFString;
2102}
2103
2104extern "C" {
2105    /// The duration that should be removed at the beginning of the sample buffer, after decoding.
2106    ///
2107    /// If this attachment is not present, the trim duration is zero (nothing removed).
2108    /// This is a CMTime in CFDictionary format as made by CMTimeCopyAsDictionary;
2109    /// use CMTimeMakeFromDictionary to convert to CMTime.
2110    /// In cases where all the output after decoding the sample buffer is to be discarded
2111    /// (eg, the samples are only being decoded to prime the decoder) the usual convention
2112    /// is to set kCMSampleBufferAttachmentKey_TrimDurationAtStart to the whole duration
2113    /// and not to set a kCMSampleBufferAttachmentKey_TrimDurationAtEnd attachment.
2114    /// Note that setting or removing kCMSampleBufferAttachmentKey_TrimDurationAtStart from
2115    /// a sample buffer will not adjust an explicitly-set OutputPresentationTimeStamp.
2116    ///
2117    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_trimdurationatstart?language=objc)
2118    pub static kCMSampleBufferAttachmentKey_TrimDurationAtStart: &'static CFString;
2119}
2120
2121extern "C" {
2122    /// The duration that should be removed at the end of the sample buffer, after decoding.
2123    ///
2124    /// If this attachment is not present, the trim duration is zero (nothing removed).
2125    /// This is a CMTime in CFDictionary format as made by CMTimeCopyAsDictionary;
2126    /// use CMTimeMakeFromDictionary to convert to CMTime.
2127    ///
2128    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_trimdurationatend?language=objc)
2129    pub static kCMSampleBufferAttachmentKey_TrimDurationAtEnd: &'static CFString;
2130}
2131
2132extern "C" {
2133    /// The factor by which the sample buffer's presentation should be accelerated (eg, in a scaled edit).
2134    ///
2135    /// For normal playback the speed multiplier would be 1.0 (which is used if this attachment is not present);
2136    /// for double-speed playback the speed multiplier would be 2.0, which would halve the output duration.
2137    /// Speed-multiplication factors take effect after trimming; see CMSampleBufferGetOutputDuration.
2138    /// Note that this attachment principally provides information about the duration-stretching effect:
2139    /// by default, it should be implemented by rate conversion, but other attachments may specify richer
2140    /// stretching operations -- for example, scaling without pitch shift, or pitch shift without changing duration.
2141    /// Sequences of speed-multiplied sample buffers should have explicit OutputPresentationTimeStamp attachments
2142    /// to clarify when each should be output.
2143    ///
2144    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_speedmultiplier?language=objc)
2145    pub static kCMSampleBufferAttachmentKey_SpeedMultiplier: &'static CFString;
2146}
2147
2148extern "C" {
2149    /// Indicates that the decoded contents of the sample buffer should be reversed.
2150    /// If this attachment is not present, the sample buffer should be played forwards as usual.
2151    /// Reversal occurs after trimming and speed multipliers.
2152    ///
2153    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_reverse?language=objc)
2154    pub static kCMSampleBufferAttachmentKey_Reverse: &'static CFString;
2155}
2156
2157extern "C" {
2158    /// Fill the difference between discontiguous sample buffers with silence.
2159    ///
2160    /// If a sample buffer enters a buffer queue and the presentation time stamp between the
2161    /// previous buffer and the buffer with this attachment are discontiguous, handle the
2162    /// discontinuity by generating silence for the time difference.
2163    ///
2164    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_filldiscontinuitieswithsilence?language=objc)
2165    pub static kCMSampleBufferAttachmentKey_FillDiscontinuitiesWithSilence: &'static CFString;
2166}
2167
2168extern "C" {
2169    /// Marks an intentionally empty interval in the sequence of samples.
2170    ///
2171    /// The sample buffer's output presentation timestamp indicates when the empty interval begins.
2172    /// Marker sample buffers with this attachment are used to announce the arrival of empty edits.
2173    ///
2174    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_emptymedia?language=objc)
2175    pub static kCMSampleBufferAttachmentKey_EmptyMedia: &'static CFString;
2176}
2177
2178extern "C" {
2179    /// Marks the end of the sequence of samples.
2180    ///
2181    /// Marker sample buffers with this attachment in addition to kCMSampleBufferAttachmentKey_EmptyMedia
2182    /// are used to indicate that no further samples are expected.
2183    ///
2184    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_permanentemptymedia?language=objc)
2185    pub static kCMSampleBufferAttachmentKey_PermanentEmptyMedia: &'static CFString;
2186}
2187
2188extern "C" {
2189    /// Tells that the empty marker should be dequeued immediately regardless of its timestamp.
2190    ///
2191    /// Marker sample buffers with this attachment in addition to kCMSampleBufferAttachmentKey_EmptyMedia
2192    /// are used to tell that the empty sample buffer should be dequeued immediately regardless of its timestamp.
2193    /// This attachment should only be used with sample buffers with the kCMSampleBufferAttachmentKey_EmptyMedia
2194    /// attachment.
2195    ///
2196    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_displayemptymediaimmediately?language=objc)
2197    pub static kCMSampleBufferAttachmentKey_DisplayEmptyMediaImmediately: &'static CFString;
2198}
2199
2200extern "C" {
2201    /// Indicates that sample buffer's decode timestamp may be used to define the previous sample buffer's duration.
2202    ///
2203    /// Marker sample buffers with this attachment may be used in situations where sample buffers are transmitted
2204    /// before their duration is known. In such situations, normally the recipient may use each sample buffer's timestamp
2205    /// to calculate the duration of the previous sample buffer. The marker sample buffer with this attachment is sent
2206    /// to provide the timestamp for calculating the final sample buffer's duration.
2207    ///
2208    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_endsprevioussampleduration?language=objc)
2209    pub static kCMSampleBufferAttachmentKey_EndsPreviousSampleDuration: &'static CFString;
2210}
2211
2212extern "C" {
2213    /// Indicates the URL where the sample data is.
2214    ///
2215    /// This key is only used for CMSampleBuffers representing sample references.
2216    /// Such CMSampleBuffers:
2217    /// - have dataBuffer == NULL and imageBuffer == NULL
2218    /// - have dataReady == true and no makeDataReadyCallback
2219    /// - have a non-NULL formatDescription
2220    /// - have numSamples > 0
2221    /// - have numSampleTimingEntries > 0 and numSampleSizeEntries > 0
2222    ///
2223    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_samplereferenceurl?language=objc)
2224    pub static kCMSampleBufferAttachmentKey_SampleReferenceURL: &'static CFString;
2225}
2226
2227extern "C" {
2228    /// Indicates the byte offset at which the sample data begins.
2229    ///
2230    /// This key is only used for CMSampleBuffers representing sample references.
2231    /// Such CMSampleBuffers:
2232    /// - have dataBuffer == NULL and imageBuffer == NULL
2233    /// - have dataReady == true and no makeDataReadyCallback
2234    /// - have a non-NULL formatDescription
2235    /// - have numSamples > 0
2236    /// - have numSampleTimingEntries > 0 and numSampleSizeEntries > 0
2237    ///
2238    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_samplereferencebyteoffset?language=objc)
2239    pub static kCMSampleBufferAttachmentKey_SampleReferenceByteOffset: &'static CFString;
2240}
2241
2242extern "C" {
2243    /// Indicates the decoder refresh count.
2244    ///
2245    /// Sample buffers with this attachment may be used to identify the audio decoder refresh count.
2246    ///
2247    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_gradualdecoderrefresh?language=objc)
2248    pub static kCMSampleBufferAttachmentKey_GradualDecoderRefresh: &'static CFString;
2249}
2250
2251extern "C" {
2252    /// Indicates the reason the current video frame was dropped.
2253    ///
2254    /// Sample buffers with this attachment contain no image or data buffer.  They mark a dropped video
2255    /// frame.  This attachment identifies the reason for the droppage.
2256    ///
2257    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_droppedframereason?language=objc)
2258    pub static kCMSampleBufferAttachmentKey_DroppedFrameReason: &'static CFString;
2259}
2260
2261extern "C" {
2262    /// The frame was dropped because it was late
2263    ///
2264    /// The value of kCMSampleBufferAttachmentKey_DroppedFrameReason if a video capture client has indicated
2265    /// that late video frames should be dropped and the current frame is late.  This condition is typically
2266    /// caused by the client's processing taking too long.
2267    ///
2268    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferdroppedframereason_framewaslate?language=objc)
2269    pub static kCMSampleBufferDroppedFrameReason_FrameWasLate: &'static CFString;
2270}
2271
2272extern "C" {
2273    /// The frame was dropped because the module providing frames is out of buffers
2274    ///
2275    /// The value of kCMSampleBufferAttachmentKey_DroppedFrameReason if the module providing sample buffers
2276    /// has run out of source buffers.  This condition is typically caused by the client holding onto
2277    /// buffers for too long and can be alleviated by returning buffers to the provider.
2278    ///
2279    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferdroppedframereason_outofbuffers?language=objc)
2280    pub static kCMSampleBufferDroppedFrameReason_OutOfBuffers: &'static CFString;
2281}
2282
2283extern "C" {
2284    /// An unknown number of frames were dropped
2285    ///
2286    /// The value of kCMSampleBufferAttachmentKey_DroppedFrameReason if the module providing sample buffers
2287    /// has experienced a discontinuity, and an unknown number of frames have been lost.  This condition is
2288    /// typically caused by the system being too busy.
2289    ///
2290    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferdroppedframereason_discontinuity?language=objc)
2291    pub static kCMSampleBufferDroppedFrameReason_Discontinuity: &'static CFString;
2292}
2293
2294extern "C" {
2295    /// Indicates additional information regarding the dropped video frame.
2296    ///
2297    /// Sample buffers with this attachment contain no image or data buffer.  They mark a dropped video
2298    /// frame. If present, this attachment provides additional information about the kCMSampleBufferAttachmentKey_DroppedFrameReason.
2299    ///
2300    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_droppedframereasoninfo?language=objc)
2301    pub static kCMSampleBufferAttachmentKey_DroppedFrameReasonInfo: &'static CFString;
2302}
2303
2304extern "C" {
2305    /// A discontinuity was caused by a camera mode switch.
2306    ///
2307    /// The value of kCMSampleBufferAttachmentKey_DroppedFrameReasonInfo if the module providing sample buffers
2308    /// has experienced a discontinuity due to a camera mode switch. Short discontinuities of this type can occur when the
2309    /// session is configured for still image capture on some devices.
2310    ///
2311    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferdroppedframereasoninfo_cameramodeswitch?language=objc)
2312    pub static kCMSampleBufferDroppedFrameReasonInfo_CameraModeSwitch: &'static CFString;
2313}
2314
2315extern "C" {
2316    /// Indicates information about the lens stabilization applied to the current still image buffer.
2317    ///
2318    /// Sample buffers that have been captured with a lens stabilization module may have an attachment of
2319    /// kCMSampleBufferAttachmentKey_StillImageLensStabilizationInfo which has information about the stabilization status
2320    /// during the capture.  This key will not be present in CMSampleBuffers coming from cameras without a lens stabilization module.
2321    ///
2322    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_stillimagelensstabilizationinfo?language=objc)
2323    pub static kCMSampleBufferAttachmentKey_StillImageLensStabilizationInfo: &'static CFString;
2324}
2325
2326extern "C" {
2327    /// The lens stabilization module was active for the duration this buffer.
2328    ///
2329    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferlensstabilizationinfo_active?language=objc)
2330    pub static kCMSampleBufferLensStabilizationInfo_Active: &'static CFString;
2331}
2332
2333extern "C" {
2334    /// The motion of the device or duration of the capture was outside of what the stabilization mechanism could support.
2335    ///
2336    /// The value of kCMSampleBufferAttachmentKey_StillImageLensStabilizationInfo if the module stabilizing the lens was unable to
2337    /// compensate for the movement.
2338    ///
2339    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferlensstabilizationinfo_outofrange?language=objc)
2340    pub static kCMSampleBufferLensStabilizationInfo_OutOfRange: &'static CFString;
2341}
2342
2343extern "C" {
2344    /// The lens stabilization module was unavailable for use.
2345    ///
2346    /// The value of kCMSampleBufferAttachmentKey_StillImageLensStabilizationInfo if the lens stabilization module is unavailable
2347    /// to compensate for the motion of the device.  The module may be available at a later time.
2348    ///
2349    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferlensstabilizationinfo_unavailable?language=objc)
2350    pub static kCMSampleBufferLensStabilizationInfo_Unavailable: &'static CFString;
2351}
2352
2353extern "C" {
2354    /// The lens stabilization module was not used during this capture.
2355    ///
2356    /// The value of kCMSampleBufferAttachmentKey_StillImageLensStabilizationInfo if the lens stabilization module was not used for this capture.
2357    ///
2358    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferlensstabilizationinfo_off?language=objc)
2359    pub static kCMSampleBufferLensStabilizationInfo_Off: &'static CFString;
2360}
2361
2362extern "C" {
2363    /// Indicates the 3x3 camera intrinsic matrix applied to the current sample buffer.
2364    ///
2365    /// Camera intrinsic matrix is a CFData containing a matrix_float3x3, which is column-major. It has the following contents:
2366    /// fx    0    ox
2367    /// 0    fy    oy
2368    /// 0    0    1
2369    /// fx and fy are the focal length in pixels. For square pixels, they will have the same value.
2370    /// ox and oy are the coordinates of the principal point. The origin is the upper left of the frame.
2371    ///
2372    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_cameraintrinsicmatrix?language=objc)
2373    pub static kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix: &'static CFString;
2374}
2375
2376extern "C" {
2377    /// Indicates that the current or next video sample buffer should be forced to be encoded as a key frame.
2378    ///
2379    /// A value of kCFBooleanTrue for kCMSampleBufferAttachmentKey_ForceKeyFrame indicates that the current or next video sample buffer processed in the stream should be forced to be encoded as a key frame.
2380    /// If this attachment is present and kCFBooleanTrue on a sample buffer with a video frame, that video frame will be forced to become a key frame.  If the sample buffer for which this is present and kCFBooleanTrue does not have a valid video frame, the next sample buffer processed that contains a valid video frame will be encoded as a key frame.
2381    ///
2382    /// Usual care should be taken when setting attachments on sample buffers whose orgins and destinations are ambiguous.  For example, CMSetAttachment() is not thread-safe, and CMSampleBuffers may be used in multiple sample buffer streams in a given system.  This can lead to crashes during concurrent access and/or unexpected behavior on alternate sample buffer streams.  Therefore, unless the orgin and destination of a sample buffer is known, the general recommended practice is to synthesize an empty sample buffer with this attachment alone and insert it into the sample buffer stream ahead of the concrete sample buffer rather than setting this attachment on the concrete sample buffer itself.
2383    ///
2384    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsamplebufferattachmentkey_forcekeyframe?language=objc)
2385    pub static kCMSampleBufferAttachmentKey_ForceKeyFrame: &'static CFString;
2386}
2387
2388extern "C" {
2389    /// Describes the ranges of protected and unprotected data within a protected CMSampleBuffer
2390    ///
2391    /// The attachment is CFData containing one or more "BytesOfClearData"/"BytesOfProtectedData" pairs as appears in the 'senc' box (see ISO/IEC 23001-7 section 7.2.2). The "BytesOfClearData” and the "BytesOfProtectedData” fields are 32-bit integers. Both are native endian in the CFData. This attachment is not present if the CMSampleBuffer contains unprotected content.
2392    ///
2393    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_cryptorsubsampleauxiliarydata?language=objc)
2394    pub static kCMSampleAttachmentKey_CryptorSubsampleAuxiliaryData: &'static CFString;
2395}
2396
2397extern "C" {
2398    /// HDR10+ per frame metadata
2399    ///
2400    /// The attachment is CFData containing HDR10+ metadata within an User Data Registered ITU-T T-35 SEI message (see ISO/IEC 23008-2-2020 section D.3.6) as little endian in the CFData. This attachment will override any HDR10+ metadata stored within the compressed data. The data shall start with the field itu_t_t35_country_code with the value 0xb5.
2401    ///
2402    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_hdr10plusperframedata?language=objc)
2403    pub static kCMSampleAttachmentKey_HDR10PlusPerFrameData: &'static CFString;
2404}
2405
2406extern "C" {
2407    /// Represents the sequence and frame level metadata for post decode processing.
2408    ///
2409    /// This attachment is used to pass sequence and frame level metadata from a format reader to a decoder or RAW processor. It should be a CFDictionary that conforms to CFPropertyList.
2410    ///
2411    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremedia/kcmsampleattachmentkey_postdecodeprocessingmetadata?language=objc)
2412    pub static kCMSampleAttachmentKey_PostDecodeProcessingMetadata: &'static CFString;
2413}
2414
2415impl CMSampleBuffer {
2416    /// Calls a function for every individual sample in a sample buffer.
2417    ///
2418    /// Temporary sample buffers will be created for individual samples,
2419    /// referring to the sample data and containing its timing, size and attachments.
2420    /// The callback function may retain these sample buffers if desired.
2421    /// If the callback function returns an error, iteration will stop immediately
2422    /// and the error will be returned.
2423    /// If there are no sample sizes in the provided sample buffer, kCMSampleBufferError_CannotSubdivide will be returned.
2424    /// This will happen, for example, if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where
2425    /// the channel values for a single sample are scattered through the buffer).
2426    ///
2427    /// # Safety
2428    ///
2429    /// - `callback` must be implemented correctly.
2430    /// - `refcon` must be a valid pointer or null.
2431    #[doc(alias = "CMSampleBufferCallForEachSample")]
2432    #[cfg(feature = "CMBase")]
2433    #[inline]
2434    pub unsafe fn call_for_each_sample(
2435        &self,
2436        callback: unsafe extern "C-unwind" fn(
2437            NonNull<CMSampleBuffer>,
2438            CMItemCount,
2439            *mut c_void,
2440        ) -> OSStatus,
2441        refcon: *mut c_void,
2442    ) -> OSStatus {
2443        extern "C-unwind" {
2444            fn CMSampleBufferCallForEachSample(
2445                sbuf: &CMSampleBuffer,
2446                callback: unsafe extern "C-unwind" fn(
2447                    NonNull<CMSampleBuffer>,
2448                    CMItemCount,
2449                    *mut c_void,
2450                ) -> OSStatus,
2451                refcon: *mut c_void,
2452            ) -> OSStatus;
2453        }
2454        unsafe { CMSampleBufferCallForEachSample(self, callback, refcon) }
2455    }
2456
2457    /// Calls a block for every individual sample in a sample buffer.
2458    ///
2459    /// Temporary sample buffers will be created for individual samples,
2460    /// referring to the sample data and containing its timing, size and attachments.
2461    /// The block may retain these sample buffers if desired.
2462    /// If the block returns an error, iteration will stop immediately
2463    /// and the error will be returned.
2464    /// If there are no sample sizes in the provided sample buffer, kCMSampleBufferError_CannotSubdivide will be returned.
2465    /// This will happen, for example, if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where
2466    /// the channel values for a single sample are scattered through the buffer).
2467    #[doc(alias = "CMSampleBufferCallBlockForEachSample")]
2468    #[cfg(all(feature = "CMBase", feature = "block2"))]
2469    #[inline]
2470    pub unsafe fn call_block_for_each_sample(
2471        &self,
2472        handler: &block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>, CMItemCount) -> OSStatus>,
2473    ) -> OSStatus {
2474        extern "C-unwind" {
2475            fn CMSampleBufferCallBlockForEachSample(
2476                sbuf: &CMSampleBuffer,
2477                handler: &block2::DynBlock<
2478                    dyn Fn(NonNull<CMSampleBuffer>, CMItemCount) -> OSStatus,
2479                >,
2480            ) -> OSStatus;
2481        }
2482        unsafe { CMSampleBufferCallBlockForEachSample(self, handler) }
2483    }
2484}
2485
2486#[cfg(all(
2487    feature = "CMBase",
2488    feature = "CMBlockBuffer",
2489    feature = "CMFormatDescription",
2490    feature = "CMTime"
2491))]
2492#[deprecated = "renamed to `CMSampleBuffer::create`"]
2493#[inline]
2494pub unsafe extern "C-unwind" fn CMSampleBufferCreate(
2495    allocator: Option<&CFAllocator>,
2496    data_buffer: Option<&CMBlockBuffer>,
2497    data_ready: bool,
2498    make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
2499    make_data_ready_refcon: *mut c_void,
2500    format_description: Option<&CMFormatDescription>,
2501    num_samples: CMItemCount,
2502    num_sample_timing_entries: CMItemCount,
2503    sample_timing_array: *const CMSampleTimingInfo,
2504    num_sample_size_entries: CMItemCount,
2505    sample_size_array: *const usize,
2506    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2507) -> OSStatus {
2508    extern "C-unwind" {
2509        fn CMSampleBufferCreate(
2510            allocator: Option<&CFAllocator>,
2511            data_buffer: Option<&CMBlockBuffer>,
2512            data_ready: Boolean,
2513            make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
2514            make_data_ready_refcon: *mut c_void,
2515            format_description: Option<&CMFormatDescription>,
2516            num_samples: CMItemCount,
2517            num_sample_timing_entries: CMItemCount,
2518            sample_timing_array: *const CMSampleTimingInfo,
2519            num_sample_size_entries: CMItemCount,
2520            sample_size_array: *const usize,
2521            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2522        ) -> OSStatus;
2523    }
2524    unsafe {
2525        CMSampleBufferCreate(
2526            allocator,
2527            data_buffer,
2528            data_ready as _,
2529            make_data_ready_callback,
2530            make_data_ready_refcon,
2531            format_description,
2532            num_samples,
2533            num_sample_timing_entries,
2534            sample_timing_array,
2535            num_sample_size_entries,
2536            sample_size_array,
2537            sample_buffer_out,
2538        )
2539    }
2540}
2541
2542#[cfg(all(
2543    feature = "CMBase",
2544    feature = "CMBlockBuffer",
2545    feature = "CMFormatDescription",
2546    feature = "CMTime",
2547    feature = "block2"
2548))]
2549#[deprecated = "renamed to `CMSampleBuffer::create_with_make_data_ready_handler`"]
2550#[inline]
2551pub unsafe extern "C-unwind" fn CMSampleBufferCreateWithMakeDataReadyHandler(
2552    allocator: Option<&CFAllocator>,
2553    data_buffer: Option<&CMBlockBuffer>,
2554    data_ready: bool,
2555    format_description: Option<&CMFormatDescription>,
2556    num_samples: CMItemCount,
2557    num_sample_timing_entries: CMItemCount,
2558    sample_timing_array: *const CMSampleTimingInfo,
2559    num_sample_size_entries: CMItemCount,
2560    sample_size_array: *const usize,
2561    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2562    make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
2563) -> OSStatus {
2564    extern "C-unwind" {
2565        fn CMSampleBufferCreateWithMakeDataReadyHandler(
2566            allocator: Option<&CFAllocator>,
2567            data_buffer: Option<&CMBlockBuffer>,
2568            data_ready: Boolean,
2569            format_description: Option<&CMFormatDescription>,
2570            num_samples: CMItemCount,
2571            num_sample_timing_entries: CMItemCount,
2572            sample_timing_array: *const CMSampleTimingInfo,
2573            num_sample_size_entries: CMItemCount,
2574            sample_size_array: *const usize,
2575            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2576            make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
2577        ) -> OSStatus;
2578    }
2579    unsafe {
2580        CMSampleBufferCreateWithMakeDataReadyHandler(
2581            allocator,
2582            data_buffer,
2583            data_ready as _,
2584            format_description,
2585            num_samples,
2586            num_sample_timing_entries,
2587            sample_timing_array,
2588            num_sample_size_entries,
2589            sample_size_array,
2590            sample_buffer_out,
2591            make_data_ready_handler,
2592        )
2593    }
2594}
2595
2596extern "C-unwind" {
2597    #[cfg(all(
2598        feature = "CMBase",
2599        feature = "CMBlockBuffer",
2600        feature = "CMFormatDescription",
2601        feature = "CMTime"
2602    ))]
2603    #[deprecated = "renamed to `CMSampleBuffer::create_ready`"]
2604    pub fn CMSampleBufferCreateReady(
2605        allocator: Option<&CFAllocator>,
2606        data_buffer: Option<&CMBlockBuffer>,
2607        format_description: Option<&CMFormatDescription>,
2608        num_samples: CMItemCount,
2609        num_sample_timing_entries: CMItemCount,
2610        sample_timing_array: *const CMSampleTimingInfo,
2611        num_sample_size_entries: CMItemCount,
2612        sample_size_array: *const usize,
2613        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2614    ) -> OSStatus;
2615}
2616
2617#[cfg(all(
2618    feature = "CMFormatDescription",
2619    feature = "CMTime",
2620    feature = "objc2-core-video"
2621))]
2622#[deprecated = "renamed to `CMSampleBuffer::create_for_image_buffer`"]
2623#[inline]
2624pub unsafe extern "C-unwind" fn CMSampleBufferCreateForImageBuffer(
2625    allocator: Option<&CFAllocator>,
2626    image_buffer: &CVImageBuffer,
2627    data_ready: bool,
2628    make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
2629    make_data_ready_refcon: *mut c_void,
2630    format_description: &CMVideoFormatDescription,
2631    sample_timing: NonNull<CMSampleTimingInfo>,
2632    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2633) -> OSStatus {
2634    extern "C-unwind" {
2635        fn CMSampleBufferCreateForImageBuffer(
2636            allocator: Option<&CFAllocator>,
2637            image_buffer: &CVImageBuffer,
2638            data_ready: Boolean,
2639            make_data_ready_callback: CMSampleBufferMakeDataReadyCallback,
2640            make_data_ready_refcon: *mut c_void,
2641            format_description: &CMVideoFormatDescription,
2642            sample_timing: NonNull<CMSampleTimingInfo>,
2643            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2644        ) -> OSStatus;
2645    }
2646    unsafe {
2647        CMSampleBufferCreateForImageBuffer(
2648            allocator,
2649            image_buffer,
2650            data_ready as _,
2651            make_data_ready_callback,
2652            make_data_ready_refcon,
2653            format_description,
2654            sample_timing,
2655            sample_buffer_out,
2656        )
2657    }
2658}
2659
2660#[cfg(all(
2661    feature = "CMFormatDescription",
2662    feature = "CMTime",
2663    feature = "block2",
2664    feature = "objc2-core-video"
2665))]
2666#[deprecated = "renamed to `CMSampleBuffer::create_for_image_buffer_with_make_data_ready_handler`"]
2667#[inline]
2668pub unsafe extern "C-unwind" fn CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(
2669    allocator: Option<&CFAllocator>,
2670    image_buffer: &CVImageBuffer,
2671    data_ready: bool,
2672    format_description: &CMVideoFormatDescription,
2673    sample_timing: NonNull<CMSampleTimingInfo>,
2674    sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2675    make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
2676) -> OSStatus {
2677    extern "C-unwind" {
2678        fn CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(
2679            allocator: Option<&CFAllocator>,
2680            image_buffer: &CVImageBuffer,
2681            data_ready: Boolean,
2682            format_description: &CMVideoFormatDescription,
2683            sample_timing: NonNull<CMSampleTimingInfo>,
2684            sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2685            make_data_ready_handler: CMSampleBufferMakeDataReadyHandler,
2686        ) -> OSStatus;
2687    }
2688    unsafe {
2689        CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(
2690            allocator,
2691            image_buffer,
2692            data_ready as _,
2693            format_description,
2694            sample_timing,
2695            sample_buffer_out,
2696            make_data_ready_handler,
2697        )
2698    }
2699}
2700
2701extern "C-unwind" {
2702    #[cfg(all(
2703        feature = "CMFormatDescription",
2704        feature = "CMTime",
2705        feature = "objc2-core-video"
2706    ))]
2707    #[deprecated = "renamed to `CMSampleBuffer::create_ready_with_image_buffer`"]
2708    pub fn CMSampleBufferCreateReadyWithImageBuffer(
2709        allocator: Option<&CFAllocator>,
2710        image_buffer: &CVImageBuffer,
2711        format_description: &CMVideoFormatDescription,
2712        sample_timing: NonNull<CMSampleTimingInfo>,
2713        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2714    ) -> OSStatus;
2715}
2716
2717extern "C-unwind" {
2718    #[deprecated = "renamed to `CMSampleBuffer::create_copy`"]
2719    pub fn CMSampleBufferCreateCopy(
2720        allocator: Option<&CFAllocator>,
2721        sbuf: &CMSampleBuffer,
2722        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2723    ) -> OSStatus;
2724}
2725
2726extern "C-unwind" {
2727    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
2728    #[deprecated = "renamed to `CMSampleBuffer::create_copy_with_new_timing`"]
2729    pub fn CMSampleBufferCreateCopyWithNewTiming(
2730        allocator: Option<&CFAllocator>,
2731        original_s_buf: &CMSampleBuffer,
2732        num_sample_timing_entries: CMItemCount,
2733        sample_timing_array: *const CMSampleTimingInfo,
2734        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2735    ) -> OSStatus;
2736}
2737
2738extern "C-unwind" {
2739    #[deprecated = "renamed to `CMSampleBuffer::copy_sample_buffer_for_range`"]
2740    pub fn CMSampleBufferCopySampleBufferForRange(
2741        allocator: Option<&CFAllocator>,
2742        sbuf: &CMSampleBuffer,
2743        sample_range: CFRange,
2744        sample_buffer_out: NonNull<*mut CMSampleBuffer>,
2745    ) -> OSStatus;
2746}
2747
2748extern "C-unwind" {
2749    #[cfg(feature = "CMBlockBuffer")]
2750    #[deprecated = "renamed to `CMSampleBuffer::set_data_buffer`"]
2751    pub fn CMSampleBufferSetDataBuffer(
2752        sbuf: &CMSampleBuffer,
2753        data_buffer: &CMBlockBuffer,
2754    ) -> OSStatus;
2755}
2756
2757#[cfg(feature = "CMBlockBuffer")]
2758#[deprecated = "renamed to `CMSampleBuffer::data_buffer`"]
2759#[inline]
2760pub unsafe extern "C-unwind" fn CMSampleBufferGetDataBuffer(
2761    sbuf: &CMSampleBuffer,
2762) -> Option<CFRetained<CMBlockBuffer>> {
2763    extern "C-unwind" {
2764        fn CMSampleBufferGetDataBuffer(sbuf: &CMSampleBuffer) -> Option<NonNull<CMBlockBuffer>>;
2765    }
2766    let ret = unsafe { CMSampleBufferGetDataBuffer(sbuf) };
2767    ret.map(|ret| unsafe { CFRetained::retain(ret) })
2768}
2769
2770#[cfg(feature = "objc2-core-video")]
2771#[deprecated = "renamed to `CMSampleBuffer::image_buffer`"]
2772#[inline]
2773pub unsafe extern "C-unwind" fn CMSampleBufferGetImageBuffer(
2774    sbuf: &CMSampleBuffer,
2775) -> Option<CFRetained<CVImageBuffer>> {
2776    extern "C-unwind" {
2777        fn CMSampleBufferGetImageBuffer(sbuf: &CMSampleBuffer) -> Option<NonNull<CVImageBuffer>>;
2778    }
2779    let ret = unsafe { CMSampleBufferGetImageBuffer(sbuf) };
2780    ret.map(|ret| unsafe { CFRetained::retain(ret) })
2781}
2782
2783extern "C-unwind" {
2784    #[cfg(feature = "objc2-core-audio-types")]
2785    #[deprecated = "renamed to `CMSampleBuffer::set_data_buffer_from_audio_buffer_list`"]
2786    pub fn CMSampleBufferSetDataBufferFromAudioBufferList(
2787        sbuf: &CMSampleBuffer,
2788        block_buffer_structure_allocator: Option<&CFAllocator>,
2789        block_buffer_block_allocator: Option<&CFAllocator>,
2790        flags: u32,
2791        buffer_list: NonNull<AudioBufferList>,
2792    ) -> OSStatus;
2793}
2794
2795extern "C-unwind" {
2796    #[cfg(all(feature = "CMBlockBuffer", feature = "objc2-core-audio-types"))]
2797    #[deprecated = "renamed to `CMSampleBuffer::audio_buffer_list_with_retained_block_buffer`"]
2798    pub fn CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
2799        sbuf: &CMSampleBuffer,
2800        buffer_list_size_needed_out: *mut usize,
2801        buffer_list_out: *mut AudioBufferList,
2802        buffer_list_size: usize,
2803        block_buffer_structure_allocator: Option<&CFAllocator>,
2804        block_buffer_block_allocator: Option<&CFAllocator>,
2805        flags: u32,
2806        block_buffer_out: *mut *mut CMBlockBuffer,
2807    ) -> OSStatus;
2808}
2809
2810extern "C-unwind" {
2811    #[cfg(feature = "objc2-core-audio-types")]
2812    #[deprecated = "renamed to `CMSampleBuffer::audio_stream_packet_descriptions`"]
2813    pub fn CMSampleBufferGetAudioStreamPacketDescriptions(
2814        sbuf: &CMSampleBuffer,
2815        packet_descriptions_size: usize,
2816        packet_descriptions_out: *mut AudioStreamPacketDescription,
2817        packet_descriptions_size_needed_out: *mut usize,
2818    ) -> OSStatus;
2819}
2820
2821extern "C-unwind" {
2822    #[cfg(feature = "objc2-core-audio-types")]
2823    #[deprecated = "renamed to `CMSampleBuffer::audio_stream_packet_descriptions_ptr`"]
2824    pub fn CMSampleBufferGetAudioStreamPacketDescriptionsPtr(
2825        sbuf: &CMSampleBuffer,
2826        packet_descriptions_pointer_out: *mut *const AudioStreamPacketDescription,
2827        packet_descriptions_size_out: *mut usize,
2828    ) -> OSStatus;
2829}
2830
2831extern "C-unwind" {
2832    #[cfg(feature = "objc2-core-audio-types")]
2833    #[deprecated = "renamed to `CMSampleBuffer::copy_pcm_data_into_audio_buffer_list`"]
2834    pub fn CMSampleBufferCopyPCMDataIntoAudioBufferList(
2835        sbuf: &CMSampleBuffer,
2836        frame_offset: i32,
2837        num_frames: i32,
2838        buffer_list: NonNull<AudioBufferList>,
2839    ) -> OSStatus;
2840}
2841
2842extern "C-unwind" {
2843    #[deprecated = "renamed to `CMSampleBuffer::set_data_ready`"]
2844    pub fn CMSampleBufferSetDataReady(sbuf: &CMSampleBuffer) -> OSStatus;
2845}
2846
2847#[deprecated = "renamed to `CMSampleBuffer::data_is_ready`"]
2848#[inline]
2849pub unsafe extern "C-unwind" fn CMSampleBufferDataIsReady(sbuf: &CMSampleBuffer) -> bool {
2850    extern "C-unwind" {
2851        fn CMSampleBufferDataIsReady(sbuf: &CMSampleBuffer) -> Boolean;
2852    }
2853    let ret = unsafe { CMSampleBufferDataIsReady(sbuf) };
2854    ret != 0
2855}
2856
2857extern "C-unwind" {
2858    #[deprecated = "renamed to `CMSampleBuffer::set_data_failed`"]
2859    pub fn CMSampleBufferSetDataFailed(sbuf: &CMSampleBuffer, status: OSStatus) -> OSStatus;
2860}
2861
2862#[deprecated = "renamed to `CMSampleBuffer::has_data_failed`"]
2863#[inline]
2864pub unsafe extern "C-unwind" fn CMSampleBufferHasDataFailed(
2865    sbuf: &CMSampleBuffer,
2866    status_out: *mut OSStatus,
2867) -> bool {
2868    extern "C-unwind" {
2869        fn CMSampleBufferHasDataFailed(sbuf: &CMSampleBuffer, status_out: *mut OSStatus)
2870            -> Boolean;
2871    }
2872    let ret = unsafe { CMSampleBufferHasDataFailed(sbuf, status_out) };
2873    ret != 0
2874}
2875
2876extern "C-unwind" {
2877    #[deprecated = "renamed to `CMSampleBuffer::make_data_ready`"]
2878    pub fn CMSampleBufferMakeDataReady(sbuf: &CMSampleBuffer) -> OSStatus;
2879}
2880
2881extern "C-unwind" {
2882    #[deprecated = "renamed to `CMSampleBuffer::track_data_readiness`"]
2883    pub fn CMSampleBufferTrackDataReadiness(
2884        sbuf: &CMSampleBuffer,
2885        sample_buffer_to_track: &CMSampleBuffer,
2886    ) -> OSStatus;
2887}
2888
2889extern "C-unwind" {
2890    #[deprecated = "renamed to `CMSampleBuffer::invalidate`"]
2891    pub fn CMSampleBufferInvalidate(sbuf: &CMSampleBuffer) -> OSStatus;
2892}
2893
2894extern "C-unwind" {
2895    #[deprecated = "renamed to `CMSampleBuffer::set_invalidate_callback`"]
2896    pub fn CMSampleBufferSetInvalidateCallback(
2897        sbuf: &CMSampleBuffer,
2898        invalidate_callback: CMSampleBufferInvalidateCallback,
2899        invalidate_ref_con: u64,
2900    ) -> OSStatus;
2901}
2902
2903extern "C-unwind" {
2904    #[cfg(feature = "block2")]
2905    #[deprecated = "renamed to `CMSampleBuffer::set_invalidate_handler`"]
2906    pub fn CMSampleBufferSetInvalidateHandler(
2907        sbuf: &CMSampleBuffer,
2908        invalidate_handler: CMSampleBufferInvalidateHandler,
2909    ) -> OSStatus;
2910}
2911
2912#[deprecated = "renamed to `CMSampleBuffer::is_valid`"]
2913#[inline]
2914pub unsafe extern "C-unwind" fn CMSampleBufferIsValid(sbuf: &CMSampleBuffer) -> bool {
2915    extern "C-unwind" {
2916        fn CMSampleBufferIsValid(sbuf: &CMSampleBuffer) -> Boolean;
2917    }
2918    let ret = unsafe { CMSampleBufferIsValid(sbuf) };
2919    ret != 0
2920}
2921
2922extern "C-unwind" {
2923    #[cfg(feature = "CMBase")]
2924    #[deprecated = "renamed to `CMSampleBuffer::num_samples`"]
2925    pub fn CMSampleBufferGetNumSamples(sbuf: &CMSampleBuffer) -> CMItemCount;
2926}
2927
2928extern "C-unwind" {
2929    #[cfg(feature = "CMTime")]
2930    #[deprecated = "renamed to `CMSampleBuffer::duration`"]
2931    pub fn CMSampleBufferGetDuration(sbuf: &CMSampleBuffer) -> CMTime;
2932}
2933
2934extern "C-unwind" {
2935    #[cfg(feature = "CMTime")]
2936    #[deprecated = "renamed to `CMSampleBuffer::presentation_time_stamp`"]
2937    pub fn CMSampleBufferGetPresentationTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
2938}
2939
2940extern "C-unwind" {
2941    #[cfg(feature = "CMTime")]
2942    #[deprecated = "renamed to `CMSampleBuffer::decode_time_stamp`"]
2943    pub fn CMSampleBufferGetDecodeTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
2944}
2945
2946extern "C-unwind" {
2947    #[cfg(feature = "CMTime")]
2948    #[deprecated = "renamed to `CMSampleBuffer::output_duration`"]
2949    pub fn CMSampleBufferGetOutputDuration(sbuf: &CMSampleBuffer) -> CMTime;
2950}
2951
2952extern "C-unwind" {
2953    #[cfg(feature = "CMTime")]
2954    #[deprecated = "renamed to `CMSampleBuffer::output_presentation_time_stamp`"]
2955    pub fn CMSampleBufferGetOutputPresentationTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
2956}
2957
2958extern "C-unwind" {
2959    #[cfg(feature = "CMTime")]
2960    #[deprecated = "renamed to `CMSampleBuffer::set_output_presentation_time_stamp`"]
2961    pub fn CMSampleBufferSetOutputPresentationTimeStamp(
2962        sbuf: &CMSampleBuffer,
2963        output_presentation_time_stamp: CMTime,
2964    ) -> OSStatus;
2965}
2966
2967extern "C-unwind" {
2968    #[cfg(feature = "CMTime")]
2969    #[deprecated = "renamed to `CMSampleBuffer::output_decode_time_stamp`"]
2970    pub fn CMSampleBufferGetOutputDecodeTimeStamp(sbuf: &CMSampleBuffer) -> CMTime;
2971}
2972
2973extern "C-unwind" {
2974    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
2975    #[deprecated = "renamed to `CMSampleBuffer::sample_timing_info_array`"]
2976    pub fn CMSampleBufferGetSampleTimingInfoArray(
2977        sbuf: &CMSampleBuffer,
2978        num_sample_timing_entries: CMItemCount,
2979        timing_array_out: *mut CMSampleTimingInfo,
2980        timing_array_entries_needed_out: *mut CMItemCount,
2981    ) -> OSStatus;
2982}
2983
2984extern "C-unwind" {
2985    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
2986    #[deprecated = "renamed to `CMSampleBuffer::output_sample_timing_info_array`"]
2987    pub fn CMSampleBufferGetOutputSampleTimingInfoArray(
2988        sbuf: &CMSampleBuffer,
2989        timing_array_entries: CMItemCount,
2990        timing_array_out: *mut CMSampleTimingInfo,
2991        timing_array_entries_needed_out: *mut CMItemCount,
2992    ) -> OSStatus;
2993}
2994
2995extern "C-unwind" {
2996    #[cfg(all(feature = "CMBase", feature = "CMTime"))]
2997    #[deprecated = "renamed to `CMSampleBuffer::sample_timing_info`"]
2998    pub fn CMSampleBufferGetSampleTimingInfo(
2999        sbuf: &CMSampleBuffer,
3000        sample_index: CMItemIndex,
3001        timing_info_out: NonNull<CMSampleTimingInfo>,
3002    ) -> OSStatus;
3003}
3004
3005extern "C-unwind" {
3006    #[cfg(feature = "CMBase")]
3007    #[deprecated = "renamed to `CMSampleBuffer::sample_size_array`"]
3008    pub fn CMSampleBufferGetSampleSizeArray(
3009        sbuf: &CMSampleBuffer,
3010        size_array_entries: CMItemCount,
3011        size_array_out: *mut usize,
3012        size_array_entries_needed_out: *mut CMItemCount,
3013    ) -> OSStatus;
3014}
3015
3016extern "C-unwind" {
3017    #[cfg(feature = "CMBase")]
3018    #[deprecated = "renamed to `CMSampleBuffer::sample_size`"]
3019    pub fn CMSampleBufferGetSampleSize(sbuf: &CMSampleBuffer, sample_index: CMItemIndex) -> usize;
3020}
3021
3022extern "C-unwind" {
3023    #[deprecated = "renamed to `CMSampleBuffer::total_sample_size`"]
3024    pub fn CMSampleBufferGetTotalSampleSize(sbuf: &CMSampleBuffer) -> usize;
3025}
3026
3027#[cfg(feature = "CMFormatDescription")]
3028#[deprecated = "renamed to `CMSampleBuffer::format_description`"]
3029#[inline]
3030pub unsafe extern "C-unwind" fn CMSampleBufferGetFormatDescription(
3031    sbuf: &CMSampleBuffer,
3032) -> Option<CFRetained<CMFormatDescription>> {
3033    extern "C-unwind" {
3034        fn CMSampleBufferGetFormatDescription(
3035            sbuf: &CMSampleBuffer,
3036        ) -> Option<NonNull<CMFormatDescription>>;
3037    }
3038    let ret = unsafe { CMSampleBufferGetFormatDescription(sbuf) };
3039    ret.map(|ret| unsafe { CFRetained::retain(ret) })
3040}
3041
3042#[deprecated = "renamed to `CMSampleBuffer::sample_attachments_array`"]
3043#[inline]
3044pub unsafe extern "C-unwind" fn CMSampleBufferGetSampleAttachmentsArray(
3045    sbuf: &CMSampleBuffer,
3046    create_if_necessary: bool,
3047) -> Option<CFRetained<CFArray>> {
3048    extern "C-unwind" {
3049        fn CMSampleBufferGetSampleAttachmentsArray(
3050            sbuf: &CMSampleBuffer,
3051            create_if_necessary: Boolean,
3052        ) -> Option<NonNull<CFArray>>;
3053    }
3054    let ret = unsafe { CMSampleBufferGetSampleAttachmentsArray(sbuf, create_if_necessary as _) };
3055    ret.map(|ret| unsafe { CFRetained::retain(ret) })
3056}
3057
3058extern "C-unwind" {
3059    #[cfg(feature = "CMBase")]
3060    #[deprecated = "renamed to `CMSampleBuffer::call_for_each_sample`"]
3061    pub fn CMSampleBufferCallForEachSample(
3062        sbuf: &CMSampleBuffer,
3063        callback: unsafe extern "C-unwind" fn(
3064            NonNull<CMSampleBuffer>,
3065            CMItemCount,
3066            *mut c_void,
3067        ) -> OSStatus,
3068        refcon: *mut c_void,
3069    ) -> OSStatus;
3070}
3071
3072extern "C-unwind" {
3073    #[cfg(all(feature = "CMBase", feature = "block2"))]
3074    #[deprecated = "renamed to `CMSampleBuffer::call_block_for_each_sample`"]
3075    pub fn CMSampleBufferCallBlockForEachSample(
3076        sbuf: &CMSampleBuffer,
3077        handler: &block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>, CMItemCount) -> OSStatus>,
3078    ) -> OSStatus;
3079}