loadgen/inc/loadgen_photocapture.h
branchRCL_3
changeset 19 b3cee849fa46
parent 18 48060abbbeaf
child 20 fad26422216a
equal deleted inserted replaced
18:48060abbbeaf 19:b3cee849fa46
     1 /*
       
     2 * Copyright (c) 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 LOADGEN_PHOTOCAPTURE_H
       
    20 #define LOADGEN_PHOTOCAPTURE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <ecam.h>  // CCamera, MCameraObserver
       
    26 
       
    27 #include "loadgen_loadbase.h"
       
    28 #include "loadgen_loadattributes.h"
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CCameraManager;
       
    33 
       
    34 
       
    35 // CLASS DECLARATIONS
       
    36 
       
    37 class CPhotoCapture : public CLoadBase
       
    38     {
       
    39 public:
       
    40     static CPhotoCapture* NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber);
       
    41     virtual ~CPhotoCapture();
       
    42         
       
    43 private: // Constructors
       
    44     CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber);
       
    45     void ConstructL();  
       
    46 
       
    47 public:  // New methods
       
    48     virtual void Resume();
       
    49     virtual void Suspend();
       
    50     virtual void SetPriority();
       
    51     virtual void Close();
       
    52     virtual TPtrC Description();
       
    53     inline TPhotoCaptureAttributes& Attributes() { return iAttributes; }
       
    54 
       
    55 public:  // New static methods
       
    56     static TInt ThreadFunction(TAny* aThreadArg);
       
    57     //static void SetImagesReady(TInt aImages);
       
    58     //static TInt ImagesReady();
       
    59 
       
    60 private:  // New static methods
       
    61     static void GenerateLoad(TPhotoCaptureAttributes& aAttributes);
       
    62     static void DoHeaveStuff(TInt aMode);
       
    63 
       
    64 private: // Data
       
    65     TPhotoCaptureAttributes iAttributes;    
       
    66     RThread                 iThread;
       
    67     //static TInt             iImagesReady;
       
    68     };
       
    69  
       
    70 
       
    71 
       
    72  
       
    73 class CCameraManager : public CActive, public MCameraObserver
       
    74     {
       
    75     public:
       
    76         
       
    77         static CCameraManager* NewL(TPhotoCaptureAttributes& aAttrs);        
       
    78         virtual ~CCameraManager();
       
    79  
       
    80     private:
       
    81         
       
    82         CCameraManager(TPhotoCaptureAttributes& aAttrs);
       
    83         void ConstructL();
       
    84  
       
    85     private:
       
    86         /**
       
    87          * From MCameraObserver:
       
    88          */         
       
    89         virtual void ReserveComplete(TInt aError);
       
    90         virtual void PowerOnComplete(TInt aError);
       
    91         virtual void ViewFinderFrameReady(CFbsBitmap& aFrame);
       
    92         virtual void ImageReady(CFbsBitmap* aBitmap,
       
    93                 HBufC8* aData, TInt aError);
       
    94         virtual void FrameBufferReady(MFrameBuffer* aFrameBuffer,
       
    95                 TInt aError);
       
    96     
       
    97         static TInt PeriodicTimerCallBack(TAny* aAny);
       
    98     public:
       
    99         
       
   100         /**
       
   101          * Reserves the camera.
       
   102          */
       
   103         void ReserveCameraL();
       
   104         
       
   105         /**
       
   106          * Takes a picture.
       
   107          */
       
   108         void CapturePhotoL();
       
   109         
       
   110         TInt NumberOfPictures();
       
   111                                         
       
   112         /**
       
   113          * From CActive:
       
   114          */
       
   115         void RunL();
       
   116         void DoCancel();
       
   117  
       
   118     private:
       
   119         
       
   120         enum TState
       
   121             {
       
   122             ENotReady,
       
   123             ECameraReserved,
       
   124             EIdle,
       
   125             ECapture
       
   126             };
       
   127 
       
   128         CPeriodic*                  iPeriodicTimer;
       
   129         TPhotoCaptureAttributes&    iAttributes;
       
   130         CCamera*                    iCamera;
       
   131         TState                      iState;
       
   132         TInt                        iNumOfPics;
       
   133         TCameraInfo                 iCameraInfo;
       
   134         TInt                        iCurrentCamera;
       
   135     };
       
   136 
       
   137 
       
   138 #endif