videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description:  This class plays local video file
    14 * Description:  This class plays local video file
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 50 %
    18 
       
    19 // Version : %version: 56 %
    19 
    20 
    20 
    21 
    21 //
    22 //
    22 //  INCLUDE FILES
    23 //  INCLUDE FILES
    23 //
    24 //
    39 #include <mmf/common/mmferrors.h>
    40 #include <mmf/common/mmferrors.h>
    40 
    41 
    41 #include <e32std.h>
    42 #include <e32std.h>
    42 #include <devsoundif.h>
    43 #include <devsoundif.h>
    43 #include <avkondomainpskeys.h>
    44 #include <avkondomainpskeys.h>
    44 #include <hwrmlight.h>  
    45 #include <hwrmlight.h>
    45 #include <centralrepository.h>  // For display timeout setting
    46 #include <centralrepository.h>  // For display timeout setting
    46 #include <hwrmlightdomaincrkeys.h>
    47 #include <hwrmlightdomaincrkeys.h>
    47 
    48 
    48 #include "mpxvideoregion.h"
    49 #include "mpxvideoregion.h"
    49 #include "mpxvideoplaybackcontroller.h"
    50 #include "mpxvideoplaybackcontroller.h"
    83 _LIT( KAbstract, "Abstract" );
    84 _LIT( KAbstract, "Abstract" );
    84 _LIT( KLocation, "Location" );
    85 _LIT( KLocation, "Location" );
    85 _LIT( KRightCopy, "Copyright" );
    86 _LIT( KRightCopy, "Copyright" );
    86 _LIT( KLanguage, "Language" );
    87 _LIT( KLanguage, "Language" );
    87 _LIT( KKeywords, "Keywords" );
    88 _LIT( KKeywords, "Keywords" );
       
    89 _LIT( KCreated, "CreationTime" );
       
    90 _LIT( KLastModified, "ModificationTime" );
    88 
    91 
    89 
    92 
    90 // ============================ MEMBER FUNCTIONS ===================================================
    93 // ============================ MEMBER FUNCTIONS ===================================================
    91 
    94 
    92 //  ------------------------------------------------------------------------------------------------
    95 //  ------------------------------------------------------------------------------------------------
   162     iPlayer = CMpxVideoPlayerUtility::NewL( this );
   165     iPlayer = CMpxVideoPlayerUtility::NewL( this );
   163 
   166 
   164     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   167     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   165 
   168 
   166     iDrmHelper = CMpxVideoDrmHelper::NewL();
   169     iDrmHelper = CMpxVideoDrmHelper::NewL();
   167     
   170 
   168     iSavedPosition = 0;
   171     iSavedPosition = 0;
   169 }
   172 }
   170 
   173 
   171 //  ----------------------------------------------------------------------------
   174 //  ----------------------------------------------------------------------------
   172 //  CMPXVideoPlaybackController::CloseController()
   175 //  CMPXVideoPlaybackController::CloseController()
   183 //  ------------------------------------------------------------------------------------------------
   186 //  ------------------------------------------------------------------------------------------------
   184 //
   187 //
   185 void CMPXVideoPlaybackController::OpenFileL( const TDesC& aMediaFile,
   188 void CMPXVideoPlaybackController::OpenFileL( const TDesC& aMediaFile,
   186                                              RFile& aFile,
   189                                              RFile& aFile,
   187                                              TInt aPosition,
   190                                              TInt aPosition,
   188                                              TInt aAccessPointId ) 
   191                                              TInt aAccessPointId )
   189 {
   192 {
   190     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFileL()"),
   193     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFileL()"),
   191                    _L("file = %S"), &aMediaFile );
   194                    _L("file = %S"), &aMediaFile );
   192 
   195 
   193     TBool fileExists = EFalse;
   196     TBool fileExists = EFalse;
   214 
   217 
   215     DetermineMediaTypeL();
   218     DetermineMediaTypeL();
   216     SetPlaybackModeL();
   219     SetPlaybackModeL();
   217 
   220 
   218     iSavedPosition = aPosition;
   221     iSavedPosition = aPosition;
   219     
   222 
   220     //
   223     //
   221     //  Create accessory monitor to search for TV-Out events
   224     //  Create accessory monitor to search for TV-Out events
   222     //
   225     //
   223     if ( ! iAccessoryMonitor )
   226     if ( ! iAccessoryMonitor )
   224     {
   227     {
   347     if ( iPlayer )
   350     if ( iPlayer )
   348     {
   351     {
   349         delete iPlayer;
   352         delete iPlayer;
   350         iPlayer = NULL;
   353         iPlayer = NULL;
   351     }
   354     }
   352    
   355 
   353     if ( iUserActivityTimer )
   356     if ( iUserActivityTimer )
   354     {
   357     {
   355         iUserActivityTimer->Cancel();
   358         iUserActivityTimer->Cancel();
   356         delete iUserActivityTimer;
   359         delete iUserActivityTimer;
   357         iUserActivityTimer = NULL;
   360         iUserActivityTimer = NULL;
   358     }
   361     }
   359     
   362 
   360     ReleaseLights();
   363     ReleaseLights();
   361     
   364 
   362     CancelDisplayTimer();
   365     CancelDisplayTimer();
   363 
   366 
   364 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   367 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   365 
   368 
   366     if ( iFileHandle64.SubSessionHandle() )
   369     if ( iFileHandle64.SubSessionHandle() )
   493             }
   496             }
   494             case EPbCmdUpdateSeekable:
   497             case EPbCmdUpdateSeekable:
   495             {
   498             {
   496                 iSeekable = aCmd.ValueTObjectL<TBool>(KMPXMediaGeneralExtVideoSeekable);
   499                 iSeekable = aCmd.ValueTObjectL<TBool>(KMPXMediaGeneralExtVideoSeekable);
   497 
   500 
   498                 if( iFileDetails )
   501                 if ( iFileDetails )
   499                 {
   502                 {
   500                     iFileDetails->iSeekable &= iSeekable;
   503                     iFileDetails->iSeekable &= iSeekable;
   501                 }
   504                 }
   502 
   505 
   503                 break;
   506                 break;
   541                 }
   544                 }
   542 
   545 
   543                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   546                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   544                                              bufferingPercentage );
   547                                              bufferingPercentage );
   545 
   548 
   546                 break;
       
   547             }
       
   548             case EPbCmdSurfaceRemoved:
       
   549             {
       
   550                 iPlayer->SurfaceRemovedFromView();
       
   551                 break;
       
   552             }
       
   553             default:
       
   554             {
       
   555                 break;
   549                 break;
   556             }
   550             }
   557         }
   551         }
   558     }
   552     }
   559 }
   553 }
  1201         switch ( aChangeToState )
  1195         switch ( aChangeToState )
  1202         {
  1196         {
  1203             case EMPXVideoPlaying:
  1197             case EMPXVideoPlaying:
  1204             {
  1198             {
  1205                 iState = iPlayingState;
  1199                 iState = iPlayingState;
  1206                 
  1200 
  1207                 //
  1201                 //
  1208                 //  If clip is audio only, stop the backlight timer and break switch
  1202                 //  If clip is audio only, stop the backlight timer and break switch
  1209                 //  If clip has audio and video, proceed to the next case which will
  1203                 //  If clip has audio and video, proceed to the next case which will
  1210                 //  start the backlight timer if needed
  1204                 //  start the backlight timer if needed
  1211                 //
  1205                 //
  1215                 }
  1209                 }
  1216                 else
  1210                 else
  1217                 {
  1211                 {
  1218                     CancelLightsControl();
  1212                     CancelLightsControl();
  1219                 }
  1213                 }
  1220                 
  1214 
  1221                 break;
  1215                 break;
  1222             }
  1216             }
  1223             case EMPXVideoPaused:
  1217             case EMPXVideoPaused:
  1224             {
  1218             {
  1225                 iState = iPausedState;
  1219                 iState = iPausedState;
  1376 
  1370 
  1377             CleanupStack::PushL( metaData );
  1371             CleanupStack::PushL( metaData );
  1378 
  1372 
  1379             if ( ! metaData->Name().CompareF( KSeekable ) )
  1373             if ( ! metaData->Name().CompareF( KSeekable ) )
  1380             {
  1374             {
  1381                 if ( ! metaData->Value().CompareF( KTrue ) )
  1375                 if ( ! metaData->Value().CompareF( KFalse ) )
  1382                 {
  1376                 {
  1383                     iFileDetails->iSeekable = ETrue;
  1377                     iFileDetails->iSeekable = EFalse;
  1384                 }
  1378                 }
  1385             }
  1379             }
  1386             else if ( ! metaData->Name().CompareF( KLiveStream ) )
  1380             else if ( ! metaData->Name().CompareF( KLiveStream ) )
  1387             {
  1381             {
  1388                 if ( ! metaData->Value().CompareF( KTrue ) )
  1382                 if ( ! metaData->Value().CompareF( KTrue ) )
  1447                 iFileDetails->iLanguage = metaData->Value().AllocL();
  1441                 iFileDetails->iLanguage = metaData->Value().AllocL();
  1448             }
  1442             }
  1449             else if ( !metaData->Name().CompareF( KKeywords ) )
  1443             else if ( !metaData->Name().CompareF( KKeywords ) )
  1450             {
  1444             {
  1451                 iFileDetails->iKeywords = metaData->Value().AllocL();
  1445                 iFileDetails->iKeywords = metaData->Value().AllocL();
       
  1446             }
       
  1447             else if ( !metaData->Name().CompareF( KCreated ) )
       
  1448             {
       
  1449                 TLex lex( metaData->Value() );
       
  1450                 lex.Val( iFileDetails->iCreationTime );
       
  1451             }
       
  1452             else if ( !metaData->Name().CompareF( KLastModified ) )
       
  1453             {
       
  1454                 TLex lex( metaData->Value() );
       
  1455                 lex.Val( iFileDetails->iModificationTime );
  1452             }
  1456             }
  1453 
  1457 
  1454             CleanupStack::PopAndDestroy( metaData );
  1458             CleanupStack::PopAndDestroy( metaData );
  1455         }
  1459         }
  1456 
  1460 
  1749     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsAlarm(%d)"), alarm);
  1753     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsAlarm(%d)"), alarm);
  1750 
  1754 
  1751     return alarm;
  1755     return alarm;
  1752 }
  1756 }
  1753 
  1757 
  1754 // -----------------------------------------------------------------------------
  1758 // -------------------------------------------------------------------------------------------------
  1755 // CMPXVideoPlaybackController::IsKeyLocked
  1759 //   CMPXVideoPlaybackController::IsKeyLocked
  1756 // -----------------------------------------------------------------------------
  1760 // -------------------------------------------------------------------------------------------------
  1757 //
  1761 //
  1758 TBool CMPXVideoPlaybackController::IsKeyLocked()
  1762 TBool CMPXVideoPlaybackController::IsKeyLocked()
  1759 {
  1763 {
  1760     TBool keylock( EFalse );
  1764     TBool keylock( EFalse );
  1761     RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
  1765     RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
  1763     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsKeyLocked(%d)"), keylock);
  1767     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsKeyLocked(%d)"), keylock);
  1764 
  1768 
  1765     return keylock;
  1769     return keylock;
  1766 }
  1770 }
  1767 
  1771 
       
  1772 // -------------------------------------------------------------------------------------------------
       
  1773 //   CMPXVideoPlaybackController::SendTvOutEventL
       
  1774 // -------------------------------------------------------------------------------------------------
       
  1775 //
       
  1776 void CMPXVideoPlaybackController::SendTvOutEventL( TBool aConnected, TBool aPlaybackAllowed )
       
  1777 {
       
  1778     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendTvOutEventL()"));
       
  1779 
       
  1780     //
       
  1781     //  Send notice to the playback view with TV-Out connection status
       
  1782     //  and TV-Out playback allowed flag
       
  1783     //
       
  1784     CMPXMessage* message = CMPXMessage::NewL();
       
  1785     CleanupStack::PushL( message );
       
  1786 
       
  1787     message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback );
       
  1788     message->SetTObjectValueL<TMPXVideoPlaybackCommand>
       
  1789         ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent );
       
  1790     message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, aConnected );
       
  1791     message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, aPlaybackAllowed );
       
  1792 
       
  1793     iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
       
  1794 
       
  1795     CleanupStack::PopAndDestroy( message );
       
  1796 }
       
  1797 
       
  1798 // -------------------------------------------------------------------------------------------------
       
  1799 //   CMPXVideoPlaybackController::SendHideControlsEventL
       
  1800 // -------------------------------------------------------------------------------------------------
       
  1801 //
       
  1802 void CMPXVideoPlaybackController::SendHideControlsEventL()
       
  1803 {
       
  1804     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendHideControlsEventL()"));
       
  1805 
       
  1806     //
       
  1807     //  Send notice to the playback view to hide the controls
       
  1808     //  when key lock
       
  1809     //
       
  1810     CMPXMessage* message = CMPXMessage::NewL();
       
  1811     CleanupStack::PushL( message );
       
  1812 
       
  1813     message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback );
       
  1814 
       
  1815     message->SetTObjectValueL<TMPXVideoPlaybackCommand>
       
  1816         ( KMPXMediaVideoPlaybackCommand, EPbCmdHideControls );
       
  1817 
       
  1818     iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
       
  1819 
       
  1820     CleanupStack::PopAndDestroy( message );
       
  1821 }
       
  1822 
  1768 //  ------------------------------------------------------------------------------------------------
  1823 //  ------------------------------------------------------------------------------------------------
  1769 //    CMPXVideoPlaybackController::HandleTvOutEventL()
  1824 //    CMPXVideoPlaybackController::HandleTvOutEventL()
  1770 //  ------------------------------------------------------------------------------------------------
  1825 //  ------------------------------------------------------------------------------------------------
  1771 //
  1826 //
  1772 void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected )
  1827 void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected )
  1773 {
  1828 {
  1774     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"),
  1829     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"),
  1775                     _L("aConnected = %d"), aConnected );
  1830                     _L("aConnected = %d"), aConnected );
  1776 
  1831 
  1777     TBool playbackAllowed = ETrue;
  1832     TBool playbackAllowed = iAccessoryMonitor->IsTvOutPlaybackAllowed();
  1778 
  1833 
       
  1834     SendTvOutEventL( aConnected, playbackAllowed );
       
  1835 
       
  1836     //
       
  1837     //  Check playback status of clip with new Tv-Out status
       
  1838     //
  1779     if ( aConnected )
  1839     if ( aConnected )
  1780     {
  1840     {
  1781         //
  1841         //
  1782         //  TV-Out accessory connected
  1842         //  TV-Out accessory connected
  1783         //
  1843         //
  1784         if ( ! iAccessoryMonitor->IsTvOutPlaybackAllowed() )
  1844         if ( ! playbackAllowed )
  1785         {
  1845         {
  1786             //
  1846             //
  1787             //  Clip has DRM protection and TV-Out is connected
  1847             //  Clip has DRM protection and TV-Out is connected
  1788             //  Pause playback and display info note
  1848             //  Pause playback and display info note
  1789             //
  1849             //
  1790             DoHandleCommandL( EPbCmdPause );
  1850             DoHandleCommandL( EPbCmdPause );
  1791 
  1851 
  1792             playbackAllowed = EFalse;
       
  1793 
       
  1794             iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed );
  1852             iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed );
  1795         }
  1853         }
  1796         else
  1854         else
  1797         {
  1855         {
  1798             // If lights are being controlled enable display timer so that screen backlight will be turned
  1856             // If lights are being controlled enable display timer so that screen backlight will be turned
  1799             // of after timeout.
  1857             // of after timeout.
  1800             if ( iBackLightTimer->IsActive() )
  1858             if ( iBackLightTimer->IsActive() )
  1801             {
  1859             {
  1802                 RestartDisplayTimer();
  1860                 RestartDisplayTimer();
  1803             }
  1861             }
  1804          } 
  1862          }
  1805     }
  1863     }
  1806     else 
  1864     else
  1807     {
  1865     {
  1808         // TV out disconnected
  1866         // TV out disconnected
  1809         CancelDisplayTimer();
  1867         CancelDisplayTimer();
  1810         
  1868 
  1811         // Ensure that lights are on after this 
  1869         // Ensure that lights are on after this
  1812         ReleaseLights();
  1870         ReleaseLights();
  1813         
  1871 
  1814         // Pause playback since TV-Out accessory has been disconnected.
  1872         // Pause playback since TV-Out accessory has been disconnected.
  1815         DoHandleCommandL( EPbCmdPause );
  1873         DoHandleCommandL( EPbCmdPause );
  1816     }
  1874     }
  1817 
       
  1818     //
       
  1819     //  Send notice to the playback view with TV-Out connection status
       
  1820     //  and TV-Out playback allowed flag
       
  1821     //
       
  1822     CMPXMessage* message = CMPXMessage::NewL();
       
  1823     CleanupStack::PushL( message );
       
  1824 
       
  1825     message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback );
       
  1826     message->SetTObjectValueL<TMPXVideoPlaybackCommand>
       
  1827         ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent );
       
  1828     message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, aConnected );
       
  1829     message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, playbackAllowed );
       
  1830 
       
  1831     iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
       
  1832 
       
  1833     CleanupStack::PopAndDestroy( message );
       
  1834 }
  1875 }
  1835 
  1876 
  1836 //  ------------------------------------------------------------------------------------------------
  1877 //  ------------------------------------------------------------------------------------------------
  1837 //    CMPXVideoPlaybackController::CancelBackLightTimer
  1878 //    CMPXVideoPlaybackController::CancelBackLightTimer
  1838 //  ------------------------------------------------------------------------------------------------
  1879 //  ------------------------------------------------------------------------------------------------
  1842 
  1883 
  1843     if ( iBackLightTimer->IsActive() )
  1884     if ( iBackLightTimer->IsActive() )
  1844     {
  1885     {
  1845         iBackLightTimer->Cancel();
  1886         iBackLightTimer->Cancel();
  1846     }
  1887     }
  1847     
       
  1848 }
  1888 }
  1849 
  1889 
  1850 //  ------------------------------------------------------------------------------------------------
  1890 //  ------------------------------------------------------------------------------------------------
  1851 //    CMPXVideoPlaybackState::StartBackLightTimer
  1891 //    CMPXVideoPlaybackState::StartBackLightTimer
  1852 //  ------------------------------------------------------------------------------------------------
  1892 //  ------------------------------------------------------------------------------------------------
  1859         iBackLightTimer->Start(
  1899         iBackLightTimer->Start(
  1860             0,
  1900             0,
  1861             KMPXBackLightTimeOut,
  1901             KMPXBackLightTimeOut,
  1862             TCallBack( CMPXVideoPlaybackController::HandleBackLightTimeout, this ));
  1902             TCallBack( CMPXVideoPlaybackController::HandleBackLightTimeout, this ));
  1863     }
  1903     }
  1864     
       
  1865 }
  1904 }
  1866 
  1905 
  1867 // -------------------------------------------------------------------------------------------------
  1906 // -------------------------------------------------------------------------------------------------
  1868 // Handle back light timer timeout callback
  1907 // Handle back light timer timeout callback
  1869 // -------------------------------------------------------------------------------------------------
  1908 // -------------------------------------------------------------------------------------------------
  1879 // -------------------------------------------------------------------------------------------------
  1918 // -------------------------------------------------------------------------------------------------
  1880 //
  1919 //
  1881 void CMPXVideoPlaybackController::DoHandleBackLightTimeout()
  1920 void CMPXVideoPlaybackController::DoHandleBackLightTimeout()
  1882 {
  1921 {
  1883     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleBackLightTimeout()"));
  1922     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleBackLightTimeout()"));
  1884     
  1923 
  1885     TBool tvOutConnected( EFalse );
  1924     TBool tvOutConnected( EFalse );
  1886     if ( iAccessoryMonitor )
  1925     if ( iAccessoryMonitor )
  1887     {
  1926     {
  1888         tvOutConnected = iAccessoryMonitor->IsTvOutConnected();
  1927         tvOutConnected = iAccessoryMonitor->IsTvOutConnected();
  1889     }
  1928     }
  1890     
  1929 
  1891     // User activity timer runs always when TV-out is connected
  1930     // User activity timer runs always when TV-out is connected
  1892     // it keeps resetting display timer and keeps lights on whenever there is user activity
  1931     // it keeps resetting display timer and keeps lights on whenever there is user activity
  1893     if ( tvOutConnected )
  1932     if ( tvOutConnected )
  1894     {
  1933     {
  1895         MPX_DEBUG ( _L("CMPXVideoPlaybackController::DoHandleBackLightTimeout() inactivity time = %d"), User::InactivityTime().Int() );
  1934         MPX_DEBUG ( _L("CMPXVideoPlaybackController::DoHandleBackLightTimeout() inactivity time = %d"), User::InactivityTime().Int() );
  1896         // Cancel activity timer. Otherwise resetting inactivity time would fire user activity detection
  1935         // Cancel activity timer. Otherwise resetting inactivity time would fire user activity detection
  1897         CancelUserActivityTimer();
  1936         CancelUserActivityTimer();
  1898     }
  1937     }
  1899         
  1938 
  1900     User::ResetInactivityTime();
  1939     User::ResetInactivityTime();
  1901     
  1940 
  1902     if ( tvOutConnected )
  1941     if ( tvOutConnected )
  1903     {
  1942     {
  1904         // Restart user activity timer. It must be running between backlight timer intervals so that backlight
  1943         // Restart user activity timer. It must be running between backlight timer intervals so that backlight
  1905         // can be turned on if user activity is detected.
  1944         // can be turned on if user activity is detected.
  1906         RestartUserActivityTimer();
  1945         RestartUserActivityTimer();
  1914 void CMPXVideoPlaybackController::StartLightsControl()
  1953 void CMPXVideoPlaybackController::StartLightsControl()
  1915 {
  1954 {
  1916     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::StartLightsControl()"));
  1955     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::StartLightsControl()"));
  1917 
  1956 
  1918     StartBackLightTimer();
  1957     StartBackLightTimer();
  1919              
  1958 
  1920     if (iAccessoryMonitor )
  1959     if (iAccessoryMonitor )
  1921     {
  1960     {
  1922         if ( iAccessoryMonitor->IsTvOutConnected() )
  1961         if ( iAccessoryMonitor->IsTvOutConnected() )
  1923         {
  1962         {
  1924             RestartDisplayTimer();
  1963             RestartDisplayTimer();
  1931 // -----------------------------------------------------------------------------
  1970 // -----------------------------------------------------------------------------
  1932 //
  1971 //
  1933 void CMPXVideoPlaybackController::CancelLightsControl()
  1972 void CMPXVideoPlaybackController::CancelLightsControl()
  1934 {
  1973 {
  1935     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()"));
  1974     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()"));
  1936 	
  1975 
  1937     // This is called whenever there is no need to keep screensaver of anymore
  1976     // This is called whenever there is no need to keep screensaver of anymore
  1938     // This means that also displaytimer and activity monitoring can be stopped. 
  1977     // This means that also displaytimer and activity monitoring can be stopped.
  1939     // This method is not correct place for these calls
  1978     // This method is not correct place for these calls
  1940     CancelBackLightTimer();
  1979     CancelBackLightTimer();
  1941    
  1980 
  1942     CancelUserActivityTimer();
  1981     CancelUserActivityTimer();
  1943     
  1982 
  1944     CancelDisplayTimer();
  1983     CancelDisplayTimer();
  1945 	
  1984 
  1946     // Ensure that lights are on
  1985     // Ensure that lights are on
  1947     EnableDisplayBacklight();
  1986     EnableDisplayBacklight();
  1948     
  1987 
  1949 	// Release lights if releserved
  1988     // Release lights if releserved
  1950     ReleaseLights();  
  1989     ReleaseLights();
  1951 }
  1990 }
  1952 
  1991 
  1953 
  1992 
  1954 // -----------------------------------------------------------------------------
  1993 // -----------------------------------------------------------------------------
  1955 // CMPXVideoPlaybackController::InitDisplayTimerL
  1994 // CMPXVideoPlaybackController::InitDisplayTimerL
  1956 // -----------------------------------------------------------------------------
  1995 // -----------------------------------------------------------------------------
  1957 //
  1996 //
  1958 TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL()
  1997 TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL()
  1959 {
  1998 {
  1960     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()"));
  1999     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()"));
  1961 	
  2000 
  1962     if ( !iDisplayTimer )
  2001     if ( !iDisplayTimer )
  1963     {
  2002     {
  1964         iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
  2003         iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
  1965 		
  2004 
  1966         MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") );	
  2005         MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") );
  1967         
  2006     }
  1968     }
  2007 
  1969    
       
  1970     if ( iDisplayTimerTimeout.Int() == 0 )
  2008     if ( iDisplayTimerTimeout.Int() == 0 )
  1971     {
  2009     {
  1972         // Get the display light time-out value from CenRep
  2010         // Get the display light time-out value from CenRep
  1973         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );    
  2011         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );
  1974         // What's the timeout value (in seconds ) for the display light?
  2012         // What's the timeout value (in seconds ) for the display light?
  1975         TInt displayTimeOut ( 0 );
  2013         TInt displayTimeOut ( 0 );
  1976         repository->Get( KDisplayLightsTimeout, displayTimeOut );
  2014         repository->Get( KDisplayLightsTimeout, displayTimeOut );
  1977         
  2015 
  1978         if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt )
  2016         if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt )
  1979         {
  2017         {
  1980             iDisplayTimerTimeout = KMaxTInt;
  2018             iDisplayTimerTimeout = KMaxTInt;
  1981         }
  2019         }
  1982         else
  2020         else
  1983         {
  2021         {
  1984             iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond;
  2022             iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond;
  1985         }
  2023         }
  1986         
  2024 
  1987         CleanupStack::PopAndDestroy( repository );
  2025         CleanupStack::PopAndDestroy( repository );
  1988     }     
  2026     }
  1989     
  2027 
  1990     
       
  1991     MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() );
  2028     MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() );
  1992 	
  2029 
  1993     // Convert the timeout value to microseconds
  2030     // Convert the timeout value to microseconds
  1994     return iDisplayTimerTimeout;   
  2031     return iDisplayTimerTimeout;
  1995 }
  2032 }
  1996 
  2033 
  1997 // -----------------------------------------------------------------------------
  2034 // -----------------------------------------------------------------------------
  1998 // CMPXVideoPlaybackController::RestartDisplayTimer
  2035 // CMPXVideoPlaybackController::RestartDisplayTimer
  1999 // -----------------------------------------------------------------------------
  2036 // -----------------------------------------------------------------------------
  2004 
  2041 
  2005     TTimeIntervalMicroSeconds32 displayTimeOut(0);
  2042     TTimeIntervalMicroSeconds32 displayTimeOut(0);
  2006     // Leave system to safe state if following leaves. Lights stay on
  2043     // Leave system to safe state if following leaves. Lights stay on
  2007     MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); )
  2044     MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); )
  2008     if ( err == KErrNone )
  2045     if ( err == KErrNone )
  2009     {   
  2046     {
  2010         // check if the display timer is running and cancel it
  2047         // check if the display timer is running and cancel it
  2011         if ( iDisplayTimer->IsActive() )
  2048         if ( iDisplayTimer->IsActive() )
  2012         {
  2049         {
  2013             iDisplayTimer->Cancel();
  2050             iDisplayTimer->Cancel();
  2014         }
  2051         }
  2015       
  2052 
  2016         MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() );
  2053         MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() );
  2017         
  2054 
  2018         iDisplayTimer->Start( displayTimeOut, displayTimeOut,
  2055         iDisplayTimer->Start( displayTimeOut, displayTimeOut,
  2019             TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) );
  2056             TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) );
  2020     }
  2057     }
  2021     
       
  2022 }
  2058 }
  2023 
  2059 
  2024 // -----------------------------------------------------------------------------
  2060 // -----------------------------------------------------------------------------
  2025 // CMPXVideoPlaybackController::CancelDisplayTimer
  2061 // CMPXVideoPlaybackController::CancelDisplayTimer
  2026 // -----------------------------------------------------------------------------
  2062 // -----------------------------------------------------------------------------
  2027 //
  2063 //
  2028 void CMPXVideoPlaybackController::CancelDisplayTimer() 
  2064 void CMPXVideoPlaybackController::CancelDisplayTimer()
  2029 {
  2065 {
  2030     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer"));
  2066     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer"));
  2031     
  2067 
  2032     if ( iDisplayTimer )
  2068     if ( iDisplayTimer )
  2033     {
  2069     {
  2034         if ( iDisplayTimer->IsActive() )
  2070         if ( iDisplayTimer->IsActive() )
  2035         {
  2071         {
  2036             iDisplayTimer->Cancel();
  2072             iDisplayTimer->Cancel();
  2069 
  2105 
  2070 
  2106 
  2071 //  ------------------------------------------------------------------------------------------------
  2107 //  ------------------------------------------------------------------------------------------------
  2072 //  CMPXVideoPlaybackController::EnableDisplayBacklight
  2108 //  CMPXVideoPlaybackController::EnableDisplayBacklight
  2073 //  ------------------------------------------------------------------------------------------------
  2109 //  ------------------------------------------------------------------------------------------------
  2074 // 
  2110 //
  2075 void CMPXVideoPlaybackController::EnableDisplayBacklight()
  2111 void CMPXVideoPlaybackController::EnableDisplayBacklight()
  2076 {
  2112 {
  2077     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()"));
  2113     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()"));
  2078     
  2114 
  2079     // ELightStatusUnknown - We are not controlling lights and we don't care about lights
  2115     // ELightStatusUnknown - We are not controlling lights and we don't care about lights
  2080     // ELightOn            - Ligths are certainly on 
  2116     // ELightOn            - Ligths are certainly on
  2081     MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus );
  2117     MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus );
  2082     
  2118 
  2083     // We are responsible of turning lights on only if we have switched them off.
  2119     // We are responsible of turning lights on only if we have switched them off.
  2084     if ( iLightStatus == CHWRMLight::ELightOff )
  2120     if ( iLightStatus == CHWRMLight::ELightOff )
  2085     {
  2121     {
  2086 
  2122 
  2087         MPX_TRAPD( err,
  2123         MPX_TRAPD( err,
  2088         {   
  2124         {
  2089             // Following GetLightsL() call will not leave.
  2125             // Following GetLightsL() call will not leave.
  2090             // This call should not result to creation of CHWRMLight in this case
  2126             // This call should not result to creation of CHWRMLight in this case
  2091             // because CHWRMLight was created when lights were turned off.
  2127             // because CHWRMLight was created when lights were turned off.
  2092             CHWRMLight* lights= GetLightsL();
  2128             CHWRMLight* lights= GetLightsL();
  2093             if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff )
  2129             if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff )
  2094             {
  2130             {
  2095                 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") );
  2131                 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") );
  2096 			
  2132 
  2097                 lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0  );
  2133                 lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0  );
  2098                 iLightStatus = CHWRMLight::ELightOn;
  2134                 iLightStatus = CHWRMLight::ELightOn;
  2099             }
  2135             }
  2100         } );
  2136         } );
  2101         
  2137     }
  2102     }
       
  2103    
       
  2104 }
  2138 }
  2105 
  2139 
  2106 //  ------------------------------------------------------------------------------------------------
  2140 //  ------------------------------------------------------------------------------------------------
  2107 //  CMPXVideoPlaybackController::DisableDisplayBacklight
  2141 //  CMPXVideoPlaybackController::DisableDisplayBacklight
  2108 //  ------------------------------------------------------------------------------------------------
  2142 //  ------------------------------------------------------------------------------------------------
  2109 // 
  2143 //
  2110 void CMPXVideoPlaybackController::DisableDisplayBacklight()
  2144 void CMPXVideoPlaybackController::DisableDisplayBacklight()
  2111 {
  2145 {
  2112     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()"));
  2146     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()"));
  2113        
  2147 
  2114     // No major harm done if following block leaves. Lights are left on
  2148     // No major harm done if following block leaves. Lights are left on
  2115     MPX_TRAPD( err,
  2149     MPX_TRAPD( err,
  2116     {  
  2150     {
  2117         CHWRMLight* lights = GetLightsL();
  2151         CHWRMLight* lights = GetLightsL();
  2118         if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn )
  2152         if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn )
  2119         {
  2153         {
  2120            MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") );
  2154            MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") );
  2121 		   
  2155 
  2122            lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0  );
  2156            lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0  );
  2123            iLightStatus = CHWRMLight::ELightOff;
  2157            iLightStatus = CHWRMLight::ELightOff;
  2124         }
  2158         }
  2125     } );
  2159     } );
  2126    
       
  2127 }
  2160 }
  2128 
  2161 
  2129 
  2162 
  2130 //  ------------------------------------------------------------------------------------------------
  2163 //  ------------------------------------------------------------------------------------------------
  2131 //  CMPXVideoPlaybackController::InitUserActivityTimer
  2164 //  CMPXVideoPlaybackController::InitUserActivityTimer
  2132 //  ------------------------------------------------------------------------------------------------
  2165 //  ------------------------------------------------------------------------------------------------
  2133 // 
  2166 //
  2134 void CMPXVideoPlaybackController::InitUserActivityTimerL()
  2167 void CMPXVideoPlaybackController::InitUserActivityTimerL()
  2135 {
  2168 {
  2136     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()"));
  2169     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()"));
  2137     
  2170 
  2138     iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard);
  2171     iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard);
  2139     
  2172 
  2140     // This timer will not run to the end. Timer will be canceled and reset at backlight timeout.    
  2173     // This timer will not run to the end. Timer will be canceled and reset at backlight timeout.
  2141     iUserActivityTimer->Start(
  2174     iUserActivityTimer->Start(
  2142         0,
  2175         0,
  2143         KMPXInactivityTimeout,
  2176         KMPXInactivityTimeout,
  2144         TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this ));
  2177         TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this ));
  2145     
       
  2146 }
  2178 }
  2147 
  2179 
  2148 //  ------------------------------------------------------------------------------------------------
  2180 //  ------------------------------------------------------------------------------------------------
  2149 //  CMPXVideoPlaybackController::RestartUserActivityTimer
  2181 //  CMPXVideoPlaybackController::RestartUserActivityTimer
  2150 //  ------------------------------------------------------------------------------------------------
  2182 //  ------------------------------------------------------------------------------------------------
  2151 // 
  2183 //
  2152 void CMPXVideoPlaybackController::RestartUserActivityTimer() 
  2184 void CMPXVideoPlaybackController::RestartUserActivityTimer()
  2153 {
  2185 {
  2154     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()"));
  2186     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()"));
  2155     
  2187 
  2156     if ( !iUserActivityTimer )
  2188     if ( !iUserActivityTimer )
  2157     {
  2189     {
  2158        // This is first call. Create and initialize timer
  2190        // This is first call. Create and initialize timer
  2159        MPX_TRAPD( err,
  2191        MPX_TRAPD( err,
  2160        {   
  2192        {
  2161            InitUserActivityTimerL();
  2193            InitUserActivityTimerL();
  2162        } );
  2194        } );
  2163        // If user activity timer creation fails we can't detect user activity and 
  2195 
  2164        // get lights back on when user taps screen. 
  2196        // If user activity timer creation fails we can't detect user activity and
       
  2197        // get lights back on when user taps screen.
  2165        // Leave lights on.
  2198        // Leave lights on.
  2166        if ( err != KErrNone )
  2199        if ( err != KErrNone )
  2167        { 
  2200        {
  2168            EnableDisplayBacklight(); 
  2201            EnableDisplayBacklight();
  2169        }  
  2202        }
  2170     }
  2203     }
  2171       
  2204 
  2172     if ( iUserActivityTimer )
  2205     if ( iUserActivityTimer )
  2173     {
  2206     {
  2174         if ( iUserActivityTimer->IsActive() )
  2207         if ( iUserActivityTimer->IsActive() )
  2175         {
  2208         {
  2176             iUserActivityTimer->Cancel();
  2209             iUserActivityTimer->Cancel();
  2177         }            
  2210         }
       
  2211 
  2178         // Not interested about inactivity callback, only activity
  2212         // Not interested about inactivity callback, only activity
  2179         // If CPeriodic::Inactivity is started with argument 0 
  2213         // If CPeriodic::Inactivity is started with argument 0
  2180         // timer will fire when system's user inactivity timer resets.
  2214         // timer will fire when system's user inactivity timer resets.
  2181         iUserActivityTimer->Inactivity( 0 );
  2215         iUserActivityTimer->Inactivity( 0 );
  2182     } 
  2216     }
  2183 }
  2217 }
  2184 
  2218 
  2185 //  ------------------------------------------------------------------------------------------------
  2219 //  ------------------------------------------------------------------------------------------------
  2186 //  CMPXVideoPlaybackController::CancelUserActivityTimer
  2220 //  CMPXVideoPlaybackController::CancelUserActivityTimer
  2187 //  ------------------------------------------------------------------------------------------------
  2221 //  ------------------------------------------------------------------------------------------------
  2188 // 
  2222 //
  2189 void CMPXVideoPlaybackController::CancelUserActivityTimer() 
  2223 void CMPXVideoPlaybackController::CancelUserActivityTimer()
  2190 {
  2224 {
  2191     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()"));
  2225     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()"));
  2192 	
  2226 
  2193     if  ( iUserActivityTimer ) 
  2227     if  ( iUserActivityTimer )
  2194     {   
  2228     {
  2195         if ( iUserActivityTimer->IsActive() )
  2229         if ( iUserActivityTimer->IsActive() )
  2196         {
  2230         {
  2197             iUserActivityTimer->Cancel();
  2231             iUserActivityTimer->Cancel();
  2198         }
  2232         }
  2199     }
  2233     }
  2200 }
  2234 }
  2201 
  2235 
  2202 //  ------------------------------------------------------------------------------------------------
  2236 //  ------------------------------------------------------------------------------------------------
  2203 //  CMPXVideoPlaybackController::HandleUserActivityTimeout
  2237 //  CMPXVideoPlaybackController::HandleUserActivityTimeout
  2204 //  ------------------------------------------------------------------------------------------------
  2238 //  ------------------------------------------------------------------------------------------------
  2205 // 
  2239 //
  2206 TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr )
  2240 TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr )
  2207 {
  2241 {
  2208     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()"));
  2242     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()"));
  2209 	
  2243 
  2210     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleUserActivityTimeout();
  2244     static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleUserActivityTimeout();
  2211     return KErrNone;     
  2245     return KErrNone;
  2212 }
  2246 }
  2213 
  2247 
  2214 //  ------------------------------------------------------------------------------------------------
  2248 //  ------------------------------------------------------------------------------------------------
  2215 //  CMPXVideoPlaybackController::DoHandleUserActivityTimeout
  2249 //  CMPXVideoPlaybackController::DoHandleUserActivityTimeout
  2216 //  ------------------------------------------------------------------------------------------------
  2250 //  ------------------------------------------------------------------------------------------------
  2217 // 
  2251 //
  2218 void CMPXVideoPlaybackController::DoHandleUserActivityTimeout()
  2252 void CMPXVideoPlaybackController::DoHandleUserActivityTimeout()
  2219 {
  2253 {
  2220     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()"));
  2254     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()"));
  2221     
  2255 
  2222     // Act only once for detected activity.
  2256     // Act only once for detected activity.
  2223     if ( iUserActivityTimer->IsActive() ) 
  2257     if ( iUserActivityTimer->IsActive() )
  2224     {
  2258     {
  2225         iUserActivityTimer->Cancel();
  2259         iUserActivityTimer->Cancel();
  2226     }
  2260     }
  2227     
  2261 
  2228     // iUserActivityTimer runs when TV-out is connected and playback with video is going on
  2262     // iUserActivityTimer runs when TV-out is connected and playback with video is going on
  2229     // This timer fires in two situations. 
  2263     // This timer fires in two situations.
  2230     // a) Lights are off and user activity is detected - Turn lights on and restart display timer
  2264     // a) Lights are off and user activity is detected - Turn lights on and restart display timer
  2231     // b) Lights are on and user activity is detected - restart display timer to prevent lights go off
  2265     // b) Lights are on and user activity is detected - restart display timer to prevent lights go off
  2232     EnableDisplayBacklight();
  2266     EnableDisplayBacklight();
  2233     
  2267 
  2234     // Start counting down to next lights off
  2268     // Start counting down to next lights off
  2235     RestartDisplayTimer();
  2269     RestartDisplayTimer();
  2236 }
  2270 }
  2237 
  2271 
  2238 //  ------------------------------------------------------------------------------------------------
  2272 //  ------------------------------------------------------------------------------------------------
  2240 //  ------------------------------------------------------------------------------------------------
  2274 //  ------------------------------------------------------------------------------------------------
  2241 //
  2275 //
  2242 CHWRMLight* CMPXVideoPlaybackController::GetLightsL()
  2276 CHWRMLight* CMPXVideoPlaybackController::GetLightsL()
  2243 {
  2277 {
  2244     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::GetLightsL()"));
  2278     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::GetLightsL()"));
  2245 	
  2279 
  2246     if ( !iLight ) 
  2280     if ( !iLight )
  2247     {
  2281     {
  2248         MPX_DEBUG( _L("CMPXVideoPlaybackController::GetLightsL() - creating") );
  2282         MPX_DEBUG( _L("CMPXVideoPlaybackController::GetLightsL() - creating") );
  2249         iLight = CHWRMLight::NewL();
  2283         iLight = CHWRMLight::NewL();
  2250     }
  2284     }
  2251     return iLight;
  2285     return iLight;
  2256 //  ------------------------------------------------------------------------------------------------
  2290 //  ------------------------------------------------------------------------------------------------
  2257 //
  2291 //
  2258 void CMPXVideoPlaybackController::ReleaseLights()
  2292 void CMPXVideoPlaybackController::ReleaseLights()
  2259 {
  2293 {
  2260     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ReleaseLights()"));
  2294     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ReleaseLights()"));
  2261 	
  2295 
  2262     if ( iLight )
  2296     if ( iLight )
  2263     {
  2297     {
  2264         // If iLights was created when ReleaseLights was called then TV out must be connected and lights may be off. 
  2298         // If iLights was created when ReleaseLights was called then TV out must be connected and lights may be off.
  2265         // This call ensures that lights are on again.
  2299         // This call ensures that lights are on again.
  2266         EnableDisplayBacklight();
  2300         EnableDisplayBacklight();
  2267 		
  2301 
  2268         MPX_DEBUG( _L("CMPXVideoPlaybackController::ReleaseLights() - deleting") );
  2302         MPX_DEBUG( _L("CMPXVideoPlaybackController::ReleaseLights() - deleting") );
  2269         delete iLight;
  2303         delete iLight;
  2270         iLight = NULL;
  2304         iLight = NULL;
  2271     }
  2305     }
  2272 }
  2306 }
  2377     if ( iFileHandle64.SubSessionHandle() )
  2411     if ( iFileHandle64.SubSessionHandle() )
  2378     {
  2412     {
  2379         iFileHandle64.Close();
  2413         iFileHandle64.Close();
  2380     }
  2414     }
  2381 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  2415 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  2382     
  2416 
  2383     // reset to True
  2417     // reset to True
  2384     iSeekable = ETrue;
  2418     iSeekable = ETrue;
  2385 
  2419 
  2386     //
  2420     //
  2387     //  Needs to be last thing destroyed since PDL requires the
  2421     //  Needs to be last thing destroyed since PDL requires the
  2482     }
  2516     }
  2483 
  2517 
  2484     DetermineMediaTypeL();
  2518     DetermineMediaTypeL();
  2485     SetPlaybackModeL();
  2519     SetPlaybackModeL();
  2486 
  2520 
  2487     iSavedPosition = aPosition; 
  2521     iSavedPosition = aPosition;
  2488     
  2522 
  2489     //
  2523     //
  2490     //  Create accessory monitor to search for TV-Out events
  2524     //  Create accessory monitor to search for TV-Out events
  2491     //
  2525     //
  2492     if ( ! iAccessoryMonitor )
  2526     if ( ! iAccessoryMonitor )
  2493     {
  2527     {