objc2_cinematic/generated/
CNSpatialAudio.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-av-foundation")]
7use objc2_av_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Standard rendering styles for Audio Mix type effects
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnspatialaudiorenderingstyle?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct CNSpatialAudioRenderingStyle(pub NSInteger);
19impl CNSpatialAudioRenderingStyle {
20    /// Isolates the ambience and place it in a spatial stem. Isolates all voices and place them in a mono stem.
21    #[doc(alias = "CNSpatialAudioRenderingStyleCinematic")]
22    pub const Cinematic: Self = Self(0);
23    /// Isolates the ambience and place it in a spatial stem. Isolates all voices, add a studio/proximity effect in the voice track and place them in a mono stem.
24    #[doc(alias = "CNSpatialAudioRenderingStyleStudio")]
25    pub const Studio: Self = Self(1);
26    /// Isolates the ambience and place it in a spatial stem. Isolates only voices from the camera field of view and place them in a mono stem.
27    #[doc(alias = "CNSpatialAudioRenderingStyleInFrame")]
28    pub const InFrame: Self = Self(2);
29    /// Isolates the ambience when foreground is cinematic Audio Mix and place it in a spatial stem. There is no voice stem.
30    #[doc(alias = "CNSpatialAudioRenderingStyleCinematicBackgroundStem")]
31    pub const CinematicBackgroundStem: Self = Self(3);
32    /// Isolates all voices and places them in a mono stem. There is no ambience stem.
33    #[doc(alias = "CNSpatialAudioRenderingStyleCinematicForegroundStem")]
34    pub const CinematicForegroundStem: Self = Self(4);
35    /// Isolates all voices, add a studio/proximity effect in the voice track and place them in a mono stem. There is no ambience stem.
36    #[doc(alias = "CNSpatialAudioRenderingStyleStudioForegroundStem")]
37    pub const StudioForegroundStem: Self = Self(5);
38    /// Isolates only voices from the camera field of view and place them in a mono stem. There is no ambience stem.
39    #[doc(alias = "CNSpatialAudioRenderingStyleInFrameForegroundStem")]
40    pub const InFrameForegroundStem: Self = Self(6);
41    /// This produces a spatial stem of the original recording that is unprocessed. This is the default rendering style.
42    #[doc(alias = "CNSpatialAudioRenderingStyleStandard")]
43    pub const Standard: Self = Self(7);
44    /// Isolates the ambience when foreground is studio Audio Mix and place it in a spatial stem. There is no voice stem.
45    #[doc(alias = "CNSpatialAudioRenderingStyleStudioBackgroundStem")]
46    pub const StudioBackgroundStem: Self = Self(8);
47    /// Isolates the ambience and foreground that is out of frame and place it in a spatial stem. There is no voice stem.
48    #[doc(alias = "CNSpatialAudioRenderingStyleInFrameBackgroundStem")]
49    pub const InFrameBackgroundStem: Self = Self(9);
50}
51
52unsafe impl Encode for CNSpatialAudioRenderingStyle {
53    const ENCODING: Encoding = NSInteger::ENCODING;
54}
55
56unsafe impl RefEncode for CNSpatialAudioRenderingStyle {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60/// Enum used to generate settings dictionary for export using AssetReader and AssetWriter with Spatial Audio effects burned in
61///
62/// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnspatialaudiocontenttype?language=objc)
63// NS_ENUM
64#[repr(transparent)]
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66pub struct CNSpatialAudioContentType(pub NSInteger);
67impl CNSpatialAudioContentType {
68    /// Export settings to generate an asset with stereo audio and effect burned in
69    #[doc(alias = "CNSpatialAudioContentTypeStereo")]
70    pub const Stereo: Self = Self(0);
71    /// Export settings to generate an asset with spatial audio and effect burned in
72    #[doc(alias = "CNSpatialAudioContentTypeSpatial")]
73    pub const Spatial: Self = Self(1);
74}
75
76unsafe impl Encode for CNSpatialAudioContentType {
77    const ENCODING: Encoding = NSInteger::ENCODING;
78}
79
80unsafe impl RefEncode for CNSpatialAudioContentType {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84extern_class!(
85    /// A helper class to inspect recordings made when Spatial Audio setting is turned on. An instance of this class contains the default audio track with Spatial Audio, metadata read from the file that can be applied
86    /// during to enhance the playback experience. This class also provides tunable parameters to change the intensity
87    /// &
88    /// mode of the playback experience.
89    ///
90    ///
91    /// The goal of this class is to assist users operate on assets in which audio has been captured in multiple formats like Spatial Audio and Stereo to allow more audio customization.
92    /// Users can audition playback of this asset with an immersive audio rendering effect applied by fetching an AVAudioMix containing the necessary metadata serialized in the file as well as any user supplied changes.
93    /// Once the results of the audition are satisfactory, clients can create a copy of the asset with the audio effect burned in.
94    ///
95    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnassetspatialaudioinfo?language=objc)
96    #[unsafe(super(NSObject))]
97    #[derive(Debug, PartialEq, Eq, Hash)]
98    pub struct CNAssetSpatialAudioInfo;
99);
100
101unsafe impl Send for CNAssetSpatialAudioInfo {}
102
103unsafe impl Sync for CNAssetSpatialAudioInfo {}
104
105extern_conformance!(
106    unsafe impl NSObjectProtocol for CNAssetSpatialAudioInfo {}
107);
108
109impl CNAssetSpatialAudioInfo {
110    extern_methods!(
111        #[unsafe(method(init))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
114
115        #[unsafe(method(new))]
116        #[unsafe(method_family = new)]
117        pub unsafe fn new() -> Retained<Self>;
118
119        /// Indicates whether the current device supports Audio Mix.
120        #[unsafe(method(isSupported))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn isSupported() -> bool;
123
124        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
125        /// Check if asset meets all the requirements to operate with Spatial Audio and its accompanying effects
126        ///
127        /// Parameter `asset`: An instance of AVAsset.
128        ///
129        /// Parameter `completionHandler`: Completion handler to return the result
130        ///
131        /// Returns: Boolean
132        #[unsafe(method(checkIfContainsSpatialAudio:completionHandler:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn checkIfContainsSpatialAudio_completionHandler(
135            asset: &AVAsset,
136            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
137        );
138
139        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
140        /// Returns an instance of CNAssetAudioInfo for an AVAsset object asynchronously.
141        ///
142        /// Parameter `asset`: An instance of AVAsset
143        ///
144        /// Parameter `completionHandler`: Completion handler to return the result
145        ///
146        /// Returns: An instance of CNAssetSpatialAudioInfo delivered via the completion handler or an error on failure
147        #[unsafe(method(loadFromAsset:completionHandler:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn loadFromAsset_completionHandler(
150            asset: &AVAsset,
151            completion_handler: &block2::DynBlock<
152                dyn Fn(*mut CNAssetSpatialAudioInfo, *mut NSError),
153            >,
154        );
155    );
156}
157
158/// Properties.
159impl CNAssetSpatialAudioInfo {
160    extern_methods!(
161        #[cfg(feature = "objc2-av-foundation")]
162        /// default `AVAssetTrack` containing Spatial Audio
163        ///
164        /// This property is not atomic.
165        ///
166        /// # Safety
167        ///
168        /// This might not be thread-safe.
169        #[unsafe(method(defaultSpatialAudioTrack))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn defaultSpatialAudioTrack(&self) -> Retained<AVAssetTrack>;
172
173        /// default effect intensity value as provided by the system. Supported range is [0.0-1.0]
174        ///
175        /// This property is not atomic.
176        ///
177        /// # Safety
178        ///
179        /// This might not be thread-safe.
180        #[unsafe(method(defaultEffectIntensity))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn defaultEffectIntensity(&self) -> c_float;
183
184        /// default rendering style as provided by the system
185        ///
186        /// This property is not atomic.
187        ///
188        /// # Safety
189        ///
190        /// This might not be thread-safe.
191        #[unsafe(method(defaultRenderingStyle))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn defaultRenderingStyle(&self) -> CNSpatialAudioRenderingStyle;
194
195        /// The result of audio analysis during recording which contains metadata necessary to properly configure the Audio Mix feature during playback or editing..
196        /// Can be used with `AUAudioUnit` instances that support AudioUnitPropertyID `kProperty_SpatialAudioMixMetadata`
197        ///
198        /// This property is not atomic.
199        ///
200        /// # Safety
201        ///
202        /// This might not be thread-safe.
203        #[unsafe(method(spatialAudioMixMetadata))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn spatialAudioMixMetadata(&self) -> Retained<NSData>;
206    );
207}
208
209/// SynthesizeAVFoundationObjects.
210impl CNAssetSpatialAudioInfo {
211    extern_methods!(
212        #[cfg(feature = "objc2-av-foundation")]
213        /// returns an instance of `AVAudioMix` encapsulating all spatial audio related data with specified effect intensity and rendering style.
214        ///
215        /// Returns an `AVAudioMix` containing all the necessary state to operate on the asset with Spatial Audio effects enabled
216        #[unsafe(method(audioMixWithEffectIntensity:renderingStyle:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn audioMixWithEffectIntensity_renderingStyle(
219            &self,
220            effect_intensity: c_float,
221            rendering_style: CNSpatialAudioRenderingStyle,
222        ) -> Retained<AVAudioMix>;
223
224        /// Returns a dictionary of settings and the source track that should be used to fetch LPCM samples from this track with the effect applied
225        ///
226        /// Use the returned NSDictionary with the `defaulSpatialAudioTrack` to initialize an instance of `AVAssetReaderAudioMixOutput`
227        #[unsafe(method(assetReaderOutputSettingsForContentType:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn assetReaderOutputSettingsForContentType(
230            &self,
231            content_type: CNSpatialAudioContentType,
232        ) -> Retained<NSDictionary<NSString, AnyObject>>;
233
234        /// Returns a dictionary of settings that should be used to encode LPCM samples using `AVAssetWriterInput`
235        #[unsafe(method(assetWriterInputSettingsForContentType:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn assetWriterInputSettingsForContentType(
238            &self,
239            content_type: CNSpatialAudioContentType,
240        ) -> Retained<NSDictionary<NSString, AnyObject>>;
241    );
242}