videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp
branchRCL_3
changeset 15 8f0df5c82986
parent 14 55fa1ec415c6
child 21 315810614048
equal deleted inserted replaced
14:55fa1ec415c6 15:8f0df5c82986
    14 * Description:  This class plays local video file
    14 * Description:  This class plays local video file
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 58 %
    19 // Version : %version: 62 %
    20 
    20 
    21 
    21 
    22 //
    22 //
    23 //  INCLUDE FILES
    23 //  INCLUDE FILES
    24 //
    24 //
   166     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   166     iBackLightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   167 
   167 
   168     iDrmHelper = CMpxVideoDrmHelper::NewL();
   168     iDrmHelper = CMpxVideoDrmHelper::NewL();
   169 
   169 
   170     iSavedPosition = 0;
   170     iSavedPosition = 0;
       
   171     iViewActivated  = EFalse;
   171 }
   172 }
   172 
   173 
   173 //  ----------------------------------------------------------------------------
   174 //  ----------------------------------------------------------------------------
   174 //  CMPXVideoPlaybackController::CloseController()
   175 //  CMPXVideoPlaybackController::CloseController()
   175 //  ----------------------------------------------------------------------------
   176 //  ----------------------------------------------------------------------------
   262 //    C++ constructor
   263 //    C++ constructor
   263 //  ----------------------------------------------------------------------------
   264 //  ----------------------------------------------------------------------------
   264 //
   265 //
   265 CMPXVideoPlaybackController::CMPXVideoPlaybackController()
   266 CMPXVideoPlaybackController::CMPXVideoPlaybackController()
   266     : iAppInForeground(ETrue)
   267     : iAppInForeground(ETrue)
   267     , iForegroundPause(EFalse)
       
   268     , iAllowAutoPlay(ETrue)
   268     , iAllowAutoPlay(ETrue)
   269     , iHelixLoadingStarted(EFalse)
   269     , iHelixLoadingStarted(EFalse)
   270     , iLightStatus(CHWRMLight::ELightStatusUnknown)
   270     , iLightStatus(CHWRMLight::ELightStatusUnknown)
   271 {
   271 {
   272 }
   272 }
   369         iFileHandle64.Close();
   369         iFileHandle64.Close();
   370     }
   370     }
   371 
   371 
   372 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   372 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   373 
   373 
       
   374     iViewActivated  = EFalse;
   374 }
   375 }
   375 
   376 
   376 //  ----------------------------------------------------------------------------
   377 //  ----------------------------------------------------------------------------
   377 //    Executes general playback commands supported by the playback FW
   378 //    Executes general playback commands supported by the playback FW
   378 //    CMPXVideoPlaybackController::HandleGeneralPlaybackCommandL()
   379 //    CMPXVideoPlaybackController::HandleGeneralPlaybackCommandL()
   537 
   538 
   538                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   539                 aCmd.SetTObjectValueL<TInt>( KMPXMediaVideoBufferingPercentage,
   539                                              bufferingPercentage );
   540                                              bufferingPercentage );
   540 
   541 
   541                 break;
   542                 break;
       
   543             }
       
   544             case EPbCmdSetPosterFrame:
       
   545             {
       
   546                 iState->HandleSetPosterFrame();
       
   547                 break;    
   542             }
   548             }
   543         }
   549         }
   544     }
   550     }
   545 }
   551 }
   546 
   552 
   877         else
   883         else
   878         {
   884         {
   879             volume = aVolume;
   885             volume = aVolume;
   880         }
   886         }
   881 
   887 
       
   888         //
       
   889         // Volume needs to have n number of steps.
       
   890         // For example, if we get 26, we need to save it as 25 in 20 volume steps
       
   891         // For example, if we get 77, we need to save it as 70 in 10 volume steps
       
   892         //
       
   893         volume -= volume % iVolumeNormalizer;
       
   894  
   882         MPX_DEBUG(
   895         MPX_DEBUG(
   883             _L("CMPXVideoPlaybackController::SetVolumeCenRepL(): Setting volume = %d"), volume );
   896             _L("CMPXVideoPlaybackController::SetVolumeCenRepL(): Setting volume = %d"), volume );
   884 
   897 
   885         if ( volume > 0 )
   898         iVolumeWatcher->SetValueL( volume );
   886         {
   899 
   887             //
   900         SetMuteCenRepL( volume > 0? EFalse: ETrue );
   888             // Media player's CenRep volume range : 0 - number of volume steps
       
   889             // MPX framework volume range : 0-100
       
   890             //
       
   891             iVolumeWatcher->SetValueL( volume / iVolumeNormalizer );
       
   892             SetMuteCenRepL( EFalse );
       
   893         }
       
   894         else
       
   895         {
       
   896             //
       
   897             // save both mute and current volume values in CenRep
       
   898             //
       
   899             iVolumeWatcher->SetValueL( 0 );
       
   900             SetMuteCenRepL( ETrue );
       
   901         }
       
   902     }
   901     }
   903     else
   902     else
   904     {
   903     {
   905         MPX_DEBUG(_L("CMPXVideoPlaybackController::SetVolumeCenRepL(): Audio isn't enabled"));
   904         MPX_DEBUG(_L("CMPXVideoPlaybackController::SetVolumeCenRepL(): Audio isn't enabled"));
   906     }
   905     }
   937     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SetVolumeMMFL()"));
   936     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SetVolumeMMFL()"));
   938 
   937 
   939     TInt volume = iVolumeWatcher->CurrentValueL();
   938     TInt volume = iVolumeWatcher->CurrentValueL();
   940     TBool mute = iMuteWatcher->CurrentValueL();
   939     TBool mute = iMuteWatcher->CurrentValueL();
   941 
   940 
   942     MPX_DEBUG(_L("CMPXVideoPlaybackController::SetVolumeMMFL() volume = %d, mute = %d")
   941     MPX_DEBUG(
       
   942             _L("CMPXVideoPlaybackController::SetVolumeMMFL() volume = %d, mute = %d")
   943             , volume, mute );
   943             , volume, mute );
   944 
   944 
   945     TInt newVolume = 0;
   945     TInt newVolume = 0;
   946 
   946 
   947     if ( ! mute )
   947     if ( ! mute )
   948     {
   948     {
   949         //
   949         //
   950         // If it was muted and previous volume level was 0, set the volume to 1
   950         // If it was muted and previous volume level was KPbPlaybackVolumeLevelMin, set the volume to next level
   951         //
   951         //
   952         if ( volume == 0 )
   952         if ( volume == KPbPlaybackVolumeLevelMin )
   953         {
   953         {
   954             volume++;
   954             volume = KPbPlaybackVolumeLevelMin + iVolumeNormalizer;
   955         }
   955         }
   956 
   956 
   957         newVolume =
   957         newVolume = volume * iFileDetails->iMaxVolume / KPbPlaybackVolumeLevelMax;
   958             volume  * iVolumeNormalizer * iFileDetails->iMaxVolume / KPbPlaybackVolumeLevelMax;
       
   959     }
   958     }
   960 
   959 
   961     MPX_DEBUG(_L("CMPXVideoPlaybackController::SetVolumeMMFL() new volume = %d"), newVolume );
   960     MPX_DEBUG(_L("CMPXVideoPlaybackController::SetVolumeMMFL() new volume = %d"), newVolume );
   962 
   961 
   963     //  Change MMF Audio player's volume
   962     //  Change MMF Audio player's volume
  1099         {
  1098         {
  1100             TInt volume = 0;
  1099             TInt volume = 0;
  1101 
  1100 
  1102             if ( ! iMuteWatcher->CurrentValueL() )
  1101             if ( ! iMuteWatcher->CurrentValueL() )
  1103             {
  1102             {
  1104                 volume = iVolumeWatcher->CurrentValueL() * iVolumeNormalizer;
  1103                 volume = iVolumeWatcher->CurrentValueL();
  1105             }
  1104             }
  1106 
  1105 
  1107             value = volume;
  1106             value = volume;
  1108 
  1107 
  1109             break;
  1108             break;
  1151 void CMPXVideoPlaybackController::SendMediaL( const TArray<TMPXAttribute>& aAttrs )
  1150 void CMPXVideoPlaybackController::SendMediaL( const TArray<TMPXAttribute>& aAttrs )
  1152 {
  1151 {
  1153     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::SendMediaL()"));
  1152     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::SendMediaL()"));
  1154 
  1153 
  1155     TInt retError = KErrNone;
  1154     TInt retError = KErrNone;
       
  1155 
       
  1156     iViewActivated = ETrue;
       
  1157 
       
  1158     iPlayer->SendSurfaceCreatedCommand();
  1156 
  1159 
  1157     RArray<TInt> suppIds;
  1160     RArray<TInt> suppIds;
  1158     CleanupClosePushL( suppIds );
  1161     CleanupClosePushL( suppIds );
  1159 
  1162 
  1160     suppIds.AppendL( KMPXMediaIdGeneral );
  1163     suppIds.AppendL( KMPXMediaIdGeneral );
  2305                                                 this );
  2308                                                 this );
  2306     }
  2309     }
  2307 
  2310 
  2308     //
  2311     //
  2309     // MPX framework volume range : 0-100
  2312     // MPX framework volume range : 0-100
  2310     // Media player volume range : 0-10
       
  2311     // MPX video player volume range : 0 - volume steps (defined in PlaybackHelper)
       
  2312     // For IAD, need to manipulate volume to save in cenrep
       
  2313     // MPX Framework volume / iVolumeNormalizer => CenRep
       
  2314     //
  2313     //
  2315     CDevSoundIf* devSoundIf = CDevSoundIf::NewL();
  2314     CDevSoundIf* devSoundIf = CDevSoundIf::NewL();
  2316     TInt volumeSteps =  devSoundIf->GetNumberOfVolumeSteps();
  2315     TInt volumeSteps =  devSoundIf->GetNumberOfVolumeSteps();
  2317     delete devSoundIf;
  2316     delete devSoundIf;
  2318 
  2317 
  2399     //  Reset the flag to retrieve the Buffering percentage from Helix
  2398     //  Reset the flag to retrieve the Buffering percentage from Helix
  2400     //
  2399     //
  2401     iHelixLoadingStarted = EFalse;
  2400     iHelixLoadingStarted = EFalse;
  2402 
  2401 
  2403     iSavedPosition = 0;
  2402     iSavedPosition = 0;
       
  2403 
       
  2404     iViewActivated  = EFalse;
  2404 }
  2405 }
  2405 
  2406 
  2406 //  ------------------------------------------------------------------------------------------------
  2407 //  ------------------------------------------------------------------------------------------------
  2407 //  CMPXVideoPlaybackController::HandleVolumeL
  2408 //  CMPXVideoPlaybackController::HandleVolumeL
  2408 //  ------------------------------------------------------------------------------------------------
  2409 //  ------------------------------------------------------------------------------------------------
  2410 void CMPXVideoPlaybackController::HandleVolumeL( TBool aIncrease )
  2411 void CMPXVideoPlaybackController::HandleVolumeL( TBool aIncrease )
  2411 {
  2412 {
  2412     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleVolumeL()"),
  2413     MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleVolumeL()"),
  2413                     _L("aIncrease = %d"), aIncrease );
  2414                     _L("aIncrease = %d"), aIncrease );
  2414 
  2415 
  2415     //
       
  2416     // Media player's CenRep volume range : 0 - number of volume steps
       
  2417     // MPX framework volume range : 0-100
       
  2418     //
       
  2419     TInt volume = iVolumeWatcher->CurrentValueL();
  2416     TInt volume = iVolumeWatcher->CurrentValueL();
  2420 
  2417     TInt diff = iVolumeNormalizer;
  2421     if ( aIncrease )
  2418 
  2422     {
  2419     if ( ! aIncrease )
  2423         //
  2420     {
  2424         // increase the current volume
  2421         diff *= -1;
  2425         //
  2422     }
  2426         volume++;
  2423 
  2427     }
  2424     volume += diff;
  2428     else if ( volume > 0 )
       
  2429     {
       
  2430         //
       
  2431         // decrease the current volume
       
  2432         //
       
  2433         volume--;
       
  2434     }
       
  2435 
  2425 
  2436     //
  2426     //
  2437     // save the current volume level in CenRep
  2427     // save the current volume level in CenRep
  2438     //
  2428     //
  2439     SetVolumeCenRepL( volume * iVolumeNormalizer );
  2429     SetVolumeCenRepL( volume );
  2440 }
  2430 }
  2441 
  2431 
  2442 //  ------------------------------------------------------------------------------------------------
  2432 //  ------------------------------------------------------------------------------------------------
  2443 //  CMPXVideoPlaybackController::SetVolumeSteps
  2433 //  CMPXVideoPlaybackController::SetVolumeSteps
  2444 //  ------------------------------------------------------------------------------------------------
  2434 //  ------------------------------------------------------------------------------------------------
  2530     }
  2520     }
  2531 }
  2521 }
  2532 
  2522 
  2533 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  2523 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  2534 
  2524 
       
  2525 //  ------------------------------------------------------------------------------------------------ 
       
  2526 //    CMPXVideoPlaybackController::IsViewActivated() 
       
  2527 //  ------------------------------------------------------------------------------------------------ 
       
  2528 // 
       
  2529 TBool CMPXVideoPlaybackController::IsViewActivated() 
       
  2530 { 
       
  2531     MPX_DEBUG(_L("CMPXVideoPlaybackController::IsViewActivated")); 
       
  2532     return iViewActivated; 
       
  2533 } 
       
  2534 
       
  2535 //  ------------------------------------------------------------------------------------------------
       
  2536 //    CMPXVideoPlaybackController::HandleFrameReady()
       
  2537 //  ------------------------------------------------------------------------------------------------
       
  2538 //
       
  2539 void CMPXVideoPlaybackController::HandleFrameReady(TInt aError)
       
  2540 {
       
  2541     MPX_DEBUG(_L("CMPXVideoPlaybackController::HandleFrameReady"));
       
  2542     
       
  2543     iPlaybackMode->HandleFrameReady(aError);
       
  2544 }
  2535 // End of file
  2545 // End of file