mmsharing/mmshengine/src/musengorientationhandler.cpp
branchRCL_3
changeset 16 ce86b6d44a6d
child 18 407431f36921
equal deleted inserted replaced
15:95754dcd27ad 16:ce86b6d44a6d
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // USER
       
    20 #include "musengorientationhandler.h"
       
    21 #include "muslogger.h"
       
    22 #include "musenglivesession.h"
       
    23 #include "musenglivesessionobserver.h"
       
    24 
       
    25 // SYSTEM
       
    26 
       
    27 const TInt KMusEngDelayedResume = 300000; // 300 ms
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CMusEngOrientationHandler* CMusEngOrientationHandler::NewL( 
       
    34     CMusEngLiveSession& aSession, MMusEngLiveSessionObserver& aSessionObserver )
       
    35     {
       
    36     CMusEngOrientationHandler* self = 
       
    37         new (ELeave) CMusEngOrientationHandler( aSession, aSessionObserver );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self);
       
    41     return self;
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CMusEngOrientationHandler::~CMusEngOrientationHandler()
       
    49     {
       
    50     MUS_LOG( "mus: [ENGINE]     CMusEngOrientationHandler::~CMusEngOrientationHandler()" )
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CMusEngOrientationHandler::RefreshOrientationL()
       
    58     {
       
    59     MUS_LOG( "mus: [ENGINE]  -> CMusEngOrientationHandler::RefreshOrientationL()" )
       
    60     if ( !IsActive() )
       
    61         {
       
    62         TBool refreshBeginStateCamera = iSession.IsPlayingL();
       
    63         TBool refreshBeginStateDisplay = iSession.IsDisplayEnabledL();
       
    64             
       
    65         if ( refreshBeginStateCamera )
       
    66              {
       
    67              MUS_LOG( "mus: [MUSENG]  -> Playing, pause/stop to restart camera" );
       
    68              iSession.PauseL();
       
    69              } 
       
    70          
       
    71         if ( refreshBeginStateDisplay )
       
    72              {
       
    73              MUS_LOG( "mus: [MUSENG]  -> display is enabled, disable/enable it");
       
    74              iSession.EnableDisplayL(EFalse);
       
    75              }
       
    76         iRefreshBeginStateCamera = refreshBeginStateCamera;
       
    77         iRefreshBeginStateDisplay = refreshBeginStateDisplay;
       
    78         }
       
    79     
       
    80     DoDelayedResumeL();
       
    81     
       
    82     MUS_LOG( "mus: [ENGINE]  <- CMusEngOrientationHandler::RefreshOrientationL()" )
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CMusEngOrientationHandler::UpdateL()
       
    90     {
       
    91     MUS_LOG( "mus: [ENGINE]  -> CMusEngOrientationHandler::UpdateL()" )
       
    92     iRefreshBeginStateCamera = iSession.IsPlayingL();
       
    93     iRefreshBeginStateDisplay = iSession.IsDisplayEnabledL();
       
    94     MUS_LOG2( "mus: [ENGINE]  <- CMusEngOrientationHandler::UpdateL(), cam:%d disp:%d", 
       
    95         iRefreshBeginStateCamera, iRefreshBeginStateDisplay )
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CMusEngOrientationHandler::RunL()
       
   103     {
       
   104     MUS_LOG( "mus: [ENGINE]  -> CMusEngOrientationHandler::RunL()" )
       
   105 
       
   106     TBool refreshBeginStateCamera = iRefreshBeginStateCamera;
       
   107     TBool refreshBeginStateDisplay = iRefreshBeginStateDisplay;
       
   108        
       
   109     iSessionObserver.OrientationRefreshEnded();
       
   110     
       
   111     if ( refreshBeginStateDisplay )
       
   112         {
       
   113         MUS_LOG( "mus: [ENGINE] enable display after delayed orientation" )
       
   114         iSession.EnableDisplayL(ETrue);
       
   115         }
       
   116     
       
   117     if ( refreshBeginStateCamera )
       
   118         {
       
   119         MUS_LOG( "mus: [ENGINE] enable camera after delayed orientation" )
       
   120         iSession.PlayL();
       
   121         }
       
   122     MUS_LOG( "mus: [ENGINE]  <- CMusEngOrientationHandler::RunL()" )
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 TInt CMusEngOrientationHandler::RunError( TInt aError )
       
   130     {
       
   131     MUS_LOG( "mus: [ENGINE]  <-> CMusEngOrientationHandler::RunError()" )
       
   132     aError = KErrNone;
       
   133     return aError;
       
   134     }
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CMusEngOrientationHandler::DoDelayedResumeL()
       
   140     {
       
   141     if ( IsActive() )
       
   142         {
       
   143         Cancel();
       
   144         }
       
   145     After( KMusEngDelayedResume );
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 CMusEngOrientationHandler::CMusEngOrientationHandler( 
       
   153     CMusEngLiveSession& aSession, MMusEngLiveSessionObserver& aSessionObserver )
       
   154     : CTimer( CActive::EPriorityStandard ), iSession( aSession ), 
       
   155       iSessionObserver( aSessionObserver )
       
   156     {
       
   157     CActiveScheduler::Add(this);
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CMusEngOrientationHandler::ConstructL()
       
   166     {
       
   167     MUS_LOG( "mus: [ENGINE]  -> CMusEngOrientationHandler::ConstructL()" )
       
   168         
       
   169     CTimer::ConstructL();
       
   170     
       
   171     MUS_LOG( "mus: [ENGINE]  <- CMusEngOrientationHandler::ConstructL()" )
       
   172     }
       
   173