objc2_av_foundation/generated/AVCaptionRenderer.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
16extern_class!(
17 /// An instance of AVCaptionRenderer represents a service that can render the captions for a particular time
18 ///
19 /// An instance of AVCaptionRenderer performs drawing of a caption "scene" from a population of captions given a time. If there are no captions or no captions at the specified time, "emptiness" will still be drawn (e.g., flood filling with zero alpha or a color).
20 ///
21 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionrenderer?language=objc)
22 #[unsafe(super(NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub struct AVCaptionRenderer;
25);
26
27unsafe impl NSObjectProtocol for AVCaptionRenderer {}
28
29impl AVCaptionRenderer {
30 extern_methods!(
31 #[cfg(feature = "AVCaption")]
32 /// A NSArray holding captions to consider for rendering.
33 ///
34 /// This is the array of AVCaptions to consider when drawing. The array can contain no captions.
35 #[unsafe(method(captions))]
36 #[unsafe(method_family = none)]
37 pub unsafe fn captions(&self) -> Retained<NSArray<AVCaption>>;
38
39 #[cfg(feature = "AVCaption")]
40 /// Setter for [`captions`][Self::captions].
41 #[unsafe(method(setCaptions:))]
42 #[unsafe(method_family = none)]
43 pub unsafe fn setCaptions(&self, captions: &NSArray<AVCaption>);
44
45 #[cfg(feature = "objc2-core-foundation")]
46 /// A CGRect holding bounds for the drawing of caption scene(s).
47 ///
48 /// This is a CGRect indicating where captions are drawn using renderInContext:atTime: Once established, this CGRect is used in each call to renderInContext:atTime: until it is changed to another value. This should be set up earlier than drawing.
49 #[unsafe(method(bounds))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn bounds(&self) -> CGRect;
52
53 #[cfg(feature = "objc2-core-foundation")]
54 /// Setter for [`bounds`][Self::bounds].
55 #[unsafe(method(setBounds:))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn setBounds(&self, bounds: CGRect);
58
59 #[cfg(feature = "objc2-core-media")]
60 /// Determine render time ranges within an enclosing time range to account for visual changes among captions.
61 ///
62 /// Returns: An NSArray of AVCaptionRendererScenes; perhaps empty if there are no captions intersecting with the consideredTimeRange
63 ///
64 /// This is an optional service useful for optimizing drawing. A client can perform drawing without it.
65 ///
66 /// As captions may become active and inactive throughout the timeline, this method will return a NSArray holding scene objects with time ranges on whose edges there's a visual change. The client can use the ranges of time between these edges with -renderInContext:atTime: to ensure all visual changes are rendered. The returned time ranges consider activation/deactivation of captions, temporal overlapping, and intra-caption timing requirements (e.g., character reveal animations). Time ranges may be returned where no captions are active as this is also a change in the caption "scene".
67 ///
68 /// The returned NSArray contains AVCaptionRendererScenes, each holding the CMTimeRange of that scene but potentially other information that may be useful to the client during renderering.
69 ///
70 /// The consideredTimeRange parameter is a CMTimeRange expressing the limits for consideration. The extent of this range does not need to correspond to the timing of captions. It might be the range from 0 to some duration. For efficiency, the range can be limited to a window of time. It is also possible to use the range anchored at a time and extending in the direction of playback.
71 #[unsafe(method(captionSceneChangesInRange:))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn captionSceneChangesInRange(
74 &self,
75 considered_time_range: CMTimeRange,
76 ) -> Retained<NSArray<AVCaptionRendererScene>>;
77
78 #[cfg(all(feature = "objc2-core-graphics", feature = "objc2-core-media"))]
79 /// Draw the captions corresponding to a time established by the AVCaptions to a CGContext.
80 ///
81 /// Captions are drawn into the CGContextRef based upon their activation at the specified time. If there are no captions or no captions at the specified time, "emptiness" will still be drawn (e.g., flood filling with zero alpha or a color).
82 #[unsafe(method(renderInContext:forTime:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn renderInContext_forTime(&self, ctx: &CGContext, time: CMTime);
85 );
86}
87
88/// Methods declared on superclass `NSObject`.
89impl AVCaptionRenderer {
90 extern_methods!(
91 #[unsafe(method(init))]
92 #[unsafe(method_family = init)]
93 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
94
95 #[unsafe(method(new))]
96 #[unsafe(method_family = new)]
97 pub unsafe fn new() -> Retained<Self>;
98 );
99}
100
101extern_class!(
102 /// An instance of AVCaptionRendererScene holds a time range and associated state indicating when the AVCaptionRenderer will draw different output.
103 ///
104 /// In rendering the timeline established by the captions referenced by an AVCaptionRenderer, there are considerations such as temporal overlapping of captions, the existence of captions and other graphical elements like regions, and whether captions may be animated (e.g., scrolling in regions, character reveal in a caption). To communicate to the AVCaptionRenderer client the minimal set of time ranges where there are any visual differences, AVCaptionRendererScenes can be requested from -[AVCaptionRenderer captionSceneChangesInRange:]. A client wanting to optimize drawing performance may use this timing information to draw scenes only once per scene. Alternatively, clients can ignore scenes and repeatedly call renderInContext:atTime: but this may have additional performance impact.
105 ///
106 /// Other information about the rendering of a caption scene can be communicated through the AVCaptionRendererScene. For example, if captions are animated, an AVCaptionRendererScene with the time range and an indication of the animation occurring will be returned. There should be no inference from the number of scenes to the number of captions. Even a single caption with internal animations in part of its duration could result in multiple AVCaptionRendererScenes being produced.
107 ///
108 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
109 ///
110 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionrendererscene?language=objc)
111 #[unsafe(super(NSObject))]
112 #[derive(Debug, PartialEq, Eq, Hash)]
113 pub struct AVCaptionRendererScene;
114);
115
116unsafe impl Send for AVCaptionRendererScene {}
117
118unsafe impl Sync for AVCaptionRendererScene {}
119
120unsafe impl NSCopying for AVCaptionRendererScene {}
121
122unsafe impl CopyingHelper for AVCaptionRendererScene {
123 type Result = Self;
124}
125
126unsafe impl NSObjectProtocol for AVCaptionRendererScene {}
127
128impl AVCaptionRendererScene {
129 extern_methods!(
130 #[unsafe(method(init))]
131 #[unsafe(method_family = init)]
132 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
133
134 #[unsafe(method(new))]
135 #[unsafe(method_family = new)]
136 pub unsafe fn new() -> Retained<Self>;
137
138 #[cfg(feature = "objc2-core-media")]
139 /// The time range during which new captions will not be introduced into or existing captions will be retired from the caption scene
140 #[unsafe(method(timeRange))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn timeRange(&self) -> CMTimeRange;
143
144 /// The scene contains one or more active captions.
145 ///
146 /// Clients should not use this to restrict their drawing and should call renderInContext:atTime: to draw "emptiness". However, this information may be useful for purposes such as scrubbing to times where captions are present, skipping scenes in which no captions are present.
147 #[unsafe(method(hasActiveCaptions))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn hasActiveCaptions(&self) -> bool;
150
151 /// The scene may have embedded animations or other state where periodic redrawing while playing through this scene is needed.
152 ///
153 /// This property indicates if refreshing should occur if the client is progressing through the content. If the client is not progressing (i.e., it is treating playback as though the rate is 0.0), a single render at the current render time suffices. This property does not prescribe a refresh rate. A client is free to choose a refresh rate corresponding to rates of associated video frames or other timing appropriate for the client.
154 #[unsafe(method(needsPeriodicRefresh))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn needsPeriodicRefresh(&self) -> bool;
157 );
158}