examples/ForumNokia/AudioStreamExample/inc/AudioStreamEngine.h

00001 /*
00002  * Copyright � 2008 Nokia Corporation.
00003  */
00004 
00005 #ifndef AUDIOSTREAMENGINE_H
00006 #define AUDIOSTREAMENGINE_H
00007 
00008 // INCLUDES
00009 #include <e32base.h>
00010 #include <aknviewappui.h> 
00011 
00012 #include <mda\common\audio.h>
00013 #include <MdaAudioInputStream.h>    // audio input stream
00014 #include <MdaAudioOutputStream.h>   // audio output stream
00015 
00016 #include "AudioStream.hrh"
00017 #include "AudioStreamView.h"    
00018 #include "AudioStreamAppUi.h"   
00019 
00020 // FORWARD DECLARATIONS
00021 class CAudioStreamView;
00022 
00023 // CLASS DECLARATION
00024 
00029 class CAudioStreamEngine : public CBase, MMdaAudioInputStreamCallback, 
00030     MMdaAudioOutputStreamCallback
00031 {
00032 public:
00039     static CAudioStreamEngine* NewL(CAudioStreamAppUi* /* aAppUi */);
00040 
00048     static CAudioStreamEngine* NewLC(CAudioStreamAppUi* /* aAppUi */);
00049 
00050 
00056     ~CAudioStreamEngine();
00057         
00058 
00059 public: // New functions
00060     
00066     void Play();
00072     void Record();
00078     void Stop();
00079     
00085     void LoadAudioFileL();
00091     void SaveAudioFileL();
00092 
00100     void SetEncodingL(TBool aAmr);
00101     
00102 private: // in-class methods
00103 
00113     TPtr8& CAudioStreamEngine::GetFrame(TUint aFrameIdx);
00123     TPtr8& CAudioStreamEngine::GetPlaybackFrames(TUint aLastFrame);
00124 
00134     void ShowMessage(const TDesC& /* aMsg */, TBool /* aReset=false */);
00135     
00146     virtual void MaiscOpenComplete(TInt aError);
00157     virtual void MaiscBufferCopied(TInt aError, const TDesC8& aBuffer);
00167     virtual void MaiscRecordComplete(TInt aError);
00168 
00179     virtual void MaoscOpenComplete(TInt aError);
00194     virtual void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);
00195     
00205     virtual void MaoscPlayComplete(TInt aError);
00206 
00207     static TInt BackgroundStop( TAny *aStream );
00208     
00209 public: // Functions from base classes
00210 
00211 private: // Basic two-phase EPOC constructors
00212 
00219     void ConstructL();
00220  
00226     CAudioStreamEngine(CAudioStreamAppUi* /* aAppUi */);
00227 
00228 private:    
00229 
00230     // enumeration of input/output stream status
00231     enum TStatus
00232         {
00233         ENotReady,
00234         EOpen
00235         };
00236 
00237         
00238 private:    // data members
00239 
00240     // application UI object reference
00241     CAudioStreamAppUi* iAppUi;
00242     // audio input stream object reference
00243     CMdaAudioInputStream* iInputStream;
00244     // audio output stream object reference
00245     CMdaAudioOutputStream* iOutputStream;
00246 
00247     // Handle to CCoeEnv's file server
00248     RFs iFs;
00249 
00250     // Do we use AMR-NB encoding?
00251     TBool iUseAMR;
00252     // The path to the sample audio file (sample.aud or sample.amr)
00253     TFileName iAudioFilePath;
00254     // The audio file to be used (sample.aud or sample.amr)
00255     TFileName iAudioFile;   
00256     // The frame size for the current encoding
00257     TUint iFrameSize;
00258     // The number of frames to be buffered
00259     TUint iFrameCount;
00260 
00261     // A buffer containing the audio frames
00262     HBufC8* iStreamBuffer;  
00263     // Modifiable pointer used to reference a single frame in iStreamBuffer 
00264     // while recording, and all the valid frames in iStreamBuffer while playback (the
00265     // iStreamBuffer might not always be fully recorded in this example).
00266     TPtr8 iFramePtr;
00267     // Buffer status (does it contain valid audio data)
00268     TBool iBufferOK;
00269     // The default encoding used by the platform
00270     TFourCC iDefaultEncoding;
00271     // The encoding we are currently using
00272     TFourCC iCurrentEncoding;
00273 
00274     // Audio data stream settings for input and output streams
00275     TMdaAudioDataSettings iStreamSettings;
00276     // Status enumeration of input stream
00277     TStatus iInputStatus;
00278     // Status enumeration of output stream  
00279     TStatus iOutputStatus;
00280     // Index of audio data block currently being played/recorded on the buffer
00281     TUint iStreamIdx;
00282     // Application status message displayed to user
00283     TBuf<255> iMsg;
00284     // Stream start (first audio block in buffer) and end index
00285     TUint iStreamStart;
00286     TUint iStreamEnd;
00287     
00288     CIdle* iStop;
00289     
00290 };
00291 
00292 #endif // AUDIOSTREAMENGINE_H
00293 
00294 

Generated by  doxygen 1.6.2