objc2_av_foundation/generated/
AVSampleBufferVideoRenderer.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::*;
8#[cfg(feature = "objc2-core-video")]
9use objc2_core_video::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebuffervideorendererdidfailtodecodenotification?language=objc)
16    pub static AVSampleBufferVideoRendererDidFailToDecodeNotification: &'static NSNotificationName;
17}
18
19extern "C" {
20    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebuffervideorendererdidfailtodecodenotificationerrorkey?language=objc)
21    pub static AVSampleBufferVideoRendererDidFailToDecodeNotificationErrorKey: &'static NSString;
22}
23
24extern "C" {
25    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebuffervideorendererrequiresflushtoresumedecodingdidchangenotification?language=objc)
26    pub static AVSampleBufferVideoRendererRequiresFlushToResumeDecodingDidChangeNotification:
27        &'static NSNotificationName;
28}
29
30extern_class!(
31    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avsamplebuffervideorenderer?language=objc)
32    #[unsafe(super(NSObject))]
33    #[derive(Debug, PartialEq, Eq, Hash)]
34    pub struct AVSampleBufferVideoRenderer;
35);
36
37#[cfg(feature = "AVQueuedSampleBufferRendering")]
38extern_conformance!(
39    unsafe impl AVQueuedSampleBufferRendering for AVSampleBufferVideoRenderer {}
40);
41
42extern_conformance!(
43    unsafe impl NSObjectProtocol for AVSampleBufferVideoRenderer {}
44);
45
46impl AVSampleBufferVideoRenderer {
47    extern_methods!(
48        #[cfg(feature = "AVQueuedSampleBufferRendering")]
49        /// The ability of the video renderer to be used for enqueueing sample buffers.
50        ///
51        /// The value of this property is an AVQueuedSampleBufferRenderingStatus that indicates whether the receiver can be used for enqueueing 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 video renderer after a failure, clients must first reset the status to AVQueuedSampleBufferRenderingStatusUnknown. This can be achieved by invoking -flush on the video renderer.
52        /// This property is key value observable.
53        #[unsafe(method(status))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn status(&self) -> AVQueuedSampleBufferRenderingStatus;
56
57        /// If the video renderer's status is AVQueuedSampleBufferRenderingStatusFailed, this describes the error that caused the failure.
58        ///
59        /// The value of this property is an NSError that describes what caused the video renderer to no longer be able to enqueue sample buffers. If the status is not AVQueuedSampleBufferRenderingStatusFailed, the value of this property is nil.
60        #[unsafe(method(error))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
63
64        /// Indicates that the receiver is in a state where it requires a call to -flush to continue decoding frames.
65        ///
66        /// 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 video renderer's status changing to AVQueuedSampleBufferRenderingStatusFailed.
67        /// To resume rendering sample buffers using the video renderer after this property's value is YES, clients must first reset the video renderer by calling flush or flushWithRemovalOfDisplayedImage:completionHandler:.
68        /// Clients can track changes to this property via AVSampleBufferVideoRendererRequiresFlushToResumeDecodingDidChangeNotification.
69        /// This property is not key value observable.
70        #[unsafe(method(requiresFlushToResumeDecoding))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn requiresFlushToResumeDecoding(&self) -> bool;
73
74        #[cfg(feature = "block2")]
75        /// Instructs the video renderer to discard pending enqueued sample buffers and call the provided block when complete.
76        ///
77        /// Parameter `removeDisplayedImage`: Set YES to remove any currently displayed image, NO to preserve any current image.
78        ///
79        /// Parameter `handler`: The handler to invoke when flush operation is complete. May be nil.
80        ///
81        /// A flush resets decoder state. The next frame passed to enqueueSampleBuffer: should be an IDR frame (also known as a key frame or sync sample).
82        ///
83        /// # Safety
84        ///
85        /// `handler` block must be sendable.
86        #[unsafe(method(flushWithRemovalOfDisplayedImage:completionHandler:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn flushWithRemovalOfDisplayedImage_completionHandler(
89            &self,
90            remove_displayed_image: bool,
91            handler: Option<&block2::DynBlock<dyn Fn()>>,
92        );
93    );
94}
95
96/// Methods declared on superclass `NSObject`.
97impl AVSampleBufferVideoRenderer {
98    extern_methods!(
99        #[unsafe(method(init))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
102
103        #[unsafe(method(new))]
104        #[unsafe(method_family = new)]
105        pub unsafe fn new() -> Retained<Self>;
106    );
107}
108
109/// AVSampleBufferVideoRendererPixelBufferOutput.
110impl AVSampleBufferVideoRenderer {
111    extern_methods!(
112        #[cfg(feature = "objc2-core-video")]
113        /// Returns a retained reference to the pixel buffer currently displayed in the AVSampleBufferVideoRenderer's target. This will return NULL if the displayed pixel buffer is protected, no image is currently being displayed, or if the image is unavailable.
114        ///
115        /// This will return NULL if the rate is non-zero.  Clients must release the pixel buffer after use.
116        ///
117        /// Do not write to the returned CVPixelBuffer's attachments or pixel data.
118        #[unsafe(method(copyDisplayedPixelBuffer))]
119        #[unsafe(method_family = copy)]
120        pub unsafe fn copyDisplayedPixelBuffer(&self) -> Option<Retained<CVPixelBuffer>>;
121    );
122}
123
124/// AVSampleBufferVideoRendererPowerOptimization.
125impl AVSampleBufferVideoRenderer {
126    extern_methods!(
127        #[cfg(feature = "objc2-core-media")]
128        /// Promises, for the purpose of enabling power optimizations, that future sample buffers will have PTS values no less than a specified lower-bound PTS.
129        ///
130        /// Only applicable for forward playback.
131        /// Sending this message and later calling -enqueueSampleBuffer: with a buffer with a lower PTS has the potential to lead to dropping that later buffer.
132        /// For best results, call -expectMinimumUpcomingSampleBufferPresentationTime: regularly, in between calls to -enqueueSampleBuffer:, to advance the lower-bound PTS.
133        /// Messaging -flush resets such expectations.
134        /// (For example, it's OK to make this expectation, then in response to a seek back, flush and then enqueue buffers with lower PTS values.)
135        ///
136        /// Parameter `minimumUpcomingPresentationTime`: A lower bound on PTS values for buffers that will be passed to -enqueueSampleBuffer: in the future.
137        #[unsafe(method(expectMinimumUpcomingSampleBufferPresentationTime:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn expectMinimumUpcomingSampleBufferPresentationTime(
140            &self,
141            minimum_upcoming_presentation_time: CMTime,
142        );
143
144        /// Promises, for the purpose of enabling power optimizations, that future sample buffers will have monotonically increasing PTS values.
145        ///
146        /// Only applicable for forward playback.
147        /// Sending this message and later calling -enqueueSampleBuffer: with a buffer with a lower PTS than any previously enqueued PTS has the potential to lead to dropped buffers.
148        /// Messaging -flush resets such expectations.
149        #[unsafe(method(expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes(&self);
152
153        /// Resets previously-promised expectations about upcoming sample buffer PTSs.
154        ///
155        /// This undoes the state set by messaging -expectMinimumUpcomingSampleBufferPresentationTime: or -expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes.
156        /// If you didn't use either of those, you don't have to use this.
157        #[unsafe(method(resetUpcomingSampleBufferPresentationTimeExpectations))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn resetUpcomingSampleBufferPresentationTimeExpectations(&self);
160
161        /// Recommended pixel buffer attributes for optimal performance when using CMSampleBuffers containing CVPixelBuffers.
162        ///
163        /// The returned dictionary does not contain all of the attributes needed for creating pixel buffers.
164        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary()`` to reconcile these attributes with the pixel buffer creation attributes.
165        #[unsafe(method(recommendedPixelBufferAttributes))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn recommendedPixelBufferAttributes(
168            &self,
169        ) -> Retained<NSDictionary<NSString, AnyObject>>;
170    );
171}
172
173/// AVSampleBufferVideoRendererVideoPerformanceMetrics.
174impl AVSampleBufferVideoRenderer {
175    extern_methods!(
176        #[cfg(all(feature = "AVVideoPerformanceMetrics", feature = "block2"))]
177        /// Gathers a snapshot of the video performance metrics and calls the completion handler with the results.
178        ///
179        /// Parameter `completionHandler`: The handler to invoke with the video performance metrics.
180        ///
181        /// If there are no performance metrics available, the completion handler will be called with nil videoPerformanceMetrics.
182        ///
183        /// # Safety
184        ///
185        /// `completion_handler` block must be sendable.
186        #[unsafe(method(loadVideoPerformanceMetricsWithCompletionHandler:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn loadVideoPerformanceMetricsWithCompletionHandler(
189            &self,
190            completion_handler: &block2::DynBlock<dyn Fn(*mut AVVideoPerformanceMetrics)>,
191        );
192    );
193}