|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef CHAR_A3F_DEVSOUND_TESTBASE_H |
|
17 #define CHAR_A3F_DEVSOUND_TESTBASE_H |
|
18 |
|
19 // system includes |
|
20 #include <testframework.h> |
|
21 #include <mmf/server/sounddevice.h> |
|
22 |
|
23 // user includes |
|
24 #include "char_a3f_devsound_compliancesuiteconstants.h" |
|
25 |
|
26 // forward declaration |
|
27 class CA3FDevSoundToneClient; |
|
28 class CA3FDevSoundPlayClient; |
|
29 class CA3FDevSoundRecordClient; |
|
30 |
|
31 class CAsyncWriteBufferToFile; |
|
32 |
|
33 /* |
|
34 Base class for all DevSound test steps in this suite. |
|
35 */ |
|
36 class RA3FDevSoundTestBase: public RAsyncTestStep, public MDevSoundObserver |
|
37 { |
|
38 public: |
|
39 // from RAsyncTestStep |
|
40 void KickoffTestL(); |
|
41 void CloseTest(); |
|
42 void CallStopTest(TInt aError); |
|
43 |
|
44 protected: |
|
45 RA3FDevSoundTestBase(const TDesC& aTestName); |
|
46 virtual void DoKickoffTestL() = 0; |
|
47 virtual void DoTimerCallback(); |
|
48 static TInt TimerCallback(TAny*); |
|
49 void StartTimer(TTimeIntervalMicroSeconds32 aWaitTime); |
|
50 // from MDevSoundObserver |
|
51 void InitializeComplete(TInt aError); |
|
52 void ToneFinished(TInt aError); |
|
53 void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
54 void PlayError(TInt aError); |
|
55 void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
56 void RecordError(TInt aError); |
|
57 void ConvertError(TInt aError); |
|
58 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
|
59 void SendEventToClient(const TMMFEvent& aEvent); |
|
60 // Executes events of DevSound using a Finite State Machine |
|
61 virtual void Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError) = 0; |
|
62 |
|
63 void SampleRateFromTIntToTMMFSampleRate(TInt aSampleRate, TMMFSampleRate &aESampleRate); |
|
64 void SampleRateFromTUintToString(TUint aSampleRate, TDes& aStringSampleRate); |
|
65 void ChannelsFromTUintToString(TUint aChannels, TDes& aStringChannels); |
|
66 void EncodingFromStringToTFourCC(const TDesC& aFourCCString); |
|
67 void PrintSupportedCapabilities(TUint aSampleRate,TUint aChannel); |
|
68 |
|
69 protected: |
|
70 TBuf<KSizeBuf> iFourCCString; |
|
71 TFourCC iFourCCCode; |
|
72 TMmfDevSoundState iDevSoundState; |
|
73 CA3FDevSoundToneClient* iDevsoundToneClient; |
|
74 CA3FDevSoundPlayClient* iDevsoundPlayClient; |
|
75 CA3FDevSoundRecordClient* iDevsoundRecordClient; |
|
76 CMMFDevSound* iMMFDevSound; |
|
77 CPeriodic* iTimer; |
|
78 CMMFBuffer* iBuffer; |
|
79 // Handle for the audio file for playing and recording |
|
80 RFile iFile; |
|
81 // Handle to a file server session |
|
82 RFs iFs; |
|
83 CAsyncWriteBufferToFile* iAsyncWriteBTFAO; |
|
84 }; |
|
85 |
|
86 class TSampleRateToTMMFSampleRate |
|
87 { |
|
88 public: |
|
89 TInt iTIntSampleRate; |
|
90 TMMFSampleRate iTMMFSampleRate; |
|
91 }; |
|
92 |
|
93 class TSampleRateToString |
|
94 { |
|
95 public: |
|
96 TUint iTUIntSampleRate; |
|
97 TPtrC iTPtrSampleRate; |
|
98 }; |
|
99 |
|
100 class TChannelsToString |
|
101 { |
|
102 public: |
|
103 TUint iTUIntChannels; |
|
104 TPtrC iTPtrChannels; |
|
105 }; |
|
106 /* |
|
107 * |
|
108 * CAsyncWriteBufferToFile |
|
109 * |
|
110 */ |
|
111 |
|
112 class CAsyncWriteBufferToFile : public CActive |
|
113 { |
|
114 public: |
|
115 static CAsyncWriteBufferToFile* NewL(RFile& aFile, CMMFDevSound* aDevSound, RA3FDevSoundTestBase& aTestStep); |
|
116 ~CAsyncWriteBufferToFile(); |
|
117 void Start(CMMFDataBuffer* aBuffer); |
|
118 |
|
119 private: |
|
120 CAsyncWriteBufferToFile(RFile& aFile, CMMFDevSound* aDevSound, RA3FDevSoundTestBase& aTestStep); |
|
121 void ConstructL(); |
|
122 virtual void DoCancel(); |
|
123 virtual void RunL(); |
|
124 virtual TInt RunError(TInt aError); |
|
125 |
|
126 private: |
|
127 RFile& iFile; |
|
128 CMMFDevSound* iDevSound; |
|
129 RA3FDevSoundTestBase& iTestStep; |
|
130 }; |
|
131 |
|
132 #endif // CHAR_A3F_DEVSOUND_TESTBASE_H |
|
133 |