|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Active object which implements ringing tone functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __PHONERINGINGTONESRVPLAYERAO_H |
|
20 #define __PHONERINGINGTONESRVPLAYERAO_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <Profile.hrh> |
|
25 |
|
26 #include "mphoneaudioplayerobserver.h" |
|
27 #include "mphonetimer.h" |
|
28 #include "cphoneaudioplayer.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class RFs; |
|
32 class CPhoneTimer; |
|
33 class CMdaServer; |
|
34 class CPhoneRingingTone; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 class CPhoneRingingToneSrvPlayerAO : |
|
38 public CActive, |
|
39 private MPhoneAudioPlayerObserver, |
|
40 private MPhoneTimer |
|
41 { |
|
42 public: |
|
43 // States for this active object |
|
44 enum TState |
|
45 { |
|
46 EIdleState, |
|
47 EDeletingAudioPlayer |
|
48 }; |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @return new instance. |
|
55 */ |
|
56 static CPhoneRingingToneSrvPlayerAO* NewL( RFs &aFs ); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 ~CPhoneRingingToneSrvPlayerAO(); |
|
62 |
|
63 /** |
|
64 * Play audio ring tone. |
|
65 * @param aVolume Volume used to play the ringing tone. |
|
66 * @param aRingingType Ringing type. |
|
67 * @param aMessage Message from Client. |
|
68 * @return ETrue if the client message should not be completed. |
|
69 */ |
|
70 TBool PlayAudioRingTone( |
|
71 TInt aVolume, |
|
72 TProfileRingingType aRingingType, |
|
73 const RMessage2& aMessage ); |
|
74 |
|
75 /** |
|
76 * Play default tone. |
|
77 * @param aVolume volume used for the playing. |
|
78 * @param aRingingType ringing type. |
|
79 */ |
|
80 void PlayDefaultTone( |
|
81 TInt aVolume, |
|
82 TProfileRingingType aRingingType ); |
|
83 |
|
84 /** |
|
85 * Play backup tone. |
|
86 * @param aVolume volume used for the playing. |
|
87 * @param aRingingType ringing type. |
|
88 */ |
|
89 void PlayBackupTone( |
|
90 TInt aVolume, |
|
91 TProfileRingingType aRingingType ); |
|
92 |
|
93 /** |
|
94 * Playing the Beep once. |
|
95 * @param aVolume volume used to play the ringing tone. |
|
96 */ |
|
97 void BeepOnce( TInt aVolume ); |
|
98 |
|
99 /** |
|
100 * Play silent tone. No_sound.wav will be played. If vibration alert |
|
101 * is ON, it will vibrate. |
|
102 */ |
|
103 void PlaySilentTone(); |
|
104 |
|
105 /** |
|
106 * Play unsecure VoIP tone. |
|
107 * Play tone if secure call fails and call is changed to unsecure call. |
|
108 */ |
|
109 void PlayUnsecureVoIPTone(); |
|
110 |
|
111 /** |
|
112 * Stops playing the ringing tone. |
|
113 * Method does not do anything if ringing tone is not playing. |
|
114 */ |
|
115 void StopPlaying(); |
|
116 |
|
117 /** |
|
118 * Mutes ringing tone. |
|
119 */ |
|
120 void MuteRingingTone(); |
|
121 |
|
122 /** |
|
123 * Play TTS tone simultaneously with Personal or Default tones. |
|
124 * This method does not command phone to play TTS immediately. Instead |
|
125 * it registers a request to play TTS, when Personal or default tones |
|
126 * are played. |
|
127 * |
|
128 * @since Series 60 3.0 |
|
129 * @param aTextToSay Text, that should be pronounced by the |
|
130 * Text-To-Speech engine. This is normal descriptor, no UTF-8 |
|
131 * and no "(tts)" prefix |
|
132 * @param aVolume Volume for the TTS-tone, Does not effect the volume |
|
133 * of the normal tone, that will be played simulteneously with the TTS |
|
134 * @param aRingingType ringing type. |
|
135 */ |
|
136 void PlayTtsTone( |
|
137 const TDesC& aTextToSay, |
|
138 TInt aVolume, |
|
139 TProfileRingingType aRingingType ); |
|
140 |
|
141 /** |
|
142 * Checks if extended security required. |
|
143 * @since Series 60 3.1 |
|
144 * @return ETrue if extended security is required. |
|
145 */ |
|
146 TBool ExtendedSecurity() const; |
|
147 |
|
148 public: |
|
149 /** |
|
150 * Sets extended security required flag. |
|
151 * @param aNeeded Extended security required. |
|
152 */ |
|
153 void SetExtendedSecurityNeeded( TBool aNeeded ); |
|
154 |
|
155 /** |
|
156 * Sets extended security required flag. |
|
157 * @param aLimit Extended security required. |
|
158 */ |
|
159 void SetToneFileSizeLimit( TInt aLimit ); |
|
160 |
|
161 /** |
|
162 * Sets default ringing tone. |
|
163 * @param aFilename Ringing tone. |
|
164 */ |
|
165 void SetDefaultRingingToneL( const TDesC& aFilename ); |
|
166 |
|
167 /** |
|
168 * Sets ringing tone. |
|
169 * @param aFilename Ringing tone. |
|
170 */ |
|
171 void SetRingingToneL( const TDesC& aFilename ); |
|
172 |
|
173 private: |
|
174 |
|
175 /** |
|
176 * Handle the error of audio file player. |
|
177 * @param aEvent The error event happend in initializing or playing. |
|
178 * @param aError The error code return by audio server. Observer can |
|
179 * handle these two error code for recoverable |
|
180 * and unrecoverable errors. |
|
181 * @param aId Indicate which audio player is out of working. |
|
182 */ |
|
183 virtual void HandleAudioPlayerError( |
|
184 TPhoneAudioPlayerErrorEvent aEvent, |
|
185 TInt aError, |
|
186 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
187 |
|
188 /** |
|
189 * Handle audio player initialize complete. |
|
190 * @param aId Indicate which audio player is out of working. |
|
191 */ |
|
192 virtual void HandleAudioPlayerInitComplete( |
|
193 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
194 |
|
195 /** |
|
196 * Handle audio file playing complete successfully. |
|
197 * @param aId Indicate which audio player is out of working. |
|
198 */ |
|
199 virtual void HandlePlayingComplete( |
|
200 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
201 |
|
202 /** |
|
203 * @see MPhoneTimer |
|
204 */ |
|
205 virtual void HandleTimeOutL(); |
|
206 |
|
207 /** |
|
208 * Enumerates identifiers for each player: |
|
209 * EPlayerAudio - audio |
|
210 * EPlayerBeepOnce - beep once |
|
211 * EPlayerSilent - silent |
|
212 * EPlayerUnsecureVoIP - unsecure VoIP |
|
213 * EPlayerDefault - default |
|
214 * EPlayerBackup - backup |
|
215 * |
|
216 * EPlayerFirst and EPlayerLast are alias |
|
217 * to other identifiers. |
|
218 * EPlayerFirst - first player |
|
219 * EPlayerLast - last player |
|
220 */ |
|
221 enum TPlayerId |
|
222 { |
|
223 EPlayerFirst, |
|
224 EPlayerAudio = EPlayerFirst, |
|
225 EPlayerBeepOnce, |
|
226 EPlayerSilent, |
|
227 EPlayerUnsecureVoIP, |
|
228 EPlayerDefault, |
|
229 EPlayerBackup, |
|
230 EPlayerTts, |
|
231 EPlayerLast = EPlayerTts, |
|
232 EPlayerCount |
|
233 }; |
|
234 |
|
235 /** |
|
236 * Enumerates how many times TTs is played |
|
237 * ESaidOnce -once |
|
238 * ESaidTwice twice |
|
239 */ |
|
240 enum TTtsStatus |
|
241 { |
|
242 ESaidOnce, |
|
243 ESaidTwice |
|
244 }; |
|
245 |
|
246 /** |
|
247 * C++ default constructor. |
|
248 */ |
|
249 CPhoneRingingToneSrvPlayerAO( RFs& aFs ); |
|
250 |
|
251 /** |
|
252 * Symbian 2nd phase constructor. |
|
253 */ |
|
254 void ConstructL(); |
|
255 |
|
256 /** |
|
257 * Do construct tone. |
|
258 * @param aRingingTone Ringing tone. |
|
259 * @param aId Indicates the audio player. |
|
260 * @return The instance of the player. NULL is returned if it's failed. |
|
261 */ |
|
262 CPhoneAudioPlayer* ConstructTonePlayer( |
|
263 const CPhoneRingingTone& aRingingTone, |
|
264 TInt aId ); |
|
265 |
|
266 /** |
|
267 * Handle audio player error. |
|
268 * @param aDelete ETrue if deletion of the player allowed, |
|
269 * EFalse otherwise. |
|
270 * @param aSync ETrue if synchronous deletion of players is allowed, |
|
271 * EFalse otherwise. |
|
272 */ |
|
273 void DoHandlePlayerError( |
|
274 TBool aDelete, |
|
275 TBool aSync ); |
|
276 |
|
277 /** |
|
278 * Convert ringing type from PhoneAppEnging to the ringing type in |
|
279 * CPhoneAudioPlayer. |
|
280 * @param aRingingType the ringing type form PhoneAppEngine. |
|
281 * @return ringing type of CPhoneAudioPlayer. |
|
282 */ |
|
283 CPhoneAudioPlayer::TRingingType ConvertRingingType( |
|
284 TProfileRingingType aRingingType ); |
|
285 |
|
286 /** |
|
287 * Construct media server and backup tone player. |
|
288 */ |
|
289 TInt ConstructPlayers(); |
|
290 |
|
291 /** |
|
292 * Construct media server and backup tone player. |
|
293 */ |
|
294 void ConstructPlayersL(); |
|
295 |
|
296 /** |
|
297 * Construct sequence players. |
|
298 * @param aPlayer player to be constructed. |
|
299 */ |
|
300 void ConstructSequencePlayer( |
|
301 TPlayerId aPlayer ); |
|
302 |
|
303 /** |
|
304 * Construct sequence players. |
|
305 * @param aPlayer player to be constructed. |
|
306 */ |
|
307 void ConstructSequencePlayerL( |
|
308 TPlayerId aPlayer ); |
|
309 |
|
310 /** |
|
311 * Cleanup players. |
|
312 */ |
|
313 void CleanupPlayers(); |
|
314 |
|
315 /** |
|
316 * Deletes player asynchronoysly. |
|
317 * @param aPlayer player to be deleted. |
|
318 */ |
|
319 void DeletePlayerAsync( |
|
320 TPlayerId aPlayer ); |
|
321 |
|
322 /** |
|
323 * @see CActive::RunL. |
|
324 */ |
|
325 void RunL(); |
|
326 |
|
327 /** |
|
328 * @see CActive::DoCancel. |
|
329 */ |
|
330 void DoCancel(); |
|
331 |
|
332 /** |
|
333 * Wrapper of DoHandleTtsDelayTimeout, that can be used as TCallback. |
|
334 * Immediately passes control to DoHandleTtsDelayTimeout method. |
|
335 * @since Series 60 3.0 |
|
336 * @param aObject Object to call DoHandleTtsDelayTimeout() on, |
|
337 * instance of CPhoneRingingTonePlayer. |
|
338 * @return KErrNone. |
|
339 */ |
|
340 static TInt HandleTtsDelayTimeout( TAny* aObject ); |
|
341 |
|
342 /** |
|
343 * It is called after TTS delay elapsed. Starts playing TTS. |
|
344 */ |
|
345 void DoHandleTtsDelayTimeout(); |
|
346 |
|
347 /** |
|
348 * Checks if TTS component should be played for the current ringtone |
|
349 * playback and initializes the TTS playback. This method is to be |
|
350 * called from within PlayXXXXTone methods |
|
351 * @since Series 60 3.0 |
|
352 * @param aRingingType ringing type |
|
353 */ |
|
354 void AddTtsPlaybackIfNeeded( TProfileRingingType aRingingType ); |
|
355 |
|
356 /** |
|
357 * Returns currently active player which is used wit TTS player. |
|
358 * @return pointer to CPhoneAudioPlayer. |
|
359 */ |
|
360 CPhoneAudioPlayer* GetCurrentlyActiveAudioPlayerWithTTs(); |
|
361 |
|
362 /** |
|
363 * TTs cases only. Calculates new volume and ramptimes |
|
364 * for Ascending TTS ringing case and normal TTS ringing case. |
|
365 * @param aStatus -status of TTs player. |
|
366 */ |
|
367 void SolveNewVolumeAndRamptime( TTtsStatus aStatus ); |
|
368 |
|
369 /** |
|
370 * Retarts currently active ringingtone player. |
|
371 */ |
|
372 void ReStartRingingTonePlayer(); |
|
373 |
|
374 /** |
|
375 * Checks if ringing tone file's size is larger than the size limit. |
|
376 * If size limit is exceeded, default tone is played instead. |
|
377 * @since 3.1 |
|
378 * @param aRingingTone Tone to check. |
|
379 * @return EFalse if the limit was exceeded and thus default tone played. |
|
380 * ETrue if tone file's size was valid and the checked tone |
|
381 * can be played. |
|
382 */ |
|
383 TBool CheckAndHandleToneSizeLimit( CPhoneRingingTone* aRingingTone ); |
|
384 |
|
385 /** |
|
386 * Checks if ringing tone file's size is larger than the size limit. |
|
387 * @since 3.1 |
|
388 * @param aFile File to check. |
|
389 * aSizeLimitKB the size limit in kB is set to this variable. |
|
390 * @return KErrNone if the file can be used as a ringing tone. |
|
391 * KErrTooBig if the file size limit is exceeded. |
|
392 * Other error value if error happened during size checking. |
|
393 */ |
|
394 TInt CheckToneFileSize( const TDesC& aFile, TInt aSizeLimitKB ); |
|
395 |
|
396 /** |
|
397 * Returns currently active audio player. |
|
398 * @return Currently active audio player or NULL if none active. |
|
399 */ |
|
400 CPhoneAudioPlayer* ActiveAudioPlayer(); |
|
401 |
|
402 private: // Data |
|
403 // Handle to file server |
|
404 RFs &iFs; |
|
405 |
|
406 // Audio ring tone player. Memory allocated during construction. |
|
407 // After constructed, no leave may be caused during audio playing |
|
408 CPhoneAudioPlayer* iAudioPlayer; |
|
409 |
|
410 // Audio player for beep once. |
|
411 CPhoneAudioPlayer* iBeepOncePlayer; |
|
412 |
|
413 // Audio player for silent tone. |
|
414 CPhoneAudioPlayer* iSilentPlayer; |
|
415 |
|
416 // Audio player for unsecure VoIP tone. |
|
417 CPhoneAudioPlayer* iUnsecureVoIPTonePlayer; |
|
418 |
|
419 // Default player. |
|
420 CPhoneAudioPlayer* iDefaultPlayer; |
|
421 |
|
422 // Tts player. |
|
423 CPhoneAudioPlayer* iTtsPlayer; |
|
424 |
|
425 // Backup ringing tone. Incase all default player failed. |
|
426 CPhoneAudioPlayer* iBackupPlayer; |
|
427 |
|
428 // Default ringing tone |
|
429 CPhoneRingingTone* iDefaultRingingTone; |
|
430 |
|
431 // Media server. |
|
432 CMdaServer* iMdaServer; |
|
433 |
|
434 // Indicate which tone is playing or need to be played: |
|
435 // EIdle - idle, |
|
436 // EAudioTonePlaying - audio playing, |
|
437 // EBeepOnce - beep once playing, |
|
438 // ESilentTonePlaying - silent tone playing, |
|
439 // EDefaultTonePlaying - default tone playing, |
|
440 // EBackupTonePlaying - backup tone playing, |
|
441 enum TTonePlayingStatus |
|
442 { |
|
443 EIdle, |
|
444 EAudioTonePlaying, |
|
445 EBeepOnce, |
|
446 ESilentTonePlaying, |
|
447 EUnsecureVoIPTonePlaying, |
|
448 EDefaultTonePlaying, |
|
449 EBackupTonePlaying |
|
450 }; |
|
451 |
|
452 // Current playing status. |
|
453 TTonePlayingStatus iTonePlayingStatus; |
|
454 |
|
455 // True if Tts is currently playing. Is different from |
|
456 // iTonePlayingStatus, because TTS is played in |
|
457 // parallel with the other tone types |
|
458 TBool iTtsTonePlaying; |
|
459 |
|
460 // Index of the TTS delay that is "executed" currently or is to be |
|
461 // "executed" after the current playing of the TTS tone. Is zero based |
|
462 TInt iTtsDelayIndex; |
|
463 |
|
464 // True if TTS tone should be played when the next playing of the |
|
465 // default or personal tone is fired. |
|
466 TBool iTtsToneToBePlayed; |
|
467 |
|
468 // Normal ringing tone |
|
469 CPhoneRingingTone* iAudioVideoRingingTone; |
|
470 |
|
471 // Volume for backup tone playing. |
|
472 TInt iVolume; |
|
473 |
|
474 // Volume of the text pronounced by the TTS engine |
|
475 TInt iTtsVolume; |
|
476 |
|
477 // Ringing type for backup tone playing. |
|
478 TProfileRingingType iRingingType; |
|
479 |
|
480 // Timer. |
|
481 CPhoneTimer* iTimer; |
|
482 |
|
483 // Timer, that tracks delays before playing TTS |
|
484 CPhoneTimer* iTtsDelayTimer; |
|
485 |
|
486 // Number of times TTS tone should be played for the CURRENT ringtone |
|
487 // If ringing tone is to be played just once, iTtsDelayCount == 1, |
|
488 // otherwise iTtsDelayCount == KTtsDelayCount |
|
489 TInt iTtsDelaysCount; |
|
490 |
|
491 // Player to be deleted asynchronously. |
|
492 RPointerArray<CPhoneAudioPlayer> iAsyncDeletePlayers; |
|
493 |
|
494 // DRM extend security |
|
495 TBool iExtSecNeeded; |
|
496 |
|
497 // State of this active object |
|
498 TState iState; |
|
499 |
|
500 // RingingType for TtsPlayer only. |
|
501 TProfileRingingType iTtsRingingType; |
|
502 |
|
503 // Counter for TTs timeouts |
|
504 TInt iTTsTimeOutCounter; |
|
505 |
|
506 // Voice call ringing tone file size max value. |
|
507 TInt iToneFileSizeLimitKB; |
|
508 |
|
509 // Client message. |
|
510 RMessage2 iClientMessage; |
|
511 |
|
512 }; |
|
513 |
|
514 #endif //__PHONERINGINGTONESRVPLAYERAO_H |