|
1 /* |
|
2 * Copyright (c) 2005 - 2006 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: SVG Implementation header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_SVGAUDIOELEMENTIMPL_H |
|
20 #define C_SVGAUDIOELEMENTIMPL_H |
|
21 |
|
22 #include "SVGMediaElementBase.h" |
|
23 #include "SVGRequestObserver.h" |
|
24 #include <mdaaudiosampleplayer.h> |
|
25 |
|
26 class CSvgDocumentImpl; |
|
27 class MXmlDocument; |
|
28 |
|
29 /** |
|
30 * Class description: |
|
31 * This class provides the implementation for the audio |
|
32 * element as mentioned in the svg-t 1.2 specification. |
|
33 * @lib SVGEngine.lib |
|
34 * @since S60 3.2 |
|
35 */ |
|
36 NONSHARABLE_CLASS( CSvgAudioElementImpl ) : public CSvgMediaElementBase, |
|
37 public MMdaAudioPlayerCallback |
|
38 { |
|
39 public: |
|
40 /** |
|
41 * Deep Copy of the parent |
|
42 * |
|
43 * @since S60 3.2 |
|
44 * @param element to be copied |
|
45 * @return |
|
46 */ |
|
47 MXmlElement* CloneL(MXmlElement* aParentElement); |
|
48 |
|
49 /** |
|
50 * Create new element of audioelementimpl |
|
51 * |
|
52 * @since S60 3.2 |
|
53 * @param |
|
54 * @return |
|
55 */ |
|
56 static CSvgAudioElementImpl* NewL( const TUint8 aElemID, |
|
57 CSvgDocumentImpl* aDoc ); |
|
58 |
|
59 /** |
|
60 * Create new element of audioimpl |
|
61 * |
|
62 * @since S60 3.2 |
|
63 * @param |
|
64 * @return |
|
65 */ |
|
66 static CSvgAudioElementImpl* NewLC( const TUint8 aElemID, |
|
67 CSvgDocumentImpl* aDoc ); |
|
68 |
|
69 private: |
|
70 /** |
|
71 * Create new element of audioelementimpl |
|
72 * |
|
73 * @since S60 3.2 |
|
74 * @param |
|
75 * @return |
|
76 */ |
|
77 void ConstructL( const TUint8 aElemID,CSvgDocumentImpl* aDoc ); |
|
78 |
|
79 public: |
|
80 void CSvgAudioElementImpl::SetUriL( const TDesC& aUri ); |
|
81 |
|
82 /** |
|
83 * Constructor for AudioElement |
|
84 * |
|
85 * @since S60 3.2 |
|
86 * @param SvgDocument |
|
87 * @return None |
|
88 */ |
|
89 CSvgAudioElementImpl( CSvgDocumentImpl* aDoc ); |
|
90 |
|
91 |
|
92 /** |
|
93 * Destructor for Audioelement |
|
94 * |
|
95 * @since S60 3.2 |
|
96 * @param None |
|
97 * @return None |
|
98 */ |
|
99 virtual ~CSvgAudioElementImpl(); |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 /** |
|
105 * Need method description |
|
106 * |
|
107 * @since S60 3.2 |
|
108 * @param |
|
109 * @return |
|
110 */ |
|
111 void LoadUriL(); |
|
112 |
|
113 // From MXmlElement API |
|
114 |
|
115 |
|
116 /** |
|
117 * Sets attributes of audio element |
|
118 * |
|
119 * @since S60 3.2 |
|
120 * @param name of attribute and value to be set to attribute |
|
121 * @return |
|
122 */ |
|
123 TInt SetAttributeL( const TDesC& aName, const TDesC& aValue ); |
|
124 |
|
125 /** |
|
126 * Sets attributes of audio element |
|
127 * |
|
128 * @since S60 3.2 |
|
129 * @param name of attribute and value to be set to attribute |
|
130 * @return |
|
131 */ |
|
132 TInt SetAttributeDesL( const TInt aNameId, const TDesC& aValue ); |
|
133 |
|
134 |
|
135 /** |
|
136 * Get attributes of audio element |
|
137 * |
|
138 * @since S60 3.2 |
|
139 * @param name of attribute and value to be set to attribute |
|
140 * @return |
|
141 */ |
|
142 TInt GetAttributeFloat( const TInt aNameId, TFloatFixPt& aValue ); |
|
143 |
|
144 /** |
|
145 * Sets attributes of audio element |
|
146 * |
|
147 * @since S60 3.2 |
|
148 * @param name of attribute and value to be set to attribute |
|
149 * @return |
|
150 */ |
|
151 TInt SetAttributeFloatL( const TInt aNameId, TFloatFixPt aValue ); |
|
152 |
|
153 |
|
154 /** |
|
155 * From CSvgMediaElementBase |
|
156 * ReceiveEventL: This function will be called whenever the registered |
|
157 * event was happened. |
|
158 * |
|
159 * @since S60 3.2 |
|
160 * @param MSvgEvent* aEvent |
|
161 * @return TBool ETrue if redraw is needed |
|
162 */ |
|
163 TBool ReceiveEventL( MSvgEvent* aEvent ); |
|
164 |
|
165 /** |
|
166 * From CSvgMediaElementBase |
|
167 * |
|
168 * @since S60 3.2 |
|
169 * @param none. |
|
170 * @return none. |
|
171 */ |
|
172 void ResetAnimationL(); |
|
173 |
|
174 /** |
|
175 * From CSvgMediaElementBase |
|
176 * |
|
177 * @since S60 3.2 |
|
178 * @param MSvgEvent* aEvent |
|
179 * @return none. |
|
180 */ |
|
181 void Reset( MSvgEvent* aEvent ); |
|
182 |
|
183 /** |
|
184 * Call AnimaProcL |
|
185 * |
|
186 * @since S60 3.2 |
|
187 * @param MsvgEvent |
|
188 * @return Boolean indicating successfull completion of the event |
|
189 */ |
|
190 TBool DoAnimProcL(MSvgEvent* aEvent); |
|
191 |
|
192 |
|
193 /** |
|
194 * Return wether an svg element is displayable, such as <rect>, |
|
195 * <circle>, or an abstract element, such as <g>, <animate>. |
|
196 * |
|
197 * @since S60 3.2 |
|
198 * @param None |
|
199 * @return ETrue if element is viewable. |
|
200 */ |
|
201 TBool IsViewable() { return EFalse; } |
|
202 |
|
203 /* |
|
204 * Set the volume of the Audio Player to the specified level |
|
205 * |
|
206 * @since S60 3.2 |
|
207 * @param TInt Volume |
|
208 * @return none |
|
209 */ |
|
210 void SetVolume(TInt aVolume); |
|
211 void Print( TBool aIsEncodeOn ); |
|
212 |
|
213 protected: |
|
214 |
|
215 /** |
|
216 * Need method description |
|
217 * |
|
218 * @since S60 3.2 |
|
219 * @param CSvgAudioElementImpl |
|
220 * @return None |
|
221 */ |
|
222 void CopyL( CSvgAudioElementImpl* aDestElement ); |
|
223 |
|
224 private: |
|
225 /* |
|
226 * From MsvgAnimationBase |
|
227 */ |
|
228 virtual TBool AnimProcL( MSvgTimerEvent* aEvent ); |
|
229 /* |
|
230 * From MsvgAnimationBase |
|
231 */ |
|
232 virtual void InitAnimationL(); |
|
233 |
|
234 /* |
|
235 * From CMdaAudioPlayerUtility |
|
236 * Callback from Audio Player indicating the audio has finished |
|
237 * initialisation |
|
238 * @ since S60 3.2 |
|
239 */ |
|
240 virtual void MapcInitComplete( TInt aError, |
|
241 const TTimeIntervalMicroSeconds& aDuration ); |
|
242 /* |
|
243 * From CMdaAudioPlayerUtility |
|
244 * Callback from Audio Player indicating the audio has finished |
|
245 * playing |
|
246 * @ since S60 3.2 |
|
247 */ |
|
248 virtual void MapcPlayComplete(TInt aError); |
|
249 |
|
250 private: |
|
251 // From base classes |
|
252 |
|
253 /** |
|
254 * From CSvgMediaElementBase |
|
255 * When the timed entity acts as timing master in the time container, |
|
256 * the time container gets the timed entity clock using this method |
|
257 * and feeds to rest of timed entities. |
|
258 * @since S60 3.2 |
|
259 * @param aEntityCurTime Current Entity Time in msecs. |
|
260 * @return none. |
|
261 */ |
|
262 void GetEntityCurrentTime( TUint32& aEntityCurTime ); |
|
263 |
|
264 |
|
265 /** |
|
266 * From CSvgMediaElementBase |
|
267 * Check if timed entity can provide timing ticks to rest of time |
|
268 * container elements. This behavior could change dynamically. |
|
269 * For example, if audio clip is over, the audio element can't generate |
|
270 * ticks for others. |
|
271 * @since S60 3.2 |
|
272 * @param none. |
|
273 * @return TBool True if can generate timing tick. |
|
274 */ |
|
275 TBool CanGenerateTick(); |
|
276 |
|
277 /** |
|
278 * From CSvgMediaElementBase |
|
279 * If the timed entity needs to be in sync with the time container and |
|
280 * it has slipped beyond the sync tolerance limit, the method is called to |
|
281 * bring the element in sync with the time container. |
|
282 * @since S60 3.2 |
|
283 * @param aSynctime Time for resync in msecs. |
|
284 * @return none. |
|
285 */ |
|
286 void ResyncTimedEntity( TUint32 aSynctime ); |
|
287 |
|
288 /** |
|
289 * From CSvgMediaElementBase |
|
290 * This would be used for pausing the timed entity while other locked |
|
291 * timed entities get loaded. |
|
292 * @since S60 3.2 |
|
293 * @param none. |
|
294 * @return none. |
|
295 */ |
|
296 void PauseTimedEntity(); |
|
297 |
|
298 /** |
|
299 * From CSvgMediaElementBase |
|
300 * This would be used for resuming the timed entity once all locked |
|
301 * timed entities get loaded. |
|
302 * @since S60 3.2 |
|
303 * @param none. |
|
304 * @return none. |
|
305 */ |
|
306 void ResumeTimedEntity(); |
|
307 |
|
308 /** |
|
309 * From CSvgMediaElementBase |
|
310 * This would be used for stoping the timed entity once all locked |
|
311 * timed entities get loaded. |
|
312 * @since S60 3.2 |
|
313 * @param none. |
|
314 * @return none. |
|
315 */ |
|
316 void StopTimedEntity(); |
|
317 |
|
318 |
|
319 /* |
|
320 * From MSvgTimedEntityInterface |
|
321 * Would return the type of object |
|
322 * @param none |
|
323 * @return type of object |
|
324 */ |
|
325 TSvgObjectType ObjectType(); |
|
326 |
|
327 CSvgTimeContainer* GetChildTimeContainer(); |
|
328 |
|
329 |
|
330 void DeactivateAnimation(); |
|
331 |
|
332 |
|
333 private: |
|
334 |
|
335 //Audio Player Utility |
|
336 CMdaAudioPlayerUtility* iAudioPlayer; |
|
337 |
|
338 enum TPlayerState |
|
339 { |
|
340 EPlayerStateIdle, |
|
341 EPlayerStatePlayInit, |
|
342 EPlayerStatePlaying, |
|
343 EPlayerStatePaused, |
|
344 EPlayerStateStop, |
|
345 EPlayerProhibit, |
|
346 EPlayerStateComplete, |
|
347 |
|
348 }; |
|
349 |
|
350 //Current status of player |
|
351 TPlayerState iAudioStatus; |
|
352 //Current Volume of the player |
|
353 TReal32 iVolume; |
|
354 TInt iPercentLevelVolume; |
|
355 // Media duration in usecs |
|
356 TTimeIntervalMicroSeconds iMediaDuration; |
|
357 // Indicates whether time container issued a pause command |
|
358 enum TcCommandStatus |
|
359 { |
|
360 ESvgTEPausedState, |
|
361 ESvgTEStoppedState, |
|
362 ESvgTEPlayingState |
|
363 }; |
|
364 |
|
365 //Current Command on the player |
|
366 TcCommandStatus iTcCommandState; |
|
367 // Offset in msecs from document start since the audio |
|
368 // element became active |
|
369 TUint32 iAudioStartOffset; |
|
370 |
|
371 //Flag indicating if duration is specified as media |
|
372 TBool iDurMedia; |
|
373 |
|
374 HBufC* iUri; |
|
375 |
|
376 //Indicates the length of the clip that has already played |
|
377 //Introduced to ensure that getentitycurrent time returns correct value |
|
378 //At the end of a clip getPosition returns zero |
|
379 //because of some bug in audio player |
|
380 TTimeIntervalMicroSeconds iStoredPos; |
|
381 |
|
382 }; |
|
383 |
|
384 #endif //C_SVGAUDIOELEMENTIMPL_H |
|
385 // --------------------------------------------------------------------------- |
|
386 // End of file |
|
387 // --------------------------------------------------------------------------- |