objc2_video_toolbox/generated/
VTRAWProcessingSession.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12#[cfg(feature = "objc2-core-video")]
13use objc2_core_video::*;
14
15use crate::*;
16
17/// A reference to a Video Toolbox RAW Processing Session.
18///
19/// A RAW processing session supports processing of frames that have been output from decoders in camera native formats, for example RAW or bayer formats.
20/// The session reference is a reference-counted CF object.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtrawprocessingsession?language=objc)
23#[repr(C)]
24pub struct VTRAWProcessingSession {
25    inner: [u8; 0],
26    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
27}
28
29cf_type!(
30    unsafe impl VTRAWProcessingSession {}
31);
32#[cfg(feature = "objc2")]
33cf_objc2_type!(
34    unsafe impl RefEncode<"OpaqueVTRAWProcessingSession"> for VTRAWProcessingSession {}
35);
36
37/// Block invoked when processing parameters change.
38///
39/// This block is called when available parameters or parameter values change without an explicit call to VTRAWProcessingSessionSetProcessingParameters.
40/// This is intended to allow the client to update any UI driven by these parameters.
41///
42/// Parameter `newParameters`: A CFArrayRef contaiing the new parameter details.  This follows the same form as the array returned from VTRAWProcessingSessionCopyProcessingParameters.
43///
44/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtrawprocessingparameterchangehandler?language=objc)
45#[cfg(feature = "block2")]
46pub type VTRAWProcessingParameterChangeHandler = *mut block2::DynBlock<dyn Fn(*const CFArray)>;
47
48impl VTRAWProcessingSession {
49    /// Creates a RAW video frame processing session.
50    ///
51    /// .
52    ///
53    /// Parameter `allocator`: An allocator for the session.  Pass NULL to use the default allocator.
54    ///
55    /// Parameter `formatDescription`: The CMVideoFormatDescription corresponding to the original media samples, containing sequence-level processing parameters.
56    ///
57    /// Parameter `outputPixelBufferAttributes`: A CoreVideo pixel buffer attributes dictionary describing the client's requirements for pixel buffers for output frames.
58    /// Pass NULL to receive the RAW processor's native output format.
59    ///
60    /// Parameter `processingSessionOptions`: A dictionary of creation-time options for the VTRAWProcessingSession.
61    ///
62    /// Parameter `processingSessionOut`: Points to a variable to receive the new RAW processing session.
63    /// When you are done with the session, call VTRAWProcessingSessionInvalidate
64    /// to tear it down and then CFRelease to release your object reference.
65    #[doc(alias = "VTRAWProcessingSessionCreate")]
66    #[cfg(feature = "objc2-core-media")]
67    #[inline]
68    pub unsafe fn create(
69        allocator: Option<&CFAllocator>,
70        format_description: &CMVideoFormatDescription,
71        output_pixel_buffer_attributes: Option<&CFDictionary>,
72        processing_session_options: Option<&CFDictionary>,
73        processing_session_out: NonNull<*mut VTRAWProcessingSession>,
74    ) -> OSStatus {
75        extern "C-unwind" {
76            fn VTRAWProcessingSessionCreate(
77                allocator: Option<&CFAllocator>,
78                format_description: &CMVideoFormatDescription,
79                output_pixel_buffer_attributes: Option<&CFDictionary>,
80                processing_session_options: Option<&CFDictionary>,
81                processing_session_out: NonNull<*mut VTRAWProcessingSession>,
82            ) -> OSStatus;
83        }
84        unsafe {
85            VTRAWProcessingSessionCreate(
86                allocator,
87                format_description,
88                output_pixel_buffer_attributes,
89                processing_session_options,
90                processing_session_out,
91            )
92        }
93    }
94
95    /// Tears down a RAW processing session.
96    ///
97    /// When you are done with a decompression session you created, call VTRAWProcessingSessionInvalidate
98    /// to tear it down and then CFRelease to release your object reference.
99    /// When a  session's retain count reaches zero, it is automatically invalidated, but
100    /// since sessions may be retained by multiple parties, it can be hard to predict when this will happen.
101    /// Calling VTRAWProcessingSessionInvalidate ensures a deterministic, orderly teardown.
102    #[doc(alias = "VTRAWProcessingSessionInvalidate")]
103    #[inline]
104    pub unsafe fn invalidate(self: &VTRAWProcessingSession) {
105        extern "C-unwind" {
106            fn VTRAWProcessingSessionInvalidate(session: &VTRAWProcessingSession);
107        }
108        unsafe { VTRAWProcessingSessionInvalidate(self) }
109    }
110}
111
112unsafe impl ConcreteType for VTRAWProcessingSession {
113    /// Returns the CFTypeID for RAW processing sessions.
114    #[doc(alias = "VTRAWProcessingSessionGetTypeID")]
115    #[inline]
116    fn type_id() -> CFTypeID {
117        extern "C-unwind" {
118            fn VTRAWProcessingSessionGetTypeID() -> CFTypeID;
119        }
120        unsafe { VTRAWProcessingSessionGetTypeID() }
121    }
122}
123
124impl VTRAWProcessingSession {
125    /// Provides a block which will be called when the VTRAWProcessingPlugin changes the set of processing parameters..
126    ///
127    /// This block will be called the VTRAWProcessingPlugin either changes the set of available processing parameters, or changes the current value of parameters.
128    /// The VTRAWProcessingPlugin may change parameters based on metadata associated with input frames, or in response to other parameters configured by VTRAWProcessingSessionSetProcessingParameters.
129    /// This optional and does not need to be configured if the client is not driving UI based on these parameters, or otherwise does not need this.
130    ///
131    /// Parameter `session`: The RAW processing session.
132    ///
133    /// Parameter `parameterChangeHandler`: A VTRAWProcessingParameterChangeHandler block which will be called when the set of processing parameters changes, or the value of a parameter changes without the client explicitly requesting it.
134    /// Setting this to NULL removes the current handler.
135    #[doc(alias = "VTRAWProcessingSessionSetParameterChangedHander")]
136    #[cfg(feature = "block2")]
137    #[inline]
138    pub unsafe fn set_parameter_changed_hander(
139        self: &VTRAWProcessingSession,
140        parameter_change_handler: VTRAWProcessingParameterChangeHandler,
141    ) -> OSStatus {
142        extern "C-unwind" {
143            fn VTRAWProcessingSessionSetParameterChangedHander(
144                session: &VTRAWProcessingSession,
145                parameter_change_handler: VTRAWProcessingParameterChangeHandler,
146            ) -> OSStatus;
147        }
148        unsafe { VTRAWProcessingSessionSetParameterChangedHander(self, parameter_change_handler) }
149    }
150}
151
152/// Block invoked when frame processing is complete.
153///
154/// On successful processing, will return a CVPixelBuffer conforming to the session's outputPixelBufferAttributes if any were provided.
155///
156/// Parameter `status`: noErr if processing request was successful; an error code if it was not successful.
157///
158/// Parameter `processedPixelBuffer`: A CVPixelBuffer containing the processed video frame if processing request was successful;
159/// otherwise, NULL.
160///
161/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtrawprocessingoutputhandler?language=objc)
162#[cfg(all(feature = "block2", feature = "objc2-core-video"))]
163pub type VTRAWProcessingOutputHandler = *mut block2::DynBlock<dyn Fn(OSStatus, *mut CVPixelBuffer)>;
164
165impl VTRAWProcessingSession {
166    /// Call this function to submit RAW frames for format-specific processing using sequence and frame level parameters.
167    ///
168    /// Processed frames may or may not be output before the function returns,
169    /// The client should not modify the input pixel data after making this call.
170    /// The RAW Processor will retain the input pixel buffer as long as necessary.
171    ///
172    /// For any RAW processor, there is a finite number of frames that can be
173    /// presented to VTRAWProcessingSessionProcessFrame before the function will block
174    /// until the output callback is invoked.
175    ///
176    /// Parameter `session`: The RAW processing session.
177    ///
178    /// Parameter `inputPixelBuffer`: A CVPixelBuffer containing an input video frame to be processed.
179    ///
180    /// Parameter `frameOptions`: Contains key/value pairs specifying additional properties for processing this frame.
181    /// No keys currently.  Pass NULL.
182    ///
183    /// Parameter `outputHandler`: A VTRAWProcessingOutputHandler block which will be called once when processing is complete.
184    #[doc(alias = "VTRAWProcessingSessionProcessFrame")]
185    #[cfg(all(feature = "block2", feature = "objc2-core-video"))]
186    #[inline]
187    pub unsafe fn process_frame(
188        self: &VTRAWProcessingSession,
189        input_pixel_buffer: &CVPixelBuffer,
190        frame_options: Option<&CFDictionary>,
191        output_handler: VTRAWProcessingOutputHandler,
192    ) -> OSStatus {
193        extern "C-unwind" {
194            fn VTRAWProcessingSessionProcessFrame(
195                session: &VTRAWProcessingSession,
196                input_pixel_buffer: &CVPixelBuffer,
197                frame_options: Option<&CFDictionary>,
198                output_handler: VTRAWProcessingOutputHandler,
199            ) -> OSStatus;
200        }
201        unsafe {
202            VTRAWProcessingSessionProcessFrame(
203                self,
204                input_pixel_buffer,
205                frame_options,
206                output_handler,
207            )
208        }
209    }
210
211    /// Forces the RAW Processor to complete processing frames.
212    ///
213    /// Call this after calling a set of VTRAWProcessingSessionProcessFrame calls to ensure that all frames have been processed.
214    /// Before VTRAWProcessingSessionCompleteFrames returns, the output handler will be invoked for all pending frames.
215    ///
216    /// Parameter `session`: The RAW processing session.
217    #[doc(alias = "VTRAWProcessingSessionCompleteFrames")]
218    #[inline]
219    pub unsafe fn complete_frames(self: &VTRAWProcessingSession) -> OSStatus {
220        extern "C-unwind" {
221            fn VTRAWProcessingSessionCompleteFrames(session: &VTRAWProcessingSession) -> OSStatus;
222        }
223        unsafe { VTRAWProcessingSessionCompleteFrames(self) }
224    }
225
226    /// Copies an array of dictionaries describing the parameters provided by the RAW Processor for frame processing
227    ///
228    /// This will return an array of dictionaries, one dictionary for each parameter that can be controlled in the RAW Processing operation.
229    /// The dictionary for each parameter will contain a set of kVTRAWProcessingParameter keys whose values provide a name, value type,
230    /// value range, and current value for each parameter.
231    ///
232    /// The returned values can be used to contruct dynamic UI presenting RAW Processing controls allowing the various knobs for this
233    /// specific RAW Processor to be viewed and manipulated.
234    ///
235    /// Parameter `session`: The RAW processing session.
236    ///
237    /// Parameter `outParameterArray`: Pointer for receiving the RAW Processing parameter array..
238    #[doc(alias = "VTRAWProcessingSessionCopyProcessingParameters")]
239    #[inline]
240    pub unsafe fn copy_processing_parameters(
241        self: &VTRAWProcessingSession,
242        out_parameter_array: NonNull<*const CFArray>,
243    ) -> OSStatus {
244        extern "C-unwind" {
245            fn VTRAWProcessingSessionCopyProcessingParameters(
246                session: &VTRAWProcessingSession,
247                out_parameter_array: NonNull<*const CFArray>,
248            ) -> OSStatus;
249        }
250        unsafe { VTRAWProcessingSessionCopyProcessingParameters(self, out_parameter_array) }
251    }
252
253    /// Sets a collection of RAW Processing parameters
254    ///
255    /// This call will set a collection of RAW Processing parameters on the RAW Processor.  These are set as a dictionary where the keys match
256    /// kVTRAWProcessingParameter_Key values that were returned in VTRAWProcessingSessionCopyProcessingParameters and where values conform
257    /// to the type and range defined in the kVTRAWProcessingParameter dictionary for each parameter.
258    ///
259    /// Not all parameters from the RAWProcessingParameter array need to be set at any given time.  Changining the parameters will not change
260    /// processing on frames already submitted for processing, it will only impact frames where VTRAWProcessingSessionProcessFrame is called
261    /// after VTRAWProcessingSessionSetProcessingParameters returns.
262    ///
263    /// If any parameters specified are not in the array reported by VTRAWProcessingSessionCopyProcessingParameters, or are the wrong type or are out of range,
264    /// kVTParameterErr will be returned and none of the parameters will be applied.
265    ///
266    /// Parameter `session`: The RAW processing session.
267    ///
268    /// Parameter `processingParameters`: A dictionary of keys and values setting parameters reported by VTRAWProcessingSessionCopyProcessingParameters.
269    ///
270    /// Returns: Returns an error if any of the provided parameters are invalid, disabled or outside of the declared valid range.
271    /// None of the provided parameters will be set on the processor if an error is returned.
272    #[doc(alias = "VTRAWProcessingSessionSetProcessingParameters")]
273    #[inline]
274    pub unsafe fn set_processing_parameters(
275        self: &VTRAWProcessingSession,
276        processing_parameters: &CFDictionary,
277    ) -> OSStatus {
278        extern "C-unwind" {
279            fn VTRAWProcessingSessionSetProcessingParameters(
280                session: &VTRAWProcessingSession,
281                processing_parameters: &CFDictionary,
282            ) -> OSStatus;
283        }
284        unsafe { VTRAWProcessingSessionSetProcessingParameters(self, processing_parameters) }
285    }
286}
287
288extern "C" {
289    /// The value corresponding to this key is the string used when specifying this parameter when calling VTRAWProcessingSessionSetProcessingParameters.
290    ///
291    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_key?language=objc)
292    pub static kVTRAWProcessingParameter_Key: &'static CFString;
293}
294
295extern "C" {
296    /// The value corresponding to this key is a localized string  which can be displayed in UI representing this parameter.
297    ///
298    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_name?language=objc)
299    pub static kVTRAWProcessingParameter_Name: &'static CFString;
300}
301
302extern "C" {
303    /// The value corresponding to this key is a localized string with a description of the parameter suitable for display in a tooltip or other descriptive UI.
304    ///
305    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_description?language=objc)
306    pub static kVTRAWProcessingParameter_Description: &'static CFString;
307}
308
309extern "C" {
310    /// The value corresponding to this key is Boolean indicating whether the parameter is enabled and can be modified.
311    ///
312    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_enabled?language=objc)
313    pub static kVTRAWProcessingParameter_Enabled: &'static CFString;
314}
315
316extern "C" {
317    /// The value corresponding to this key is the type of the parameter - a Boolean, Integer, Float, List, or SubGroup.
318    ///
319    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_valuetype?language=objc)
320    pub static kVTRAWProcessingParameter_ValueType: &'static CFString;
321}
322
323extern "C" {
324    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparametervaluetype_boolean?language=objc)
325    pub static kVTRAWProcessingParameterValueType_Boolean: &'static CFString;
326}
327
328extern "C" {
329    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparametervaluetype_integer?language=objc)
330    pub static kVTRAWProcessingParameterValueType_Integer: &'static CFString;
331}
332
333extern "C" {
334    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparametervaluetype_float?language=objc)
335    pub static kVTRAWProcessingParameterValueType_Float: &'static CFString;
336}
337
338extern "C" {
339    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparametervaluetype_list?language=objc)
340    pub static kVTRAWProcessingParameterValueType_List: &'static CFString;
341}
342
343extern "C" {
344    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparametervaluetype_subgroup?language=objc)
345    pub static kVTRAWProcessingParameterValueType_SubGroup: &'static CFString;
346}
347
348extern "C" {
349    /// The value corresponding to this key is a CFArray of CFDictionaries describing each element in the list..
350    ///
351    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_listarray?language=objc)
352    pub static kVTRAWProcessingParameter_ListArray: &'static CFString;
353}
354
355extern "C" {
356    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameterlistelement_label?language=objc)
357    pub static kVTRAWProcessingParameterListElement_Label: &'static CFString;
358}
359
360extern "C" {
361    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameterlistelement_description?language=objc)
362    pub static kVTRAWProcessingParameterListElement_Description: &'static CFString;
363}
364
365extern "C" {
366    /// [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameterlistelement_listelementid?language=objc)
367    pub static kVTRAWProcessingParameterListElement_ListElementID: &'static CFString;
368}
369
370extern "C" {
371    /// The value corresponding to this key is a CFArray of CFDictionaries representing the individual sub-parameters in this group.
372    ///
373    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_subgroup?language=objc)
374    pub static kVTRAWProcessingParameter_SubGroup: &'static CFString;
375}
376
377extern "C" {
378    /// The value corresponding to this key is the maximum value allowed for this parameter when calling VTRAWProcessingSessionSetProcessingParameters.
379    /// This parameter is optional and not required for parameters where it is not appropriate (such as Boolean or List types).
380    ///
381    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_maximumvalue?language=objc)
382    pub static kVTRAWProcessingParameter_MaximumValue: &'static CFString;
383}
384
385extern "C" {
386    /// The value corresponding to this key is the minimum value allowed for this parameter when calling VTRAWProcessingSessionSetProcessingParameters.
387    /// This parameter is optional and not required for parameters where it is not appropriate (such as Boolean or List types).
388    ///
389    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_minimumvalue?language=objc)
390    pub static kVTRAWProcessingParameter_MinimumValue: &'static CFString;
391}
392
393extern "C" {
394    /// The value corresponding to this key is the initial value for this parameter as defined by the container and metadata provided at creation time.
395    /// For List types, this is the ListElementID for the List element.
396    ///
397    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_initialvalue?language=objc)
398    pub static kVTRAWProcessingParameter_InitialValue: &'static CFString;
399}
400
401extern "C" {
402    /// The value corresponding to this key is a neutral setting for the processor.
403    /// For List types, this is the ListElementID for the List element.
404    ///
405    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_neutralvalue?language=objc)
406    pub static kVTRAWProcessingParameter_NeutralValue: &'static CFString;
407}
408
409extern "C" {
410    /// The value corresponding to this key is the "As Shot" value for this parameter as originally captured by the camera.
411    /// For List types, this is the ListElementID for the List element.
412    ///
413    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_cameravalue?language=objc)
414    pub static kVTRAWProcessingParameter_CameraValue: &'static CFString;
415}
416
417extern "C" {
418    /// The value corresponding to this key is the currently configured value for this parameter.  For List types, this is the ListElementID for the List element.
419    ///
420    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvtrawprocessingparameter_currentvalue?language=objc)
421    pub static kVTRAWProcessingParameter_CurrentValue: &'static CFString;
422}
423
424extern "C-unwind" {
425    #[cfg(feature = "objc2-core-media")]
426    #[deprecated = "renamed to `VTRAWProcessingSession::create`"]
427    pub fn VTRAWProcessingSessionCreate(
428        allocator: Option<&CFAllocator>,
429        format_description: &CMVideoFormatDescription,
430        output_pixel_buffer_attributes: Option<&CFDictionary>,
431        processing_session_options: Option<&CFDictionary>,
432        processing_session_out: NonNull<*mut VTRAWProcessingSession>,
433    ) -> OSStatus;
434}
435
436extern "C-unwind" {
437    #[deprecated = "renamed to `VTRAWProcessingSession::invalidate`"]
438    pub fn VTRAWProcessingSessionInvalidate(session: &VTRAWProcessingSession);
439}
440
441extern "C-unwind" {
442    #[cfg(feature = "block2")]
443    #[deprecated = "renamed to `VTRAWProcessingSession::set_parameter_changed_hander`"]
444    pub fn VTRAWProcessingSessionSetParameterChangedHander(
445        session: &VTRAWProcessingSession,
446        parameter_change_handler: VTRAWProcessingParameterChangeHandler,
447    ) -> OSStatus;
448}
449
450extern "C-unwind" {
451    #[cfg(all(feature = "block2", feature = "objc2-core-video"))]
452    #[deprecated = "renamed to `VTRAWProcessingSession::process_frame`"]
453    pub fn VTRAWProcessingSessionProcessFrame(
454        session: &VTRAWProcessingSession,
455        input_pixel_buffer: &CVPixelBuffer,
456        frame_options: Option<&CFDictionary>,
457        output_handler: VTRAWProcessingOutputHandler,
458    ) -> OSStatus;
459}
460
461extern "C-unwind" {
462    #[deprecated = "renamed to `VTRAWProcessingSession::complete_frames`"]
463    pub fn VTRAWProcessingSessionCompleteFrames(session: &VTRAWProcessingSession) -> OSStatus;
464}
465
466extern "C-unwind" {
467    #[deprecated = "renamed to `VTRAWProcessingSession::copy_processing_parameters`"]
468    pub fn VTRAWProcessingSessionCopyProcessingParameters(
469        session: &VTRAWProcessingSession,
470        out_parameter_array: NonNull<*const CFArray>,
471    ) -> OSStatus;
472}
473
474extern "C-unwind" {
475    #[deprecated = "renamed to `VTRAWProcessingSession::set_processing_parameters`"]
476    pub fn VTRAWProcessingSessionSetProcessingParameters(
477        session: &VTRAWProcessingSession,
478        processing_parameters: &CFDictionary,
479    ) -> OSStatus;
480}