camerauis/cameraapp/generic/inc/CamSelfTimer.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 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:  CCamSelfTimer class for Camera*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 #ifndef CAMSELFTIMER_H
       
    20 #define CAMSELFTIMER_H
       
    21 
       
    22 #include "CamAppController.h"
       
    23 #include "CamSelfTimerObserver.h"
       
    24 #include "CamAppUiBase.h"   // For TCamSelfTimerFunctions
       
    25 #include "CamPSI.h" 
       
    26 
       
    27 //////////
       
    28 
       
    29 
       
    30 
       
    31 // INCLUDES
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // DATA TYPES
       
    36 
       
    37 // Represents the selftimer state.  Allows up to 3 different active states, 
       
    38 // plus the standby (inactive) state.
       
    39 enum TCamSelfTimer  
       
    40     {
       
    41     ECamSelfTimerActive1,   
       
    42     ECamSelfTimerActive2,   
       
    43     ECamSelfTimerActive3,
       
    44     ECamSelfTimerStandby
       
    45     };
       
    46 
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 /**
       
    53 *  Implements self-timer functionality 
       
    54 *
       
    55 *  @since 2.8
       
    56 */
       
    57 class CCamSelfTimer : public CBase
       
    58     {   
       
    59     public:  // Constructors and destructor
       
    60         
       
    61         /**
       
    62         * Two-phased constructor.
       
    63         */
       
    64         static CCamSelfTimer* NewL( CCamAppController& aController );
       
    65         
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         virtual ~CCamSelfTimer();
       
    70 
       
    71     public: // New functions
       
    72         
       
    73         /**
       
    74         * Called by client to start the self timer functionatlity.
       
    75         * Starts the timer counting down.
       
    76         * @since 2.8
       
    77         */
       
    78         void StartSelfTimer();
       
    79 
       
    80         /**
       
    81         * Called by client to set the current capture mode.  This is needed
       
    82         * to ensure the Self-Timer operation, if started, would call the 
       
    83         * correct capture (for video or photo) on timer completion.
       
    84         * @since 2.8
       
    85         * @param aMode The capture mode (video/image)
       
    86         * @param aMode The image capture mode (single/burst/timelapse)
       
    87         * @param aFunc The period data set to use
       
    88         */
       
    89         void SetModeL( TCamCameraMode         aMode, 
       
    90                       TCamImageCaptureMode   aImageMode,
       
    91                       TCamSelfTimerFunctions aFunc );
       
    92         
       
    93 
       
    94         /**
       
    95         * Cancels any oustanding self-timer operation, and resets internal
       
    96         * state to standby/idle state.
       
    97         * @since 2.8
       
    98         */
       
    99         void Cancel();
       
   100 
       
   101         /**
       
   102         * Returns whether the self-timer is currently active (counting down)
       
   103         * @since 2.8
       
   104         * @return TBool - ETrue if active, EFalse if in standby/idle.
       
   105         */
       
   106         TBool IsActive();
       
   107 
       
   108         /**
       
   109         * Add a self timer observer
       
   110         * @since 2.8
       
   111         * @param aObserver Pointer to object implementing MCamSelfTimerObserver
       
   112         */
       
   113         void AddObserverL( const MCamSelfTimerObserver* aObserver );
       
   114 
       
   115         /**
       
   116         * Remove self timer observer
       
   117         * @since 2.8
       
   118         * @param aObserver Pointer to object implementing MCamSelfTimerObserver
       
   119         */
       
   120         void RemoveObserver( const MCamSelfTimerObserver* aObserver );
       
   121 
       
   122         /**
       
   123         * Send event to self timer observers
       
   124         * @since 2.8
       
   125         * @param aEvent event to send to observers
       
   126         */
       
   127         void NotifyObservers( const TCamSelfTimerEvent aEvent );
       
   128 
       
   129     public: // Functions from base classes
       
   130        
       
   131     protected:  // New functions        
       
   132 
       
   133     protected:  // Functions from base classes
       
   134         
       
   135     private:
       
   136 
       
   137         /**
       
   138         * C++ default constructor.
       
   139         */
       
   140         CCamSelfTimer( CCamAppController& aController );
       
   141 
       
   142         /**
       
   143         * By default Symbian 2nd phase constructor is private.
       
   144         */
       
   145         void ConstructL();
       
   146 
       
   147         /**
       
   148         * Allows the self-timer object to change it's internal state based upon
       
   149         * the parameter passed in.
       
   150         * @since 2.8
       
   151         * @param aState, The internal state to move to.
       
   152         */
       
   153         void ChangeState( TCamSelfTimer aState); 
       
   154 
       
   155         /**
       
   156         * The timer callback used by the periodic timer.  Will call the 
       
   157         * CCamSelfTimer's Tick() method.
       
   158         * @since 2.8
       
   159         * @param aPtr A pointer to the instance of CCamSelfTimer
       
   160         * @return KErrNone
       
   161         */
       
   162         static TInt TimerCallback( TAny* aPtr );
       
   163 
       
   164         /**
       
   165         * Called by the timer callback function to progress the internal 
       
   166         * self-timer state accordingly.  
       
   167         * @since 2.8
       
   168         */
       
   169         void Tick();
       
   170 
       
   171         /**
       
   172         * Turns the indicators (LED/icon/tone) on or off depending on the 
       
   173         * parameter passed in.
       
   174         * @since 2.8
       
   175         * @param aOn If ETrue, turns the indication(s) on, else turns them off
       
   176         */
       
   177         void DoIndication( TBool aOn );
       
   178 
       
   179     public:     // Data
       
   180     
       
   181     protected:  // Data
       
   182 
       
   183     private:    // Data
       
   184 
       
   185         // Main timer
       
   186         CPeriodic* iPeriodicTimer;
       
   187         
       
   188         // Callback used for timer
       
   189         TCallBack iCallback;
       
   190         
       
   191         // Current state of the SelfTimer object
       
   192         TCamSelfTimer iState;               
       
   193 
       
   194         // Whether LED is currently on or off
       
   195         TBool iIndication;  
       
   196 
       
   197         // Specifies whether capturing video or still.
       
   198         TCamCameraMode         iMode; 
       
   199         // Image submode (single/burst/timelapse)
       
   200         TCamImageCaptureMode   iImageMode;
       
   201 
       
   202          
       
   203         // Tracks the time remaining before capture when timer is active.
       
   204         TTimeIntervalMicroSeconds32 iTimeRemaining;
       
   205 
       
   206         // Tracks the period between "ticks" when timer is active
       
   207         TTimeIntervalMicroSeconds32 iTimerTickPeriod; 
       
   208 
       
   209         // Camera Controller used to start autofocus/capture operations
       
   210         CCamAppController& iController;
       
   211 
       
   212         // array of self timer observer objects
       
   213         RPointerArray<MCamSelfTimerObserver> iObservers;
       
   214 
       
   215         // Holds the period details from the PSI
       
   216         TSelfTimerSetting iSettings;
       
   217 
       
   218         // Tracks the time that has elapsed since last indicator state change
       
   219         TInt iTimeElapsedSinceIndication;
       
   220 
       
   221     public:     // Friend classes        
       
   222     protected:  // Friend classes        
       
   223     private:    // Friend classes                
       
   224     };
       
   225 
       
   226 #endif      // CAMSELFTIMER_H   
       
   227             
       
   228 // End of File
       
   229 
       
   230 
       
   231 
       
   232 
       
   233 
       
   234 
       
   235 
       
   236 
       
   237 
       
   238 
       
   239 
       
   240 
       
   241 
       
   242