|
1 /* |
|
2 * Copyright (c) 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: Provides the base class implementation for the media elements. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SVGMediaElementBase.h" |
|
22 #include "SVGAnimTimingParser.h" |
|
23 #include "SVGTimeContainer.h" |
|
24 |
|
25 _LIT( KTmpCanSlip, "canSlip" ); |
|
26 _LIT( KTmpLocked, "locked" ); |
|
27 _LIT( KTmpIndependent, "independent" ); |
|
28 _LIT( KTmpDefault, "default" ); |
|
29 _LIT( KTmpSyncBehavior, "syncBehavior" ); |
|
30 _LIT( KTmpSyncTolerance, "syncTolerance" ); |
|
31 _LIT( KTmpSyncMaster, "syncMaster" ); |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 //extern ?external_data; |
|
34 |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 //extern ?external_function( ?arg_type,?arg_type ); |
|
37 |
|
38 // CONSTANTS |
|
39 //const ?type ?constant_var = ?constant; |
|
40 |
|
41 // MACROS |
|
42 //#define ?macro ?macro_def |
|
43 |
|
44 // LOCAL CONSTANTS AND MACROS |
|
45 //const ?type ?constant_var = ?constant; |
|
46 //#define ?macro_name ?macro_def |
|
47 |
|
48 // MODULE DATA STRUCTURES |
|
49 //enum ?declaration |
|
50 //typedef ?declaration |
|
51 |
|
52 // LOCAL FUNCTION PROTOTYPES |
|
53 //?type ?function_name( ?arg_type, ?arg_type ); |
|
54 |
|
55 // FORWARD DECLARATIONS |
|
56 //class ?FORWARD_CLASSNAME; |
|
57 |
|
58 |
|
59 // ============================ MEMBER FUNCTIONS =============================== |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CSvgMediaElementBase::CSvgMediaElementBase |
|
64 // C++ default constructor can NOT contain any code, that |
|
65 // might leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CSvgMediaElementBase::CSvgMediaElementBase( CSvgDocumentImpl* aDoc ): |
|
69 CSvgAnimationBase( aDoc ), |
|
70 iSyncMasterConfig( EFalse ), |
|
71 iSyncMasterCurrent( EFalse ), |
|
72 iSyncOffset( 0 ) |
|
73 { |
|
74 // Obtain the default sync behaviour/tolerance from the root element |
|
75 CSvgSvgElementImpl* lSvgEle = (CSvgSvgElementImpl* )aDoc->RootElement(); |
|
76 if ( lSvgEle ) |
|
77 { |
|
78 iSyncBehavior = lSvgEle->SyncBehaviorDefault(); |
|
79 iSyncTolerance = lSvgEle->SyncToleranceDefault(); |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSvgMediaElementBase::ConstructL |
|
85 // Symbian 2nd phase constructor can leave. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CSvgMediaElementBase::ConstructL( const TUint8 aElemID ) |
|
89 { |
|
90 CSvgAnimationBase::ConstructL( aElemID ); |
|
91 // Add this element to the time container to recieve runtime sync events |
|
92 ((CSvgDocumentImpl* )iOwnerDocument)->TimeContainer()->AddTimedEntityL( this ); |
|
93 } |
|
94 |
|
95 // Destructor |
|
96 CSvgMediaElementBase::~CSvgMediaElementBase() |
|
97 { |
|
98 // Remove this element from the time container |
|
99 ((CSvgDocumentImpl* )iOwnerDocument)->TimeContainer()->DelTimedEntity( this ); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSvgMediaElementBase::SetSyncBehavior |
|
104 // Set the Synchronised behaviour for the media element |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSvgMediaElementBase::SetSyncBehavior( const TDesC& aValue ) |
|
108 { |
|
109 |
|
110 if ( !aValue.CompareF( KTmpCanSlip ) ) |
|
111 { |
|
112 iSyncBehavior = ESvgSyncCanSlip; |
|
113 } |
|
114 else if ( !aValue.CompareF( KTmpLocked ) ) |
|
115 { |
|
116 iSyncBehavior = ESvgSyncLocked; |
|
117 } |
|
118 else if ( !aValue.CompareF( KTmpIndependent ) ) |
|
119 { |
|
120 iSyncBehavior = ESvgSyncIndependent; |
|
121 } |
|
122 else if ( !aValue.CompareF( KTmpDefault ) ) |
|
123 { |
|
124 // Obtain the sync behaviour from the root of time container |
|
125 CSvgDocumentImpl* lSvgDoc = (( CSvgDocumentImpl* ) |
|
126 iOwnerDocument); |
|
127 CSvgSvgElementImpl* lSvgEle = (CSvgSvgElementImpl* )lSvgDoc->RootElement(); |
|
128 if ( lSvgEle ) |
|
129 { |
|
130 iSyncBehavior = lSvgEle->SyncBehaviorDefault(); |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CSvgMediaElementBase::SetSyncTolerance |
|
137 // Set the Synchronised Tolerance for the media element |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CSvgMediaElementBase::SetSyncTolerance( const TDesC& aValue ) |
|
141 { |
|
142 if ( aValue.CompareF( KTmpDefault ) ) |
|
143 { |
|
144 CSvgAnimTimingParser* lATParserPtr = NULL; |
|
145 // Treat as clock value |
|
146 TRAPD( lCreateATPErr, |
|
147 { |
|
148 lATParserPtr = CSvgAnimTimingParser::NewL( aValue, this ); |
|
149 } ); |
|
150 |
|
151 if ( lCreateATPErr != KErrNone ) |
|
152 { |
|
153 // Error Processing |
|
154 return; |
|
155 } |
|
156 |
|
157 TInt32 lClockValue; |
|
158 TLex lLex( aValue ); |
|
159 lATParserPtr->ParseClockValue( lLex, lClockValue ); |
|
160 delete lATParserPtr; |
|
161 iSyncTolerance = lClockValue; |
|
162 } |
|
163 else |
|
164 { |
|
165 // Get clock value from parent |
|
166 CSvgDocumentImpl* lSvgDoc = (( CSvgDocumentImpl* ) |
|
167 iOwnerDocument); |
|
168 CSvgSvgElementImpl* lSvgEle = (CSvgSvgElementImpl* )lSvgDoc->RootElement(); |
|
169 if ( lSvgEle ) |
|
170 { |
|
171 iSyncTolerance = lSvgEle->SyncToleranceDefault(); |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CSvgMediaElementBase::SetSyncMaster |
|
178 // Set the media element as Synchronised Master |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CSvgMediaElementBase::SetSyncMaster( const TDesC& aValue ) |
|
182 { |
|
183 if ( !aValue.CompareF(_L("true")) ) |
|
184 { |
|
185 iSyncMasterConfig = ETrue; |
|
186 } |
|
187 else |
|
188 { |
|
189 iSyncMasterConfig = EFalse; |
|
190 } |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CSvgMediaElementBase::SetSyncBehavior |
|
195 // Set the Synchronised behaviour for the media element |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CSvgMediaElementBase::SetSyncBehavior( |
|
199 const TSvgSyncBehaviour aValue ) |
|
200 { |
|
201 if ( aValue == ESvgSyncDefault ) |
|
202 { |
|
203 // Obtain the sync behaviour from the root of time container |
|
204 CSvgDocumentImpl* lSvgDoc = (( CSvgDocumentImpl* ) |
|
205 iOwnerDocument); |
|
206 CSvgSvgElementImpl* lSvgEle = (CSvgSvgElementImpl* )lSvgDoc->RootElement(); |
|
207 if ( lSvgEle ) |
|
208 { |
|
209 iSyncBehavior = lSvgEle->SyncBehaviorDefault(); |
|
210 } |
|
211 } |
|
212 else |
|
213 { |
|
214 iSyncBehavior = aValue; |
|
215 } |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CSvgMediaElementBase::SetSyncTolerance |
|
220 // Set the Synchronised Tolerance for the media element |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CSvgMediaElementBase::SetSyncTolerance( const TInt32 aValue , |
|
224 const TBool aUseDefault ) |
|
225 { |
|
226 if ( aUseDefault ) |
|
227 { |
|
228 // Get clock value from parent |
|
229 CSvgDocumentImpl* lSvgDoc = (( CSvgDocumentImpl* ) |
|
230 iOwnerDocument); |
|
231 CSvgSvgElementImpl* lSvgEle = (CSvgSvgElementImpl* )lSvgDoc->RootElement(); |
|
232 if ( lSvgEle ) |
|
233 { |
|
234 iSyncTolerance = lSvgEle->SyncToleranceDefault(); |
|
235 } |
|
236 } |
|
237 else |
|
238 { |
|
239 iSyncTolerance = aValue; |
|
240 } |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CSvgMediaElementBase::SetSyncMaster |
|
245 // Set the media element as Synchronised Master |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CSvgMediaElementBase::SetSyncMaster( const TBool aValue ) |
|
249 { |
|
250 iSyncMasterConfig = aValue; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CSvgMediaElementBase::SyncBehavior |
|
255 // Accessor for the Synchronised behaviour for the media element |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 TSvgSyncBehaviour CSvgMediaElementBase::SyncBehavior() |
|
259 { |
|
260 return iSyncBehavior; |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CSvgMediaElementBase::SyncTolerance |
|
265 // Accessor for the Synchronised Tolerance for the media element |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 TInt32 CSvgMediaElementBase::SyncTolerance() |
|
269 { |
|
270 return iSyncTolerance; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CSvgMediaElementBase::SyncMaster |
|
275 // Accessor for the Synchronised Mastership for the media element |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 TBool CSvgMediaElementBase::SyncMaster() |
|
279 { |
|
280 return iSyncMasterConfig; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // SetAttributeL: Called by Contenthandler or decoder to set attributes |
|
285 // From CSvgAnimationBase |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CSvgMediaElementBase::SetAttributeL( const TDesC& aName, |
|
289 const TDesC& aValue ) |
|
290 { |
|
291 |
|
292 if ( !aName.CompareF( KTmpSyncBehavior ) ) |
|
293 { |
|
294 SetSyncBehavior( aValue ); |
|
295 } |
|
296 else if ( !aName.CompareF( KTmpSyncTolerance ) ) |
|
297 { |
|
298 SetSyncTolerance( aValue ); |
|
299 } |
|
300 else if ( !aName.CompareF( KTmpSyncMaster ) ) |
|
301 { |
|
302 SetSyncMaster( aValue ); |
|
303 } |
|
304 else |
|
305 { |
|
306 return CSvgAnimationBase::SetAttributeL( aName, aValue ); |
|
307 } |
|
308 |
|
309 return KErrNone; |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CSvgMediaElementBase::ParentTimeContainerTick |
|
314 // From MSvgTimedEntityInterface |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CSvgMediaElementBase::ParentTimeContainerTick( |
|
318 TSvgTick aTick ) // Current tick information |
|
319 { |
|
320 // Check if the element is currently acting as syncMaster for the locked |
|
321 // group it is part of. |
|
322 // Note element having syncMaster property set doesn't make it master. It |
|
323 // needs to be resolved. |
|
324 TBool lIsCurSyncMaster = EFalse; |
|
325 |
|
326 GetCurSyncMasterStatus( lIsCurSyncMaster ); |
|
327 |
|
328 if ( lIsCurSyncMaster || iSyncBehavior != ESvgSyncLocked ) |
|
329 { |
|
330 // Could be locked, or not locked. In both cases, use media |
|
331 // element clock. |
|
332 if ( CanGenerateTick() ) |
|
333 { |
|
334 //No action. |
|
335 } |
|
336 else |
|
337 { |
|
338 // Use the Real Time Tick. |
|
339 // Create a timer event with real time tick |
|
340 // Send this event to engine |
|
341 } |
|
342 } |
|
343 |
|
344 if( !lIsCurSyncMaster && iSyncBehavior == ESvgSyncLocked) |
|
345 { |
|
346 // The element needs to be in sync with Parent. |
|
347 if ( CanUseParentTick() ) |
|
348 { |
|
349 // Run the media element with parent's tick. |
|
350 // Create a timer event with parent's tick |
|
351 // Send this event to engine |
|
352 // Only required at Document Level. |
|
353 } |
|
354 else |
|
355 { |
|
356 // Calculate SyncOffset value |
|
357 // Get the current tick on the element |
|
358 TUint32 lEntityTime; |
|
359 GetEntityCurrentTime( lEntityTime ); |
|
360 // Calculate the drift |
|
361 TInt32 iSyncOffset = aTick.iParentTcTick - lEntityTime; |
|
362 |
|
363 // Media element running with its own clock, need |
|
364 // to resynchronize if the element is out of sync |
|
365 // wrt to parent clock. |
|
366 if ( Abs( iSyncOffset ) > iSyncTolerance ) |
|
367 { |
|
368 // Resynchronize the Media Element wrt to |
|
369 // Parent Clock. |
|
370 ResyncTimedEntity( aTick.iParentTcTick ); |
|
371 } |
|
372 } |
|
373 } |
|
374 |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CSvgMediaElementBase::GetEntitySyncBehavior |
|
379 // From MSvgTimedEntityInterface |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 TSvgSyncBehaviour CSvgMediaElementBase::GetEntitySyncBehavior() |
|
383 { |
|
384 return iSyncBehavior; |
|
385 } |
|
386 |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CSvgMediaElementBase::GetEntityCurrentTime |
|
390 // From MSvgTimedEntityInterface |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 void CSvgMediaElementBase::GetEntityCurrentTime( TUint32& |
|
394 /* aEntityCurTime*/ ) // Current Entity Time in msecs. |
|
395 { |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CSvgMediaElementBase::GetCnfSyncMasterStatus |
|
400 // From MSvgTimedEntityInterface |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 void CSvgMediaElementBase::GetCnfSyncMasterStatus( |
|
404 TBool& aIsSyncMaster ) // Indicates whether the element is configured as |
|
405 // Sync Master. |
|
406 { |
|
407 aIsSyncMaster = iSyncMasterConfig; |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CSvgMediaElementBase::GetCurSyncMasterStatus |
|
412 // From MSvgTimedEntityInterface |
|
413 // ----------------------------------------------------------------------------- |
|
414 void CSvgMediaElementBase::GetCurSyncMasterStatus( |
|
415 TBool& aIsSyncMaster ) // Indicates whether the element is currrently |
|
416 // Sync Master. |
|
417 { |
|
418 aIsSyncMaster = iSyncMasterCurrent; |
|
419 } |
|
420 |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CSvgMediaElementBase::SetCurSyncMasterStatus |
|
424 // From MSvgTimedEntityInterface |
|
425 // ----------------------------------------------------------------------------- |
|
426 void CSvgMediaElementBase::SetCurSyncMasterStatus( |
|
427 TBool aSyncMasterStatus ) // Indicates whether the element is currrently |
|
428 // Sync Master. |
|
429 { |
|
430 iSyncMasterCurrent = aSyncMasterStatus; |
|
431 } |
|
432 |
|
433 // ----------------------------------------------------------------------------- |
|
434 // CSvgMediaElementBase::CanGenerateTick |
|
435 // From MSvgTimedEntityInterface |
|
436 // ----------------------------------------------------------------------------- |
|
437 TBool CSvgMediaElementBase::CanGenerateTick() |
|
438 { |
|
439 return EFalse; |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CSvgMediaElementBase::CanUseParentTick |
|
444 // From MSvgTimedEntityInterface |
|
445 // ----------------------------------------------------------------------------- |
|
446 TBool CSvgMediaElementBase::CanUseParentTick() |
|
447 { |
|
448 return EFalse; |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CSvgMediaElementBase::ResyncTimedEntity |
|
453 // From MSvgTimedEntityInterface |
|
454 // ----------------------------------------------------------------------------- |
|
455 void CSvgMediaElementBase::ResyncTimedEntity( |
|
456 TUint32 /* aSynctime */ ) // Time for resync in msecs. |
|
457 { |
|
458 |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CSvgMediaElementBase::PauseTimedEntity |
|
463 // From MSvgTimedEntityInterface |
|
464 // ----------------------------------------------------------------------------- |
|
465 void CSvgMediaElementBase::PauseTimedEntity() |
|
466 { |
|
467 |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CSvgMediaElementBase::ResumeTimedEntity |
|
472 // From MSvgTimedEntityInterface |
|
473 // ----------------------------------------------------------------------------- |
|
474 void CSvgMediaElementBase::ResumeTimedEntity() |
|
475 { |
|
476 |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CSvgMediaElementBase::StopTimedEntity |
|
481 // From MSvgTimedEntityInterface |
|
482 // ----------------------------------------------------------------------------- |
|
483 void CSvgMediaElementBase::StopTimedEntity() |
|
484 { |
|
485 |
|
486 } |
|
487 |
|
488 |
|
489 //From MSvgTimedEntityInterface |
|
490 TSvgObjectType CSvgMediaElementBase::ObjectType() |
|
491 { |
|
492 return ESvgInvalidReference ; |
|
493 } |
|
494 |
|
495 |
|
496 //returns the child time container of the element |
|
497 //used in timecontainer |
|
498 CSvgTimeContainer* CSvgMediaElementBase::GetChildTimeContainer() |
|
499 { |
|
500 return NULL; |
|
501 } |
|
502 |
|
503 // End of File |