|
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 }; |
|
63 |
|
64 // audio setting options |
|
65 enum TAudioSetting |
|
66 { |
|
67 EDefault, |
|
68 EGeneralMusic, |
|
69 ERingTonePreview, |
|
70 //EIncomingCall, |
|
71 EDtmfString |
|
72 }; |
|
73 |
|
74 public: // Constructors and destructor |
|
75 |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 */ |
|
79 static CHtiAudioServicePlugin* NewL(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 public: // Functions from base classes |
|
84 |
|
85 /** |
|
86 * From CHTIServicePluginInterface |
|
87 * Called by the HTI Framework when sending message to this service. |
|
88 * @param aMessage message body destinated to a servive |
|
89 * @param aPriority message priority |
|
90 */ |
|
91 void ProcessMessageL( const TDesC8& aMessage, |
|
92 THtiMessagePriority aPriority ); |
|
93 |
|
94 /** |
|
95 * From CHTIServicePluginInterface |
|
96 * Called by HTI Framework to tell the service how much memory is |
|
97 * available for messages in the message queue. |
|
98 * @param aAvailableMemory amount of currently available memory |
|
99 * in the message queue |
|
100 */ |
|
101 void NotifyMemoryChange( TInt aAvailableMemory ); |
|
102 |
|
103 /** |
|
104 * From CHTIServicePluginInterface |
|
105 * Indicates to HTI Framework whether the plugin is ready to process |
|
106 * a new message or if it's busy processing previous message. |
|
107 */ |
|
108 TBool IsBusy(); |
|
109 |
|
110 /** |
|
111 * From MMdaAudioToneObserver |
|
112 * Handle the event when a tone utility initialisation |
|
113 * operation has completed. |
|
114 * @param aError indicates whether an error occurred. |
|
115 */ |
|
116 void MatoPrepareComplete( TInt aError ); |
|
117 |
|
118 /** |
|
119 * From MMdaAudioToneObserver |
|
120 * Handle the event when a tone playing operation has completed. |
|
121 * @param aError indicates whether an error occurred. |
|
122 */ |
|
123 void MatoPlayComplete( TInt aError ); |
|
124 |
|
125 /** |
|
126 * From MMdaAudioPlayerCallback |
|
127 * Handle the event when initialisation of |
|
128 * the audio player utility is complete. |
|
129 * @param aError The status of the audio sample after initialisation |
|
130 * @param aDuration The duration of the sample |
|
131 */ |
|
132 void MapcInitComplete( TInt aError, |
|
133 const TTimeIntervalMicroSeconds& aDuration ); |
|
134 |
|
135 /** |
|
136 * From MMdaAudioPlayerCallback |
|
137 * Handle the event when when the audio player utility |
|
138 * completes asynchronous playing. |
|
139 * @param aError The status of playback |
|
140 */ |
|
141 void MapcPlayComplete( TInt aError ); |
|
142 |
|
143 |
|
144 protected: // New functions |
|
145 |
|
146 /** |
|
147 * C++ default constructor. |
|
148 */ |
|
149 CHtiAudioServicePlugin(); |
|
150 |
|
151 /** |
|
152 * 2nd phase constructor. |
|
153 */ |
|
154 void ConstructL(); |
|
155 |
|
156 /** |
|
157 * Destructor. |
|
158 */ |
|
159 virtual ~CHtiAudioServicePlugin(); |
|
160 |
|
161 |
|
162 protected: // Functions from base classes |
|
163 |
|
164 private: |
|
165 |
|
166 void HandleListAudioFilesCmdL( const TDesC8& aMessage ); |
|
167 |
|
168 void HandlePlayFileCmdL( const TDesC8&aMessage ); |
|
169 |
|
170 void HandlePlayToneCmdL( const TDesC8& aMessage ); |
|
171 |
|
172 void HandlePlayDtmfCmdL( const TDesC8& aMessage ); |
|
173 |
|
174 void HandleStopCmdL( const TDesC8& aMessage ); |
|
175 |
|
176 void HandleGetDurationCmdL( const TDesC8& aMessage ); |
|
177 |
|
178 void HandleGetMaxVolCmdL( const TDesC8& aMessage ); |
|
179 |
|
180 void HandleSetVolCmdL( const TDesC8& aMessage ); |
|
181 |
|
182 TInt ParseString( const TDesC8& aRequest, |
|
183 TInt aOffset, TDes& aResult ); |
|
184 |
|
185 TInt SendResponseMsg( const TDesC8& aMsg, |
|
186 const TUint8 aCommandId = 0 ); |
|
187 |
|
188 TInt SendErrorResponseMsg( TInt aErrorCode, |
|
189 const TDesC8& aErrorDescription, |
|
190 const TUint8 aCommandId = 0 ); |
|
191 |
|
192 void AddSubdirsRecursivelyL( const TDesC& aPath, |
|
193 CDesCArraySeg& aArray, RFs& aFs ); |
|
194 |
|
195 TBool MatchMimeTypeL( const TDesC& aFilePath, |
|
196 const TDesC& aMimeTypeMatchPattern ); |
|
197 |
|
198 void SetAudioSettings( TAudioSetting aSetting ); |
|
199 |
|
200 inline TUint ParseUint16( const TUint8* aPtr ) |
|
201 { |
|
202 return aPtr[0] + ( aPtr[1] << 8 ); |
|
203 } |
|
204 |
|
205 inline TUint ParseUint32( const TUint8* aPtr ) |
|
206 { |
|
207 return aPtr[0] + ( aPtr[1] << 8 ) |
|
208 + ( aPtr[2] << 16 ) + ( aPtr[3] << 24 ); |
|
209 } |
|
210 |
|
211 |
|
212 public: // Data |
|
213 |
|
214 protected: // Data |
|
215 |
|
216 private: // Data |
|
217 // Flag telling if the service is busy processing a message |
|
218 TBool iIsBusy; |
|
219 |
|
220 // Flag telling if audio or tone is currently playing |
|
221 TBool iIsPlaying; |
|
222 |
|
223 // Id of the latest command |
|
224 TUint8 iCommandId; |
|
225 |
|
226 // Id of the latest play command |
|
227 TUint8 iPlayCommandId; |
|
228 |
|
229 // Container for the response message to be dispatched out |
|
230 HBufC8* iMessage; |
|
231 |
|
232 // Error code in the outgoing error message |
|
233 TInt iErrorCode; |
|
234 |
|
235 // Audio player utility object |
|
236 CMdaAudioPlayerUtility* iAudioPlayer; |
|
237 |
|
238 // Tone player utility object |
|
239 CMdaAudioToneUtility* iTonePlayer; |
|
240 |
|
241 // Current volume value |
|
242 TInt iVolume; |
|
243 |
|
244 // Current repeat value |
|
245 TInt iRepeats; |
|
246 |
|
247 // Current trailing silence value |
|
248 TInt iTrailingSilence; |
|
249 |
|
250 // DTMF tone length |
|
251 TInt iDtmfLength; |
|
252 |
|
253 // Silence between DTMF tones |
|
254 TInt iDtmfGapLength; |
|
255 |
|
256 // Playback start position |
|
257 TInt iStartPos; |
|
258 |
|
259 // Playback end position |
|
260 TInt iEndPos; |
|
261 |
|
262 // Audio priority setting |
|
263 TInt iAudioPriority; |
|
264 |
|
265 // Audio priority preference setting |
|
266 TMdaPriorityPreference iAudioPriorityPreference; |
|
267 |
|
268 |
|
269 public: // Friend classes |
|
270 |
|
271 protected: // Friend classes |
|
272 |
|
273 private: // Friend classes |
|
274 |
|
275 }; |
|
276 |
|
277 #endif // HTIAUDIOSERVICEPLUGIN_H |
|
278 |
|
279 // End of File |