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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPHONERINGINGTONEPLAYER_H_ |
|
19 #define CPHONERINGINGTONEPLAYER_H_ |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 #include <Profile.hrh> |
|
24 |
|
25 // User includes |
|
26 #include "mphoneaudioplayerobserver.h" |
|
27 #include "cphoneaudioplayer.h" |
|
28 #include "mphonevideoplayer.h" |
|
29 #include "mphonecenrepobserver.h" |
|
30 #include "mphonetimer.h" |
|
31 |
|
32 // Forward declarations |
|
33 class CPhoneTimer; |
|
34 class CPhoneRingingTone; |
|
35 |
|
36 |
|
37 NONSHARABLE_CLASS(CPhoneRingingtonePlayer) : public CActive, |
|
38 public MPhoneAudioPlayerObserver, |
|
39 public MPhoneCenRepObserver, |
|
40 private MPhoneTimer |
|
41 { |
|
42 public: |
|
43 CPhoneRingingtonePlayer(); |
|
44 virtual ~CPhoneRingingtonePlayer(); |
|
45 |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 * @return new instance. |
|
50 */ |
|
51 static CPhoneRingingtonePlayer* NewL(); |
|
52 |
|
53 /** |
|
54 * Playing ringing tone based on profile. |
|
55 * @param aAudioVideoRingingTone |
|
56 */ |
|
57 void PlayProfileBasedTone( CPhoneRingingTone* aAudioVideoRingingTone ); |
|
58 |
|
59 /** |
|
60 * Playing the Beep once. |
|
61 * @param aVolume volume used to play the ringing tone. |
|
62 */ |
|
63 void PlayBeepOnce( TInt aVolume ); |
|
64 |
|
65 /** |
|
66 * Play silent tone. No_sound.wav will be played. If vibration alert |
|
67 * is ON, it will vibrate. |
|
68 */ |
|
69 void PlaySilentTone(); |
|
70 |
|
71 /** |
|
72 * Play video ring tone. |
|
73 * @since Series 60 3.1 |
|
74 * @param aRingingTone Ringing tone to be played. |
|
75 * @param aVolume Volume used to play the ringing tone. |
|
76 * @param aRingingType Ringing type. |
|
77 */ |
|
78 void PlayVideoRingingTone( |
|
79 const CPhoneRingingTone& aRingingTone, |
|
80 TInt aVolume, |
|
81 TProfileRingingType aRingingType, |
|
82 TBool aPersonalTone = EFalse ); |
|
83 |
|
84 /** |
|
85 * Play default tone. |
|
86 * @param aVolume volume used for the playing. |
|
87 * @param aRingingType ringing type. |
|
88 */ |
|
89 void PlayDefaultTone( |
|
90 TInt aVolume, |
|
91 TProfileRingingType aRingingType ); |
|
92 |
|
93 /** |
|
94 * Play backup tone. |
|
95 * @param aVolume volume used for the playing. |
|
96 * @param aRingingType ringing type. |
|
97 */ |
|
98 void PlayBackupTone( |
|
99 TInt aVolume, |
|
100 TProfileRingingType aRingingType ); |
|
101 |
|
102 /** |
|
103 * Stops playing the ringing tone. |
|
104 * Method does not do anything if ringing tone is not playing. |
|
105 */ |
|
106 void StopPlaying(); |
|
107 |
|
108 /** |
|
109 * Enumerates identifiers for each player: |
|
110 * EPlayerAudio - audio |
|
111 * EPlayerBeepOnce - beep once |
|
112 * EPlayerSilent - silent |
|
113 * EPlayerDefault - default |
|
114 * EPlayerBackup - backup |
|
115 * |
|
116 * EPlayerFirst and EPlayerLast are alias |
|
117 * to other identifiers. |
|
118 * EPlayerFirst - first player |
|
119 * EPlayerLast - last player |
|
120 */ |
|
121 enum TPlayerId |
|
122 { |
|
123 EPlayerFirst, |
|
124 EPlayerAudio = EPlayerFirst, |
|
125 EPlayerBeepOnce, |
|
126 EPlayerSilent, |
|
127 EPlayerDefault, |
|
128 EPlayerBackup, |
|
129 EPlayerTts, |
|
130 EPlayerLast = EPlayerTts, |
|
131 EPlayerCount |
|
132 }; |
|
133 |
|
134 CPhoneAudioPlayer* GetCurrentlyActiveAudioPlayer(); |
|
135 |
|
136 void MuteActiveAudioPlayer(); |
|
137 |
|
138 public: // From MPhoneCenRepObserver |
|
139 |
|
140 /** |
|
141 * Handle the change of the setting from Central Repository |
|
142 * @param aUid identifing the central repository UID. |
|
143 * @param aId central repository ID. |
|
144 */ |
|
145 virtual void HandleCenRepChangeL( |
|
146 const TUid& aUid, |
|
147 const TUint aId ); |
|
148 |
|
149 |
|
150 |
|
151 private: |
|
152 |
|
153 /** |
|
154 * By default Symbian OS constructor is private. |
|
155 */ |
|
156 void ConstructL(); |
|
157 |
|
158 private: // CActive |
|
159 |
|
160 /** |
|
161 * @see CActive::RunL. |
|
162 */ |
|
163 void RunL(); |
|
164 |
|
165 /** |
|
166 * @see CActive::DoCancel. |
|
167 */ |
|
168 void DoCancel(); |
|
169 |
|
170 private: // from MPhoneAudioPlayerObserver |
|
171 /** |
|
172 * Handle the error of audio file player. |
|
173 */ |
|
174 virtual void HandleAudioPlayerError( |
|
175 TPhoneAudioPlayerErrorEvent aEvent, |
|
176 TInt aError, |
|
177 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
178 |
|
179 /** |
|
180 * Handle audio player initialize complete. |
|
181 */ |
|
182 virtual void HandleAudioPlayerInitComplete( |
|
183 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
184 |
|
185 /** |
|
186 * Handle auido file playing complete successfully. |
|
187 */ |
|
188 virtual void HandlePlayingComplete( |
|
189 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
190 |
|
191 private: |
|
192 |
|
193 /** |
|
194 * @see MPhoneTimer |
|
195 */ |
|
196 virtual void HandleTimeOutL(); |
|
197 |
|
198 private: |
|
199 |
|
200 |
|
201 // Indicate which tone is playing or need to be played: |
|
202 // EIdle - idle, |
|
203 // EAudioTonePlaying - audio playing, |
|
204 // EBeepOnce - beep once playing, |
|
205 // ESilentTonePlaying - silent tone playing, |
|
206 // EDefaultTonePlaying - default tone playing, |
|
207 // EBackupTonePlaying - backup tone playing, |
|
208 // EVideoTonePlaying - playing video ringing tone |
|
209 // ESilentVideoTonePlaying - silent playing video ringing tone |
|
210 // EPersonalVideoTonePlaying - personal playing video ringing tone |
|
211 enum TTonePlayingStatus |
|
212 { |
|
213 EIdle, |
|
214 EAudioTonePlaying, |
|
215 EBeepOnce, |
|
216 ESilentTonePlaying, |
|
217 EDefaultTonePlaying, |
|
218 EBackupTonePlaying, |
|
219 EVideoTonePlaying, |
|
220 ESilentVideoTonePlaying, |
|
221 EPersonalVideoTonePlaying |
|
222 }; |
|
223 |
|
224 // States for this active object |
|
225 enum TState |
|
226 { |
|
227 EIdleState, |
|
228 EDeletingAudioPlayer, |
|
229 EDeletingVideoPlayer, |
|
230 EPlayingDefaultVideo |
|
231 }; |
|
232 |
|
233 /** |
|
234 * Deletes player asynchronoysly. |
|
235 * @param aPlayer player to be deleted. |
|
236 */ |
|
237 void DeletePlayerAsync( |
|
238 TPlayerId aPlayer ); |
|
239 |
|
240 /** |
|
241 * Construct sequence players. |
|
242 * @param aPlayer player to be constructed. |
|
243 */ |
|
244 void ConstructSequencePlayer( |
|
245 TPlayerId aPlayer ); |
|
246 |
|
247 /** |
|
248 * Construct sequence players. |
|
249 * @param aPlayer player to be constructed. |
|
250 */ |
|
251 void ConstructSequencePlayerL( |
|
252 TPlayerId aPlayer ); |
|
253 |
|
254 /** |
|
255 * Construct backup tone player. |
|
256 */ |
|
257 TInt ConstructBackupPlayer(); |
|
258 |
|
259 |
|
260 /** |
|
261 * Construct media server and backup tone player. |
|
262 */ |
|
263 void ConstructBackupPlayerL(); |
|
264 |
|
265 /** |
|
266 * Default ringingtone from profile engine. |
|
267 */ |
|
268 void ConstructDefaultPlayerL(); |
|
269 |
|
270 /** |
|
271 * Do construct tone. |
|
272 * @param aRingingTone Ringing tone. |
|
273 * @return The instance of the player. NULL is returned if it's failed. |
|
274 */ |
|
275 CPhoneAudioPlayer* ConstructTonePlayer( |
|
276 const CPhoneRingingTone& aRingingTone, |
|
277 TInt aId ); |
|
278 |
|
279 /** |
|
280 * Convert ringing type from PhoneAppEnging to the ringing type in |
|
281 * CPhoneAudioPlayer. |
|
282 * @param aRingingType the ringing type form PhoneAppEngine. |
|
283 * @return ringing type of CPhoneAudioPlayer. |
|
284 */ |
|
285 CPhoneAudioPlayer::TRingingType ConvertRingingType( |
|
286 TProfileRingingType aRingingType ); |
|
287 |
|
288 /** |
|
289 * Convert ringing type from PhoneAppEnging to the ringing type in |
|
290 * MPhoneVideoPlayer. |
|
291 * @since Series 60 3.1 |
|
292 * @param aRingingType the ringing type form PhoneAppEngine. |
|
293 * @return ringing type of MPhoneVideoPlayer. |
|
294 */ |
|
295 MPhoneVideoPlayer::TPlayMode ConvertVideoRingingType( |
|
296 TProfileRingingType aRingingType ); |
|
297 |
|
298 /** |
|
299 * Cleanup players. |
|
300 */ |
|
301 void CleanupPlayers(); |
|
302 |
|
303 /** |
|
304 * Handle audio player error. |
|
305 * @param aDelete ETrue if deletion of the player allowed, |
|
306 * EFalse otherwise. |
|
307 * @param aSync ETrue if synchronous deletion of players is allowed, |
|
308 * EFalse otherwise. |
|
309 */ |
|
310 void DoHandlePlayerError( |
|
311 TBool aDelete, |
|
312 TBool aSync ); |
|
313 |
|
314 |
|
315 private: // Data |
|
316 |
|
317 |
|
318 // State of this active object |
|
319 TState iState; |
|
320 |
|
321 // Player to be deleted asynchronously. |
|
322 RPointerArray<CPhoneAudioPlayer> iAsyncDeletePlayers; |
|
323 |
|
324 // Current playing status. |
|
325 TTonePlayingStatus iTonePlayingStatus; |
|
326 |
|
327 // Voice call ringing tone file size max value. |
|
328 TInt iToneFileSizeLimitKB; |
|
329 |
|
330 // DRM extend security |
|
331 TBool iExtSecNeeded; |
|
332 |
|
333 // Volume for backup tone playing. |
|
334 TInt iVolume; |
|
335 |
|
336 // Ringing type for backup tone playing. |
|
337 TProfileRingingType iRingingType; |
|
338 |
|
339 // Audio ring tone player. Memory allocated during construction. |
|
340 // After constructed, no leave may be caused during audio playing |
|
341 CPhoneAudioPlayer* iAudioPlayer; |
|
342 |
|
343 // Audio player for beep once. |
|
344 CPhoneAudioPlayer* iBeepOncePlayer; |
|
345 |
|
346 // Audio player for silent tone. |
|
347 CPhoneAudioPlayer* iSilentPlayer; |
|
348 |
|
349 // Default player. |
|
350 CPhoneAudioPlayer* iDefaultPlayer; |
|
351 |
|
352 // Tts player. |
|
353 CPhoneAudioPlayer* iTtsPlayer; |
|
354 |
|
355 // Backup ringing tone. Incase all default player failed. |
|
356 CPhoneAudioPlayer* iBackupPlayer; |
|
357 |
|
358 // Default player |
|
359 CPhoneRingingTone* iDefaultRingingTone; |
|
360 |
|
361 // Media server. |
|
362 CMdaServer* iMdaServer; |
|
363 |
|
364 // Timer. |
|
365 CPhoneTimer* iTimer; |
|
366 |
|
367 // Audio/Video tone |
|
368 CPhoneRingingTone* iAudioVideoRingingTone; |
|
369 }; |
|
370 |
|
371 #endif /* CPHONERINGINGTONEPLAYER_H_ */ |
|