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