PrjName = 'swCameraOptions' UID = '0x02222224' resource.caption = ['swCamera Options', 'swCamOpt'] #resource.model = '7610' appui.intro_src += """ #define VIDEO( x ) { TRAPD( Error, iVideoRecorder->x ); ErrorNotifyL(_L("x err"), Error, EFalse); } """ resource.menu = [ ['Video', [['Start Capturing', 'VIDEO( StartVideoCaptureL() )' ], ['Stop Capturing', 'VIDEO( StopVideoCapture() )' ], ]], ['Video Resolution', [['128x96', 'VIDEO( SetVideoCaptureRes(1) )' ], ['176x144', 'VIDEO( SetVideoCaptureRes(0) )' ], ]], ['Video Settings', [['Adjust Contrast', [['Increase', 'VIDEO( IncContrastL() )' ], ['Decrease', 'VIDEO( DecContrastL() )' ], ]], ['Adjust Brightness', [['Increase', 'VIDEO( IncBrightnessL() )' ], ['Decrease', 'VIDEO( DecBrightnessL() )' ], ]], ['Digital Zoom', [['1X', 'VIDEO( SetZoomLevelL(0) )' ], ['2X', 'VIDEO( SetZoomLevelL(1) )' ], ['3X', 'VIDEO( SetZoomLevelL(2) )' ], ['4X', 'VIDEO( SetZoomLevelL(3) )' ], ]], ['Exposure Modes', [['Night', 'VIDEO( ExposureModeNightL() )' ], ['Auto', 'VIDEO( ExposureModeAutoL() )' ], ]], ['Reset Settings', 'VIDEO( ResetSettingsL() )' ], ]], ['Camera Info', 'VIDEO( HWInformation() )' ], ] resource.libraries += [ 'fbscli', 'ws32' ] appui.add_notify() appui.inc_inc += [ '"VideoRecorder.h"' ] appui.add_private( Var( 'CVideoRecorder*', 'iVideoRecorder' ), destroy_var = True ) appui.members['ConstructL'].code += """ iVideoRecorder = CVideoRecorder::NewL( iAppView );""" videoeng = CClass( ('VideoRecorder', 'An engine class that does the camera specific things') ) videoeng.parent = ': public CBase' videoeng.use_camera() videoeng.members['ConstructL'].code += """ iCamera->Reserve(); iVideoSizeIndex = KResolution128x96; iCurrZoomFactor = 0; TCameraInfo cameraInfo; iCamera->CameraInfo(cameraInfo);""" videoeng.intro_src = """ const TInt KFrameRateIndex = 0; const TInt KFramesPerBuffer = 1; const TInt KBuffersInUse = 2; const CCamera::TFormat KVideoFormat = CCamera::EFormatYUV420Planar; const TInt KResolution128x96 = 1;""" videoeng.members['ReserveComplete'].code += '\n iCamera->PowerOn();' videoeng.members['PowerOnComplete'].code += '\n StartViewFinder();' videoeng.members['FrameBufferReady'].code += """ iProcessedBuffer = aFrameBuffer; if ( iProcessedBuffer ) { TDesC8* ptr = aFrameBuffer->DataL(0); if ( !ptr ) { ErrorNotifyL(_L("Vid Frame err: "), 0, EFalse); } else { iFrameIndex = aFrameBuffer->iIndexOfFirstFrameInBuffer; } // just check that you could get back the data, FrameL() returns the bitmap // but this example doesn't do anything with it TRAPD( err, aFrameBuffer->FrameL(0) ); if( err != KErrNotSupported ) { ErrorNotifyL(_L("Frame ready err: "), err, EFalse); } aFrameBuffer->Release(); } iProcessedBuffer = NULL;""" videoeng.add_public( Method( 'void', ('HWInformation', 'Shows some camera information.'), [], r""" TBuf<200> text; TCameraInfo iCamInfo; iCamera->CameraInfo(iCamInfo); TReal32 rate = 0; iCamera->EnumerateVideoFrameRates(rate,KFrameRateIndex,KVideoFormat,iVideoSizeIndex); text.Format( _L( "Camera Info\nHW: %S\nSW: %S\nDigital Zoom: %d\nFrame Rate: %d" ), &iCamInfo.iHardwareVersion.Name(), &iCamInfo.iSoftwareVersion.Name(), (TInt)iCamInfo.iMaxDigitalZoomFactor, (TInt)rate); InfoNotifyL(text);""" ) ) videoeng.add_public( Method( 'TInt', ('StartVideoCaptureL', 'Start Video Capture.'), [], """ if ( iCamera->VideoCaptureActive() ) { return KErrInUse; } else { iCamera->PrepareVideoCaptureL( KVideoFormat, iVideoSizeIndex, KFrameRateIndex, KBuffersInUse, KFramesPerBuffer ); iCamera->StartVideoCapture(); } if ( !iCamera->VideoCaptureActive() ) { return KErrNotSupported; } return KErrNone;""") ) videoeng.add_public( Method( 'void', ('StopVideoCapture', 'Stop Video Capture, show how many frames were captured.'), [], """ if ( iProcessedBuffer ) { iProcessedBuffer->Release(); iProcessedBuffer = NULL; } iCamera->StopVideoCapture(); TBuf<40> text; text.Format( _L("Captured %d frames"), iFrameIndex ); InfoNotifyL(text);""") ) videoeng.add_public( Method( 'void', ('IncBrightnessL', 'Increases brightness by 10.'), [], """ iCamera->SetBrightnessL( iCamera->Brightness() + 10 );""") ) videoeng.add_public( Method( 'void', ('DecBrightnessL', 'Decreases brightness by 10.'), [], """ iCamera->SetBrightnessL( iCamera->Brightness() - 10 );""") ) videoeng.add_public( Method( 'void', ('IncContrastL', 'Increases contrast by 10.'), [], """ iCamera->SetContrastL( iCamera->Contrast() + 10 );""") ) videoeng.add_public( Method( 'void', ('DecContrastL', 'Decreases contrast by 10.'), [], """ iCamera->SetContrastL( iCamera->Contrast() - 10 );""") ) videoeng.add_public( Method( 'void', ('ResetSettingsL', 'Reset default camera settings.'), [], """ iCamera->SetBrightnessL( 0 ); iCamera->SetContrastL( 0 ); iCamera->SetDigitalZoomFactorL( 0 ); iCamera->SetExposureL( CCamera::EExposureAuto );""") ) videoeng.add_public( Method( 'void', ('SetZoomLevelL', 'Set camera zoom factor.'), [Arg('TInt', 'aZoom')], """ iCamera->SetDigitalZoomFactorL( aZoom );""") ) videoeng.add_public( Method( 'void', ('ExposureModeNightL', 'Set camera exposure mode to Night.'), [], """ iCamera->SetExposureL( CCamera::EExposureNight );""") ) videoeng.add_public( Method( 'void', ('ExposureModeAutoL', 'Set camera exposure mode to Auto.'), [], """ iCamera->SetExposureL( CCamera::EExposureAuto );""") ) videoeng.add_public( Method( 'void', ('SetVideoCaptureRes', 'Set video capture resolution.'), [Arg('TInt', 'aSizeIndex')], 'iVideoSizeIndex = aSizeIndex;') ) videoeng.add_private( Var( 'MFrameBuffer*', 'iProcessedBuffer' ) ) videoeng.add_private( Var( 'TInt', 'iFrameIndex' ) ) videoeng.add_private( Var( 'TInt', 'iCurrZoomFactor' ) ) videoeng.add_private( Var( 'TInt', 'iVideoSizeIndex' ) )