1 /* |
|
2 * Copyright (c) 2010 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: Ring Tone Audio playback handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef TMSRTAUDIOHDLR_H |
|
19 #define TMSRTAUDIOHDLR_H |
|
20 |
|
21 // INCLUDES |
|
22 |
|
23 #include <AudioOutput.h> |
|
24 //#include <c3dringingtoneinterface.h> |
|
25 #include <mdaaudiosampleplayer.h> |
|
26 #include <mdaaudiotoneplayer.h> |
|
27 |
|
28 namespace TMS { |
|
29 |
|
30 // CLASS DECLARATION |
|
31 class TMSRtAudioHdlrObsrv; |
|
32 class TMSRtContainer; |
|
33 |
|
34 /** |
|
35 * RingTone audio handler. |
|
36 * Handles audio for tone sequence and digital sample playback. |
|
37 */ |
|
38 class TMSRtAudioHdlr : public CBase, |
|
39 public MMdaAudioPlayerCallback, |
|
40 public MMdaAudioToneObserver |
|
41 { |
|
42 public: |
|
43 |
|
44 enum TAudioPlayerStatus |
|
45 { |
|
46 EToneLoading, |
|
47 EToneReady, |
|
48 ETonePlaying |
|
49 }; |
|
50 |
|
51 enum TRingingType |
|
52 { |
|
53 ETypeRinging, |
|
54 ETypeRingingOnce, |
|
55 ETypeAscending |
|
56 }; |
|
57 |
|
58 public: |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * @param aRingingTone The ringing tone |
|
62 * @param aPriority The priority for the playing |
|
63 * @param aPreference The preference value |
|
64 * @param aObserver Audio player observer |
|
65 * @param aType The id of this audio player |
|
66 * @param aExtSecNeeded ETrue if DRM extend security is needed |
|
67 * @return The instance of the audio player. |
|
68 */ |
|
69 static TMSRtAudioHdlr* NewL(const TMSRtContainer& aRingingTone, |
|
70 TUint aPriority, TUint aPreference, |
|
71 TMSRtAudioHdlrObsrv& aObserver, TInt aType = 0, |
|
72 TBool aExtSecNeeded = EFalse); |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 * @param aFileName The ringing tone file name. |
|
77 * @param aPriority The priority for the playing |
|
78 * @param aPreference The preference value |
|
79 * @param aObserver Audio player observer |
|
80 * @param aType The id of this audio player |
|
81 * @param aExtSecNeeded ETrue if DRM extend security is needed |
|
82 * @return The instance of the audio player. |
|
83 */ |
|
84 static TMSRtAudioHdlr* NewL(const TDesC& aFileName, TUint aPriority, |
|
85 TUint aPreference, TMSRtAudioHdlrObsrv& aObserver, |
|
86 TInt aType = 0, TBool aExtSecNeeded = EFalse); |
|
87 |
|
88 /** |
|
89 * Two-phased constructor, take audio from descriptor. |
|
90 * |
|
91 * @param aSequence sequence to be played. |
|
92 * @param aPriority priority of tone. |
|
93 * @param aPreference preference of tone. |
|
94 * @param aObserver observer. |
|
95 * @param aType identifier, used in observer interface calls. |
|
96 * @return The instance of the audio player. |
|
97 */ |
|
98 static TMSRtAudioHdlr* NewSeqL(const TDesC8& aSequence, |
|
99 TUint aPriority, TUint aPreference, |
|
100 TMSRtAudioHdlrObsrv& aObserver, TInt aType = 0); |
|
101 |
|
102 /** |
|
103 * Two-phased constructor, takes Text-To-Speech text to be played. |
|
104 * @param aText Text to be pronounced. |
|
105 * @param aPriority priority of tone. |
|
106 * @param aPreference preference of tone. |
|
107 * @param aObserver observer. |
|
108 * @param aType identifier, used in observer interface calls. |
|
109 * @return The instance of the audio player. |
|
110 */ |
|
111 static TMSRtAudioHdlr* NewTtsL(const TDesC& aText, TUint aPriority, |
|
112 TUint aPreference, TMSRtAudioHdlrObsrv& aObserver, TInt aType = 0); |
|
113 |
|
114 /** |
|
115 * Destructor. |
|
116 */ |
|
117 ~TMSRtAudioHdlr(); |
|
118 |
|
119 public: |
|
120 // new function |
|
121 |
|
122 /** |
|
123 * Play the audio file or tone |
|
124 * @param aRingingType |
|
125 * @param aVolume take value from 1 to 10 |
|
126 * @param aTTsToBePlayed |
|
127 */ |
|
128 void Play(TRingingType aRingType, TInt aVolume, TBool aTTsToBePlayed); |
|
129 |
|
130 /** |
|
131 * Stop current file playing |
|
132 */ |
|
133 void StopPlaying(); |
|
134 |
|
135 /** |
|
136 * Sets new volumes and ramptimes. |
|
137 * @param aVolume -volume to be set |
|
138 * @param aRamptime -ramptime to be set. |
|
139 */ |
|
140 void SetNewVolumeAndRamptime(TInt aVolume, TInt aRamptime); |
|
141 |
|
142 /** |
|
143 * Re starts playing. |
|
144 */ |
|
145 void ReStartPlaying(); |
|
146 /** |
|
147 * Enable or disable TTs playing. |
|
148 * @param aTTsToBePlayed |
|
149 */ |
|
150 void SetTTsToBePlayed(const TBool aTTsToBePlayed); |
|
151 |
|
152 /** |
|
153 * Sets volume level to zero. |
|
154 */ |
|
155 void MutePlaying(); |
|
156 |
|
157 public: |
|
158 /** |
|
159 * from MMdaAudioPlayerCallback |
|
160 */ |
|
161 virtual void MapcInitComplete(TInt aError, |
|
162 const TTimeIntervalMicroSeconds& aDuration); |
|
163 |
|
164 /** |
|
165 * from MMdaAudioPlayerCallback |
|
166 */ |
|
167 virtual void MapcPlayComplete(TInt aError); |
|
168 |
|
169 /** |
|
170 * from MMdaAudioToneObserver |
|
171 */ |
|
172 virtual void MatoPrepareComplete(TInt aError); |
|
173 |
|
174 /** |
|
175 * from MMdaAudioToneObserver |
|
176 */ |
|
177 virtual void MatoPlayComplete(TInt aError); |
|
178 |
|
179 private: |
|
180 |
|
181 enum TAudioDataFormat |
|
182 { |
|
183 EFormatTone, |
|
184 EFormatSample, |
|
185 EFormatTts |
|
186 }; |
|
187 |
|
188 /** |
|
189 * C++ constructor. |
|
190 */ |
|
191 TMSRtAudioHdlr(TAudioDataFormat aDataFormat, |
|
192 TMSRtAudioHdlrObsrv& aObserver, TUint aPriority, |
|
193 TUint aPreference, TInt aType); |
|
194 |
|
195 /** |
|
196 * Symbian OS constructor. |
|
197 */ |
|
198 void ConstructL(const TDesC& aFileName); |
|
199 |
|
200 /** |
|
201 * Symbian OS constructor. |
|
202 */ |
|
203 void ConstructSeqL(const TDesC8& aSequence); |
|
204 |
|
205 /** |
|
206 * Symbian OS constructor for the Text-To-Speech option |
|
207 */ |
|
208 void ConstructTtsL(const TDesC& aTtsText, TUint aPriority, |
|
209 TUint aPreference); |
|
210 |
|
211 /** |
|
212 * Do the playing stuff |
|
213 */ |
|
214 void DoPlay(); |
|
215 |
|
216 /** |
|
217 * Set ringing type properties |
|
218 */ |
|
219 void SetRingingTypeProperties(); |
|
220 |
|
221 /** |
|
222 * Call back function for timer |
|
223 */ |
|
224 static TInt TimerCallBack(TAny* aAny); |
|
225 |
|
226 /** |
|
227 * Handle timer events |
|
228 */ |
|
229 void HandleTimerEvent(); |
|
230 |
|
231 /* |
|
232 * Convert volume to the scale used by hardware |
|
233 * @param aVolume volume to be altered |
|
234 * @return TInt new volume |
|
235 */ |
|
236 TInt ConvertVolume(TInt aVolume); |
|
237 |
|
238 private: |
|
239 // Data |
|
240 |
|
241 // The format of audio data, audio sample file or tone file |
|
242 TAudioDataFormat iFormat; |
|
243 |
|
244 // Observer for error handling |
|
245 TMSRtAudioHdlrObsrv& iObserver; |
|
246 |
|
247 // Priority. It's only used in playing tone file |
|
248 const TInt iPriority; |
|
249 |
|
250 // Preference. Only used for tone file |
|
251 const TUint iPreference; |
|
252 |
|
253 // Identifier number |
|
254 TInt iRtType; |
|
255 |
|
256 // Player for tone file. |
|
257 CMdaAudioToneUtility* iTonePlayer; |
|
258 |
|
259 // Player for audio file. |
|
260 CMdaAudioPlayerUtility* iSamplePlayer; |
|
261 |
|
262 // Player for the Text-To-Speech texts |
|
263 CMdaAudioPlayerUtility* iTtsPlayer; |
|
264 |
|
265 // The status of the player |
|
266 TAudioPlayerStatus iPlayerStatus; |
|
267 |
|
268 // How does the file played. It's only used if the player |
|
269 // is playing the file |
|
270 TRingingType iRingType; |
|
271 |
|
272 // Volume |
|
273 TInt iVolume; |
|
274 |
|
275 // For ascending and descending used for set current volume |
|
276 TInt iCurrentVolume; |
|
277 |
|
278 // Used by sample player |
|
279 TBool iToBePlaying; |
|
280 |
|
281 // Store for sequence. |
|
282 HBufC8* iSequence; |
|
283 |
|
284 // Store for the TTS source string |
|
285 HBufC8* iTtsText; |
|
286 |
|
287 // 3D Audio ringing tone plugin |
|
288 //C3DRingingToneInterface* i3DPlugin; |
|
289 |
|
290 // Ringingtone output |
|
291 //CAudioOutput* iAudioOutput; |
|
292 |
|
293 // Flag to indicate whether we need to play TTs or not |
|
294 TBool iTTsToBePlayed; |
|
295 }; |
|
296 |
|
297 } //namespace TMS |
|
298 |
|
299 #endif //TMSRTAUDIOHDLR_H |
|
300 |
|
301 // End of File |
|