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