camerauis/cameraapp/generic/src/cameracontroller/CamCamera.cpp
changeset 0 1ddebce53859
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     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:  
       
    15 *                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /*
       
    23 * Refer CCamCamera.h
       
    24 * Implementing the Interfaces defined in CCamCamera class duplicating the definitions
       
    25 * for Emulator Ennvironment
       
    26 */
       
    27 
       
    28 #include <e32cmn.h>
       
    29 #include "CamCamera.h"  // Interface declarations
       
    30 #include <ecam.h>
       
    31 #include "CamCamera.hrh" // Constants and Possible Events definitions
       
    32 #include "camcameracontroller.pan"     // Panic category and codes (use cameracontroller's)
       
    33 #include "camcameracontrollertypes.h"
       
    34 #include <AknIconUtils.h>
       
    35 #include <fbs.h>
       
    36 #include "CamCameraCallback.h"
       
    37 #include "CameraappTestBitmapManager.h"
       
    38 
       
    39 
       
    40 using namespace NCamCameraController;
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // NewL
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CCamCamera* 
       
    47 CCamCamera::NewL( MCameraObserver2& aObserver, 
       
    48                   TInt              aCameraIndex, 
       
    49                   TInt              aPriority )
       
    50   {
       
    51   CCamCamera* self = new (ELeave) CCamCamera
       
    52                                     ( aObserver, 
       
    53                                       aCameraIndex, 
       
    54                                       aPriority
       
    55                                     );
       
    56   CleanupStack::PushL( self );
       
    57   self->ConstructL();
       
    58   CleanupStack::Pop();
       
    59   return self;
       
    60   }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // New2L
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCamCamera* 
       
    67 CCamCamera::New2L( MCameraObserver2& aObserver,
       
    68                    TInt              aCameraIndex,
       
    69                    TInt              aPriority )
       
    70   {
       
    71   return CCamCamera::NewL( aObserver, aCameraIndex, aPriority );
       
    72   }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // NewL
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CCamCamera* 
       
    79 CCamCamera::NewL( MCameraObserver& aObserver, 
       
    80                   TInt             aCameraIndex )
       
    81   {
       
    82   CCamCamera* self = new (ELeave) CCamCamera( aObserver, aCameraIndex );
       
    83   CleanupStack::PushL( self );
       
    84   self->ConstructL();
       
    85   CleanupStack::Pop();
       
    86   return self;
       
    87   }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // New2L
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CCamCamera* 
       
    94 CCamCamera::New2L( MCameraObserver& /*aObserver   */,
       
    95                    TInt             /*aCameraIndex*/ )
       
    96   {
       
    97   // Also CCamera implementation rejects New2L + MCameraObserver(1)
       
    98   User::Leave( KErrNotSupported );
       
    99   return NULL;
       
   100   }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // ~CCamCamera
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 /*
       
   107 * CCamCamera::NewDuplicateL
       
   108 */
       
   109 CCamCamera* 
       
   110 CCamCamera::NewDuplicateL( MCameraObserver2& /*aObserver*/,
       
   111                            TInt              /*aCameraHandle*/ )
       
   112   {
       
   113   User::Leave( KErrNotSupported );
       
   114   return NULL;
       
   115   }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // NewDuplicate2L
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 CCamCamera* 
       
   122 CCamCamera::NewDuplicate2L( MCameraObserver2& /*aObserver*/,
       
   123                             TInt              /*aCameraHandle*/ )
       
   124   {
       
   125   User::Leave( KErrNotSupported );
       
   126   return NULL;
       
   127   }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // NewDuplicateL
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 CCamCamera* 
       
   135 CCamCamera::NewDuplicateL( MCameraObserver& /*aObserver*/,
       
   136                            TInt             /*aCameraHandle*/ )
       
   137   {
       
   138   User::Leave( KErrNotSupported );
       
   139   return NULL;
       
   140   }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // NewDuplicate2L
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 CCamCamera* 
       
   147 CCamCamera::NewDuplicate2L( MCameraObserver& /*aObserver*/,
       
   148                             TInt             /*aCameraHandle*/ )
       
   149   {
       
   150   User::Leave( KErrNotSupported );
       
   151   return NULL;
       
   152   }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // ~CCamCamera
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 CCamCamera::~CCamCamera()
       
   159   {
       
   160   iPhotoResolutions.Reset();
       
   161   delete iCallBackActive;
       
   162   delete iBitmapManager;
       
   163   if( iVfPeriodic )
       
   164     {                
       
   165     iVfPeriodic->Cancel();
       
   166     delete iVfPeriodic;
       
   167     }
       
   168   }
       
   169 
       
   170 
       
   171 
       
   172 
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CamerasAvailable
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 TInt 
       
   179 CCamCamera::CamerasAvailable()
       
   180   {
       
   181   return 2;
       
   182   }
       
   183 
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Reserve
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void 
       
   190 CCamCamera::Reserve()
       
   191   {
       
   192   TInt status = KErrNone;
       
   193   if ( ECamIdle == iState )
       
   194     {
       
   195     iState |= ECamReserved;
       
   196     }
       
   197   else
       
   198     {
       
   199     status = KErrInUse;
       
   200     }
       
   201     
       
   202   User::After( KDelayReserve );
       
   203 
       
   204   if ( iCallBackActive )
       
   205     {
       
   206     iCallBackActive->ReserveCompleteRequest( status );
       
   207     }
       
   208   }
       
   209 
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // PowerOn
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 void 
       
   216 CCamCamera::PowerOn()
       
   217   {
       
   218   TInt status = KErrNone;
       
   219 
       
   220   if      ( ECamIdle     == iState ) status = KErrNotReady;
       
   221   else if ( ECamReserved != iState ) status = KErrInUse;
       
   222   else                               iState |= ECamPowerOn;
       
   223 
       
   224   User::After( KDelayPowerOn );
       
   225 
       
   226   if ( iCallBackActive )
       
   227     {
       
   228     iCallBackActive->PowerOnCompleteRequest( status );
       
   229     }
       
   230   }
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // Release
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 void 
       
   237 CCamCamera::Release()
       
   238   {
       
   239   iState = ECamIdle;
       
   240   }
       
   241   
       
   242 // ---------------------------------------------------------------------------
       
   243 // PowerOff
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246  void CCamCamera::PowerOff()
       
   247   {
       
   248   iState = ECamIdle | ECamReserved;
       
   249 
       
   250   User::After( KDelayPowerOff );
       
   251   }
       
   252 
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // Handle
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 TInt 
       
   259 CCamCamera::Handle()
       
   260   {
       
   261   return KCameraHandle;
       
   262   };
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // SetZoomFactorL
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 void  
       
   269 CCamCamera::SetZoomFactorL( TInt aZoomFactor )
       
   270   {
       
   271   if( Rng( iInfo.iMinZoom, aZoomFactor, iInfo.iMaxZoom ) )
       
   272     {
       
   273     iZoomFactor = aZoomFactor;
       
   274     }
       
   275     else
       
   276     {
       
   277     User::Leave( KErrNotSupported );
       
   278     }
       
   279   }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // ZoomFactor
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 TInt 
       
   286 CCamCamera::ZoomFactor() const
       
   287   {
       
   288   return iZoomFactor;
       
   289   }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // SetDigitalZoomFactorL
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 void  
       
   296 CCamCamera::SetDigitalZoomFactorL( TInt aDigitalZoomFactor )
       
   297   {
       
   298   if( Rng( 0, aDigitalZoomFactor, iInfo.iMaxDigitalZoom ) )
       
   299     {
       
   300     iDigitalZoom = aDigitalZoomFactor;
       
   301     }
       
   302   else
       
   303     {
       
   304     User::Leave( KErrNotSupported );
       
   305     }
       
   306   }
       
   307 
       
   308 // ---------------------------------------------------------------------------
       
   309 // DigitalZoomFactor
       
   310 // ---------------------------------------------------------------------------
       
   311 //
       
   312 TInt 
       
   313 CCamCamera::DigitalZoomFactor() const
       
   314   {
       
   315   return iDigitalZoom;
       
   316   }
       
   317 
       
   318 // ---------------------------------------------------------------------------
       
   319 // SetContrastL
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 void  
       
   323 CCamCamera::SetContrastL( TInt aContrast )
       
   324   {
       
   325   if( EContrastAuto == aContrast )
       
   326     {
       
   327     iContrast = EContrastAuto;
       
   328     }
       
   329   else if( Rng( -100, aContrast, 100 ) )
       
   330     {
       
   331     iContrast = aContrast;
       
   332     }
       
   333   else
       
   334     {
       
   335     User::Leave( KErrNotSupported );  
       
   336     }
       
   337   }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // Contrast
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 TInt 
       
   344 CCamCamera::Contrast() const
       
   345   {
       
   346   return iContrast;
       
   347   }
       
   348 
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // SetBrightnessL
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 void 
       
   355 CCamCamera::SetBrightnessL(TInt aBrightness)
       
   356   {
       
   357   if( EContrastAuto == aBrightness )
       
   358     {
       
   359     iBrightness = EBrightnessAuto;
       
   360     }
       
   361   else if( Rng( -100, aBrightness, 100 ) )
       
   362     {
       
   363     iBrightness = aBrightness;
       
   364     }
       
   365   else
       
   366     {
       
   367     User::Leave( KErrNotSupported );  
       
   368     }
       
   369   }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // Brightness
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 TInt 
       
   376 CCamCamera::Brightness() const
       
   377   {
       
   378   return iBrightness;
       
   379   }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // SetFlashL
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 void
       
   386 CCamCamera::SetFlashL( TFlash aFlash )
       
   387   {
       
   388   if( CCamCamera::EFlashNone == aFlash // Zero, so need special attention
       
   389    || KFlashModeSupport      &  aFlash ) iFlash = aFlash;
       
   390   else                                   User::Leave( KErrNotSupported );
       
   391   }
       
   392 
       
   393 // ---------------------------------------------------------------------------
       
   394 // Flash
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 CCamCamera::TFlash 
       
   398 CCamCamera::Flash() const
       
   399   {
       
   400   return iFlash;
       
   401   }
       
   402 
       
   403 // ---------------------------------------------------------------------------
       
   404 // SetExposureL
       
   405 // ---------------------------------------------------------------------------
       
   406 //
       
   407 void 
       
   408 CCamCamera::SetExposureL(TExposure aExposure )
       
   409   {
       
   410   if( CCamCamera::EExposureAuto == aExposure 
       
   411    || KExposureSupport          &  aExposure ) iExposure = aExposure;
       
   412   else                                         User::Leave( KErrNotSupported );
       
   413   }
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // Exposure
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 CCamCamera::TExposure 
       
   420 CCamCamera::Exposure() const
       
   421   {
       
   422   return iExposure;
       
   423   }
       
   424 
       
   425 // ---------------------------------------------------------------------------
       
   426 // SetWhiteBalanceL
       
   427 // ---------------------------------------------------------------------------
       
   428 //
       
   429 void 
       
   430 CCamCamera::SetWhiteBalanceL( TWhiteBalance aWhiteBalance )
       
   431   {
       
   432   if( CCamCamera::EWBAuto == aWhiteBalance
       
   433    || KWBSupport          &  aWhiteBalance ) iWhiteBalance = aWhiteBalance;
       
   434   else                                       User::Leave( KErrNotSupported );
       
   435   }
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // WhiteBalance
       
   439 // ---------------------------------------------------------------------------
       
   440 //
       
   441 CCamCamera::TWhiteBalance 
       
   442 CCamCamera::WhiteBalance() const
       
   443   {
       
   444   return iWhiteBalance;
       
   445   }
       
   446 
       
   447 
       
   448 // ---------------------------------------------------------------------------
       
   449 // StartViewFinderDirectL
       
   450 // ---------------------------------------------------------------------------
       
   451 //
       
   452 void 
       
   453 CCamCamera::StartViewFinderDirectL( RWsSession& /*aWs*/,
       
   454                                    CWsScreenDevice& /*aScreenDevice*/,
       
   455                                    RWindowBase& /*aWindow*/,
       
   456                                    TRect& /*aScreenRect*/ )
       
   457   {
       
   458   User::Leave( KErrNotSupported );
       
   459   }
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // StartViewFinderDirectL
       
   463 // ---------------------------------------------------------------------------
       
   464 //
       
   465 void 
       
   466 CCamCamera::StartViewFinderDirectL( RWsSession& /*aWs*/,
       
   467                                     CWsScreenDevice& /*aScreenDevice*/,
       
   468                                     RWindowBase& /*aWindow*/,
       
   469                                     TRect& /*aScreenRect*/,
       
   470                                     TRect& /*aClipRect*/ )
       
   471   {
       
   472   User::Leave( KErrNotSupported );
       
   473   }
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 // StartViewFinderBitmapsL
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 void 
       
   480 CCamCamera::StartViewFinderBitmapsL( TSize& aSize )
       
   481   {  
       
   482   iViewfinderSize = aSize;
       
   483 
       
   484   iVfPeriodic->Start( KVfFrameInterval, 
       
   485                       KVfFrameInterval, 
       
   486                       TCallBack( ViewfinderCallBack, this ) 
       
   487                      );
       
   488 
       
   489   iState |= ECamVFOn;
       
   490   }
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // StartViewFinderBitmapsL
       
   494 // ---------------------------------------------------------------------------
       
   495 //
       
   496 void 
       
   497 CCamCamera::StartViewFinderBitmapsL( TSize& aSize,
       
   498                                      TRect& aClipRect )
       
   499   {
       
   500   StartViewFinderBitmapsL( aSize );
       
   501   aSize     = iViewfinderSize;
       
   502   aClipRect = TRect( iViewfinderSize );  
       
   503   }
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 // StartViewFinderL
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 void 
       
   510 CCamCamera::StartViewFinderL( TFormat /*aImageFormat*/,
       
   511                               TSize&  /*aSize*/ )
       
   512   {
       
   513   User::Leave( KErrNotSupported );
       
   514   }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // StartViewFinderL
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 void 
       
   521 CCamCamera::StartViewFinderL( TFormat /*aImageFormat*/,
       
   522                               TSize&  /*aSize*/,
       
   523                               TRect&  /*aClipRect*/ )
       
   524   {
       
   525   User::Leave( KErrNotSupported );
       
   526   }
       
   527 
       
   528 // ---------------------------------------------------------------------------
       
   529 // StopViewFinder
       
   530 // ---------------------------------------------------------------------------
       
   531 //
       
   532 void 
       
   533 CCamCamera::StopViewFinder()
       
   534   {
       
   535   // Stop the viewfinder frames
       
   536   iVfPeriodic->Cancel();
       
   537 
       
   538   iState &= ~ECamVFOn;
       
   539   }
       
   540 
       
   541 // ---------------------------------------------------------------------------
       
   542 // ViewFinderActive
       
   543 // ---------------------------------------------------------------------------
       
   544 //
       
   545 TBool 
       
   546 CCamCamera::ViewFinderActive() const
       
   547   {
       
   548   return ( iState & ECamVFOn );
       
   549   }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // SetViewFinderMirrorL
       
   553 // ---------------------------------------------------------------------------
       
   554 //
       
   555 void 
       
   556 CCamCamera::SetViewFinderMirrorL( TBool aMirror )
       
   557   {
       
   558   iViewFinderMirror = aMirror;
       
   559   }
       
   560 
       
   561 // ---------------------------------------------------------------------------
       
   562 // ViewFinderMirror
       
   563 // ---------------------------------------------------------------------------
       
   564 //
       
   565 TBool 
       
   566 CCamCamera::ViewFinderMirror() const
       
   567   {
       
   568   return iViewFinderMirror;
       
   569   }
       
   570 
       
   571 // ---------------------------------------------------------------------------
       
   572 // PrepareImageCaptureL
       
   573 // ---------------------------------------------------------------------------
       
   574 //
       
   575  void 
       
   576 CCamCamera::PrepareImageCaptureL( TFormat aImageFormat, TInt aSizeIndex )
       
   577   {
       
   578   TRect temp;
       
   579   PrepareImageCaptureL( aImageFormat, aSizeIndex, temp );
       
   580   }
       
   581 
       
   582 // ---------------------------------------------------------------------------
       
   583 // PrepareImageCaptureL
       
   584 // ---------------------------------------------------------------------------
       
   585 //
       
   586 void 
       
   587 CCamCamera::PrepareImageCaptureL( TFormat      aImageFormat, 
       
   588                                   TInt         aSizeIndex, 
       
   589                                   const TRect& /*aClipRect*/ )
       
   590   {
       
   591   if( ECamPowerOn & iState )
       
   592     {
       
   593     TSize size;
       
   594     EnumerateCaptureSizes( size, aSizeIndex, aImageFormat );
       
   595     iState |= ECamImageOn;
       
   596     }
       
   597   else
       
   598     {
       
   599     User::Leave( KErrNotReady );
       
   600     }
       
   601   }
       
   602 
       
   603 // ---------------------------------------------------------------------------
       
   604 // CaptureImage
       
   605 // ---------------------------------------------------------------------------
       
   606 //
       
   607 void 
       
   608 CCamCamera::CaptureImage()
       
   609   {
       
   610   if ( iCallBackActive )
       
   611     {
       
   612     iCallBackActive->RequestCaptureImage();
       
   613     }
       
   614   }
       
   615 
       
   616 // ---------------------------------------------------------------------------
       
   617 // CancelCaptureImage
       
   618 // ---------------------------------------------------------------------------
       
   619 //
       
   620 void 
       
   621 CCamCamera::CancelCaptureImage()
       
   622   {
       
   623   
       
   624   // In Wins we dont exactly start any async method
       
   625   // to capture the image. 
       
   626   }
       
   627 
       
   628 // ---------------------------------------------------------------------------
       
   629 // EnumerateCaptureSizes
       
   630 // ---------------------------------------------------------------------------
       
   631 ///
       
   632 void 
       
   633 CCamCamera::EnumerateCaptureSizes( TSize&  aSize,
       
   634                                    TInt    aSizeIndex,
       
   635                                    TFormat aFormat ) const
       
   636   {
       
   637   switch( aFormat )
       
   638     {
       
   639     // -----------------------------------------------------
       
   640     case EFormatJpeg:
       
   641       //
       
   642       // switch( aSizeIndex )
       
   643       //  {
       
   644       aSize = iPhotoResolutions[ aSizeIndex ];                
       
   645       // case 0:  aSize = KImageSizeJpegCam1; break;
       
   646       // default: aSize = TSize();        break;       
       
   647       //  }
       
   648       break;
       
   649     // -----------------------------------------------------
       
   650     case EFormatExif:      
       
   651       // switch( aSizeIndex )
       
   652       //  {      
       
   653       aSize = iPhotoResolutions[ aSizeIndex ];        
       
   654       //  case 0:  aSize = KImageSizeExifCam1; break;
       
   655       //  default: aSize = TSize();        break;       
       
   656       //   }
       
   657       break;
       
   658     // -----------------------------------------------------
       
   659     default:
       
   660       aSize = TSize();
       
   661       break;
       
   662     // -----------------------------------------------------
       
   663     }
       
   664   }
       
   665 
       
   666 // ---------------------------------------------------------------------------
       
   667 // PrepareVideoCaptureL
       
   668 // ---------------------------------------------------------------------------
       
   669 //
       
   670 void 
       
   671 CCamCamera::PrepareVideoCaptureL( TFormat /*aFormat*/,
       
   672                                   TInt /*aSizeIndex*/,
       
   673                                   TInt /*aRateIndex*/,
       
   674                                   TInt /*aBuffersToUse*/,
       
   675                                   TInt /*aFramesPerBuffer*/ )
       
   676   {
       
   677   User::Leave( KErrNotSupported );
       
   678   }
       
   679 
       
   680 // ---------------------------------------------------------------------------
       
   681 // PrepareVideoCaptureL
       
   682 // ---------------------------------------------------------------------------
       
   683 //
       
   684 void 
       
   685 CCamCamera::PrepareVideoCaptureL( TFormat /*aFormat*/,
       
   686                                   TInt /*aSizeIndex*/,
       
   687                                   TInt /*aRateIndex*/,
       
   688                                   TInt /*aBuffersToUse*/,
       
   689                                   TInt /*aFramesPerBuffer*/,
       
   690                                   const TRect& /*aClipRect*/ )
       
   691   {
       
   692   User::Leave( KErrNotSupported );
       
   693   }
       
   694 
       
   695 // ---------------------------------------------------------------------------
       
   696 // StartVideoCapture
       
   697 // ---------------------------------------------------------------------------
       
   698 //
       
   699 void 
       
   700 CCamCamera::StartVideoCapture()
       
   701   {
       
   702   Panic( ECamCameraControllerUnsupported );
       
   703   }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 // StopVideoCapture
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 void 
       
   710 CCamCamera::StopVideoCapture()
       
   711   {
       
   712   Panic( ECamCameraControllerUnsupported );
       
   713   }
       
   714 
       
   715 // ---------------------------------------------------------------------------
       
   716 // VideoCaptureActive
       
   717 // ---------------------------------------------------------------------------
       
   718 //
       
   719 TBool 
       
   720 CCamCamera::VideoCaptureActive() const
       
   721   {
       
   722   return EFalse;
       
   723   }
       
   724 
       
   725 // ---------------------------------------------------------------------------
       
   726 // EnumerateVideoFrameSizes
       
   727 // ---------------------------------------------------------------------------
       
   728 //
       
   729 void 
       
   730 CCamCamera::EnumerateVideoFrameSizes( TSize& /*aSize*/,
       
   731                                       TInt /*aSizeIndex*/,
       
   732                                       TFormat /*aFormat*/ ) const
       
   733   {
       
   734   // Video not supported
       
   735   Panic( ECamCameraControllerUnsupported );
       
   736   }
       
   737 
       
   738 // ---------------------------------------------------------------------------
       
   739 // EnumerateVideoFrameRates
       
   740 // ---------------------------------------------------------------------------
       
   741 //
       
   742 void 
       
   743 CCamCamera::EnumerateVideoFrameRates(
       
   744             TReal32& /*aRate*/,
       
   745             TInt /*aRateIndex*/,
       
   746             TFormat /*aFormat*/,
       
   747             TInt /*aSizeIndex*/,
       
   748             CCamCamera::TExposure /*aExposure*/ ) const
       
   749   {
       
   750   // Video not supported
       
   751   Panic( ECamCameraControllerUnsupported );
       
   752   }
       
   753 
       
   754 
       
   755 // ---------------------------------------------------------------------------
       
   756 // GetFrameSize
       
   757 // ---------------------------------------------------------------------------
       
   758 //
       
   759 void 
       
   760 CCamCamera::GetFrameSize( TSize& /*aSize*/ ) const
       
   761   {
       
   762   // Video not supported
       
   763   Panic( ECamCameraControllerUnsupported );
       
   764   }
       
   765 
       
   766 // ---------------------------------------------------------------------------
       
   767 // FrameRate
       
   768 // ---------------------------------------------------------------------------
       
   769 //
       
   770 TReal32 
       
   771 CCamCamera::FrameRate() const
       
   772   {
       
   773   // Video not supported
       
   774   Panic( ECamCameraControllerUnsupported );
       
   775 
       
   776   return 0;
       
   777   }
       
   778 
       
   779 // ---------------------------------------------------------------------------
       
   780 // BuffersInUse
       
   781 // ---------------------------------------------------------------------------
       
   782 //
       
   783 TInt 
       
   784 CCamCamera::BuffersInUse() const
       
   785   {
       
   786   // Not sure
       
   787   return 1;
       
   788   } 
       
   789 
       
   790 // ---------------------------------------------------------------------------
       
   791 // FramesPerBuffer
       
   792 // ---------------------------------------------------------------------------
       
   793 //
       
   794 TInt 
       
   795 CCamCamera::FramesPerBuffer() const
       
   796   {
       
   797   return 1;
       
   798   }
       
   799 
       
   800 // ---------------------------------------------------------------------------
       
   801 // SetJpegQuality
       
   802 // ---------------------------------------------------------------------------
       
   803 //
       
   804 void 
       
   805 CCamCamera::SetJpegQuality( TInt aQuality )
       
   806   {
       
   807   iQuality = Min( 100, Max( 0, aQuality ) );
       
   808   }
       
   809 
       
   810 // ---------------------------------------------------------------------------
       
   811 // JpegQuality
       
   812 // ---------------------------------------------------------------------------
       
   813 //
       
   814 TInt 
       
   815 CCamCamera::JpegQuality() const
       
   816   {
       
   817   return iQuality;
       
   818   }
       
   819 
       
   820 // ---------------------------------------------------------------------------
       
   821 // CustomInterface
       
   822 // ---------------------------------------------------------------------------
       
   823 //
       
   824 TAny* 
       
   825 CCamCamera::CustomInterface( TUid /*aInterface*/ )
       
   826   {
       
   827   return NULL;
       
   828   }
       
   829 
       
   830 // ---------------------------------------------------------------------------
       
   831 // CameraInfo
       
   832 // ---------------------------------------------------------------------------
       
   833 //
       
   834 void  
       
   835 CCamCamera::CameraInfo( TCameraInfo& aInfo ) const
       
   836   {
       
   837 	aInfo.iHardwareVersion             = TVersion( 0, 0, 2007 ); /** Version number and name of camera hardware. */
       
   838 	aInfo.iSoftwareVersion             = TVersion( 0, 0, 2007 ); /** Version number and name of camera software (device driver). */
       
   839 	aInfo.iOrientation                 = TCameraInfo::EOrientationUnknown;
       
   840     aInfo.iOptionsSupported            = KOptionsSupport;
       
   841 	aInfo.iFlashModesSupported         = KFlashModeSupport;
       
   842 	aInfo.iExposureModesSupported      = KExposureSupport;
       
   843 	aInfo.iWhiteBalanceModesSupported  = KWBSupport;
       
   844 	aInfo.iMinZoom                     = 0;
       
   845 	aInfo.iMaxZoom                     = 100;
       
   846 	aInfo.iMaxDigitalZoom              = 100;
       
   847 	aInfo.iMinZoomFactor               = 1.0;
       
   848 	aInfo.iMaxZoomFactor               = 10.0;
       
   849 	aInfo.iMaxDigitalZoomFactor        = 10.0;
       
   850 	// aInfo.iNumImageSizesSupported      = 1;	
       
   851 	aInfo.iNumImageSizesSupported      = iPhotoResolutions.Count();
       
   852 	aInfo.iImageFormatsSupported       = (iCameraIndex == 0)? KImageFormatSupportCAM1 : KImageFormatSupportCAM2;;
       
   853 	aInfo.iNumVideoFrameSizesSupported = 1;
       
   854 	aInfo.iNumVideoFrameRatesSupported = 1;
       
   855 	aInfo.iVideoFrameFormatsSupported  = (iCameraIndex == 0)? KVideoFormatSupportCAM1 : KVideoFormatSupportCAM2;;
       
   856 	aInfo.iMaxFramesPerBufferSupported = 1;
       
   857 	aInfo.iMaxBuffersSupported         = 2;
       
   858   }
       
   859 
       
   860 
       
   861 // ---------------------------------------------------------------------------
       
   862 // InitPhotoResolutionsL
       
   863 // ---------------------------------------------------------------------------
       
   864 //
       
   865 void CCamCamera::InitPhotoResolutionsL()
       
   866     {
       
   867     iPhotoResolutions.Append( TSize(  640,  480 ) ); // VGA
       
   868     iPhotoResolutions.Append( TSize(  800,  600 ) ); // SVGA
       
   869     iPhotoResolutions.Append( TSize( 1024,  768 ) ); // XGA
       
   870     iPhotoResolutions.Append( TSize( 1152,  864 ) ); // 1 MP
       
   871     iPhotoResolutions.Append( TSize( 1280,  960 ) ); // 1.3 MP
       
   872     iPhotoResolutions.Append( TSize( 1600, 1200 ) ); // 2 MP
       
   873     iPhotoResolutions.Append( TSize( 2048, 1536 ) ); // 3 MP
       
   874     iPhotoResolutions.Append( TSize( 2592, 1944 ) ); // 5 MP
       
   875     iPhotoResolutions.Append( TSize( 3264, 2448 ) ); // 8 MP
       
   876     iPhotoResolutions.Append( TSize( 4000, 3000 ) ); // 12 MP
       
   877     iPhotoResolutions.Append( TSize( 3264, 1832 ) ); // 6 MP 16:9
       
   878     iPhotoResolutions.Append( TSize( 4000, 2248 ) ); // 9 MP 16:9
       
   879     iPhotoResolutions.Append( TSize(  354,  288 ) ); // CIF
       
   880     iPhotoResolutions.Append( TSize(  320,  240 ) ); // QVGA
       
   881     }
       
   882 
       
   883 
       
   884 // ---------------------------------------------------------------------------
       
   885 // ViewfinderCallBack
       
   886 // ---------------------------------------------------------------------------
       
   887 //
       
   888 TInt 
       
   889 CCamCamera::ViewfinderCallBack( TAny* aSelf )
       
   890   {
       
   891   CCamCamera* self = static_cast<CCamCamera*>( aSelf );
       
   892   if( self && self->iObserver )
       
   893     {
       
   894     self->iObserver->ViewFinderFrameReady( self->iBitmapManager->NextBitmap() );         
       
   895     }
       
   896   return KErrNone;    
       
   897   }
       
   898     
       
   899 // ===========================================================================
       
   900 // Constructors
       
   901 
       
   902 
       
   903 // ---------------------------------------------------------------------------
       
   904 // 2nd phase constructor
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 void CCamCamera::ConstructL()
       
   908   {
       
   909   InitPhotoResolutionsL();
       
   910   iBitmapManager  = CCameraappTestBitmapManager::NewL();
       
   911   iVfPeriodic     = CPeriodic::NewL( EPriorityLow );
       
   912   iCallBackActive = CCamCameraCallBack::NewL( *iObserver );
       
   913 
       
   914   CameraInfo( iInfo );
       
   915   }
       
   916 
       
   917 
       
   918 // ---------------------------------------------------------------------------
       
   919 // 1st phase constructor
       
   920 // CCamCamera::CCamCamera
       
   921 // ---------------------------------------------------------------------------
       
   922 //
       
   923 CCamCamera::CCamCamera( MCameraObserver& aObserver, TInt aCameraIndex )
       
   924   : iObserver   ( &aObserver   ),
       
   925     iState      ( ECamIdle     ),
       
   926     iCameraIndex( aCameraIndex )
       
   927   {
       
   928   }
       
   929 
       
   930 // ---------------------------------------------------------------------------
       
   931 // CCamCamera::CCamCamera
       
   932 //
       
   933 // ---------------------------------------------------------------------------
       
   934 //
       
   935 CCamCamera::CCamCamera( MCameraObserver2& aObserver,TInt aCameraIndex, TInt aPriority )
       
   936   : iObserver2  ( &aObserver   ),
       
   937     iState      ( ECamIdle     ),
       
   938     iCameraIndex( aCameraIndex ),
       
   939     iPriority   ( aPriority    )
       
   940   {
       
   941   }
       
   942 
       
   943 
       
   944 void CCamCamera::Construct2L(MCameraObserver& /*aObserver*/, TInt /*aCameraIndex*/)
       
   945     {
       
   946     // not implemented
       
   947     }
       
   948 
       
   949 void CCamCamera::Construct2DupL(MCameraObserver& /*aObserver*/, TInt /*aCameraHandle*/)
       
   950     {
       
   951     // not implemented
       
   952     }
       
   953 
       
   954 void CCamCamera::Construct2L(MCameraObserver2& /*aObserver*/, TInt /*aCameraIndex*/, TInt /*aPriority*/)
       
   955     {
       
   956     // not implemented
       
   957     }
       
   958 
       
   959 void CCamCamera::Construct2DupL(MCameraObserver2& /*aObserver*/, TInt /*aCameraHandle*/)
       
   960     {
       
   961     // not implemented
       
   962     }
       
   963 
       
   964 
       
   965 // end of file
       
   966 
       
   967