1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Defines the ECom plugin for HTI audio playback control service. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HTIAUDIOSERVICEPLUGIN_H |
|
21 #define HTIAUDIOSERVICEPLUGIN_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <badesca.h> |
|
25 #include <HtiServicePluginInterface.h> |
|
26 #include <mdaaudiosampleplayer.h> |
|
27 #include <mdaaudiotoneplayer.h> |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * The ECom plugin for HTI audio playback control service. |
|
43 * |
|
44 */ |
|
45 class CHtiAudioServicePlugin : public CHTIServicePluginInterface, |
|
46 public MMdaAudioPlayerCallback, |
|
47 public MMdaAudioToneObserver |
|
48 { |
|
49 |
|
50 protected: |
|
51 // commands |
|
52 enum TAudioCommands |
|
53 { |
|
54 ECmdListAudioFiles = 0x01, |
|
55 ECmdPlayFile = 0x02, |
|
56 ECmdPlayTone = 0x03, |
|
57 ECmdPlayDtmf = 0x04, |
|
58 ECmdStop = 0x05, |
|
59 ECmdGetDuration = 0x06, |
|
60 ECmdGetMaxVol = 0x07, |
|
61 ECmdSetVol = 0x08, |
|
62 ECmdPlayFile2 = 0x10, |
|
63 ECmdPlayTone2 = 0x11, |
|
64 ECmdPlayDtmf2 = 0x12, |
|
65 ECmdGetMaxVol2 = 0x13, |
|
66 ECmdSetVol2 = 0x14 |
|
67 }; |
|
68 |
|
69 // audio setting options |
|
70 enum TAudioSetting |
|
71 { |
|
72 EDefault, |
|
73 EGeneralMusic, |
|
74 ERingTonePreview, |
|
75 //EIncomingCall, |
|
76 EDtmfString |
|
77 }; |
|
78 |
|
79 public: // Constructors and destructor |
|
80 |
|
81 /** |
|
82 * Two-phased constructor. |
|
83 */ |
|
84 static CHtiAudioServicePlugin* NewL(); |
|
85 |
|
86 public: // New functions |
|
87 |
|
88 public: // Functions from base classes |
|
89 |
|
90 /** |
|
91 * From CHTIServicePluginInterface |
|
92 * Called by the HTI Framework when sending message to this service. |
|
93 * @param aMessage message body destinated to a servive |
|
94 * @param aPriority message priority |
|
95 */ |
|
96 void ProcessMessageL( const TDesC8& aMessage, |
|
97 THtiMessagePriority aPriority ); |
|
98 |
|
99 /** |
|
100 * From CHTIServicePluginInterface |
|
101 * Called by HTI Framework to tell the service how much memory is |
|
102 * available for messages in the message queue. |
|
103 * @param aAvailableMemory amount of currently available memory |
|
104 * in the message queue |
|
105 */ |
|
106 void NotifyMemoryChange( TInt aAvailableMemory ); |
|
107 |
|
108 /** |
|
109 * From CHTIServicePluginInterface |
|
110 * Indicates to HTI Framework whether the plugin is ready to process |
|
111 * a new message or if it's busy processing previous message. |
|
112 */ |
|
113 TBool IsBusy(); |
|
114 |
|
115 /** |
|
116 * From MMdaAudioToneObserver |
|
117 * Handle the event when a tone utility initialisation |
|
118 * operation has completed. |
|
119 * @param aError indicates whether an error occurred. |
|
120 */ |
|
121 void MatoPrepareComplete( TInt aError ); |
|
122 |
|
123 /** |
|
124 * From MMdaAudioToneObserver |
|
125 * Handle the event when a tone playing operation has completed. |
|
126 * @param aError indicates whether an error occurred. |
|
127 */ |
|
128 void MatoPlayComplete( TInt aError ); |
|
129 |
|
130 /** |
|
131 * From MMdaAudioPlayerCallback |
|
132 * Handle the event when initialisation of |
|
133 * the audio player utility is complete. |
|
134 * @param aError The status of the audio sample after initialisation |
|
135 * @param aDuration The duration of the sample |
|
136 */ |
|
137 void MapcInitComplete( TInt aError, |
|
138 const TTimeIntervalMicroSeconds& aDuration ); |
|
139 |
|
140 /** |
|
141 * From MMdaAudioPlayerCallback |
|
142 * Handle the event when when the audio player utility |
|
143 * completes asynchronous playing. |
|
144 * @param aError The status of playback |
|
145 */ |
|
146 void MapcPlayComplete( TInt aError ); |
|
147 |
|
148 |
|
149 protected: // New functions |
|
150 |
|
151 /** |
|
152 * C++ default constructor. |
|
153 */ |
|
154 CHtiAudioServicePlugin(); |
|
155 |
|
156 /** |
|
157 * 2nd phase constructor. |
|
158 */ |
|
159 void ConstructL(); |
|
160 |
|
161 /** |
|
162 * Destructor. |
|
163 */ |
|
164 virtual ~CHtiAudioServicePlugin(); |
|
165 |
|
166 |
|
167 protected: // Functions from base classes |
|
168 |
|
169 private: |
|
170 |
|
171 void HandleListAudioFilesCmdL( const TDesC8& aMessage ); |
|
172 |
|
173 void HandlePlayFileCmdL( const TDesC8&aMessage ); |
|
174 |
|
175 void HandlePlayToneCmdL( const TDesC8& aMessage ); |
|
176 |
|
177 void HandlePlayDtmfCmdL( const TDesC8& aMessage ); |
|
178 |
|
179 void HandleStopCmdL( const TDesC8& aMessage ); |
|
180 |
|
181 void HandleGetDurationCmdL( const TDesC8& aMessage ); |
|
182 |
|
183 void HandleGetMaxVolCmdL( const TDesC8& aMessage ); |
|
184 |
|
185 void HandleSetVolCmdL( const TDesC8& aMessage ); |
|
186 |
|
187 TInt ParseString( const TDesC8& aRequest, |
|
188 TInt aOffset, TDes& aResult ); |
|
189 |
|
190 TInt SendResponseMsg( const TDesC8& aMsg, |
|
191 const TUint8 aCommandId = 0 ); |
|
192 |
|
193 TInt SendErrorResponseMsg( TInt aErrorCode, |
|
194 const TDesC8& aErrorDescription, |
|
195 const TUint8 aCommandId = 0 ); |
|
196 |
|
197 void AddSubdirsRecursivelyL( const TDesC& aPath, |
|
198 CDesCArraySeg& aArray, RFs& aFs ); |
|
199 |
|
200 TBool MatchMimeTypeL( const TDesC& aFilePath, |
|
201 const TDesC& aMimeTypeMatchPattern ); |
|
202 |
|
203 void SetAudioSettings( TAudioSetting aSetting ); |
|
204 |
|
205 inline TUint ParseUint16( const TUint8* aPtr ) |
|
206 { |
|
207 return aPtr[0] + ( aPtr[1] << 8 ); |
|
208 } |
|
209 |
|
210 inline TUint ParseUint32( const TUint8* aPtr ) |
|
211 { |
|
212 return aPtr[0] + ( aPtr[1] << 8 ) |
|
213 + ( aPtr[2] << 16 ) + ( aPtr[3] << 24 ); |
|
214 } |
|
215 |
|
216 |
|
217 public: // Data |
|
218 |
|
219 protected: // Data |
|
220 |
|
221 private: // Data |
|
222 // Flag telling if the service is busy processing a message |
|
223 TBool iIsBusy; |
|
224 |
|
225 // Flag telling if audio or tone is currently playing |
|
226 TBool iIsPlaying; |
|
227 |
|
228 // Id of the latest command |
|
229 TUint8 iCommandId; |
|
230 |
|
231 // Id of the latest play command |
|
232 TUint8 iPlayCommandId; |
|
233 |
|
234 // Container for the response message to be dispatched out |
|
235 HBufC8* iMessage; |
|
236 |
|
237 // Error code in the outgoing error message |
|
238 TInt iErrorCode; |
|
239 |
|
240 // Audio player utility object |
|
241 CMdaAudioPlayerUtility* iAudioPlayer; |
|
242 |
|
243 // Tone player utility object |
|
244 CMdaAudioToneUtility* iTonePlayer; |
|
245 |
|
246 // Current volume value |
|
247 TInt iVolume; |
|
248 |
|
249 // Current repeat value |
|
250 TInt iRepeats; |
|
251 |
|
252 // Current trailing silence value |
|
253 TInt iTrailingSilence; |
|
254 |
|
255 // DTMF tone length |
|
256 TInt iDtmfLength; |
|
257 |
|
258 // Silence between DTMF tones |
|
259 TInt iDtmfGapLength; |
|
260 |
|
261 // Playback start position |
|
262 TInt iStartPos; |
|
263 |
|
264 // Playback end position |
|
265 TInt iEndPos; |
|
266 |
|
267 // Audio priority setting |
|
268 TInt iAudioPriority; |
|
269 |
|
270 // Audio priority preference setting |
|
271 TMdaPriorityPreference iAudioPriorityPreference; |
|
272 |
|
273 |
|
274 public: // Friend classes |
|
275 |
|
276 protected: // Friend classes |
|
277 |
|
278 private: // Friend classes |
|
279 |
|
280 }; |
|
281 |
|
282 #endif // HTIAUDIOSERVICEPLUGIN_H |
|
283 |
|
284 // End of File |
|