objc2_video_toolbox/generated/
VTFrameProcessor.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-core-media")]
8use objc2_core_media::*;
9#[cfg(feature = "objc2-foundation")]
10use objc2_foundation::*;
11#[cfg(feature = "objc2-metal")]
12use objc2_metal::*;
13
14use crate::*;
15
16#[cfg(feature = "objc2")]
17extern_class!(
18    /// Provides a unified interface you can use to apply video effects to frames.
19    ///
20    /// The VTFrameProcessor gives access to a set of powerful video processing implementation suitable for different use cases.
21    /// A configuration object (conforming to the ``VTFrameProcessorConfiguration`` protocol) passes initialization and
22    /// configuration parameters for the processor. A Parameter object (conforming to the ``VTFrameProcessorParameters``
23    /// protocol) provides the parameters for each individual processing operation. A Configuration object and a Parameter
24    /// object define each processor implementation. These Configuration and Parameters objects for each implementation are
25    /// defined in a processor-specific header file.
26    ///
27    /// Use an instance of this class to apply configured video effects either directly to pixel buffers or as a
28    /// part of Metal pipeline. The video effect must be specified as a ``VTFrameProcessorConfiguration`` instance at session
29    /// startup. Once a session is started, you need to call one of the process methods for each input frame. After all input
30    /// frames have been provided, session must be ended for the system to finish all pending processing.
31    ///
32    /// After you call the process function, you must not modify input and output buffers (including attachments) before the
33    /// function returns or the system receives the callback, in the case of asynchronous processing.
34    ///
35    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframeprocessor?language=objc)
36    #[unsafe(super(NSObject))]
37    #[derive(Debug, PartialEq, Eq, Hash)]
38    #[cfg(feature = "objc2")]
39    pub struct VTFrameProcessor;
40);
41
42#[cfg(feature = "objc2")]
43extern_conformance!(
44    unsafe impl NSObjectProtocol for VTFrameProcessor {}
45);
46
47#[cfg(feature = "objc2")]
48impl VTFrameProcessor {
49    extern_methods!(
50        /// Create a new instance of the frame processor.
51        #[unsafe(method(init))]
52        #[unsafe(method_family = init)]
53        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
54
55        #[cfg(all(
56            feature = "VTFrameProcessorConfiguration",
57            feature = "objc2-foundation"
58        ))]
59        /// Starts a new session and configures the processor pipeline for an effect.
60        ///
61        /// - Parameters:
62        /// - configuration: The system uses this parameter to create an effect pipeline for processing frames. This object
63        /// must conform to the ``VTFrameProcessorConfiguration`` interface.
64        /// - error: Contains error information if any. You may specify NULL for this parameter if you do not want the error information.
65        #[unsafe(method(startSessionWithConfiguration:error:_))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn startSessionWithConfiguration_error(
68            &self,
69            configuration: &ProtocolObject<dyn VTFrameProcessorConfiguration>,
70        ) -> Result<(), Retained<NSError>>;
71
72        #[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2-foundation"))]
73        /// Synchronously performs the processor effects.
74        ///
75        /// Use the respective ``VTFrameProcessorParameters`` to pass frame level settings and frame level input/output parameters
76        /// for the effect that you configured this session for by calling ``startSessionWithConfiguration:error``.
77        ///
78        /// - Parameters:
79        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
80        /// during processing. It needs to match the configuration type used during start session.
81        /// - error: Contains error information if any. You may specify NULL for this parameter if you do not want the error information.
82        #[unsafe(method(processWithParameters:error:_))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn processWithParameters_error(
85            &self,
86            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
87        ) -> Result<(), Retained<NSError>>;
88
89        #[cfg(all(
90            feature = "VTFrameProcessorParameters",
91            feature = "block2",
92            feature = "objc2-foundation"
93        ))]
94        /// Asynchronously performs the processor effects.
95        ///
96        /// - Parameters:
97        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
98        /// during processing. It needs to match the configuration type used during start session.
99        /// - completionHandler: This completion handler is called when frame processing is completed. The completion handler
100        /// receives the same parameters object that you provided to the original call, as well as an `NSError` which contains
101        /// an error code if processing was not successful.
102        #[unsafe(method(processWithParameters:completionHandler:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn processWithParameters_completionHandler(
105            &self,
106            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
107            completion_handler: &block2::DynBlock<
108                dyn Fn(NonNull<ProtocolObject<dyn VTFrameProcessorParameters>>, *mut NSError),
109            >,
110        );
111
112        #[cfg(all(
113            feature = "VTFrameProcessorParameters",
114            feature = "block2",
115            feature = "objc2-core-media",
116            feature = "objc2-foundation"
117        ))]
118        /// Asynchronously performs the processor effects and outputs each frame separately.
119        ///
120        /// Use with frame processor configurations which allow multiple output frames from a single processing call, such
121        /// as frame rate conversion processor cases when you need access to output frames as they become available, rather than
122        /// waiting for all output frames to be complete.
123        ///
124        /// This interface is suitable for low-latency scenarios when a call would generate multiple output frames, but waiting
125        /// for all frames to be generated before beginning to use the frames is not ideal. Because the processor may use the
126        /// output frames as references for frames still being generated, the output frames are strictly read-only. If you want
127        /// to modify the frames, you must create a copy first.
128        ///
129        /// - Parameters:
130        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
131        /// during processing. It needs to match the configuration type used during start session.
132        /// - frameOutputHandler: This frame output handler is called once for each destination frame in the provided parameters
133        /// if no errors are encountered. The output handler receives the same parameters object that you provided to the
134        /// original call, a flag indicating if this is the final output to be called for this processing request, and the
135        /// presentation timestamp associated with the `VTFrameProcessorFrame` that it is being called for. The `NSError`
136        /// parameter contains an error code if processing was not successful.
137        #[unsafe(method(processWithParameters:frameOutputHandler:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn processWithParameters_frameOutputHandler(
140            &self,
141            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
142            frame_output_handler: &block2::DynBlock<
143                dyn Fn(
144                    NonNull<ProtocolObject<dyn VTFrameProcessorParameters>>,
145                    CMTime,
146                    Bool,
147                    *mut NSError,
148                ),
149            >,
150        );
151
152        #[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2-metal"))]
153        /// Performs effects in a Metal command buffer.
154        ///
155        /// This function allows you to add the effect to an existing Metal command buffer. The clients that have an existing
156        /// Metal pipeline and want to add this effect to it can use this function.
157        ///
158        /// > Note: this function waits until all previously inserted tasks in the command buffer finish before running. Tasks
159        /// inserted after the `processWithCommandBuffer` returns are run by the system after the effect is applied. Processing
160        /// does not happen until the commandBuffer is executed.
161        ///
162        /// - Parameters:
163        /// - commandBuffer: An existing Metal command buffer where the frame processing is inserted.
164        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
165        /// during processing. It needs to match the configuration type used during start session.
166        #[unsafe(method(processWithCommandBuffer:parameters:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn processWithCommandBuffer_parameters(
169            &self,
170            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
171            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
172        );
173
174        /// Performs all necessary tasks to end the session.
175        ///
176        /// After this call completes, you can process no new frames unless you call ``startSessionWithConfiguration`` again.
177        #[unsafe(method(endSession))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn endSession(&self);
180    );
181}
182
183/// Methods declared on superclass `NSObject`.
184#[cfg(feature = "objc2")]
185impl VTFrameProcessor {
186    extern_methods!(
187        #[unsafe(method(new))]
188        #[unsafe(method_family = new)]
189        pub unsafe fn new() -> Retained<Self>;
190    );
191}