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
27extern_conformance!(
28 unsafe impl NSObjectProtocol for AVCaptionRenderer {}
29);
30
31impl AVCaptionRenderer {
32 extern_methods!(
33 #[cfg(feature = "AVCaption")]
34 /// A NSArray holding captions to consider for rendering.
35 ///
36 /// This is the array of AVCaptions to consider when drawing. The array can contain no captions.
37 #[unsafe(method(captions))]
38 #[unsafe(method_family = none)]
39 pub unsafe fn captions(&self) -> Retained<NSArray<AVCaption>>;
40
41 #[cfg(feature = "AVCaption")]
42 /// Setter for [`captions`][Self::captions].
43 ///
44 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
45 #[unsafe(method(setCaptions:))]
46 #[unsafe(method_family = none)]
47 pub unsafe fn setCaptions(&self, captions: &NSArray<AVCaption>);
48
49 #[cfg(feature = "objc2-core-foundation")]
50 /// A CGRect holding bounds for the drawing of caption scene(s).
51 ///
52 /// 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.
53 #[unsafe(method(bounds))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn bounds(&self) -> CGRect;
56
57 #[cfg(feature = "objc2-core-foundation")]
58 /// Setter for [`bounds`][Self::bounds].
59 #[unsafe(method(setBounds:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn setBounds(&self, bounds: CGRect);
62
63 #[cfg(feature = "objc2-core-media")]
64 /// Determine render time ranges within an enclosing time range to account for visual changes among captions.
65 ///
66 /// Returns: An NSArray of AVCaptionRendererScenes; perhaps empty if there are no captions intersecting with the consideredTimeRange
67 ///
68 /// This is an optional service useful for optimizing drawing. A client can perform drawing without it.
69 ///
70 /// 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".
71 ///
72 /// 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.
73 ///
74 /// 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.
75 #[unsafe(method(captionSceneChangesInRange:))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn captionSceneChangesInRange(
78 &self,
79 considered_time_range: CMTimeRange,
80 ) -> Retained<NSArray<AVCaptionRendererScene>>;
81
82 #[cfg(all(feature = "objc2-core-graphics", feature = "objc2-core-media"))]
83 /// Draw the captions corresponding to a time established by the AVCaptions to a CGContext.
84 ///
85 /// 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).
86 #[unsafe(method(renderInContext:forTime:))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn renderInContext_forTime(&self, ctx: &CGContext, time: CMTime);
89 );
90}
91
92/// Methods declared on superclass `NSObject`.
93impl AVCaptionRenderer {
94 extern_methods!(
95 #[unsafe(method(init))]
96 #[unsafe(method_family = init)]
97 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
98
99 #[unsafe(method(new))]
100 #[unsafe(method_family = new)]
101 pub unsafe fn new() -> Retained<Self>;
102 );
103}
104
105extern_class!(
106 /// An instance of AVCaptionRendererScene holds a time range and associated state indicating when the AVCaptionRenderer will draw different output.
107 ///
108 /// 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.
109 ///
110 /// 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.
111 ///
112 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
113 ///
114 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptionrendererscene?language=objc)
115 #[unsafe(super(NSObject))]
116 #[derive(Debug, PartialEq, Eq, Hash)]
117 pub struct AVCaptionRendererScene;
118);
119
120unsafe impl Send for AVCaptionRendererScene {}
121
122unsafe impl Sync for AVCaptionRendererScene {}
123
124extern_conformance!(
125 unsafe impl NSCopying for AVCaptionRendererScene {}
126);
127
128unsafe impl CopyingHelper for AVCaptionRendererScene {
129 type Result = Self;
130}
131
132extern_conformance!(
133 unsafe impl NSObjectProtocol for AVCaptionRendererScene {}
134);
135
136impl AVCaptionRendererScene {
137 extern_methods!(
138 #[unsafe(method(init))]
139 #[unsafe(method_family = init)]
140 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142 #[unsafe(method(new))]
143 #[unsafe(method_family = new)]
144 pub unsafe fn new() -> Retained<Self>;
145
146 #[cfg(feature = "objc2-core-media")]
147 /// The time range during which new captions will not be introduced into or existing captions will be retired from the caption scene
148 ///
149 /// This property is not atomic.
150 ///
151 /// # Safety
152 ///
153 /// This might not be thread-safe.
154 #[unsafe(method(timeRange))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn timeRange(&self) -> CMTimeRange;
157
158 /// The scene contains one or more active captions.
159 ///
160 /// 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.
161 ///
162 /// This property is not atomic.
163 ///
164 /// # Safety
165 ///
166 /// This might not be thread-safe.
167 #[unsafe(method(hasActiveCaptions))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn hasActiveCaptions(&self) -> bool;
170
171 /// The scene may have embedded animations or other state where periodic redrawing while playing through this scene is needed.
172 ///
173 /// 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.
174 ///
175 /// This property is not atomic.
176 ///
177 /// # Safety
178 ///
179 /// This might not be thread-safe.
180 #[unsafe(method(needsPeriodicRefresh))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn needsPeriodicRefresh(&self) -> bool;
183 );
184}