objc2_av_foundation/generated/AVSampleBufferDisplayLayer.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-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15extern "C" {
16 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayerfailedtodecodenotification?language=objc)
17 pub static AVSampleBufferDisplayLayerFailedToDecodeNotification: &'static NSString;
18}
19
20extern "C" {
21 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayerfailedtodecodenotificationerrorkey?language=objc)
22 pub static AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey: &'static NSString;
23}
24
25extern "C" {
26 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayerrequiresflushtoresumedecodingdidchangenotification?language=objc)
27 pub static AVSampleBufferDisplayLayerRequiresFlushToResumeDecodingDidChangeNotification:
28 &'static NSNotificationName;
29}
30
31extern "C" {
32 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayeroutputobscuredduetoinsufficientexternalprotectiondidchangenotification?language=objc)
33 pub static AVSampleBufferDisplayLayerOutputObscuredDueToInsufficientExternalProtectionDidChangeNotification:
34 &'static NSNotificationName;
35}
36
37extern "C" {
38 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayerreadyfordisplaydidchangenotification?language=objc)
39 pub static AVSampleBufferDisplayLayerReadyForDisplayDidChangeNotification:
40 &'static NSNotificationName;
41}
42
43extern_class!(
44 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebufferdisplaylayer?language=objc)
45 #[unsafe(super(CALayer, NSObject))]
46 #[derive(Debug, PartialEq, Eq, Hash)]
47 #[cfg(feature = "objc2-quartz-core")]
48 #[cfg(not(target_os = "watchos"))]
49 pub struct AVSampleBufferDisplayLayer;
50);
51
52#[cfg(feature = "objc2-quartz-core")]
53#[cfg(not(target_os = "watchos"))]
54unsafe impl CAMediaTiming for AVSampleBufferDisplayLayer {}
55
56#[cfg(feature = "objc2-quartz-core")]
57#[cfg(not(target_os = "watchos"))]
58unsafe impl NSCoding for AVSampleBufferDisplayLayer {}
59
60#[cfg(feature = "objc2-quartz-core")]
61#[cfg(not(target_os = "watchos"))]
62unsafe impl NSObjectProtocol for AVSampleBufferDisplayLayer {}
63
64#[cfg(feature = "objc2-quartz-core")]
65#[cfg(not(target_os = "watchos"))]
66unsafe impl NSSecureCoding for AVSampleBufferDisplayLayer {}
67
68#[cfg(feature = "objc2-quartz-core")]
69#[cfg(not(target_os = "watchos"))]
70impl AVSampleBufferDisplayLayer {
71 extern_methods!(
72 #[cfg(feature = "objc2-core-media")]
73 /// The layer's control timebase, which governs how time stamps are interpreted.
74 ///
75 /// By default, this property is NULL, in which case time stamps will be interpreted
76 /// according to the host time clock (mach_absolute_time with the appropriate timescale
77 /// conversion; this is the same as Core Animation's CACurrentMediaTime). With no
78 /// control timebase, once frames are enqueued, it is not possible to adjust exactly
79 /// when they are displayed.
80 ///
81 /// If a non-NULL control timebase is set, it will be used to interpret time stamps.
82 /// You can control the timing of frame display by setting the rate and time of the
83 /// control timebase.
84 /// If you are synchronizing video to audio, you can use a timebase whose source clock
85 /// is a CMAudioDeviceClock for the appropriate audio device to prevent drift.
86 ///
87 /// Note that prior to OSX 10.10 and iOS 8.0, the control timebase could not be changed after enqueueSampleBuffer: was called. As of OSX 10.10 and iOS 8.0, the control timebase may be changed at any time.
88 #[unsafe(method(controlTimebase))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn controlTimebase(&self) -> Option<Retained<CMTimebase>>;
91
92 #[cfg(feature = "objc2-core-media")]
93 /// Setter for [`controlTimebase`][Self::controlTimebase].
94 #[unsafe(method(setControlTimebase:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn setControlTimebase(&self, control_timebase: Option<&CMTimebase>);
97
98 #[cfg(feature = "AVAnimation")]
99 /// A string defining how the video is displayed within an AVSampleBufferDisplayLayer bounds rect.
100 ///
101 /// Options are AVLayerVideoGravityResizeAspect, AVLayerVideoGravityResizeAspectFill
102 /// and AVLayerVideoGravityResize. AVLayerVideoGravityResizeAspect is default.
103 /// See
104 /// <AVFoundation
105 /// /AVAnimation.h> for a description of these options.
106 #[unsafe(method(videoGravity))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;
109
110 #[cfg(feature = "AVAnimation")]
111 /// Setter for [`videoGravity`][Self::videoGravity].
112 #[unsafe(method(setVideoGravity:))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
115
116 /// Boolean indicating that the first video frame has been made ready for display.
117 ///
118 /// Use this property as an indicator of when best to show or animate-in an AVSampleBufferDisplayLayer into view.
119 /// An AVSampleBufferDisplayLayer may be displayed, or made visible, while this property is NO, however the layer will not have any user-visible content until the value becomes YES. Note that if an animation is added to an AVSampleBufferDisplayLayer before it becomes readyForDisplay the video image displayed inside might not animate with the receiver.
120 /// readyForDisplay will change to NO when the layer can no longer display frames. readyForDisplay will be YES when the first video frame has been made ready for display.
121 /// This property is not key-value observable. AVSampleBufferDisplayLayerReadyForDisplayDidChangeNotification is posted when this value changes.
122 #[unsafe(method(isReadyForDisplay))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn isReadyForDisplay(&self) -> bool;
125 );
126}
127
128/// Methods declared on superclass `CALayer`.
129#[cfg(feature = "objc2-quartz-core")]
130#[cfg(not(target_os = "watchos"))]
131impl AVSampleBufferDisplayLayer {
132 extern_methods!(
133 /// Layer creation and initialization. *
134 #[unsafe(method(layer))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn layer() -> Retained<Self>;
137
138 #[unsafe(method(init))]
139 #[unsafe(method_family = init)]
140 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142 #[unsafe(method(initWithLayer:))]
143 #[unsafe(method_family = init)]
144 pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
145 );
146}
147
148/// Methods declared on superclass `NSObject`.
149#[cfg(feature = "objc2-quartz-core")]
150#[cfg(not(target_os = "watchos"))]
151impl AVSampleBufferDisplayLayer {
152 extern_methods!(
153 #[unsafe(method(new))]
154 #[unsafe(method_family = new)]
155 pub unsafe fn new() -> Retained<Self>;
156 );
157}
158
159/// AVSampleBufferDisplayLayerQueueManagement.
160#[cfg(feature = "objc2-quartz-core")]
161#[cfg(not(target_os = "watchos"))]
162impl AVSampleBufferDisplayLayer {
163 extern_methods!(
164 #[cfg(feature = "objc2-core-media")]
165 /// The renderer's timebase, which governs how time stamps are interpreted.
166 ///
167 /// The timebase is used to interpret time stamps.
168 ///
169 /// The timebase is read-only. Use the AVSampleBufferRenderSynchronizer to set the rate or time.
170 #[deprecated = "Use sampleBufferRenderer's timebase instead"]
171 #[unsafe(method(timebase))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn timebase(&self) -> Retained<CMTimebase>;
174
175 #[cfg(feature = "AVQueuedSampleBufferRendering")]
176 /// The ability of the display layer to be used for enqueuing sample buffers.
177 ///
178 /// The value of this property is an AVQueuedSampleBufferRenderingStatus that indicates whether the receiver can be used for enqueuing and rendering sample buffers. When the value of this property is AVQueuedSampleBufferRenderingStatusFailed, clients can check the value of the error property to determine the failure. To resume rendering sample buffers using the display layer after a failure, clients must first reset the status to AVQueuedSampleBufferRenderingStatusUnknown. This can be achieved by invoking -flush on the display layer.
179 ///
180 /// This property is key value observable.
181 #[deprecated = "Use sampleBufferRenderer's status instead"]
182 #[unsafe(method(status))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn status(&self) -> AVQueuedSampleBufferRenderingStatus;
185
186 /// If the display layer's status is AVQueuedSampleBufferRenderingStatusFailed, this describes the error that caused the failure.
187 ///
188 /// The value of this property is an NSError that describes what caused the display layer to no longer be able to enqueue sample buffers. If the status is not AVQueuedSampleBufferRenderingStatusFailed, the value of this property is nil.
189 #[deprecated = "Use sampleBufferRenderer's error instead"]
190 #[unsafe(method(error))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn error(&self) -> Option<Retained<NSError>>;
193
194 #[cfg(feature = "objc2-core-media")]
195 /// Sends a sample buffer for display.
196 ///
197 /// If sampleBuffer has the kCMSampleAttachmentKey_DoNotDisplay attachment set to
198 /// kCFBooleanTrue, the frame will be decoded but not displayed.
199 /// Otherwise, if sampleBuffer has the kCMSampleAttachmentKey_DisplayImmediately
200 /// attachment set to kCFBooleanTrue, the decoded image will be displayed as soon
201 /// as possible, replacing all previously enqueued images regardless of their timestamps.
202 /// Otherwise, the decoded image will be displayed at sampleBuffer's output presentation
203 /// timestamp, as interpreted by the control timebase (or the mach_absolute_time timeline
204 /// if there is no control timebase).
205 ///
206 /// To schedule the removal of previous images at a specific timestamp, enqueue
207 /// a marker sample buffer containing no samples, with the
208 /// kCMSampleBufferAttachmentKey_EmptyMedia attachment set to kCFBooleanTrue.
209 ///
210 /// IMPORTANT NOTE: attachments with the kCMSampleAttachmentKey_ prefix must be set via
211 /// CMSampleBufferGetSampleAttachmentsArray and CFDictionarySetValue.
212 /// Attachments with the kCMSampleBufferAttachmentKey_ prefix must be set via
213 /// CMSetAttachment.
214 ///
215 /// IMPORTANT NOTE: When using CMSampleBuffers that wrap CVPixelBuffer, it is important that such CVPixelBuffers be IOSurface-backed.
216 /// CoreVideo allocates IOSurface-backed CVPixelBuffers when the pixel buffer attribute dictionary passed to CVPixelBufferPoolCreate contains
217 /// an entry with key kCVPixelBufferIOSurfacePropertiesKey and value being a dictionary (which can be an empty dictionary).
218 ///
219 /// The combination of either a non-NULL controlTimebase or an AVSampleBufferRenderSynchronizer with the use of kCMSampleAttachmentKey_DisplayImmediately as an attachment to the CMSampleBuffers that are enqueued for display is not recommended.
220 #[deprecated = "Use sampleBufferRenderer's enqueueSampleBuffer: instead"]
221 #[unsafe(method(enqueueSampleBuffer:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn enqueueSampleBuffer(&self, sample_buffer: &CMSampleBuffer);
224
225 /// Instructs the layer to discard pending enqueued sample buffers.
226 ///
227 /// It is not possible to determine which sample buffers have been decoded,
228 /// so the next frame passed to enqueueSampleBuffer: should be an IDR frame
229 /// (also known as a key frame or sync sample).
230 #[deprecated = "Use sampleBufferRenderer's flush instead"]
231 #[unsafe(method(flush))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn flush(&self);
234
235 /// Instructs the layer to discard pending enqueued sample buffers and remove any
236 /// currently displayed image.
237 ///
238 /// It is not possible to determine which sample buffers have been decoded,
239 /// so the next frame passed to enqueueSampleBuffer: should be an IDR frame
240 /// (also known as a key frame or sync sample).
241 #[deprecated = "Use sampleBufferRenderer's flushWithRemovalOfDisplayedImage:completionHandler: instead"]
242 #[unsafe(method(flushAndRemoveImage))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn flushAndRemoveImage(&self);
245
246 /// Indicates that the receiver is in a state where it requires a call to -flush to continue decoding frames.
247 ///
248 /// When the application enters a state where use of video decoder resources is not permissible, the value of this property changes to YES along with the display layer's status changing to AVQueuedSampleBufferRenderingStatusFailed.
249 /// To resume rendering sample buffers using the display layer after this property's value is YES, clients must first reset the display layer's status to AVQueuedSampleBufferRenderingStatusUnknown. This can be achieved by invoking -flush on the display layer.
250 /// Clients can track changes to this property via AVSampleBufferDisplayLayerRequiresFlushToResumeDecodingDidChangeNotification.
251 /// This property is not key value observable.
252 #[deprecated = "Use sampleBufferRenderer's requiresFlushToResumeDecoding instead"]
253 #[unsafe(method(requiresFlushToResumeDecoding))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn requiresFlushToResumeDecoding(&self) -> bool;
256
257 /// Indicates the readiness of the layer to accept more sample buffers.
258 ///
259 /// AVSampleBufferDisplayLayer keeps track of the occupancy levels of its internal queues
260 /// for the benefit of clients that enqueue sample buffers from non-real-time sources --
261 /// i.e., clients that can supply sample buffers faster than they are consumed, and so
262 /// need to decide when to hold back.
263 ///
264 /// Clients enqueueing sample buffers from non-real-time sources may hold off from
265 /// generating or obtaining more sample buffers to enqueue when the value of
266 /// readyForMoreMediaData is NO.
267 ///
268 /// It is safe to call enqueueSampleBuffer: when readyForMoreMediaData is NO, but
269 /// it is a bad idea to enqueue sample buffers without bound.
270 ///
271 /// To help with control of the non-real-time supply of sample buffers, such clients can use
272 /// -requestMediaDataWhenReadyOnQueue:usingBlock
273 /// in order to specify a block that the layer should invoke whenever it's ready for
274 /// sample buffers to be appended.
275 ///
276 /// The value of readyForMoreMediaData will often change from NO to YES asynchronously,
277 /// as previously supplied sample buffers are decoded and displayed.
278 ///
279 /// This property is not key value observable.
280 #[deprecated = "Use sampleBufferRenderer's readyForMoreMediaData instead"]
281 #[unsafe(method(isReadyForMoreMediaData))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn isReadyForMoreMediaData(&self) -> bool;
284
285 /// Cancels any current requestMediaDataWhenReadyOnQueue:usingBlock: call.
286 ///
287 /// This method may be called from outside the block or from within the block.
288 #[deprecated = "Use sampleBufferRenderer's stopRequestingMediaData instead"]
289 #[unsafe(method(stopRequestingMediaData))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn stopRequestingMediaData(&self);
292
293 /// Indicates whether the enqueued media data meets the renderer's preroll level.
294 ///
295 /// Clients should fetch the value of this property to learn if the renderer has had enough media data enqueued to start playback reliably. Starting playback when this property is NO may prevent smooth playback following an immediate start.
296 #[deprecated = "Use sampleBufferRenderer's hasSufficientMediaDataForReliablePlaybackStart instead"]
297 #[unsafe(method(hasSufficientMediaDataForReliablePlaybackStart))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn hasSufficientMediaDataForReliablePlaybackStart(&self) -> bool;
300 );
301}
302
303#[cfg(all(
304 feature = "AVQueuedSampleBufferRendering",
305 feature = "objc2-quartz-core"
306))]
307#[cfg(not(target_os = "watchos"))]
308unsafe impl AVQueuedSampleBufferRendering for AVSampleBufferDisplayLayer {}
309
310/// AVSampleBufferDisplayLayerImageProtection.
311#[cfg(feature = "objc2-quartz-core")]
312#[cfg(not(target_os = "watchos"))]
313impl AVSampleBufferDisplayLayer {
314 extern_methods!(
315 /// Indicates that image data should be protected from capture.
316 #[unsafe(method(preventsCapture))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn preventsCapture(&self) -> bool;
319
320 /// Setter for [`preventsCapture`][Self::preventsCapture].
321 #[unsafe(method(setPreventsCapture:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn setPreventsCapture(&self, prevents_capture: bool);
324 );
325}
326
327/// AVSampleBufferDisplayLayerVideoDisplaySleepPrevention.
328#[cfg(feature = "objc2-quartz-core")]
329#[cfg(not(target_os = "watchos"))]
330impl AVSampleBufferDisplayLayer {
331 extern_methods!(
332 /// Indicates whether video playback prevents display and device sleep.
333 ///
334 /// Default is YES on iOS, tvOS and in Mac Catalyst apps. Default is NO on macOS.
335 /// Setting this property to NO does not force the display to sleep, it simply stops preventing display sleep. Other apps or frameworks within your app may still be preventing display sleep for various reasons.
336 /// Note: If sample buffers are being enqueued for playback at the user's request, you should ensure that the value of this property is set to YES. If video is not being displayed as part of the user's primary focus, you should ensure that the value of this property is set to NO.
337 #[unsafe(method(preventsDisplaySleepDuringVideoPlayback))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn preventsDisplaySleepDuringVideoPlayback(&self) -> bool;
340
341 /// Setter for [`preventsDisplaySleepDuringVideoPlayback`][Self::preventsDisplaySleepDuringVideoPlayback].
342 #[unsafe(method(setPreventsDisplaySleepDuringVideoPlayback:))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn setPreventsDisplaySleepDuringVideoPlayback(
345 &self,
346 prevents_display_sleep_during_video_playback: bool,
347 );
348 );
349}
350
351/// AVSampleBufferDisplayLayerAutomaticBackgroundPrevention.
352#[cfg(feature = "objc2-quartz-core")]
353#[cfg(not(target_os = "watchos"))]
354impl AVSampleBufferDisplayLayer {
355 extern_methods!(
356 /// Indicates whether video playback prevents the app from automatically getting backgrounded.
357 ///
358 /// Default is YES.
359 /// Setting this property to YES prevents an application that is playing video from automatically getting backgrounded. This property does not prevent the user from backgrounding the application.
360 /// Note: If sample buffers are being enqueued for playback at the user's request, you should ensure that the value of this property is set to YES. If video is not being displayed as part of the user's primary focus, you should ensure that the value of this property is set to NO.
361 #[unsafe(method(preventsAutomaticBackgroundingDuringVideoPlayback))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn preventsAutomaticBackgroundingDuringVideoPlayback(&self) -> bool;
364
365 /// Setter for [`preventsAutomaticBackgroundingDuringVideoPlayback`][Self::preventsAutomaticBackgroundingDuringVideoPlayback].
366 #[unsafe(method(setPreventsAutomaticBackgroundingDuringVideoPlayback:))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn setPreventsAutomaticBackgroundingDuringVideoPlayback(
369 &self,
370 prevents_automatic_backgrounding_during_video_playback: bool,
371 );
372 );
373}
374
375/// ProtectedContent.
376#[cfg(feature = "objc2-quartz-core")]
377#[cfg(not(target_os = "watchos"))]
378impl AVSampleBufferDisplayLayer {
379 extern_methods!(
380 /// Whether or not decoded output is being obscured due to insufficient external protection.
381 ///
382 ///
383 /// The value of this property indicates whether the layer is purposefully obscuring its visual output
384 /// because the requirement for an external protection mechanism is not met by the current device
385 /// configuration. The change of this property can be observed through AVSampleBufferDisplayLayerOutputObscuredDueToInsufficientExternalProtectionDidChangeNotification
386 ///
387 /// It is highly recommended that clients whose content requires external
388 /// protection observe this property and set the playback rate to zero and display an appropriate user
389 /// interface when the value changes to YES.
390 ///
391 /// Note that the value of this property is dependent on the external protection requirements of the
392 /// media being displayed by the layer. These requirements are inherent to the content itself and cannot
393 /// be externally specified. If the content does not require external protection, the value of this
394 /// property will be NO.
395 #[unsafe(method(outputObscuredDueToInsufficientExternalProtection))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn outputObscuredDueToInsufficientExternalProtection(&self) -> bool;
398 );
399}
400
401/// AVSampleBufferDisplayLayerRenderer.
402#[cfg(feature = "objc2-quartz-core")]
403#[cfg(not(target_os = "watchos"))]
404impl AVSampleBufferDisplayLayer {
405 extern_methods!(
406 #[cfg(feature = "AVSampleBufferVideoRenderer")]
407 /// An AVSampleBufferVideoRenderer instance that allows enqueuing sample buffers for rendering.
408 ///
409 /// Although AVSampleBufferDisplayLayer conforms to the AVQueuedSampleBufferRendering protocol, the sampleBufferRenderer should be used to enqueue sample buffers. sampleBufferRenderer allows the client to safely enqueue sample buffers from a background thread. NOTE: Do not use AVSampleBufferDisplayLayer's AVQueuedSampleBufferRendering functions when using sampleBufferRenderer.
410 #[unsafe(method(sampleBufferRenderer))]
411 #[unsafe(method_family = none)]
412 pub unsafe fn sampleBufferRenderer(&self) -> Retained<AVSampleBufferVideoRenderer>;
413 );
414}