00001
00002
00003
00004
00005 #ifndef AUDIOSTREAMENGINE_H
00006 #define AUDIOSTREAMENGINE_H
00007
00008
00009 #include <e32base.h>
00010 #include <aknviewappui.h>
00011
00012 #include <mda\common\audio.h>
00013 #include <MdaAudioInputStream.h>
00014 #include <MdaAudioOutputStream.h>
00015
00016 #include "AudioStream.hrh"
00017 #include "AudioStreamView.h"
00018 #include "AudioStreamAppUi.h"
00019
00020
00021 class CAudioStreamView;
00022
00023
00024
00029 class CAudioStreamEngine : public CBase, MMdaAudioInputStreamCallback,
00030 MMdaAudioOutputStreamCallback
00031 {
00032 public:
00039 static CAudioStreamEngine* NewL(CAudioStreamAppUi* );
00040
00048 static CAudioStreamEngine* NewLC(CAudioStreamAppUi* );
00049
00050
00056 ~CAudioStreamEngine();
00057
00058
00059 public:
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:
00103
00113 TPtr8& CAudioStreamEngine::GetFrame(TUint aFrameIdx);
00123 TPtr8& CAudioStreamEngine::GetPlaybackFrames(TUint aLastFrame);
00124
00134 void ShowMessage(const TDesC& , TBool );
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:
00210
00211 private:
00212
00219 void ConstructL();
00220
00226 CAudioStreamEngine(CAudioStreamAppUi* );
00227
00228 private:
00229
00230
00231 enum TStatus
00232 {
00233 ENotReady,
00234 EOpen
00235 };
00236
00237
00238 private:
00239
00240
00241 CAudioStreamAppUi* iAppUi;
00242
00243 CMdaAudioInputStream* iInputStream;
00244
00245 CMdaAudioOutputStream* iOutputStream;
00246
00247
00248 RFs iFs;
00249
00250
00251 TBool iUseAMR;
00252
00253 TFileName iAudioFilePath;
00254
00255 TFileName iAudioFile;
00256
00257 TUint iFrameSize;
00258
00259 TUint iFrameCount;
00260
00261
00262 HBufC8* iStreamBuffer;
00263
00264
00265
00266 TPtr8 iFramePtr;
00267
00268 TBool iBufferOK;
00269
00270 TFourCC iDefaultEncoding;
00271
00272 TFourCC iCurrentEncoding;
00273
00274
00275 TMdaAudioDataSettings iStreamSettings;
00276
00277 TStatus iInputStatus;
00278
00279 TStatus iOutputStatus;
00280
00281 TUint iStreamIdx;
00282
00283 TBuf<255> iMsg;
00284
00285 TUint iStreamStart;
00286 TUint iStreamEnd;
00287
00288 CIdle* iStop;
00289
00290 };
00291
00292 #endif // AUDIOSTREAMENGINE_H
00293
00294