camerauis/cameraapp/generic/src/cameracontroller/camcameracontroller.cpp
branchRCL_3
changeset 25 bf64cebf4673
parent 20 38fb6f7eacd5
child 27 53c8aa5d97a3
equal deleted inserted replaced
20:38fb6f7eacd5 25:bf64cebf4673
    51 
    51 
    52 // -------------------------------------
    52 // -------------------------------------
    53 // Custom interfaces
    53 // Custom interfaces
    54 #include <ECamOrientationCustomInterface2.h>
    54 #include <ECamOrientationCustomInterface2.h>
    55 #include <ECamUIOrientationOverrideCustomAPI.h>
    55 #include <ECamUIOrientationOverrideCustomAPI.h>
    56 
    56 #include <ecamusecasehintcustomapi.h>
    57 #include <ecamfacetrackingcustomapi.h>
    57 #include <ecamfacetrackingcustomapi.h>
    58 #include <akntoolbar.h>
    58 #include <akntoolbar.h>
    59 // -------------------------------------
    59 // -------------------------------------
    60 // Own
    60 // Own
    61 #include "camcameracontroller.pan"
    61 #include "camcameracontroller.pan"
   100 // ===========================================================================
   100 // ===========================================================================
   101 // Local constants
   101 // Local constants
   102 const TInt KIveRecoveryCountMax = 2;
   102 const TInt KIveRecoveryCountMax = 2;
   103 typedef CCamera::CCameraAdvancedSettings CAS;
   103 typedef CCamera::CCameraAdvancedSettings CAS;
   104 typedef CCamera::CCameraImageProcessing  CIP;
   104 typedef CCamera::CCameraImageProcessing  CIP;
       
   105 
       
   106 //for camusecasehintcustomapi
       
   107 _LIT8(KCMRMimeTypeH263, "video/H263-2000");
       
   108 _LIT8(KCMRMimeTypeMPEG4VSPL2, "video/mp4v-es; profile-level-id=2");
       
   109 _LIT8(KCMRMimeTypeMPEG4VSPL3, "video/mp4v-es; profile-level-id=3");
       
   110 _LIT8(KCMRMimeTypeMPEG4VSPL4A, "video/mp4v-es; profile-level-id=4");
       
   111 _LIT8(KCMRMimeTypeH264AVCBPL30, "video/H264; profile-level-id=42801E");
       
   112 _LIT8(KCMRMimeTypeH264AVCBPL31, "video/H264; profile-level-id=42801F");
       
   113 
   105 
   114 
   106 namespace NCamCameraController
   115 namespace NCamCameraController
   107   {
   116   {
   108   static const TInt               KPrimaryCameraIndex         =  0;
   117   static const TInt               KPrimaryCameraIndex         =  0;
   109   //static const TInt               KSecondaryCameraIndex       =  1;
   118   //static const TInt               KSecondaryCameraIndex       =  1;
  1513     PRINT ( _L("Camera <> Get i/f MCameraOrientation..") )
  1522     PRINT ( _L("Camera <> Get i/f MCameraOrientation..") )
  1514     iCustomInterfaceOrientation =
  1523     iCustomInterfaceOrientation =
  1515       static_cast <MCameraOrientation*>(
  1524       static_cast <MCameraOrientation*>(
  1516   	    iCamera->CustomInterface( KCameraOrientationUid ) );
  1525   	    iCamera->CustomInterface( KCameraOrientationUid ) );
  1517     PRINT1( _L("Camera <> Orientation custom i/f pointer:%d"), iCustomInterfaceOrientation );
  1526     PRINT1( _L("Camera <> Orientation custom i/f pointer:%d"), iCustomInterfaceOrientation );
       
  1527     
       
  1528     iCustomInterfaceUseCaseHint =
       
  1529       static_cast <MCameraUseCaseHint*>(
       
  1530   	    iCamera->CustomInterface( KCameraUseCaseHintUid ) );
       
  1531     PRINT1( _L("Camera <> UseCaseHint custom i/f pointer:%d"), iCustomInterfaceUseCaseHint );
       
  1532     
       
  1533     
       
  1534     
  1518 
  1535 
  1519 #endif // CAMERAAPP_CAPI_V2_ADV
  1536 #endif // CAMERAAPP_CAPI_V2_ADV
  1520 
  1537 
  1521     PRINT ( _L("Camera <> ..done") );
  1538     PRINT ( _L("Camera <> ..done") );
  1522     PRINT ( _L("############################################################") );
  1539     PRINT ( _L("############################################################") );
  2547   // -------------------------------------------------------
  2564   // -------------------------------------------------------
  2548   // Reserve
  2565   // Reserve
  2549   if( ECamRequestReserve == aRequestId )
  2566   if( ECamRequestReserve == aRequestId )
  2550     {
  2567     {
  2551     CheckFlagOffL( iInfo.iState, ECamReserved, KErrInUse );
  2568     CheckFlagOffL( iInfo.iState, ECamReserved, KErrInUse );
       
  2569 
       
  2570     // tell CAPI the usecase (still or video), not fatal if fails
       
  2571     TRAPD( err, HintUseCaseL() );
       
  2572     
       
  2573     if( err ) 
       
  2574       {
       
  2575       PRINT1( _L("Camera <> CCamCameraController::ProcessControlStartupRequestL HintUseCaseL failed:%d"), err)
       
  2576       }
  2552 
  2577 
  2553     CAMERAAPP_PERF_CONTROLLER_START( ECamRequestReserve );
  2578     CAMERAAPP_PERF_CONTROLLER_START( ECamRequestReserve );
  2554     iCamera->Reserve();
  2579     iCamera->Reserve();
  2555     // If UIOrientationOverrideAPI is used, ui construction is completed while
  2580     // If UIOrientationOverrideAPI is used, ui construction is completed while
  2556     // waiting for Reserve to complete, event sent here to continue ui construction
  2581     // waiting for Reserve to complete, event sent here to continue ui construction
  3721     iAfInProgress = ETrue;
  3746     iAfInProgress = ETrue;
  3722     iFirstAfEventReceived = EFalse;
  3747     iFirstAfEventReceived = EFalse;
  3723     }
  3748     }
  3724   else if( ECamRequestCancelAutofocus == aRequestId )
  3749   else if( ECamRequestCancelAutofocus == aRequestId )
  3725     {
  3750     {
  3726     if( iAfInProgress )
  3751     if( iAfInProgress && iInfo.iCurrentCamera == KPrimaryCameraIndex )
  3727       {
  3752       {
  3728       // Autofocus in progress, need to cancel it before setting range to hyperfocal
  3753       // Autofocus in progress, need to cancel it before setting range to hyperfocal
  3729       PRINT( _L("Camera <> Cancel ongoing autofocus request") );
  3754       PRINT( _L("Camera <> Cancel ongoing autofocus request") );
  3730       iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff );
  3755       iAdvancedSettings->SetAutoFocusType( CAS::EAutoFocusTypeOff );
  3731       iAfHyperfocalPending = ETrue;
  3756       iAfHyperfocalPending = ETrue;
  4115 //
  4140 //
  4116 void
  4141 void
  4117 CCamCameraController::HandleReserveGainEvent( TInt aStatus )
  4142 CCamCameraController::HandleReserveGainEvent( TInt aStatus )
  4118   {
  4143   {
  4119   PRINT1( _L("Camera => CCamCameraController::HandleReserveGainEvent, status:%d"), aStatus );
  4144   PRINT1( _L("Camera => CCamCameraController::HandleReserveGainEvent, status:%d"), aStatus );
       
  4145   CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
  4146   if( appUi->StandbyStatus() && !appUi->IsRecoverableStatus() )
       
  4147       {
       
  4148       PRINT( _L("Camera <= CCamCameraController::HandleReserveGainEvent - return, in non recoverable standby state"));
       
  4149       return;
       
  4150       }
  4120   if( iIdle && iIdle->IsActive() )
  4151   if( iIdle && iIdle->IsActive() )
  4121     {
  4152     {
  4122     PRINT( _L("Camera => CCamCameraController::HandleReserveGainEvent - return, recovery in progress"));
  4153     PRINT( _L("Camera => CCamCameraController::HandleReserveGainEvent - return, recovery in progress"));
  4123     return;
  4154     return;
  4124     }
  4155     }
  4769 //
  4800 //
  4770 void
  4801 void
  4771 CCamCameraController::HandleAutoFocusEvent( TInt aStatus, const TUid& aEventUid )
  4802 CCamCameraController::HandleAutoFocusEvent( TInt aStatus, const TUid& aEventUid )
  4772   {
  4803   {
  4773   PRINT1( _L("Camera => CCamCameraController::HandleAutoFocusEvent, status: %d"), aStatus );
  4804   PRINT1( _L("Camera => CCamCameraController::HandleAutoFocusEvent, status: %d"), aStatus );
       
  4805 
       
  4806  if( IsFlagOn( iInfo.iState, ECamVideoOn ) && ECamCaptureOn == iInfo.iCaptureState )
       
  4807     {
       
  4808     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
  4809     if ( appUi && !appUi->AppController().UiConfigManagerPtr()->IsContinuosAutofocusSupported() )
       
  4810         {
       
  4811         // Autofocus events are not need anymore, if video recording is started already.
       
  4812         PRINT( _L("Camera <= CCamCameraController::HandleAutoFocusEvent - ignore") );
       
  4813         return;
       
  4814         }
       
  4815     }
       
  4816 
  4774   TBool proceed = EFalse;
  4817   TBool proceed = EFalse;
  4775 
  4818 
  4776   // -------------------------------------------------------
  4819   // -------------------------------------------------------
  4777   // Check the event
  4820   // Check the event
  4778   if( KUidECamEventCameraSettingsOptimalFocus == aEventUid )
  4821   if( KUidECamEventCameraSettingsOptimalFocus == aEventUid )
  6705 void CCamCameraController::SetFaceTrackingL()
  6748 void CCamCameraController::SetFaceTrackingL()
  6706     {
  6749     {
  6707     if( iCustomInterfaceFaceTracking &&
  6750     if( iCustomInterfaceFaceTracking &&
  6708         KPrimaryCameraIndex == iInfo.iCurrentCamera )
  6751         KPrimaryCameraIndex == iInfo.iCurrentCamera )
  6709       {
  6752       {
       
  6753       // always enable FaceIndicators regardless of FT setting
       
  6754       // to get reticule visible  
       
  6755       iCustomInterfaceFaceTracking->EnableFaceIndicatorsL( ETrue );
  6710       TBool ftOn( EFalse );
  6756       TBool ftOn( EFalse );
  6711       iSettingProvider.ProvideCameraSettingL( ECameraSettingFacetracking, &ftOn );
  6757       iSettingProvider.ProvideCameraSettingL( ECameraSettingFacetracking, &ftOn );
  6712       PRINT1( _L("Camera <> Set facetracking: %d"), ftOn )
  6758       PRINT1( _L("Camera <> Set facetracking: %d"), ftOn )
  6713       if( ( ftOn && !iCustomInterfaceFaceTracking->FaceTrackingOn() ) ||
  6759       if( ( ftOn && !iCustomInterfaceFaceTracking->FaceTrackingOn() ) ||
  6714           ( !ftOn && iCustomInterfaceFaceTracking->FaceTrackingOn() ) )
  6760           ( !ftOn && iCustomInterfaceFaceTracking->FaceTrackingOn() ) )
  6715           {
  6761           {
  6716           iCustomInterfaceFaceTracking->SetFaceTrackingL( ftOn );
  6762           iCustomInterfaceFaceTracking->SetFaceTrackingL( ftOn );
  6717           iCustomInterfaceFaceTracking->EnableFaceIndicatorsL( ETrue );
       
  6718           DirectRequestL( ECamRequestSetAfRange );
  6763           DirectRequestL( ECamRequestSetAfRange );
  6719           }
  6764           }
  6720       }
  6765       }
  6721     }
  6766     }
  6722 
  6767 
       
  6768 // ---------------------------------------------------------------------------
       
  6769 // CCamCameraController::HintUseCase
       
  6770 // ---------------------------------------------------------------------------
       
  6771 //
       
  6772 void CCamCameraController::HintUseCaseL()
       
  6773     {
       
  6774     PRINT( _L("Camera => CCamCameraController::HintUseCaseL"))
       
  6775     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );    
       
  6776     //videomode    
       
  6777     if ( iCustomInterfaceUseCaseHint && appUi && 
       
  6778        ( ( appUi->IsEmbedded() && appUi->TargetMode() == ECamControllerVideo ) || 
       
  6779        ( !appUi->IsEmbedded() && iAppController.TargetMode() == ECamControllerVideo ) ) )
       
  6780         {
       
  6781         PRINT( _L("Camera <> HintUseCaseL VideoMode") );
       
  6782         MCameraUseCaseHint::TVideoCodec codec = MCameraUseCaseHint::ECodecUnknown;
       
  6783         MCameraUseCaseHint::TVideoProfile profile = MCameraUseCaseHint::EProfileUnknown;
       
  6784         TPckgBuf<TCamParamsVideoCae> params;
       
  6785         iSettingProvider.ProvideCameraParamL( ECameraParamVideoCae, &params );
       
  6786         if( params().iVideoType == KCMRMimeTypeH264AVCBPL31 )
       
  6787             {
       
  6788             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeH264AVCBPL31") );    
       
  6789             codec = MCameraUseCaseHint::ECodecH264;
       
  6790             profile = MCameraUseCaseHint::EProfileH264BpL3_1;
       
  6791             }
       
  6792         else if( params().iVideoType == KCMRMimeTypeH263 )
       
  6793             {
       
  6794             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeH263") );    
       
  6795             codec = MCameraUseCaseHint::ECodecH263;
       
  6796             profile = MCameraUseCaseHint::EProfileH263P0L10;
       
  6797             }
       
  6798         else if( params().iVideoType == KCMRMimeTypeH264AVCBPL30 )
       
  6799             {
       
  6800             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeH264AVCBPL30") );    
       
  6801             codec = MCameraUseCaseHint::ECodecH264;
       
  6802             profile = MCameraUseCaseHint::EProfileH264BpL3;
       
  6803             }            
       
  6804         else if( params().iVideoType == KCMRMimeTypeMPEG4VSPL4A )
       
  6805             {
       
  6806             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeMPEG4VSPL4A") );    
       
  6807             codec = MCameraUseCaseHint::ECodecMpeg4;
       
  6808             profile = MCameraUseCaseHint::EProfileMPEG4SpL4a;     
       
  6809             }
       
  6810         else if( params().iVideoType == KCMRMimeTypeMPEG4VSPL3 )
       
  6811             {
       
  6812             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeMPEG4VSPL3") );    
       
  6813             codec = MCameraUseCaseHint::ECodecMpeg4;
       
  6814             profile = MCameraUseCaseHint::EProfileMPEG4SpL3;                        
       
  6815             }
       
  6816         else if( params().iVideoType == KCMRMimeTypeMPEG4VSPL2 )
       
  6817             {
       
  6818             PRINT( _L("Camera <> HintUseCaseL VideoMode KCMRMimeTypeMPEG4VSPL2") );    
       
  6819             codec = MCameraUseCaseHint::ECodecMpeg4;
       
  6820             profile = MCameraUseCaseHint::EProfileMPEG4SpL2;                        
       
  6821             }                        
       
  6822         else
       
  6823             {
       
  6824             PRINT( _L("Camera <> HintUseCaseL VideoMode not supported") );        
       
  6825             //leave if type not supported
       
  6826             User::Leave( KErrNotSupported );
       
  6827             }    
       
  6828         iCustomInterfaceUseCaseHint->HintDirectVideoCaptureL( codec, 
       
  6829                                                               profile, 
       
  6830                                                               params().iFrameSize );
       
  6831             
       
  6832         }
       
  6833     //stillmode    
       
  6834     else if ( iCustomInterfaceUseCaseHint && appUi && 
       
  6835             ( ( appUi->IsEmbedded() && appUi->TargetMode() == ECamControllerImage ) || 
       
  6836               ( !appUi->IsEmbedded() && iAppController.TargetMode() == ECamControllerImage ) ) )
       
  6837         {
       
  6838         PRINT( _L("Camera <> HintUseCaseL ImageMode") );    
       
  6839         TPckgBuf<TCamParamsImage> params;
       
  6840         iSettingProvider.ProvideCameraParamL( ECameraParamImage, &params );
       
  6841         CCamera::TFormat format( params().iFormat );
       
  6842         TInt index ( GetResolutionIndexL( format, params().iSize ) );    
       
  6843         iCustomInterfaceUseCaseHint->HintStillCaptureL( format, index );
       
  6844         }
       
  6845 
       
  6846     PRINT( _L("Camera <= CCamCameraController::HintUseCaseL"))    
       
  6847     }
  6723 // End of file
  6848 // End of file