|
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 CPHONETTSPLAYER_H_ |
|
19 #define CPHONETTSPLAYER_H_ |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 #include <Profile.hrh> |
|
24 |
|
25 // User includes |
|
26 #include "cphonetimer.h" |
|
27 #include "cphoneaudioplayer.h" |
|
28 #include "mphoneaudioplayerobserver.h" |
|
29 |
|
30 // Forward declarations |
|
31 class CPhoneRingingTone; |
|
32 class CPhoneRingingtonePlayer; |
|
33 |
|
34 NONSHARABLE_CLASS(CPhoneTTSPlayer): public CBase, |
|
35 public MPhoneAudioPlayerObserver |
|
36 |
|
37 { |
|
38 public: |
|
39 CPhoneTTSPlayer(CPhoneRingingtonePlayer* aRingingtonePlayer); |
|
40 virtual ~CPhoneTTSPlayer(); |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * @return new instance. |
|
45 */ |
|
46 static CPhoneTTSPlayer* NewL(CPhoneRingingtonePlayer* aRingingtonePlayer); |
|
47 |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Play TTS tone simultaneously with Personal or Default tones. |
|
53 * This method does not command phone to play TTS immediately. Instead |
|
54 * it registers a request to play TTS, when Personal or default tones |
|
55 * are played. |
|
56 * |
|
57 * @since Series 60 3.0 |
|
58 * @param aTextToSay Text, that should be pronounced by the |
|
59 * Text-To-Speech engine. This is normal descriptor, no UTF-8 |
|
60 * and no "(tts)" prefix |
|
61 */ |
|
62 void PlayTtsTone( |
|
63 const TDesC& aTextToSay, |
|
64 CPhoneRingingTone* aAudioVideoRingingTone ); |
|
65 |
|
66 void StopPlaying(); |
|
67 |
|
68 |
|
69 /** |
|
70 * Checks if TTS component should be played for the current ringtone |
|
71 * playback and initializes the TTS playback. This method is to be |
|
72 * called from within PlayXXXXTone methods |
|
73 * @since Series 60 3.0 |
|
74 * @param aRingingType ringing type |
|
75 */ |
|
76 void AddTtsPlaybackIfNeeded(); |
|
77 |
|
78 |
|
79 private: // from MPhoneAudioPlayerObserver |
|
80 /** |
|
81 * Handle the error of audio file player. |
|
82 */ |
|
83 virtual void HandleAudioPlayerError( |
|
84 TPhoneAudioPlayerErrorEvent aEvent, |
|
85 TInt aError, |
|
86 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
87 |
|
88 /** |
|
89 * Handle audio player initialize complete. |
|
90 */ |
|
91 virtual void HandleAudioPlayerInitComplete( |
|
92 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
93 |
|
94 /** |
|
95 * Handle auido file playing complete successfully. |
|
96 */ |
|
97 virtual void HandlePlayingComplete( |
|
98 TInt aId = KPhoneAudioPlayerNotSpecified ); |
|
99 |
|
100 private: |
|
101 |
|
102 /** |
|
103 * Enumerates how many times TTs is played |
|
104 * ESaidOnce -once |
|
105 * ESaidTwice twice |
|
106 */ |
|
107 enum TTtsStatus |
|
108 { |
|
109 ESaidOnce, |
|
110 ESaidTwice |
|
111 }; |
|
112 |
|
113 /** |
|
114 * Wrapper of DoHandleTtsDelayTimeout, that can be used as TCallback. |
|
115 * Immediately passes control to DoHandleTtsDelayTimeout method. |
|
116 * @since Series 60 3.0 |
|
117 * @param object Object to call DoHandleTtsDelayTimeout() on, . |
|
118 * instance of CPhoneRingingTonePlayer. |
|
119 * @return KErrNone. |
|
120 */ |
|
121 static TInt HandleTtsDelayTimeout( TAny* object ); |
|
122 |
|
123 /** |
|
124 * It is called after TTS delay elapsed. Starts playing TTS. |
|
125 */ |
|
126 void DoHandleTtsDelayTimeout(); |
|
127 |
|
128 /** |
|
129 * Returns currently active player which is used with TTS player. |
|
130 * @return pointer to CPhoneAudioPlayer. |
|
131 */ |
|
132 CPhoneAudioPlayer* GetCurrentlyActiveAudioPlayerWithTTs(); |
|
133 |
|
134 /** |
|
135 * TTs cases only. Calculates new volume and ramptimes |
|
136 * for Ascending TTS ringing case and normal TTS ringing case. |
|
137 * @param aStatus -status of TTs player. |
|
138 */ |
|
139 void SolveNewVolumeAndRamptime( TTtsStatus aStatus ); |
|
140 |
|
141 /** |
|
142 * Retarts currently active ringingtone player. |
|
143 */ |
|
144 void ReStartRingingTonePlayer(); |
|
145 |
|
146 /** |
|
147 * Convert ringing type from PhoneAppEnging to the ringing type in |
|
148 * CPhoneAudioPlayer. |
|
149 * @param aRingingType the ringing type form PhoneAppEngine. |
|
150 * @return ringing type of CPhoneAudioPlayer. |
|
151 */ |
|
152 CPhoneAudioPlayer::TRingingType ConvertRingingType( |
|
153 TProfileRingingType aRingingType ); |
|
154 |
|
155 private: |
|
156 |
|
157 /** |
|
158 * By default Symbian OS constructor is private. |
|
159 */ |
|
160 void ConstructL(); |
|
161 |
|
162 private: |
|
163 |
|
164 // Tts player. |
|
165 CPhoneAudioPlayer* iTtsPlayer; |
|
166 |
|
167 // True if Tts is currently playing. Is different from |
|
168 // iTonePlayingStatus, because TTS is played in |
|
169 // parallel with the other tone types |
|
170 TBool iTtsTonePlaying; |
|
171 |
|
172 // Index of the TTS delay that is "executed" currently or is to be |
|
173 // "executed" after the current playing of the TTS tone. Is zero based |
|
174 TInt iTtsDelayIndex; |
|
175 |
|
176 // True if TTS tone should be played when the next playing of the |
|
177 // default or personal tone is fired. |
|
178 TBool iTtsToneToBePlayed; |
|
179 |
|
180 // Timer, that tracks delays before playing TTS |
|
181 CPhoneTimer* iTtsDelayTimer; |
|
182 |
|
183 // Number of times TTS tone should be played for the CURRENT ringtone |
|
184 // If ringing tone is to be played just once, iTtsDelayCount == 1, |
|
185 // otherwise iTtsDelayCount == KTtsDelayCount |
|
186 TInt iTtsDelaysCount; |
|
187 |
|
188 // Counter for TTs timeouts |
|
189 TInt iTTsTimeOutCounter; |
|
190 |
|
191 // RingingType for TtsPlayer only. |
|
192 TProfileRingingType iTtsRingingType; |
|
193 |
|
194 // Volume of the text pronounced by the TTS engine |
|
195 TInt iTtsVolume; |
|
196 |
|
197 CPhoneRingingtonePlayer* iRingingtonePlayer; |
|
198 }; |
|
199 |
|
200 #endif /* CPHONETTSPLAYER_H_ */ |