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;
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10
11use crate::*;
12
13/// A VTFrameSilo stores a large number of sample buffers, as produced by a multi-pass compression session.
14///
15/// The sample buffers are ordered by decode timestamp.
16/// A VTFrameSilo starts out empty and is populated by calls to VTFrameSiloAddSampleBuffer to add sample buffers in ascending decode order.
17/// After the first full pass, additional passes may be performed to replace sample buffers.
18/// Each such pass must begin with a call to VTFrameSiloSetTimeRangesForNextPass, which takes a list of time ranges.
19/// Samples in these time ranges are deleted, and calls to VTFrameSiloAddSampleBuffer can then be made to provide replacements.
20/// Call VTFrameSiloCallFunctionForEachSampleBuffer or VTFrameSiloCallBlockForEachSampleBuffer to retrieve sample buffers.
21/// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
22/// do not expect to get identical object pointers back.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframesilo?language=objc)
25#[repr(C)]
26pub struct VTFrameSilo {
27    inner: [u8; 0],
28    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
29}
30
31cf_type!(
32    #[encoding_name = "OpaqueVTFrameSilo"]
33    unsafe impl VTFrameSilo {}
34);
35
36unsafe impl ConcreteType for VTFrameSilo {
37    #[doc(alias = "VTFrameSiloGetTypeID")]
38    #[inline]
39    fn type_id() -> CFTypeID {
40        extern "C-unwind" {
41            fn VTFrameSiloGetTypeID() -> CFTypeID;
42        }
43        unsafe { VTFrameSiloGetTypeID() }
44    }
45}
46
47extern "C-unwind" {
48    /// Creates a VTFrameSilo object using a temporary file.
49    ///
50    /// The returned VTFrameSilo object may be used to gather frames produced by multi-pass encoding.
51    ///
52    /// Parameter `fileURL`: Specifies where to put the backing file for the VTFrameSilo object.
53    /// If you pass NULL for fileURL, the video toolbox will pick a unique temporary file name.
54    ///
55    /// Parameter `options`: Reserved, pass NULL.
56    ///
57    /// Parameter `timeRange`: The valid time range for the frame silo. Must be valid for progress reporting.
58    ///
59    /// Parameter `frameSiloOut`: Points to a VTFrameSiloRef to receive the newly created object.
60    /// Call CFRelease to release your retain on the created VTFrameSilo object when you are done with it.
61    #[cfg(feature = "objc2-core-media")]
62    pub fn VTFrameSiloCreate(
63        allocator: Option<&CFAllocator>,
64        file_url: Option<&CFURL>,
65        time_range: CMTimeRange,
66        options: Option<&CFDictionary>,
67        frame_silo_out: NonNull<*mut VTFrameSilo>,
68    ) -> OSStatus;
69}
70
71extern "C-unwind" {
72    /// Adds a sample buffer to a VTFrameSilo object.
73    ///
74    /// Within each pass, sample buffers must have strictly increasing decode timestamps.
75    /// Passes after the first pass are begun with a call to VTFrameSiloSetTimeRangesForNextPass.
76    /// After a call to VTFrameSiloSetTimeRangesForNextPass, sample buffer decode timestamps must also be within
77    /// the stated time ranges.
78    /// Note that CMTimeRanges are considered to contain their start times but not their end times.
79    ///
80    /// Returns: Returns kVTFrameSiloInvalidTimeStampErr if an attempt is made to add a sample buffer with an inappropriate decode timestamp.
81    #[cfg(feature = "objc2-core-media")]
82    pub fn VTFrameSiloAddSampleBuffer(
83        silo: &VTFrameSilo,
84        sample_buffer: &CMSampleBuffer,
85    ) -> OSStatus;
86}
87
88extern "C-unwind" {
89    /// Begins a new pass of samples to be added to a VTFrameSilo object.
90    ///
91    /// Previously-added sample buffers with decode timestamps within the time ranges will be deleted from the VTFrameSilo.
92    /// It is not necessary to call VTFrameSiloSetTimeRangesForNextPass before adding the first pass' sample buffers.
93    ///
94    /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
95    #[cfg(feature = "objc2-core-media")]
96    pub fn VTFrameSiloSetTimeRangesForNextPass(
97        silo: &VTFrameSilo,
98        time_range_count: CMItemCount,
99        time_range_array: NonNull<CMTimeRange>,
100    ) -> OSStatus;
101}
102
103extern "C-unwind" {
104    /// Gets the progress of the current pass.
105    ///
106    /// Calculates the current progress based on the most recent sample buffer added and the current pass time ranges.
107    ///
108    /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
109    pub fn VTFrameSiloGetProgressOfCurrentPass(
110        silo: &VTFrameSilo,
111        progress_out: NonNull<f32>,
112    ) -> OSStatus;
113}
114
115extern "C-unwind" {
116    /// Retrieves sample buffers from a VTFrameSilo object.
117    ///
118    /// You call this function to retrieve sample buffers at the end of a multi-pass compression session.
119    ///
120    /// Parameter `timeRange`: The decode time range of sample buffers to retrieve.
121    /// Pass kCMTimeRangeInvalid to retrieve all sample buffers from the VTFrameSilo.
122    ///
123    /// Parameter `callback`: A function to be called, in decode order, with each sample buffer that was added.
124    /// To abort iteration early, return a nonzero status.
125    /// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
126    /// do not expect to get identical object pointers back.
127    ///
128    /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
129    /// Returns any nonzero status returned by the callback function.
130    #[cfg(feature = "objc2-core-media")]
131    pub fn VTFrameSiloCallFunctionForEachSampleBuffer(
132        silo: &VTFrameSilo,
133        time_range: CMTimeRange,
134        refcon: *mut c_void,
135        callback: unsafe extern "C-unwind" fn(*mut c_void, NonNull<CMSampleBuffer>) -> OSStatus,
136    ) -> OSStatus;
137}
138
139extern "C-unwind" {
140    /// Retrieves sample buffers from a VTFrameSilo object.
141    ///
142    /// You call this function to retrieve sample buffers at the end of a multi-pass compression session.
143    ///
144    /// Parameter `timeRange`: The decode time range of sample buffers to retrieve.
145    /// Pass kCMTimeRangeInvalid to retrieve all sample buffers from the VTFrameSilo.
146    ///
147    /// Parameter `handler`: A block to be called, in decode order, with each sample buffer that was added.
148    /// To abort iteration early, return a nonzero status.
149    /// The VTFrameSilo may write sample buffers and data to the backing file between addition and retrieval;
150    /// do not expect to get identical object pointers back.
151    ///
152    /// Returns: Returns kVTFrameSiloInvalidTimeRangeErr if any time ranges are non-numeric, overlap or are not in ascending order.
153    /// Returns any nonzero status returned by the handler block.
154    #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
155    pub fn VTFrameSiloCallBlockForEachSampleBuffer(
156        silo: &VTFrameSilo,
157        time_range: CMTimeRange,
158        handler: &block2::Block<dyn Fn(NonNull<CMSampleBuffer>) -> OSStatus>,
159    ) -> OSStatus;
160}