objc2-av-foundation 0.3.2

Bindings to the AVFoundation framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
#[cfg(feature = "objc2-core-video")]
use objc2_core_video::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutput?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemOutput;
);

unsafe impl Send for AVPlayerItemOutput {}

unsafe impl Sync for AVPlayerItemOutput {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerItemOutput {}
);

impl AVPlayerItemOutput {
    extern_methods!(
        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
        /// Convert a host time, expressed in seconds, to item time.
        ///
        /// Converts a host time value (for example a CADisplayLink timestamp, or the value returned by CACurrentMediaTime()) to the equivalent time on the item's timebase.
        ///
        /// Note: The Core Animation CADisplayLink timestamp property expresses the most recent, or previous, screen refresh time. You need to increment this timestamp by the CADisplayLink's duration property to find the next appropriate item time.
        ///
        /// Parameter `hostTimeInSeconds`: The timestamp value to convert to item time.
        ///
        /// Returns: The equivalent item time.
        #[unsafe(method(itemTimeForHostTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn itemTimeForHostTime(&self, host_time_in_seconds: CFTimeInterval) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Convenience method to convert a Mach host time to item time.
        ///
        /// Converts Mach host time to the equivalent time on the item's timebase.
        /// mach_absolute_time() returns time awake since boot in system-specific rational units that can be queried by calling mach_timebase_info().
        ///
        /// Parameter `machAbsoluteTime`: The Mach host time to convert to item time.
        ///
        /// Returns: The equivalent item time.
        #[unsafe(method(itemTimeForMachAbsoluteTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn itemTimeForMachAbsoluteTime(&self, mach_absolute_time: i64) -> CMTime;

        #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
        /// Convenience method to convert a CoreVideo timestamp to the equivalent time on the item's timebase.
        ///
        /// Note: A CVDisplayLink provides a parameter inOutputTimestamp that expresses a future screen refresh time. You can use this value directly to find the next appropriate item time.
        /// Use `itemTimeForHostTime` if you were using this method previously to find the item time and have to switch over due to CVDisplayLink deprecation.
        ///
        /// Parameter `timestamp`: The CoreVideo timestamp value to convert to item time.
        ///
        /// Returns: The equivalent item time.
        #[unsafe(method(itemTimeForCVTimeStamp:))]
        #[unsafe(method_family = none)]
        pub unsafe fn itemTimeForCVTimeStamp(&self, timestamp: CVTimeStamp) -> CMTime;

        /// Indicates whether the output, when added to an AVPlayerItem, will be used in addition to normal rendering of media data by the player or instead of normal rendering.
        ///
        /// The default value is NO, indicating that the output will be used in addition to normal rendering. If you want to render the media data provided by the output yourself instead of allowing it to be rendered as in normally would be by AVPlayer, set suppressesPlayerRendering to YES.
        ///
        /// Whenever any output is added to an AVPlayerItem that has suppressesPlayerRendering set to YES, the media data supplied to the output will not be rendered by AVPlayer. Other media data associated with the item but not provided to such an output is not affected. For example, if an output of class AVPlayerItemVideoOutput with a value of YES for suppressesPlayerRendering is added to an AVPlayerItem, video media for that item will not be rendered by the AVPlayer, while audio media, subtitle media, and other kinds of media, if present, will be rendered.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(suppressesPlayerRendering))]
        #[unsafe(method_family = none)]
        pub unsafe fn suppressesPlayerRendering(&self) -> bool;

        /// Setter for [`suppressesPlayerRendering`][Self::suppressesPlayerRendering].
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setSuppressesPlayerRendering:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSuppressesPlayerRendering(&self, suppresses_player_rendering: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerItemOutput {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemvideooutput?language=objc)
    #[unsafe(super(AVPlayerItemOutput, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemVideoOutput;
);

unsafe impl Send for AVPlayerItemVideoOutput {}

unsafe impl Sync for AVPlayerItemVideoOutput {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerItemVideoOutput {}
);

impl AVPlayerItemVideoOutput {
    extern_methods!(
        /// Returns an instance of AVPlayerItemVideoOutput, initialized with the specified pixel buffer attributes, for video image output.
        ///
        /// Parameter `pixelBufferAttributes`: The client requirements for output CVPixelBuffers, expressed using the constants in
        /// <CoreVideo
        /// /CVPixelBuffer.h>.
        ///
        /// Returns: An instance of AVPlayerItemVideoOutput.
        ///
        /// # Safety
        ///
        /// `pixel_buffer_attributes` generic should be of the correct type.
        #[unsafe(method(initWithPixelBufferAttributes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPixelBufferAttributes(
            this: Allocated<Self>,
            pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Returns an instance of AVPlayerItemVideoOutput, initialized with the specified output settings, for video image output.
        ///
        /// Parameter `outputSettings`: The client requirements for output CVPixelBuffers, expressed using the constants in AVVideoSettings.h.
        ///
        /// For uncompressed video output, start with kCVPixelBuffer* keys in
        /// <CoreVideo
        /// /CVPixelBuffer.h>.
        ///
        /// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
        ///
        /// AVVideoAllowWideColorKey
        ///
        ///
        /// Returns: An instance of AVPlayerItemVideoOutput.
        ///
        /// This method throws an exception for any of the following reasons:
        /// - the output settings dictionary is empty
        /// - the settings will yield compressed output
        /// - the settings do not honor the requirements listed above for outputSettings
        ///
        /// # Safety
        ///
        /// `output_settings` generic should be of the correct type.
        #[unsafe(method(initWithOutputSettings:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithOutputSettings(
            this: Allocated<Self>,
            output_settings: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-media")]
        /// Query if any new video output is available for an item time.
        ///
        /// This method returns YES if there is available video output, appropriate for display, at the specified item time not marked as acquired. If you require multiple objects to acquire video output from the same AVPlayerItem, you should instantiate more than one AVPlayerItemVideoOutput and add each via addOutput:. Each AVPlayerItemVideoOutput maintains a separate record of client acquisition.
        ///
        /// Parameter `itemTime`: The item time to query.
        ///
        /// Returns: A BOOL indicating if there is newer output.
        #[unsafe(method(hasNewPixelBufferForItemTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasNewPixelBufferForItemTime(&self, item_time: CMTime) -> bool;

        #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
        /// Retrieves an image that is appropriate for display at the specified item time, and marks the image as acquired.
        ///
        /// The client is responsible for calling CVBufferRelease on the returned CVPixelBuffer when finished with it.
        ///
        /// Typically you would call this method in response to a CADisplayLink delegate invocation and if hasNewPixelBufferForItemTime: also returns YES.
        ///
        /// The buffer reference retrieved from copyPixelBufferForItemTime:itemTimeForDisplay: may itself be NULL. A reference to a NULL pixel buffer communicates that nothing should be displayed for the supplied item time.
        ///
        /// Parameter `itemTime`: A CMTime that expresses a desired item time.
        ///
        /// Parameter `itemTimeForDisplay`: A CMTime pointer whose value will contain the true display deadline for the copied pixel buffer. Can be NULL.
        ///
        /// # Safety
        ///
        /// `out_item_time_for_display` must be a valid pointer or null.
        #[unsafe(method(copyPixelBufferForItemTime:itemTimeForDisplay:))]
        #[unsafe(method_family = copy)]
        pub unsafe fn copyPixelBufferForItemTime_itemTimeForDisplay(
            &self,
            item_time: CMTime,
            out_item_time_for_display: *mut CMTime,
        ) -> Option<Retained<CVPixelBuffer>>;

        #[cfg(feature = "dispatch2")]
        /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
        ///
        /// Parameter `delegate`: An object conforming to AVPlayerItemOutputPullDelegate protocol.
        ///
        /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
        ///
        /// # Safety
        ///
        /// `delegate_queue` possibly has additional threading requirements.
        #[unsafe(method(setDelegate:queue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate_queue(
            &self,
            delegate: Option<&ProtocolObject<dyn AVPlayerItemOutputPullDelegate>>,
            delegate_queue: Option<&DispatchQueue>,
        );

        /// Informs the receiver that the AVPlayerItemVideoOutput client is entering a quiescent state.
        ///
        /// Parameter `interval`: A wall clock time interval.
        ///
        /// Message this method before you suspend your use of a CADisplayLink. The interval you provide will be used to message your delegate, in advance, that it should resume the display link. If the interval you provide is large, effectively requesting wakeup earlier than the AVPlayerItemVideoOutput is prepared to act, the delegate will be invoked as soon as possible. Do not use this method to force a delegate invocation for each sample.
        #[unsafe(method(requestNotificationOfMediaDataChangeWithAdvanceInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestNotificationOfMediaDataChangeWithAdvanceInterval(
            &self,
            interval: NSTimeInterval,
        );

        /// The receiver's delegate.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemOutputPullDelegate>>>;

        #[cfg(feature = "dispatch2")]
        /// The dispatch queue where the delegate is messaged.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegateQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerItemVideoOutput {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// Defines common delegate methods for objects participating in AVPlayerItemOutput pull sample output acquisition.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutputpulldelegate?language=objc)
    pub unsafe trait AVPlayerItemOutputPullDelegate: NSObjectProtocol + Send + Sync {
        /// A method invoked once, prior to a new sample, if the AVPlayerItemOutput sender was previously messaged requestNotificationOfMediaDataChangeWithAdvanceInterval:.
        ///
        /// This method is invoked once after the sender is messaged requestNotificationOfMediaDataChangeWithAdvanceInterval:.
        #[optional]
        #[unsafe(method(outputMediaDataWillChange:))]
        #[unsafe(method_family = none)]
        unsafe fn outputMediaDataWillChange(&self, sender: &AVPlayerItemOutput);

        /// A method invoked when the output is commencing a new sequence.
        ///
        /// This method is invoked after any seeking and change in playback direction. If you are maintaining any queued future samples, copied previously, you may want to discard these after receiving this message.
        #[optional]
        #[unsafe(method(outputSequenceWasFlushed:))]
        #[unsafe(method_family = none)]
        unsafe fn outputSequenceWasFlushed(&self, output: &AVPlayerItemOutput);
    }
);

extern_class!(
    /// A subclass of AVPlayerItemOutput that can vend media with a legible characteristic as NSAttributedStrings.
    ///
    /// An instance of AVPlayerItemLegibleOutput is typically initialized using the -init method.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutput?language=objc)
    #[unsafe(super(AVPlayerItemOutput, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemLegibleOutput;
);

unsafe impl Send for AVPlayerItemLegibleOutput {}

unsafe impl Sync for AVPlayerItemLegibleOutput {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerItemLegibleOutput {}
);

impl AVPlayerItemLegibleOutput {
    extern_methods!(
        #[cfg(feature = "dispatch2")]
        /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
        ///
        /// Parameter `delegate`: An object conforming to AVPlayerItemLegibleOutputPushDelegate protocol.
        ///
        /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
        ///
        /// The delegate is held using a zeroing-weak reference, so it is safe to deallocate the delegate while the receiver still has a reference to it.
        ///
        /// # Safety
        ///
        /// `delegate_queue` possibly has additional threading requirements.
        #[unsafe(method(setDelegate:queue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate_queue(
            &self,
            delegate: Option<&ProtocolObject<dyn AVPlayerItemLegibleOutputPushDelegate>>,
            delegate_queue: Option<&DispatchQueue>,
        );

