objc2_audio_toolbox/generated/AudioFileStream.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::__framework_prelude::*;
8#[cfg(feature = "objc2-core-audio-types")]
9use objc2_core_audio_types::*;
10
11use crate::*;
12
13/// This flag is set in a call to AudioFileStream_PropertyListenerProc when the value of the property
14/// can be obtained at any later time. If this flag is not set, then you should either get the value of
15/// the property from within this callback or set the flag kAudioFileStreamPropertyFlag_CacheProperty in order to signal
16/// to the parser to begin caching the property data. Otherwise the value may not be available in the future.
17///
18///
19/// This flag can be set by a property listener in order to signal to the parser that the client is
20/// interested in the value of the property and that it should be cached until the full value of the property is available.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestreampropertyflags?language=objc)
23// NS_OPTIONS
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct AudioFileStreamPropertyFlags(pub u32);
27bitflags::bitflags! {
28 impl AudioFileStreamPropertyFlags: u32 {
29 #[doc(alias = "kAudioFileStreamPropertyFlag_PropertyIsCached")]
30 const PropertyIsCached = 1;
31 #[doc(alias = "kAudioFileStreamPropertyFlag_CacheProperty")]
32 const CacheProperty = 2;
33 }
34}
35
36unsafe impl Encode for AudioFileStreamPropertyFlags {
37 const ENCODING: Encoding = u32::ENCODING;
38}
39
40unsafe impl RefEncode for AudioFileStreamPropertyFlags {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// This flag is passed in to AudioFileStreamParseBytes to signal a discontinuity. Any partial packet straddling a buffer
45/// boundary will be discarded. This is necessary to avoid being called with a corrupt packet. After a discontinuity occurs
46/// seeking may be approximate in some data formats.
47///
48/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestreamparseflags?language=objc)
49// NS_OPTIONS
50#[repr(transparent)]
51#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
52pub struct AudioFileStreamParseFlags(pub u32);
53bitflags::bitflags! {
54 impl AudioFileStreamParseFlags: u32 {
55 #[doc(alias = "kAudioFileStreamParseFlag_Discontinuity")]
56 const Discontinuity = 1;
57 }
58}
59
60unsafe impl Encode for AudioFileStreamParseFlags {
61 const ENCODING: Encoding = u32::ENCODING;
62}
63
64unsafe impl RefEncode for AudioFileStreamParseFlags {
65 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68/// This flag may be returned from AudioFileStreamSeek if the byte offset is only an estimate, not exact.
69///
70/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestreamseekflags?language=objc)
71// NS_OPTIONS
72#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct AudioFileStreamSeekFlags(pub u32);
75bitflags::bitflags! {
76 impl AudioFileStreamSeekFlags: u32 {
77 #[doc(alias = "kAudioFileStreamSeekFlag_OffsetIsEstimated")]
78 const OffsetIsEstimated = 1;
79 }
80}
81
82unsafe impl Encode for AudioFileStreamSeekFlags {
83 const ENCODING: Encoding = u32::ENCODING;
84}
85
86unsafe impl RefEncode for AudioFileStreamSeekFlags {
87 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestreampropertyid?language=objc)
91pub type AudioFileStreamPropertyID = u32;
92
93/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaqueaudiofilestreamid?language=objc)
94#[repr(C)]
95#[derive(Debug)]
96pub struct OpaqueAudioFileStreamID {
97 inner: [u8; 0],
98 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
99}
100
101unsafe impl RefEncode for OpaqueAudioFileStreamID {
102 const ENCODING_REF: Encoding =
103 Encoding::Pointer(&Encoding::Struct("OpaqueAudioFileStreamID", &[]));
104}
105
106/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestreamid?language=objc)
107pub type AudioFileStreamID = *mut OpaqueAudioFileStreamID;
108
109/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestream_propertylistenerproc?language=objc)
110pub type AudioFileStream_PropertyListenerProc = Option<
111 unsafe extern "C-unwind" fn(
112 NonNull<c_void>,
113 AudioFileStreamID,
114 AudioFileStreamPropertyID,
115 NonNull<AudioFileStreamPropertyFlags>,
116 ),
117>;
118
119/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/audiofilestream_packetsproc?language=objc)
120#[cfg(feature = "objc2-core-audio-types")]
121pub type AudioFileStream_PacketsProc = Option<
122 unsafe extern "C-unwind" fn(
123 NonNull<c_void>,
124 u32,
125 u32,
126 NonNull<c_void>,
127 *mut AudioStreamPacketDescription,
128 ),
129>;
130
131/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_unsupportedfiletype?language=objc)
132pub const kAudioFileStreamError_UnsupportedFileType: OSStatus = 0x7479703f;
133/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_unsupporteddataformat?language=objc)
134pub const kAudioFileStreamError_UnsupportedDataFormat: OSStatus = 0x666d743f;
135/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_unsupportedproperty?language=objc)
136pub const kAudioFileStreamError_UnsupportedProperty: OSStatus = 0x7074793f;
137/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_badpropertysize?language=objc)
138pub const kAudioFileStreamError_BadPropertySize: OSStatus = 0x2173697a;
139/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_notoptimized?language=objc)
140pub const kAudioFileStreamError_NotOptimized: OSStatus = 0x6f70746d;
141/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_invalidpacketoffset?language=objc)
142pub const kAudioFileStreamError_InvalidPacketOffset: OSStatus = 0x70636b3f;
143/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_invalidfile?language=objc)
144pub const kAudioFileStreamError_InvalidFile: OSStatus = 0x6474613f;
145/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_valueunknown?language=objc)
146pub const kAudioFileStreamError_ValueUnknown: OSStatus = 0x756e6b3f;
147/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_dataunavailable?language=objc)
148pub const kAudioFileStreamError_DataUnavailable: OSStatus = 0x6d6f7265;
149/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_illegaloperation?language=objc)
150pub const kAudioFileStreamError_IllegalOperation: OSStatus = 0x6e6f7065;
151/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_unspecifiederror?language=objc)
152pub const kAudioFileStreamError_UnspecifiedError: OSStatus = 0x7768743f;
153/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamerror_discontinuitycantrecover?language=objc)
154pub const kAudioFileStreamError_DiscontinuityCantRecover: OSStatus = 0x64736321;
155
156/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_readytoproducepackets?language=objc)
157pub const kAudioFileStreamProperty_ReadyToProducePackets: AudioFileStreamPropertyID = 0x72656479;
158/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_fileformat?language=objc)
159pub const kAudioFileStreamProperty_FileFormat: AudioFileStreamPropertyID = 0x66666d74;
160/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_dataformat?language=objc)
161pub const kAudioFileStreamProperty_DataFormat: AudioFileStreamPropertyID = 0x64666d74;
162/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_formatlist?language=objc)
163pub const kAudioFileStreamProperty_FormatList: AudioFileStreamPropertyID = 0x666c7374;
164/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_magiccookiedata?language=objc)
165pub const kAudioFileStreamProperty_MagicCookieData: AudioFileStreamPropertyID = 0x6d676963;
166/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_audiodatabytecount?language=objc)
167pub const kAudioFileStreamProperty_AudioDataByteCount: AudioFileStreamPropertyID = 0x62636e74;
168/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_audiodatapacketcount?language=objc)
169pub const kAudioFileStreamProperty_AudioDataPacketCount: AudioFileStreamPropertyID = 0x70636e74;
170/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_maximumpacketsize?language=objc)
171pub const kAudioFileStreamProperty_MaximumPacketSize: AudioFileStreamPropertyID = 0x70737a65;
172/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_dataoffset?language=objc)
173pub const kAudioFileStreamProperty_DataOffset: AudioFileStreamPropertyID = 0x646f6666;
174/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_channellayout?language=objc)
175pub const kAudioFileStreamProperty_ChannelLayout: AudioFileStreamPropertyID = 0x636d6170;
176/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packettoframe?language=objc)
177pub const kAudioFileStreamProperty_PacketToFrame: AudioFileStreamPropertyID = 0x706b6672;
178/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_frametopacket?language=objc)
179pub const kAudioFileStreamProperty_FrameToPacket: AudioFileStreamPropertyID = 0x6672706b;
180/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_restrictsrandomaccess?language=objc)
181pub const kAudioFileStreamProperty_RestrictsRandomAccess: AudioFileStreamPropertyID = 0x72726170;
182/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packettorolldistance?language=objc)
183pub const kAudioFileStreamProperty_PacketToRollDistance: AudioFileStreamPropertyID = 0x706b726c;
184/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_previousindependentpacket?language=objc)
185pub const kAudioFileStreamProperty_PreviousIndependentPacket: AudioFileStreamPropertyID =
186 0x70696e64;
187/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_nextindependentpacket?language=objc)
188pub const kAudioFileStreamProperty_NextIndependentPacket: AudioFileStreamPropertyID = 0x6e696e64;
189/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packettodependencyinfo?language=objc)
190pub const kAudioFileStreamProperty_PacketToDependencyInfo: AudioFileStreamPropertyID = 0x706b6470;
191/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packettobyte?language=objc)
192pub const kAudioFileStreamProperty_PacketToByte: AudioFileStreamPropertyID = 0x706b6279;
193/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_bytetopacket?language=objc)
194pub const kAudioFileStreamProperty_ByteToPacket: AudioFileStreamPropertyID = 0x6279706b;
195/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packettableinfo?language=objc)
196pub const kAudioFileStreamProperty_PacketTableInfo: AudioFileStreamPropertyID = 0x706e666f;
197/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_packetsizeupperbound?language=objc)
198pub const kAudioFileStreamProperty_PacketSizeUpperBound: AudioFileStreamPropertyID = 0x706b7562;
199/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_averagebytesperpacket?language=objc)
200pub const kAudioFileStreamProperty_AverageBytesPerPacket: AudioFileStreamPropertyID = 0x61627070;
201/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_bitrate?language=objc)
202pub const kAudioFileStreamProperty_BitRate: AudioFileStreamPropertyID = 0x62726174;
203/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiofilestreamproperty_infodictionary?language=objc)
204pub const kAudioFileStreamProperty_InfoDictionary: AudioFileStreamPropertyID = 0x696e666f;
205
206extern "C-unwind" {
207 /// Create a new audio file stream parser.
208 /// The client provides the parser with data and the parser calls
209 /// callbacks when interesting things are found in the data, such as properties and
210 /// audio packets.
211 ///
212 ///
213 /// Parameter `inClientData`: a constant that will be passed to your callbacks.
214 ///
215 /// Parameter `inPropertyListenerProc`: Whenever the value of a property is parsed in the data, this function will be called.
216 /// You can then get the value of the property from in the callback. In some cases, due to
217 /// boundaries in the input data, the property may return kAudioFileStreamError_DataUnavailable.
218 /// When unavailable data is requested from within the property listener, the parser will begin
219 /// caching the property value and will call the property listener again when the property is
220 /// available. For property values for which kAudioFileStreamPropertyFlag_PropertyIsCached is unset, this
221 /// will be the only opportunity to get the value of the property, since the data will be
222 /// disposed upon return of the property listener callback.
223 ///
224 /// Parameter `inPacketsProc`: Whenever packets are parsed in the data, a pointer to the packets is passed to the client
225 /// using this callback. At times only a single packet may be passed due to boundaries in the
226 /// input data.
227 ///
228 /// Parameter `inFileTypeHint`: For files whose type cannot be easily or uniquely determined from the data (ADTS,AC3),
229 /// this hint can be used to indicate the file type.
230 /// Otherwise if you do not know the file type, you can pass zero.
231 ///
232 /// Parameter `outAudioFileStream`: A new file stream ID for use in other AudioFileStream API calls.
233 ///
234 /// # Safety
235 ///
236 /// - `in_client_data` must be a valid pointer or null.
237 /// - `in_property_listener_proc` must be implemented correctly.
238 /// - `in_packets_proc` must be implemented correctly.
239 /// - `out_audio_file_stream` must be a valid pointer.
240 #[cfg(all(feature = "AudioFile", feature = "objc2-core-audio-types"))]
241 pub fn AudioFileStreamOpen(
242 in_client_data: *mut c_void,
243 in_property_listener_proc: AudioFileStream_PropertyListenerProc,
244 in_packets_proc: AudioFileStream_PacketsProc,
245 in_file_type_hint: AudioFileTypeID,
246 out_audio_file_stream: NonNull<AudioFileStreamID>,
247 ) -> OSStatus;
248}
249
250extern "C-unwind" {
251 /// This call is the means for streams to supply data to the parser.
252 /// Data is expected to be passed in sequentially from the beginning of the file, without gaps.
253 /// In the course of parsing, the client's property and/or packets callbacks may be called.
254 /// At the end of the stream, this function must be called once with null data pointer and zero
255 /// data byte size to flush any remaining packets out of the parser.
256 ///
257 ///
258 /// Parameter `inAudioFileStream`: The file stream ID
259 ///
260 /// Parameter `inDataByteSize`: The number of bytes passed in for parsing. Must be zero when flushing the parser.
261 ///
262 /// Parameter `inData`: The data passed in to be parsed. Must be null when flushing the parser.
263 ///
264 /// Parameter `inFlags`: If there is a data discontinuity, then kAudioFileStreamParseFlag_Discontinuity should be set true.
265 ///
266 /// # Safety
267 ///
268 /// - `in_audio_file_stream` must be a valid pointer.
269 /// - `in_data` must be a valid pointer or null.
270 pub fn AudioFileStreamParseBytes(
271 in_audio_file_stream: AudioFileStreamID,
272 in_data_byte_size: u32,
273 in_data: *const c_void,
274 in_flags: AudioFileStreamParseFlags,
275 ) -> OSStatus;
276}
277
278extern "C-unwind" {
279 /// This call is used to seek in the data stream. The client passes in a packet
280 /// offset to seek to and the parser passes back a byte offset from which to
281 /// get the data to satisfy that request. The data passed to the next call to
282 /// AudioFileParseBytes will be assumed to be from that byte offset.
283 /// For file formats which do not contain packet tables the byte offset may
284 /// be an estimate. If so, the flag kAudioFileStreamSeekFlag_OffsetIsEstimated will be true.
285 ///
286 ///
287 /// Parameter `inAudioFileStream`: The file stream ID
288 ///
289 /// Parameter `inPacketOffset`: The offset from the beginning of the file of the packet to which to seek.
290 ///
291 /// Parameter `outDataByteOffset`: The byte offset of the data from the file's data offset returned.
292 /// You need to add the value of kAudioFileStreamProperty_DataOffset to get an absolute byte offset in the file.
293 ///
294 /// Parameter `ioFlags`: If outDataByteOffset is an estimate, then kAudioFileStreamSeekFlag_OffsetIsEstimated will be set on output.
295 /// There are currently no flags defined for passing into this call.
296 ///
297 /// # Safety
298 ///
299 /// - `in_audio_file_stream` must be a valid pointer.
300 /// - `out_data_byte_offset` must be a valid pointer.
301 /// - `io_flags` must be a valid pointer.
302 pub fn AudioFileStreamSeek(
303 in_audio_file_stream: AudioFileStreamID,
304 in_packet_offset: i64,
305 out_data_byte_offset: NonNull<i64>,
306 io_flags: NonNull<AudioFileStreamSeekFlags>,
307 ) -> OSStatus;
308}
309
310extern "C-unwind" {
311 /// Retrieve the info about the given property. The outSize argument
312 /// will return the size in bytes of the current value of the property.
313 ///
314 ///
315 /// Parameter `inAudioFileStream`: The file stream ID
316 ///
317 /// Parameter `inPropertyID`: Property ID whose value should be read
318 ///
319 /// Parameter `outPropertyDataSize`: Size in bytes of the property
320 ///
321 /// Parameter `outWritable`: whether the property is writable
322 ///
323 ///
324 /// Returns: an OSStatus return code
325 ///
326 /// # Safety
327 ///
328 /// - `in_audio_file_stream` must be a valid pointer.
329 /// - `out_property_data_size` must be a valid pointer or null.
330 /// - `out_writable` must be a valid pointer or null.
331 pub fn AudioFileStreamGetPropertyInfo(
332 in_audio_file_stream: AudioFileStreamID,
333 in_property_id: AudioFileStreamPropertyID,
334 out_property_data_size: *mut u32,
335 out_writable: *mut Boolean,
336 ) -> OSStatus;
337}
338
339extern "C-unwind" {
340 /// Retrieve the indicated property data.
341 ///
342 ///
343 /// Parameter `inAudioFileStream`: The file stream ID
344 ///
345 /// Parameter `inPropertyID`: Property ID whose value should be read
346 ///
347 /// Parameter `ioPropertyDataSize`: On input, the size of the buffer pointed to by outPropertyData. On output,
348 /// the number of bytes written.
349 ///
350 /// Parameter `outPropertyData`: Pointer to the property data buffer
351 ///
352 ///
353 /// Returns: an OSStatus return code
354 ///
355 /// # Safety
356 ///
357 /// - `in_audio_file_stream` must be a valid pointer.
358 /// - `io_property_data_size` must be a valid pointer.
359 /// - `out_property_data` must be a valid pointer.
360 pub fn AudioFileStreamGetProperty(
361 in_audio_file_stream: AudioFileStreamID,
362 in_property_id: AudioFileStreamPropertyID,
363 io_property_data_size: NonNull<u32>,
364 out_property_data: NonNull<c_void>,
365 ) -> OSStatus;
366}
367
368extern "C-unwind" {
369 /// Set the value of the property. There are currently no settable properties.
370 ///
371 ///
372 /// Parameter `inAudioFileStream`: The file stream ID
373 ///
374 /// Parameter `inPropertyID`: Property ID whose value should be set
375 ///
376 /// Parameter `inPropertyDataSize`: Size in bytes of the property data
377 ///
378 /// Parameter `inPropertyData`: Pointer to the property data buffer
379 ///
380 ///
381 /// Returns: an OSStatus return code
382 ///
383 /// # Safety
384 ///
385 /// - `in_audio_file_stream` must be a valid pointer.
386 /// - `in_property_data` must be a valid pointer.
387 pub fn AudioFileStreamSetProperty(
388 in_audio_file_stream: AudioFileStreamID,
389 in_property_id: AudioFileStreamPropertyID,
390 in_property_data_size: u32,
391 in_property_data: NonNull<c_void>,
392 ) -> OSStatus;
393}
394
395extern "C-unwind" {
396 /// Close and deallocate the file stream object.
397 ///
398 ///
399 /// Parameter `inAudioFileStream`: The file stream ID
400 ///
401 /// # Safety
402 ///
403 /// `in_audio_file_stream` must be a valid pointer.
404 pub fn AudioFileStreamClose(in_audio_file_stream: AudioFileStreamID) -> OSStatus;
405}