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")]
38unsafe impl AVQueuedSampleBufferRendering for AVSampleBufferVideoRenderer {}
39
40unsafe impl NSObjectProtocol for AVSampleBufferVideoRenderer {}
41
42impl AVSampleBufferVideoRenderer {
43    extern_methods!(
44        #[cfg(feature = "AVQueuedSampleBufferRendering")]
45        /// The ability of the video renderer to be used for enqueueing sample buffers.
46        ///
47        /// 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.
48        /// This property is key value observable.
49        #[unsafe(method(status))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn status(&self) -> AVQueuedSampleBufferRenderingStatus;
52
53        /// If the video renderer's status is AVQueuedSampleBufferRenderingStatusFailed, this describes the error that caused the failure.
54        ///
55        /// 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.
56        #[unsafe(method(error))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
59
60        /// Indicates that the receiver is in a state where it requires a call to -flush to continue decoding frames.
61        ///
62        /// 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.
63        /// 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:.
64        /// Clients can track changes to this property via AVSampleBufferVideoRendererRequiresFlushToResumeDecodingDidChangeNotification.
65        /// This property is not key value observable.
66        #[unsafe(method(requiresFlushToResumeDecoding))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn requiresFlushToResumeDecoding(&self) -> bool;
69
70        #[cfg(feature = "block2")]
71        /// Instructs the video renderer to discard pending enqueued sample buffers and call the provided block when complete.
72        ///
73        /// Parameter `removeDisplayedImage`: Set YES to remove any currently displayed image, NO to preserve any current image.
74        ///
75        /// Parameter `handler`: The handler to invoke when flush operation is complete. May be nil.
76        ///
77        /// 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).
78        #[unsafe(method(flushWithRemovalOfDisplayedImage:completionHandler:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn flushWithRemovalOfDisplayedImage_completionHandler(
81            &self,
82            remove_displayed_image: bool,
83            handler: Option<&block2::Block<dyn Fn()>>,
84        );
85    );
86}
87
88/// Methods declared on superclass `NSObject`.
89impl AVSampleBufferVideoRenderer {
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
101/// AVSampleBufferVideoRendererPixelBufferOutput.
102impl AVSampleBufferVideoRenderer {
103    extern_methods!(
104        #[cfg(feature = "objc2-core-video")]
105        /// 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.
106        ///
107        /// This will return NULL if the rate is non-zero.  Clients must release the pixel buffer after use.
108        ///
109        /// Do not write to the returned CVPixelBuffer's attachments or pixel data.
110        #[unsafe(method(copyDisplayedPixelBuffer))]
111        #[unsafe(method_family = copy)]
112        pub unsafe fn copyDisplayedPixelBuffer(&self) -> Option<Retained<CVPixelBuffer>>;
113    );
114}
115
116/// AVSampleBufferVideoRendererPowerOptimization.
117impl AVSampleBufferVideoRenderer {
118    extern_methods!(
119        #[cfg(feature = "objc2-core-media")]
120        /// Promises, for the purpose of enabling power optimizations, that future sample buffers will have PTS values no less than a specified lower-bound PTS.
121        ///
122        /// Only applicable for forward playback.
123        /// Sending this message and later calling -enqueueSampleBuffer: with a buffer with a lower PTS has the potential to lead to dropping that later buffer.
124        /// For best results, call -expectMinimumUpcomingSampleBufferPresentationTime: regularly, in between calls to -enqueueSampleBuffer:, to advance the lower-bound PTS.
125        /// Messaging -flush resets such expectations.
126        /// (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.)
127        ///
128        /// Parameter `minimumUpcomingPresentationTime`: A lower bound on PTS values for buffers that will be passed to -enqueueSampleBuffer: in the future.
129        #[unsafe(method(expectMinimumUpcomingSampleBufferPresentationTime:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn expectMinimumUpcomingSampleBufferPresentationTime(
132            &self,
133            minimum_upcoming_presentation_time: CMTime,
134        );
135
136        /// Promises, for the purpose of enabling power optimizations, that future sample buffers will have monotonically increasing PTS values.
137        ///
138        /// Only applicable for forward playback.
139        /// 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.
140        /// Messaging -flush resets such expectations.
141        #[unsafe(method(expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes(&self);
144
145        /// Resets previously-promised expectations about upcoming sample buffer PTSs.
146        ///
147        /// This undoes the state set by messaging -expectMinimumUpcomingSampleBufferPresentationTime: or -expectMonotonicallyIncreasingUpcomingSampleBufferPresentationTimes.
148        /// If you didn't use either of those, you don't have to use this.
149        #[unsafe(method(resetUpcomingSampleBufferPresentationTimeExpectations))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn resetUpcomingSampleBufferPresentationTimeExpectations(&self);
152    );
153}
154
155/// AVSampleBufferVideoRendererVideoPerformanceMetrics.
156impl AVSampleBufferVideoRenderer {
157    extern_methods!(
158        #[cfg(all(feature = "AVVideoPerformanceMetrics", feature = "block2"))]
159        /// Gathers a snapshot of the video performance metrics and calls the completion handler with the results.
160        ///
161        /// Parameter `completionHandler`: The handler to invoke with the video performance metrics.
162        ///
163        /// If there are no performance metrics available, the completion handler will be called with nil videoPerformanceMetrics.
164        #[unsafe(method(loadVideoPerformanceMetricsWithCompletionHandler:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn loadVideoPerformanceMetricsWithCompletionHandler(
167            &self,
168            completion_handler: &block2::Block<dyn Fn(*mut AVVideoPerformanceMetrics)>,
169        );
170    );
171}