        /// The receiver's delegate.
        ///
        /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated.  This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemLegibleOutputPushDelegate>>>;

        #[cfg(feature = "dispatch2")]
        /// The dispatch queue where the delegate is messaged.
        ///
        /// This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegateQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;

        /// Permits advance invocation of the associated delegate, if any.
        ///
        /// If it is possible, an AVPlayerItemLegibleOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemLegibleOutput is prepared to act on them, the delegate will be invoked as soon as possible.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(advanceIntervalForDelegateInvocation))]
        #[unsafe(method_family = none)]
        pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;

        /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAdvanceIntervalForDelegateInvocation(
            &self,
            advance_interval_for_delegate_invocation: NSTimeInterval,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerItemLegibleOutput {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// AVPlayerItemLegibleOutput_NativeRepresentation.
impl AVPlayerItemLegibleOutput {
    extern_methods!(
        /// Returns an instance of AVPlayerItemLegibleOutput with filtering enabled for AVPlayerItemLegibleOutputPushDelegate's legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:.
        ///
        /// Parameter `subtypes`: NSArray of NSNumber FourCC codes, e.g.
        /// @
        /// [ [NSNumber numberWithUnsignedInt:'tx3g'] ]
        ///
        /// Returns: An instance of AVPlayerItemLegibleOutput.
        ///
        /// Add media subtype FourCC number objects to the subtypes array to elect to receive that type as a CMSampleBuffer instead of an NSAttributedString.  Initializing an AVPlayerItemLegibleOutput using the -init method is equivalent to calling -initWithMediaSubtypesForNativeRepresentation: with an empty array, which means that all legible data, regardless of media subtype, will be delivered using NSAttributedString in a common format.
        ///
        /// If a media subtype for which there is no legible data in the current player item is included in the media subtypes array, no error will occur.  AVPlayerItemLegibleOutput will not vend closed caption data as CMSampleBuffers, so it is an error to include 'c608' in the media subtypes array.
        ///
        /// This method throws an exception if any media subtype is kCMClosedCaptionFormatType_CEA608 (native representation is not available for media subtype).
        #[unsafe(method(initWithMediaSubtypesForNativeRepresentation:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithMediaSubtypesForNativeRepresentation(
            this: Allocated<Self>,
            subtypes: &NSArray<NSNumber>,
        ) -> Retained<Self>;
    );
}

/// The type of a text styling resolution.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolution?language=objc)
// NS_TYPED_ENUM
pub type AVPlayerItemLegibleOutputTextStylingResolution = NSString;

extern "C" {
    /// Specify this level of text styling resolution to receive attributed strings from an AVPlayerItemLegibleOutput that include the same level of styling information that AVFoundation would use itself to render text within an AVPlayerLayer. The text styling will accommodate user-level Media Accessibility settings.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolutiondefault?language=objc)
    pub static AVPlayerItemLegibleOutputTextStylingResolutionDefault:
        &'static AVPlayerItemLegibleOutputTextStylingResolution;
}

extern "C" {
    /// Specify this level of text styling resolution to receive only the styling present in the source media and the styling provided via AVPlayerItem.textStyleRules.
    ///
    /// This level of resolution excludes styling provided by the user-level Media Accessibility settings. You would typically use it if you wish to override the styling specified in source media. If you do this, you are strongly encouraged to allow your custom styling in turn to be overriden by user preferences for text styling that are available as Media Accessibility settings.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolutionsourceandrulesonly?language=objc)
    pub static AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly:
        &'static AVPlayerItemLegibleOutputTextStylingResolution;
}

/// AVPlayerItemLegibleOutput_TextStylingResolution.
impl AVPlayerItemLegibleOutput {
    extern_methods!(
        /// A string identifier indicating the degree of text styling to be applied to attributed strings vended by the receiver
        ///
        /// Valid values are AVPlayerItemLegibleOutputTextStylingResolutionDefault and AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly.  An NSInvalidArgumentException is raised if this property is set to any other value.  The default value is AVPlayerItemLegibleOutputTextStylingResolutionDefault, which indicates that attributed strings vended by the receiver will include the same level of styling information that would be used if AVFoundation were rendering the text via AVPlayerLayer.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(textStylingResolution))]
        #[unsafe(method_family = none)]
        pub unsafe fn textStylingResolution(
            &self,
        ) -> Retained<AVPlayerItemLegibleOutputTextStylingResolution>;

        /// Setter for [`textStylingResolution`][Self::textStylingResolution].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setTextStylingResolution:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextStylingResolution(
            &self,
            text_styling_resolution: &AVPlayerItemLegibleOutputTextStylingResolution,
        );
    );
}

extern_protocol!(
    /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to attributed string output.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputpushdelegate?language=objc)
    pub unsafe trait AVPlayerItemLegibleOutputPushDelegate:
        AVPlayerItemOutputPushDelegate + Send + Sync
    {
        #[cfg(feature = "objc2-core-media")]
        /// A delegate callback that delivers new textual samples.
        ///
        /// Parameter `output`: The AVPlayerItemLegibleOutput source.
        ///
        /// Parameter `strings`: An NSArray of NSAttributedString, each containing both the run of text and descriptive markup.
        ///
        /// Parameter `nativeSamples`: An NSArray of CMSampleBuffer objects, for media subtypes included in the array passed in to -initWithMediaSubtypesForNativeRepresentation:
        ///
        /// Parameter `itemTime`: The item time at which the strings should be presented.
        ///
        /// For each media subtype in the array passed in to -initWithMediaSubtypesForNativeRepresentation:, the delegate will receive sample buffers carrying data in its native format via the nativeSamples parameter, if there is media data of that subtype in the media resource.  For all other media subtypes present in the media resource, the delegate will receive attributed strings in a common format via the strings parameter.  See
        /// <CoreMedia
        /// /CMTextMarkup.h> for the string attributes that are used in the attributed strings.
        ///
        /// # Safety
        ///
        /// `native_samples` generic should be of the correct type.
        #[optional]
        #[unsafe(method(legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:))]
        #[unsafe(method_family = none)]
        unsafe fn legibleOutput_didOutputAttributedStrings_nativeSampleBuffers_forItemTime(
            &self,
            output: &AVPlayerItemLegibleOutput,
            strings: &NSArray<NSAttributedString>,
            native_samples: &NSArray,
            item_time: CMTime,
        );
    }
);

extern_protocol!(
    /// Defines common delegate methods for objects participating in AVPlayerItemOutput push sample output acquisition.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutputpushdelegate?language=objc)
    pub unsafe trait AVPlayerItemOutputPushDelegate: NSObjectProtocol + Send + Sync {
        /// A method invoked when the output is commencing a new sequence of media data.
        ///
        /// This method is invoked after any seeking and change in playback direction. If you are maintaining any queued future media data, received previously, you may want to discard these after receiving this message.
        #[optional]
        #[unsafe(method(outputSequenceWasFlushed:))]
        #[unsafe(method_family = none)]
        unsafe fn outputSequenceWasFlushed(&self, output: &AVPlayerItemOutput);
    }
);

extern_class!(
    /// A subclass of AVPlayerItemOutput that vends collections of metadata items carried in metadata tracks.
    ///
    ///
    /// Setting the value of suppressesPlayerRendering on an instance of AVPlayerItemMetadataOutput has no effect.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemmetadataoutput?language=objc)
    #[unsafe(super(AVPlayerItemOutput, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemMetadataOutput;
);

unsafe impl Send for AVPlayerItemMetadataOutput {}

unsafe impl Sync for AVPlayerItemMetadataOutput {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerItemMetadataOutput {}
);

impl AVPlayerItemMetadataOutput {
    extern_methods!(
        /// Creates an instance of AVPlayerItemMetadataOutput.
        ///
        /// Parameter `identifiers`: A array of metadata identifiers indicating the metadata items that the output should provide.
        ///
        /// See AVMetadataIdentifiers.h for publicly defined metadata identifiers. Pass nil to receive all of the timed metadata from all enabled AVPlayerItemTracks that carry timed metadata.
        #[unsafe(method(initWithIdentifiers:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifiers(
            this: Allocated<Self>,
            identifiers: Option<&NSArray<NSString>>,
        ) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
        ///
        /// Parameter `delegate`: An object conforming to AVPlayerItemMetadataOutputPushDelegate protocol.
        ///
        /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
        ///
        /// # Safety
        ///
        /// `delegate_queue` possibly has additional threading requirements.
        #[unsafe(method(setDelegate:queue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate_queue(
            &self,
            delegate: Option<&ProtocolObject<dyn AVPlayerItemMetadataOutputPushDelegate>>,
            delegate_queue: Option<&DispatchQueue>,
        );

