svgtopt/SVG/SVGImpl/src/SVGTimeContainer.cpp
changeset 0 d46562c3d99d
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     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 implementation of a time container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "SVGTimeContainer.h"
       
    22 #include "SVGTimer.h"
       
    23 #include "SVGEvent.h"
       
    24 #include "SVGDocumentImpl.h"
       
    25 
       
    26 #include "SVGLockedRealTimeEntity.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 //extern  ?external_data;
       
    30 
       
    31 // EXTERNAL FUNCTION PROTOTYPES  
       
    32 //extern ?external_function( ?arg_type,?arg_type );
       
    33 
       
    34 // CONSTANTS
       
    35 //const ?type ?constant_var = ?constant;
       
    36 
       
    37 // MACROS
       
    38 //#define ?macro ?macro_def
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 //const ?type ?constant_var = ?constant;
       
    42 //#define ?macro_name ?macro_def
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 //enum ?declaration
       
    46 //typedef ?declaration
       
    47 
       
    48 // LOCAL FUNCTION PROTOTYPES
       
    49 //?type ?function_name( ?arg_type, ?arg_type );
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 //class ?FORWARD_CLASSNAME;
       
    53 
       
    54 // ============================ MEMBER FUNCTIONS ===============================
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSvgTimeContainer::CSvgTimeContainer
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CSvgTimeContainer::CSvgTimeContainer( CSvgDocumentImpl* aOwnerDoc,
       
    63     const TBool aHasParent,
       
    64     const TSvgSyncBehaviour aSyncBehavior,
       
    65     const TBool aIsSyncMaster,
       
    66     const TUint32 aSyncTolerance ) : 
       
    67           iTcSyncBehavior( aSyncBehavior ),
       
    68           iTcSyncTolerance( aSyncTolerance ),
       
    69           iTcSyncMasterConfig( aIsSyncMaster ),
       
    70           iIsParentTcPresent( aHasParent ),
       
    71           iOwnerDoc( aOwnerDoc ),
       
    72           iMediaState( ESvgMediaReady ),
       
    73           iUserState(ESvgUserRunning),
       
    74           iIsSyncPaused(EFalse)
       
    75     {
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSvgTimeContainer::ConstructL
       
    80 // Symbian 2nd phase constructor can leave.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CSvgTimeContainer::ConstructL()
       
    84     {
       
    85     //Add locked real time entity(LRTE) here
       
    86     iLrte = CSvgLockedRealTimeEntity::NewL(iOwnerDoc);
       
    87     // Populate the entity list item corresponding to LRTE
       
    88     iLrteListItem.iTimedEntity = iLrte;
       
    89     iLrteListItem.iMediaState = ESvgMediaIdle;
       
    90     iLrteListItem.iUserState =ESvgUserRunning ;
       
    91     iLrteListItem.iIsSyncPaused = EFalse;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CSvgTimeContainer::NewL
       
    96 // Two-phased constructor.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CSvgTimeContainer* CSvgTimeContainer::NewL( CSvgDocumentImpl* aOwnerDoc,
       
   100     const TBool aHasParent, 
       
   101     const TSvgSyncBehaviour aSyncBehavior,
       
   102     const TBool aIsSyncMaster,
       
   103     const TUint32 aSyncTolerance )
       
   104     {
       
   105     CSvgTimeContainer* self = new( ELeave ) CSvgTimeContainer( aOwnerDoc,
       
   106         aHasParent, aSyncBehavior, aIsSyncMaster, aSyncTolerance );
       
   107     
       
   108     CleanupStack::PushL( self );
       
   109     self->ConstructL();
       
   110     CleanupStack::Pop();
       
   111 
       
   112     return self;
       
   113     }
       
   114 
       
   115     
       
   116 // Destructor
       
   117 CSvgTimeContainer::~CSvgTimeContainer()
       
   118     {
       
   119     // Reset the observer
       
   120     iObserver = NULL;
       
   121     // Delete the locked realtime timed entity 
       
   122     delete iLrte;
       
   123     // Cleanup the list of timed entities
       
   124     CleanupTimedEntities();
       
   125     
       
   126     // Delete the timer if present
       
   127     if ( iTimer )
       
   128         {
       
   129         delete iTimer;
       
   130         iTimer = NULL;
       
   131         }
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CSvgTimeContainer::GetSyncMasterForTimeContainer
       
   136 // Resolves the sync master within the time container and returns the same.
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 MSvgTimedEntityInterface* CSvgTimeContainer::GetSyncMasterForTimeContainer()
       
   140     {
       
   141     // First check the number of elements in the time container
       
   142   TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   143 
       
   144     // if there is only one element in the list(which is the document),
       
   145     // return NULL to avoid list traversal
       
   146     if ( lTimedEntityListCnt <= 1 )
       
   147         {
       
   148         return NULL;
       
   149         }
       
   150         
       
   151     TInt lFirstAudioIndex = iTcTimedEntities.Count();    // Store invalid value
       
   152     MSvgTimedEntityInterface* lCurSyncMaster = NULL;    
       
   153 
       
   154   // Within the locked group of timed entities within the time 
       
   155   // container, need to find out which element is acting as master. 
       
   156 
       
   157   // For All Timed Entities
       
   158   // Get the first eligible sync master
       
   159   for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   160       {
       
   161     //get each element
       
   162     MSvgTimedEntityInterface* lCurTimedEntity = 
       
   163         (iTcTimedEntities[ lItemIndex ]).iTimedEntity ;
       
   164     
       
   165     // In case an audio element is found
       
   166     //      check whether is is locked and can generate tick
       
   167     //      If so, it is an eligible sync master
       
   168     if( lFirstAudioIndex == lTimedEntityListCnt && 
       
   169         lCurTimedEntity->ObjectType() == ESvgAudioElement && 
       
   170         lCurTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked &&
       
   171         lCurTimedEntity->CanGenerateTick() )
       
   172         {
       
   173         // Remember this so it can be used later if 
       
   174         // no eligible syncmaster found
       
   175         lFirstAudioIndex = lItemIndex;
       
   176         }
       
   177 
       
   178       TBool lIsSyncMaster = EFalse;
       
   179       lCurTimedEntity->GetCnfSyncMasterStatus( lIsSyncMaster );
       
   180       // An element is an eligible sync master if:
       
   181       //      a. It is locked wrt the TC
       
   182       //      b. It is configured as a sync master
       
   183       //      c. It can generate tick i.e. it is active and has implicit duration.
       
   184         if ( lCurTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked 
       
   185             && lIsSyncMaster 
       
   186             && lCurTimedEntity->CanGenerateTick() )
       
   187             {
       
   188             lCurSyncMaster = lCurTimedEntity;
       
   189             break;
       
   190             }
       
   191     }
       
   192     
       
   193 
       
   194     if ( !lCurSyncMaster ) 
       
   195     {
       
   196       if( lFirstAudioIndex != lTimedEntityListCnt ) 
       
   197         {
       
   198         // Did not find a sync master, and audio element available
       
   199         lCurSyncMaster = iTcTimedEntities[ lFirstAudioIndex ].iTimedEntity;
       
   200         }   
       
   201         //Locked real time entityas syncmaster
       
   202       else
       
   203         {
       
   204             lCurSyncMaster = iLrteListItem.iTimedEntity;
       
   205         }  
       
   206         
       
   207     } 
       
   208       
       
   209     if ( lCurSyncMaster )
       
   210         {
       
   211         // Sync Master found
       
   212         // Store the syncMaster in iTcSyncMaster.
       
   213         iTcSyncMaster = lCurSyncMaster;
       
   214 
       
   215         // Set the state in the sync master that it is the chosen one.
       
   216         iTcSyncMaster->SetCurSyncMasterStatus( ETrue );
       
   217 
       
   218         // For All Timed Entities other than syncMaster in TC group
       
   219         //          SetCurSyncMasterStatus = False;
       
   220         for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   221             {
       
   222             MSvgTimedEntityInterface* lCurTimedEntity = 
       
   223                 (iTcTimedEntities[ lItemIndex ]).iTimedEntity ;
       
   224             if ( lCurTimedEntity != iTcSyncMaster )
       
   225                 {
       
   226                 lCurTimedEntity->SetCurSyncMasterStatus( EFalse );            
       
   227                 }
       
   228             }
       
   229             
       
   230             if(iLrteListItem.iTimedEntity != lCurSyncMaster)
       
   231             {
       
   232                 iLrteListItem.iTimedEntity->SetCurSyncMasterStatus(EFalse);
       
   233             }    
       
   234         }
       
   235     
       
   236 
       
   237     return iTcSyncMaster;
       
   238     }
       
   239         
       
   240 // -----------------------------------------------------------------------------
       
   241 // CSvgTimeContainer::AddTimedEntityL
       
   242 // Add a timed entity to the time container.
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 void CSvgTimeContainer::AddTimedEntityL( 
       
   246     MSvgTimedEntityInterface* aTimedEntity )
       
   247     {
       
   248     if ( !aTimedEntity )
       
   249         {
       
   250         User::Leave( KErrArgument );
       
   251         }
       
   252     
       
   253     // check to see if entity is already in list and simply return
       
   254     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   255     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   256         {
       
   257         if ( (iTcTimedEntities[ lItemIndex ]).iTimedEntity == aTimedEntity )
       
   258             {
       
   259             return;
       
   260             }
       
   261         }
       
   262    
       
   263     TSvgTimedEntityListItem lListItem;
       
   264     lListItem.iTimedEntity = aTimedEntity;
       
   265 
       
   266     //Media State initially Idle
       
   267     lListItem.iMediaState = ESvgMediaIdle;
       
   268     
       
   269     //User state initially is running
       
   270     lListItem.iUserState =ESvgUserRunning ;
       
   271     
       
   272     // Sync State is Playing
       
   273     lListItem.iIsSyncPaused = EFalse;
       
   274 
       
   275     // Append to Timed Entity List
       
   276     iTcTimedEntities.AppendL( lListItem );
       
   277     
       
   278     // Obtain the post order list of media elements 
       
   279      RPointerArray<CSvgElementImpl> lMediaEleList;
       
   280     lMediaEleList.Reset(); 
       
   281     
       
   282     CSvgElementImpl *handle = (CSvgElementImpl *)(iOwnerDoc->RootElement());
       
   283     iOwnerDoc->ParsePostOrderMediaElements( handle, lMediaEleList );
       
   284     
       
   285     // Rearrange as per Post order
       
   286     RearrangeTimedEntityList( lMediaEleList );
       
   287     
       
   288     // Done with the list
       
   289     lMediaEleList.Close();  
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CSvgTimeContainer::DelTimedEntity
       
   294 // Removes the timed entity from the time container.
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 void CSvgTimeContainer::DelTimedEntity( 
       
   298     MSvgTimedEntityInterface* aTimedEntity )
       
   299     {
       
   300     // check whether the entity exists and then remove it from the list
       
   301     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   302     
       
   303     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   304         {
       
   305         if ( (iTcTimedEntities[ lItemIndex ]).iTimedEntity == aTimedEntity )
       
   306             {
       
   307             iTcTimedEntities.Remove( lItemIndex );
       
   308       break;
       
   309             }
       
   310         }
       
   311     
       
   312     }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // CSvgTimeContainer::CleanupTimedEntities
       
   316 // Removes all the timed entities from the time container.
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 void CSvgTimeContainer::CleanupTimedEntities( )
       
   320     {
       
   321     // Delete the entries in the timed entity list; does not delete the 
       
   322     // timed entities.
       
   323     iTcTimedEntities.Reset();
       
   324     }
       
   325 
       
   326 // ---------------------------------------------------------------------------
       
   327 // CSvgTimeContainer::SetCurrentTime
       
   328 // Set Function for the TC's current time
       
   329 // ---------------------------------------------------------------------------
       
   330 void CSvgTimeContainer::SetCurrentTime( TInt32 aCurTime )
       
   331     {
       
   332     iCurrentTime = aCurTime;
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // CSvgTimeContainer::CurrentTime
       
   337 // Accessor for the TC's current time
       
   338 // ---------------------------------------------------------------------------
       
   339 TInt32 CSvgTimeContainer::CurrentTime()
       
   340     {
       
   341     return iCurrentTime;
       
   342     }
       
   343 
       
   344 // ---------------------------------------------------------------------------
       
   345 // CSvgTimeContainer::SetSyncBehavior
       
   346 // Set the Synchronised behaviour for the time container
       
   347 // ---------------------------------------------------------------------------
       
   348 void CSvgTimeContainer::SetSyncBehavior( const TSvgSyncBehaviour aValue )
       
   349     {
       
   350     iTcSyncBehavior = aValue;
       
   351     }
       
   352 
       
   353 // ---------------------------------------------------------------------------
       
   354 // CSvgTimeContainer::SetSyncTolerance
       
   355 // Set the Synchronised Tolerance for the time container
       
   356 // ---------------------------------------------------------------------------
       
   357 void CSvgTimeContainer::SetSyncTolerance( const TUint32 aValue )
       
   358     {
       
   359     iTcSyncTolerance = aValue;    
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------------------------
       
   363 // CSvgTimeContainer::SetSyncMaster
       
   364 // Set the time container as Synchronised Master
       
   365 // ---------------------------------------------------------------------------
       
   366 void CSvgTimeContainer::SetSyncMaster( const TBool aValue )
       
   367     {
       
   368     iTcSyncMasterConfig = aValue;
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // CSvgTimeContainer::GetCurTick
       
   373 // Accessor function to get the current tick
       
   374 // ---------------------------------------------------------------------------
       
   375 TSvgTick CSvgTimeContainer::GetCurTick()
       
   376     {
       
   377     return iCurrentTick;
       
   378     }
       
   379 
       
   380 // ---------------------------------------------------------------------------
       
   381 // CSvgTimeContainer::Document
       
   382 // Accessor function to get the owner doc of the TC
       
   383 // ---------------------------------------------------------------------------
       
   384 CSvgDocumentImpl* CSvgTimeContainer::Document()
       
   385     {
       
   386     return iOwnerDoc;
       
   387     }
       
   388 
       
   389 
       
   390 // ---------------------------------------------------------------------------
       
   391 // CSvgTimeContainer::TimedEntityNotReady
       
   392 // Informing the time container that timed entity is not ready
       
   393   /*
       
   394     If this element is locked
       
   395     {
       
   396       PauseLockedElements
       
   397         {
       
   398           (Whether ready/not ready)
       
   399                  For all locked elements:
       
   400           SyncPauseElement.
       
   401         }
       
   402         If TC Observer present
       
   403           Give Not Ready Event 
       
   404     }
       
   405 
       
   406     */
       
   407  // ---------------------------------------------------------------------------
       
   408 void CSvgTimeContainer::TimedEntityNotReady( 
       
   409     MSvgTimedEntityInterface* aTimedEntity )
       
   410     {
       
   411     
       
   412     
       
   413     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   414     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   415         {
       
   416       //get current element
       
   417         if ( (iTcTimedEntities[ lItemIndex ]).iTimedEntity == aTimedEntity )
       
   418             {
       
   419           //set current element as not ready
       
   420           (iTcTimedEntities[ lItemIndex ]).iMediaState = ESvgMediaNotReady;
       
   421           
       
   422           //if current element is locked
       
   423           if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked )
       
   424               {
       
   425               //Indicate the timecontainer is not ready
       
   426             SetMediaState(ESvgMediaNotReady);
       
   427             
       
   428             PauseLockedEntities();
       
   429             
       
   430             // Inform the observer that the time container is not ready
       
   431           if ( iObserver )
       
   432                 {
       
   433                     iObserver->TimeContainerNotReady();
       
   434                 }
       
   435               }
       
   436           //Once we have got the right timed entity on which not ready was called
       
   437       //exit the loop
       
   438       break;
       
   439             }
       
   440         }
       
   441     }
       
   442 
       
   443 // -----------------------------------------------------------------------------
       
   444 // CSvgTimeContainer::SyncpauseElement
       
   445 //Pauses running syncronised elements
       
   446   /*
       
   447       Pauses a single element
       
   448     
       
   449     If ( syncStatus is not paused AND ( userStatus is not paused or not stopped ) )
       
   450       Pause Element
       
   451       Set syncStatus = Paused // iIsSyncPaused 
       
   452       
       
   453       
       
   454       If Element type = Animation
       
   455           {
       
   456               Get Child TC Pointer.
       
   457               If Valid,
       
   458                 Call Child Tc->SyncPause
       
   459           }
       
   460 
       
   461   
       
   462   */
       
   463   // -----------------------------------------------------------------------------
       
   464 //
       
   465 
       
   466 
       
   467 void CSvgTimeContainer::SyncPauseElement(TSvgTimedEntityListItem* aTimedEntityItem)
       
   468     {
       
   469       if (
       
   470          (!aTimedEntityItem->iIsSyncPaused)  
       
   471       && (aTimedEntityItem->iUserState == ESvgUserRunning)
       
   472          )
       
   473         {
       
   474         aTimedEntityItem->iTimedEntity->PauseTimedEntity();
       
   475         }
       
   476       aTimedEntityItem->iIsSyncPaused = ETrue;
       
   477       
       
   478       if(aTimedEntityItem->iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
   479         {
       
   480         CSvgTimeContainer* lAnimTimeContainer = aTimedEntityItem->iTimedEntity->GetChildTimeContainer();
       
   481         if(lAnimTimeContainer)
       
   482             {
       
   483             lAnimTimeContainer->SyncPause();
       
   484             }
       
   485         }
       
   486     }
       
   487     
       
   488 
       
   489 // ---------------------------------------------------------------------------
       
   490 // CSvgTimeContainer::TimedEntityReady
       
   491 // Informing the time container that timed entity is ready
       
   492     /*
       
   493     If this element is locked
       
   494     {
       
   495      If all locked elements ready
       
   496     {
       
   497       ResumeLockedElements
       
   498        {
       
   499             For all locked elements:
       
   500                  SyncResumeElement.
       
   501 
       
   502         }
       
   503       If TC Observer present
       
   504         Give ready of TC
       
   505     }
       
   506      }
       
   507     */
       
   508 // ---------------------------------------------------------------------------
       
   509 void CSvgTimeContainer::TimedEntityReady( 
       
   510     MSvgTimedEntityInterface* aTimedEntity )
       
   511     {
       
   512 
       
   513     TBool lIsOkToResume = ETrue;
       
   514 
       
   515     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   516   for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   517       {
       
   518     //get current element from entities list
       
   519       if ( (iTcTimedEntities[ lItemIndex ]).iTimedEntity == aTimedEntity )
       
   520         {
       
   521         //set current element as not ready
       
   522         (iTcTimedEntities[ lItemIndex ]).iMediaState = ESvgMediaReady;
       
   523           
       
   524         //if current element is locked
       
   525         if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked )
       
   526             {
       
   527         //for all timed entities
       
   528             for ( lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   529               {
       
   530               // check if any timed entities are locked and not ready
       
   531               // Idle elements cannot be checked as they are not active
       
   532               if(
       
   533               ( (iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked )
       
   534               && ((iTcTimedEntities[lItemIndex].iMediaState == ESvgMediaNotReady))
       
   535               )
       
   536                 {
       
   537                 //Indicate cant resume now as some locked entities are not ready
       
   538                 lIsOkToResume = EFalse;
       
   539                 //exit loop
       
   540                 break;
       
   541                 }
       
   542               }
       
   543             }
       
   544             //Once we have got the right timed entity on which ready was called
       
   545             //exit the loop
       
   546             break;
       
   547           }
       
   548       }
       
   549     
       
   550       if ( lIsOkToResume )
       
   551         {
       
   552         //Indicate the timecontainer is ready as all elements are ready
       
   553       SetMediaState(ESvgMediaReady);
       
   554       
       
   555       ResumeLockedEntities();
       
   556 
       
   557       // Inform the observer that the time container is ready
       
   558          if ( iObserver )
       
   559           {
       
   560           iObserver->TimeContainerReady();
       
   561           }
       
   562         }
       
   563     }
       
   564     
       
   565 //-------------------------------------------------------------------------------
       
   566 //void CSvgTimeContainer::SyncResumeElement
       
   567   /*
       
   568     Resumes a single element
       
   569   
       
   570   if ( syncStatus is not running AND (userStatus is running))
       
   571   AND (TC.syncStatus is running) AND (TC.userStatus is running))
       
   572     {
       
   573 
       
   574     Resume Element
       
   575   }
       
   576     Set syncStatus = running 
       
   577     If Element type = Animation
       
   578   {
       
   579           Get Child TC Pointer.
       
   580           If Valid,
       
   581     Call Child Tc->SyncResume
       
   582   }
       
   583 
       
   584 	*/
       
   585 //-------------------------------------------------------------------------------
       
   586 void CSvgTimeContainer::SyncResumeElement(TSvgTimedEntityListItem* aTimedEntity)
       
   587     {
       
   588     if(
       
   589      (aTimedEntity->iIsSyncPaused) 
       
   590     && (aTimedEntity->iUserState == ESvgUserRunning)
       
   591     && (!iIsSyncPaused)
       
   592     && (iUserState == ESvgUserRunning )
       
   593     )
       
   594         {
       
   595         aTimedEntity->iTimedEntity->ResumeTimedEntity();
       
   596         }
       
   597     aTimedEntity->iIsSyncPaused = EFalse;
       
   598       
       
   599     if(aTimedEntity->iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
   600         {
       
   601         CSvgTimeContainer* AnimTimeContainer = aTimedEntity->iTimedEntity->GetChildTimeContainer();
       
   602         if(AnimTimeContainer)
       
   603             {
       
   604             AnimTimeContainer->SyncResume();
       
   605             }
       
   606         }
       
   607     }   
       
   608     
       
   609     
       
   610 // -----------------------------------------------------------------------------
       
   611 // CSvgTimeContainer::PauseLockedEntities
       
   612 // Pauses the time container's locked entities
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 void CSvgTimeContainer::PauseLockedEntities()    
       
   616     {
       
   617      /*
       
   618      (Whether ready/not ready)
       
   619             For all locked elements:
       
   620             SyncPauseElement.
       
   621      */
       
   622     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   623     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   624         {
       
   625         if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked ) 
       
   626             {
       
   627             SyncPauseElement(&iTcTimedEntities[ lItemIndex ]);
       
   628             }
       
   629         }
       
   630     SyncPauseElement(&iLrteListItem);
       
   631     }
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 // CSvgTimeContainer::ResumeLockedEntities
       
   635 // Resumes the time container's locked entities
       
   636 // -----------------------------------------------------------------------------
       
   637 //
       
   638 void CSvgTimeContainer::ResumeLockedEntities()    
       
   639     {
       
   640   /*
       
   641     For all locked elements:
       
   642                SyncResumeElement.
       
   643   */
       
   644     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   645     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   646         {
       
   647         if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked ) 
       
   648             {
       
   649             SyncResumeElement(&iTcTimedEntities[ lItemIndex ]);
       
   650             }
       
   651         }
       
   652     SyncResumeElement(&iLrteListItem) ;
       
   653      
       
   654           
       
   655     }      
       
   656 
       
   657 
       
   658     
       
   659 // -----------------------------------------------------------------------------
       
   660 // CSvgTimeContainer::SetTcObserver
       
   661 // Set the observer for the time container
       
   662 // -----------------------------------------------------------------------------
       
   663 //
       
   664 void CSvgTimeContainer::SetTcObserver( MSvgTimeContainerObserver* aTCObserver )
       
   665     {
       
   666     iObserver = aTCObserver;
       
   667   // Inform the observer that the time container is ready
       
   668      if ( iObserver )
       
   669         {
       
   670         if ( iMediaState == ESvgMediaReady)
       
   671             {
       
   672             iObserver->TimeContainerReady();
       
   673             }
       
   674         else
       
   675             {
       
   676             iObserver->TimeContainerNotReady();
       
   677             }
       
   678         }    
       
   679     }
       
   680 
       
   681 // -----------------------------------------------------------------------------
       
   682 // CSvgTimeContainer::UserStop
       
   683 // Called to handle user/client generated stop event
       
   684 /*
       
   685       UserStop()
       
   686       {
       
   687       
       
   688                   Set the TC.UserState too 
       
   689                   This.UserState = Paused.
       
   690 
       
   691         
       
   692         For all timed entities
       
   693     {
       
   694         UserStopElement()
       
   695       {
       
   696         StopElement()
       
   697         Set userStatus = Stopped
       
   698         If Element type = Animation       
       
   699                 {
       
   700                 Get Child TC Pointer.
       
   701                 If Valid,
       
   702               Call Child Tc->UserStop
       
   703             }
       
   704 
       
   705       }
       
   706         }
       
   707        }
       
   708     */
       
   709 // -----------------------------------------------------------------------------
       
   710 //
       
   711 void CSvgTimeContainer::UserStop()
       
   712     {
       
   713     SetUserState(ESvgUserStopped);
       
   714     // Cancel the timer
       
   715     if ( iTimer )
       
   716         {
       
   717         iTimer->SVGStop();
       
   718         }    
       
   719     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   720     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   721         {
       
   722         UserStopElement(&iTcTimedEntities[lItemIndex]);
       
   723         }
       
   724     UserStopElement(&iLrteListItem);
       
   725     
       
   726     }
       
   727 
       
   728 
       
   729 void CSvgTimeContainer::UserStopElement(TSvgTimedEntityListItem* aTimedEntity)
       
   730 {
       
   731   aTimedEntity->iTimedEntity->StopTimedEntity();
       
   732   
       
   733   aTimedEntity->iIsSyncPaused = EFalse;
       
   734   
       
   735   SetUserState(ESvgUserStopped);
       
   736   
       
   737   if(aTimedEntity->iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
   738     {
       
   739           CSvgTimeContainer* AnimTimeContainer = aTimedEntity->iTimedEntity->GetChildTimeContainer();
       
   740           if(AnimTimeContainer)
       
   741           {
       
   742               AnimTimeContainer->UserStop();
       
   743           }
       
   744     }
       
   745 }
       
   746 
       
   747 // -----------------------------------------------------------------------------
       
   748 // CSvgTimeContainer::UserResume
       
   749 // Called to handle user/client generated resume event
       
   750 // -----------------------------------------------------------------------------
       
   751 //
       
   752 void CSvgTimeContainer::UserResume( TInt32 aTime )
       
   753     {
       
   754         
       
   755     SetUserState(ESvgUserRunning);
       
   756     if ( iTimer )
       
   757         {
       
   758         iTimer->SVGResume( aTime );
       
   759         }
       
   760         
       
   761     
       
   762     
       
   763     /*
       
   764     UserResume()
       
   765     {
       
   766       For all timed entities
       
   767     {
       
   768       UserResumeElement()
       
   769          }
       
   770     }
       
   771   */
       
   772   
       
   773     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   774     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   775       {
       
   776       UserResumeElement(&iTcTimedEntities[ lItemIndex ]);
       
   777       }
       
   778       
       
   779       
       
   780     UserResumeElement(&iLrteListItem);
       
   781 
       
   782     }
       
   783 
       
   784 // -----------------------------------------------------------------------------
       
   785 // CSvgTimeContainer::UserResumeElement
       
   786 /*
       
   787 UserResumeElement()
       
   788        {
       
   789           If(Element is locked)
       
   790               {
       
   791                 If ( syncStatus is running AND TC.syncStatus is running)
       
   792                     Resume Element
       
   793               }
       
   794               Else
       
   795               {
       
   796                 ResumeElement()
       
   797               }
       
   798   
       
   799               Set userStatus = running
       
   800                 If Element type = Animation
       
   801             {
       
   802                 Get Child TC Pointer.
       
   803                 If Valid,
       
   804                   Call Child Tc->UserResume
       
   805             }
       
   806 
       
   807       }
       
   808 */
       
   809 // -----------------------------------------------------------------------------
       
   810 //
       
   811 
       
   812 void CSvgTimeContainer::UserResumeElement(TSvgTimedEntityListItem* aTimedEntity)
       
   813   {
       
   814   aTimedEntity->iUserState = ESvgUserRunning ;
       
   815       
       
   816   if(//Element is locked
       
   817     (aTimedEntity->iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked)
       
   818     &&((aTimedEntity->iIsSyncPaused) || (iIsSyncPaused))
       
   819      //element or timecontainer is syncpaused
       
   820   )
       
   821     {
       
   822     //Do not resume
       
   823     }
       
   824   else
       
   825     {
       
   826     aTimedEntity->iTimedEntity->ResumeTimedEntity();
       
   827     }
       
   828 
       
   829   
       
   830   if(aTimedEntity->iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
   831     {
       
   832     CSvgTimeContainer* AnimTimeContainer = aTimedEntity->iTimedEntity->GetChildTimeContainer();
       
   833     if(AnimTimeContainer)
       
   834         {
       
   835         AnimTimeContainer->UserResume();
       
   836         }
       
   837     }
       
   838   }
       
   839 
       
   840 // -----------------------------------------------------------------------------
       
   841 // CSvgTimeContainer::UserPlay
       
   842 // Called to handle user/client generated play event
       
   843 // -----------------------------------------------------------------------------
       
   844 //
       
   845 void CSvgTimeContainer::UserPlay()
       
   846     {
       
   847 
       
   848     
       
   849     if ( !iTimer )
       
   850         {
       
   851         // Check whether this time container has a parent
       
   852         // then we do not have to create the timer
       
   853         if ( !iIsParentTcPresent )
       
   854             {
       
   855             // Obtain the post order list of media elements 
       
   856              RPointerArray<CSvgElementImpl> lMediaEleList;
       
   857             lMediaEleList.Reset(); 
       
   858             
       
   859             CSvgElementImpl *handle = (CSvgElementImpl *)(iOwnerDoc->RootElement());
       
   860             
       
   861             //Parse postorderr only if there are media elements
       
   862             if(iTcTimedEntities.Count() > 1 )
       
   863             {
       
   864               iOwnerDoc->ParsePostOrderMediaElements( handle, lMediaEleList );    
       
   865             }
       
   866             
       
   867             
       
   868             // Rearrange as per Post order
       
   869             RearrangeTimedEntityList( lMediaEleList );
       
   870             
       
   871             // Done with the list
       
   872             lMediaEleList.Close();  
       
   873             
       
   874             TRAPD( lTimerCreateErr, iTimer = CSvgTimer::NewL( this ) );
       
   875             
       
   876             if ( lTimerCreateErr != KErrNone )
       
   877                 {
       
   878                 // Error Processing
       
   879                 return;
       
   880                 }
       
   881             
       
   882             iTimer->SetStartTime();
       
   883             
       
   884             // the current home time needs to be updated.
       
   885             if ( iOwnerDoc && iCurrentTime != 0 )
       
   886                 {
       
   887                 iCurrentTime = 0;
       
   888                 iCurrentTick.iParentTcTick = 0;
       
   889                 iCurrentTick.iRealTimeTick = 0;
       
   890                 TSvgTimerEvent timeEvent( iCurrentTime );
       
   891                 iOwnerDoc->Reset( &timeEvent );
       
   892                 }            
       
   893 
       
   894             if ( !iTimer->IsActive() )
       
   895                 {
       
   896                 iTimer->After( 1000 );
       
   897                 }           
       
   898             }
       
   899         }
       
   900     }
       
   901 
       
   902 // -----------------------------------------------------------------------------
       
   903 // CSvgTimeContainer::UserPause
       
   904 
       
   905  /*
       
   906  
       
   907                    Set the TC.UserState too 
       
   908                   This.UserState = Paused.
       
   909 
       
   910     UserPause()
       
   911     {
       
   912       For all timed entities
       
   913     {
       
   914          UserPauseElement()     iIsSyncPaused is syncStatus 
       
   915       
       
   916     }
       
   917     }
       
   918     */
       
   919 // -----------------------------------------------------------------------------
       
   920 //
       
   921 void CSvgTimeContainer::UserPause()
       
   922 {
       
   923   SetUserState(ESvgUserPaused);
       
   924   if ( iTimer )
       
   925     {
       
   926   	iTimer->SVGStop();
       
   927     }
       
   928  
       
   929   TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
   930   for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
   931     {
       
   932     UserPauseElement(&iTcTimedEntities[ lItemIndex ]);
       
   933     }
       
   934     
       
   935     UserPauseElement(&iLrteListItem);
       
   936 
       
   937 }
       
   938     
       
   939 // -----------------------------------------------------------------------------
       
   940 // CSvgTimeContainer::UserPauseElement
       
   941 // Called to handle user/client generated pause event
       
   942 // 
       
   943 /*
       
   944     UserPauseElement()     iIsSyncPaused is syncStatus 
       
   945       {
       
   946           If ( syncStatus is not Paused AND userStatus is not paused or stopped )
       
   947           Pause Element
       
   948            Set userStatus = Paused
       
   949            
       
   950                If Element type = Animation
       
   951                 {
       
   952                     Get Child TC Pointer.
       
   953                     If Valid,
       
   954                       Call Child Tc->UserPause
       
   955                 }
       
   956 
       
   957       }
       
   958 */
       
   959 
       
   960 //-----------------------------------------------------------------------------
       
   961 //
       
   962    
       
   963  void CSvgTimeContainer::UserPauseElement(TSvgTimedEntityListItem* aTimedEntity)
       
   964 {
       
   965   if(
       
   966       !(aTimedEntity->iIsSyncPaused )
       
   967     &&  (aTimedEntity->iUserState == ESvgUserRunning)
       
   968       )
       
   969     {
       
   970       aTimedEntity->iTimedEntity->PauseTimedEntity();
       
   971           
       
   972     } 
       
   973     aTimedEntity->iUserState = ESvgUserPaused;
       
   974     
       
   975     if(aTimedEntity->iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
   976     {
       
   977         CSvgTimeContainer* AnimTimeContainer = aTimedEntity->iTimedEntity->GetChildTimeContainer();
       
   978         if(AnimTimeContainer)
       
   979         {
       
   980             AnimTimeContainer->UserPause();
       
   981       }
       
   982     }
       
   983     
       
   984 }
       
   985 
       
   986 // -----------------------------------------------------------------------------
       
   987 // CSvgTimeContainer::UserSeek
       
   988 // Called to handle user/client generated seek event
       
   989 // -----------------------------------------------------------------------------
       
   990 //
       
   991 void CSvgTimeContainer::UserSeek( 
       
   992     TInt aTime ) // Time in msecs to seek
       
   993     {
       
   994     if ( iTimer )
       
   995         {
       
   996         //if ( iOwnerDoc && iCurrentTime != aTime )
       
   997         if ( iOwnerDoc)
       
   998             {
       
   999             iCurrentTime = aTime;
       
  1000             iCurrentTick.iParentTcTick = aTime;
       
  1001             iCurrentTick.iRealTimeTick = aTime;
       
  1002             TSvgTimerEvent timeEvent( iCurrentTime );
       
  1003             iOwnerDoc->Reset( &timeEvent );
       
  1004             }            
       
  1005 
       
  1006         iTimer->SetSeekTime( aTime );
       
  1007         }
       
  1008     // Need to send user resume events to timed entities
       
  1009     SetUserState(ESvgUserRunning);
       
  1010     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
  1011     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
  1012     	{
       
  1013 		UserResumeElement( &iTcTimedEntities[ lItemIndex ] );
       
  1014     	}
       
  1015     
       
  1016     UserResumeElement(&iLrteListItem);
       
  1017     }
       
  1018 
       
  1019 // ---------------------------------------------------------------------------
       
  1020 // CSvgTimeContainer::UserResetTime
       
  1021 // Resets the time variables
       
  1022 // ---------------------------------------------------------------------------
       
  1023 void CSvgTimeContainer::UserResetTime()
       
  1024     {
       
  1025     if ( iTimer )
       
  1026         {
       
  1027         iTimer->ResetTime();
       
  1028         }
       
  1029     }
       
  1030 
       
  1031 // ---------------------------------------------------------------------------
       
  1032 // CSvgTimeContainer::UserChangeFrameDuration
       
  1033 // Changes the frame duration in the timer
       
  1034 // ---------------------------------------------------------------------------
       
  1035 void CSvgTimeContainer::UserChangeFrameDuration( TUint32 aTimerDuration )
       
  1036     {
       
  1037     if ( iTimer )
       
  1038         {
       
  1039         iTimer->ChangeFrameDuration( aTimerDuration );
       
  1040         }    
       
  1041     }
       
  1042 // ---------------------------------------------------------------------------
       
  1043 // CSvgTimeContainer::UserFps
       
  1044 // Returns number of frames per sec(debug api)
       
  1045 // ---------------------------------------------------------------------------
       
  1046 TUint CSvgTimeContainer::UserFps()
       
  1047     {
       
  1048     if ( iTimer )
       
  1049         {
       
  1050         return iTimer->Fps();
       
  1051         }
       
  1052     return 0;        
       
  1053     }
       
  1054     
       
  1055 // -----------------------------------------------------------------------------
       
  1056 // CSvgTimeContainer::ParentTimeContainerTick
       
  1057 // From MSvgTimedEntityInterface
       
  1058 // -----------------------------------------------------------------------------
       
  1059 //
       
  1060 void CSvgTimeContainer::ParentTimeContainerTick( 
       
  1061     TSvgTick aTick ) // Current tick information 
       
  1062     {
       
  1063     // Update the member variable keeping track of current tick
       
  1064     iCurrentTick.iRealTimeTick = aTick.iRealTimeTick;
       
  1065     
       
  1066     // If the TC is locked wrt to its parent and parent is present
       
  1067     if ( ( iTcSyncBehavior == ESvgSyncLocked ) && iIsParentTcPresent )
       
  1068         {
       
  1069         iCurrentTick.iParentTcTick = aTick.iParentTcTick;
       
  1070         // Propogate the tick to all timed elements in the container
       
  1071         PropogateTickToContainerElements( iCurrentTick );
       
  1072         }
       
  1073     else
       
  1074         {
       
  1075         // Container not locked with respect to parent.
       
  1076         // Get Sync Master Entity in the group and use its clock as timing
       
  1077         // reference for the Time container. 
       
  1078         MSvgTimedEntityInterface* lSyncMaster = GetSyncMasterForTimeContainer();
       
  1079 
       
  1080         if ( !lSyncMaster )
       
  1081             {
       
  1082             // No Sync Master
       
  1083             iCurrentTick.iParentTcTick = aTick.iRealTimeTick;
       
  1084             // Propogate the tick to all timed elements in the container
       
  1085             PropogateTickToContainerElements( iCurrentTick );
       
  1086             }
       
  1087         else
       
  1088             {
       
  1089             // Sync Master Present, check whether it can generate tick
       
  1090             if ( lSyncMaster->CanGenerateTick() )
       
  1091                 {
       
  1092                 TUint32 lMasterCurTime = 0;
       
  1093                 lSyncMaster->GetEntityCurrentTime( lMasterCurTime );
       
  1094                 iCurrentTick.iParentTcTick = lMasterCurTime;
       
  1095                 // Propogate the tick to all timed elements in the container
       
  1096                 PropogateTickToContainerElements( iCurrentTick );
       
  1097                 }
       
  1098             else
       
  1099                 {
       
  1100                 // Sync Master present but cannot generate tick, so use
       
  1101                 // real time tick
       
  1102                 iCurrentTick.iParentTcTick = aTick.iRealTimeTick;
       
  1103                 // Propogate the tick to all timed elements in the container
       
  1104                 PropogateTickToContainerElements( iCurrentTick );
       
  1105                 }
       
  1106             }
       
  1107         }
       
  1108     }
       
  1109 
       
  1110 // -----------------------------------------------------------------------------
       
  1111 // CSvgTimeContainer::GetEntitySyncBehavior
       
  1112 // From MSvgTimedEntityInterface
       
  1113 // -----------------------------------------------------------------------------
       
  1114 //        
       
  1115 TSvgSyncBehaviour CSvgTimeContainer::GetEntitySyncBehavior()
       
  1116     {
       
  1117     return iTcSyncBehavior; 
       
  1118     }
       
  1119         
       
  1120 
       
  1121 // -----------------------------------------------------------------------------
       
  1122 // CSvgTimeContainer::GetEntityCurrentTime
       
  1123 // From MSvgTimedEntityInterface
       
  1124 // -----------------------------------------------------------------------------
       
  1125 //        
       
  1126 void CSvgTimeContainer::GetEntityCurrentTime( TUint32& 
       
  1127             aEntityCurTime ) // Current Entity Time in msecs. 
       
  1128     {
       
  1129     // IF GetCurSyncMasterStatus == FALSE, Error. // Shouldn't be happening.
       
  1130     TBool lCurSyncMasterStatus = EFalse;
       
  1131     GetCurSyncMasterStatus( lCurSyncMasterStatus );
       
  1132 
       
  1133     if ( lCurSyncMasterStatus )
       
  1134         {
       
  1135         // Resolve the sync Master for the container.  (Should have happened?)
       
  1136         MSvgTimedEntityInterface* lSyncMaster = GetSyncMasterForTimeContainer();
       
  1137         // IF no syncMaster, Error (Shouldn't be happening.)
       
  1138         if ( !lSyncMaster )
       
  1139             {
       
  1140             return;
       
  1141             }
       
  1142         lSyncMaster->GetEntityCurrentTime( aEntityCurTime );
       
  1143         }
       
  1144     }
       
  1145 
       
  1146 // -----------------------------------------------------------------------------
       
  1147 // CSvgTimeContainer::GetCnfSyncMasterStatus
       
  1148 // From MSvgTimedEntityInterface
       
  1149 // -----------------------------------------------------------------------------
       
  1150 //        
       
  1151 void CSvgTimeContainer::GetCnfSyncMasterStatus( 
       
  1152             TBool& aIsSyncMaster ) // Indicates whether the element is configured as 
       
  1153                                    // Sync Master. 
       
  1154     {
       
  1155     iTcSyncMasterConfig = aIsSyncMaster;
       
  1156     }                                   
       
  1157 
       
  1158 // -----------------------------------------------------------------------------
       
  1159 // CSvgTimeContainer::GetCurSyncMasterStatus
       
  1160 // From MSvgTimedEntityInterface
       
  1161 // -----------------------------------------------------------------------------
       
  1162 void CSvgTimeContainer::GetCurSyncMasterStatus( 
       
  1163             TBool& aIsSyncMaster ) // Indicates whether the element is currrently 
       
  1164                                   // Sync Master. 
       
  1165     {
       
  1166     aIsSyncMaster = iTcSyncMasterCurrent;
       
  1167     }        
       
  1168 
       
  1169 
       
  1170 // -----------------------------------------------------------------------------
       
  1171 // CSvgTimeContainer::SetCurSyncMasterStatus
       
  1172 // From MSvgTimedEntityInterface
       
  1173 // -----------------------------------------------------------------------------
       
  1174 void CSvgTimeContainer::SetCurSyncMasterStatus( 
       
  1175     TBool aSyncMasterStatus ) //  Indicates whether the element is currrently 
       
  1176                               // Sync Master.
       
  1177     {
       
  1178     iTcSyncMasterCurrent = aSyncMasterStatus;
       
  1179     // Update the state of current sync master if there is one
       
  1180     if ( iTcSyncMaster )
       
  1181         {
       
  1182         iTcSyncMaster->SetCurSyncMasterStatus( aSyncMasterStatus );
       
  1183         }
       
  1184     }
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // CSvgTimeContainer::CanGenerateTick
       
  1188 // From MSvgTimedEntityInterface
       
  1189 // -----------------------------------------------------------------------------
       
  1190 TBool CSvgTimeContainer::CanGenerateTick()
       
  1191     {
       
  1192     MSvgTimedEntityInterface* lSyncMaster = GetSyncMasterForTimeContainer();
       
  1193     if(lSyncMaster == iLrteListItem.iTimedEntity)
       
  1194         {
       
  1195         return EFalse;
       
  1196         }
       
  1197     return ( lSyncMaster ? ETrue:EFalse );
       
  1198     }
       
  1199 
       
  1200 // -----------------------------------------------------------------------------
       
  1201 // CSvgTimeContainer::CanUseParentTick
       
  1202 // From MSvgTimedEntityInterface
       
  1203 // -----------------------------------------------------------------------------
       
  1204 TBool CSvgTimeContainer::CanUseParentTick()
       
  1205     {
       
  1206     // This function returns true if it does not have a parent time container
       
  1207     // Hence the root time container creates the timer and hence can use
       
  1208     // parent tick
       
  1209     return ( !iIsParentTcPresent );
       
  1210     }
       
  1211     
       
  1212 // -----------------------------------------------------------------------------
       
  1213 // CSvgTimeContainer::ResyncTimedEntity
       
  1214 // From MSvgTimedEntityInterface
       
  1215 // -----------------------------------------------------------------------------
       
  1216 void CSvgTimeContainer::ResyncTimedEntity( 
       
  1217             TUint32 /*aSynctime */) // Time for resync in msecs.
       
  1218     {
       
  1219     // TODO: Resync Logic
       
  1220     }
       
  1221     
       
  1222 
       
  1223 // -----------------------------------------------------------------------------
       
  1224 // CSvgTimeContainer::PauseTimedEntity
       
  1225 // From MSvgTimedEntityInterface
       
  1226 // -----------------------------------------------------------------------------
       
  1227 void CSvgTimeContainer::PauseTimedEntity()
       
  1228     {
       
  1229 
       
  1230     }
       
  1231 
       
  1232 // -----------------------------------------------------------------------------
       
  1233 // CSvgTimeContainer::ResumeTimedEntity
       
  1234 // From MSvgTimedEntityInterface
       
  1235 // -----------------------------------------------------------------------------
       
  1236 void CSvgTimeContainer::ResumeTimedEntity()
       
  1237     {
       
  1238  
       
  1239     }
       
  1240 
       
  1241 // -----------------------------------------------------------------------------
       
  1242 // CSvgTimeContainer::StopTimedEntity
       
  1243 // From MSvgTimedEntityInterface
       
  1244 // -----------------------------------------------------------------------------
       
  1245 void CSvgTimeContainer::StopTimedEntity()
       
  1246     {
       
  1247 
       
  1248     }
       
  1249 
       
  1250 
       
  1251 //From MSvgTimedEntityInterface
       
  1252 TSvgObjectType CSvgTimeContainer::ObjectType()
       
  1253 {
       
  1254   return ESvgInvalidReference;  
       
  1255 }
       
  1256 
       
  1257 //returns the child time container of the element 
       
  1258 //used in timecontainer
       
  1259 CSvgTimeContainer* CSvgTimeContainer::GetChildTimeContainer()
       
  1260 {
       
  1261     return NULL;
       
  1262 }
       
  1263 
       
  1264 //-------------------------------------------------------------------------------
       
  1265 /*
       
  1266 TC::SyncPause()
       
  1267 {
       
  1268      tc.SyncStatus = Paused;
       
  1269 
       
  1270      For All Locked Elements
       
  1271   {
       
  1272       Pause Element; 
       
  1273        Note: No element level state change, as element level syncStatus reflects only
       
  1274        syncStatus evaluated in TC group level. ,e.g. syncStatus could be running in this
       
  1275                              case 
       
  1276         If element = animation 
       
  1277     {
       
  1278         Get Child TC pointer
       
  1279         If Child TC
       
  1280             childTc->SyncPause;
       
  1281     }
       
  1282 
       
  1283   }
       
  1284 }
       
  1285 
       
  1286 
       
  1287 */
       
  1288 //-------------------------------------------------------------------------------
       
  1289 void CSvgTimeContainer::SyncPause()
       
  1290     {
       
  1291     //iIsSyncPaused = ETrue;
       
  1292     SetSyncState(ETrue);
       
  1293     
       
  1294     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
  1295     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
  1296         {
       
  1297         if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked )
       
  1298             {
       
  1299             iTcTimedEntities[lItemIndex].iTimedEntity->PauseTimedEntity();
       
  1300             }
       
  1301         
       
  1302         if(iTcTimedEntities[lItemIndex].iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
  1303             {
       
  1304             CSvgTimeContainer* AnimTimeContainer = iTcTimedEntities[lItemIndex].iTimedEntity->GetChildTimeContainer();
       
  1305             if(AnimTimeContainer)
       
  1306                 {
       
  1307                 AnimTimeContainer->SyncPause();
       
  1308                 }
       
  1309             }    
       
  1310         }
       
  1311     iLrteListItem.iTimedEntity->PauseTimedEntity()  ;
       
  1312     
       
  1313     }
       
  1314 
       
  1315 //----------------------------------------------------------------------------------
       
  1316 //
       
  1317 /*
       
  1318 TC::SyncResume()
       
  1319 {
       
  1320      tc.SyncStatus = Running;
       
  1321      For all locked elements
       
  1322      {
       
  1323         If (syncStatus == running AND userStatus == running AND TC.userStatus == running)
       
  1324         {
       
  1325           Resume Element
       
  1326       }
       
  1327   
       
  1328         If element = animation 
       
  1329       {
       
  1330         Get Child TC pointer
       
  1331         If Child TC
       
  1332             childTc->SyncResume;
       
  1333       }
       
  1334      }
       
  1335 }
       
  1336 
       
  1337 
       
  1338 */
       
  1339 //----------------------------------------------------------------------------------
       
  1340 void CSvgTimeContainer::SyncResume()
       
  1341     {
       
  1342     SetSyncState(EFalse);
       
  1343     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
  1344     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
  1345         {
       
  1346         if((iTcTimedEntities[ lItemIndex ]).iTimedEntity->GetEntitySyncBehavior() == ESvgSyncLocked )
       
  1347             {
       
  1348             if(
       
  1349             !(iTcTimedEntities[lItemIndex].iIsSyncPaused)
       
  1350             &&(iTcTimedEntities[lItemIndex].iUserState == ESvgUserRunning)
       
  1351             &&(iUserState == ESvgUserRunning)
       
  1352             )
       
  1353                 {
       
  1354                 iTcTimedEntities[lItemIndex].iTimedEntity->ResumeTimedEntity();    
       
  1355                 }
       
  1356             
       
  1357             }
       
  1358         
       
  1359         if(iTcTimedEntities[lItemIndex].iTimedEntity->ObjectType() == ESvgMediaAnimationElement)  
       
  1360             {
       
  1361             CSvgTimeContainer* AnimTimeContainer = iTcTimedEntities[lItemIndex].iTimedEntity->GetChildTimeContainer();
       
  1362             if(AnimTimeContainer)
       
  1363                 {
       
  1364                 AnimTimeContainer->SyncResume();
       
  1365                 }
       
  1366             }    
       
  1367         }
       
  1368         
       
  1369         iLrteListItem.iTimedEntity->ResumeTimedEntity();
       
  1370     
       
  1371 }
       
  1372 //---------------------------------------------------------------
       
  1373 //Sets the time container User state
       
  1374 //void CSvgTimeContainer::SetUserState(TSvgEntityUserState state)
       
  1375 //---------------------------------------------------------------
       
  1376 void CSvgTimeContainer::SetUserState(TSvgEntityUserState state)
       
  1377 {
       
  1378     iUserState = state;
       
  1379   /*  #ifdef _DEBUG
       
  1380     RDebug::Print(_L("CSvgTimeContainer User State changed to %d"),state);
       
  1381     RDebug::Print(_L("\n0.ESvgUserRunning 1.ESvgUserPaused 2.ESvgUserStopped\n\n"));
       
  1382     #endif
       
  1383   */  
       
  1384 }
       
  1385  
       
  1386 
       
  1387 //---------------------------------------------------------------
       
  1388 //Sets the time container Media state
       
  1389 //void CSvgTimeContainer::SetMediaState(TSvgEntityMediaState state)
       
  1390 //---------------------------------------------------------------
       
  1391 void CSvgTimeContainer::SetMediaState(TSvgEntityMediaState state)
       
  1392 {
       
  1393     iMediaState = state;
       
  1394     /*
       
  1395     #ifdef _DEBUG
       
  1396     RDebug::Print(_L("CSvgTimeContainer Media State changed to %d"),state);
       
  1397     RDebug::Print(_L("\n0.ESvgMediaIdle 1.ESvgMediaNotReady 2.ESvgMediaReady\n\n"));
       
  1398     #endif
       
  1399     */
       
  1400 }
       
  1401         
       
  1402 //---------------------------------------------------------------
       
  1403 //Sets the time container sync state state
       
  1404 //void CSvgTimeContainer::SetSyncState(TBool state)
       
  1405 //---------------------------------------------------------------
       
  1406 void CSvgTimeContainer::SetSyncState(TBool state)
       
  1407 {
       
  1408     iIsSyncPaused = state;
       
  1409 /*    #ifdef _DEBUG
       
  1410     RDebug::Print(_L("CSvgTimeContainer iIsyncPaused  changed to %d"),state);
       
  1411     RDebug::Print(_L("\n0 False 1 True\n\n"));
       
  1412     #endif
       
  1413  */   
       
  1414 }
       
  1415         
       
  1416 // -----------------------------------------------------------------------------
       
  1417 // CSvgTimeContainer::PropogateTickToContainerElements
       
  1418 // Propogate tick to all elements in time container
       
  1419 // -----------------------------------------------------------------------------
       
  1420 void CSvgTimeContainer::PropogateTickToContainerElements( TSvgTick& aTick )
       
  1421     {
       
  1422     // Propogate the tick to all container elements
       
  1423     TInt lTimedEntityListCnt = iTcTimedEntities.Count();
       
  1424     for ( TInt lItemIndex = lTimedEntityListCnt - 1; lItemIndex >= 0 ; lItemIndex-- )
       
  1425         {
       
  1426         (iTcTimedEntities[ lItemIndex ]).iTimedEntity->ParentTimeContainerTick( aTick );
       
  1427         }
       
  1428     }
       
  1429 
       
  1430 // -----------------------------------------------------------------------------
       
  1431 // CSvgTimeContainer::RearrangeTimedEntityList
       
  1432 // Rearrange the timed entities as per post order
       
  1433 // -----------------------------------------------------------------------------
       
  1434 void CSvgTimeContainer::RearrangeTimedEntityList( RPointerArray<CSvgElementImpl>& 
       
  1435             aPostOrderList )
       
  1436     {
       
  1437     TUint lCurElement = 0;
       
  1438     TUint lCurTimedEntity = 0;
       
  1439     for ( ;lCurElement < aPostOrderList.Count(); lCurElement++, lCurTimedEntity++ )
       
  1440         {
       
  1441         CSvgMediaElementBase* lCurMediaEle = ( CSvgMediaElementBase* )
       
  1442             aPostOrderList[ lCurElement ];
       
  1443         
       
  1444         // Start looking in the timed entity list from lCurTimedEntity
       
  1445         TUint lListIndex = lCurTimedEntity; 
       
  1446         
       
  1447         // Find the element in the current timed entity list
       
  1448         /*for ( ; ( ( iTcTimedEntities[ lListIndex ].iTimedEntity != 
       
  1449                 ( MSvgTimedEntityInterface* ) lCurMediaEle ) && 
       
  1450                     ( lListIndex < iTcTimedEntities.Count() ) ); 
       
  1451             lListIndex++ )
       
  1452             {
       
  1453             }
       
  1454         */
       
  1455         do
       
  1456 				{
       
  1457 					if( iTcTimedEntities[ lListIndex ].iTimedEntity == ( MSvgTimedEntityInterface* ) lCurMediaEle ) 
       
  1458 						break;
       
  1459 					lListIndex++; 
       
  1460 				}while(lListIndex < iTcTimedEntities.Count() ) ;
       
  1461 
       
  1462         
       
  1463         if ( lListIndex != iTcTimedEntities.Count() )    
       
  1464             {
       
  1465             if ( lListIndex != lCurTimedEntity )
       
  1466                 {
       
  1467                 // Not in same position, need to swap 
       
  1468                 TSvgTimedEntityListItem lTempItem = iTcTimedEntities[ lCurTimedEntity ];
       
  1469                 iTcTimedEntities[ lCurTimedEntity ] = iTcTimedEntities[ lListIndex ];
       
  1470                 iTcTimedEntities[ lListIndex ] = lTempItem;
       
  1471                 }
       
  1472             }
       
  1473         else
       
  1474             {
       
  1475             // Can occur in case of Delete Timed Entity -> ignore
       
  1476             }
       
  1477         }
       
  1478     }
       
  1479 
       
  1480 // -----------------------------------------------------------------------------
       
  1481 // CSvgTimeContainer::?member_function
       
  1482 // ?implementation_description
       
  1483 // (other items were commented in a header).
       
  1484 // -----------------------------------------------------------------------------
       
  1485 //
       
  1486 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  1487 
       
  1488 
       
  1489 
       
  1490 //  End of File