objc2_av_foundation/generated/
AVCaption.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-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12use objc2_foundation::*;
13
14use crate::*;
15
16/// Geometry unit.
17///
18/// Some geometric objects are positioned or sized with different kinds of dimensions differeing in unit. In some cases, an object might allow multiple kinds of dimensions varrying by units. AVCaptionUnitsType is an enumeration of kinds of units that are used across caption formats.
19///
20/// The units has not been specified. The dimension can be seen as invalid.
21///
22/// The integer value is a number of cells.
23///
24/// The floating-point value number value is [0 .. 100] correspondng to 0% to 100%, typically relative to the enclosing rectangle.
25///
26/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionunitstype?language=objc)
27// NS_ENUM
28#[repr(transparent)]
29#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
30pub struct AVCaptionUnitsType(pub NSInteger);
31impl AVCaptionUnitsType {
32    #[doc(alias = "AVCaptionUnitsTypeUnspecified")]
33    pub const Unspecified: Self = Self(0);
34    #[doc(alias = "AVCaptionUnitsTypeCells")]
35    pub const Cells: Self = Self(1);
36    #[doc(alias = "AVCaptionUnitsTypePercent")]
37    pub const Percent: Self = Self(2);
38}
39
40unsafe impl Encode for AVCaptionUnitsType {
41    const ENCODING: Encoding = NSInteger::ENCODING;
42}
43
44unsafe impl RefEncode for AVCaptionUnitsType {
45    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
46}
47
48/// The length with a unit or coordinate on a 2D geometric axis
49/// Field: value The value of the coordinate or length.
50/// Field: units The units of the coordinate (e.g., cells, points)
51///
52/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptiondimension?language=objc)
53#[cfg(feature = "objc2-core-foundation")]
54#[repr(C)]
55#[derive(Clone, Copy, Debug, PartialEq)]
56pub struct AVCaptionDimension {
57    pub value: CGFloat,
58    pub units: AVCaptionUnitsType,
59}
60
61#[cfg(feature = "objc2-core-foundation")]
62unsafe impl Encode for AVCaptionDimension {
63    const ENCODING: Encoding = Encoding::Struct(
64        "AVCaptionDimension",
65        &[<CGFloat>::ENCODING, <AVCaptionUnitsType>::ENCODING],
66    );
67}
68
69#[cfg(feature = "objc2-core-foundation")]
70unsafe impl RefEncode for AVCaptionDimension {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74/// A two dimensional point made of x and y AVCaptionDimension coordinates
75/// Field: x An AVCaptionDimension holding the x coordinate of the point
76/// Field: y An AVCaptionDimension holding the y coordinate of the point
77///
78/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionpoint?language=objc)
79#[cfg(feature = "objc2-core-foundation")]
80#[repr(C)]
81#[derive(Clone, Copy, Debug, PartialEq)]
82pub struct AVCaptionPoint {
83    pub x: AVCaptionDimension,
84    pub y: AVCaptionDimension,
85}
86
87#[cfg(feature = "objc2-core-foundation")]
88unsafe impl Encode for AVCaptionPoint {
89    const ENCODING: Encoding = Encoding::Struct(
90        "AVCaptionPoint",
91        &[
92            <AVCaptionDimension>::ENCODING,
93            <AVCaptionDimension>::ENCODING,
94        ],
95    );
96}
97
98#[cfg(feature = "objc2-core-foundation")]
99unsafe impl RefEncode for AVCaptionPoint {
100    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
101}
102
103/// A two dimensional size made of width and height AVCaptionDimensions
104/// Field: width An AVCaptionDimension holding the width
105/// Field: height An AVCaptionDimension holding the height
106///
107/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionsize?language=objc)
108#[cfg(feature = "objc2-core-foundation")]
109#[repr(C)]
110#[derive(Clone, Copy, Debug, PartialEq)]
111pub struct AVCaptionSize {
112    pub width: AVCaptionDimension,
113    pub height: AVCaptionDimension,
114}
115
116#[cfg(feature = "objc2-core-foundation")]
117unsafe impl Encode for AVCaptionSize {
118    const ENCODING: Encoding = Encoding::Struct(
119        "AVCaptionSize",
120        &[
121            <AVCaptionDimension>::ENCODING,
122            <AVCaptionDimension>::ENCODING,
123        ],
124    );
125}
126
127#[cfg(feature = "objc2-core-foundation")]
128unsafe impl RefEncode for AVCaptionSize {
129    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
130}
131
132#[cfg(feature = "objc2-core-foundation")]
133impl AVCaptionDimension {
134    /// Makes an AVCaptionDimension from a value and units.
135    #[doc(alias = "AVCaptionDimensionMake")]
136    #[cfg(feature = "objc2-core-foundation")]
137    #[inline]
138    pub unsafe fn new(value: CGFloat, units: AVCaptionUnitsType) -> AVCaptionDimension {
139        extern "C-unwind" {
140            fn AVCaptionDimensionMake(
141                value: CGFloat,
142                units: AVCaptionUnitsType,
143            ) -> AVCaptionDimension;
144        }
145        unsafe { AVCaptionDimensionMake(value, units) }
146    }
147}
148
149#[cfg(feature = "objc2-core-foundation")]
150impl AVCaptionPoint {
151    /// Makes an AVCaptionPoint from x and y coordinate AVCaptionDimensions.
152    #[doc(alias = "AVCaptionPointMake")]
153    #[cfg(feature = "objc2-core-foundation")]
154    #[inline]
155    pub unsafe fn new(x: AVCaptionDimension, y: AVCaptionDimension) -> AVCaptionPoint {
156        extern "C-unwind" {
157            fn AVCaptionPointMake(x: AVCaptionDimension, y: AVCaptionDimension) -> AVCaptionPoint;
158        }
159        unsafe { AVCaptionPointMake(x, y) }
160    }
161}
162
163#[cfg(feature = "objc2-core-foundation")]
164impl AVCaptionSize {
165    /// Makes an AVCaptionSize from width and height AVCaptionDimensions.
166    #[doc(alias = "AVCaptionSizeMake")]
167    #[cfg(feature = "objc2-core-foundation")]
168    #[inline]
169    pub unsafe fn new(width: AVCaptionDimension, height: AVCaptionDimension) -> AVCaptionSize {
170        extern "C-unwind" {
171            fn AVCaptionSizeMake(
172                width: AVCaptionDimension,
173                height: AVCaptionDimension,
174            ) -> AVCaptionSize;
175        }
176        unsafe { AVCaptionSizeMake(width, height) }
177    }
178}
179
180/// Choices for region display alignment
181///
182///
183/// Whenever a caption line is inserted into a region, it's placed relative to the existing lines and the direction to which the line is placed is called the block progression direction of the region. For example, English caption's block progression direction is top-to-bottom, while Japanese vertical caption uses right-to-left.
184///
185/// The value describes how the caption lines should positioned in a region in terms of the block progression direction.
186///
187///
188/// Align lines in earlier position in the block progression direction, or align to the top for English captions, for example.
189///
190///
191/// Align lines in center position in the block progression direction. iTT doesn't support this.
192///
193///
194/// Align lines in later position in the block progression direction, or align to the left for Japanese vertical captions, for example.
195///
196/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionregiondisplayalignment?language=objc)
197// NS_ENUM
198#[repr(transparent)]
199#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
200pub struct AVCaptionRegionDisplayAlignment(pub NSInteger);
201impl AVCaptionRegionDisplayAlignment {
202    #[doc(alias = "AVCaptionRegionDisplayAlignmentBefore")]
203    pub const Before: Self = Self(0);
204    #[doc(alias = "AVCaptionRegionDisplayAlignmentCenter")]
205    pub const Center: Self = Self(1);
206    #[doc(alias = "AVCaptionRegionDisplayAlignmentAfter")]
207    pub const After: Self = Self(2);
208}
209
210unsafe impl Encode for AVCaptionRegionDisplayAlignment {
211    const ENCODING: Encoding = NSInteger::ENCODING;
212}
213
214unsafe impl RefEncode for AVCaptionRegionDisplayAlignment {
215    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
216}
217
218/// Choices for region writing mode
219///
220/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionregionwritingmode?language=objc)
221// NS_ENUM
222#[repr(transparent)]
223#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
224pub struct AVCaptionRegionWritingMode(pub NSInteger);
225impl AVCaptionRegionWritingMode {
226    #[doc(alias = "AVCaptionRegionWritingModeLeftToRightAndTopToBottom")]
227    pub const LeftToRightAndTopToBottom: Self = Self(0);
228    #[doc(alias = "AVCaptionRegionWritingModeTopToBottomAndRightToLeft")]
229    pub const TopToBottomAndRightToLeft: Self = Self(2);
230}
231
232unsafe impl Encode for AVCaptionRegionWritingMode {
233    const ENCODING: Encoding = NSInteger::ENCODING;
234}
235
236unsafe impl RefEncode for AVCaptionRegionWritingMode {
237    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
238}
239
240/// Scrolling effect for a region
241///
242/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionregionscroll?language=objc)
243// NS_ENUM
244#[repr(transparent)]
245#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
246pub struct AVCaptionRegionScroll(pub NSInteger);
247impl AVCaptionRegionScroll {
248    #[doc(alias = "AVCaptionRegionScrollNone")]
249    pub const None: Self = Self(0);
250    #[doc(alias = "AVCaptionRegionScrollRollUp")]
251    pub const RollUp: Self = Self(1);
252}
253
254unsafe impl Encode for AVCaptionRegionScroll {
255    const ENCODING: Encoding = NSInteger::ENCODING;
256}
257
258unsafe impl RefEncode for AVCaptionRegionScroll {
259    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
260}
261
262extern_class!(
263    /// An instance of AVCaptionRegion represents a region where a caption is placed.
264    ///
265    /// Currently, there is just four predefined region instances. The interface doesn't support configuration of region settings.
266    ///
267    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionregion?language=objc)
268    #[unsafe(super(NSObject))]
269    #[derive(Debug, PartialEq, Eq, Hash)]
270    pub struct AVCaptionRegion;
271);
272
273extern_conformance!(
274    unsafe impl NSCoding for AVCaptionRegion {}
275);
276
277extern_conformance!(
278    unsafe impl NSCopying for AVCaptionRegion {}
279);
280
281unsafe impl CopyingHelper for AVCaptionRegion {
282    type Result = Self;
283}
284
285extern_conformance!(
286    unsafe impl NSMutableCopying for AVCaptionRegion {}
287);
288
289unsafe impl MutableCopyingHelper for AVCaptionRegion {
290    type Result = AVMutableCaptionRegion;
291}
292
293extern_conformance!(
294    unsafe impl NSObjectProtocol for AVCaptionRegion {}
295);
296
297extern_conformance!(
298    unsafe impl NSSecureCoding for AVCaptionRegion {}
299);
300
301impl AVCaptionRegion {
302    extern_methods!(
303        /// The top region for iTT format
304        ///
305        /// This region can be used in iTT format and it occupies the top 15% of the display area. The region uses LRTB, a line progresses left to right and the block extends from top to bottom. Each line is stacked with top justified.
306        #[unsafe(method(appleITTTopRegion))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn appleITTTopRegion() -> Retained<AVCaptionRegion>;
309
310        /// The bottom region for iTT format
311        ///
312        /// This region can be used in iTT format and it occupies the bottom 15% of the display area. The region uses LRTB, a line progresses left to right and the block extends from top to bottom. Each line is stacked with bottom justified.
313        #[unsafe(method(appleITTBottomRegion))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn appleITTBottomRegion() -> Retained<AVCaptionRegion>;
316
317        /// The  left region for iTT format
318        ///
319        /// This region can be used in iTT format and it occupies the left 15% of the display area. The region uses TBRL, a line progresses top to bottom and the block extends from right to left. Each line is stacked with right justified.
320        #[unsafe(method(appleITTLeftRegion))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn appleITTLeftRegion() -> Retained<AVCaptionRegion>;
323
324        /// The right region for iTT format
325        ///
326        /// This region can be used in iTT format and it occupies the right 15% of the display area. The region uses TBRL, a line progresses top to bottom and the block extends from right to left. Each line is stacked with right justified.
327        #[unsafe(method(appleITTRightRegion))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn appleITTRightRegion() -> Retained<AVCaptionRegion>;
330
331        /// The bottom region for SubRip Text (SRT) format
332        ///
333        /// This region can be used in SRT format and it occupies the entire video display area. The region uses LRTB, a line progresses left to right and the block extends from top to bottom. Each line is stacked with bottom justified.
334        #[unsafe(method(subRipTextBottomRegion))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn subRipTextBottomRegion() -> Retained<AVCaptionRegion>;
337
338        /// Identifier for the region
339        ///
340        /// When regionIdentifier is nil, two regions with the same position and endPosition are considered to be same, that is
341        /// captions referring these regions belong to the same region when serialized to a format like TTML.  In addition, the
342        /// AVCaptionRegion cannot be mutably copied.
343        ///
344        /// When regionIdentifier is not nil, two regions are same if and only if the region identifier is equal. It is a
345        /// client's responsibility to ensure these AVCaptionRegion objects have the same properties.
346        #[unsafe(method(identifier))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn identifier(&self) -> Option<Retained<NSString>>;
349
350        #[cfg(feature = "objc2-core-foundation")]
351        /// The position of the top-left of the region, potentially with unspecified fields.
352        ///
353        /// It returns an AVCaptionPoint potentially with unspecified x and/or y fields. Unspecified dimensions indicate the region doesn't have positioning information for that dimension.
354        #[unsafe(method(origin))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn origin(&self) -> AVCaptionPoint;
357
358        #[cfg(feature = "objc2-core-foundation")]
359        /// The width and height of the region, potentally with unspecified fields.
360        ///
361        /// It returns an AVCaptionSize potentially with unspecified width and/or height.
362        /// CEA608 closed captions support limits the size.height property’s value to 1 cell except when the AVCaptionRegionScroll is AVCaptionRegionScrollRollUp.
363        /// If the AVCaptionRegionScroll is AVCaptionRegionScrollRollUp, the size.height property’s value must be 2, 3 or 4 cells.
364        /// It returns an AVCaptionSize with unspecifed width and height when the region doesn't have width or height information.
365        #[unsafe(method(size))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn size(&self) -> AVCaptionSize;
368
369        /// Scroll mode for the region
370        ///
371        /// See AVCaptionRegionScrollXXX enum for possible values.
372        #[unsafe(method(scroll))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn scroll(&self) -> AVCaptionRegionScroll;
375
376        /// Alignment of lines for the region
377        #[unsafe(method(displayAlignment))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn displayAlignment(&self) -> AVCaptionRegionDisplayAlignment;
380
381        /// The block and inline progression direction of the region.
382        #[unsafe(method(writingMode))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn writingMode(&self) -> AVCaptionRegionWritingMode;
385
386        /// NSCoding protocol method override
387        ///
388        /// This method throws an exception if the caption region's size has different units for width and height, or if the units are unrecognizeable.
389        ///
390        /// # Safety
391        ///
392        /// `encoder` possibly has further requirements.
393        #[unsafe(method(encodeWithCoder:))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn encodeWithCoder(&self, encoder: &NSCoder);
396
397        /// NSObject protocol method override
398        ///
399        /// This method throws an exception if the caption region's size has different units for width and height, or if the units are unrecognizeable.
400        ///
401        /// # Safety
402        ///
403        /// `object` should be of the correct type.
404        #[unsafe(method(isEqual:))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn isEqual(&self, object: &AnyObject) -> bool;
407
408        /// NSMutableCopying protocol method override
409        ///
410        /// This method throws an exception if the caption region contains an identifier.
411        ///
412        /// # Safety
413        ///
414        /// `zone` must be a valid pointer or null.
415        #[unsafe(method(mutableCopyWithZone:))]
416        #[unsafe(method_family = mutableCopy)]
417        pub unsafe fn mutableCopyWithZone(&self, zone: *mut NSZone) -> Retained<AnyObject>;
418    );
419}
420
421/// Methods declared on superclass `NSObject`.
422impl AVCaptionRegion {
423    extern_methods!(
424        #[unsafe(method(init))]
425        #[unsafe(method_family = init)]
426        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
427
428        #[unsafe(method(new))]
429        #[unsafe(method_family = new)]
430        pub unsafe fn new() -> Retained<Self>;
431    );
432}
433
434extern_class!(
435    /// Mutable subclass of AVCaptionRegion.
436    ///
437    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablecaptionregion?language=objc)
438    #[unsafe(super(AVCaptionRegion, NSObject))]
439    #[derive(Debug, PartialEq, Eq, Hash)]
440    pub struct AVMutableCaptionRegion;
441);
442
443extern_conformance!(
444    unsafe impl NSCoding for AVMutableCaptionRegion {}
445);
446
447extern_conformance!(
448    unsafe impl NSCopying for AVMutableCaptionRegion {}
449);
450
451unsafe impl CopyingHelper for AVMutableCaptionRegion {
452    type Result = AVCaptionRegion;
453}
454
455extern_conformance!(
456    unsafe impl NSMutableCopying for AVMutableCaptionRegion {}
457);
458
459unsafe impl MutableCopyingHelper for AVMutableCaptionRegion {
460    type Result = Self;
461}
462
463extern_conformance!(
464    unsafe impl NSObjectProtocol for AVMutableCaptionRegion {}
465);
466
467extern_conformance!(
468    unsafe impl NSSecureCoding for AVMutableCaptionRegion {}
469);
470
471impl AVMutableCaptionRegion {
472    extern_methods!(
473        /// Create a region object without any properties.
474        #[unsafe(method(init))]
475        #[unsafe(method_family = init)]
476        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
477
478        /// Create a region object with the identifier.
479        #[unsafe(method(initWithIdentifier:))]
480        #[unsafe(method_family = init)]
481        pub unsafe fn initWithIdentifier(
482            this: Allocated<Self>,
483            identifier: &NSString,
484        ) -> Retained<Self>;
485
486        #[cfg(feature = "objc2-core-foundation")]
487        /// The position of the top-left of the region.
488        #[unsafe(method(origin))]
489        #[unsafe(method_family = none)]
490        pub unsafe fn origin(&self) -> AVCaptionPoint;
491
492        #[cfg(feature = "objc2-core-foundation")]
493        /// Setter for [`origin`][Self::origin].
494        #[unsafe(method(setOrigin:))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn setOrigin(&self, origin: AVCaptionPoint);
497
498        #[cfg(feature = "objc2-core-foundation")]
499        /// The width and height of the region, potentally with unspecified fields.
500        #[unsafe(method(size))]
501        #[unsafe(method_family = none)]
502        pub unsafe fn size(&self) -> AVCaptionSize;
503
504        #[cfg(feature = "objc2-core-foundation")]
505        /// Setter for [`size`][Self::size].
506        #[unsafe(method(setSize:))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn setSize(&self, size: AVCaptionSize);
509
510        /// Region scroll mode.
511        #[unsafe(method(scroll))]
512        #[unsafe(method_family = none)]
513        pub unsafe fn scroll(&self) -> AVCaptionRegionScroll;
514
515        /// Setter for [`scroll`][Self::scroll].
516        #[unsafe(method(setScroll:))]
517        #[unsafe(method_family = none)]
518        pub unsafe fn setScroll(&self, scroll: AVCaptionRegionScroll);
519
520        /// Alignment of lines in the region.
521        #[unsafe(method(displayAlignment))]
522        #[unsafe(method_family = none)]
523        pub unsafe fn displayAlignment(&self) -> AVCaptionRegionDisplayAlignment;
524
525        /// Setter for [`displayAlignment`][Self::displayAlignment].
526        #[unsafe(method(setDisplayAlignment:))]
527        #[unsafe(method_family = none)]
528        pub unsafe fn setDisplayAlignment(
529            &self,
530            display_alignment: AVCaptionRegionDisplayAlignment,
531        );
532
533        /// The block and inline progression direction of the region.
534        #[unsafe(method(writingMode))]
535        #[unsafe(method_family = none)]
536        pub unsafe fn writingMode(&self) -> AVCaptionRegionWritingMode;
537
538        /// Setter for [`writingMode`][Self::writingMode].
539        #[unsafe(method(setWritingMode:))]
540        #[unsafe(method_family = none)]
541        pub unsafe fn setWritingMode(&self, writing_mode: AVCaptionRegionWritingMode);
542    );
543}
544
545/// Methods declared on superclass `NSObject`.
546impl AVMutableCaptionRegion {
547    extern_methods!(
548        #[unsafe(method(new))]
549        #[unsafe(method_family = new)]
550        pub unsafe fn new() -> Retained<Self>;
551    );
552}
553
554/// Animation effect for a caption
555///
556/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionanimation?language=objc)
557// NS_ENUM
558#[repr(transparent)]
559#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
560pub struct AVCaptionAnimation(pub NSInteger);
561impl AVCaptionAnimation {
562    #[doc(alias = "AVCaptionAnimationNone")]
563    pub const None: Self = Self(0);
564    #[doc(alias = "AVCaptionAnimationCharacterReveal")]
565    pub const CharacterReveal: Self = Self(1);
566}
567
568unsafe impl Encode for AVCaptionAnimation {
569    const ENCODING: Encoding = NSInteger::ENCODING;
570}
571
572unsafe impl RefEncode for AVCaptionAnimation {
573    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
574}
575
576extern_class!(
577    /// An instance of AVCaption represents a unit of text that is active at a particular time range.
578    ///
579    /// A caption contains one meaningful sentence, paragraph, or otherwise known as a caption cue. Within the active time range, it may perform animation (e.g. Karaoke), rolling-up, changes the visibility, or any other dynamic styling.
580    ///
581    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaption?language=objc)
582    #[unsafe(super(NSObject))]
583    #[derive(Debug, PartialEq, Eq, Hash)]
584    pub struct AVCaption;
585);
586
587extern_conformance!(
588    unsafe impl NSCoding for AVCaption {}
589);
590
591extern_conformance!(
592    unsafe impl NSCopying for AVCaption {}
593);
594
595unsafe impl CopyingHelper for AVCaption {
596    type Result = Self;
597}
598
599extern_conformance!(
600    unsafe impl NSMutableCopying for AVCaption {}
601);
602
603unsafe impl MutableCopyingHelper for AVCaption {
604    type Result = AVMutableCaption;
605}
606
607extern_conformance!(
608    unsafe impl NSObjectProtocol for AVCaption {}
609);
610
611extern_conformance!(
612    unsafe impl NSSecureCoding for AVCaption {}
613);
614
615impl AVCaption {
616    extern_methods!(
617        #[unsafe(method(init))]
618        #[unsafe(method_family = init)]
619        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
620
621        #[unsafe(method(new))]
622        #[unsafe(method_family = new)]
623        pub unsafe fn new() -> Retained<Self>;
624
625        #[cfg(feature = "objc2-core-media")]
626        /// Initializes an instance of AVCaption with the given text and time range.
627        ///
628        /// Parameter `text`: The text for the new caption object. See text property for the available character sets and other restrictions.
629        ///
630        /// Parameter `timeRange`: The time range for the new caption object.
631        ///
632        /// Returns: An instance of AVCaption that carries the given text and time range.
633        #[unsafe(method(initWithText:timeRange:))]
634        #[unsafe(method_family = init)]
635        pub unsafe fn initWithText_timeRange(
636            this: Allocated<Self>,
637            text: &NSString,
638            time_range: CMTimeRange,
639        ) -> Retained<Self>;
640
641        /// The text content of the caption.
642        ///
643        /// The text may contain any of the line breaking character sequences (LF, CR, or CF+LF) and separating the lines in the presentation.
644        ///
645        /// The Apple iTT format supports all Unicode code points allowed in a XML document. Any XML special characters such as '
646        /// &
647        /// ' are converted to a corresponding character reference syntax when written to the destination file.
648        ///
649        /// CEA608 closed captions support the following Unicode characters.
650        /// Range: U+0020 - U+005F
651        /// Range: U+0061 - U+007E
652        /// Range: U+00A1 - U+00A5
653        /// Characters: U+00A9, U+00AB, U+00AE, U+00B0, U+00BB, U+00BD, U+00BF
654        /// Range: U+00C0-U+00C5
655        /// Range: U+00C7-U+00CF
656        /// Range: U+00D1-U+00D6
657        /// Range: U+00D8-U+00DC
658        /// Range: U+00DF-U+00E5
659        /// Range: U+00E7-U+00EF
660        /// Range: U+00F1-U+00FC
661        /// Range: U+2018-U+2019
662        /// Range: U+2018-U+201D
663        /// Character: U+2022
664        /// Range: U+2120-U+2122
665        /// Characters: U+2501, U+2503, U+250F, U+2513, U+2517, U+251B, U+2588, U+266A
666        ///
667        /// CEA608 closed captions don't support the line breaking character sequences (LF, CR, or CF+LF).
668        #[unsafe(method(text))]
669        #[unsafe(method_family = none)]
670        pub unsafe fn text(&self) -> Retained<NSString>;
671
672        #[cfg(feature = "objc2-core-media")]
673        /// The time range during which the caption should be presented.
674        ///
675        /// Apple iTT format doesn't allow two captions to have overlapped time range except when the two captions are associated with different regions.
676        ///
677        /// CEA608 closed caption time ranges can't start with zero, because the decoder needs some transmission time.
678        /// CEA608 closed caption time ranges should be aligned with the video frame rate because this is how often the commands are delivered.
679        #[unsafe(method(timeRange))]
680        #[unsafe(method_family = none)]
681        pub unsafe fn timeRange(&self) -> CMTimeRange;
682    );
683}
684
685extern_class!(
686    /// Mutable subclass of AVCaption.
687    ///
688    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablecaption?language=objc)
689    #[unsafe(super(AVCaption, NSObject))]
690    #[derive(Debug, PartialEq, Eq, Hash)]
691    pub struct AVMutableCaption;
692);
693
694extern_conformance!(
695    unsafe impl NSCoding for AVMutableCaption {}
696);
697
698extern_conformance!(
699    unsafe impl NSCopying for AVMutableCaption {}
700);
701
702unsafe impl CopyingHelper for AVMutableCaption {
703    type Result = AVCaption;
704}
705
706extern_conformance!(
707    unsafe impl NSMutableCopying for AVMutableCaption {}
708);
709
710unsafe impl MutableCopyingHelper for AVMutableCaption {
711    type Result = Self;
712}
713
714extern_conformance!(
715    unsafe impl NSObjectProtocol for AVMutableCaption {}
716);
717
718extern_conformance!(
719    unsafe impl NSSecureCoding for AVMutableCaption {}
720);
721
722impl AVMutableCaption {
723    extern_methods!(
724        /// The text content of the caption.
725        ///
726        /// All styling information is cleared on setting this property.
727        #[unsafe(method(text))]
728        #[unsafe(method_family = none)]
729        pub unsafe fn text(&self) -> Retained<NSString>;
730
731        /// Setter for [`text`][Self::text].
732        ///
733        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
734        #[unsafe(method(setText:))]
735        #[unsafe(method_family = none)]
736        pub unsafe fn setText(&self, text: &NSString);
737
738        #[cfg(feature = "objc2-core-media")]
739        /// The time range during which the caption should be presented.
740        #[unsafe(method(timeRange))]
741        #[unsafe(method_family = none)]
742        pub unsafe fn timeRange(&self) -> CMTimeRange;
743
744        #[cfg(feature = "objc2-core-media")]
745        /// Setter for [`timeRange`][Self::timeRange].
746        #[unsafe(method(setTimeRange:))]
747        #[unsafe(method_family = none)]
748        pub unsafe fn setTimeRange(&self, time_range: CMTimeRange);
749    );
750}
751
752/// Methods declared on superclass `AVCaption`.
753impl AVMutableCaption {
754    extern_methods!(
755        #[unsafe(method(init))]
756        #[unsafe(method_family = init)]
757        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
758
759        #[unsafe(method(new))]
760        #[unsafe(method_family = new)]
761        pub unsafe fn new() -> Retained<Self>;
762
763        #[cfg(feature = "objc2-core-media")]
764        /// Initializes an instance of AVCaption with the given text and time range.
765        ///
766        /// Parameter `text`: The text for the new caption object. See text property for the available character sets and other restrictions.
767        ///
768        /// Parameter `timeRange`: The time range for the new caption object.
769        ///
770        /// Returns: An instance of AVCaption that carries the given text and time range.
771        #[unsafe(method(initWithText:timeRange:))]
772        #[unsafe(method_family = init)]
773        pub unsafe fn initWithText_timeRange(
774            this: Allocated<Self>,
775            text: &NSString,
776            time_range: CMTimeRange,
777        ) -> Retained<Self>;
778    );
779}
780
781/// Choices for font weight.
782///
783/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionfontweight?language=objc)
784// NS_ENUM
785#[repr(transparent)]
786#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
787pub struct AVCaptionFontWeight(pub NSInteger);
788impl AVCaptionFontWeight {
789    #[doc(alias = "AVCaptionFontWeightUnknown")]
790    pub const Unknown: Self = Self(0);
791    #[doc(alias = "AVCaptionFontWeightNormal")]
792    pub const Normal: Self = Self(1);
793    #[doc(alias = "AVCaptionFontWeightBold")]
794    pub const Bold: Self = Self(2);
795}
796
797unsafe impl Encode for AVCaptionFontWeight {
798    const ENCODING: Encoding = NSInteger::ENCODING;
799}
800
801unsafe impl RefEncode for AVCaptionFontWeight {
802    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
803}
804
805/// Choices for character style.
806///
807/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionfontstyle?language=objc)
808// NS_ENUM
809#[repr(transparent)]
810#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
811pub struct AVCaptionFontStyle(pub NSInteger);
812impl AVCaptionFontStyle {
813    #[doc(alias = "AVCaptionFontStyleUnknown")]
814    pub const Unknown: Self = Self(0);
815    #[doc(alias = "AVCaptionFontStyleNormal")]
816    pub const Normal: Self = Self(1);
817    #[doc(alias = "AVCaptionFontStyleItalic")]
818    pub const Italic: Self = Self(2);
819}
820
821unsafe impl Encode for AVCaptionFontStyle {
822    const ENCODING: Encoding = NSInteger::ENCODING;
823}
824
825unsafe impl RefEncode for AVCaptionFontStyle {
826    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
827}
828
829/// Choices for character decoration .
830///
831/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptiondecoration?language=objc)
832// NS_OPTIONS
833#[repr(transparent)]
834#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
835pub struct AVCaptionDecoration(pub NSUInteger);
836bitflags::bitflags! {
837    impl AVCaptionDecoration: NSUInteger {
838        #[doc(alias = "AVCaptionDecorationNone")]
839        const None = 0;
840        #[doc(alias = "AVCaptionDecorationUnderline")]
841        const Underline = 1<<0;
842        #[doc(alias = "AVCaptionDecorationLineThrough")]
843        const LineThrough = 1<<1;
844        #[doc(alias = "AVCaptionDecorationOverline")]
845        const Overline = 1<<2;
846    }
847}
848
849unsafe impl Encode for AVCaptionDecoration {
850    const ENCODING: Encoding = NSUInteger::ENCODING;
851}
852
853unsafe impl RefEncode for AVCaptionDecoration {
854    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
855}
856
857/// Choices for text combine.
858///
859///
860/// Text combine is a special rendering policy to combine multiple characters into one unit and present it in upright position in a vertical text flow in order to accomplish so-called "Tate-Chu-Yoko" layout, or horizontal-in-vertical layout.
861///
862/// For example, it can be used to render "2017" horizontally in a vertical text.
863///
864///
865/// Don't combine text upright. It is the same as not specifying the style.
866///
867///
868/// Combine all the characters.
869///
870///
871/// Make one digit upright.
872///
873///
874/// Combine two consecutive digits
875///
876///
877/// Combine three consecutive digits
878///
879///
880/// Combine four consecutive digits
881///
882/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptiontextcombine?language=objc)
883// NS_ENUM
884#[repr(transparent)]
885#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
886pub struct AVCaptionTextCombine(pub NSInteger);
887impl AVCaptionTextCombine {
888    #[doc(alias = "AVCaptionTextCombineAll")]
889    pub const All: Self = Self(-1);
890    #[doc(alias = "AVCaptionTextCombineNone")]
891    pub const None: Self = Self(0);
892    #[doc(alias = "AVCaptionTextCombineOneDigit")]
893    pub const OneDigit: Self = Self(1);
894    #[doc(alias = "AVCaptionTextCombineTwoDigits")]
895    pub const TwoDigits: Self = Self(2);
896    #[doc(alias = "AVCaptionTextCombineThreeDigits")]
897    pub const ThreeDigits: Self = Self(3);
898    #[doc(alias = "AVCaptionTextCombineFourDigits")]
899    pub const FourDigits: Self = Self(4);
900}
901
902unsafe impl Encode for AVCaptionTextCombine {
903    const ENCODING: Encoding = NSInteger::ENCODING;
904}
905
906unsafe impl RefEncode for AVCaptionTextCombine {
907    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
908}
909
910/// Alignment of a caption within the containing region.
911///
912/// Aligned to the start of inline progression direction; e.g. left in left-to-right writing mode and right in right-to-left writing mode.
913///
914/// Aligned to the end of inline progression direction; e.g. right in left-to-right writing mode and right in right-to-left writing mode.
915///
916/// Aligned at center in inline progression direction.
917///
918/// Aligned to left in horizontal writing mode or top in vertical writing mode.
919///
920/// Aligned to right in horizontal writing mode or bottom in vertical writing mode.
921///
922/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptiontextalignment?language=objc)
923// NS_ENUM
924#[repr(transparent)]
925#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
926pub struct AVCaptionTextAlignment(pub NSInteger);
927impl AVCaptionTextAlignment {
928    #[doc(alias = "AVCaptionTextAlignmentStart")]
929    pub const Start: Self = Self(0);
930    #[doc(alias = "AVCaptionTextAlignmentEnd")]
931    pub const End: Self = Self(1);
932    #[doc(alias = "AVCaptionTextAlignmentCenter")]
933    pub const Center: Self = Self(2);
934    #[doc(alias = "AVCaptionTextAlignmentLeft")]
935    pub const Left: Self = Self(3);
936    #[doc(alias = "AVCaptionTextAlignmentRight")]
937    pub const Right: Self = Self(4);
938}
939
940unsafe impl Encode for AVCaptionTextAlignment {
941    const ENCODING: Encoding = NSInteger::ENCODING;
942}
943
944unsafe impl RefEncode for AVCaptionTextAlignment {
945    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
946}
947
948/// Styling.
949impl AVCaption {
950    extern_methods!(
951        #[cfg(feature = "objc2-core-graphics")]
952        /// The color of the character(s).
953        ///
954        /// A value of NULL means that the color is not specified. The caller must release the returned object via CGColorRelease. The range parameter receives UTF-16 code unit index range the style is effective. The range will indicate where the current style returned (including NULL) will be active and allows discovery of the next change in the style.
955        ///
956        /// CEA608 closed captions support the following 8 colors with 1.0 alpha value.
957        /// White    (RGB:1.0, 1.0, 1.0)
958        /// Red        (RGB:1.0, 0.0, 0.0)
959        /// Blue    (RGB:0.0, 0.0, 1.0)
960        /// Green    (RGB:0.0, 1.0, 0.0)
961        /// Yellow    (RGB:1.0, 1.0, 0.0)
962        /// Cyan    (RGB:0.0, 1.0, 1.0)
963        /// Magenta    (RGB:1.0, 0.0, 1.0)
964        /// Black    (RGB:0.0, 0.0, 0.0)
965        ///
966        /// # Safety
967        ///
968        /// `out_range` must be a valid pointer or null.
969        #[unsafe(method(textColorAtIndex:range:))]
970        // required for soundness, method has `returns_retained` attribute.
971        #[unsafe(method_family = copy)]
972        pub unsafe fn textColorAtIndex_range(
973            &self,
974            index: NSInteger,
975            out_range: *mut NSRange,
976        ) -> Option<Retained<CGColor>>;
977
978        #[cfg(feature = "objc2-core-graphics")]
979        /// The background color of the character(s).
980        ///
981        /// A value of NULL means that the color is not specified. The caller must release the returned object via CGColorRelease. The range parameter receives UTF-16 code unit index range the style is effective. After returning from the call, the range will indicate where the current style returned (including NULL) will be active and allows discovery of the next change in the style.
982        ///
983        /// iTT format ignores this property.
984        ///
985        /// CEA608 closed captions support the following 8 colors with 1.0, 0.5 and 0.0 alpha values.
986        /// White    (RGB:1.0, 1.0, 1.0)
987        /// Red        (RGB:1.0, 0.0, 0.0)
988        /// Blue    (RGB:0.0, 0.0, 1.0)
989        /// Green    (RGB:0.0, 1.0, 0.0)
990        /// Yellow    (RGB:1.0, 1.0, 0.0)
991        /// Cyan    (RGB:0.0, 1.0, 1.0)
992        /// Magenta    (RGB:1.0, 0.0, 1.0)
993        /// Black    (RGB:0.0, 0.0, 0.0)
994        ///
995        /// # Safety
996        ///
997        /// `out_range` must be a valid pointer or null.
998        #[unsafe(method(backgroundColorAtIndex:range:))]
999        // required for soundness, method has `returns_retained` attribute.
1000        #[unsafe(method_family = copy)]
1001        pub unsafe fn backgroundColorAtIndex_range(
1002            &self,
1003            index: NSInteger,
1004            out_range: *mut NSRange,
1005        ) -> Option<Retained<CGColor>>;
1006
1007        /// Indicates the font weight of the character(s).
1008        ///
1009        /// The range parameter receives UTF-16 code unit index range the style is effective. After returning from the call, the range will indicate where the current style returned will be active and allows discovery of the next change in the style.
1010        ///
1011        /// CEA608 closed captions ignore this property.
1012        ///
1013        /// A visible distinction between AVCaptionFontWeightNormal and AVCaptionFontWeightBold may not exist if the font used has only one weight. This can be more common with CJK fonts where individual fonts can be quite large in terms of storage. Nevertheless, AVCaption still carries the font weight semantics so if the same AVCaption is applied to a different font having multiple weights, the distinction will become visible.
1014        ///
1015        /// # Safety
1016        ///
1017        /// `out_range` must be a valid pointer or null.
1018        #[unsafe(method(fontWeightAtIndex:range:))]
1019        #[unsafe(method_family = none)]
1020        pub unsafe fn fontWeightAtIndex_range(
1021            &self,
1022            index: NSInteger,
1023            out_range: *mut NSRange,
1024        ) -> AVCaptionFontWeight;
1025
1026        /// Indicates the font style of the character(s).
1027        ///
1028        /// The range parameter receives UTF-16 code unit index range the style is effective. After returning from the call, the range will indicate where the current style returned will be active and allows discovery of the next change in the style.
1029        ///
1030        /// Some writing systems may not have italic glyphs for characters and so fonts with italic forms are not available. For example, Japanese fonts do not typically have italic forms for most characters although there may be special cases for Latin characters. Nevertheless, AVCaption still carries the font style semantics even though there may be no visible rendering distinction between using AVCaptionFontStyleNormal and AVCaptionFontStyleItalic with that language.
1031        ///
1032        /// # Safety
1033        ///
1034        /// `out_range` must be a valid pointer or null.
1035        #[unsafe(method(fontStyleAtIndex:range:))]
1036        #[unsafe(method_family = none)]
1037        pub unsafe fn fontStyleAtIndex_range(
1038            &self,
1039            index: NSInteger,
1040            out_range: *mut NSRange,
1041        ) -> AVCaptionFontStyle;
1042
1043        /// Character decoration
1044        ///
1045        /// The value of OR-ed value of AVCaptionDecoration as NSInteger. The range parameter receives UTF-16 code unit index range the style is effective. After returning from the call, the range will indicate where the current style returned will be active and allows discovery of the next change in the style.
1046        ///
1047        /// CEA608 closed captions support only AVCaptionDecorationNone and AVCaptionDecorationUnderline.
1048        ///
1049        /// # Safety
1050        ///
1051        /// `out_range` must be a valid pointer or null.
1052        #[unsafe(method(decorationAtIndex:range:))]
1053        #[unsafe(method_family = none)]
1054        pub unsafe fn decorationAtIndex_range(
1055            &self,
1056            index: NSInteger,
1057            out_range: *mut NSRange,
1058        ) -> AVCaptionDecoration;
1059
1060        /// Text combine (Tate-Chu-Yoko)
1061        ///
1062        /// The style is effective only in a vertical text region.
1063        ///
1064        /// When specified, the renderer combines all the characters in the style range so that their glyph areas consume the nominal bounding box of a single em square of the surrounding vertical text.
1065        ///
1066        /// # Safety
1067        ///
1068        /// `out_range` must be a valid pointer or null.
1069        #[unsafe(method(textCombineAtIndex:range:))]
1070        #[unsafe(method_family = none)]
1071        pub unsafe fn textCombineAtIndex_range(
1072            &self,
1073            index: NSInteger,
1074            out_range: *mut NSRange,
1075        ) -> AVCaptionTextCombine;
1076
1077        /// Get Ruby associated with the characters.
1078        ///
1079        /// The range parameter receives UTF-16 code unit index range where the ruby text is applied. After returning from the call, the range will indicate where the current style returned (including NULL) will be active and allows discovery of the next change in the style.
1080        ///
1081        /// It returns nil when the text doesn't have a ruby at the position.
1082        ///
1083        /// CEA608 closed captions ignore this property.
1084        ///
1085        /// # Safety
1086        ///
1087        /// `out_range` must be a valid pointer or null.
1088        #[unsafe(method(rubyAtIndex:range:))]
1089        #[unsafe(method_family = none)]
1090        pub unsafe fn rubyAtIndex_range(
1091            &self,
1092            index: NSInteger,
1093            out_range: *mut NSRange,
1094        ) -> Option<Retained<AVCaptionRuby>>;
1095    );
1096}
1097
1098/// Region.
1099impl AVCaption {
1100    extern_methods!(
1101        /// The region where the caption is placed.
1102        ///
1103        /// It can be nil when the underlying caption format doesn't support or use regions.
1104        #[unsafe(method(region))]
1105        #[unsafe(method_family = none)]
1106        pub unsafe fn region(&self) -> Option<Retained<AVCaptionRegion>>;
1107
1108        /// The text alignment within the containing region.
1109        ///
1110        /// This property throws an exception if a value is set which is not a valid AVCaptionTextAlignment.
1111        #[unsafe(method(textAlignment))]
1112        #[unsafe(method_family = none)]
1113        pub unsafe fn textAlignment(&self) -> AVCaptionTextAlignment;
1114    );
1115}
1116
1117/// Animation.
1118impl AVCaption {
1119    extern_methods!(
1120        #[unsafe(method(animation))]
1121        #[unsafe(method_family = none)]
1122        pub unsafe fn animation(&self) -> AVCaptionAnimation;
1123    );
1124}
1125
1126/// Styling.
1127impl AVMutableCaption {
1128    extern_methods!(
1129        #[cfg(feature = "objc2-core-graphics")]
1130        /// Set text color for the range.
1131        ///
1132        /// The range parameter uses UTF-16 code unit index range.
1133        #[unsafe(method(setTextColor:inRange:))]
1134        #[unsafe(method_family = none)]
1135        pub unsafe fn setTextColor_inRange(&self, color: &CGColor, range: NSRange);
1136
1137        #[cfg(feature = "objc2-core-graphics")]
1138        /// Set background color for the range.
1139        ///
1140        /// The range parameter uses UTF-16 code unit index range.
1141        #[unsafe(method(setBackgroundColor:inRange:))]
1142        #[unsafe(method_family = none)]
1143        pub unsafe fn setBackgroundColor_inRange(&self, color: &CGColor, range: NSRange);
1144
1145        /// Set font weight for the range.
1146        ///
1147        /// The range parameter uses UTF-16 code unit index range.
1148        #[unsafe(method(setFontWeight:inRange:))]
1149        #[unsafe(method_family = none)]
1150        pub unsafe fn setFontWeight_inRange(
1151            &self,
1152            font_weight: AVCaptionFontWeight,
1153            range: NSRange,
1154        );
1155
1156        /// Set font style for the range.
1157        ///
1158        /// The range parameter uses UTF-16 code unit index range.
1159        #[unsafe(method(setFontStyle:inRange:))]
1160        #[unsafe(method_family = none)]
1161        pub unsafe fn setFontStyle_inRange(&self, font_style: AVCaptionFontStyle, range: NSRange);
1162
1163        /// Set text decoration for the range.
1164        ///
1165        /// The range parameter uses UTF-16 code unit index range.
1166        #[unsafe(method(setDecoration:inRange:))]
1167        #[unsafe(method_family = none)]
1168        pub unsafe fn setDecoration_inRange(&self, decoration: AVCaptionDecoration, range: NSRange);
1169
1170        /// Set text combine for the range.
1171        ///
1172        /// The range parameter uses UTF-16 code unit index range.
1173        #[unsafe(method(setTextCombine:inRange:))]
1174        #[unsafe(method_family = none)]
1175        pub unsafe fn setTextCombine_inRange(
1176            &self,
1177            text_combine: AVCaptionTextCombine,
1178            range: NSRange,
1179        );
1180
1181        /// Set ruby text  for the range.
1182        ///
1183        /// The range parameter uses UTF-16 code unit index range.
1184        #[unsafe(method(setRuby:inRange:))]
1185        #[unsafe(method_family = none)]
1186        pub unsafe fn setRuby_inRange(&self, ruby: &AVCaptionRuby, range: NSRange);
1187
1188        /// Remove text color for the range.
1189        ///
1190        /// The range parameter uses UTF-16 code unit index range.
1191        #[unsafe(method(removeTextColorInRange:))]
1192        #[unsafe(method_family = none)]
1193        pub unsafe fn removeTextColorInRange(&self, range: NSRange);
1194
1195        /// Remove background color for the range.
1196        ///
1197        /// The range parameter uses UTF-16 code unit index range.
1198        #[unsafe(method(removeBackgroundColorInRange:))]
1199        #[unsafe(method_family = none)]
1200        pub unsafe fn removeBackgroundColorInRange(&self, range: NSRange);
1201
1202        /// Remove font weight for the range.
1203        ///
1204        /// The range parameter uses UTF-16 code unit index range.
1205        #[unsafe(method(removeFontWeightInRange:))]
1206        #[unsafe(method_family = none)]
1207        pub unsafe fn removeFontWeightInRange(&self, range: NSRange);
1208
1209        /// Remove font style for the range.
1210        ///
1211        /// The range parameter uses UTF-16 code unit index range.
1212        #[unsafe(method(removeFontStyleInRange:))]
1213        #[unsafe(method_family = none)]
1214        pub unsafe fn removeFontStyleInRange(&self, range: NSRange);
1215
1216        /// Remove text decoration for the range.
1217        ///
1218        /// The range parameter uses UTF-16 code unit index range.
1219        #[unsafe(method(removeDecorationInRange:))]
1220        #[unsafe(method_family = none)]
1221        pub unsafe fn removeDecorationInRange(&self, range: NSRange);
1222
1223        /// Remove text combine for the range.
1224        ///
1225        /// The range parameter uses UTF-16 code unit index range.
1226        #[unsafe(method(removeTextCombineInRange:))]
1227        #[unsafe(method_family = none)]
1228        pub unsafe fn removeTextCombineInRange(&self, range: NSRange);
1229
1230        /// Remove ruby text  for the range.
1231        ///
1232        /// The range parameter uses UTF-16 code unit index range.
1233        #[unsafe(method(removeRubyInRange:))]
1234        #[unsafe(method_family = none)]
1235        pub unsafe fn removeRubyInRange(&self, range: NSRange);
1236    );
1237}
1238
1239/// Region.
1240impl AVMutableCaption {
1241    extern_methods!(
1242        /// The region where the caption is placed.
1243        ///
1244        /// It can be nil when the underlying caption format doesn't support or use regions.
1245        /// This property throws an exception if region has unrecognizeable units.
1246        #[unsafe(method(region))]
1247        #[unsafe(method_family = none)]
1248        pub unsafe fn region(&self) -> Retained<AVCaptionRegion>;
1249
1250        /// Setter for [`region`][Self::region].
1251        ///
1252        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
1253        #[unsafe(method(setRegion:))]
1254        #[unsafe(method_family = none)]
1255        pub unsafe fn setRegion(&self, region: &AVCaptionRegion);
1256
1257        /// The text alignemnt within the containing region.
1258        #[unsafe(method(textAlignment))]
1259        #[unsafe(method_family = none)]
1260        pub unsafe fn textAlignment(&self) -> AVCaptionTextAlignment;
1261
1262        /// Setter for [`textAlignment`][Self::textAlignment].
1263        #[unsafe(method(setTextAlignment:))]
1264        #[unsafe(method_family = none)]
1265        pub unsafe fn setTextAlignment(&self, text_alignment: AVCaptionTextAlignment);
1266    );
1267}
1268
1269/// Animation.
1270impl AVMutableCaption {
1271    extern_methods!(
1272        #[unsafe(method(animation))]
1273        #[unsafe(method_family = none)]
1274        pub unsafe fn animation(&self) -> AVCaptionAnimation;
1275
1276        /// Setter for [`animation`][Self::animation].
1277        #[unsafe(method(setAnimation:))]
1278        #[unsafe(method_family = none)]
1279        pub unsafe fn setAnimation(&self, animation: AVCaptionAnimation);
1280    );
1281}
1282
1283/// Choices for Ruby position
1284///
1285/// Display Ruby text above horizontal text or right of vertical text in a right to left block progression.
1286///
1287/// Display Ruby text below horizontal text or left of vertical text in a right to left block progression.
1288///
1289/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionrubyposition?language=objc)
1290// NS_ENUM
1291#[repr(transparent)]
1292#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1293pub struct AVCaptionRubyPosition(pub NSInteger);
1294impl AVCaptionRubyPosition {
1295    #[doc(alias = "AVCaptionRubyPositionBefore")]
1296    pub const Before: Self = Self(0);
1297    #[doc(alias = "AVCaptionRubyPositionAfter")]
1298    pub const After: Self = Self(1);
1299}
1300
1301unsafe impl Encode for AVCaptionRubyPosition {
1302    const ENCODING: Encoding = NSInteger::ENCODING;
1303}
1304
1305unsafe impl RefEncode for AVCaptionRubyPosition {
1306    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1307}
1308
1309/// Choices for Ruby alignment
1310///
1311///
1312/// Given a ruby text rendering area denoted as [...], each spacing policy works as follows.
1313///
1314/// Start          [Ruby Text         ]
1315///
1316/// Center         [     Ruby Text    ]
1317///
1318/// SpaceBetween   [R u b y  T e x t]
1319/// <
1320/// - 'R' and 't' are aligned with start end end edges, spaces between each Ruby text character is equal.
1321///
1322/// SpaceAround    [ R u b y  T e x t ]
1323/// <
1324/// - Spaces around each Ruby text character is equal
1325///
1326///
1327/// Align Ruby base and text at left edge of horizontal text in a left to right inline progression, or at top of the vertical text in a top to bottom inline progression.
1328///
1329/// Align Ruby text at the center of Ruby base.
1330///
1331/// Align Ruby text so that the spaces between the Ruby text characters are equal. This is the default.
1332///
1333/// Align Ruby text so that the spaces around each Ruby text character are equal.
1334///
1335/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionrubyalignment?language=objc)
1336// NS_ENUM
1337#[repr(transparent)]
1338#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1339pub struct AVCaptionRubyAlignment(pub NSInteger);
1340impl AVCaptionRubyAlignment {
1341    #[doc(alias = "AVCaptionRubyAlignmentStart")]
1342    pub const Start: Self = Self(0);
1343    #[doc(alias = "AVCaptionRubyAlignmentCenter")]
1344    pub const Center: Self = Self(1);
1345    #[doc(alias = "AVCaptionRubyAlignmentDistributeSpaceBetween")]
1346    pub const DistributeSpaceBetween: Self = Self(2);
1347    #[doc(alias = "AVCaptionRubyAlignmentDistributeSpaceAround")]
1348    pub const DistributeSpaceAround: Self = Self(3);
1349}
1350
1351unsafe impl Encode for AVCaptionRubyAlignment {
1352    const ENCODING: Encoding = NSInteger::ENCODING;
1353}
1354
1355unsafe impl RefEncode for AVCaptionRubyAlignment {
1356    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1357}
1358
1359extern_class!(
1360    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
1361    ///
1362    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionruby?language=objc)
1363    #[unsafe(super(NSObject))]
1364    #[derive(Debug, PartialEq, Eq, Hash)]
1365    pub struct AVCaptionRuby;
1366);
1367
1368unsafe impl Send for AVCaptionRuby {}
1369
1370unsafe impl Sync for AVCaptionRuby {}
1371
1372extern_conformance!(
1373    unsafe impl NSCoding for AVCaptionRuby {}
1374);
1375
1376extern_conformance!(
1377    unsafe impl NSCopying for AVCaptionRuby {}
1378);
1379
1380unsafe impl CopyingHelper for AVCaptionRuby {
1381    type Result = Self;
1382}
1383
1384extern_conformance!(
1385    unsafe impl NSObjectProtocol for AVCaptionRuby {}
1386);
1387
1388extern_conformance!(
1389    unsafe impl NSSecureCoding for AVCaptionRuby {}
1390);
1391
1392impl AVCaptionRuby {
1393    extern_methods!(
1394        #[unsafe(method(init))]
1395        #[unsafe(method_family = init)]
1396        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1397
1398        #[unsafe(method(new))]
1399        #[unsafe(method_family = new)]
1400        pub unsafe fn new() -> Retained<Self>;
1401
1402        #[unsafe(method(initWithText:))]
1403        #[unsafe(method_family = init)]
1404        pub unsafe fn initWithText(this: Allocated<Self>, text: &NSString) -> Retained<Self>;
1405
1406        #[unsafe(method(initWithText:position:alignment:))]
1407        #[unsafe(method_family = init)]
1408        pub unsafe fn initWithText_position_alignment(
1409            this: Allocated<Self>,
1410            text: &NSString,
1411            position: AVCaptionRubyPosition,
1412            alignment: AVCaptionRubyAlignment,
1413        ) -> Retained<Self>;
1414
1415        /// The ruby text
1416        ///
1417        /// This property is not atomic.
1418        ///
1419        /// # Safety
1420        ///
1421        /// This might not be thread-safe.
1422        #[unsafe(method(text))]
1423        #[unsafe(method_family = none)]
1424        pub unsafe fn text(&self) -> Retained<NSString>;
1425
1426        /// The position of ruby text with respect to the ruby base.
1427        ///
1428        /// This property is not atomic.
1429        ///
1430        /// # Safety
1431        ///
1432        /// This might not be thread-safe.
1433        #[unsafe(method(position))]
1434        #[unsafe(method_family = none)]
1435        pub unsafe fn position(&self) -> AVCaptionRubyPosition;
1436
1437        /// The alignment of ruby text.
1438        ///
1439        /// This property is not atomic.
1440        ///
1441        /// # Safety
1442        ///
1443        /// This might not be thread-safe.
1444        #[unsafe(method(alignment))]
1445        #[unsafe(method_family = none)]
1446        pub unsafe fn alignment(&self) -> AVCaptionRubyAlignment;
1447    );
1448}
1449
1450extern "C-unwind" {
1451    #[cfg(feature = "objc2-core-foundation")]
1452    #[deprecated = "renamed to `AVCaptionDimension::new`"]
1453    pub fn AVCaptionDimensionMake(value: CGFloat, units: AVCaptionUnitsType) -> AVCaptionDimension;
1454}
1455
1456extern "C-unwind" {
1457    #[cfg(feature = "objc2-core-foundation")]
1458    #[deprecated = "renamed to `AVCaptionPoint::new`"]
1459    pub fn AVCaptionPointMake(x: AVCaptionDimension, y: AVCaptionDimension) -> AVCaptionPoint;
1460}
1461
1462extern "C-unwind" {
1463    #[cfg(feature = "objc2-core-foundation")]
1464    #[deprecated = "renamed to `AVCaptionSize::new`"]
1465    pub fn AVCaptionSizeMake(
1466        width: AVCaptionDimension,
1467        height: AVCaptionDimension,
1468    ) -> AVCaptionSize;
1469}