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