camerasrv_plat/camera_application_engine_api/tsrc/src/CaeTestClient.cpp
changeset 15 50d5061ee01e
parent 14 34024902876b
child 17 880d946921e4
equal deleted inserted replaced
14:34024902876b 15:50d5061ee01e
     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: CaeTestClient.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 #include <fbs.h>
       
    19 
       
    20 #include "CaeTestClient.h"
       
    21 #include "CaeTestVariation.h"
       
    22 
       
    23 // Set 0
       
    24 _LIT8(KVideoMimeType, "video/3gpp");
       
    25 _LIT(KVideoPreferredSupplier, "Nokia");
       
    26 _LIT8(KVideoType, "video/H263-2000");
       
    27 _LIT8(KVideoAudioType, " AMR");
       
    28 // Set 1 for 2.7 
       
    29 _LIT8(KVideoMimeType1, "video/3gpp2");
       
    30 _LIT(KVideoPreferredSupplier1, "Nokia");
       
    31 _LIT8(KVideoType1, "video/H263-2000"); // H.263 video
       
    32 _LIT8(KVideoAudioType1, " AMR");       // AMR audio
       
    33 // Set 2 for 2.7 AAC
       
    34 _LIT8(KVideoMimeType2, "video/3gpp2");
       
    35 _LIT(KVideoPreferredSupplier2, "Nokia");
       
    36 _LIT8(KVideoType2, "video/mp4v-es");   // MPEG-4 video
       
    37 _LIT8(KVideoAudioType2, " AAC");       // AAC audio
       
    38 // Set 3 for 2.8
       
    39 _LIT8(KVideoMimeType3, "video/3gpp");
       
    40 _LIT(KVideoPreferredSupplier3, "Nokia");
       
    41 _LIT8(KVideoType3, "video/H263-2000; profile=0; level=45");
       
    42 _LIT8(KVideoAudioType3, " AMR");
       
    43 
       
    44 
       
    45 CCaeTestClient::CCaeTestClient () : 
       
    46     CTimer( CActive::EPriorityStandard )
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 CCaeTestClient::~CCaeTestClient()
       
    52     {
       
    53     Cancel();
       
    54     delete iCameraDup;
       
    55     delete iCamAppEngine;
       
    56     
       
    57     iFsSession.Close();
       
    58     RFbsSession::Disconnect();
       
    59     delete iBitmapSave;
       
    60     delete iDataSave;
       
    61 
       
    62     }
       
    63 
       
    64 
       
    65 void CCaeTestClient::ConstructL()
       
    66     {
       
    67     // Initializing: FBS session, bitmaps and so on.
       
    68     User::LeaveIfError( FbsStartup() ); // Ensure Fbserv has started up OK
       
    69     User::LeaveIfError( RFbsSession::Connect() );
       
    70  
       
    71     // Connect and open output data file.
       
    72     #if ( WRITE_VIDEOTIMES_TO_FILE )
       
    73     User::LeaveIfError( iFsSession.Connect() );
       
    74     User::LeaveIfError( iFile.Replace( iFsSession, KProcessFileName, EFileShareAny ) );
       
    75     TInt aPos;
       
    76     User::LeaveIfError( iFile.Seek( ESeekEnd, aPos ) );
       
    77     iFile.Write( _L8( "CaeTestClient output data\n" ) );
       
    78     iFile.Close();
       
    79     #endif
       
    80 
       
    81     iSnapFileName  = KiSnapFileName;
       
    82     iStillFileName = KiStillFileName;
       
    83     iVideoFileName = KiVideoFileName;
       
    84     iVideoFileName2 = KiVideoFileName2;
       
    85     iVideoFileName3 = KiVideoFileName3;
       
    86     iVideoFileName4 = KiVideoFileName4;
       
    87     
       
    88     iCreateSnapImage = ETrue;
       
    89     
       
    90     TRect emptyRect( 0, 0, 0, 0 );
       
    91     iCropRect = emptyRect;
       
    92 
       
    93     TSize sizeEmpty;
       
    94     iSizeEmpty = sizeEmpty;
       
    95 
       
    96     TSize sizeSubQcif( KImgWidthSubQCIF, KImgHeightSubQCIF );
       
    97     iViewFinderSize    = sizeSubQcif;
       
    98 
       
    99     iStillFrameSize    = TSize( KDefaultStillImageWidth, KDefaultStillImageHeight );
       
   100 
       
   101 	iSnapImageSize = TSize(0, 0);
       
   102 
       
   103     iSnapImageSource = CCaeEngine::ESnapImageSourceOriginal;
       
   104     iStillDataFormat = KDefaultStillDataFormat;
       
   105 	iSnapImageColorMode = (TDisplayMode)0;
       
   106 
       
   107     iStillCompressionQuality = 95;
       
   108 
       
   109     iStillBurstLength = 1;
       
   110 
       
   111     iVideoFrameSize = sizeSubQcif;
       
   112     iBitmapSave = NULL;
       
   113     iDataSave = NULL;
       
   114 
       
   115     iCamAppEngine = CCaeEngine::NewL();
       
   116 
       
   117 // If interface after S60 2.1.
       
   118 #ifndef CAE_INTERFACE_21
       
   119     if ( iAction != ESpecifiedPrepareAndRecordVideoNoInit )
       
   120         {
       
   121         // For testing with the version inputting camera index and 
       
   122         // CCaeEngine::CamerasAvailable().
       
   123         delete iCamAppEngine;
       
   124         iCamAppEngine = NULL;
       
   125         if ( CCaeEngine::CamerasAvailable() > 0 ) 
       
   126             {
       
   127             iCamAppEngine = CCaeEngine::NewL( 0 );
       
   128             }
       
   129         else 
       
   130             {
       
   131             User::Leave( KErrHardwareNotAvailable );
       
   132             }
       
   133     
       
   134         }
       
   135 #endif
       
   136 
       
   137     iCamAppEngine->SetCamAppEngineObserver( *this );
       
   138     iCamAppEngine->SetCaeStillBurstObserver( *this );
       
   139 
       
   140     iTimeout = 500000;
       
   141 
       
   142 	iCamAppEngine->GetInfo( iInfo );
       
   143 
       
   144     iOpMode = EClientOpModeStill;
       
   145 
       
   146 	iStopOnErrorInMcaeoSnapImageReady = ETrue;
       
   147 	iStopOnErrorInMcaeoStillImageReady = ETrue;
       
   148 
       
   149     iVideoCodecSet = 0; // default set in use
       
   150 
       
   151     //set 0
       
   152     iMimeTypeSet[0]          = &KVideoMimeType;
       
   153     iPreferredSupplierSet[0] = &KVideoPreferredSupplier;
       
   154     iVideoTypeSet[0]         = &KVideoType;
       
   155     iAudioTypeSet[0]         = &KVideoAudioType;
       
   156 
       
   157     //set 1
       
   158     iMimeTypeSet[1]          = &KVideoMimeType1;
       
   159     iPreferredSupplierSet[1] = &KVideoPreferredSupplier1;
       
   160     iVideoTypeSet[1]         = &KVideoType1;
       
   161     iAudioTypeSet[1]         = &KVideoAudioType1;
       
   162 
       
   163     //set 2
       
   164     iMimeTypeSet[2]          = &KVideoMimeType2;
       
   165     iPreferredSupplierSet[2] = &KVideoPreferredSupplier2;
       
   166     iVideoTypeSet[2]         = &KVideoType2;
       
   167     iAudioTypeSet[2]         = &KVideoAudioType2;
       
   168 
       
   169     //set 3
       
   170     iMimeTypeSet[3]          = &KVideoMimeType3;
       
   171     iPreferredSupplierSet[3] = &KVideoPreferredSupplier3;
       
   172     iVideoTypeSet[3]         = &KVideoType3;
       
   173     iAudioTypeSet[3]         = &KVideoAudioType3;
       
   174 
       
   175     CTimer::ConstructL();
       
   176     CActiveScheduler::Add( this );
       
   177     }
       
   178 
       
   179 
       
   180 void CCaeTestClient::InitStateVariables()
       
   181     {
       
   182     iError = KErrNone;
       
   183 
       
   184     iStop                   = EFalse;
       
   185 
       
   186     iStopWhenCompleted      = EFalse;
       
   187     iContinueWhenCompleted  = EFalse;
       
   188 
       
   189     iStopViewFinder         = EFalse;
       
   190     
       
   191     iRunlForSnapImage       = EFalse;
       
   192     iRunlForStillImage      = EFalse;
       
   193 
       
   194     iInitReady              = EFalse;
       
   195     iPowerOn                = EFalse;
       
   196 
       
   197     iViewFinderStarted      = EFalse;
       
   198     iViewFindingUsed        = EFalse;
       
   199 
       
   200     iStillPrepareReady      = EFalse;
       
   201     iSnapImageReady         = EFalse;
       
   202     iStillCaptureReady      = EFalse;
       
   203     iStillCapturingOn       = EFalse;
       
   204     iStillCaptured          = EFalse;
       
   205 
       
   206     iStillBurstCaptureMoment = EFalse;
       
   207     iStillBurstReady        = EFalse;
       
   208     iStopStillBurst         = EFalse;
       
   209     iCancelStillBurst       = EFalse;
       
   210     iCancelStillBurstAfterVfFrame = EFalse;
       
   211     
       
   212     iVideoPrepareReady      = EFalse;
       
   213     iVideoRecordingReady    = EFalse;
       
   214     iVideoRecordingPaused   = EFalse;
       
   215     iVideoRecordingResumed  = EFalse;
       
   216     iVideoRecordingOn       = EFalse;
       
   217     iVideoRecorded          = EFalse;
       
   218 
       
   219 	iStoppedOnError			= EFalse;
       
   220 
       
   221     iAcceptVideoCompletionError = EFalse;    
       
   222 
       
   223     iVfFrameCount           = 0;
       
   224     
       
   225     iImageCountToCapture    = 1;
       
   226     
       
   227     iCancelCount            = 0;
       
   228     
       
   229     iCountInitComplete              = 0;
       
   230     iCountStillPrepareComplete      = 0;
       
   231     iCountStillBurstCaptureMoment   = 0;
       
   232     iCountStillBurstComplete        = 0;
       
   233     iCountVideoPrepareComplete      = 0;
       
   234     iCountViewFinderFrameReady      = 0;
       
   235     iCountSnapImageReady            = 0;
       
   236     iCountStillImageReady           = 0;
       
   237     iCountVideoRecordingOn          = 0;
       
   238     iCountVideoRecordingComplete    = 0;
       
   239     iCountVideoRecordingStopped     = 0;
       
   240     iCountVideoRecordingPaused      = 0;
       
   241     iCountVideoRecordingTimes       = 0;
       
   242 
       
   243     #ifdef CAE_TEST_VERSION
       
   244     CaeSetMcaeseoHBufC8ImageReadyError( KErrNone );
       
   245     CaeSetMcaeseoHBufC8ImageReadyError( KErrNone );
       
   246     CaeSetPowerOnCompleteError( KErrNone );
       
   247     CaeSetReserveCompleteError( KErrNone );
       
   248     CaeSetImageReadyError( KErrNone );
       
   249     CaeSetMvruoOpenCompleteError( KErrNone );
       
   250     CaeSetMvruoPrepareCompleteError( KErrNone );
       
   251     CaeSetMvruoRecordCompleteError( KErrNone );
       
   252     CaeSetPrepareVideoSettingsError( KErrNone );
       
   253     CaeSetCreateAndDeliverSnapImageError( KErrNone );
       
   254     CaeSetCreateAndDeliverStillImageError( KErrNone );
       
   255     CaeSetConvertCFbsBitmapToHBufC8Error( KErrNone );
       
   256     CaeSetConvertHBufC8ToCFbsBitmapError( KErrNone );
       
   257     CaeSetStillConvertError( KErrNone );
       
   258     #endif // CAE_TEST_VERSION
       
   259 
       
   260     iReleaseDone = EFalse;
       
   261     iReserveDone = EFalse;
       
   262 
       
   263     iNextRunLTime.HomeTime();
       
   264 
       
   265     iExtensionMode        = EFalse;
       
   266     iBitmapSendDone       = EFalse;
       
   267 
       
   268     }
       
   269 
       
   270 
       
   271 void CCaeTestClient::SetSnapImageCreation( TBool aCreateSnapImage )
       
   272     {
       
   273     iCreateSnapImage = aCreateSnapImage;
       
   274     }
       
   275 
       
   276 
       
   277 void CCaeTestClient::SetRunningWithViewFinder( TBool aRunWithViewFinder )
       
   278     {
       
   279     iRunWithViewFinder = aRunWithViewFinder;
       
   280     }
       
   281 
       
   282 
       
   283 void CCaeTestClient::SetViewFinderSize( const TSize& aSize )
       
   284     {
       
   285     iViewFinderSize = aSize;
       
   286     }
       
   287 
       
   288 
       
   289 void CCaeTestClient::SetStillQualityLevelIndex( TInt aQualityLevelIndex )
       
   290     {
       
   291     iStillQualityLevelIndex = aQualityLevelIndex;
       
   292     }
       
   293 
       
   294 
       
   295 void CCaeTestClient::SetVideoQualityLevelIndex( TInt aQualityLevelIndex )
       
   296     {
       
   297     iVideoQualityLevelIndex = aQualityLevelIndex;
       
   298     }
       
   299 
       
   300 
       
   301 void CCaeTestClient::SetStillFormat( CCamera::TFormat aFormat )
       
   302     {
       
   303     iStillDataFormat = aFormat;
       
   304     }
       
   305 
       
   306 
       
   307 void CCaeTestClient::SetStillCompressionQuality( TInt aCompressionQuality )
       
   308     {
       
   309     iStillCompressionQuality = aCompressionQuality;
       
   310     }
       
   311 
       
   312 
       
   313 void CCaeTestClient::SetStillFrameSize( const TSize& aSize )
       
   314     {
       
   315     iStillFrameSize = aSize;
       
   316     }
       
   317 
       
   318 
       
   319 void CCaeTestClient::SetSnapImageSize( const TSize& aSize )
       
   320     {
       
   321     iSnapImageSize = aSize;
       
   322     }
       
   323 
       
   324 
       
   325 void CCaeTestClient::SetSnapImageSource( CCaeEngine::TSnapImageSource aSnapImageSource )
       
   326     {
       
   327     iSnapImageSource = aSnapImageSource;
       
   328     }
       
   329 
       
   330 
       
   331 void CCaeTestClient::SetSnapImageColorMode( TDisplayMode aMode )
       
   332     {
       
   333     iSnapImageColorMode = aMode;
       
   334     }
       
   335 
       
   336 
       
   337 void CCaeTestClient::SetImageCodecs( TUid aDecoderUid, TUid aEncoderUid )
       
   338     {
       
   339     iImageDecoderUid = aDecoderUid;
       
   340     iImageEncoderUid = aEncoderUid;
       
   341     }
       
   342 
       
   343 
       
   344 void CCaeTestClient::SetCropRect( const TRect& aRect )
       
   345     {
       
   346     iCropRect = aRect;
       
   347     }
       
   348 
       
   349 
       
   350 void CCaeTestClient::SetStillBurstLength( TInt aLength )
       
   351     {
       
   352     iStillBurstLength = aLength;
       
   353     }
       
   354 
       
   355 
       
   356 void CCaeTestClient::SetVideoFrameSize( const TSize& aSize )
       
   357     {
       
   358     iVideoFrameSize = aSize;
       
   359     }
       
   360 
       
   361 
       
   362 void CCaeTestClient::SetVideoFrameRate( TReal32 aFrameRate )
       
   363     {
       
   364     iVideoFrameRate = aFrameRate;
       
   365     }
       
   366 
       
   367 
       
   368 void CCaeTestClient::SetVideoBitRate( TInt aBitRate )
       
   369     {
       
   370     iVideoBitRate = aBitRate;
       
   371     }
       
   372 
       
   373 
       
   374 void CCaeTestClient::SetVideoAudio( TBool aAudioEnabled )
       
   375     {
       
   376     iVideoAudioEnabled = aAudioEnabled;
       
   377     }
       
   378 
       
   379 
       
   380 void CCaeTestClient::SetAudioBitRate( TInt aAudioBitRate )
       
   381     {
       
   382     iAudioBitRate = aAudioBitRate;
       
   383     }
       
   384 
       
   385 
       
   386 void CCaeTestClient::SetFileNameBase( const TFileName& aFileNameBase ) 
       
   387     {
       
   388     iFileNameBase = aFileNameBase;
       
   389     }
       
   390 
       
   391 
       
   392 void CCaeTestClient::SetVfFileName( const TFileName& aFileName ) 
       
   393     {
       
   394     iVfFileName = iFileNameBase;
       
   395     iVfFileName.Append ( aFileName );
       
   396 #if ( WRITE_VF_TO_FILE )
       
   397     iVfFrameCountToSave = 1;
       
   398 #else
       
   399     iVfFrameCountToSave = 0;
       
   400 #endif
       
   401     }
       
   402 
       
   403 void CCaeTestClient::SetVideoStopMode( TBool aAsyncVideoStopEnabled )
       
   404     {
       
   405     iVideoStopModeCommand = ETrue; // mark for new command
       
   406     iAsyncVideoStopEnabled = aAsyncVideoStopEnabled; // new stop mode
       
   407     }
       
   408 
       
   409 
       
   410 void CCaeTestClient::SetVfFileCountToSave( TInt aCountOfVfFilesToSave ) 
       
   411     {
       
   412     iVfFrameCountToSave = aCountOfVfFilesToSave;
       
   413 #if ( WRITE_VF_TO_FILE )
       
   414     iVfFrameCountToSave = aCountOfVfFilesToSave;
       
   415 #else
       
   416     iVfFrameCountToSave = 0;
       
   417 #endif
       
   418     }
       
   419 
       
   420 
       
   421 void CCaeTestClient::SetSnapFileName( const TFileName& aFileName ) 
       
   422     {
       
   423     iSnapFileName = iFileNameBase;
       
   424     iSnapFileName.Append ( aFileName );
       
   425 #if ( WRITE_SNAPIMAGE_TO_FILE )
       
   426     iSaveSnapImage = ETrue;
       
   427 #else
       
   428     iSaveSnapImage = EFalse;
       
   429 #endif
       
   430     }
       
   431 
       
   432 
       
   433 void CCaeTestClient::SetStillFileName( const TFileName& aFileName ) 
       
   434     {
       
   435     iStillFileName = iFileNameBase;
       
   436     iStillFileName.Append ( aFileName );
       
   437 #if ( WRITE_STILLIMAGE_TO_FILE )
       
   438     iSaveStillImage = ETrue;
       
   439 #else
       
   440     iSaveStillImage = EFalse;
       
   441 #endif
       
   442     }
       
   443 
       
   444 
       
   445 void CCaeTestClient::SetVideoFileName( const TFileName& aFileName ) 
       
   446     {
       
   447     iVideoFileName = iFileNameBase;
       
   448     iVideoFileName.Append ( aFileName );
       
   449 #if ( WRITE_VIDEOCLIP_TO_FILE )
       
   450     iSaveVideoClip = ETrue;
       
   451 #else
       
   452     iSaveVideoClip = EFalse;
       
   453 #endif
       
   454     }
       
   455 
       
   456 
       
   457 void CCaeTestClient::SetTimeout( TTimeIntervalMicroSeconds32 aTimeout )
       
   458     {
       
   459 	iTimeout = aTimeout;
       
   460     }
       
   461 
       
   462 
       
   463 void CCaeTestClient::SetStillBurstCaptureInterval( TTimeIntervalMicroSeconds aInterval )
       
   464     {
       
   465     iStillBurstCaptureInterval = aInterval;
       
   466     }
       
   467 
       
   468 
       
   469 void CCaeTestClient::SetExposureMode( TInt aExposureMode )
       
   470     {
       
   471     iExposureMode = aExposureMode;
       
   472     }
       
   473 
       
   474 
       
   475 void CCaeTestClient::SetEvCompensation( TInt aEvCompensation )
       
   476     {
       
   477     iEvCompensation = aEvCompensation;
       
   478     }
       
   479 
       
   480 
       
   481 void CCaeTestClient::SetWhiteBalanceMode( TInt aWhiteBalanceMode )
       
   482     {
       
   483     iWhiteBalanceMode = aWhiteBalanceMode;
       
   484     }
       
   485 
       
   486 
       
   487 void CCaeTestClient::SetFlashMode( TInt aFlashMode )
       
   488     {
       
   489     iFlashMode = aFlashMode;
       
   490     }
       
   491 
       
   492 
       
   493 void CCaeTestClient::SetBrightness( TInt aBrightness )
       
   494     {
       
   495     iBrightness = aBrightness;
       
   496     }
       
   497 
       
   498 
       
   499 void CCaeTestClient::SetContrast( TInt aContrast )
       
   500     {
       
   501     iContrast = aContrast;
       
   502     }
       
   503 
       
   504 
       
   505 void CCaeTestClient::SetZoomMode( TInt aZoomMode )
       
   506     {
       
   507     iZoomMode = aZoomMode;
       
   508     }
       
   509 
       
   510 
       
   511 void CCaeTestClient::SetDigiZoomValue( TInt aDigiZoomValue )
       
   512     {
       
   513     iDigiZoomValue = aDigiZoomValue;
       
   514     }
       
   515 
       
   516 void CCaeTestClient::SetVideoClipMaxSize( TInt aMaxClipSizeInBytes )
       
   517     {
       
   518     iVideoMaxClipSizeInBytes = aMaxClipSizeInBytes;
       
   519     }
       
   520 
       
   521 
       
   522 void CCaeTestClient::SetVideoTimesInterval( TTimeIntervalMicroSeconds aInterval )
       
   523     {
       
   524     iVideoTimesInterval = aInterval;
       
   525     }
       
   526 
       
   527 
       
   528 void CCaeTestClient::SetOpMode( TestClientOpMode aOpMode )
       
   529     {
       
   530     iOpMode = aOpMode;
       
   531     }
       
   532   
       
   533 
       
   534 void CCaeTestClient::SetDisplayIndex( TInt aDisplayIndex )
       
   535     {
       
   536     iDisplayIndex = aDisplayIndex;
       
   537     }
       
   538   
       
   539 
       
   540 void CCaeTestClient::SetStopOnErrorInMcaeoSnapImageReady( TBool aStopOnError )
       
   541     {
       
   542     iStopOnErrorInMcaeoSnapImageReady = aStopOnError;
       
   543     }
       
   544 
       
   545 
       
   546 void CCaeTestClient::SetStopOnErrorInMcaeoStillImageReady( TBool aStopOnError )
       
   547     {
       
   548     iStopOnErrorInMcaeoStillImageReady = aStopOnError;
       
   549     }
       
   550 
       
   551 
       
   552 void CCaeTestClient::GetInfo( TCamAppEngineInfo& aInfo ) const
       
   553     {
       
   554     aInfo = iInfo;
       
   555     }
       
   556 
       
   557 
       
   558 void CCaeTestClient::GetStillFrameSize( TSize& aSize ) const
       
   559     {
       
   560     aSize = iStillFrameSizeSet;
       
   561     }
       
   562 
       
   563 
       
   564 TInt CCaeTestClient::EstimatedStillSizeInBytes() const
       
   565     {
       
   566     return iEstimatedStillSizeInBytesSet;
       
   567     }
       
   568 
       
   569 
       
   570 void CCaeTestClient::GetVideoFrameSize( TSize& aSize ) const
       
   571     {
       
   572     aSize = iVideoFrameSizeSet;
       
   573     }
       
   574 
       
   575 
       
   576 TReal32 CCaeTestClient::VideoFrameRate() const
       
   577     {
       
   578     return iVideoFrameRateSet;
       
   579     }
       
   580 
       
   581 TInt CCaeTestClient::EstimatedVideoRecordingBitRate() const
       
   582     {
       
   583     return iEstimatedVideoBitRateSet;
       
   584     }
       
   585 
       
   586 
       
   587 TReal32 CCaeTestClient::ViewFinderFrameFrequency()
       
   588     {
       
   589     return 15.0;
       
   590     }
       
   591 
       
   592 
       
   593 TInt CCaeTestClient::CountInitComplete()
       
   594     {
       
   595     return iCountInitComplete;
       
   596     }
       
   597 
       
   598 
       
   599 TInt CCaeTestClient::CountStillPrepareComplete()
       
   600     {
       
   601     return iCountStillPrepareComplete;
       
   602     }
       
   603 
       
   604 
       
   605 TInt CCaeTestClient::CountStillBurstCaptureMoment()
       
   606     {
       
   607     return iCountStillBurstCaptureMoment;
       
   608     }
       
   609 
       
   610 
       
   611 TInt CCaeTestClient::CountStillBurstComplete()
       
   612     {
       
   613     return iCountStillBurstComplete;
       
   614     }
       
   615 
       
   616 TInt CCaeTestClient::CountImageDeliveredStillBurstComplete()
       
   617     {
       
   618     return iImageCountDeliveredForStillBurst;
       
   619     }
       
   620 
       
   621 
       
   622 TInt CCaeTestClient::CountVideoPrepareComplete()
       
   623     {
       
   624     return iCountVideoPrepareComplete;
       
   625     }
       
   626 
       
   627 
       
   628 TInt CCaeTestClient::CountViewFinderFrameReady()
       
   629     {
       
   630     return iCountViewFinderFrameReady;
       
   631     }
       
   632 
       
   633 
       
   634 TInt CCaeTestClient::CountSnapImageReady()
       
   635     {
       
   636     return iCountSnapImageReady;
       
   637     }
       
   638 
       
   639 
       
   640 TInt CCaeTestClient::CountStillImageReady()
       
   641     {
       
   642     return iCountStillImageReady;
       
   643     }
       
   644 
       
   645 
       
   646 TInt CCaeTestClient::CountVideoRecordingOn()
       
   647     {
       
   648     return iCountVideoRecordingOn;
       
   649     }
       
   650 
       
   651 
       
   652 TInt CCaeTestClient::CountVideoRecordingComplete()
       
   653     {
       
   654     return iCountVideoRecordingComplete;
       
   655     }
       
   656 
       
   657 TInt CCaeTestClient::CountVideoRecordingStopped()
       
   658     {
       
   659     return iCountVideoRecordingStopped;
       
   660     }
       
   661 
       
   662 
       
   663 TInt CCaeTestClient::CountVideoRecordingPaused()
       
   664     {
       
   665     return iCountVideoRecordingPaused;
       
   666     }
       
   667 
       
   668 
       
   669 TInt CCaeTestClient::CountVideoRecordingTimes()
       
   670     {
       
   671     return iCountVideoRecordingTimes;
       
   672     }
       
   673 
       
   674 void CCaeTestClient::SetCustomInterfaceUid( TUid aCustomInterfaceUid )
       
   675     {
       
   676     iCustomInterfaceUid = aCustomInterfaceUid;
       
   677     }
       
   678 
       
   679 TAny* CCaeTestClient::CustomInterfacePointer()
       
   680     {
       
   681     return iCustomInterfacePointer;
       
   682     }
       
   683 
       
   684 void CCaeTestClient::SetColorToneValue( MCameraColorToneSettings::TColorTone aValue)
       
   685     {
       
   686     iColorToneValue = aValue;
       
   687     }
       
   688 
       
   689 void CCaeTestClient::SetVideoCodecSet( TInt aValue)
       
   690     {
       
   691     iVideoCodecSet = aValue;
       
   692     }
       
   693 
       
   694 // Trap RunL, to catch if the AO leaves.
       
   695 // A Walkaround...
       
   696 // RunError() should be used in this case, but
       
   697 // Apparently, it is not possible to use the AO RunError() virtual function
       
   698 // for that purpose, it is not called.
       
   699 void CCaeTestClient::RunL()
       
   700     {
       
   701     TRAPD( error, RunTrappedL() );
       
   702 	if ( error )
       
   703 	    {
       
   704     	#ifdef _DEBUG
       
   705         RDebug::Print( _L( "Cae: CCaeTestClient::RunL() RunTrappedL leaved! %d" ), error );
       
   706         #endif
       
   707         StopOnError( error );
       
   708         // After the Stop, execution should continue at the end of RunTestAction()
       
   709         }
       
   710     }
       
   711 
       
   712 
       
   713 void CCaeTestClient::DoCancel()
       
   714     {
       
   715 	#ifdef _DEBUG
       
   716     RDebug::Print( _L( "Cae: CCaeTestClient::DoCancel() entering" ) );
       
   717     #endif
       
   718 	
       
   719     if ( iCamAppEngine->IsViewFinding() )
       
   720 	    {
       
   721         iCamAppEngine->StopViewFinder();
       
   722         iViewFinderStarted = EFalse;
       
   723         }
       
   724     
       
   725     iCamAppEngine->CancelCaptureStill();
       
   726     
       
   727     if ( iCamAppEngine->IsVideoRecording() ) 
       
   728         {
       
   729         iCamAppEngine->StopVideoRecording();
       
   730         }
       
   731     
       
   732     delete iCamAppEngine;
       
   733 	iCamAppEngine = NULL;
       
   734 
       
   735 	#ifdef _DEBUG
       
   736     RDebug::Print( _L( "Cae: CCaeTestClient::DoCancel() returning" ) );
       
   737     #endif
       
   738     }
       
   739 
       
   740 
       
   741 void CCaeTestClient::McaeoInitComplete( TInt aError )
       
   742     {
       
   743 	#ifdef _DEBUG
       
   744     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoInitComplete() entering: %d" ), iCountInitComplete );
       
   745     #endif
       
   746 
       
   747     iCountInitComplete++;
       
   748 
       
   749     #if CAE_OOM_TESTING_HARNESS
       
   750     // For OOM testing in CppUnit.
       
   751     TInt* memTest = new TInt( 1 );
       
   752     if ( !memTest ) 
       
   753         {
       
   754         #ifdef _DEBUG
       
   755         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoInitComplete(): OOM test, calling CancelCaptureStill()" ) );
       
   756         #endif
       
   757         iCamAppEngine->CancelCaptureStill();
       
   758         StopOnError( KErrNoMemory );
       
   759         }
       
   760     else 
       
   761         {
       
   762         delete memTest;
       
   763         }
       
   764     #endif
       
   765 
       
   766     if ( aError ) 
       
   767         {
       
   768 	    #ifdef _DEBUG
       
   769         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoInitComplete(): error detected: %d" ), aError );
       
   770         #endif
       
   771         StopOnError( aError );
       
   772         }
       
   773     else
       
   774         {
       
   775         if ( !(iAction == ECaptureStillAfterPowerOffOn && iStopWhenCompleted) ) 
       
   776             {
       
   777             iInitReady = ETrue;
       
   778             }
       
   779         iPowerOn   = ETrue;
       
   780         CTimer::After( KNormalTimingDelay );
       
   781         }
       
   782 
       
   783 	#ifdef _DEBUG
       
   784     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoInitComplete() returning" ) );
       
   785     #endif
       
   786     }
       
   787 
       
   788 
       
   789 void CCaeTestClient::McaeoStillPrepareComplete( TInt aError )
       
   790     {
       
   791 	#ifdef _DEBUG
       
   792     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillPrepareComplete() entering: %d" ), iCountStillPrepareComplete );
       
   793     #endif
       
   794 
       
   795     iCountStillPrepareComplete++;
       
   796 
       
   797     #if CAE_OOM_TESTING_HARNESS
       
   798     // For OOM testing in CppUnit.
       
   799     TInt* memTest = new TInt( 1 );
       
   800     if ( !memTest ) 
       
   801         {
       
   802         #ifdef _DEBUG
       
   803         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillPrepareComplete(): OOM test, calling CancelCaptureStill()" ) );
       
   804         #endif
       
   805         iCamAppEngine->CancelCaptureStill();
       
   806         StopOnError( KErrNoMemory );
       
   807         }
       
   808     else 
       
   809         {
       
   810         delete memTest;
       
   811         }
       
   812     #endif
       
   813 
       
   814     if ( aError ) 
       
   815         {
       
   816 	    #ifdef _DEBUG
       
   817         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillPrepareComplete(): error detected" ) );
       
   818         #endif
       
   819         StopOnError( aError );
       
   820         }
       
   821     else
       
   822         {
       
   823         iStillPrepareReady = ETrue;
       
   824         CTimer::After( KNormalTimingDelay );
       
   825         }
       
   826 
       
   827 	#ifdef _DEBUG
       
   828     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillPrepareComplete() returning" ) );
       
   829     #endif
       
   830     }
       
   831 
       
   832 
       
   833 void CCaeTestClient::McaeoVideoPrepareComplete( TInt aError )
       
   834     {
       
   835 	#ifdef _DEBUG
       
   836     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoPrepareComplete() entering: %d" ), iCountVideoPrepareComplete );
       
   837     #endif
       
   838 
       
   839     iCountVideoPrepareComplete++;
       
   840 
       
   841     if ( aError ) 
       
   842         {
       
   843 	    #ifdef _DEBUG
       
   844         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoPrepareComplete(): error detected: %d" ), aError );
       
   845         #endif
       
   846         StopOnError( aError );
       
   847         }
       
   848     else
       
   849         {
       
   850         iVideoPrepareReady = ETrue;
       
   851 
       
   852         if ( iVideoStopModeCommand ) // New command should be sent once
       
   853             {
       
   854             iVideoStopModeCommand = EFalse;
       
   855             TInt err = iCamAppEngine->SetAsyncVideoStopMode( iAsyncVideoStopEnabled );
       
   856             if ( err ) 
       
   857                 {
       
   858 	            #ifdef _DEBUG
       
   859                 RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoPrepareComplete(): error detected in SetAsyncVideoStopMode: %d" ), err );
       
   860                 #endif
       
   861                 StopOnError( err );
       
   862                 }
       
   863             }
       
   864         
       
   865         CTimer::After( KNormalTimingDelay );
       
   866         }
       
   867 
       
   868 	#ifdef _DEBUG
       
   869     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoPrepareComplete() returning" ) );
       
   870     #endif
       
   871     }
       
   872 
       
   873 
       
   874 void CCaeTestClient::McaeoViewFinderFrameReady( CFbsBitmap& aFrame, TInt aError )
       
   875     {
       
   876 	#ifdef _DEBUG
       
   877     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoViewFinderFrameReady() entering: %d" ), iCountViewFinderFrameReady );
       
   878     #endif
       
   879     TSize sizeEmpty;
       
   880 
       
   881     iCountViewFinderFrameReady++;
       
   882 
       
   883     #if CAE_OOM_TESTING_HARNESS
       
   884     // For OOM testing in CppUnit.
       
   885     TInt* memTest = new TInt( 1 );
       
   886     if ( !memTest ) 
       
   887         {
       
   888         #ifdef _DEBUG
       
   889         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoViewFinderFrameReady(): OOM test, calling CancelCaptureStill()" ) );
       
   890         #endif
       
   891         iCamAppEngine->CancelCaptureStill();
       
   892         StopOnError( KErrNoMemory );
       
   893         }
       
   894     else 
       
   895         {
       
   896         delete memTest;
       
   897         }
       
   898     #endif
       
   899 
       
   900     if ( aError ) 
       
   901         {
       
   902 	    #ifdef _DEBUG
       
   903         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoViewFinderFrameReady(): error detected: %d" ), aError );
       
   904         #endif
       
   905         StopOnError( aError );
       
   906         }
       
   907     else
       
   908         {
       
   909         iViewFinderStarted = ETrue;
       
   910 
       
   911         iVfFrameCount++;
       
   912 
       
   913 
       
   914 		if ( iCancelStillBurstAfterVfFrame && ( iCountStillBurstCaptureMoment == 2 ) )
       
   915 			{
       
   916 			iCamAppEngine->CancelCaptureStill();
       
   917             iStop = ETrue;
       
   918 			CTimer::After( KNormalTimingDelay );
       
   919 			}
       
   920         
       
   921         // TSize viewFinderSize;
       
   922         // iCamAppEngine->GetViewFinderSize( viewFinderSize );
       
   923         // AsyncAssert( viewFinderSize==iViewFinderSize, KErrGeneral );
       
   924 
       
   925         if ( iVfFrameCount <= iVfFrameCountToSave ) 
       
   926             {
       
   927             TFileName fn( iVfFileName );
       
   928             TInt length = fn.Length();
       
   929             TBuf<4> ext;
       
   930             ext = fn.Right( 4 );
       
   931             fn.SetLength( length  - 4 );
       
   932             TBuf<10> num;
       
   933             num.Num( iVfFrameCount - 1 );
       
   934             fn.Append( _L("_") );
       
   935             fn.Append( num );
       
   936             fn.Append( ext );
       
   937 
       
   938             #ifdef _DEBUG
       
   939             RDebug::Print( fn );
       
   940             #endif
       
   941 
       
   942             iError = aFrame.Save( fn );
       
   943             if ( iError ) 
       
   944                 {
       
   945                 StopOnError( iError );
       
   946                 }
       
   947             } 
       
   948             
       
   949         // Create a duplicate bitmap and save it
       
   950         if ( iAction == EProcessExtViewFinderFrameReady  &&
       
   951             !iBitmapSave &&
       
   952             aFrame.SizeInPixels() != sizeEmpty ) 
       
   953             {
       
   954             iBitmapSave = new CFbsBitmap;
       
   955             if ( iBitmapSave )
       
   956                 {
       
   957                 TInt err = iBitmapSave->Duplicate( aFrame.Handle() );
       
   958                 if ( err ) 
       
   959                     {
       
   960 //                        LOGTEXT2( _L( "Cae: CCaeEngineImp::ProcessExtSnapImageL(): Duplicate error:%d" ), err);
       
   961                         delete iBitmapSave;
       
   962                         iBitmapSave = NULL;
       
   963 //                        User::Leave( KErrNoMemory );
       
   964                      }
       
   965                 }
       
   966             else
       
   967                 {
       
   968 //                LOGTEXT( _L( "Cae: CCaeEngineImp::ProcessExtSnapImageL(): new CFbsBitmap failed" ));
       
   969 //                User::Leave( KErrNoMemory );
       
   970                 }
       
   971             }
       
   972                        
       
   973         }
       
   974 
       
   975 	#ifdef _DEBUG
       
   976     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoViewFinderFrameReady() returning" ) );
       
   977     #endif
       
   978     }
       
   979 
       
   980 
       
   981 void CCaeTestClient::McaeoSnapImageReady( const CFbsBitmap& aBitmap, TInt aError ) 
       
   982     {
       
   983 	#ifdef _DEBUG
       
   984     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoSnapImageReady() entering: %d" ), iCountSnapImageReady );
       
   985     #endif
       
   986     TSize sizeEmpty;
       
   987 
       
   988     iCountSnapImageReady++;
       
   989 
       
   990     #if CAE_OOM_TESTING_HARNESS
       
   991     // For OOM testing in CppUnit.
       
   992     TInt* memTest = new TInt( 1 );
       
   993     if ( !memTest ) 
       
   994         {
       
   995         #ifdef _DEBUG
       
   996         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoSnapImageReady(): OOM test, calling CancelCaptureStill()" ) );
       
   997         #endif
       
   998         iCamAppEngine->CancelCaptureStill();
       
   999         StopOnError( KErrNoMemory );
       
  1000         }
       
  1001     else 
       
  1002         {
       
  1003         delete memTest;
       
  1004         }
       
  1005     #endif
       
  1006 
       
  1007     if ( aError ) 
       
  1008         {
       
  1009 	    #ifdef _DEBUG
       
  1010         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoSnapImageReady(): error detected: %d" ), aError );
       
  1011         #endif
       
  1012 		if (iStopOnErrorInMcaeoSnapImageReady)
       
  1013 			{
       
  1014 			StopOnError( aError );
       
  1015 			}
       
  1016         }
       
  1017     else
       
  1018         {
       
  1019         if ( iSaveSnapImage && ( iCountSnapImageReady < 10 ) )
       
  1020             {
       
  1021             if ( aBitmap.SizeInPixels() != iSizeEmpty ) 
       
  1022                 {
       
  1023                 // create bitmap 3 as a duplicate of bitmap 2
       
  1024                 CFbsBitmap* bitmapSave = new CFbsBitmap;
       
  1025                 if ( bitmapSave )
       
  1026                     {
       
  1027                     iError = bitmapSave->Duplicate( aBitmap.Handle() );
       
  1028                     if ( iError ) 
       
  1029                         {
       
  1030                         delete bitmapSave;
       
  1031                         bitmapSave = NULL;
       
  1032                         StopOnError( iError );
       
  1033                         }
       
  1034 
       
  1035                     TFileName fn( iSnapFileName );
       
  1036                     TInt length = fn.Length();
       
  1037                     TBuf<4> ext;
       
  1038                     ext = fn.Right( 4 );
       
  1039                     fn.SetLength( length  - 4 );
       
  1040                     TBuf<10> num;
       
  1041                     num.Num( iCountSnapImageReady - 1 );
       
  1042                     fn.Append( _L("_") );
       
  1043                     fn.Append( num );
       
  1044                     fn.Append( ext );
       
  1045 
       
  1046 	                #ifdef _DEBUG
       
  1047                     RDebug::Print( fn );
       
  1048                     #endif
       
  1049 
       
  1050                     iError = bitmapSave->Save( fn );
       
  1051 
       
  1052                     delete bitmapSave;
       
  1053                     bitmapSave = NULL;
       
  1054 
       
  1055                     if ( iError ) 
       
  1056                         {
       
  1057                         StopOnError( iError );
       
  1058                         }
       
  1059                     }
       
  1060                 }
       
  1061             }
       
  1062         // Extension mode
       
  1063         // Create a duplicate bitmap and save it
       
  1064         if ( (iAction == EProcessExtSnapImage || iAction == EProcessExtCapturedImageBurst ||
       
  1065             iAction == EProcessExtCapturedImageBurstTDesC8 || iAction == EProcessExtCapturedImageCFbsBitmap) &&
       
  1066             !iBitmapSave &&
       
  1067             aBitmap.SizeInPixels() != sizeEmpty ) 
       
  1068             {
       
  1069             iBitmapSave = new CFbsBitmap;
       
  1070             if ( iBitmapSave )
       
  1071                 {
       
  1072                 TInt err = iBitmapSave->Duplicate( aBitmap.Handle() );
       
  1073                 if ( err ) 
       
  1074                     {
       
  1075 //                        LOGTEXT2( _L( "Cae: CCaeEngineImp::ProcessExtSnapImageL(): Duplicate error:%d" ), err);
       
  1076                         delete iBitmapSave;
       
  1077                         iBitmapSave = NULL;
       
  1078 //                        User::Leave( KErrNoMemory );
       
  1079                      }
       
  1080                 }
       
  1081             else
       
  1082                 {
       
  1083 //                LOGTEXT( _L( "Cae: CCaeEngineImp::ProcessExtSnapImageL(): new CFbsBitmap failed" ));
       
  1084 //                User::Leave( KErrNoMemory );
       
  1085                 }
       
  1086             if ( iExtensionMode &&  // If CAE is switched to ext mode
       
  1087                 iAction == EProcessExtSnapImage )   // Only snap image is sent in this test case
       
  1088                 {
       
  1089                 CTimer::After( KNormalTimingDelay ); // start timer for next action
       
  1090                 }
       
  1091             }
       
  1092 
       
  1093         if ( iRunlForSnapImage && ( iCountSnapImageReady < 2 ) )
       
  1094             {
       
  1095             iSnapImageReady = ETrue;
       
  1096             CTimer::After( KNormalTimingDelay );
       
  1097             }
       
  1098         }
       
  1099 
       
  1100 	#ifdef _DEBUG
       
  1101     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoSnapImageReady() returning" ) );
       
  1102     #endif
       
  1103     }
       
  1104 
       
  1105 
       
  1106 void CCaeTestClient::McaeoStillImageReady( CFbsBitmap* aBitmap, HBufC8* aData, TInt aError ) 
       
  1107     {
       
  1108 	#ifdef _DEBUG
       
  1109     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillImageReady() entering: %d" ), iCountStillImageReady );
       
  1110     #endif
       
  1111 
       
  1112     iCountStillImageReady++;
       
  1113 
       
  1114     #if CAE_OOM_TESTING_HARNESS
       
  1115     // For OOM testing in CppUnit.
       
  1116     TInt* memTest = new TInt( 1 );
       
  1117     if ( !memTest ) 
       
  1118         {
       
  1119         #ifdef _DEBUG
       
  1120         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillImageReady(): OOM test, calling CancelCaptureStill()" ) );
       
  1121         #endif
       
  1122         iCamAppEngine->CancelCaptureStill();
       
  1123         StopOnError( KErrNoMemory );
       
  1124         }
       
  1125     else 
       
  1126         {
       
  1127         delete memTest;
       
  1128         }
       
  1129     #endif
       
  1130 
       
  1131     if ( aError ) 
       
  1132         {
       
  1133         if ( aBitmap )
       
  1134             {
       
  1135             delete aBitmap;
       
  1136             aBitmap = NULL;
       
  1137             }
       
  1138     
       
  1139         if ( aData ) 
       
  1140             {
       
  1141             delete aData;
       
  1142             aData = NULL;
       
  1143             }
       
  1144 
       
  1145 	    #ifdef _DEBUG
       
  1146         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillImageReady(): error detected: %d" ), aError );
       
  1147         #endif
       
  1148 		if (iStopOnErrorInMcaeoStillImageReady)
       
  1149 			{
       
  1150 			StopOnError( aError );
       
  1151 			}
       
  1152         }
       
  1153     else
       
  1154         {
       
  1155         if ( ( aBitmap == NULL ) && ( aData == NULL ) ) 
       
  1156             {
       
  1157             StopOnError( KErrBadHandle );
       
  1158             }
       
  1159 
       
  1160         if ( iSaveStillImage  && ( iCountStillImageReady < 10 ) )
       
  1161             {
       
  1162             TFileName fn( iStillFileName );
       
  1163             TInt length = fn.Length();
       
  1164             TBuf<4> ext;
       
  1165             ext = fn.Right( 4 );
       
  1166             fn.SetLength( length  - 4 );
       
  1167             TBuf<10> num;
       
  1168             num.Num( iCountStillImageReady - 1 );
       
  1169             fn.Append( _L("_") );
       
  1170             fn.Append( num );
       
  1171             fn.Append( ext );
       
  1172 
       
  1173 	        #ifdef _DEBUG
       
  1174             RDebug::Print( fn );
       
  1175             #endif
       
  1176 
       
  1177             if ( aBitmap ) 
       
  1178                 {
       
  1179                 aBitmap->Save( fn );
       
  1180                 }
       
  1181             else if ( aData ) 
       
  1182                 {
       
  1183                 RFs fsSession;
       
  1184                 RFile file;
       
  1185                 if ( fsSession.Connect() == KErrNone )
       
  1186                     {
       
  1187                     file.Replace( fsSession, fn, EFileWrite );
       
  1188                     file.Write( aData->Des() );
       
  1189                     file.Close();
       
  1190                     fsSession.Close();
       
  1191                     }
       
  1192                 }
       
  1193             }
       
  1194             
       
  1195         // Extension mode handling, don't delete image data
       
  1196         if ( (iAction == EProcessExtCapturedImage ||
       
  1197             iAction == EProcessExtCapturedImageTDesC8 ||
       
  1198             iAction == EProcessExtCapturedImageCFbsBitmap ||
       
  1199             iAction == EProcessExtCancel2 ||
       
  1200             iAction == EProcessExtCapturedImageBurst ||
       
  1201             iAction == EProcessExtCapturedImageBurstTDesC8 ||
       
  1202             iAction == EProcessExtCapturedImageNoInit)  &&
       
  1203             !iDataSave )
       
  1204             {
       
  1205             // save captured image for extension testing
       
  1206             iDataSave = aData;
       
  1207             aData = NULL;
       
  1208             }
       
  1209 
       
  1210     
       
  1211         if ( aBitmap )
       
  1212             {
       
  1213             delete aBitmap;
       
  1214             aBitmap = NULL;
       
  1215             }
       
  1216     
       
  1217         if ( aData ) 
       
  1218             {
       
  1219             delete aData;
       
  1220             aData = NULL;
       
  1221             }
       
  1222 
       
  1223         if ( iRunlForStillImage || ( !iRunlForSnapImage && ( iImageCountToCapture == 1 ) ) )
       
  1224             {
       
  1225             iStillCaptureReady = ETrue;
       
  1226             iStillCapturingOn = EFalse;
       
  1227             CTimer::After( KNormalTimingDelay );
       
  1228             }
       
  1229         }
       
  1230 
       
  1231 	#ifdef _DEBUG
       
  1232     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoStillImageReady() returning" ) );
       
  1233     #endif
       
  1234     }
       
  1235 
       
  1236 
       
  1237 void CCaeTestClient::McaesboStillBurstCaptureMoment( TInt aError )
       
  1238     {
       
  1239 	#ifdef _DEBUG
       
  1240     RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstCaptureMoment() entering: %d" ), iCountStillBurstCaptureMoment );
       
  1241     #endif
       
  1242 
       
  1243     iCountStillBurstCaptureMoment++;
       
  1244 
       
  1245     if ( aError ) 
       
  1246         {
       
  1247 	    #ifdef _DEBUG
       
  1248         RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstCaptureMoment(): error detected: %d" ), aError );
       
  1249         #endif
       
  1250         StopOnError( aError );
       
  1251         }
       
  1252 
       
  1253     if ( iStopStillBurst && ( iCountStillBurstCaptureMoment >= 3 ) )
       
  1254         {
       
  1255         iCamAppEngine->StopStillBurstCapture();
       
  1256         }
       
  1257     else if ( iCancelStillBurst && ( iCountStillBurstCaptureMoment >= 2 ) ) 
       
  1258         {
       
  1259         iStillBurstCaptureMoment = ETrue;
       
  1260         iCancelCount++;
       
  1261         iCamAppEngine->CancelCaptureStill();
       
  1262         CTimer::After( KNormalTimingDelay );
       
  1263         }
       
  1264 	else if (iRunWithViewFinder && ( iCountStillBurstCaptureMoment == iStillBurstLength) )
       
  1265 		{
       
  1266 		// View finder is running and the last burst image will be taken
       
  1267 		if ( iCountViewFinderFrameReady < ( iStillBurstLength - 1 ) )
       
  1268 			{
       
  1269 			// Error! There should be at least one VF frame between every burst image
       
  1270 			#ifdef _DEBUG
       
  1271 			RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstCaptureMoment() Error! Not enought VF frames during the burst! %d" ), iCountViewFinderFrameReady);
       
  1272 			#endif
       
  1273 			StopOnError( KErrGeneral );
       
  1274 			}
       
  1275 		}
       
  1276     #if CAE_OOM_TESTING_HARNESS
       
  1277     else
       
  1278         {
       
  1279         // For OOM testing in CppUnit.
       
  1280         TInt* memTest = new TInt( 1 );
       
  1281         if ( !memTest ) 
       
  1282             {
       
  1283             #ifdef _DEBUG
       
  1284             RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstCaptureMoment(): OOM test, calling CancelCaptureStill()" ) );
       
  1285             #endif
       
  1286             iCamAppEngine->CancelCaptureStill();
       
  1287             StopOnError( KErrNoMemory );
       
  1288             }
       
  1289         else 
       
  1290             {
       
  1291             delete memTest;
       
  1292             }
       
  1293         }
       
  1294     #endif
       
  1295 
       
  1296 	#ifdef _DEBUG
       
  1297     RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstCaptureMoment() returning" ) );
       
  1298     #endif
       
  1299     }
       
  1300 
       
  1301 
       
  1302 void CCaeTestClient::McaesboStillBurstComplete( TInt aImageCountDelivered, 
       
  1303                                                 TInt aError )
       
  1304     {
       
  1305 	#ifdef _DEBUG
       
  1306     RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstComplete() entering: %d" ), iCountStillBurstComplete );
       
  1307     #endif
       
  1308 
       
  1309     iCountStillBurstComplete++;
       
  1310 
       
  1311     #if CAE_OOM_TESTING_HARNESS
       
  1312     // For OOM testing in CppUnit.
       
  1313     TInt* memTest = new TInt( 1 );
       
  1314     if ( !memTest ) 
       
  1315         {
       
  1316         #ifdef _DEBUG
       
  1317         RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstComplete(): OOM test, calling CancelCaptureStill()" ) );
       
  1318         #endif
       
  1319         iCamAppEngine->CancelCaptureStill();
       
  1320         StopOnError( KErrNoMemory );
       
  1321         }
       
  1322     else 
       
  1323         {
       
  1324         delete memTest;
       
  1325         }
       
  1326     #endif
       
  1327 
       
  1328     iImageCountDeliveredForStillBurst = aImageCountDelivered;
       
  1329 
       
  1330     if ( aError ) 
       
  1331         {
       
  1332 	    #ifdef _DEBUG
       
  1333         RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstComplete(): error detected: %d" ), aError );
       
  1334         #endif
       
  1335         StopOnError( aError );
       
  1336         }
       
  1337     else
       
  1338         {
       
  1339         iStillBurstReady = ETrue;
       
  1340         iStillCapturingOn = EFalse;
       
  1341         CTimer::After( KNormalTimingDelay );
       
  1342         }
       
  1343 
       
  1344 	#ifdef _DEBUG
       
  1345     RDebug::Print( _L( "Cae: CCaeTestClient::McaesboStillBurstComplete() returning" ) );
       
  1346     #endif
       
  1347     }
       
  1348 
       
  1349 
       
  1350 void CCaeTestClient::McaeoVideoRecordingOn( TInt aError )
       
  1351     {
       
  1352 	#ifdef _DEBUG
       
  1353     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingOn() entering: %d" ), iCountVideoRecordingOn );
       
  1354     #endif
       
  1355 
       
  1356     iCountVideoRecordingOn++;
       
  1357     
       
  1358     if ( aError ) 
       
  1359         {
       
  1360 	    #ifdef _DEBUG
       
  1361         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingOn(): error detected: %d" ), aError );
       
  1362         #endif
       
  1363         StopOnError( aError );
       
  1364         }
       
  1365     else
       
  1366         {
       
  1367         iVideoRecordingOn = ETrue;
       
  1368         iVideoRecordingPaused = EFalse;
       
  1369         CTimer::After( iTimeout );
       
  1370         }
       
  1371 
       
  1372 	#ifdef _DEBUG
       
  1373     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingOn() returning" ) );
       
  1374     #endif
       
  1375     }
       
  1376 
       
  1377 
       
  1378 void CCaeTestClient::McaeoVideoRecordingComplete( TInt aError )
       
  1379     {
       
  1380 	#ifdef _DEBUG
       
  1381     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingComplete() entering: %d" ), iCountVideoRecordingComplete );
       
  1382     #endif
       
  1383 
       
  1384     iCountVideoRecordingComplete++;
       
  1385 
       
  1386     if ( aError ) 
       
  1387         {
       
  1388         if ( !iAcceptVideoCompletionError || aError != KErrCompletion )
       
  1389             {
       
  1390 	        #ifdef _DEBUG
       
  1391             RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingComplete(): error detected: %d" ), aError );
       
  1392             #endif
       
  1393             StopOnError( aError );
       
  1394             }
       
  1395         else
       
  1396             {
       
  1397             iVideoRecordingReady = ETrue;
       
  1398             iVideoRecordingOn = EFalse;
       
  1399             // No CTimer::After call here because there's one pending  
       
  1400             // from McaeoVideoRecordingOn.
       
  1401             }
       
  1402         }
       
  1403     else
       
  1404         {
       
  1405         iVideoRecordingReady = ETrue;
       
  1406         iVideoRecordingOn = EFalse;
       
  1407         CTimer::After( KNormalTimingDelay );
       
  1408         }
       
  1409 
       
  1410 	#ifdef _DEBUG
       
  1411     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingComplete() returning" ) );
       
  1412     #endif
       
  1413     }
       
  1414 
       
  1415 void CCaeTestClient::McaeoVideoRecordingStopped()
       
  1416     {
       
  1417 	#ifdef _DEBUG
       
  1418     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingStopped() entering: %d" ), iCountVideoRecordingStopped );
       
  1419     #endif
       
  1420 
       
  1421     iCountVideoRecordingStopped++;
       
  1422 
       
  1423 	#ifdef _DEBUG
       
  1424     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingStopped() returning" ) );
       
  1425     #endif
       
  1426     }
       
  1427 
       
  1428 
       
  1429 void CCaeTestClient::McaeoVideoRecordingPaused( TInt aError )
       
  1430     {
       
  1431 	#ifdef _DEBUG
       
  1432     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingPaused() entering: %d" ), iCountVideoRecordingPaused );
       
  1433     #endif
       
  1434 
       
  1435     iCountVideoRecordingPaused++;
       
  1436     
       
  1437     if ( aError && iAction != EPrepareRecordPausePauseStopVideo ) // Note double pause test exception
       
  1438         {
       
  1439 	    #ifdef _DEBUG
       
  1440         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingPaused(): error detected: %d" ), aError );
       
  1441         #endif
       
  1442         StopOnError( aError );
       
  1443         }
       
  1444     else
       
  1445         {
       
  1446         // Start CTimer only once, not two times for double pause test
       
  1447         if ( !iVideoRecordingPaused )
       
  1448             {
       
  1449             iVideoRecordingPaused = ETrue;
       
  1450             CTimer::After( KNormalTimingDelay );
       
  1451             }
       
  1452         }
       
  1453 
       
  1454 	#ifdef _DEBUG
       
  1455     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingPaused() returning" ) );
       
  1456     #endif
       
  1457     }
       
  1458 
       
  1459 
       
  1460 void CCaeTestClient::McaeoVideoRecordingTimes( TTimeIntervalMicroSeconds aTimeElapsed, 
       
  1461                                                TTimeIntervalMicroSeconds aTimeRemaining, 
       
  1462                                                TInt aError )
       
  1463     {
       
  1464 	#ifdef _DEBUG
       
  1465     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingTimes() entering: %d" ), iCountVideoRecordingTimes );
       
  1466     #endif
       
  1467 
       
  1468     iCountVideoRecordingTimes++;
       
  1469 
       
  1470     if ( aError ) 
       
  1471         {
       
  1472 	    #ifdef _DEBUG
       
  1473         RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingTimes(): error detected: %d" ), aError );
       
  1474         #endif
       
  1475         StopOnError( aError );
       
  1476         }
       
  1477 
       
  1478     TBuf8<128> textVideoTimes;
       
  1479     
       
  1480     _LIT(KVideoTimesTitle, "Video times (elapsed remaining):\n");
       
  1481     _LIT(KSpaceSeparator, " ");
       
  1482 
       
  1483     textVideoTimes.Append( KVideoTimesTitle );
       
  1484     textVideoTimes.AppendNum( aTimeElapsed.Int64() );
       
  1485     textVideoTimes.Append( KSpaceSeparator );
       
  1486     textVideoTimes.AppendNum( aTimeRemaining.Int64() );
       
  1487     textVideoTimes.Append( _L("\n") );
       
  1488 
       
  1489     // Save video times info to data file. 
       
  1490     #if ( WRITE_VIDEOTIMES_TO_FILE )
       
  1491     const TDesC8& text = textVideoTimes;
       
  1492     TInt err = iFile.Open( iFsSession, KProcessFileName, EFileWrite );
       
  1493     TInt aPos;
       
  1494     err = iFile.Seek( ESeekEnd, aPos );
       
  1495     iFile.Write( text );
       
  1496     iFile.Close();
       
  1497     #endif
       
  1498 
       
  1499 	#ifdef _DEBUG
       
  1500     RDebug::Print( _L( "Cae: CCaeTestClient::McaeoVideoRecordingTimes() returning" ) );
       
  1501     #endif
       
  1502     }
       
  1503 
       
  1504 
       
  1505 void CCaeTestClient::StopOnError( TInt aError )
       
  1506     {
       
  1507 	#ifdef _DEBUG
       
  1508     RDebug::Print( _L( "Cae: CCaeTestClient::StopOnError(): Error: %d" ), aError );
       
  1509     #endif
       
  1510 
       
  1511 	__ASSERT_ALWAYS( !iStoppedOnError, User::Invariant());
       
  1512 
       
  1513     // Error => mark down the error code and stop.
       
  1514     iError = aError;
       
  1515 
       
  1516     if ( iCamAppEngine->IsViewFinding() )
       
  1517 	    {
       
  1518         iCamAppEngine->StopViewFinder();
       
  1519         iViewFinderStarted = EFalse;
       
  1520         }
       
  1521 
       
  1522     iCamAppEngine->CancelCaptureStill();
       
  1523 
       
  1524     if ( iCamAppEngine->IsVideoRecording() ) 
       
  1525         {
       
  1526         iCamAppEngine->StopVideoRecording();
       
  1527         }
       
  1528     
       
  1529     CActiveScheduler::Stop();
       
  1530 
       
  1531 	iStoppedOnError = ETrue;
       
  1532     }
       
  1533 
       
  1534 // -----------------------------------------------------------------------------
       
  1535 // CCaeTestClient::ReserveComplete
       
  1536 // Camera reservation is complete. 
       
  1537 // Called asynchronously when CCamera::Reserve() completes.
       
  1538 // From McameraObserver interface
       
  1539 // -----------------------------------------------------------------------------
       
  1540 //
       
  1541 void CCaeTestClient::ReserveComplete(                                 
       
  1542     TInt aError )
       
  1543     {
       
  1544 	#ifdef _DEBUG
       
  1545     RDebug::Print( _L( "Cae: CCaeTestClient::ReserveComplete() entering, aError=%d" ), aError );
       
  1546     #endif
       
  1547 
       
  1548     if ( aError == KErrNone )
       
  1549         {
       
  1550         iCameraDup->PowerOn();
       
  1551         }
       
  1552 
       
  1553 	#ifdef _DEBUG
       
  1554     RDebug::Print( _L( "Cae: CCaeTestClient::ReserveComplete() returning" ));
       
  1555     #endif
       
  1556     }
       
  1557 
       
  1558 // -----------------------------------------------------------------------------
       
  1559 // CCaeEngineImp::PowerOnComplete
       
  1560 // Indicates camera power on is complete.
       
  1561 // Called on completion of CCamera:PowerOn().
       
  1562 // From McameraObserver interface
       
  1563 // -----------------------------------------------------------------------------
       
  1564 //
       
  1565 void CCaeTestClient::PowerOnComplete( 
       
  1566     TInt aError )
       
  1567     {
       
  1568 	#ifdef _DEBUG
       
  1569     RDebug::Print( _L( "Cae: CCaeTestClient::PowerOnComplete() entering, aError=%d" ), aError );
       
  1570     #endif
       
  1571     if ( !aError)
       
  1572         {
       
  1573         iInitReady = ETrue;
       
  1574         iPowerOn   = ETrue;
       
  1575         }
       
  1576     CTimer::After( KNormalTimingDelay ); // This will start the test case AO to run
       
  1577 	#ifdef _DEBUG
       
  1578     RDebug::Print( _L( "Cae: CCaeTestClient::PowerOnComplete() returning" ) );
       
  1579     #endif
       
  1580     }
       
  1581 
       
  1582 // -----------------------------------------------------------------------------
       
  1583 // CCaeTestClient::ViewFinderFrameReady
       
  1584 // Transfers the current view finder image from the camera. The frame is 
       
  1585 // From McameraObserver interface
       
  1586 // -----------------------------------------------------------------------------
       
  1587 //
       
  1588 void CCaeTestClient::ViewFinderFrameReady( 
       
  1589     CFbsBitmap& /*aFrame*/ )
       
  1590     {
       
  1591 	#ifdef _DEBUG
       
  1592     RDebug::Print( _L( "Cae: CCaeTestClient::ViewFinderFrameReady() entering" ) );
       
  1593     #endif
       
  1594     }
       
  1595 
       
  1596 // -----------------------------------------------------------------------------
       
  1597 // CCaeTestClient::ImageReady
       
  1598 // Transfers the current image from the camera. 
       
  1599 // Called asynchronously when CCamera::CaptureImage() completes.
       
  1600 // From McameraObserver interface
       
  1601 // -----------------------------------------------------------------------------
       
  1602 //
       
  1603 void CCaeTestClient::ImageReady( 
       
  1604     CFbsBitmap* aBitmap, 
       
  1605     HBufC8*     aImageData, 
       
  1606     TInt        aError )
       
  1607     {
       
  1608 	#ifdef _DEBUG
       
  1609     RDebug::Print( _L( "Cae: CCaeTestClient::ViewFinderFrameReady() entering %d" ), aError );
       
  1610     #endif
       
  1611     if ( aBitmap )
       
  1612         delete aBitmap;
       
  1613     if ( aImageData )
       
  1614         delete aImageData;
       
  1615     aError++;
       
  1616     }
       
  1617 
       
  1618 // -----------------------------------------------------------------------------
       
  1619 // CCaeTestClient::HandleEvent
       
  1620 // MCameraObserver2 call-back handler
       
  1621 // -----------------------------------------------------------------------------
       
  1622 //
       
  1623 void CCaeTestClient::HandleEvent( const TECAMEvent& aEvent)
       
  1624     {
       
  1625     PRINT(( _L( "CCaeTestClient::HandleEvent() entering, type=%x, err=%d" ), aEvent.iEventType.iUid, aEvent.iErrorCode ));
       
  1626 
       
  1627     if ( aEvent.iEventType == KUidECamEventCameraNoLongerReserved )
       
  1628         {
       
  1629         PRINT(( _L( "CCaeTestClient::HandleEvent() KUidECamEventCameraNoLongerReserved" ) ));
       
  1630         }
       
  1631     else if ( aEvent.iEventType == KUidECamEventPowerOnComplete )
       
  1632         {
       
  1633         PRINT(( _L( "CCaeTestClient::HandleEvent() KUidECamEventPowerOnComplete" ) ));
       
  1634         PowerOnComplete( aEvent.iErrorCode );
       
  1635         }
       
  1636     else if ( aEvent.iEventType == KUidECamEventReserveComplete )
       
  1637        {
       
  1638        PRINT(( _L( "CCaeTestClient::HandleEvent() KUidECamEventReserveComplete" ) ));
       
  1639        ReserveComplete( aEvent.iErrorCode );
       
  1640        }
       
  1641 
       
  1642     PRINT(( _L( "CCaeTestClient::HandleEvent() returning" ) ));
       
  1643     }
       
  1644 
       
  1645 // -----------------------------------------------------------------------------
       
  1646 // CCaeTestClient::ViewFinderReady
       
  1647 // MCameraObserver2 call-back handler
       
  1648 // -----------------------------------------------------------------------------
       
  1649 //
       
  1650 void CCaeTestClient::ViewFinderReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
  1651     {
       
  1652     PRINT(( _L( "CCaeTestClient::ViewFinderReady() NOT HANDLED err=%d"), aError ));
       
  1653 
       
  1654     if ( !aError )
       
  1655         {
       
  1656 	    aCameraBuffer.Release();
       
  1657         }
       
  1658     }
       
  1659 
       
  1660 // -----------------------------------------------------------------------------
       
  1661 // CCaeTestClient::ImageBufferReady
       
  1662 // MCameraObserver2 call-back handler
       
  1663 // -----------------------------------------------------------------------------
       
  1664 //
       
  1665 void CCaeTestClient::ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
  1666     {
       
  1667     PRINT(( _L( "CCaeTestClient::ImageBufferReady() NOT HANDLED, err=%d" ), aError ));
       
  1668 	
       
  1669     if ( !aError )
       
  1670         {
       
  1671 	    aCameraBuffer.Release();
       
  1672         }
       
  1673     }
       
  1674     
       
  1675 // -----------------------------------------------------------------------------
       
  1676 // CCaeTestClient::VideoBufferReady
       
  1677 // MCameraObserver2 call-back handler
       
  1678 // -----------------------------------------------------------------------------
       
  1679 //
       
  1680 void CCaeTestClient::VideoBufferReady( MCameraBuffer& aCameraBuffer, TInt aError)
       
  1681     {
       
  1682     PRINT(( _L( "CCaeTestClient::VideoBufferReady() NOT HANDLED entering, err=%d" ), aError ));
       
  1683 	
       
  1684     if ( !aError )
       
  1685         {
       
  1686 	    aCameraBuffer.Release();
       
  1687         }
       
  1688     
       
  1689     PRINT(( _L( "CCaeTestClient::VideoBufferReady() returning" )));
       
  1690     }
       
  1691