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    #[cfg(all(feature = "AudioFile", feature = "objc2-core-audio-types"))]
234    pub fn AudioFileStreamOpen(
235        in_client_data: *mut c_void,
236        in_property_listener_proc: AudioFileStream_PropertyListenerProc,
237        in_packets_proc: AudioFileStream_PacketsProc,
238        in_file_type_hint: AudioFileTypeID,
239        out_audio_file_stream: NonNull<AudioFileStreamID>,
240    ) -> OSStatus;
241}
242
243extern "C-unwind" {
244    /// This call is the means for streams to supply data to the parser.
245    /// Data is expected to be passed in sequentially from the beginning of the file, without gaps.
246    /// In the course of parsing, the client's property and/or packets callbacks may be called.
247    /// At the end of the stream, this function must be called once with null data pointer and zero
248    /// data byte size to flush any remaining packets out of the parser.
249    ///
250    ///
251    /// Parameter `inAudioFileStream`: The file stream ID
252    ///
253    /// Parameter `inDataByteSize`: The number of bytes passed in for parsing. Must be zero when flushing the parser.
254    ///
255    /// Parameter `inData`: The data passed in to be parsed. Must be null when flushing the parser.
256    ///
257    /// Parameter `inFlags`: If there is a data discontinuity, then kAudioFileStreamParseFlag_Discontinuity should be set true.
258    pub fn AudioFileStreamParseBytes(
259        in_audio_file_stream: AudioFileStreamID,
260        in_data_byte_size: u32,
261        in_data: *const c_void,
262        in_flags: AudioFileStreamParseFlags,
263    ) -> OSStatus;
264}
265
266extern "C-unwind" {
267    /// This call is used to seek in the data stream. The client passes in a packet
268    /// offset to seek to and the parser passes back a byte offset from which to
269    /// get the data to satisfy that request. The data passed to the next call to
270    /// AudioFileParseBytes will be assumed to be from that byte offset.
271    /// For file formats which do not contain packet tables the byte offset may
272    /// be an estimate. If so, the flag kAudioFileStreamSeekFlag_OffsetIsEstimated will be true.
273    ///
274    ///
275    /// Parameter `inAudioFileStream`: The file stream ID
276    ///
277    /// Parameter `inPacketOffset`: The offset from the beginning of the file of the packet to which to seek.
278    ///
279    /// Parameter `outDataByteOffset`: The byte offset of the data from the file's data offset returned.
280    /// You need to add the value of kAudioFileStreamProperty_DataOffset to get an absolute byte offset in the file.
281    ///
282    /// Parameter `ioFlags`: If outDataByteOffset is an estimate, then kAudioFileStreamSeekFlag_OffsetIsEstimated will be set on output.
283    /// There are currently no flags defined for passing into this call.
284    pub fn AudioFileStreamSeek(
285        in_audio_file_stream: AudioFileStreamID,
286        in_packet_offset: i64,
287        out_data_byte_offset: NonNull<i64>,
288        io_flags: NonNull<AudioFileStreamSeekFlags>,
289    ) -> OSStatus;
290}
291
292extern "C-unwind" {
293    /// Retrieve the info about the given property. The outSize argument
294    /// will return the size in bytes of the current value of the property.
295    ///
296    ///
297    /// Parameter `inAudioFileStream`: The file stream ID
298    ///
299    /// Parameter `inPropertyID`: Property ID whose value should be read
300    ///
301    /// Parameter `outPropertyDataSize`: Size in bytes of the property
302    ///
303    /// Parameter `outWritable`: whether the property is writable
304    ///
305    ///
306    /// Returns: an OSStatus return code
307    pub fn AudioFileStreamGetPropertyInfo(
308        in_audio_file_stream: AudioFileStreamID,
309        in_property_id: AudioFileStreamPropertyID,
310        out_property_data_size: *mut u32,
311        out_writable: *mut Boolean,
312    ) -> OSStatus;
313}
314
315extern "C-unwind" {
316    /// Retrieve the indicated property data.
317    ///
318    ///
319    /// Parameter `inAudioFileStream`: The file stream ID
320    ///
321    /// Parameter `inPropertyID`: Property ID whose value should be read
322    ///
323    /// Parameter `ioPropertyDataSize`: On input, the size of the buffer pointed to by outPropertyData. On output,
324    /// the number of bytes written.
325    ///
326    /// Parameter `outPropertyData`: Pointer to the property data buffer
327    ///
328    ///
329    /// Returns: an OSStatus return code
330    pub fn AudioFileStreamGetProperty(
331        in_audio_file_stream: AudioFileStreamID,
332        in_property_id: AudioFileStreamPropertyID,
333        io_property_data_size: NonNull<u32>,
334        out_property_data: NonNull<c_void>,
335    ) -> OSStatus;
336}
337
338extern "C-unwind" {
339    /// Set the value of the property. There are currently no settable properties.
340    ///
341    ///
342    /// Parameter `inAudioFileStream`: The file stream ID
343    ///
344    /// Parameter `inPropertyID`: Property ID whose value should be set
345    ///
346    /// Parameter `inPropertyDataSize`: Size in bytes of the property data
347    ///
348    /// Parameter `inPropertyData`: Pointer to the property data buffer
349    ///
350    ///
351    /// Returns: an OSStatus return code
352    pub fn AudioFileStreamSetProperty(
353        in_audio_file_stream: AudioFileStreamID,
354        in_property_id: AudioFileStreamPropertyID,
355        in_property_data_size: u32,
356        in_property_data: NonNull<c_void>,
357    ) -> OSStatus;
358}
359
360extern "C-unwind" {
361    /// Close and deallocate the file stream object.
362    ///
363    ///
364    /// Parameter `inAudioFileStream`: The file stream ID
365    pub fn AudioFileStreamClose(in_audio_file_stream: AudioFileStreamID) -> OSStatus;
366}