Nokia N97 SDK Example Applications Guide |
AudioStreaming Example
1. About this Example
2. Architecture
3. Design and Implementation
Audio Streaming Example demonstrates the use of Audio Streaming API that provides functionality for recording audio stream
into a buffer, and playback of the audio buffer.Also, the recorded audio stream can be saved into a file and further loaded
to be played again.Sample files can be PCM encoded or AMR-NB-encoded audio files. This application is designed to run in both
S60 2nd Edition and S60 3rd Edition devices.
List the functionalities of the application:
- Play
- Record
- Stop
- Load
- Save
- Encoding
- Exit
- CMdaAudioInputStream
- CMdaAudioOutputStream
- MMdaAudioInputStreamCallback
- MMdaAudioOutputStreamCallback.
Audio Streaming API is part of the Symbian Multimedia Framework (MMF) and supported from S60 2nd Edition onwards.User is expected
to have an acquaintance with the Symbian Multimedia Framework.
Ensure the following points before building this example.
MOBILE DEVICE (S60 3rd Edition)
Ensure that the sample.aud/amr files located at /AudioStreamExample/data have been copied to /epoc32/winscw/c/system/Apps/audiostream/
in your SDK installation directory
MOBILE DEVICE (S60 2nd Edition)
Ensure that the sample.aud/amr files located at /AudioStreamExample/data have been copied to /epoc32/winscw/c/system/Apps/audiostream/
in your SDK installation directory
EMULATOR (S60 3rd Edition)
Ensure that the sample.aud/amr files located at /AudioStreamExample/data have been copied to /epoc32/winscw/c/private/e01ff1c3/
in your SDK installation directory
EMULATOR (S60 2nd Edition)
Ensure that the sample.aud/amr files located at /AudioStreamExample/data have been copied to /epoc32/winscw/c/system/Apps/audiostream/
in your SDK installation directory
Audio streaming example follows traditional Symbian OS Control-based architecture. CAudioStreamEngine is engine class which, inherits from MMdaAudioInputStreamCallback and MMdaAudioOutputStreamCallback. CAudioStreamEngine class defines audio functions (Play, Record, LoadFile, Stop) and the callback functions to get the error status of the audio
operations.
Since this example implements recording functionality, program is defined with the UserEnvironment capability.
The program capabilities are defined in the AudioStream_s60_3rd_ed.mmp file: CAPABILITY UserEnvironment
The heart of this application is CAudioStreamEngine class, which inherits MMdaAudioInputStreamCallback and MMdaAudioOutputStreamCallback. CAudioStreamEngine implements CMdaAudioInputStream for input stream (Recording) and CMdaAudioOutputStream for output stream(Playing). The important functionalities of example are discussed below.
- Play
This operation is implemented using the out stream class CMdaAudioOutputStream, which is used to pass the audio data from
buffers to output stream. This class supports following callback functions from server to notify the client:
- MaoscOpenComplete() will be called when the audio streaming object is open and ready to stream data back to the audio hardware as a result of
a previous call to Open().
- MaoscBufferCopied() will be called each time audio data has been successfully copied to the lower layers of the MMF as a result of a previous
ReadL().
- MaoscPlayComplete() will be called when the audio data stream has been closed as a result of a previous Stop().
- Record
This functionality is implemented using CMdaAudioInputStream, which is used to pass audio data from audio hardware to buffer.
This class supports following callback functions from server to notify the client:
- MaiscOpenComplete() will be called when the audio streaming object is open and ready to stream data back to the user as a result of a previous
call to Open().
- MaiscBufferCopied() will be called multiple times while the FIFO (queued via ReadL()) is emptied. Note: Each buffer will be flagged with KErrAbort
if received after Stop() on is called.
- MaiscRecordComplete() will be called once all remaining buffers have been read or after Stop() has been called
- Stop
This function uses both CMdaAudioInputStream and CMdaAudioOutputStream classes depending upon whether the audio is recording
or playing:
- in case of playing CMdaAudioOutputStream::Stop() is used and the result is notified via MaoscPlayComplete()
- in case of recording CMdaAudioInputStream::Stop() is used and the result is notified via MaiscRecordComplete() .
- Encoding
The purpose of this API is to encode the audio data. By default the audio data is encoded as PCM (Pulse-code modulation).
This example also demonstrates encoding of audio data to AMR-NB (Adaptive Multi-Rate). If the AMR-NB is not supported by the
platform then default PCM encoding is used. CMdaAudioInputStream::SetDataTypeL(TFourCC aAudioType) is used to carry out the purpose of encoding.
This example has two mmp files, in order to support both S60 2.X and S60 3.X versions of S60 platform
|
© Nokia 2009
|

|