camerauis/cameraapp/generic/src/CamAppController.cpp
branchRCL_3
changeset 12 8c55c525d5d7
parent 11 792dfc98fb3b
child 16 d486e5e3cc9a
equal deleted inserted replaced
11:792dfc98fb3b 12:8c55c525d5d7
  5640 // ---------------------------------------------------------------------------
  5640 // ---------------------------------------------------------------------------
  5641 //
  5641 //
  5642 void CCamAppController::GenerateNextVideoFilePathL( TBool aForcePhoneMem )
  5642 void CCamAppController::GenerateNextVideoFilePathL( TBool aForcePhoneMem )
  5643   {
  5643   {
  5644   PRINT1( _L( "Camera => CCamAppController::GenerateNextVideoFilePathL, force phone mem:%d" ), aForcePhoneMem )    
  5644   PRINT1( _L( "Camera => CCamAppController::GenerateNextVideoFilePathL, force phone mem:%d" ), aForcePhoneMem )    
       
  5645   if( aForcePhoneMem )
       
  5646     {
       
  5647     ForceUsePhoneMemoryL( ETrue );
       
  5648     }
  5645   TInt store = IntegerSettingValue( ECamSettingItemVideoMediaStorage ); 
  5649   TInt store = IntegerSettingValue( ECamSettingItemVideoMediaStorage ); 
  5646   
  5650   
  5647   TBuf<KMaxExtension> extension;        
  5651   TBuf<KMaxExtension> extension;        
  5648 
  5652 
  5649 #ifdef __WINS__
  5653 #ifdef __WINS__
  5935          {
  5939          {
  5936          PRINT( _L("Camera <> CCamAppController::HandleSaveEvent .. Saving started") );
  5940          PRINT( _L("Camera <> CCamAppController::HandleSaveEvent .. Saving started") );
  5937          OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_APP_PREP_FOR_NEXT_SHOT 1" ); //CCORAPP_PREP_FOR_NEXT_SHOT_START      
  5941          OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_APP_PREP_FOR_NEXT_SHOT 1" ); //CCORAPP_PREP_FOR_NEXT_SHOT_START      
  5938          HandleCaptureCompletion();
  5942          HandleCaptureCompletion();
  5939          NotifyControllerObservers( ECamEventCaptureComplete, KErrNone );
  5943          NotifyControllerObservers( ECamEventCaptureComplete, KErrNone );
       
  5944          iSaveStarted = ETrue;
  5940          NotifyControllerObservers( ECamEventSaveComplete );
  5945          NotifyControllerObservers( ECamEventSaveComplete );
  5941          iCaptureRequested = EFalse;
  5946          iCaptureRequested = EFalse;
  5942          iSaveStarted = ETrue;
       
  5943          OstTrace0( CAMERAAPP_PERFORMANCE, DUP4_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_APP_PREP_FOR_NEXT_SHOT 0" ); //CCORAPP_PREP_FOR_NEXT_SHOT_END
  5947          OstTrace0( CAMERAAPP_PERFORMANCE, DUP4_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_APP_PREP_FOR_NEXT_SHOT 0" ); //CCORAPP_PREP_FOR_NEXT_SHOT_END
  5944          OstTrace0( CAMERAAPP_PERFORMANCE, DUP5_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_PRI_SHOT_TO_SHOT 0" ); //CCORAPP_PRI_SHOT_TO_SHOT_END   
  5948          OstTrace0( CAMERAAPP_PERFORMANCE, DUP5_CCAMAPPCONTROLLER_HANDLESAVEEVENT, "e_CAM_PRI_SHOT_TO_SHOT 0" ); //CCORAPP_PRI_SHOT_TO_SHOT_END   
  5945          }
  5949          }
  5946      }
  5950      }
  5947      
  5951      
  6178   // No error reported
  6182   // No error reported
  6179   else
  6183   else
  6180     {
  6184     {
  6181     PRINT( _L("Camera <> CCamAppController: status in KErrNone..") );
  6185     PRINT( _L("Camera <> CCamAppController: status in KErrNone..") );
  6182     __ASSERT_ALWAYS( aBitmap, CamPanic( ECamPanicNullPointer ) );
  6186     __ASSERT_ALWAYS( aBitmap, CamPanic( ECamPanicNullPointer ) );
  6183 
  6187     
       
  6188     // The secondary camera postcapture snapshot is rotated here. 
       
  6189     // Due to the viewfinder mirroring along the landscape axis the 
       
  6190     // portrait (or upside down portrait) postcapture snapshot would 
       
  6191     // otherwise be upside down.
       
  6192     // This affects the snapshot seen in postcapture view.
       
  6193    
  6184     if( iInfo.iActiveCamera == ECamActiveCameraSecondary &&
  6194     if( iInfo.iActiveCamera == ECamActiveCameraSecondary &&
  6185         iCaptureOrientation == ECamOrientation90 &&
  6195         iCaptureOrientation == ECamOrientation180 &&
  6186         ECamSettOn == IntegerSettingValue( ECamSettingItemShowCapturedPhoto ) )
  6196         ECamSettOn == IntegerSettingValue( ECamSettingItemShowCapturedPhoto ) )
  6187         {
  6197         {
  6188         PRINT( _L( "Camera <> Rotate portrait secondary camera snapshot image 180 degrees" ) )
  6198         PRINT( _L( "Camera <> Rotate portrait secondary camera snapshot image 180 degrees" ) )
  6189         TRAP_IGNORE( iSnapShotRotator->RotateL( aBitmap ) );
  6199         TRAP_IGNORE( iSnapShotRotator->RotateL( aBitmap ) );
  6190         }
  6200         }
  6327         if ( ECamImageCaptureBurst == iInfo.iImageMode )
  6337         if ( ECamImageCaptureBurst == iInfo.iImageMode )
  6328           {          
  6338           {          
  6329           NotifyControllerObservers( ECamEventImageData );  
  6339           NotifyControllerObservers( ECamEventImageData );  
  6330           }
  6340           }
  6331         PRINT1( _L("Camera <> CCamAppController::HandleImageCaptureEventL array count:%d"), BurstCaptureArray()->Count() );  
  6341         PRINT1( _L("Camera <> CCamAppController::HandleImageCaptureEventL array count:%d"), BurstCaptureArray()->Count() );  
       
  6342 
       
  6343         // Snapshots are rotated here if necessary, so that the thumbnails created by 
       
  6344         // ThumbNailManager accurately represent the actual images.
       
  6345         // This affects the thumbnails seen in Photos.
       
  6346         
  6332         // check if snapshot bitmap needs to be rotated before creating a thumbnail from it
  6347         // check if snapshot bitmap needs to be rotated before creating a thumbnail from it
  6333         TBool rotate( ( ECamSettOn == iSettingsModel->IntegerSettingValue( ECamSettingItemImageRotation ) || 
  6348         TBool rotate( ( ECamSettOn == iSettingsModel->IntegerSettingValue( ECamSettingItemImageRotation ) || 
  6334                       iInfo.iActiveCamera == ECamActiveCameraSecondary ) &&
  6349                       iInfo.iActiveCamera == ECamActiveCameraSecondary ) &&
  6335                       ECamSettOn == IntegerSettingValue( ECamSettingItemShowCapturedPhoto ) &&
  6350                       ECamSettOn == IntegerSettingValue( ECamSettingItemShowCapturedPhoto ) &&
  6336                       iCaptureOrientation != ECamOrientation0 );
  6351                       iCaptureOrientation != ECamOrientation0 );
  7402     PRINT3( _L("Camera => CCamAppController::DataReceived aChannel %d aCount %d aDataLost %d"), 
  7417     PRINT3( _L("Camera => CCamAppController::DataReceived aChannel %d aCount %d aDataLost %d"), 
  7403                 aChannel.GetChannelInfo().iChannelType, aCount, aDataLost );
  7418                 aChannel.GetChannelInfo().iChannelType, aCount, aDataLost );
  7404 
  7419 
  7405     if ( KSensrvChannelTypeIdOrientationData == aChannel.GetChannelInfo().iChannelType )
  7420     if ( KSensrvChannelTypeIdOrientationData == aChannel.GetChannelInfo().iChannelType )
  7406         {
  7421         {
       
  7422         // Rotation is used in primary camera whenever the feature is enabled by user.
       
  7423         // A rotation is always set for secondary camera in portrait and upside down
       
  7424         // portrait orientations due to the the viewfinder mirroring along the landscape axis.
       
  7425         // This affects the final JPEG file.
  7407         TBool rotate( ECamSettOn == iSettingsModel->IntegerSettingValue( ECamSettingItemImageRotation ) 
  7426         TBool rotate( ECamSettOn == iSettingsModel->IntegerSettingValue( ECamSettingItemImageRotation ) 
  7408                       || iInfo.iActiveCamera == ECamActiveCameraSecondary );
  7427                       || iInfo.iActiveCamera == ECamActiveCameraSecondary );
  7409 
  7428 
  7410         if( rotate )
  7429         if( rotate )
  7411             {
  7430             {
  7412             TSensrvOrientationData orientationData;
  7431             TSensrvOrientationData orientationData;
  7413             TPckg<TSensrvOrientationData> orientationPackage( orientationData );
  7432             TPckg<TSensrvOrientationData> orientationPackage( orientationData );
  7414             aChannel.GetData( orientationPackage );
  7433             aChannel.GetData( orientationPackage );
  7415 
  7434 
  7416             iImageOrientation =
  7435             iImageOrientation =
  7417                 MapSensorOrientatio2CamOrientation( orientationData.iDeviceOrientation, iLastImageOrientation );
  7436                 MapSensorOrientatio2CamOrientation( orientationData.iDeviceOrientation, 
       
  7437                                                     iLastImageOrientation, 
       
  7438                                                     iInfo.iActiveCamera );
  7418             }
  7439             }
  7419         else
  7440         else
  7420             {
  7441             {
  7421             // If "rotate images" setting is OFF, set "no rotation" value
  7442             // If "rotate images" setting is OFF, set "no rotation" value
  7422             iImageOrientation = ECamOrientation0;
  7443             iImageOrientation = ECamOrientation0;
  7527 // MapSensorOrientatio2CamOrientation
  7548 // MapSensorOrientatio2CamOrientation
  7528 // ---------------------------------------------------------------------------
  7549 // ---------------------------------------------------------------------------
  7529 //
  7550 //
  7530 TCamImageOrientation 
  7551 TCamImageOrientation 
  7531 CCamAppController::MapSensorOrientatio2CamOrientation( 
  7552 CCamAppController::MapSensorOrientatio2CamOrientation( 
  7532     const TSensrvOrientationData::TSensrvDeviceOrientation& aSensorOrientation, TCamImageOrientation aLastImageOrientation )
  7553     const TSensrvOrientationData::TSensrvDeviceOrientation& aSensorOrientation, TCamImageOrientation aLastImageOrientation,
       
  7554     TCamActiveCamera aActiveCamera )
  7533     {
  7555     {
  7534     PRINT1 ( _L("Camera => CCamAppController::MapSensorOrientatio2CamOrientation aSensorOrientation: %d"), aSensorOrientation );   
  7556     PRINT1 ( _L("Camera => CCamAppController::MapSensorOrientatio2CamOrientation aSensorOrientation: %d"), aSensorOrientation );   
  7535 
  7557 
  7536     TCamImageOrientation cameraOrientation( ECamOrientation0 );
  7558     TCamImageOrientation cameraOrientation( ECamOrientation0 );
  7537 
  7559 
  7538     switch( aSensorOrientation )
  7560     // Primary camera rotation
       
  7561     if ( aActiveCamera == ECamActiveCameraPrimary ) 
       
  7562       {
       
  7563       switch( aSensorOrientation )
  7539         {        
  7564         {        
  7540         case TSensrvOrientationData::EOrientationDisplayUpwards:
  7565         case TSensrvOrientationData::EOrientationDisplayUpwards:
  7541             // If coming from upside down portrait...
  7566             // If coming from upside down portrait...
  7542             if ( ECamOrientation270 == aLastImageOrientation )
  7567             if ( ECamOrientation270 == aLastImageOrientation )
  7543               {
  7568               {
  7592             break;
  7617             break;
  7593         default:
  7618         default:
  7594             PRINT( _L("Camera <> Unexpected orientation value") );
  7619             PRINT( _L("Camera <> Unexpected orientation value") );
  7595             break;
  7620             break;
  7596         }
  7621         }
       
  7622       }
       
  7623     // Secondary camera rotations
       
  7624     else if ( aActiveCamera == ECamActiveCameraSecondary )
       
  7625       {
       
  7626       if ( aSensorOrientation == TSensrvOrientationData::EOrientationDisplayUp ) // Portrait
       
  7627         {
       
  7628         cameraOrientation = ECamOrientation180; 
       
  7629         }
       
  7630       else if ( aSensorOrientation == TSensrvOrientationData::EOrientationDisplayDown )  // Upside down portrait
       
  7631         {
       
  7632         cameraOrientation = ECamOrientation180;
       
  7633         }
       
  7634       else
       
  7635         {
       
  7636         cameraOrientation = ECamOrientation0;
       
  7637         }
       
  7638       }
       
  7639       
  7597     PRINT1( _L("Camera <= CCamAppController::MapSensorOrientatio2CamOrientation, return [%s]"), 
  7640     PRINT1( _L("Camera <= CCamAppController::MapSensorOrientatio2CamOrientation, return [%s]"), 
  7598             KCamOrientationNames[cameraOrientation] );
  7641             KCamOrientationNames[cameraOrientation] );
  7599 
  7642 
  7600     return cameraOrientation;
  7643     return cameraOrientation;
  7601     }
  7644     }
  7602 
  7645 
  7603 // ---------------------------------------------------------------------------
  7646 // ---------------------------------------------------------------------------
  7604 // MapSensorOrientatio2CamOrientation
  7647 // MapCamOrientation2RotationAngle
  7605 // ---------------------------------------------------------------------------
  7648 // ---------------------------------------------------------------------------
  7606 //
  7649 //
  7607 CBitmapRotator::TRotationAngle 
  7650 CBitmapRotator::TRotationAngle 
  7608 CCamAppController::MapCamOrientation2RotationAngle( 
  7651 CCamAppController::MapCamOrientation2RotationAngle( 
  7609                    const TCamImageOrientation aOrientation )
  7652                    const TCamImageOrientation aOrientation )
 10168 // CalculateVideoTimeRemainingL
 10211 // CalculateVideoTimeRemainingL
 10169 //
 10212 //
 10170 // ---------------------------------------------------------------------------
 10213 // ---------------------------------------------------------------------------
 10171 //
 10214 //
 10172 TTimeIntervalMicroSeconds
 10215 TTimeIntervalMicroSeconds
 10173 CCamAppController::CalculateVideoTimeRemainingL(const TCamMediaStorage aStorage)
 10216 CCamAppController::CalculateVideoTimeRemainingL( TCamMediaStorage aStorage )
 10174   {
 10217   {
 10175   RFs& fs = CEikonEnv::Static()->FsSession();
 10218   RFs& fs = CEikonEnv::Static()->FsSession();
 10176   TInt drive = 0;
 10219   TInt drive = 0;
       
 10220   // Check if setting the new video path is pending. The path may not have been 
       
 10221   // set if camera controller was busy or video mode not initialized. This 
       
 10222   // happens e.g. while in Settings menu.
       
 10223   // If yes, use the storage media that is going to be used next.
       
 10224   if( iSetNewPathnamesPending != ECamMediaStorageNone )
       
 10225     {
       
 10226     aStorage = iSetNewPathnamesPending;
       
 10227     }
 10177   if(aStorage == ECamMediaStorageCurrent)
 10228   if(aStorage == ECamMediaStorageCurrent)
 10178 	{
 10229 	{
 10179   const TDesC& filename = CurrentVideoFileName();
 10230   const TDesC& filename = CurrentVideoFileName();
 10180   TParse fp;
 10231   TParse fp;
 10181   User::LeaveIfError(fs.Parse(filename, fp));
 10232   User::LeaveIfError(fs.Parse(filename, fp));
 11085         PRINT( _L("Camera =><= CCamAppController::ToggleWideScreenQuality - current quality level NOT high") );
 11136         PRINT( _L("Camera =><= CCamAppController::ToggleWideScreenQuality - current quality level NOT high") );
 11086 
 11137 
 11087     return qualityChanged;
 11138     return qualityChanged;
 11088     }
 11139     }
 11089 
 11140 
       
 11141 // ---------------------------------------------------------------------------
       
 11142 // CCamAppController::IsSaveStarted
       
 11143 // 
       
 11144 // ---------------------------------------------------------------------------
       
 11145 //
       
 11146 TBool CCamAppController::IsSaveStarted()
       
 11147     {
       
 11148     return iSaveStarted;    
       
 11149     }
 11090 //  End of File  
 11150 //  End of File  
 11091 
 11151