Audio File Stream Services
Parse streamed audio files as the data arrives on the user’s computer.
Overview
Audio File Stream Services provides the interface for parsing streamed audio files—in which only a limited window of data is available at a time.
Audio file streams, by nature, are not random access. When you request data from a stream, earlier data might no longer be accessible and later data might not yet be available. In addition, the data you obtain (and then provide to a parser) might include partial packets. To parse streamed audio data, then, a parser must remember data from partially satisfied requests, and must be able to wait for the remainder of that data. In other words, a parser must be able to suspend parsing as needed and then resume where it left off.
To use a parser, you pass data from a streamed audio file, as you acquire it, to the parser. When the parser has a complete packet of audio data or a complete property, it invokes a callback function. Your callbacks then process the parsed data—such as by playing it or writing it to disk.
Here, in outline form, is a typical usage pattern for an audio file stream parser:
Create a new audio file stream parser by calling the AudioFileStreamOpen(_:_:_:_:_:) function. Pass pointers to your callback functions for audio data and metadata (AudioFileStream_PacketsProc and AudioFileStream_PropertyListenerProc). The AudioFileStreamOpen(_:_:_:_:_:) function gives you a reference to the new parser.
Acquire some streamed data. Call the AudioFileStreamParseBytes(_:_:_:_:) function when you have data to pass to the parser. Send the data to the parser sequentially and, if possible, without gaps.
When the parser acquires a usable buffer of audio data, it invokes your audio data callback. Your callback can then play the data, write it to a file, or otherwise process it.
When the parser acquires metadata, it invokes your property callback—which in turn can obtain the property value by calling the AudioFileStreamGetPropertyInfo(_:_:_:_:) and AudioFileStreamGetProperty(_:_:_:_:) functions.
When finished parsing a stream, call the AudioFileStreamClose(_:) function to close and deallocate the parser.
Audio File Stream Services supports the following audio data types:
AIFF
AIFC
WAVE
CAF
NeXT
ADTS
MPEG Audio Layer 3
AAC
Topics
Opening Audio File Streams
Supplying Data to the Parser
Seeking Packets in the Data Stream
Working with Data Stream Property Information
AudioFileStreamGetPropertyInfo(_:_:_:_:)AudioFileStreamGetProperty(_:_:_:_:)AudioFileStreamSetProperty(_:_:_:_:)
Closing an Audio File Stream
Callbacks
Data Types
Enumerations
Constants
Result Codes
Audio File ErrorskAudioFileStreamError_UnsupportedFileTypekAudioFileStreamError_UnsupportedDataFormatkAudioFileStreamError_UnsupportedPropertykAudioFileStreamError_BadPropertySizekAudioFileStreamError_NotOptimizedkAudioFileStreamError_InvalidPacketOffsetkAudioFileStreamError_InvalidFilekAudioFileStreamError_ValueUnknownkAudioFileStreamError_DataUnavailablekAudioFileStreamError_IllegalOperationkAudioFileStreamError_UnspecifiedErrorkAudioFileStreamError_DiscontinuityCantRecover