camerauis/cameraapp/generic/inc/cameracontroller/camcameracontroller.h
changeset 0 1ddebce53859
child 11 792dfc98fb3b
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAM_CAMERACONTROLLER_H
       
    20 #define CAM_CAMERACONTROLLER_H
       
    21 
       
    22 
       
    23 // ===========================================================================
       
    24 // Included headers
       
    25 #include "camcameracontrollerflags.hrh"
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <ecam.h>
       
    29 #ifdef CAMERAAPP_CAE_FOR_VIDEO
       
    30   #include <CaeEngine.h>
       
    31 #endif
       
    32 
       
    33 #include "camimageencoder.h"
       
    34 #include "camcameraevents.h"
       
    35 #include "camcamerarequests.h"
       
    36 #include "camcameracontrollertypes.h"
       
    37 #include "camcameracontrollersettings.h"
       
    38 #include "mcamcameraobserver.h"          // MCamCameraObservable, MCamCameraObserver
       
    39 
       
    40 // ===========================================================================
       
    41 // Forward declarations
       
    42 
       
    43 class MCameraBuffer;
       
    44 class MCamSettingProvider;
       
    45 class CIdle;
       
    46 class CFbsBitmap;
       
    47 
       
    48 class CCamSnapshotProvider;
       
    49 class CCamCameraControllerActive;
       
    50 class CCamAppController; 
       
    51 
       
    52 #ifdef CAMERAAPP_CAPI_EMULATOR
       
    53   class CCamCamera;
       
    54   #define CAMERA CCamCamera
       
    55 #else
       
    56   #define CAMERA CCamera 
       
    57 #endif // CAMERAAPP_CAPI_EMULATOR
       
    58 
       
    59 #ifdef FORCE_DUMMY_ENGINE
       
    60   class CCameraappDummyEngine;
       
    61 #endif // FORCE_DUMMY_ENGINE
       
    62 
       
    63 class MCameraOrientation;
       
    64 class MCameraFaceTracking;
       
    65   class MCameraUIOrientationOverride;
       
    66 
       
    67 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER
       
    68   class CCamPerformanceLogger;
       
    69 #endif
       
    70 #ifdef CAMERAAPP_FLASH_SIMULATOR
       
    71   class CCamFlashSimulator;
       
    72 #endif
       
    73 
       
    74 #ifdef CAMERAAPP_CAE_ERR_SIMULATION
       
    75   class CCamTimer;
       
    76 #endif // CAMERAAPP_CAE_ERR_SIMULATION
       
    77 
       
    78 // ===========================================================================
       
    79 // Class declarations
       
    80 
       
    81 
       
    82 /**
       
    83  * Camera controller class.
       
    84  *
       
    85  * If using MCameraObserver to receive callbacks from (old) Camera API,
       
    86  * still use (new) MCameraObserver2 to receive thumbnails events.
       
    87  */
       
    88 class CCamCameraController : public CBase,
       
    89                              public MCamCameraObservable,
       
    90 #ifdef CAMERAAPP_CAE_FOR_VIDEO
       
    91                              public MCamAppEngineObserver,
       
    92 #endif
       
    93 #if !defined( CAMERAAPP_CAPI_V2 )
       
    94                              public MCameraObserver,
       
    95 #endif                             
       
    96                              public MCameraObserver2,
       
    97                              public MCamImageEncoderObserver
       
    98   {
       
    99   // =======================================================
       
   100   // Friends
       
   101   private:
       
   102 
       
   103     friend class CCamCameraControllerActive;
       
   104 
       
   105   // =======================================================
       
   106   // Methods
       
   107 
       
   108   // -------------------------------------------------------
       
   109   // Public constructors and destructor
       
   110   public:
       
   111 
       
   112     static CCamCameraController* NewL( MCamSettingProvider& aProvider, 
       
   113                                        CCamAppController& aAppController, 
       
   114                                        TInt aCameraIndex = 0 );
       
   115     virtual ~CCamCameraController();
       
   116 
       
   117   // -------------------------------------------------------
       
   118   // From MCamCameraObservable
       
   119   public:
       
   120     virtual void AttachObserverL( const MCamCameraObserver* aObserver,
       
   121                                   const TUint&              aInterest );
       
   122     virtual void DetachObserver ( const MCamCameraObserver* aObserver );
       
   123 
       
   124   // -------------------------------------------------------
       
   125   // From MCameraObserver2
       
   126   public:
       
   127     virtual void HandleEvent( const TECAMEvent& aEvent );
       
   128     virtual void ViewFinderReady( MCameraBuffer& aCameraBuffer, TInt aError );
       
   129     virtual void ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError );
       
   130     virtual void VideoBufferReady( MCameraBuffer& aCameraBuffer, TInt aError );
       
   131 
       
   132 #ifndef CAMERAAPP_CAPI_V2
       
   133   // -------------------------------------------------------
       
   134   // From MCameraObserver
       
   135   public:
       
   136     virtual void ReserveComplete( TInt aError );
       
   137     virtual void PowerOnComplete( TInt aError );
       
   138     virtual void ViewFinderFrameReady( CFbsBitmap& aFrame );
       
   139     virtual void ImageReady( CFbsBitmap* aBitmap, HBufC8* aData, TInt aError );
       
   140     virtual void FrameBufferReady( MFrameBuffer* aFrameBuffer, TInt aError );
       
   141 #endif // CAMERAAPP_CAPI_V2
       
   142 
       
   143 #ifdef CAMERAAPP_CAE_FOR_VIDEO
       
   144   // -------------------------------------------------------
       
   145   // From MCamAppEngineObserver
       
   146   public:
       
   147     virtual void McaeoInitComplete( TInt aError );
       
   148     virtual void McaeoStillPrepareComplete( TInt aError );
       
   149     virtual void McaeoVideoPrepareComplete( TInt aError );
       
   150     virtual void McaeoViewFinderFrameReady( CFbsBitmap& aFrame, TInt aError );
       
   151     virtual void McaeoSnapImageReady( const CFbsBitmap& aBitmap, TInt aError );
       
   152     virtual void McaeoStillImageReady( CFbsBitmap* aBitmap, HBufC8* aData, TInt aError );
       
   153     virtual void McaeoVideoRecordingOn( TInt aError );
       
   154     virtual void McaeoVideoRecordingPaused( TInt aError );
       
   155     virtual void McaeoVideoRecordingComplete( TInt aError );
       
   156     virtual void McaeoVideoRecordingTimes( 
       
   157         TTimeIntervalMicroSeconds aTimeElapsed, 
       
   158         TTimeIntervalMicroSeconds aTimeRemaining, 
       
   159         TInt aError );
       
   160     virtual void McaeoVideoRecordingStopped();
       
   161 #endif // CAMERAAPP_CAE_FOR_VIDEO
       
   162 
       
   163   // -------------------------------------------------------
       
   164   // From MCamImageEncoderObserver
       
   165   public:
       
   166 
       
   167     virtual void ImageEncoded( TInt aStatus, HBufC8* aData );
       
   168   
       
   169   // -------------------------------------------------------
       
   170   // New methods
       
   171   public:
       
   172     
       
   173     /**
       
   174     * Issue a request for one operation.
       
   175     * Operation will be started synchronously.
       
   176     * Observers will receive notification when the operation is ready.
       
   177     */
       
   178     void RequestL( const TCamCameraRequestId& aRequestId );
       
   179 
       
   180     /**
       
   181     * 
       
   182     */
       
   183     void DirectRequestL( const TCamCameraRequestId& aRequestId );
       
   184 
       
   185     /**
       
   186     * Issue a sequence of operation requests.
       
   187     * This method will return immediately and the requests will be
       
   188     * processed in the background by callbacks.
       
   189     */
       
   190     void RequestSequenceL( const RCamRequestArray& aSequence );
       
   191 
       
   192     /**
       
   193     * Request one or more settings to be set to camera.
       
   194     * The settings to be processed are queried from Setting Provider.
       
   195     * Also the values are queried from there.
       
   196     * Settings are processed asynchronously and ECamCameraEventSettingsDone
       
   197     * event is sent when the process is complete.
       
   198     */
       
   199     void RequestSettingsChangeL();
       
   200 
       
   201     /**
       
   202     * Request one setting to be set synchronously to camera.
       
   203     * @param aSettingId  Id of the setting to change. Value to set
       
   204     *                    is asked from Setting Provider.
       
   205     * @see TCamCameraSettingId    
       
   206     */
       
   207     void DirectSettingsChangeL( 
       
   208             const NCamCameraController::TCamCameraSettingId& aSettingId );
       
   209 
       
   210     /**
       
   211     * Cancel outstanding request sequence.
       
   212     * Operations that have been already performed will not be rolled back.
       
   213     * Observers have received notifications of such operations.
       
   214     * If the sequence is not completed already (observers have not received
       
   215     * ECamEngineEventSequenceEnd notification), once the sequence is cancelled,
       
   216     * observers will receive ECamEngineEventSequenceEnd notification with 
       
   217     * status KErrCancel.
       
   218     */
       
   219     void CancelSequence();
       
   220     
       
   221     void SwitchCameraL( TInt aCameraIndex );
       
   222 
       
   223     void CompleteSwitchCameraL();
       
   224     
       
   225     void SetOrientationModeL( TInt aOrientation );
       
   226     
       
   227     /**
       
   228     * Set viewfinder window for direct screen viewfinder. The handle must remain
       
   229     * valid as long as viewfinder is running. 
       
   230     * @since S60 v5.0
       
   231     * @param aWindow Handle to viewfinder window. Must remain valid while
       
   232     *                viewfinder is running. Ownership not transferred.
       
   233     */
       
   234     void SetViewfinderWindowHandle( RWindowBase* aWindow );
       
   235 
       
   236     /**
       
   237     * Notify that the viewfinder window is about to be deleted. Viewfinder
       
   238     * will be stopped if this window handle is currently used for the
       
   239     * viewfinder.
       
   240     * @since S60 v5.0
       
   241     * @param aWindow Handle to viewfinder window. Ownership not transferred.
       
   242     */
       
   243     void ViewfinderWindowDeleted( RWindowBase* aWindow );
       
   244 
       
   245   // -------------------------------------------------------
       
   246   // Info getters
       
   247   public:
       
   248 
       
   249     static TInt CamerasAvailable();
       
   250 
       
   251     TInt CameraHandle(); // Calls CCamera::Handle which is not const
       
   252 
       
   253     const TCameraInfo& CameraInfo() const;
       
   254     const TCamControllerInfo& ControllerInfo() const;
       
   255 
       
   256     TUint                State()           const;
       
   257     TCamViewfinderMode   ViewfinderMode()  const;    
       
   258     TCamCameraTriState   ViewfinderState() const;
       
   259     TCamCameraTriState   SnapshotState()   const;
       
   260     TCamCameraReadyState FlashState()      const;
       
   261 
       
   262     /**
       
   263     * Method to retrieve the Remaining recording time from
       
   264     * CCaeEngine, this information is used in AppUi and
       
   265     * AppController to handle or continue with Video Rec operation
       
   266     */
       
   267     TTimeIntervalMicroSeconds RemainingVideoRecordingTime();
       
   268 
       
   269     void GetCameraSettingValueL( 
       
   270             const NCamCameraController::TCamCameraSettingId& aSettingId,
       
   271                   TAny*                                      aSettingData );
       
   272 
       
   273     /**
       
   274     * Checks whether setting value given by setting provider matches
       
   275     * the value currently set for iCamera.
       
   276     * @param aSettingId Setting id
       
   277     * @return upToDate
       
   278     */
       
   279     TBool SettingValueUpToDateL( 
       
   280             const NCamCameraController::TCamCameraSettingId& aSettingId );
       
   281 
       
   282   // -------------------------------------------------------
       
   283   // Private methods
       
   284   private:
       
   285 
       
   286     TInt ProcessNextRequestL();
       
   287 
       
   288     TInt ProcessOneRequestL( const TCamCameraRequestId& aRequestId );
       
   289 
       
   290     TInt ProcessSettingL( 
       
   291             const NCamCameraController::TCamCameraSettingId& aSettingId );
       
   292 
       
   293     // Helper methods used to divide ProcessOneRequestL to smaller portions.
       
   294     TInt ProcessControlStartupRequestL( const TCamCameraRequestId& aRequestId );
       
   295     TInt ProcessControlShutdownRequest( const TCamCameraRequestId& aRequestId ); // non-leaving
       
   296     
       
   297     TInt ProcessVfRequestL( const TCamCameraRequestId& aRequestId );
       
   298     void InitViewfinderL( const TCamViewfinderMode& aMode );
       
   299     void ProcessVfStartRequestL();
       
   300     void ProcessVfStopRequestL();
       
   301     void ProcessVfStopEcamRequest();
       
   302     void ProcessVfRelaseRequest(); // non-leaving    
       
   303 
       
   304     TInt ProcessSnapshotRequestL( const TCamCameraRequestId& aRequestId );
       
   305     void ProcessSsStopRequest();    // non-leaving
       
   306     void ProcessSsReleaseRequest(); // non-leaving
       
   307     void InitSnapshotL();
       
   308     
       
   309     TInt ProcessImageRequestL( const TCamCameraRequestId& aRequestId );
       
   310     TInt ProcessImageShutdownRequest( const TCamCameraRequestId& aRequestId );
       
   311     
       
   312     TInt ProcessVideoRequestL( const TCamCameraRequestId& aRequestId );
       
   313 
       
   314     void ProcessAutofocusRequestL( const TCamCameraRequestId& aRequestId );
       
   315 
       
   316     void ProcessCaptureLimitSettingL();
       
   317     
       
   318     void EndSequence( TInt aStatus );
       
   319     void ClearRequestQueue();
       
   320     void ClearSettingQueue();
       
   321 
       
   322   // -------------------------------------------------------
       
   323   // Event handlers
       
   324 
       
   325     void HandlePowerOnEvent( TInt aStatus );
       
   326     void HandleReserveGainEvent( TInt aStatus );
       
   327     void HandleReserveLostEvent( TInt aStatus );
       
   328     void HandleViewfinderEvent( MCameraBuffer* aBitmap, TInt aStatus );
       
   329     void HandleImageCaptureEvent( MCameraBuffer* aBitmap, TInt aStatus );
       
   330     void HandleImageCaptureEventL( MCameraBuffer*& aCameraBuffer );
       
   331     void HandleSnapshotEvent( TInt aStatus );
       
   332     void HandleSnapshotEventL( TBool aIgnore = EFalse  );
       
   333 
       
   334     void HandleVideoEvent( const TCamCameraEventId& aEventId,
       
   335                                  TInt               aStatus  );
       
   336 
       
   337     void HandleVideoTimeEvent( TInt aStatus,
       
   338                                TTimeIntervalMicroSeconds aTimeElapsed, 
       
   339                                TTimeIntervalMicroSeconds aTimeRemaining );
       
   340 
       
   341     void HandleAutoFocusEvent(       TInt  aStatus, 
       
   342                                const TUid& aEventUid );
       
   343 
       
   344     void HandleFlashStatusEvent(       TInt                aStatus,
       
   345                                  const TCamCameraEventId& aEventId );
       
   346 
       
   347     void HandleCallbackEvent( 
       
   348                         TInt                    aStatus, 
       
   349                   const TCamCameraEventId&      aEventId, 
       
   350                   const TCamCameraEventClassId& aEventClass,
       
   351                         TAny*                   aEventData = NULL );
       
   352 
       
   353   // -------------------------------------------------------
       
   354   // Helper methods
       
   355     
       
   356     void ReleaseCurrentCamera();
       
   357     void ReleaseCustomInterfaces();
       
   358 
       
   359     TBool HasCallback( const TCamCameraRequestId& aType );
       
   360  
       
   361     TBool CurrentSettingHasCallback();
       
   362 
       
   363     /**
       
   364     * Sets viewfinder window ordinal position so that the window is visible.
       
   365     * Window needs to visible when viewfinder is started. In addition,
       
   366     * ordinal position can be set as a parameter, if original position needs to
       
   367     * be returned back.
       
   368     * @since S60 5.0
       
   369     * @param aOrdinalPosition,viewfinder window ordinal position to set 
       
   370     * @return TInt, DSA viewfinder window ordinal position or KErrUnknown
       
   371     */   
       
   372     TInt SetVfWindowOrdinal( TInt aOrdinalPosition = KErrUnknown ); 
       
   373 
       
   374 
       
   375   // -------------------------------------------------------
       
   376   // Notification of observers
       
   377 
       
   378     void NotifyObservers( TInt                   aStatus, 
       
   379                           TCamCameraEventId      aEventId,
       
   380                           TCamCameraEventClassId aEventClass,
       
   381                           TAny*                  aEventData = NULL );
       
   382 
       
   383  
       
   384 
       
   385   // -------------------------------------------------------
       
   386   // Getters for info on current camera
       
   387   
       
   388     TInt GetResolutionIndexL(       CCamera::TFormat& aFormat,
       
   389                               const TSize&            aSize   );
       
   390 #ifdef CAMERAAPP_CAPI_V2_ADV
       
   391     /**
       
   392     * Get info related to advanced settings.
       
   393     */
       
   394     void GetAdvancedSettingsInfoL();
       
   395     
       
   396     /**
       
   397     * Get closest supported EV compensation step to the given value.
       
   398     * @aEvProposedStep The step for which the closest supported one
       
   399     *                  is asked.
       
   400     * @return Closest supported step to the given proposed step.
       
   401     *         Always 0 if no supported EV steps available.
       
   402     */
       
   403     TInt ResolveEvStep( TInt aEvProposedStep ) const;
       
   404 
       
   405     /**
       
   406     * Helper method to check whether the given value is supported,
       
   407     * based on the value array and value info.
       
   408     * Depending on aValueInfo content, the aValueList may represent
       
   409     * the supported values in completely different ways. This 
       
   410     * method is used to help determining if single value is supported
       
   411     * or not.
       
   412     * @param aValue     The value to be checked if it's supported.
       
   413     * @param aValueList Array describing the supported values. Actual meaning
       
   414     *                   depends on aValueInfo value.
       
   415     * @param aValueInfo Enumeration value describing the meaning of values in
       
   416     *                   aValueList array.
       
   417     * @see   TValueInfo
       
   418     */
       
   419     static TBool IsSupportedValue( const TInt&         aValue, 
       
   420                                    const RArray<TInt>& aValueList, 
       
   421                                    const TValueInfo&   aValueInfo );
       
   422 
       
   423 #endif // CAMERAAPP_CAPI_V2_ADV
       
   424 
       
   425     /**
       
   426     * Resolve the snapshot format to be used based on supported formats
       
   427     * and the given preferred format.
       
   428     *
       
   429     * @aPreferredFormat Format to be preferably used, if available.
       
   430     * @leave  KErrNotSupported No acceptable formats are supported.
       
   431     * @leave  KErrNotReady     Snapshot provider not available.
       
   432     * @return Best supported snapshot format.
       
   433     */
       
   434     CCamera::TFormat ResolveSnapshotFormatL( CCamera::TFormat aPreferredFormat ) const;
       
   435 
       
   436 
       
   437   // -------------------------------------------------------
       
   438   // Conversion methods between requests, events and event classes 
       
   439 
       
   440     static TCamCameraEventId Request2Event( const TCamCameraRequestId& aType );
       
   441 
       
   442     static TCamCameraEventClassId EventClass( const TCamCameraEventId& aEventId );
       
   443 
       
   444     // Comparison function for searching for a matching resolution in
       
   445     // an RArray<TSize>
       
   446     static TBool CompareSize( const TSize& aA, const TSize& aB );
       
   447 
       
   448   // -------------------------------------------------------
       
   449   // Camera / engine construction
       
   450   
       
   451     CCaeEngine* NewCaeEngineL( TInt aCameraIndex );
       
   452 
       
   453     CAMERA* NewCameraL( TInt aCameraIndex );
       
   454   
       
   455     CAMERA* NewDuplicateCameraL( TInt aCameraHandle );    
       
   456 
       
   457   // -------------------------------------------------------
       
   458   // Private constructors
       
   459   private:
       
   460 
       
   461     void ConstructL( TInt aCameraIndex );
       
   462 
       
   463     CCamCameraController( MCamSettingProvider& aProvider, 
       
   464                           CCamAppController& aAppController );
       
   465 
       
   466   // -------------------------------------------------------
       
   467   // Prints for debug builds
       
   468 #ifdef _DEBUG
       
   469   private:
       
   470 
       
   471     void PrintCameraInfo() const;
       
   472 
       
   473   #ifdef CAMERAAPP_CAPI_V2_ADV
       
   474     void PrintAdvancedSettingInfo() const;
       
   475   #endif // CAMERAAPP_CAPI_V2_ADV
       
   476 
       
   477     void PrintSnapshotInfo() const;
       
   478 
       
   479 #endif // _DEBUG
       
   480 
       
   481 
       
   482     void SetFaceTrackingL();
       
   483 
       
   484 
       
   485   // =======================================================
       
   486   // Data
       
   487   private:
       
   488 
       
   489   // -------------------------------------------------------
       
   490   // Request queue and related
       
   491     TInt                               iSequenceIndex;
       
   492     RCamRequestArray                   iSequenceArray;
       
   493     
       
   494     TInt                               iReserveTryAgainCount;
       
   495 
       
   496   // -------------------------------------------------------
       
   497   // Settings queue and related
       
   498     TInt                                              iSettingIndex;
       
   499     RArray<NCamCameraController::TCamCameraSettingId> iSettingArray;
       
   500 
       
   501     MCamSettingProvider&               iSettingProvider;   /** Entity providing settings.             */
       
   502 
       
   503   // -------------------------------------------------------
       
   504   // Active object thriving our asynchronous processes.
       
   505 
       
   506     CCamCameraControllerActive*        iActive;            /** Own.                                   */
       
   507 
       
   508   // -------------------------------------------------------
       
   509   // Observers and their interests
       
   510 
       
   511     RPointerArray<MCamCameraObserver>  iObservers;         /** Array of observers. Observers not own. */
       
   512     RArray       <TUint>               iObserverInterests; /** Array of observer interests            */
       
   513 
       
   514 
       
   515   // -------------------------------------------------------
       
   516   // Info containers
       
   517     TCameraInfo                        iCameraInfo;        /** Camera details                         */
       
   518     TCamControllerInfo                 iInfo;              /** Our own details                        */
       
   519 
       
   520     TCamCameraResolutionSupport        iResolutionSupport; /** Supported resolutions info             */
       
   521 #ifdef CAMERAAPP_CAPI_V2_ADV
       
   522     TCamAdvancedSettingInfo            iAdvancedSettingInfo;  /** Info related to advanced settings   */
       
   523 #endif
       
   524 
       
   525     TBool                              iAlternateFormatInUse; /** Encode jpeg from bitmap internally  */                                       
       
   526 
       
   527   // -------------------------------------------------------
       
   528   // ECam
       
   529     CAMERA*                            iCamera;            /** Onboard camera instance. Own.          */
       
   530     TBool                              iReleasedByUi;      /** Flag to distinguish own and external   */
       
   531                                                            /** camera release.                        */
       
   532 
       
   533 #ifdef CAMERAAPP_CAPI_V2
       
   534   #ifdef CAMERAAPP_CAPI_V2_DVF
       
   535     CCamera::CCameraDirectViewFinder*  iDirectViewfinder;  /** Direct viewfinder. Own.                */
       
   536   #endif
       
   537   #ifdef CAMERAAPP_CAPI_V2_OL
       
   538     CCamera::CCameraOverlay*           iOverlayProvider;   /** Overlay provider. Own.                 */
       
   539   #endif
       
   540   #ifdef CAMERAAPP_CAPI_V2_ADV
       
   541     CCamera::CCameraAdvancedSettings*  iAdvancedSettings;  /** Advanced settings instance. Own.       */
       
   542   #endif
       
   543   #ifdef CAMERAAPP_CAPI_V2_HG
       
   544     CCamera::CCameraHistogram*         iHistogramProvider; /** Histogram provider. Own.               */
       
   545   #endif
       
   546   #ifdef CAMERAAPP_CAPI_V2_IP
       
   547     CCamera::CCameraImageProcessing*   iImageProcessor;    /** Image processor. Own.                  */
       
   548   #endif
       
   549 #endif
       
   550 
       
   551     CCamSnapshotProvider*              iSnapshotProvider;
       
   552 
       
   553     CCamImageEncoder*                  iEncoder;
       
   554 
       
   555     MCameraOrientation*                iCustomInterfaceOrientation;   /** Not own. */
       
   556 
       
   557     MCameraFaceTracking*               iCustomInterfaceFaceTracking;   /** Not own. */
       
   558     
       
   559     MCameraUIOrientationOverride*      iCustomInterfaceUIOrientationOverride; /** Not own. */
       
   560 
       
   561   // -------------------------------------------------------
       
   562   // CAE 
       
   563 #ifdef CAMERAAPP_CAE_FOR_VIDEO
       
   564 
       
   565     CCaeEngine*                        iCaeEngine;         /** Camera app engine for video. Own.      */
       
   566     TCamVideoRecordingTimes            iVideoTimes;
       
   567     TBool                              iAsyncVideoStopModeSupported;
       
   568 
       
   569   #ifdef CAMERAAPP_CAE_FIX
       
   570     /** 
       
   571     * Workaround for changing between video (CCaeEngine) and image (CCamera) modes
       
   572     * Without the support for camera handle sharing in CAE.
       
   573     */
       
   574 
       
   575     TBool iCaeInUse;
       
   576     
       
   577     TInt ProceedModeSwitch();
       
   578     TInt DoProceedModeSwitchL();
       
   579 
       
   580     enum TCamModeChange
       
   581       {
       
   582       ECamModeChangeInactive,
       
   583       ECamModeChangeVideo2Image,
       
   584       ECamModeChangeImage2Video
       
   585       };
       
   586     enum TCamModeChangePhase
       
   587       {
       
   588       ECamModeChangePhaseIdle,
       
   589       ECamModeChangePhase0,
       
   590       ECamModeChangePhase1,
       
   591       ECamModeChangePhase2,
       
   592       ECamModeChangePhase3,
       
   593       ECamModeChangePhase4
       
   594       };
       
   595 
       
   596     TCamModeChange      iModeChange;      
       
   597     TInt                iModeChangePhase; // TCamModeChangePhase
       
   598     TInt                iModeChangeStatus;
       
   599   #endif // CAMERAAPP_CAE_FIX
       
   600 #endif
       
   601 
       
   602     // This bool is used to determine whether current event is the first or second one.
       
   603     TBool               iFirstAfEventReceived;
       
   604 	 
       
   605     // This bool is used to determine whether AF operation is started 
       
   606     TBool               iAfInProgress;
       
   607 	
       
   608     // This bool is used to determine whether HyperFocal needs to be set 	
       
   609     TBool               iAfHyperfocalPending;
       
   610 
       
   611   // -------------------------------------------------------
       
   612   // Flash simulation
       
   613 #ifdef CAMERAAPP_FLASH_SIMULATOR
       
   614     CCamFlashSimulator*                iFlashSimulator;
       
   615 #endif 
       
   616 
       
   617     // -------------------------------------------------------
       
   618     // CAE error simulation
       
   619 #ifdef CAMERAAPP_CAE_ERR_SIMULATION
       
   620     // Timer for delaying callbacks to simulate difficult/erroneous situations
       
   621     CCamTimer* iCallbackTimer;
       
   622     
       
   623     TCamCameraEventId  iSimEventId;
       
   624     TInt               iSimStatus;
       
   625 
       
   626     static TInt DelayedCaeCallback( TAny* aController );
       
   627     
       
   628     void CallAppropriateCallback( const TCamCameraEventId aEventId = ECamCameraEventNone,
       
   629                                         TInt              aStatus  = 0 );
       
   630     
       
   631 #endif // CAMERAAPP_CAE_ERR_SIMULATION
       
   632     
       
   633   // -------------------------------------------------------    
       
   634 
       
   635   // -------------------------------------------------------
       
   636   // Performance logging related
       
   637 #ifdef CAMERAAPP_PERFORMANCE_CONTROLLER
       
   638   public:
       
   639     const CCamPerformanceLogger* PerformanceLogger() const;
       
   640 
       
   641   private:
       
   642     CCamPerformanceLogger*             iPerformanceLogger;
       
   643     TBool                              iFirstVfFrameReceived;    
       
   644 #endif // CAMERAAPP_PERFORMANCE_CONTROLLER
       
   645   // -------------------------------------------------------
       
   646 
       
   647   public:
       
   648      void SetBurstImagesRemaining( TInt aBurstImagesRemaining );
       
   649     TBool AsyncVideoStopModeSupported();
       
   650 
       
   651         
       
   652     /**
       
   653     * Used to recover lost resources. 
       
   654     *
       
   655     * @param aSelf pointer to CCamCameraController object
       
   656     * @return N/A
       
   657     */
       
   658     static TInt IdleCallback( TAny* aSelf );   
       
   659 
       
   660     /**
       
   661     * Helper method for IdleCallback 
       
   662     */
       
   663     void DoIveRecovery();
       
   664 
       
   665     /**
       
   666     * Indicates resource recovery state.
       
   667     * @return TBool, ETrue if resource recovering is initated
       
   668     */
       
   669     TBool IsWaitingIveResources();  
       
   670     
       
   671   private:
       
   672     TInt iBurstImagesRemaining;
       
   673 
       
   674     // not own
       
   675     RWindowBase* iViewfinderWindow;
       
   676     CIdle* iIdle;  
       
   677 
       
   678     // Counts how many times lost resources are tried to recover 
       
   679     // (KIveRecoveryCountMax).
       
   680     TInt iIveRecoveryCount;  
       
   681     TBool iIveRecoveryOngoing;
       
   682     
       
   683     CCamAppController& iAppController;
       
   684     TInt iCurrentCameraIndex;  
       
   685 
       
   686   };
       
   687 
       
   688 #endif // CAM_CAMERACONTROLLER_H
       
   689 
       
   690 // end of file