        /// The receiver's delegate.
        ///
        /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated.  This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemMetadataOutputPushDelegate>>>;

        #[cfg(feature = "dispatch2")]
        /// The dispatch queue on which messages are sent to the delegate.
        ///
        /// This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegateQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;

        /// Permits advance invocation of the associated delegate, if any.
        ///
        /// If it is possible, an AVPlayerItemMetadataOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemMetadataOutput is prepared to act on them, the delegate will be invoked as soon as possible.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(advanceIntervalForDelegateInvocation))]
        #[unsafe(method_family = none)]
        pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;

        /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAdvanceIntervalForDelegateInvocation(
            &self,
            advance_interval_for_delegate_invocation: NSTimeInterval,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerItemMetadataOutput {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to metadata output.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemmetadataoutputpushdelegate?language=objc)
    pub unsafe trait AVPlayerItemMetadataOutputPushDelegate:
        AVPlayerItemOutputPushDelegate + Send + Sync
    {
        #[cfg(all(feature = "AVPlayerItemTrack", feature = "AVTimedMetadataGroup"))]
        /// A delegate callback that delivers a new collection of metadata items.
        ///
        /// Parameter `output`: The AVPlayerItemMetadataOutput source.
        ///
        /// Parameter `groups`: An NSArray of AVTimedMetadataGroups that may contain metadata items with requested identifiers, according to the format descriptions associated with the underlying tracks.
        ///
        /// Parameter `track`: An instance of AVPlayerItemTrack that indicates the source of the metadata items in the group.
        ///
        /// Each group provided in a single invocation of this method will have timing that does not overlap with any other group in the array.
        /// Note that for some timed metadata formats carried by HTTP live streaming, the timeRange of each group must be reported as kCMTimeIndefinite, because its duration will be unknown until the next metadata group in the stream arrives. In these cases, the groups parameter will always contain a single group.
        /// Groups are typically packaged into arrays for delivery to your delegate according to the chunking or interleaving of the underlying metadata data.
        /// Note that if the item carries multiple metadata tracks containing metadata with the same metadata identifiers, this method can be invoked for each one separately, each with reference to the associated AVPlayerItemTrack.
        /// Note that the associated AVPlayerItemTrack parameter can be nil which implies that the metadata describes the asset as a whole, not just a single track of the asset.
        #[optional]
        #[unsafe(method(metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:))]
        #[unsafe(method_family = none)]
        unsafe fn metadataOutput_didOutputTimedMetadataGroups_fromPlayerItemTrack(
            &self,
            output: &AVPlayerItemMetadataOutput,
            groups: &NSArray<AVTimedMetadataGroup>,
            track: Option<&AVPlayerItemTrack>,
        );
    }
);

extern_class!(
    /// A subclass of AVPlayerItemOutput that can vend media with a legible characteristic as rendered CVPixelBufferRefs.
    ///
    /// An instance of AVPlayerItemRenderedLegibleOutput is initialized using the -init method.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemrenderedlegibleoutput?language=objc)
    #[unsafe(super(AVPlayerItemOutput, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemRenderedLegibleOutput;
);

unsafe impl Send for AVPlayerItemRenderedLegibleOutput {}

unsafe impl Sync for AVPlayerItemRenderedLegibleOutput {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerItemRenderedLegibleOutput {}
);

impl AVPlayerItemRenderedLegibleOutput {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Creates an instance of AVPlayerItemRenderedLegibleOutput.
        ///
        /// Parameter `videoDisplaySize`: CGSize for the video display area
        ///
        /// This is the only available initializer for AVPlayerItemRenderedLegibleOutput. The client can also choose to reset videoDisplaySize after initialization or during playback. Initializing and resetting videoDisplaySize with a zero height or width will result in an exception being thrown.
        #[unsafe(method(initWithVideoDisplaySize:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithVideoDisplaySize(
            this: Allocated<Self>,
            video_display_size: CGSize,
        ) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
        ///
        /// Parameter `delegate`: An object conforming to AVPlayerItemRenderedLegibleOutputPushDelegate protocol.
        ///
        /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
        ///
        /// The delegate is held using a zeroing-weak reference, so it is safe to deallocate the delegate while the receiver still has a reference to it.
        ///
        /// # Safety
        ///
        /// `delegate_queue` possibly has additional threading requirements.
        #[unsafe(method(setDelegate:queue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate_queue(
            &self,
            delegate: Option<&ProtocolObject<dyn AVPlayerItemRenderedLegibleOutputPushDelegate>>,
            delegate_queue: Option<&DispatchQueue>,
        );

        /// The receiver's delegate.
        ///
        /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated.  This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemRenderedLegibleOutputPushDelegate>>>;

        #[cfg(feature = "dispatch2")]
        /// The dispatch queue where the delegate is messaged.
        ///
        /// This property is not key-value observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(delegateQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;

        /// Permits advance invocation of the associated delegate, if any.
        ///
        /// If it is possible, an AVPlayerItemRenderedLegibleOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemRenderedLegibleOutput is prepared to act on them, the delegate will be invoked as soon as possible.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(advanceIntervalForDelegateInvocation))]
        #[unsafe(method_family = none)]
        pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;

        /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAdvanceIntervalForDelegateInvocation(
            &self,
            advance_interval_for_delegate_invocation: NSTimeInterval,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Permits rendering of pixel buffers according to the set width and height
        ///
        /// The client is expected to set videodisplay size during init and may also set it again during playback. The pixel buffers will be rendered according to the set width and height of display area. If this property is set during the presentation time of a vended caption image, a new caption image rendered according to new videoDisplaySize, will be vended out. Setting this property with a zero height or width will result in an exception being thrown and it is client's responsibility to handle it using appropriate catch block.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(videoDisplaySize))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoDisplaySize(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`videoDisplaySize`][Self::videoDisplaySize].
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(setVideoDisplaySize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVideoDisplaySize(&self, video_display_size: CGSize);
    );
}

extern_protocol!(
    /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to pixel buffers output.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemrenderedlegibleoutputpushdelegate?language=objc)
    pub unsafe trait AVPlayerItemRenderedLegibleOutputPushDelegate:
        AVPlayerItemOutputPushDelegate
    {
        #[cfg(all(feature = "AVRenderedCaptionImage", feature = "objc2-core-media"))]
        /// A delegate callback that delivers new rendered caption images
        ///
        /// Parameter `output`: The AVPlayerItemRenderedLegibleOutput source.
        ///
        /// Parameter `captionImages`: An NSArray of AVRenderedCaptionImage(s), consisting of a CVPixelBufferRef and its associated position (in pixels) relative to the video frame
        ///
        /// Parameter `itemTime`: The item time at which the caption images should be presented.
        #[optional]
        #[unsafe(method(renderedLegibleOutput:didOutputRenderedCaptionImages:forItemTime:))]
        #[unsafe(method_family = none)]
        unsafe fn renderedLegibleOutput_didOutputRenderedCaptionImages_forItemTime(
            &self,
            output: &AVPlayerItemRenderedLegibleOutput,
            caption_images: &NSArray<AVRenderedCaptionImage>,
            item_time: CMTime,
        );
    }
);