--- a/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Wed Mar 31 21:34:36 2010 +0300
+++ b/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Wed Apr 14 15:59:50 2010 +0300
@@ -15,7 +15,8 @@
*
*/
-// Version : %version: 50 %
+
+// Version : %version: 52 %
//
@@ -41,7 +42,7 @@
#include <e32std.h>
#include <devsoundif.h>
#include <avkondomainpskeys.h>
-#include <hwrmlight.h>
+#include <hwrmlight.h>
#include <centralrepository.h> // For display timeout setting
#include <hwrmlightdomaincrkeys.h>
@@ -164,7 +165,7 @@
iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
iDrmHelper = CMpxVideoDrmHelper::NewL();
-
+
iSavedPosition = 0;
}
@@ -185,7 +186,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 +217,7 @@
SetPlaybackModeL();
iSavedPosition = aPosition;
-
+
//
// Create accessory monitor to search for TV-Out events
//
@@ -349,16 +350,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 +496,7 @@
{
iSeekable = aCmd.ValueTObjectL<TBool>(KMPXMediaGeneralExtVideoSeekable);
- if( iFileDetails )
+ if ( iFileDetails )
{
iFileDetails->iSeekable &= iSeekable;
}
@@ -1203,7 +1204,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 +1218,7 @@
{
CancelLightsControl();
}
-
+
break;
}
case EMPXVideoPaused:
@@ -1378,9 +1379,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 ) )
@@ -1751,9 +1752,9 @@
return alarm;
}
-// -----------------------------------------------------------------------------
-// CMPXVideoPlaybackController::IsKeyLocked
-// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
+// CMPXVideoPlaybackController::IsKeyLocked
+// -------------------------------------------------------------------------------------------------
//
TBool CMPXVideoPlaybackController::IsKeyLocked()
{
@@ -1765,55 +1766,13 @@
return keylock;
}
-// ------------------------------------------------------------------------------------------------
-// CMPXVideoPlaybackController::HandleTvOutEventL()
-// ------------------------------------------------------------------------------------------------
+// -------------------------------------------------------------------------------------------------
+// CMPXVideoPlaybackController::SendTvOutEventL
+// -------------------------------------------------------------------------------------------------
//
-void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected )
+TBool 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 +1785,7 @@
message->SetTObjectValueL<TMPXVideoPlaybackCommand>
( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent );
message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, aConnected );
- message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, playbackAllowed );
+ message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, aPlaybackAllowed );
iMPXPluginObs->HandlePlaybackMessage( message, KErrNone );
@@ -1834,6 +1793,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 +1857,6 @@
{
iBackLightTimer->Cancel();
}
-
}
// ------------------------------------------------------------------------------------------------
@@ -1861,7 +1873,6 @@
KMPXBackLightTimeOut,
TCallBack( CMPXVideoPlaybackController::HandleBackLightTimeout, this ));
}
-
}
// -------------------------------------------------------------------------------------------------
@@ -1881,13 +1892,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 +1907,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 +1927,7 @@
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::StartLightsControl()"));
StartBackLightTimer();
-
+
if (iAccessoryMonitor )
{
if ( iAccessoryMonitor->IsTvOutConnected() )
@@ -1933,21 +1944,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 +1969,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 +1993,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 +2015,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 +2079,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 +2101,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 +2208,35 @@
// ------------------------------------------------------------------------------------------------
// CMPXVideoPlaybackController::HandleUserActivityTimeout
// ------------------------------------------------------------------------------------------------
-//
+//
TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr )
{
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()"));
-
+
static_cast<CMPXVideoPlaybackController*>(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 +2248,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 +2264,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 +2385,7 @@
iFileHandle64.Close();
}
#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
-
+
// reset to True
iSeekable = ETrue;
@@ -2484,8 +2490,8 @@
DetermineMediaTypeL();
SetPlaybackModeL();
- iSavedPosition = aPosition;
-
+ iSavedPosition = aPosition;
+
//
// Create accessory monitor to search for TV-Out events
//