objc2_media_extension/generated/
MEFormatReader.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-av-foundation")]
7use objc2_av_foundation::*;
8#[cfg(feature = "objc2-core-foundation")]
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12use objc2_foundation::*;
13#[cfg(feature = "objc2-uniform-type-identifiers")]
14use objc2_uniform_type_identifiers::*;
15
16use crate::*;
17
18/// Describes whether a file supports or contains fragments. For QuickTime movie and ISO files, it indicates the presence of an 'mvex' box, which is necessary in order to signal the possible presence of later 'moof' boxes.
19///
20/// The file is not capable of being extended by fragments.
21///
22/// The file is capable of being extended by fragments *and* contains at least one fragment.
23///
24/// The file is capable of being extended by fragments, but does not contain any fragments.
25///
26/// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mefileinfofragmentsstatus?language=objc)
27// NS_ENUM
28#[repr(transparent)]
29#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
30pub struct MEFileInfoFragmentsStatus(pub NSInteger);
31impl MEFileInfoFragmentsStatus {
32    #[doc(alias = "MEFileInfoCouldNotContainFragments")]
33    pub const CouldNotContainFragments: Self = Self(0);
34    #[doc(alias = "MEFileInfoContainsFragments")]
35    pub const ContainsFragments: Self = Self(1);
36    #[doc(alias = "MEFileInfoCouldContainButDoesNotContainFragments")]
37    pub const CouldContainButDoesNotContainFragments: Self = Self(2);
38}
39
40unsafe impl Encode for MEFileInfoFragmentsStatus {
41    const ENCODING: Encoding = NSInteger::ENCODING;
42}
43
44unsafe impl RefEncode for MEFileInfoFragmentsStatus {
45    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
46}
47
48/// Informational status flags returned by parseAdditionalFragmentsWithCompletionHandler.
49///
50/// A combination of these values may be returned in the statusOut field from parseAdditionalFragmentsWithCompletionHandler.
51///
52/// Set if the size of the file increased.
53///
54/// Set if one or more fragments were added.
55///
56/// Set if no more fragments can be added. Further calls to parseAdditionalFragmentsWithCompletionHandler will return an error.
57///
58/// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/meformatreaderparseadditionalfragmentsstatus?language=objc)
59// NS_OPTIONS
60#[repr(transparent)]
61#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
62pub struct MEFormatReaderParseAdditionalFragmentsStatus(pub NSUInteger);
63bitflags::bitflags! {
64    impl MEFormatReaderParseAdditionalFragmentsStatus: NSUInteger {
65        #[doc(alias = "MEFormatReaderParseAdditionalFragmentsStatusSizeIncreased")]
66        const SizeIncreased = 1<<0;
67        #[doc(alias = "MEFormatReaderParseAdditionalFragmentsStatusFragmentAdded")]
68        const FragmentAdded = 1<<1;
69        #[doc(alias = "MEFormatReaderParseAdditionalFragmentsStatusFragmentsComplete")]
70        const FragmentsComplete = 1<<2;
71    }
72}
73
74unsafe impl Encode for MEFormatReaderParseAdditionalFragmentsStatus {
75    const ENCODING: Encoding = NSUInteger::ENCODING;
76}
77
78unsafe impl RefEncode for MEFormatReaderParseAdditionalFragmentsStatus {
79    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
80}
81
82extern_class!(
83    /// A class that encapsulates options to be passed to MEFormatReaderExtension
84    ///
85    /// The class MEFormatReaderInstantiationOptions is mutable, with options set through instance properties.
86    ///
87    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/meformatreaderinstantiationoptions?language=objc)
88    #[unsafe(super(NSObject))]
89    #[derive(Debug, PartialEq, Eq, Hash)]
90    pub struct MEFormatReaderInstantiationOptions;
91);
92
93unsafe impl Send for MEFormatReaderInstantiationOptions {}
94
95unsafe impl Sync for MEFormatReaderInstantiationOptions {}
96
97extern_conformance!(
98    unsafe impl NSCopying for MEFormatReaderInstantiationOptions {}
99);
100
101unsafe impl CopyingHelper for MEFormatReaderInstantiationOptions {
102    type Result = Self;
103}
104
105extern_conformance!(
106    unsafe impl NSObjectProtocol for MEFormatReaderInstantiationOptions {}
107);
108
109impl MEFormatReaderInstantiationOptions {
110    extern_methods!(
111        /// Enables support for parsing additional fragments
112        ///
113        /// If YES, requests that the MEFormatReader be configured to support calls to parseAdditionalFragments. By default the MEFormatReader does not support calls to parseAdditionalFragments.
114        ///
115        /// This property is not atomic.
116        ///
117        /// # Safety
118        ///
119        /// This might not be thread-safe.
120        #[unsafe(method(allowIncrementalFragmentParsing))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn allowIncrementalFragmentParsing(&self) -> bool;
123    );
124}
125
126/// Methods declared on superclass `NSObject`.
127impl MEFormatReaderInstantiationOptions {
128    extern_methods!(
129        #[unsafe(method(init))]
130        #[unsafe(method_family = init)]
131        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
132
133        #[unsafe(method(new))]
134        #[unsafe(method_family = new)]
135        pub unsafe fn new() -> Retained<Self>;
136    );
137}
138
139extern_protocol!(
140    /// Provides a factory method for creating MEFormatReader objects.
141    ///
142    /// The MEFormatReaderExtension protocol provides a factory method to create a new MEFormatReader when provided with an MEByteSource object. MEFormatReaderExtension is always instantiated by the Media Toolbox, and the MEByteSource object is also created by Media Toolbox based on the specified media asset. All async methods in MEFormatReader/METrackReader/MESampleCursor are allowed to call the completion handlers on any thread or queue.
143    ///
144    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/meformatreaderextension?language=objc)
145    pub unsafe trait MEFormatReaderExtension: NSObjectProtocol {
146        #[unsafe(method(init))]
147        #[unsafe(method_family = init)]
148        unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
149
150        /// The factory method to create a new MEFormatReader.
151        ///
152        /// Creates a new MEFormatReader given an MEByteSource, with optional MEFileReaderInstantiationOptions.
153        ///
154        /// Parameter `primaryByteSource`: The primary MEByteSource instance for the format reader. The MEFormatReader should retain this object for use when responding to later requests for information, and release it in the object finalize method.
155        ///
156        /// Parameter `options`: An optional instance of MEFormatReaderInstantiationOptions
157        ///
158        /// Parameter `error`: On return, if initialization of the MEFormatReader fails, points to an NSError describing the nature of the failure.
159        ///
160        /// Returns: A newly created instance of MEFormatReader.
161        #[unsafe(method(formatReaderWithByteSource:options:error:_))]
162        #[unsafe(method_family = none)]
163        unsafe fn formatReaderWithByteSource_options_error(
164            &self,
165            primary_byte_source: &MEByteSource,
166            options: Option<&MEFormatReaderInstantiationOptions>,
167        ) -> Result<Retained<ProtocolObject<dyn MEFormatReader>>, Retained<NSError>>;
168    }
169);
170
171extern_protocol!(
172    /// The primary object for a MediaExtension format reader, representing a single media asset.
173    ///
174    /// The MEFormatReader protocol provides an interface for the MediaToolbox to interact with MediaExtension format readers, which provide information about media assets. MEFormatReader objects are always instantiated by the MediaToolbox. To create an MEFormatReader object, MediaToolbox first creates a primary MEByteSource object around a source media asset. It then creates an MEFormatReaderExtension object and calls its formatReaderWithByteSource method. MEFormatReaders should expect to run in a sandboxed process with restricted access to the filesystem, network and other kernel resources.
175    ///
176    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/meformatreader?language=objc)
177    pub unsafe trait MEFormatReader: NSObjectProtocol {
178        #[cfg(feature = "block2")]
179        /// Asynchronously loads the MEFileInfo object with properties of the media asset.
180        ///
181        /// This method should provide either a valid MEFileInfo object or nil in case of failure.  If the method fails, the NSError will contain error information.
182        ///
183        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
184        /// 'fileInfo'
185        /// The returned MEFileInfo object.
186        /// 'error'
187        /// An NSError object that will contain error information if the method fails, otherwise nil.
188        #[unsafe(method(loadFileInfoWithCompletionHandler:))]
189        #[unsafe(method_family = none)]
190        unsafe fn loadFileInfoWithCompletionHandler(
191            &self,
192            completion_handler: &block2::DynBlock<dyn Fn(*mut MEFileInfo, *mut NSError)>,
193        );
194
195        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
196        /// Asynchronously loads the array of AVMetadataItems representing metadata from the media asset.
197        ///
198        /// This method should provide either a valid NSArray or nil. If the method fails, the NSError will contain error information.
199        ///
200        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
201        /// 'metadata'
202        /// The returned NSArray of AVMetadataItem objects.
203        /// 'error'
204        /// An NSError object that will contain error information if the method fails, otherwise nil.
205        #[unsafe(method(loadMetadataWithCompletionHandler:))]
206        #[unsafe(method_family = none)]
207        unsafe fn loadMetadataWithCompletionHandler(
208            &self,
209            completion_handler: &block2::DynBlock<
210                dyn Fn(*mut NSArray<AVMetadataItem>, *mut NSError),
211            >,
212        );
213
214        #[cfg(feature = "block2")]
215        /// Asynchronously loads the array of METrackReader objects representing the tracks in the media asset.
216        ///
217        /// This method should provide either a valid NSArray object or nil. If the method fails, the NSError will contain error information.
218        ///
219        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
220        /// 'trackReaders'
221        /// The returned NSArray of METrackReader objects.
222        /// 'error'
223        /// An NSError object that will contain error information if the method fails, otherwise nil.
224        #[unsafe(method(loadTrackReadersWithCompletionHandler:))]
225        #[unsafe(method_family = none)]
226        unsafe fn loadTrackReadersWithCompletionHandler(
227            &self,
228            completion_handler: &block2::DynBlock<
229                dyn Fn(*mut NSArray<ProtocolObject<dyn METrackReader>>, *mut NSError),
230            >,
231        );
232
233        #[cfg(feature = "block2")]
234        /// Asynchronously incorporates additional fragments that have been appended since the file was last parsed.
235        ///
236        /// Parses additional fragments of the media asset if they exist. Media asset formats that do not support incremental fragments do not need implement this method. The MEFormatReader must have been instantiated with the MEFormatReaderInstantiationOptions property allowIncrementalFragmentParsing set to YES. Does nothing unless the MEFileInfo property fragmentsStatus is MEFileInfoContainsFragments. Once this function returns an error, later calls should also always fail.
237        ///
238        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
239        /// 'fragmentStatus'
240        /// The returned MEFormatReaderParseAdditionalFragmentsStatus flags with status information.
241        /// 'error'
242        /// An NSError object that will contain error information if the method fails, otherwise nil. Returns an error of MEFormatReaderErrorUnsupportedFeature if the MEFormatReaderInstantiationOptions property allowIncrementalFragmentParsing was not set to YES at creation time. Returns an error of MEFormatReaderErrorParsingFailure if there was a parsing failure.
243        #[optional]
244        #[unsafe(method(parseAdditionalFragmentsWithCompletionHandler:))]
245        #[unsafe(method_family = none)]
246        unsafe fn parseAdditionalFragmentsWithCompletionHandler(
247            &self,
248            completion_handler: &block2::DynBlock<
249                dyn Fn(MEFormatReaderParseAdditionalFragmentsStatus, *mut NSError),
250            >,
251        );
252    }
253);
254
255extern_class!(
256    /// A class incorporating file properties parsed from the media asset.
257    ///
258    /// The MEFileInfo properties are parsed asynchronously through the loadFileInfoWithCompletionHandler method of MEFormatReader.
259    ///
260    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mefileinfo?language=objc)
261    #[unsafe(super(NSObject))]
262    #[derive(Debug, PartialEq, Eq, Hash)]
263    pub struct MEFileInfo;
264);
265
266unsafe impl Send for MEFileInfo {}
267
268unsafe impl Sync for MEFileInfo {}
269
270extern_conformance!(
271    unsafe impl NSCopying for MEFileInfo {}
272);
273
274unsafe impl CopyingHelper for MEFileInfo {
275    type Result = Self;
276}
277
278extern_conformance!(
279    unsafe impl NSObjectProtocol for MEFileInfo {}
280);
281
282impl MEFileInfo {
283    extern_methods!(
284        #[cfg(feature = "objc2-core-media")]
285        /// The duration of the media asset if known, otherwise kCMTimeInvalid.
286        ///
287        /// This property is not atomic.
288        ///
289        /// # Safety
290        ///
291        /// This might not be thread-safe.
292        #[unsafe(method(duration))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn duration(&self) -> CMTime;
295
296        #[cfg(feature = "objc2-core-media")]
297        /// Setter for [`duration`][Self::duration].
298        ///
299        /// # Safety
300        ///
301        /// This might not be thread-safe.
302        #[unsafe(method(setDuration:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn setDuration(&self, duration: CMTime);
305
306        /// Indicates if the media asset is capable of being extended by fragments or contains fragments
307        ///
308        /// See the MEFileInfoFragmentsStatus values for details of the return value. The value will default to MEFileInfoCouldNotContainFragments.
309        ///
310        /// This property is not atomic.
311        ///
312        /// # Safety
313        ///
314        /// This might not be thread-safe.
315        #[unsafe(method(fragmentsStatus))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn fragmentsStatus(&self) -> MEFileInfoFragmentsStatus;
318
319        /// Setter for [`fragmentsStatus`][Self::fragmentsStatus].
320        ///
321        /// # Safety
322        ///
323        /// This might not be thread-safe.
324        #[unsafe(method(setFragmentsStatus:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setFragmentsStatus(&self, fragments_status: MEFileInfoFragmentsStatus);
327
328        /// The sidecar filename used by the MediaExtension.
329        ///
330        /// Represents a new or existing sidecar file located in the same directory as the primary media file. The filename should include the file extension, and should not contain the file path, or contain any slashes. The file extension should be supported by the format reader, and present in the EXAppExtensionAttributes and UTExportedTypeDeclarations dictionaries in the MediaExtension format reader Info.plist.
331        ///
332        /// This property is not atomic.
333        ///
334        /// # Safety
335        ///
336        /// This might not be thread-safe.
337        #[unsafe(method(sidecarFileName))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn sidecarFileName(&self) -> Option<Retained<NSString>>;
340
341        /// Setter for [`sidecarFileName`][Self::sidecarFileName].
342        ///
343        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
344        ///
345        /// # Safety
346        ///
347        /// This might not be thread-safe.
348        #[unsafe(method(setSidecarFileName:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn setSidecarFileName(&self, sidecar_file_name: Option<&NSString>);
351    );
352}
353
354/// Methods declared on superclass `NSObject`.
355impl MEFileInfo {
356    extern_methods!(
357        #[unsafe(method(init))]
358        #[unsafe(method_family = init)]
359        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
360
361        #[unsafe(method(new))]
362        #[unsafe(method_family = new)]
363        pub unsafe fn new() -> Retained<Self>;
364    );
365}
366
367extern_protocol!(
368    /// Provides information about a track within a media asset.
369    ///
370    /// The MEFormatReader creates METrackReader objects for each track in the media asset. MEFormatReader plugin authors should provide code to implement the METrackReader protocol methods. Since not every method or property applies to every track type, those that don't make sense should return default values.
371    ///
372    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/metrackreader?language=objc)
373    pub unsafe trait METrackReader: NSObjectProtocol {
374        #[cfg(feature = "block2")]
375        /// Asynchronously loads the METrackInfo object with properties of the media asset track.
376        ///
377        /// This method should provide either a valid METrackInfo object or nil.  If the method fails, the NSError will contain error information.
378        ///
379        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
380        /// 'trackInfo'
381        /// The returned METrackInfo object if the method succeeds, otherwise nil.
382        /// 'error'
383        /// An NSError object that will contain error information if the method fails, otherwise nil.
384        #[unsafe(method(loadTrackInfoWithCompletionHandler:))]
385        #[unsafe(method_family = none)]
386        unsafe fn loadTrackInfoWithCompletionHandler(
387            &self,
388            completion_handler: &block2::DynBlock<dyn Fn(*mut METrackInfo, *mut NSError)>,
389        );
390
391        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
392        /// Provides a new MESampleCursor object pointing to the sample at or near the specified presentation timestamp.
393        ///
394        /// The new MESampleCursor will point to the last sample with a PTS less than or equal to presentationTimeStamp, or if there are no such samples, the first sample in PTS order.
395        ///
396        /// Parameter `presentationTimeStamp`: The desired PTS.
397        ///
398        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
399        /// 'sampleCursor'
400        /// The returned MESampleCursor if the method succeeds, otherwise nil.
401        /// 'error'
402        /// An NSError object that will contain error information if the method fails, otherwise nil.
403        #[unsafe(method(generateSampleCursorAtPresentationTimeStamp:completionHandler:))]
404        #[unsafe(method_family = none)]
405        unsafe fn generateSampleCursorAtPresentationTimeStamp_completionHandler(
406            &self,
407            presentation_time_stamp: CMTime,
408            completion_handler: &block2::DynBlock<
409                dyn Fn(*mut ProtocolObject<dyn MESampleCursor>, *mut NSError),
410            >,
411        );
412
413        #[cfg(feature = "block2")]
414        /// Provides a new MESampleCursor object pointing to the first sample in decode order.
415        ///
416        /// The new MESampleCursor will point to the first sample in decode order regardless of the presentation time.
417        ///
418        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
419        /// 'sampleCursor'
420        /// The returned MESampleCursor if the method succeeds, otherwise nil.
421        /// 'error'
422        /// An NSError object that will contain error information if the method fails, otherwise nil.
423        #[unsafe(method(generateSampleCursorAtFirstSampleInDecodeOrderWithCompletionHandler:))]
424        #[unsafe(method_family = none)]
425        unsafe fn generateSampleCursorAtFirstSampleInDecodeOrderWithCompletionHandler(
426            &self,
427            completion_handler: &block2::DynBlock<
428                dyn Fn(*mut ProtocolObject<dyn MESampleCursor>, *mut NSError),
429            >,
430        );
431
432        #[cfg(feature = "block2")]
433        /// Provides a new MESampleCursor object pointing to the last sample in decode order.
434        ///
435        /// The new MESampleCursor will point to the last sample in decode order regardless of the presentation time.
436        ///
437        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
438        /// 'sampleCursor'
439        /// The returned MESampleCursor if the method succeeds, otherwise nil.
440        /// 'error'
441        /// An NSError object that will contain error information if the method fails, otherwise nil.
442        #[unsafe(method(generateSampleCursorAtLastSampleInDecodeOrderWithCompletionHandler:))]
443        #[unsafe(method_family = none)]
444        unsafe fn generateSampleCursorAtLastSampleInDecodeOrderWithCompletionHandler(
445            &self,
446            completion_handler: &block2::DynBlock<
447                dyn Fn(*mut ProtocolObject<dyn MESampleCursor>, *mut NSError),
448            >,
449        );
450
451        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
452        /// Returns the duration of the track as a CMTime disregarding any edits.
453        ///
454        /// This information may be used by the MediaToolbox to validate edit information or to check if the media is suitable for gapless playback.
455        ///
456        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
457        /// 'uneditedDuration'
458        /// A valid duration if the method succeeds, otherwise kCMTimeInvalid.
459        /// 'error'
460        /// An NSError object that will contain error information if the method fails, otherwise nil.
461        #[optional]
462        #[unsafe(method(loadUneditedDurationWithCompletionHandler:))]
463        #[unsafe(method_family = none)]
464        unsafe fn loadUneditedDurationWithCompletionHandler(
465            &self,
466            completion_handler: &block2::DynBlock<dyn Fn(CMTime, *mut NSError)>,
467        );
468
469        #[cfg(feature = "block2")]
470        /// Loads the total size in bytes of all the samples in the track.
471        ///
472        /// If the method fails, the NSError will contain error information.
473        ///
474        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
475        /// 'totalSampleDataLength'
476        /// A valid data length if the method succeeds, otherwise 0.
477        /// 'error'
478        /// An NSError object that will contain error information if the method fails, otherwise nil.
479        #[optional]
480        #[unsafe(method(loadTotalSampleDataLengthWithCompletionHandler:))]
481        #[unsafe(method_family = none)]
482        unsafe fn loadTotalSampleDataLengthWithCompletionHandler(
483            &self,
484            completion_handler: &block2::DynBlock<dyn Fn(i64, *mut NSError)>,
485        );
486
487        #[cfg(feature = "block2")]
488        /// Loads the approximate data rate of the track in bytes per second as a floating point number.
489        ///
490        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
491        /// 'estimatedDataRate'
492        /// A valid data rate if the method succeeds, otherwise 0.0.
493        /// 'error'
494        /// An NSError object that will contain error information if the method fails, otherwise nil.
495        #[optional]
496        #[unsafe(method(loadEstimatedDataRateWithCompletionHandler:))]
497        #[unsafe(method_family = none)]
498        unsafe fn loadEstimatedDataRateWithCompletionHandler(
499            &self,
500            completion_handler: &block2::DynBlock<dyn Fn(f32, *mut NSError)>,
501        );
502
503        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
504        /// Asynchronously loads an NSArray object with metadata from the media asset track.
505        ///
506        /// This method should provide either a valid NSArray object or nil. If the method fails, the NSError will contain error information.
507        ///
508        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
509        /// 'metadata'
510        /// An NSArray of AVMetadataItem objects if the method succeeds, otherwise nil.
511        /// 'error'
512        /// An NSError object that will contain error information if the method fails, otherwise nil.
513        #[optional]
514        #[unsafe(method(loadMetadataWithCompletionHandler:))]
515        #[unsafe(method_family = none)]
516        unsafe fn loadMetadataWithCompletionHandler(
517            &self,
518            completion_handler: &block2::DynBlock<
519                dyn Fn(*mut NSArray<AVMetadataItem>, *mut NSError),
520            >,
521        );
522    }
523);
524
525extern_class!(
526    /// A class incorporating track properties parsed from the media asset.
527    ///
528    /// The METrackInfo properties are parsed asynchronously through the loadTrackInfoWithCompletionHandler method of METrackReader.
529    ///
530    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/metrackinfo?language=objc)
531    #[unsafe(super(NSObject))]
532    #[derive(Debug, PartialEq, Eq, Hash)]
533    pub struct METrackInfo;
534);
535
536unsafe impl Send for METrackInfo {}
537
538unsafe impl Sync for METrackInfo {}
539
540extern_conformance!(
541    unsafe impl NSCopying for METrackInfo {}
542);
543
544unsafe impl CopyingHelper for METrackInfo {
545    type Result = Self;
546}
547
548extern_conformance!(
549    unsafe impl NSObjectProtocol for METrackInfo {}
550);
551
552impl METrackInfo {
553    extern_methods!(
554        #[unsafe(method(new))]
555        #[unsafe(method_family = new)]
556        pub unsafe fn new() -> Retained<Self>;
557
558        #[unsafe(method(init))]
559        #[unsafe(method_family = init)]
560        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
561
562        #[cfg(feature = "objc2-core-media")]
563        /// Initializes a new METrackInfo instance.
564        ///
565        /// The main initializer for the METrackInfo class. After creating the class, the METrackReader should fill in all the relevant properties with the values read in from the media track.
566        ///
567        /// Parameter `mediaType`: The media type of the track.
568        ///
569        /// Parameter `trackID`: An integer identifying the track within the media asset.
570        ///
571        /// Parameter `formatDescriptions`: The format descriptions for the track, as an NSArray.
572        ///
573        /// Returns: A new instance of METrackInfo.
574        ///
575        /// # Safety
576        ///
577        /// `format_descriptions` generic should be of the correct type.
578        #[unsafe(method(initWithMediaType:trackID:formatDescriptions:))]
579        #[unsafe(method_family = init)]
580        pub unsafe fn initWithMediaType_trackID_formatDescriptions(
581            this: Allocated<Self>,
582            media_type: CMMediaType,
583            track_id: CMPersistentTrackID,
584            format_descriptions: &NSArray,
585        ) -> Retained<Self>;
586
587        #[cfg(feature = "objc2-core-media")]
588        /// The media type of the track.
589        ///
590        /// This value is set through the class initializer.
591        ///
592        /// This property is not atomic.
593        ///
594        /// # Safety
595        ///
596        /// This might not be thread-safe.
597        #[unsafe(method(mediaType))]
598        #[unsafe(method_family = none)]
599        pub unsafe fn mediaType(&self) -> CMMediaType;
600
601        #[cfg(feature = "objc2-core-media")]
602        /// An integer identifying the track within the media asset.
603        ///
604        /// The track ID is used to uniquely identify the track within the MEFormatReader. Track IDs must be unique within a media asset but do not need to be unique across assets. If a media format does not have a native concept of track IDs, track IDs may be assigned starting from 1. The track ID value of 0 is reserved to indicate an invalid track ID. This value is set through the class initializer.
605        ///
606        /// This property is not atomic.
607        ///
608        /// # Safety
609        ///
610        /// This might not be thread-safe.
611        #[unsafe(method(trackID))]
612        #[unsafe(method_family = none)]
613        pub unsafe fn trackID(&self) -> CMPersistentTrackID;
614
615        /// A BOOL value indicating whether the track is enabled by default.
616        ///
617        /// This property is not atomic.
618        ///
619        /// # Safety
620        ///
621        /// This might not be thread-safe.
622        #[unsafe(method(isEnabled))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn isEnabled(&self) -> bool;
625
626        /// Setter for [`isEnabled`][Self::isEnabled].
627        ///
628        /// # Safety
629        ///
630        /// This might not be thread-safe.
631        #[unsafe(method(setEnabled:))]
632        #[unsafe(method_family = none)]
633        pub unsafe fn setEnabled(&self, enabled: bool);
634
635        /// The format descriptions for the track, as an NSArray.
636        ///
637        /// This value is set through the class initializer.
638        ///
639        /// This property is not atomic.
640        ///
641        /// # Safety
642        ///
643        /// This might not be thread-safe.
644        #[unsafe(method(formatDescriptions))]
645        #[unsafe(method_family = none)]
646        pub unsafe fn formatDescriptions(&self) -> Retained<NSArray>;
647    );
648}
649
650/// OptionalProperties.
651impl METrackInfo {
652    extern_methods!(
653        #[cfg(feature = "objc2-core-media")]
654        /// The natural timescale of the track, as a CMTimeScale value.
655        ///
656        /// This property is not atomic.
657        ///
658        /// # Safety
659        ///
660        /// This might not be thread-safe.
661        #[unsafe(method(naturalTimescale))]
662        #[unsafe(method_family = none)]
663        pub unsafe fn naturalTimescale(&self) -> CMTimeScale;
664
665        #[cfg(feature = "objc2-core-media")]
666        /// Setter for [`naturalTimescale`][Self::naturalTimescale].
667        ///
668        /// # Safety
669        ///
670        /// This might not be thread-safe.
671        #[unsafe(method(setNaturalTimescale:))]
672        #[unsafe(method_family = none)]
673        pub unsafe fn setNaturalTimescale(&self, natural_timescale: CMTimeScale);
674
675        /// Returns the array of edit segments for the given track.
676        ///
677        /// Each NSValue in the array contains a CMTimeMapping object describing the track edit. The CMTimeMapping.target time ranges for successive edits must partition the time range from 0 to the track's duration. In other words, for edit index = 0 the CMTimeMapping.target.start must be kCMTimeZero, while for edit index > 0, the CMTimeMapping.target.start must match the CMTimeRangeGetEnd(CMTimeMapping.target) for edit (index - 1). It is valid for a track to have an empty trackEdits array; this means that there is nothing at all in the track and the track duration is zero. If this property is implemented for media asset formats that do not support edit segments, it can return nil.
678        ///
679        /// This property is not atomic.
680        ///
681        /// # Safety
682        ///
683        /// This might not be thread-safe.
684        #[unsafe(method(trackEdits))]
685        #[unsafe(method_family = none)]
686        pub unsafe fn trackEdits(&self) -> Option<Retained<NSArray<NSValue>>>;
687
688        /// Setter for [`trackEdits`][Self::trackEdits].
689        ///
690        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
691        ///
692        /// # Safety
693        ///
694        /// This might not be thread-safe.
695        #[unsafe(method(setTrackEdits:))]
696        #[unsafe(method_family = none)]
697        pub unsafe fn setTrackEdits(&self, track_edits: Option<&NSArray<NSValue>>);
698    );
699}
700
701/// LanguageTagOptionalProperties.
702impl METrackInfo {
703    extern_methods!(
704        /// Indicates the language tag associated with the track, as an IETF BCP 47 (RFC 4646) language identifier.
705        ///
706        /// This property may be used by the MediaToolbox to group similar language tracks together or to match audio and caption tracks. If no language tag is indicated, this property should be set to nil.
707        ///
708        /// This property is not atomic.
709        ///
710        /// # Safety
711        ///
712        /// This might not be thread-safe.
713        #[unsafe(method(extendedLanguageTag))]
714        #[unsafe(method_family = none)]
715        pub unsafe fn extendedLanguageTag(&self) -> Option<Retained<NSString>>;
716
717        /// Setter for [`extendedLanguageTag`][Self::extendedLanguageTag].
718        ///
719        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
720        ///
721        /// # Safety
722        ///
723        /// This might not be thread-safe.
724        #[unsafe(method(setExtendedLanguageTag:))]
725        #[unsafe(method_family = none)]
726        pub unsafe fn setExtendedLanguageTag(&self, extended_language_tag: Option<&NSString>);
727    );
728}
729
730/// VideoSpecificOptionalProperties.
731impl METrackInfo {
732    extern_methods!(
733        #[cfg(feature = "objc2-core-foundation")]
734        /// Indicates the natural dimensions of the media data referenced by the track as a CGSize.
735        ///
736        /// This property is only valid for tracks with visual media types and should return CGSizeZero if implemented for other track types.
737        ///
738        /// This property is not atomic.
739        ///
740        /// # Safety
741        ///
742        /// This might not be thread-safe.
743        #[unsafe(method(naturalSize))]
744        #[unsafe(method_family = none)]
745        pub unsafe fn naturalSize(&self) -> CGSize;
746
747        #[cfg(feature = "objc2-core-foundation")]
748        /// Setter for [`naturalSize`][Self::naturalSize].
749        ///
750        /// # Safety
751        ///
752        /// This might not be thread-safe.
753        #[unsafe(method(setNaturalSize:))]
754        #[unsafe(method_family = none)]
755        pub unsafe fn setNaturalSize(&self, natural_size: CGSize);
756
757        #[cfg(feature = "objc2-core-foundation")]
758        /// Indicates the preferred affine display transform of the track media for visual display.
759        ///
760        /// Returns an CGAffineTransform representing the preferred affine transform of the track for visual display. This property is only valid for tracks with visual media types and should return CGAffineTransformIdentity if implemented for other track types.
761        ///
762        /// This property is not atomic.
763        ///
764        /// # Safety
765        ///
766        /// This might not be thread-safe.
767        #[unsafe(method(preferredTransform))]
768        #[unsafe(method_family = none)]
769        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;
770
771        #[cfg(feature = "objc2-core-foundation")]
772        /// Setter for [`preferredTransform`][Self::preferredTransform].
773        ///
774        /// # Safety
775        ///
776        /// This might not be thread-safe.
777        #[unsafe(method(setPreferredTransform:))]
778        #[unsafe(method_family = none)]
779        pub unsafe fn setPreferredTransform(&self, preferred_transform: CGAffineTransform);
780
781        /// The frame rate of the track, in frames per second, as a 32-bit floating point number.
782        ///
783        /// For field-based video tracks that carry one field per media sample, the value of this property is the field rate, not the frame rate. This information from this property may be used by the MediaToolbox to calculate the maximum playback speed.
784        ///
785        /// This property is not atomic.
786        ///
787        /// # Safety
788        ///
789        /// This might not be thread-safe.
790        #[unsafe(method(nominalFrameRate))]
791        #[unsafe(method_family = none)]
792        pub unsafe fn nominalFrameRate(&self) -> f32;
793
794        /// Setter for [`nominalFrameRate`][Self::nominalFrameRate].
795        ///
796        /// # Safety
797        ///
798        /// This might not be thread-safe.
799        #[unsafe(method(setNominalFrameRate:))]
800        #[unsafe(method_family = none)]
801        pub unsafe fn setNominalFrameRate(&self, nominal_frame_rate: f32);
802
803        /// Indicates whether frame reordering occurs in the track.
804        ///
805        /// The value is YES if frame reordering occurs, NO otherwise. This property is only valid for tracks with video media type and should return NO for if implemented for other track types.
806        ///
807        /// This property is not atomic.
808        ///
809        /// # Safety
810        ///
811        /// This might not be thread-safe.
812        #[unsafe(method(requiresFrameReordering))]
813        #[unsafe(method_family = none)]
814        pub unsafe fn requiresFrameReordering(&self) -> bool;
815
816        /// Setter for [`requiresFrameReordering`][Self::requiresFrameReordering].
817        ///
818        /// # Safety
819        ///
820        /// This might not be thread-safe.
821        #[unsafe(method(setRequiresFrameReordering:))]
822        #[unsafe(method_family = none)]
823        pub unsafe fn setRequiresFrameReordering(&self, requires_frame_reordering: bool);
824    );
825}
826
827extern_protocol!(
828    /// Provides information about samples within a track of a media asset.
829    ///
830    /// The Media Toolbox creates an MESampleCursor object by calling one of the METrackReader sample cursor creation methods. It then makes method calls using the MESampleCursor protocol. MESampleCursors can deliver sample data either by providing sample location and sample chunk information, or by directly generating a sample buffer.
831    ///
832    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mesamplecursor?language=objc)
833    pub unsafe trait MESampleCursor: NSObjectProtocol + NSCopying {
834        #[cfg(feature = "objc2-core-media")]
835        /// The presentation timestamp (PTS) of the sample at the current position of the cursor.
836        #[unsafe(method(presentationTimeStamp))]
837        #[unsafe(method_family = none)]
838        unsafe fn presentationTimeStamp(&self) -> CMTime;
839
840        #[cfg(feature = "objc2-core-media")]
841        /// The decode timestamp (DTS) of the sample at the current position of the cursor.
842        #[unsafe(method(decodeTimeStamp))]
843        #[unsafe(method_family = none)]
844        unsafe fn decodeTimeStamp(&self) -> CMTime;
845
846        #[cfg(feature = "objc2-core-media")]
847        /// Indicates the decode duration of the sample at the receiver's current position.
848        ///
849        /// If the receiver must be advanced past its current position in order to determine the decode duration of the current sample, the value of currentSampleDuration is equal to kCMTimeIndefinite. This can occur with streaming formats such as MPEG-2 transport streams.
850        #[unsafe(method(currentSampleDuration))]
851        #[unsafe(method_family = none)]
852        unsafe fn currentSampleDuration(&self) -> CMTime;
853
854        #[cfg(feature = "objc2-core-media")]
855        /// The format description for the sample at the current position of the cursor.
856        #[unsafe(method(currentSampleFormatDescription))]
857        #[unsafe(method_family = none)]
858        unsafe fn currentSampleFormatDescription(&self) -> Option<Retained<CMFormatDescription>>;
859
860        #[cfg(feature = "block2")]
861        /// Moves the cursor a given number of samples in decode order.
862        ///
863        /// If the request would advance the cursor past the last sample or before the first sample, the cursor should be set to point to that limiting sample and actualStepCount will report the number of samples the cursor was able to move.
864        ///
865        /// Parameter `stepCount`: The number of samples to move. If positive, step forward this many samples. If negative, step backward (-stepCount) samples.
866        ///
867        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
868        /// 'actualStepCount'
869        /// The final count of steps taken.
870        /// 'error'
871        /// An NSError object that will contain error information if the method fails, otherwise nil.
872        #[unsafe(method(stepInDecodeOrderByCount:completionHandler:))]
873        #[unsafe(method_family = none)]
874        unsafe fn stepInDecodeOrderByCount_completionHandler(
875            &self,
876            step_count: i64,
877            completion_handler: &block2::DynBlock<dyn Fn(i64, *mut NSError)>,
878        );
879
880        #[cfg(feature = "block2")]
881        /// @
882        ///
883        ///
884        /// Moves the cursor a given number of samples in presentation order.
885        ///
886        /// If the request would advance the cursor past the last sample or before the first sample, the cursor should be set to point to that limiting sample and actualStepCount will report the number of samples the cursor was able to move. If decode order and presentation order are the same (ie, the samples are not reordered), this method should have the same effect as stepInDecodeOrderByCount.
887        ///
888        /// Parameter `stepCount`: The number of samples to move. If positive, step forward this many samples. If negative, step backward (-stepCount) samples.
889        ///
890        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
891        /// 'actualStepCount'
892        /// The final count of steps taken.
893        /// 'error'
894        /// An NSError object that will contain error information if the method fails, otherwise nil.
895        #[unsafe(method(stepInPresentationOrderByCount:completionHandler:))]
896        #[unsafe(method_family = none)]
897        unsafe fn stepInPresentationOrderByCount_completionHandler(
898            &self,
899            step_count: i64,
900            completion_handler: &block2::DynBlock<dyn Fn(i64, *mut NSError)>,
901        );
902
903        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
904        /// Moves the cursor by a given deltaDecodeTime on the decode timeline.
905        ///
906        /// If the request would advance the cursor past the end of the last sample or before the first sample, the cursor should be set to point to that limiting sample, and positionWasPinned will be set to YES. Otherwise, positionWasPinned will be set to NO.
907        ///
908        /// Parameter `deltaDecodeTime`: The cursor is moved to the sample at decode time (current sample decode time + deltaDecodeTime).
909        ///
910        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
911        /// 'actualDecodeTime'
912        /// The final cursor decode time. Because sample cursors snap to sample boundaries when stepped, this value may not be equal to (current sample decode time + deltaDecodeTime) even if the cursor was not pinned.
913        /// 'positionWasPinned'
914        /// YES if the request attempted to advance the cursor beyond the track limits, otherwise NO.
915        /// 'error'
916        /// An NSError object that will contain error information if the method fails, otherwise nil.
917        #[unsafe(method(stepByDecodeTime:completionHandler:))]
918        #[unsafe(method_family = none)]
919        unsafe fn stepByDecodeTime_completionHandler(
920            &self,
921            delta_decode_time: CMTime,
922            completion_handler: &block2::DynBlock<dyn Fn(CMTime, Bool, *mut NSError)>,
923        );
924
925        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
926        /// Moves the cursor by a given deltaPresentationTime on the presentation timeline.
927        ///
928        /// If the request would advance the cursor past the end of the last sample or before the first sample, the cursor should be set to point to that limiting sample, and positionWasPinned will be set to YES. Otherwise, positionWasPinned will be set to NO.
929        ///
930        /// Parameter `deltaPresentationTime`: The cursor is moved to the sample at presentation time (current sample presentation time + deltaPresentationTime).
931        ///
932        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
933        /// 'actualPresentationTime'
934        /// The final cursor presentation time. Because sample cursors snap to sample boundaries when stepped, this value may not be equal to (current sample presentation time + deltaPresentationTime) even if the cursor was not pinned.
935        /// 'positionWasPinned'
936        /// YES if the request attempted to advance the cursor beyond the track limits, otherwise NO.
937        /// 'error'
938        /// An NSError object that will contain error information if the method fails, otherwise nil.
939        #[unsafe(method(stepByPresentationTime:completionHandler:))]
940        #[unsafe(method_family = none)]
941        unsafe fn stepByPresentationTime_completionHandler(
942            &self,
943            delta_presentation_time: CMTime,
944            completion_handler: &block2::DynBlock<dyn Fn(CMTime, Bool, *mut NSError)>,
945        );
946
947        #[cfg(feature = "objc2-av-foundation")]
948        /// Retrieves decoder synchronization information about the sample pointed to by the cursor.
949        ///
950        /// The returned value will be an AVSampleCursorSyncInfo structure with any valid flags set. If this kind of synchronization information does not make sense for the sequence of samples, this property should not be implemented.
951        #[optional]
952        #[unsafe(method(syncInfo))]
953        #[unsafe(method_family = none)]
954        unsafe fn syncInfo(&self) -> AVSampleCursorSyncInfo;
955
956        #[cfg(feature = "objc2-av-foundation")]
957        /// Retrieves generic dependency information about the sample pointed to by the cursor.
958        ///
959        /// The returned value will be an AVSampleCursorDependencyInfo structure with any valid flags set. If this kind of dependency information does not make sense for the sequence of samples, this property should not be implemented.
960        #[optional]
961        #[unsafe(method(dependencyInfo))]
962        #[unsafe(method_family = none)]
963        unsafe fn dependencyInfo(&self) -> AVSampleCursorDependencyInfo;
964
965        /// Retrieves additional information necessary to recover complete sample dependency information.
966        ///
967        /// hevcDependencyInfo is an optional property that communicates additional sample dependency information not contained in syncInfo or dependencyInfo. Examples of this are the NAL unit type of an HEVC sync sample or the number of samples necessary to refresh the decoder after a USAC Independent Frame. For formats where this information does not make sense, this property should be set to nil.
968        #[optional]
969        #[unsafe(method(hevcDependencyInfo))]
970        #[unsafe(method_family = none)]
971        unsafe fn hevcDependencyInfo(&self) -> Retained<MEHEVCDependencyInfo>;
972
973        #[cfg(feature = "objc2-core-media")]
974        /// Retrieves the duration of the content playable from the cursor as a CMTime.
975        ///
976        /// Indicates the time difference between the current cursor DTS and last reachable sample DTS. This is necessary to play assets with e.g. HTTP URLs as it indicates what samples have already been loaded by the byte source.
977        #[optional]
978        #[unsafe(method(decodeTimeOfLastSampleReachableByForwardSteppingThatIsAlreadyLoadedByByteSource))]
979        #[unsafe(method_family = none)]
980        unsafe fn decodeTimeOfLastSampleReachableByForwardSteppingThatIsAlreadyLoadedByByteSource(
981            &self,
982        ) -> CMTime;
983
984        /// Tests for an earlier boundary in sample reordering.
985        ///
986        /// This method tests for a boundary in the reordering from decode order to presentation order, determining when it could be possible for any sample earlier in decode order than the receiver current sample to have a presentation time later than the current sample of the specified cursor. This test can be used to limit backward scans, e.g. to start forward playback. For example, with the argument cursor fixed, step the receiver backwards until it is impossible for any earlier-in-decode-order receiver samples to be later-in-presentation-order than the argument cursor sample. If sample reordering does not make sense for the track content, this method should not be implemented. If this method is not implemented, clients should assume the samples are not reordered.
987        ///
988        /// Parameter `cursor`: An instance of id
989        /// <MESampleCursor
990        /// > with which to test the sample reordering boundary.
991        ///
992        /// Returns: YES if it is possible earlier samples in decode order than that of the receiver can have a presentation timestamp later than that of the specified sample cursor, otherwise NO. If the receiver and argument cursors reference different sequences of samples, for example if they were created by different instances of MTTrackReader, the results are undefined.
993        #[optional]
994        #[unsafe(method(samplesWithEarlierDTSsMayHaveLaterPTSsThanCursor:))]
995        #[unsafe(method_family = none)]
996        unsafe fn samplesWithEarlierDTSsMayHaveLaterPTSsThanCursor(
997            &self,
998            cursor: &ProtocolObject<dyn MESampleCursor>,
999        ) -> bool;
1000
1001        /// Tests for a later boundary in sample reordering.
1002        ///
1003        /// This method tests for a boundary in the reordering from decode order to presentation order, determining when it could be possible for any sample later in decode order than the receiver current sample to have a presentation time earlier than the current sample of the specified cursor. This test can be used to limit forward scans, e.g. to start reverse playback. For example, with the argument cursor fixed, step the receiver forwards until it is impossible for any later-in-decode-order receiver samples to be earlier-in-presentation-order than the argument cursor sample. If sample reordering does not make sense for the track content, this method should not be implemented. If this method is not implemented, clients should assume the samples are not reordered.
1004        ///
1005        /// Parameter `cursor`: An instance of id
1006        /// <MESampleCursor
1007        /// > with which to test the sample reordering boundary.
1008        ///
1009        /// Returns: YES if it is possible later samples in decode order than that of the receiver can have a presentation timestamp earlier than that of the specified sample cursor, otherwise NO. If the receiver and argument cursors reference different sequences of samples, for example if they were created by different instances of MTTrackReader, the results are undefined.
1010        #[optional]
1011        #[unsafe(method(samplesWithLaterDTSsMayHaveEarlierPTSsThanCursor:))]
1012        #[unsafe(method_family = none)]
1013        unsafe fn samplesWithLaterDTSsMayHaveEarlierPTSsThanCursor(
1014            &self,
1015            cursor: &ProtocolObject<dyn MESampleCursor>,
1016        ) -> bool;
1017
1018        /// Returns information about the chunk holding the sample indicated by the cursor.
1019        ///
1020        /// If the sample resides in a contiguous chunk of the file among similar samples, chunkDetails returns information about that chunk. Note: For some media asset formats it is not practical to implement chunkDetails. In this case chunkDetails should return MEErrorLocationNotAvailable and loadSampleBufferContainingSamplesToEndCursor must be used to load the sample data.
1021        ///
1022        /// Parameter `error`: If provided, returns error information in the event that the method fails.
1023        ///
1024        /// Returns: Returns an instance of MESampleCursorChunk with details about the chunk if successful, returns NULL and fails with MEErrorLocationNotAvailable if sampleCursor does not support chunkDetails, or returns NULL if the method otherwise fails with error.
1025        #[optional]
1026        #[unsafe(method(chunkDetailsReturningError:_))]
1027        #[unsafe(method_family = none)]
1028        unsafe fn chunkDetailsReturningError(
1029            &self,
1030        ) -> Result<Retained<MESampleCursorChunk>, Retained<NSError>>;
1031
1032        /// Returns the location and byte source of the sample indicated by the cursor.
1033        ///
1034        /// This method is used to allow the system to handle reading the sample data. Sample data is expected to be contiguous. For some media asset formats, most samples are contiguous but there are exceptions; such MESampleCursors should support both sampleLocation and loadSampleBufferContainingSamplesToEndCursor. For samples that are not contiguous, sampleLocation should return MEErrorLocationNotAvailable. For other media asset formats, it is not practical to implement sampleLocation; such MESampleCursors must implement loadSampleBufferContainingSamplesToEndCursor instead.
1035        ///
1036        /// Parameter `error`: If provided, returns error information in the event that the method fails.
1037        ///
1038        /// Returns: Returns an instance of MESampleLocation with information about the sample location if successful, returns NULL and fails with MEErrorLocationNotAvailable if the sample is not contiguous or this method is not supported, in which case loadSampleBufferContainingSamplesToEndCursor must be called instead in order to load the sample data, or returns NULL if the method otherwise fails with error.
1039        #[optional]
1040        #[unsafe(method(sampleLocationReturningError:_))]
1041        #[unsafe(method_family = none)]
1042        unsafe fn sampleLocationReturningError(
1043            &self,
1044        ) -> Result<Retained<MESampleLocation>, Retained<NSError>>;
1045
1046        /// Returns an estimate of the sample location indicated by the cursor that can later be refined using refineSampleLocation.
1047        ///
1048        /// Optional addition to sampleLocationReturningError. For formats that need to read some data on a per-sample basis to produce the exact sample location, it may be more efficient to read a slightly larger chunk of data containing both the data necessary to produce the exact sample location and the actual sample data. The exact sample location will then be requested in a subsequent call to refineSampleLocation. It is possible to indicate that no refinement is necessary by returning a value for refinementDataLocation that has a zero length. If a non-zero length refinement location is returned, the range for the estimated sample location returned must fully cover the refined range returned by refineSampleLocation and the refinement data location. Note: Implementing estimatedSampleLocationReturningError also requires implementing refineSampleLocation. If the sample indicated by the cursor is not contiguous, this method will return MEErrorLocationNotAvailable. In this case the loadSampleBufferContainingSamplesToEndCursor must be used to load the sample data.
1049        ///
1050        /// Parameter `error`: If provided, returns error information in the event that the method fails.
1051        ///
1052        /// Returns: Returns an instance of MEEstimatedSampleLocation with information about the estimated sample location if successful, returns NULL and fails with MEErrorLocationNotAvailable if the sample is not contiguous or this method is not supported, in which case loadSampleBufferContainingSamplesToEndCursor must be called instead in order to load the sample data, or returns NULL if the method otherwise fails with error.
1053        #[optional]
1054        #[unsafe(method(estimatedSampleLocationReturningError:_))]
1055        #[unsafe(method_family = none)]
1056        unsafe fn estimatedSampleLocationReturningError(
1057            &self,
1058        ) -> Result<Retained<MEEstimatedSampleLocation>, Retained<NSError>>;
1059
1060        #[cfg(feature = "objc2-av-foundation")]
1061        /// Produces an exact sample location based on data returned from a call to estimatedSampleLocationReturningError.
1062        ///
1063        /// See the discussion in estimatedSampleLocationReturningError for details.
1064        ///
1065        /// Parameter `estimatedSampleLocation`: The value that was previously returned in the MEEstimatedSampleLocation object from estimatedSampleLocationReturningError
1066        ///
1067        /// Parameter `refinementData`: The refinement data returned from estimateSampleLocation in MEEstimatedSampleLocation.
1068        ///
1069        /// Parameter `refinementDataLength`: The length of refinementData in bytes.
1070        ///
1071        /// Parameter `refinedLocationOut`: Returns the exact starting file offset and size of the sample in bytes.
1072        ///
1073        /// Parameter `error`: If provided, returns error information in the event that the method fails.
1074        ///
1075        /// Returns: YES if the method succeeds, NO if it fails. If the method fails, error will contain error information.
1076        ///
1077        /// # Safety
1078        ///
1079        /// - `refinement_data` must be a valid pointer.
1080        /// - `refined_location_out` must be a valid pointer.
1081        #[optional]
1082        #[unsafe(method(refineSampleLocation:refinementData:refinementDataLength:refinedLocation:error:_))]
1083        #[unsafe(method_family = none)]
1084        unsafe fn refineSampleLocation_refinementData_refinementDataLength_refinedLocation_error(
1085            &self,
1086            estimated_sample_location: AVSampleCursorStorageRange,
1087            refinement_data: NonNull<u8>,
1088            refinement_data_length: usize,
1089            refined_location_out: NonNull<AVSampleCursorStorageRange>,
1090        ) -> Result<(), Retained<NSError>>;
1091
1092        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
1093        /// Builds a sample buffer containing the sample(s) at the cursor.
1094        ///
1095        /// This method is to be implemented by those plugin format readers that always load sample data in order to answer cursor queries. If a plugin format reader does not implement sampleLocation, implementing loadSampleBufferContainingSamplesToEndCursor is required. If the MESampleCursor does implement sampleLocation, implementing loadSampleBufferContainingSamplesToEndCursor is optional. Important note: If there is a change of format description between the receiver and endSampleCursor, the returned sample buffer must contain only the contiguous samples with the same format description as the first sample. If there is no sample data between cursor and endSampleCursor, this method should return an empty sample buffer. This method should only provide a NULL sample buffer when there is an error.
1096        ///
1097        /// Parameter `endSampleCursor`: If not nil, indicates the last sample that the new sample buffer should contain. If endSampleCursor refers to a sample earlier than the receiver, this method should fail and return MEErrorNoSamples as error code. If endSampleCursor is nil or refers to the same sample as the receiver, only a single sample should be returned in the new sample buffer.
1098        ///
1099        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
1100        /// 'newSampleBuffer'
1101        /// A CMSampleBufferRef with the newly created sample buffer. If the sample cursor is implemented in Objective-C, it is the responsibility of the sample cursor implementation to balance the creation of this sample buffer by calling CFRelease.
1102        /// 'error'
1103        /// An NSError object that will contain error information if the method fails, otherwise nil.
1104        #[optional]
1105        #[unsafe(method(loadSampleBufferContainingSamplesToEndCursor:completionHandler:))]
1106        #[unsafe(method_family = none)]
1107        unsafe fn loadSampleBufferContainingSamplesToEndCursor_completionHandler(
1108            &self,
1109            end_sample_cursor: Option<&ProtocolObject<dyn MESampleCursor>>,
1110            completion_handler: &block2::DynBlock<dyn Fn(*mut CMSampleBuffer, *mut NSError)>,
1111        );
1112
1113        #[cfg(feature = "block2")]
1114        /// Asynchronously loads a dictionary that represents frame level metadata for post decode processing.
1115        ///
1116        /// This method should provide either a valid NSDictionary or nil. If the method fails, the NSError will contain error information.
1117        /// The post decode processing metadata could either be contained in the media asset primary file or be located in a separate related "sidecar" file. If contained in a separate file with a different extension, that file extension should be included in the EXAppExtensionAttributes and UTExportedTypeDeclarations dictionaries in the MediaExtension format reader Info.plist. The metadata returned should contain sequence level metadata for post decode processing, along with optional frame level metadata if present.
1118        ///
1119        /// Parameter `completionHandler`: The handler that will be invoked when the method completes, or if it is nil.
1120        /// 'postDecodeProcessingMetadata'
1121        /// The returned NSDictionary should conform to a CFPropertyList.
1122        /// 'error'
1123        /// An NSError object that will contain error information if the method fails, otherwise nil.
1124        #[optional]
1125        #[unsafe(method(loadPostDecodeProcessingMetadataWithCompletionHandler:))]
1126        #[unsafe(method_family = none)]
1127        unsafe fn loadPostDecodeProcessingMetadataWithCompletionHandler(
1128            &self,
1129            completion_handler: &block2::DynBlock<
1130                dyn Fn(*mut NSDictionary<NSString, AnyObject>, *mut NSError),
1131            >,
1132        );
1133    }
1134);
1135
1136extern_class!(
1137    /// Provides information about the chunk of media where a sample is located.
1138    ///
1139    /// An instance of this class is returned by calls to the MESampleCursor method chunkDetails.
1140    ///
1141    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mesamplecursorchunk?language=objc)
1142    #[unsafe(super(NSObject))]
1143    #[derive(Debug, PartialEq, Eq, Hash)]
1144    pub struct MESampleCursorChunk;
1145);
1146
1147unsafe impl Send for MESampleCursorChunk {}
1148
1149unsafe impl Sync for MESampleCursorChunk {}
1150
1151extern_conformance!(
1152    unsafe impl NSCopying for MESampleCursorChunk {}
1153);
1154
1155unsafe impl CopyingHelper for MESampleCursorChunk {
1156    type Result = Self;
1157}
1158
1159extern_conformance!(
1160    unsafe impl NSObjectProtocol for MESampleCursorChunk {}
1161);
1162
1163impl MESampleCursorChunk {
1164    extern_methods!(
1165        #[unsafe(method(new))]
1166        #[unsafe(method_family = new)]
1167        pub unsafe fn new() -> Retained<Self>;
1168
1169        #[unsafe(method(init))]
1170        #[unsafe(method_family = init)]
1171        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1172
1173        #[cfg(all(feature = "objc2-av-foundation", feature = "objc2-core-foundation"))]
1174        /// The initializer for the MESampleCursorChunk class.
1175        ///
1176        /// Parameter `byteSource`: The MEByteSource to be used to read the data for the sample.
1177        ///
1178        /// Parameter `chunkStorageRange`: The offset location and length of the sample's chunk within the MEByteSource.
1179        ///
1180        /// Parameter `chunkInfo`: A completed AVSampleCursorChunkInfo with details about the chunk in the media.
1181        ///
1182        /// Parameter `sampleIndexWithinChunk`: The offset of the sample within the chunk, in samples.
1183        #[unsafe(method(initWithByteSource:chunkStorageRange:chunkInfo:sampleIndexWithinChunk:))]
1184        #[unsafe(method_family = init)]
1185        pub unsafe fn initWithByteSource_chunkStorageRange_chunkInfo_sampleIndexWithinChunk(
1186            this: Allocated<Self>,
1187            byte_source: &MEByteSource,
1188            chunk_storage_range: AVSampleCursorStorageRange,
1189            chunk_info: AVSampleCursorChunkInfo,
1190            sample_index_within_chunk: CFIndex,
1191        ) -> Retained<Self>;
1192
1193        /// The MEByteSource to be used to read the data for the sample.
1194        ///
1195        /// This property is not atomic.
1196        ///
1197        /// # Safety
1198        ///
1199        /// This might not be thread-safe.
1200        #[unsafe(method(byteSource))]
1201        #[unsafe(method_family = none)]
1202        pub unsafe fn byteSource(&self) -> Retained<MEByteSource>;
1203
1204        #[cfg(feature = "objc2-av-foundation")]
1205        /// The offset location and length of the sample's chunk, in bytes, within the MEByteSource.
1206        ///
1207        /// The length should be set to 0 if there is no chunk associated with the sample.
1208        ///
1209        /// This property is not atomic.
1210        ///
1211        /// # Safety
1212        ///
1213        /// This might not be thread-safe.
1214        #[unsafe(method(chunkStorageRange))]
1215        #[unsafe(method_family = none)]
1216        pub unsafe fn chunkStorageRange(&self) -> AVSampleCursorStorageRange;
1217
1218        #[cfg(feature = "objc2-av-foundation")]
1219        /// Provides information about the chunk of media samples.
1220        ///
1221        /// This property is not atomic.
1222        ///
1223        /// # Safety
1224        ///
1225        /// This might not be thread-safe.
1226        #[unsafe(method(chunkInfo))]
1227        #[unsafe(method_family = none)]
1228        pub unsafe fn chunkInfo(&self) -> AVSampleCursorChunkInfo;
1229
1230        #[cfg(feature = "objc2-core-foundation")]
1231        /// The offset of the sample within the chunk, in samples.
1232        ///
1233        /// Index value 0 corresponds to the start of the chunk. You would step back this many samples to position the cursor at the start of the chunk. Subtract from the chunkInfo.chunkSampleCount field to obtain the number of samples to the end of the chunk.
1234        ///
1235        /// This property is not atomic.
1236        ///
1237        /// # Safety
1238        ///
1239        /// This might not be thread-safe.
1240        #[unsafe(method(sampleIndexWithinChunk))]
1241        #[unsafe(method_family = none)]
1242        pub unsafe fn sampleIndexWithinChunk(&self) -> CFIndex;
1243    );
1244}
1245
1246extern_class!(
1247    /// Provides information about the sample location with the media.
1248    ///
1249    /// An instance of this class is returned by calls to the MESampleCursor method sampleLocation.
1250    ///
1251    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mesamplelocation?language=objc)
1252    #[unsafe(super(NSObject))]
1253    #[derive(Debug, PartialEq, Eq, Hash)]
1254    pub struct MESampleLocation;
1255);
1256
1257unsafe impl Send for MESampleLocation {}
1258
1259unsafe impl Sync for MESampleLocation {}
1260
1261extern_conformance!(
1262    unsafe impl NSCopying for MESampleLocation {}
1263);
1264
1265unsafe impl CopyingHelper for MESampleLocation {
1266    type Result = Self;
1267}
1268
1269extern_conformance!(
1270    unsafe impl NSObjectProtocol for MESampleLocation {}
1271);
1272
1273impl MESampleLocation {
1274    extern_methods!(
1275        #[unsafe(method(new))]
1276        #[unsafe(method_family = new)]
1277        pub unsafe fn new() -> Retained<Self>;
1278
1279        #[unsafe(method(init))]
1280        #[unsafe(method_family = init)]
1281        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1282
1283        #[cfg(feature = "objc2-av-foundation")]
1284        /// The initializer for the MESampleLocation class.
1285        ///
1286        /// Parameter `byteSource`: The MEByteSource to be used to read the data for the sample.
1287        ///
1288        /// Parameter `sampleLocation`: The starting file offset and size in bytes of the sample.
1289        #[unsafe(method(initWithByteSource:sampleLocation:))]
1290        #[unsafe(method_family = init)]
1291        pub unsafe fn initWithByteSource_sampleLocation(
1292            this: Allocated<Self>,
1293            byte_source: &MEByteSource,
1294            sample_location: AVSampleCursorStorageRange,
1295        ) -> Retained<Self>;
1296
1297        #[cfg(feature = "objc2-av-foundation")]
1298        /// The starting file offset and size in bytes of the sample.
1299        ///
1300        /// This property is not atomic.
1301        ///
1302        /// # Safety
1303        ///
1304        /// This might not be thread-safe.
1305        #[unsafe(method(sampleLocation))]
1306        #[unsafe(method_family = none)]
1307        pub unsafe fn sampleLocation(&self) -> AVSampleCursorStorageRange;
1308
1309        /// The MEByteSource to be used to read the data for the sample.
1310        ///
1311        /// This property is not atomic.
1312        ///
1313        /// # Safety
1314        ///
1315        /// This might not be thread-safe.
1316        #[unsafe(method(byteSource))]
1317        #[unsafe(method_family = none)]
1318        pub unsafe fn byteSource(&self) -> Retained<MEByteSource>;
1319    );
1320}
1321
1322extern_class!(
1323    /// Provides information about the estimated sample location with the media.
1324    ///
1325    /// An instance of this class is returned by calls to the MESampleCursor method estimatedSampleLocationReturningError.
1326    ///
1327    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/meestimatedsamplelocation?language=objc)
1328    #[unsafe(super(NSObject))]
1329    #[derive(Debug, PartialEq, Eq, Hash)]
1330    pub struct MEEstimatedSampleLocation;
1331);
1332
1333unsafe impl Send for MEEstimatedSampleLocation {}
1334
1335unsafe impl Sync for MEEstimatedSampleLocation {}
1336
1337extern_conformance!(
1338    unsafe impl NSCopying for MEEstimatedSampleLocation {}
1339);
1340
1341unsafe impl CopyingHelper for MEEstimatedSampleLocation {
1342    type Result = Self;
1343}
1344
1345extern_conformance!(
1346    unsafe impl NSObjectProtocol for MEEstimatedSampleLocation {}
1347);
1348
1349impl MEEstimatedSampleLocation {
1350    extern_methods!(
1351        #[unsafe(method(new))]
1352        #[unsafe(method_family = new)]
1353        pub unsafe fn new() -> Retained<Self>;
1354
1355        #[unsafe(method(init))]
1356        #[unsafe(method_family = init)]
1357        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1358
1359        #[cfg(feature = "objc2-av-foundation")]
1360        /// The initializer for the MEEstimatedSampleLocation class.
1361        ///
1362        /// Parameter `byteSource`: The MEByteSource to be used to read the data for the sample.
1363        ///
1364        /// Parameter `estimatedSampleLocation`: The estimated starting file offset and size in bytes of the sample.
1365        ///
1366        /// Parameter `refinementDataLocation`: The starting file offset and size in bytes of the the data necessary to provide an accurate sample location.
1367        #[unsafe(method(initWithByteSource:estimatedSampleLocation:refinementDataLocation:))]
1368        #[unsafe(method_family = init)]
1369        pub unsafe fn initWithByteSource_estimatedSampleLocation_refinementDataLocation(
1370            this: Allocated<Self>,
1371            byte_source: &MEByteSource,
1372            estimated_sample_location: AVSampleCursorStorageRange,
1373            refinement_data_location: AVSampleCursorStorageRange,
1374        ) -> Retained<Self>;
1375
1376        #[cfg(feature = "objc2-av-foundation")]
1377        /// The estimated starting file offset and size in bytes of the sample.
1378        ///
1379        /// This property is not atomic.
1380        ///
1381        /// # Safety
1382        ///
1383        /// This might not be thread-safe.
1384        #[unsafe(method(estimatedSampleLocation))]
1385        #[unsafe(method_family = none)]
1386        pub unsafe fn estimatedSampleLocation(&self) -> AVSampleCursorStorageRange;
1387
1388        #[cfg(feature = "objc2-av-foundation")]
1389        /// The starting file offset and size in bytes of the the data necessary to provide an accurate sample location.
1390        ///
1391        /// The refinement data can be provided to the MESampleCursor method refineSampleLocation to determine the exact sample location.
1392        ///
1393        /// This property is not atomic.
1394        ///
1395        /// # Safety
1396        ///
1397        /// This might not be thread-safe.
1398        #[unsafe(method(refinementDataLocation))]
1399        #[unsafe(method_family = none)]
1400        pub unsafe fn refinementDataLocation(&self) -> AVSampleCursorStorageRange;
1401
1402        /// The MEByteSource to be used to read the data for the sample.
1403        ///
1404        /// This property is not atomic.
1405        ///
1406        /// # Safety
1407        ///
1408        /// This might not be thread-safe.
1409        #[unsafe(method(byteSource))]
1410        #[unsafe(method_family = none)]
1411        pub unsafe fn byteSource(&self) -> Retained<MEByteSource>;
1412    );
1413}
1414
1415extern_class!(
1416    /// Provides information about the HEVC dependency attributes of a sample.
1417    ///
1418    /// An instance of this class is returned by MESampleCursor property hevcDependencyInfo.
1419    ///
1420    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mehevcdependencyinfo?language=objc)
1421    #[unsafe(super(NSObject))]
1422    #[derive(Debug, PartialEq, Eq, Hash)]
1423    pub struct MEHEVCDependencyInfo;
1424);
1425
1426unsafe impl Send for MEHEVCDependencyInfo {}
1427
1428unsafe impl Sync for MEHEVCDependencyInfo {}
1429
1430extern_conformance!(
1431    unsafe impl NSCopying for MEHEVCDependencyInfo {}
1432);
1433
1434unsafe impl CopyingHelper for MEHEVCDependencyInfo {
1435    type Result = Self;
1436}
1437
1438extern_conformance!(
1439    unsafe impl NSObjectProtocol for MEHEVCDependencyInfo {}
1440);
1441
1442impl MEHEVCDependencyInfo {
1443    extern_methods!(
1444        /// YES if the sample is an HEVC 'TSA' picture, NO otherwise.
1445        ///
1446        /// Maps to the kCMSampleAttachmentKey_HEVCTemporalSubLayerAccess sample buffer attachment.
1447        ///
1448        /// This property is not atomic.
1449        ///
1450        /// # Safety
1451        ///
1452        /// This might not be thread-safe.
1453        #[unsafe(method(hasTemporalSubLayerAccess))]
1454        #[unsafe(method_family = none)]
1455        pub unsafe fn hasTemporalSubLayerAccess(&self) -> bool;
1456
1457        /// Setter for [`hasTemporalSubLayerAccess`][Self::hasTemporalSubLayerAccess].
1458        ///
1459        /// # Safety
1460        ///
1461        /// This might not be thread-safe.
1462        #[unsafe(method(setTemporalSubLayerAccess:))]
1463        #[unsafe(method_family = none)]
1464        pub unsafe fn setTemporalSubLayerAccess(&self, temporal_sub_layer_access: bool);
1465
1466        /// YES if the sample is an HEVC 'STSA' picture, NO otherwise.
1467        ///
1468        /// Maps to the kCMSampleAttachmentKey_HEVCStepwiseTemporalSubLayerAccess sample buffer attachment.
1469        ///
1470        /// This property is not atomic.
1471        ///
1472        /// # Safety
1473        ///
1474        /// This might not be thread-safe.
1475        #[unsafe(method(hasStepwiseTemporalSubLayerAccess))]
1476        #[unsafe(method_family = none)]
1477        pub unsafe fn hasStepwiseTemporalSubLayerAccess(&self) -> bool;
1478
1479        /// Setter for [`hasStepwiseTemporalSubLayerAccess`][Self::hasStepwiseTemporalSubLayerAccess].
1480        ///
1481        /// # Safety
1482        ///
1483        /// This might not be thread-safe.
1484        #[unsafe(method(setStepwiseTemporalSubLayerAccess:))]
1485        #[unsafe(method_family = none)]
1486        pub unsafe fn setStepwiseTemporalSubLayerAccess(
1487            &self,
1488            stepwise_temporal_sub_layer_access: bool,
1489        );
1490
1491        /// The NAL unit type for HEVC 'sync' sample groups, or -1 if this information is not available.
1492        ///
1493        /// Maps to the kCMSampleAttachmentKey_HEVCSyncSampleNALUnitType sample buffer attachment.
1494        ///
1495        /// This property is not atomic.
1496        ///
1497        /// # Safety
1498        ///
1499        /// This might not be thread-safe.
1500        #[unsafe(method(syncSampleNALUnitType))]
1501        #[unsafe(method_family = none)]
1502        pub unsafe fn syncSampleNALUnitType(&self) -> i16;
1503
1504        /// Setter for [`syncSampleNALUnitType`][Self::syncSampleNALUnitType].
1505        ///
1506        /// # Safety
1507        ///
1508        /// This might not be thread-safe.
1509        #[unsafe(method(setSyncSampleNALUnitType:))]
1510        #[unsafe(method_family = none)]
1511        pub unsafe fn setSyncSampleNALUnitType(&self, sync_sample_nal_unit_type: i16);
1512    );
1513}
1514
1515/// Methods declared on superclass `NSObject`.
1516impl MEHEVCDependencyInfo {
1517    extern_methods!(
1518        #[unsafe(method(init))]
1519        #[unsafe(method_family = init)]
1520        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1521
1522        #[unsafe(method(new))]
1523        #[unsafe(method_family = new)]
1524        pub unsafe fn new() -> Retained<Self>;
1525    );
1526}
1527
1528/// HEVCTemporalLevelInfo.
1529///
1530/// Indicates a video frame's level within a hierarchical frame dependency structure.
1531///
1532/// The properties here map to the kCMSampleAttachmentKey_HEVCTemporalLevelInfo sample buffer attachment dictionary.
1533impl MEHEVCDependencyInfo {
1534    extern_methods!(
1535        /// The HEVC temporal level, or -1 if this information is not available.
1536        ///
1537        /// Maps to the kCMHEVCTemporalLevelInfoKey_TemporalLevel sample buffer attachment.
1538        ///
1539        /// This property is not atomic.
1540        ///
1541        /// # Safety
1542        ///
1543        /// This might not be thread-safe.
1544        #[unsafe(method(temporalLevel))]
1545        #[unsafe(method_family = none)]
1546        pub unsafe fn temporalLevel(&self) -> i16;
1547
1548        /// Setter for [`temporalLevel`][Self::temporalLevel].
1549        ///
1550        /// # Safety
1551        ///
1552        /// This might not be thread-safe.
1553        #[unsafe(method(setTemporalLevel:))]
1554        #[unsafe(method_family = none)]
1555        pub unsafe fn setTemporalLevel(&self, temporal_level: i16);
1556
1557        /// The HEVC profile space, or -1 if this information is not available.
1558        ///
1559        /// Maps to the kCMHEVCTemporalLevelInfoKey_ProfileSpace sample buffer attachment.
1560        ///
1561        /// This property is not atomic.
1562        ///
1563        /// # Safety
1564        ///
1565        /// This might not be thread-safe.
1566        #[unsafe(method(profileSpace))]
1567        #[unsafe(method_family = none)]
1568        pub unsafe fn profileSpace(&self) -> i16;
1569
1570        /// Setter for [`profileSpace`][Self::profileSpace].
1571        ///
1572        /// # Safety
1573        ///
1574        /// This might not be thread-safe.
1575        #[unsafe(method(setProfileSpace:))]
1576        #[unsafe(method_family = none)]
1577        pub unsafe fn setProfileSpace(&self, profile_space: i16);
1578
1579        /// The HEVC tier level flag, or -1 if this information is not available.
1580        ///
1581        /// Maps to the kCMHEVCTemporalLevelInfoKey_TierFlag sample buffer attachment.
1582        ///
1583        /// This property is not atomic.
1584        ///
1585        /// # Safety
1586        ///
1587        /// This might not be thread-safe.
1588        #[unsafe(method(tierFlag))]
1589        #[unsafe(method_family = none)]
1590        pub unsafe fn tierFlag(&self) -> i16;
1591
1592        /// Setter for [`tierFlag`][Self::tierFlag].
1593        ///
1594        /// # Safety
1595        ///
1596        /// This might not be thread-safe.
1597        #[unsafe(method(setTierFlag:))]
1598        #[unsafe(method_family = none)]
1599        pub unsafe fn setTierFlag(&self, tier_flag: i16);
1600
1601        /// The HEVC profile index, or -1 if this information is not available.
1602        ///
1603        /// Maps to the kCMHEVCTemporalLevelInfoKey_ProfileIndex sample buffer attachment.
1604        ///
1605        /// This property is not atomic.
1606        ///
1607        /// # Safety
1608        ///
1609        /// This might not be thread-safe.
1610        #[unsafe(method(profileIndex))]
1611        #[unsafe(method_family = none)]
1612        pub unsafe fn profileIndex(&self) -> i16;
1613
1614        /// Setter for [`profileIndex`][Self::profileIndex].
1615        ///
1616        /// # Safety
1617        ///
1618        /// This might not be thread-safe.
1619        #[unsafe(method(setProfileIndex:))]
1620        #[unsafe(method_family = none)]
1621        pub unsafe fn setProfileIndex(&self, profile_index: i16);
1622
1623        /// The HEVC profile compatibility flags (4 bytes), or nil of this information is not available.
1624        ///
1625        /// Maps to the kCMHEVCTemporalLevelInfoKey_ProfileCompatibilityFlags sample buffer attachment.
1626        ///
1627        /// This property is not atomic.
1628        ///
1629        /// # Safety
1630        ///
1631        /// This might not be thread-safe.
1632        #[unsafe(method(profileCompatibilityFlags))]
1633        #[unsafe(method_family = none)]
1634        pub unsafe fn profileCompatibilityFlags(&self) -> Option<Retained<NSData>>;
1635
1636        /// Setter for [`profileCompatibilityFlags`][Self::profileCompatibilityFlags].
1637        ///
1638        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1639        ///
1640        /// # Safety
1641        ///
1642        /// This might not be thread-safe.
1643        #[unsafe(method(setProfileCompatibilityFlags:))]
1644        #[unsafe(method_family = none)]
1645        pub unsafe fn setProfileCompatibilityFlags(
1646            &self,
1647            profile_compatibility_flags: Option<&NSData>,
1648        );
1649
1650        /// The HEVC constraint indicator flags (6 bytes), or nil of this information is not available.
1651        ///
1652        /// Maps to the kCMHEVCTemporalLevelInfoKey_ConstraintIndicatorFlags sample buffer attachment.
1653        ///
1654        /// This property is not atomic.
1655        ///
1656        /// # Safety
1657        ///
1658        /// This might not be thread-safe.
1659        #[unsafe(method(constraintIndicatorFlags))]
1660        #[unsafe(method_family = none)]
1661        pub unsafe fn constraintIndicatorFlags(&self) -> Option<Retained<NSData>>;
1662
1663        /// Setter for [`constraintIndicatorFlags`][Self::constraintIndicatorFlags].
1664        ///
1665        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1666        ///
1667        /// # Safety
1668        ///
1669        /// This might not be thread-safe.
1670        #[unsafe(method(setConstraintIndicatorFlags:))]
1671        #[unsafe(method_family = none)]
1672        pub unsafe fn setConstraintIndicatorFlags(
1673            &self,
1674            constraint_indicator_flags: Option<&NSData>,
1675        );
1676
1677        /// The HEVC level index, or -1 if this information is not available.
1678        ///
1679        /// Maps to the kCMHEVCTemporalLevelInfoKey_LevelIndex sample buffer attachment.
1680        ///
1681        /// This property is not atomic.
1682        ///
1683        /// # Safety
1684        ///
1685        /// This might not be thread-safe.
1686        #[unsafe(method(levelIndex))]
1687        #[unsafe(method_family = none)]
1688        pub unsafe fn levelIndex(&self) -> i16;
1689
1690        /// Setter for [`levelIndex`][Self::levelIndex].
1691        ///
1692        /// # Safety
1693        ///
1694        /// This might not be thread-safe.
1695        #[unsafe(method(setLevelIndex:))]
1696        #[unsafe(method_family = none)]
1697        pub unsafe fn setLevelIndex(&self, level_index: i16);
1698    );
1699}
1700
1701extern_class!(
1702    /// Provides read access to the data in a media asset file.
1703    ///
1704    /// The Media Toolbox passes an MEByteSource instance for the media asset's primary file when initializing an MEFormatReader object. The MEFormatReader may request additional MEByteSources be created for related files in the same directory as the primary file by calling the byteSourceForRelatedFileName method.
1705    ///
1706    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediaextension/mebytesource?language=objc)
1707    #[unsafe(super(NSObject))]
1708    #[derive(Debug, PartialEq, Eq, Hash)]
1709    pub struct MEByteSource;
1710);
1711
1712unsafe impl Send for MEByteSource {}
1713
1714unsafe impl Sync for MEByteSource {}
1715
1716extern_conformance!(
1717    unsafe impl NSObjectProtocol for MEByteSource {}
1718);
1719
1720impl MEByteSource {
1721    extern_methods!(
1722        #[unsafe(method(new))]
1723        #[unsafe(method_family = new)]
1724        pub unsafe fn new() -> Retained<Self>;
1725
1726        #[unsafe(method(init))]
1727        #[unsafe(method_family = init)]
1728        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1729
1730        /// The name of a MEByteSource's file.
1731        ///
1732        /// The name of the source file for the MEByteSource.
1733        ///
1734        /// This property is not atomic.
1735        ///
1736        /// # Safety
1737        ///
1738        /// This might not be thread-safe.
1739        #[unsafe(method(fileName))]
1740        #[unsafe(method_family = none)]
1741        pub unsafe fn fileName(&self) -> Retained<NSString>;
1742
1743        #[cfg(feature = "objc2-uniform-type-identifiers")]
1744        /// A UTType indicating the format of the MEByteSource's file.
1745        ///
1746        /// A UTType indicating the format of the source file for the MEByteSource.
1747        ///
1748        /// This property is not atomic.
1749        ///
1750        /// # Safety
1751        ///
1752        /// This might not be thread-safe.
1753        #[unsafe(method(contentType))]
1754        #[unsafe(method_family = none)]
1755        pub unsafe fn contentType(&self) -> Option<Retained<UTType>>;
1756
1757        /// The length of the MEByteSource's file.
1758        ///
1759        /// The length in bytes of the source file for the MEByteSource, or 0 if that information is not available.
1760        ///
1761        /// This property is not atomic.
1762        ///
1763        /// # Safety
1764        ///
1765        /// This might not be thread-safe.
1766        #[unsafe(method(fileLength))]
1767        #[unsafe(method_family = none)]
1768        pub unsafe fn fileLength(&self) -> i64;
1769
1770        /// The array of related file names in the MEByteSource's parent directory.
1771        ///
1772        /// The array of related files within the MEByteSource's parent directory that are accessible to the MEByteSource. Only the relative file names are returned, not the paths. If no related files are available, returns an empty array.
1773        ///
1774        /// This property is not atomic.
1775        ///
1776        /// # Safety
1777        ///
1778        /// This might not be thread-safe.
1779        #[unsafe(method(relatedFileNamesInSameDirectory))]
1780        #[unsafe(method_family = none)]
1781        pub unsafe fn relatedFileNamesInSameDirectory(&self) -> Retained<NSArray<NSString>>;
1782
1783        #[cfg(feature = "block2")]
1784        /// Reads bytes from an MEByteSource asynchronously into a buffer.
1785        ///
1786        /// Asynchronously reads out the specified number of bytes starting at the indicated offset. Returns the actual number of bytes read out in bytesRead. Read attempts that extend beyond the end of the MEByteSource will succeed if they include at least one valid byte before the end of the MEByteSource.
1787        ///
1788        /// Parameter `length`: The number of bytes to read.
1789        ///
1790        /// Parameter `offset`: The relative offset in bytes from the beginning of the file from which to start reading.
1791        ///
1792        /// Parameter `dest`: The block of memory to hold the data to be read.  Must be at least num bytes in length.
1793        ///
1794        /// Parameter `completionHandler`: The handler that will be invoked when the method completes.
1795        /// 'bytesRead'
1796        /// The actual number of bytes read.
1797        /// 'error'
1798        /// An NSError object that will contain error information if the method fails, otherwise nil. Returns MEErrorEndOfStream if no more bytes can be read.
1799        ///
1800        /// # Safety
1801        ///
1802        /// `dest` must be a valid pointer.
1803        #[unsafe(method(readDataOfLength:fromOffset:toDestination:completionHandler:))]
1804        #[unsafe(method_family = none)]
1805        pub unsafe fn readDataOfLength_fromOffset_toDestination_completionHandler(
1806            &self,
1807            length: usize,
1808            offset: i64,
1809            dest: NonNull<c_void>,
1810            completion_handler: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
1811        );
1812
1813        #[cfg(feature = "block2")]
1814        /// Reads bytes from an MEByteSource asynchronously into an NSData object.
1815        ///
1816        /// Asynchronously reads out the specified number of bytes starting at the indicated offset. Returns the actual number of bytes read out in bytesRead. Read attempts that extend beyond the end of the MEByteSource will succeed if they include at least one valid byte before the end of the MEByteSource.
1817        ///
1818        /// Parameter `length`: The number of bytes to read.
1819        ///
1820        /// Parameter `offset`: The relative offset in bytes from the beginning of the file from which to start reading.
1821        ///
1822        /// Parameter `completionHandler`: Completion block called when the method completes.
1823        /// 'data'
1824        /// The NSData object holding the data that have been read. The NSData length property will indicate the actual number of bytes read.
1825        /// 'error'
1826        /// An NSError object that will contain error information if the method fails, otherwise nil. Returns MEErrorEndOfStream if no more bytes can be read.
1827        #[unsafe(method(readDataOfLength:fromOffset:completionHandler:))]
1828        #[unsafe(method_family = none)]
1829        pub unsafe fn readDataOfLength_fromOffset_completionHandler(
1830            &self,
1831            length: usize,
1832            offset: i64,
1833            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
1834        );
1835
1836        /// Reads bytes from an MEByteSource synchronously into a buffer.
1837        ///
1838        /// Synchronously reads out the specified number of bytes starting at the indicated offset. Returns the actual number of bytes read out in bytesReadOut. Read attempts that extend beyond the end of the MEByteSource will succeed if they include at least one valid byte before the end of the MEByteSource.
1839        ///
1840        /// Parameter `length`: The number of bytes to read.
1841        ///
1842        /// Parameter `offset`: The relative offset in bytes from the beginning of the file from which to start reading.
1843        ///
1844        /// Parameter `dest`: The block of memory to hold the data to be read.  Must be at least num bytes in length.
1845        ///
1846        /// Parameter `bytesReadOut`: The actual number of bytes read.
1847        ///
1848        /// Parameter `error`: Reports any errors. Returns MEErrorEndOfStream if no more bytes can be read.
1849        ///
1850        /// Returns: Returns YES if successful, NO if an error occured.
1851        ///
1852        /// # Safety
1853        ///
1854        /// - `dest` must be a valid pointer.
1855        /// - `bytes_read_out` must be a valid pointer.
1856        #[unsafe(method(readDataOfLength:fromOffset:toDestination:bytesRead:error:_))]
1857        #[unsafe(method_family = none)]
1858        pub unsafe fn readDataOfLength_fromOffset_toDestination_bytesRead_error(
1859            &self,
1860            length: usize,
1861            offset: i64,
1862            dest: NonNull<c_void>,
1863            bytes_read_out: NonNull<usize>,
1864        ) -> Result<(), Retained<NSError>>;
1865
1866        /// Returns the number of available bytes from the offset within the MEByteSource.
1867        ///
1868        /// Returns the number of available bytes at the time of the query. This value could change over time. Attempting to read past this value may cause slow I/O.
1869        ///
1870        /// Parameter `offset`: The offset in bytes from the beginning of the MEByteSource.
1871        ///
1872        /// Returns: Returns the number of available bytes from the offset, or 0 if that information is not available.
1873        #[unsafe(method(availableLengthAtOffset:))]
1874        #[unsafe(method_family = none)]
1875        pub unsafe fn availableLengthAtOffset(&self, offset: i64) -> i64;
1876
1877        /// Requests creation of a new MEByteSource for a related file.
1878        ///
1879        /// Requests creation of a new MEByteSource for a file related to the receiving MEByteSource. The scope of fileName that may be opened is restricted. Only files in the same directory as the receiver MEByteSource may be accessed, and the file extension must match one of the extensions listed in the format reader bundle plist.
1880        ///
1881        /// Parameter `fileName`: The relative file name in the receiver MEByteSource's parent directory.
1882        ///
1883        /// Parameter `errorOut`: Reports any errors. Returns MEErrorPermissionDenied if the file cannot be accessed or is prohibited.
1884        ///
1885        /// Returns: Returns nil if fileName refers to a file that cannot be accessed or is prohibited, or if an error occured. The returned MEByteSource is autoreleased.
1886        #[unsafe(method(byteSourceForRelatedFileName:error:_))]
1887        #[unsafe(method_family = none)]
1888        pub unsafe fn byteSourceForRelatedFileName_error(
1889            &self,
1890            file_name: &NSString,
1891        ) -> Result<Retained<MEByteSource>, Retained<NSError>>;
1892    );
1893}