objc2_video_toolbox/generated/VTFrameSilo.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
13use crate::*;
14
15/// A VTFrameSilo stores a large number of sample buffers, as produced by a multi-pass compression session.
16///
17/// The sample buffers are ordered by decode timestamp.
18/// A VTFrameSilo starts out empty and is populated by calls to VTFrameSiloAddSampleBuffer to add sample buffers in ascending decode order.
19/// After the first full pass, additional passes may be performed to replace sample buffers.
20/// Each such pass must begin with a call to VTFrameSiloSetTimeRangesForNextPass, which takes a list of time ranges.
21/// Samples in these time ranges are deleted, and calls to VTFrameSiloAddSampleBuffer can then be made to provide replacements.
22/// Call VTFrameSiloCallFunctionForEachSampleBuffer or VTFrameSiloCallBlockForEachSampleBuffer to retrieve sample buffers.
23/// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
24/// do not expect to get identical object pointers back.
25///
26/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframesilo?language=objc)
27#[doc(alias = "VTFrameSiloRef")]
28#[repr(C)]
29pub struct VTFrameSilo {
30 inner: [u8; 0],
31 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
32}
33
34cf_type!(
35 unsafe impl VTFrameSilo {}
36);
37#[cfg(feature = "objc2")]
38cf_objc2_type!(
39 unsafe impl RefEncode<"OpaqueVTFrameSilo"> for VTFrameSilo {}
40);
41
42unsafe impl ConcreteType for VTFrameSilo {
43 #[doc(alias = "VTFrameSiloGetTypeID")]
44 #[inline]
45 fn type_id() -> CFTypeID {
46 extern "C-unwind" {
47 fn VTFrameSiloGetTypeID() -> CFTypeID;
48 }
49 unsafe { VTFrameSiloGetTypeID() }
50 }
51}
52
53impl VTFrameSilo {
54 /// Creates a VTFrameSilo object using a temporary file.
55 ///
56 /// The returned VTFrameSilo object may be used to gather frames produced by multi-pass encoding.
57 ///
58 /// Parameter `fileURL`: Specifies where to put the backing file for the VTFrameSilo object.
59 /// If you pass NULL for fileURL, the video toolbox will pick a unique temporary file name.
60 ///
61 /// Parameter `options`: Reserved, pass NULL.
62 ///
63 /// Parameter `timeRange`: The valid time range for the frame silo. Must be valid for progress reporting.
64 ///
65 /// Parameter `frameSiloOut`: Points to a VTFrameSiloRef to receive the newly created object.
66 /// Call CFRelease to release your retain on the created VTFrameSilo object when you are done with it.
67 ///
68 /// # Safety
69 ///
70 /// - `options` generics must be of the correct type.
71 /// - `frame_silo_out` must be a valid pointer.
72 #[doc(alias = "VTFrameSiloCreate")]
73 #[cfg(feature = "objc2-core-media")]
74 #[inline]
75 pub unsafe fn create(
76 allocator: Option<&CFAllocator>,
77 file_url: Option<&CFURL>,
78 time_range: CMTimeRange,
79 options: Option<&CFDictionary>,
80 frame_silo_out: NonNull<*mut VTFrameSilo>,
81 ) -> OSStatus {
82 extern "C-unwind" {
83 fn VTFrameSiloCreate(
84 allocator: Option<&CFAllocator>,
85 file_url: Option<&CFURL>,
86 time_range: CMTimeRange,
87 options: Option<&CFDictionary>,
88 frame_silo_out: NonNull<*mut VTFrameSilo>,
89 ) -> OSStatus;
90 }
91 unsafe { VTFrameSiloCreate(allocator, file_url, time_range, options, frame_silo_out) }
92 }
93
94 /// Adds a sample buffer to a VTFrameSilo object.
95 ///
96 /// Within each pass, sample buffers must have strictly increasing decode timestamps.
97 /// Passes after the first pass are begun with a call to VTFrameSiloSetTimeRangesForNextPass.
98 /// After a call to VTFrameSiloSetTimeRangesForNextPass, sample buffer decode timestamps must also be within
99 /// the stated time ranges.
100 /// Note that CMTimeRanges are considered to contain their start times but not their end times.
101 ///
102 /// Returns: Returns kVTFrameSiloInvalidTimeStampErr if an attempt is made to add a sample buffer with an inappropriate decode timestamp.
103 #[doc(alias = "VTFrameSiloAddSampleBuffer")]
104 #[cfg(feature = "objc2-core-media")]
105 #[inline]
106 pub unsafe fn add_sample_buffer(&self, sample_buffer: &CMSampleBuffer) -> OSStatus {
107 extern "C-unwind" {
108 fn VTFrameSiloAddSampleBuffer(
109 silo: &VTFrameSilo,
110 sample_buffer: &CMSampleBuffer,
111 ) -> OSStatus;
112 }
113 unsafe { VTFrameSiloAddSampleBuffer(self, sample_buffer) }
114 }
115
116 /// Begins a new pass of samples to be added to a VTFrameSilo object.
117 ///
118 /// Previously-added sample buffers with decode timestamps within the time ranges will be deleted from the VTFrameSilo.
119 /// It is not necessary to call VTFrameSiloSetTimeRangesForNextPass before adding the first pass' sample buffers.
120 ///
121 /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
122 ///
123 /// # Safety
124 ///
125 /// `time_range_array` must be a valid pointer.
126 #[doc(alias = "VTFrameSiloSetTimeRangesForNextPass")]
127 #[cfg(feature = "objc2-core-media")]
128 #[inline]
129 pub unsafe fn set_time_ranges_for_next_pass(
130 &self,
131 time_range_count: CMItemCount,
132 time_range_array: NonNull<CMTimeRange>,
133 ) -> OSStatus {
134 extern "C-unwind" {
135 fn VTFrameSiloSetTimeRangesForNextPass(
136 silo: &VTFrameSilo,
137 time_range_count: CMItemCount,
138 time_range_array: NonNull<CMTimeRange>,
139 ) -> OSStatus;
140 }
141 unsafe { VTFrameSiloSetTimeRangesForNextPass(self, time_range_count, time_range_array) }
142 }
143
144 /// Gets the progress of the current pass.
145 ///
146 /// Calculates the current progress based on the most recent sample buffer added and the current pass time ranges.
147 ///
148 /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
149 ///
150 /// # Safety
151 ///
152 /// `progress_out` must be a valid pointer.
153 #[doc(alias = "VTFrameSiloGetProgressOfCurrentPass")]
154 #[inline]
155 pub unsafe fn progress_of_current_pass(&self, progress_out: NonNull<f32>) -> OSStatus {
156 extern "C-unwind" {
157 fn VTFrameSiloGetProgressOfCurrentPass(
158 silo: &VTFrameSilo,
159 progress_out: NonNull<f32>,
160 ) -> OSStatus;
161 }
162 unsafe { VTFrameSiloGetProgressOfCurrentPass(self, progress_out) }
163 }
164
165 /// Retrieves sample buffers from a VTFrameSilo object.
166 ///
167 /// You call this function to retrieve sample buffers at the end of a multi-pass compression session.
168 ///
169 /// Parameter `timeRange`: The decode time range of sample buffers to retrieve.
170 /// Pass kCMTimeRangeInvalid to retrieve all sample buffers from the VTFrameSilo.
171 ///
172 /// Parameter `callback`: A function to be called, in decode order, with each sample buffer that was added.
173 /// To abort iteration early, return a nonzero status.
174 /// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
175 /// do not expect to get identical object pointers back.
176 ///
177 /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
178 /// Returns any nonzero status returned by the callback function.
179 ///
180 /// # Safety
181 ///
182 /// - `refcon` must be a valid pointer or null.
183 /// - `callback` must be implemented correctly.
184 #[doc(alias = "VTFrameSiloCallFunctionForEachSampleBuffer")]
185 #[cfg(feature = "objc2-core-media")]
186 #[inline]
187 pub unsafe fn call_function_for_each_sample_buffer(
188 &self,
189 time_range: CMTimeRange,
190 refcon: *mut c_void,
191 callback: unsafe extern "C-unwind" fn(*mut c_void, NonNull<CMSampleBuffer>) -> OSStatus,
192 ) -> OSStatus {
193 extern "C-unwind" {
194 fn VTFrameSiloCallFunctionForEachSampleBuffer(
195 silo: &VTFrameSilo,
196 time_range: CMTimeRange,
197 refcon: *mut c_void,
198 callback: unsafe extern "C-unwind" fn(
199 *mut c_void,
200 NonNull<CMSampleBuffer>,
201 ) -> OSStatus,
202 ) -> OSStatus;
203 }
204 unsafe { VTFrameSiloCallFunctionForEachSampleBuffer(self, time_range, refcon, callback) }
205 }
206
207 /// Retrieves sample buffers from a VTFrameSilo object.
208 ///
209 /// You call this function to retrieve sample buffers at the end of a multi-pass compression session.
210 ///
211 /// Parameter `timeRange`: The decode time range of sample buffers to retrieve.
212 /// Pass kCMTimeRangeInvalid to retrieve all sample buffers from the VTFrameSilo.
213 ///
214 /// Parameter `handler`: A block to be called, in decode order, with each sample buffer that was added.
215 /// To abort iteration early, return a nonzero status.
216 /// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
217 /// do not expect to get identical object pointers back.
218 ///
219 /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
220 /// Returns any nonzero status returned by the handler block.
221 #[doc(alias = "VTFrameSiloCallBlockForEachSampleBuffer")]
222 #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
223 #[inline]
224 pub unsafe fn call_block_for_each_sample_buffer(
225 &self,
226 time_range: CMTimeRange,
227 handler: &block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>) -> OSStatus>,
228 ) -> OSStatus {
229 extern "C-unwind" {
230 fn VTFrameSiloCallBlockForEachSampleBuffer(
231 silo: &VTFrameSilo,
232 time_range: CMTimeRange,
233 handler: &block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>) -> OSStatus>,
234 ) -> OSStatus;
235 }
236 unsafe { VTFrameSiloCallBlockForEachSampleBuffer(self, time_range, handler) }
237 }
238}
239
240extern "C-unwind" {
241 #[cfg(feature = "objc2-core-media")]
242 #[deprecated = "renamed to `VTFrameSilo::create`"]
243 pub fn VTFrameSiloCreate(
244 allocator: Option<&CFAllocator>,
245 file_url: Option<&CFURL>,
246 time_range: CMTimeRange,
247 options: Option<&CFDictionary>,
248 frame_silo_out: NonNull<*mut VTFrameSilo>,
249 ) -> OSStatus;
250}
251
252extern "C-unwind" {
253 #[cfg(feature = "objc2-core-media")]
254 #[deprecated = "renamed to `VTFrameSilo::add_sample_buffer`"]
255 pub fn VTFrameSiloAddSampleBuffer(
256 silo: &VTFrameSilo,
257 sample_buffer: &CMSampleBuffer,
258 ) -> OSStatus;
259}
260
261extern "C-unwind" {
262 #[cfg(feature = "objc2-core-media")]
263 #[deprecated = "renamed to `VTFrameSilo::set_time_ranges_for_next_pass`"]
264 pub fn VTFrameSiloSetTimeRangesForNextPass(
265 silo: &VTFrameSilo,
266 time_range_count: CMItemCount,
267 time_range_array: NonNull<CMTimeRange>,
268 ) -> OSStatus;
269}
270
271extern "C-unwind" {
272 #[deprecated = "renamed to `VTFrameSilo::progress_of_current_pass`"]
273 pub fn VTFrameSiloGetProgressOfCurrentPass(
274 silo: &VTFrameSilo,
275 progress_out: NonNull<f32>,
276 ) -> OSStatus;
277}
278
279extern "C-unwind" {
280 #[cfg(feature = "objc2-core-media")]
281 #[deprecated = "renamed to `VTFrameSilo::call_function_for_each_sample_buffer`"]
282 pub fn VTFrameSiloCallFunctionForEachSampleBuffer(
283 silo: &VTFrameSilo,
284 time_range: CMTimeRange,
285 refcon: *mut c_void,
286 callback: unsafe extern "C-unwind" fn(*mut c_void, NonNull<CMSampleBuffer>) -> OSStatus,
287 ) -> OSStatus;
288}
289
290extern "C-unwind" {
291 #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
292 #[deprecated = "renamed to `VTFrameSilo::call_block_for_each_sample_buffer`"]
293 pub fn VTFrameSiloCallBlockForEachSampleBuffer(
294 silo: &VTFrameSilo,
295 time_range: CMTimeRange,
296 handler: &block2::DynBlock<dyn Fn(NonNull<CMSampleBuffer>) -> OSStatus>,
297 ) -> OSStatus;
298}