diff -r cf5481c2bc0b -r 69946d1824c4 videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp --- a/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Fri Apr 16 14:59:52 2010 +0300 +++ b/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Mon May 03 12:32:50 2010 +0300 @@ -15,7 +15,8 @@ * */ -// Version : %version: 50 % + +// Version : %version: 56 % // @@ -41,7 +42,7 @@ #include #include #include -#include +#include #include // For display timeout setting #include @@ -85,6 +86,8 @@ _LIT( KRightCopy, "Copyright" ); _LIT( KLanguage, "Language" ); _LIT( KKeywords, "Keywords" ); +_LIT( KCreated, "CreationTime" ); +_LIT( KLastModified, "ModificationTime" ); // ============================ MEMBER FUNCTIONS =================================================== @@ -164,7 +167,7 @@ iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard ); iDrmHelper = CMpxVideoDrmHelper::NewL(); - + iSavedPosition = 0; } @@ -185,7 +188,7 @@ void CMPXVideoPlaybackController::OpenFileL( const TDesC& aMediaFile, RFile& aFile, TInt aPosition, - TInt aAccessPointId ) + TInt aAccessPointId ) { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::OpenFileL()"), _L("file = %S"), &aMediaFile ); @@ -216,7 +219,7 @@ SetPlaybackModeL(); iSavedPosition = aPosition; - + // // Create accessory monitor to search for TV-Out events // @@ -349,16 +352,16 @@ delete iPlayer; iPlayer = NULL; } - + if ( iUserActivityTimer ) { iUserActivityTimer->Cancel(); delete iUserActivityTimer; iUserActivityTimer = NULL; } - + ReleaseLights(); - + CancelDisplayTimer(); #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API @@ -495,7 +498,7 @@ { iSeekable = aCmd.ValueTObjectL(KMPXMediaGeneralExtVideoSeekable); - if( iFileDetails ) + if ( iFileDetails ) { iFileDetails->iSeekable &= iSeekable; } @@ -545,15 +548,6 @@ break; } - case EPbCmdSurfaceRemoved: - { - iPlayer->SurfaceRemovedFromView(); - break; - } - default: - { - break; - } } } } @@ -1203,7 +1197,7 @@ case EMPXVideoPlaying: { iState = iPlayingState; - + // // If clip is audio only, stop the backlight timer and break switch // If clip has audio and video, proceed to the next case which will @@ -1217,7 +1211,7 @@ { CancelLightsControl(); } - + break; } case EMPXVideoPaused: @@ -1378,9 +1372,9 @@ if ( ! metaData->Name().CompareF( KSeekable ) ) { - if ( ! metaData->Value().CompareF( KTrue ) ) + if ( ! metaData->Value().CompareF( KFalse ) ) { - iFileDetails->iSeekable = ETrue; + iFileDetails->iSeekable = EFalse; } } else if ( ! metaData->Name().CompareF( KLiveStream ) ) @@ -1450,6 +1444,16 @@ { iFileDetails->iKeywords = metaData->Value().AllocL(); } + else if ( !metaData->Name().CompareF( KCreated ) ) + { + TLex lex( metaData->Value() ); + lex.Val( iFileDetails->iCreationTime ); + } + else if ( !metaData->Name().CompareF( KLastModified ) ) + { + TLex lex( metaData->Value() ); + lex.Val( iFileDetails->iModificationTime ); + } CleanupStack::PopAndDestroy( metaData ); } @@ -1751,9 +1755,9 @@ return alarm; } -// ----------------------------------------------------------------------------- -// CMPXVideoPlaybackController::IsKeyLocked -// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- +// CMPXVideoPlaybackController::IsKeyLocked +// ------------------------------------------------------------------------------------------------- // TBool CMPXVideoPlaybackController::IsKeyLocked() { @@ -1765,55 +1769,13 @@ return keylock; } -// ------------------------------------------------------------------------------------------------ -// CMPXVideoPlaybackController::HandleTvOutEventL() -// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------- +// CMPXVideoPlaybackController::SendTvOutEventL +// ------------------------------------------------------------------------------------------------- // -void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected ) +void CMPXVideoPlaybackController::SendTvOutEventL( TBool aConnected, TBool aPlaybackAllowed ) { - MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"), - _L("aConnected = %d"), aConnected ); - - TBool playbackAllowed = ETrue; - - if ( aConnected ) - { - // - // TV-Out accessory connected - // - if ( ! iAccessoryMonitor->IsTvOutPlaybackAllowed() ) - { - // - // Clip has DRM protection and TV-Out is connected - // Pause playback and display info note - // - DoHandleCommandL( EPbCmdPause ); - - playbackAllowed = EFalse; - - iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed ); - } - else - { - // If lights are being controlled enable display timer so that screen backlight will be turned - // of after timeout. - if ( iBackLightTimer->IsActive() ) - { - RestartDisplayTimer(); - } - } - } - else - { - // TV out disconnected - CancelDisplayTimer(); - - // Ensure that lights are on after this - ReleaseLights(); - - // Pause playback since TV-Out accessory has been disconnected. - DoHandleCommandL( EPbCmdPause ); - } + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendTvOutEventL()")); // // Send notice to the playback view with TV-Out connection status @@ -1826,7 +1788,32 @@ message->SetTObjectValueL ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent ); message->SetTObjectValueL( KMPXMediaVideoTvOutConnected, aConnected ); - message->SetTObjectValueL( KMPXMediaVideoTvOutPlayAllowed, playbackAllowed ); + message->SetTObjectValueL( KMPXMediaVideoTvOutPlayAllowed, aPlaybackAllowed ); + + iMPXPluginObs->HandlePlaybackMessage( message, KErrNone ); + + CleanupStack::PopAndDestroy( message ); +} + +// ------------------------------------------------------------------------------------------------- +// CMPXVideoPlaybackController::SendHideControlsEventL +// ------------------------------------------------------------------------------------------------- +// +void CMPXVideoPlaybackController::SendHideControlsEventL() +{ + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendHideControlsEventL()")); + + // + // Send notice to the playback view to hide the controls + // when key lock + // + CMPXMessage* message = CMPXMessage::NewL(); + CleanupStack::PushL( message ); + + message->SetTObjectValueL( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); + + message->SetTObjectValueL + ( KMPXMediaVideoPlaybackCommand, EPbCmdHideControls ); iMPXPluginObs->HandlePlaybackMessage( message, KErrNone ); @@ -1834,6 +1821,60 @@ } // ------------------------------------------------------------------------------------------------ +// CMPXVideoPlaybackController::HandleTvOutEventL() +// ------------------------------------------------------------------------------------------------ +// +void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected ) +{ + MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"), + _L("aConnected = %d"), aConnected ); + + TBool playbackAllowed = iAccessoryMonitor->IsTvOutPlaybackAllowed(); + + SendTvOutEventL( aConnected, playbackAllowed ); + + // + // Check playback status of clip with new Tv-Out status + // + if ( aConnected ) + { + // + // TV-Out accessory connected + // + if ( ! playbackAllowed ) + { + // + // Clip has DRM protection and TV-Out is connected + // Pause playback and display info note + // + DoHandleCommandL( EPbCmdPause ); + + iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed ); + } + else + { + // If lights are being controlled enable display timer so that screen backlight will be turned + // of after timeout. + if ( iBackLightTimer->IsActive() ) + { + RestartDisplayTimer(); + } + } + } + else + { + // TV out disconnected + CancelDisplayTimer(); + + // Ensure that lights are on after this + ReleaseLights(); + + // Pause playback since TV-Out accessory has been disconnected. + DoHandleCommandL( EPbCmdPause ); + } +} + +// ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::CancelBackLightTimer // ------------------------------------------------------------------------------------------------ void CMPXVideoPlaybackController::CancelBackLightTimer() @@ -1844,7 +1885,6 @@ { iBackLightTimer->Cancel(); } - } // ------------------------------------------------------------------------------------------------ @@ -1861,7 +1901,6 @@ KMPXBackLightTimeOut, TCallBack( CMPXVideoPlaybackController::HandleBackLightTimeout, this )); } - } // ------------------------------------------------------------------------------------------------- @@ -1881,13 +1920,13 @@ void CMPXVideoPlaybackController::DoHandleBackLightTimeout() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleBackLightTimeout()")); - + TBool tvOutConnected( EFalse ); if ( iAccessoryMonitor ) { tvOutConnected = iAccessoryMonitor->IsTvOutConnected(); } - + // User activity timer runs always when TV-out is connected // it keeps resetting display timer and keeps lights on whenever there is user activity if ( tvOutConnected ) @@ -1896,9 +1935,9 @@ // Cancel activity timer. Otherwise resetting inactivity time would fire user activity detection CancelUserActivityTimer(); } - + User::ResetInactivityTime(); - + if ( tvOutConnected ) { // Restart user activity timer. It must be running between backlight timer intervals so that backlight @@ -1916,7 +1955,7 @@ MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::StartLightsControl()")); StartBackLightTimer(); - + if (iAccessoryMonitor ) { if ( iAccessoryMonitor->IsTvOutConnected() ) @@ -1933,21 +1972,21 @@ void CMPXVideoPlaybackController::CancelLightsControl() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()")); - + // This is called whenever there is no need to keep screensaver of anymore - // This means that also displaytimer and activity monitoring can be stopped. + // This means that also displaytimer and activity monitoring can be stopped. // This method is not correct place for these calls CancelBackLightTimer(); - + CancelUserActivityTimer(); - + CancelDisplayTimer(); - + // Ensure that lights are on EnableDisplayBacklight(); - - // Release lights if releserved - ReleaseLights(); + + // Release lights if releserved + ReleaseLights(); } @@ -1958,23 +1997,22 @@ TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()")); - + if ( !iDisplayTimer ) { iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard ); - - MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") ); - + + MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") ); } - + if ( iDisplayTimerTimeout.Int() == 0 ) { // Get the display light time-out value from CenRep - CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); + CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); // What's the timeout value (in seconds ) for the display light? TInt displayTimeOut ( 0 ); repository->Get( KDisplayLightsTimeout, displayTimeOut ); - + if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt ) { iDisplayTimerTimeout = KMaxTInt; @@ -1983,15 +2021,14 @@ { iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond; } - + CleanupStack::PopAndDestroy( repository ); - } - - + } + MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() ); - + // Convert the timeout value to microseconds - return iDisplayTimerTimeout; + return iDisplayTimerTimeout; } // ----------------------------------------------------------------------------- @@ -2006,29 +2043,28 @@ // Leave system to safe state if following leaves. Lights stay on MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); ) if ( err == KErrNone ) - { + { // check if the display timer is running and cancel it if ( iDisplayTimer->IsActive() ) { iDisplayTimer->Cancel(); } - + MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() ); - + iDisplayTimer->Start( displayTimeOut, displayTimeOut, TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) ); } - } // ----------------------------------------------------------------------------- // CMPXVideoPlaybackController::CancelDisplayTimer // ----------------------------------------------------------------------------- // -void CMPXVideoPlaybackController::CancelDisplayTimer() +void CMPXVideoPlaybackController::CancelDisplayTimer() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer")); - + if ( iDisplayTimer ) { if ( iDisplayTimer->IsActive() ) @@ -2071,21 +2107,21 @@ // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::EnableDisplayBacklight // ------------------------------------------------------------------------------------------------ -// +// void CMPXVideoPlaybackController::EnableDisplayBacklight() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()")); - + // ELightStatusUnknown - We are not controlling lights and we don't care about lights - // ELightOn - Ligths are certainly on + // ELightOn - Ligths are certainly on MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus ); - + // We are responsible of turning lights on only if we have switched them off. if ( iLightStatus == CHWRMLight::ELightOff ) { MPX_TRAPD( err, - { + { // Following GetLightsL() call will not leave. // This call should not result to creation of CHWRMLight in this case // because CHWRMLight was created when lights were turned off. @@ -2093,105 +2129,103 @@ if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff ) { MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") ); - + lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0 ); iLightStatus = CHWRMLight::ELightOn; } } ); - } - } // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::DisableDisplayBacklight // ------------------------------------------------------------------------------------------------ -// +// void CMPXVideoPlaybackController::DisableDisplayBacklight() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()")); - + // No major harm done if following block leaves. Lights are left on MPX_TRAPD( err, - { + { CHWRMLight* lights = GetLightsL(); if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn ) { MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") ); - + lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0 ); iLightStatus = CHWRMLight::ELightOff; } } ); - } // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::InitUserActivityTimer // ------------------------------------------------------------------------------------------------ -// +// void CMPXVideoPlaybackController::InitUserActivityTimerL() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()")); - + iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard); - - // This timer will not run to the end. Timer will be canceled and reset at backlight timeout. + + // This timer will not run to the end. Timer will be canceled and reset at backlight timeout. iUserActivityTimer->Start( 0, KMPXInactivityTimeout, TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this )); - } // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::RestartUserActivityTimer // ------------------------------------------------------------------------------------------------ -// -void CMPXVideoPlaybackController::RestartUserActivityTimer() +// +void CMPXVideoPlaybackController::RestartUserActivityTimer() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()")); - + if ( !iUserActivityTimer ) { // This is first call. Create and initialize timer MPX_TRAPD( err, - { + { InitUserActivityTimerL(); } ); - // If user activity timer creation fails we can't detect user activity and - // get lights back on when user taps screen. + + // If user activity timer creation fails we can't detect user activity and + // get lights back on when user taps screen. // Leave lights on. if ( err != KErrNone ) - { - EnableDisplayBacklight(); - } + { + EnableDisplayBacklight(); + } } - + if ( iUserActivityTimer ) { if ( iUserActivityTimer->IsActive() ) { iUserActivityTimer->Cancel(); - } + } + // Not interested about inactivity callback, only activity - // If CPeriodic::Inactivity is started with argument 0 + // If CPeriodic::Inactivity is started with argument 0 // timer will fire when system's user inactivity timer resets. iUserActivityTimer->Inactivity( 0 ); - } + } } // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::CancelUserActivityTimer // ------------------------------------------------------------------------------------------------ -// -void CMPXVideoPlaybackController::CancelUserActivityTimer() +// +void CMPXVideoPlaybackController::CancelUserActivityTimer() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()")); - - if ( iUserActivityTimer ) - { + + if ( iUserActivityTimer ) + { if ( iUserActivityTimer->IsActive() ) { iUserActivityTimer->Cancel(); @@ -2202,35 +2236,35 @@ // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::HandleUserActivityTimeout // ------------------------------------------------------------------------------------------------ -// +// TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr ) { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()")); - + static_cast(aPtr)->DoHandleUserActivityTimeout(); - return KErrNone; + return KErrNone; } // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackController::DoHandleUserActivityTimeout // ------------------------------------------------------------------------------------------------ -// +// void CMPXVideoPlaybackController::DoHandleUserActivityTimeout() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()")); - + // Act only once for detected activity. - if ( iUserActivityTimer->IsActive() ) + if ( iUserActivityTimer->IsActive() ) { iUserActivityTimer->Cancel(); } - + // iUserActivityTimer runs when TV-out is connected and playback with video is going on - // This timer fires in two situations. + // This timer fires in two situations. // a) Lights are off and user activity is detected - Turn lights on and restart display timer // b) Lights are on and user activity is detected - restart display timer to prevent lights go off EnableDisplayBacklight(); - + // Start counting down to next lights off RestartDisplayTimer(); } @@ -2242,8 +2276,8 @@ CHWRMLight* CMPXVideoPlaybackController::GetLightsL() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::GetLightsL()")); - - if ( !iLight ) + + if ( !iLight ) { MPX_DEBUG( _L("CMPXVideoPlaybackController::GetLightsL() - creating") ); iLight = CHWRMLight::NewL(); @@ -2258,13 +2292,13 @@ void CMPXVideoPlaybackController::ReleaseLights() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::ReleaseLights()")); - + if ( iLight ) { - // If iLights was created when ReleaseLights was called then TV out must be connected and lights may be off. + // If iLights was created when ReleaseLights was called then TV out must be connected and lights may be off. // This call ensures that lights are on again. EnableDisplayBacklight(); - + MPX_DEBUG( _L("CMPXVideoPlaybackController::ReleaseLights() - deleting") ); delete iLight; iLight = NULL; @@ -2379,7 +2413,7 @@ iFileHandle64.Close(); } #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API - + // reset to True iSeekable = ETrue; @@ -2484,8 +2518,8 @@ DetermineMediaTypeL(); SetPlaybackModeL(); - iSavedPosition = aPosition; - + iSavedPosition = aPosition; + // // Create accessory monitor to search for TV-Out events //