sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "mmcameraclientsession.h" sl@0: #include "mmdirectviewfinder.h" sl@0: sl@0: #include sl@0: #include "w32std.h" sl@0: sl@0: /** sl@0: * First-phase constructor sl@0: */ sl@0: CMMCameraClientSession::CMMCameraClientSession():iCameraObserver2(NULL), sl@0: iReserved(EFalse), sl@0: iPoweredUp(EFalse), sl@0: iPrepareCompleted(EFalse), sl@0: iCollaborativeClient(EFalse) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * NewL() factory function sl@0: */ sl@0: CMMCameraClientSession* CMMCameraClientSession::NewL() sl@0: { sl@0: FileDependencyUtil::CheckFileDependencyL(); sl@0: return new (ELeave) CMMCameraClientSession; sl@0: } sl@0: sl@0: /** sl@0: * Destructor sl@0: */ sl@0: CMMCameraClientSession::~CMMCameraClientSession() sl@0: { sl@0: delete iCameraPowerHandler; sl@0: delete iCameraAccessHandler; sl@0: sl@0: iHashMap.Close(); sl@0: iCameraSession.Close(); sl@0: } sl@0: sl@0: sl@0: // sl@0: // from CCameraPlugin sl@0: // sl@0: sl@0: /** sl@0: * Derived from CCameraPlugin. Second Phase contruction sl@0: * sl@0: * @see CCameraPlugin sl@0: */ sl@0: void CMMCameraClientSession::Construct2L(MCameraObserver& /*aObserver*/, TInt /*aCameraIndex*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Derived from CCameraPlugin. Second Phase contruction for collaborative clients sl@0: * sl@0: * @see CCameraPlugin sl@0: */ sl@0: void CMMCameraClientSession::Construct2DupL(MCameraObserver& /*aObserver*/, TInt /*aCameraHandle*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Derived from CCameraPlugin. Second Phase contruction sl@0: * sl@0: * @see CCameraPlugin sl@0: */ sl@0: void CMMCameraClientSession::Construct2L(MCameraObserver2& aObserver, TInt aCameraIndex, TInt aPriority) sl@0: { sl@0: if (aCameraIndex > CamerasAvailable()) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: iCameraIndex = aCameraIndex; sl@0: iPriority = aPriority; sl@0: iCameraObserver2 = &aObserver; sl@0: sl@0: //initialize server sl@0: //create session sl@0: User::LeaveIfError(iCameraSession.Connect()); sl@0: sl@0: //open camera sl@0: TOpenCamera openCam; sl@0: sl@0: openCam.iCameraIndex = iCameraIndex; sl@0: openCam.iPriority = iPriority; sl@0: openCam.iHandle = KECamHandleNotKnown; sl@0: openCam.iMMCapability = ETrue; //could be changed. sl@0: openCam.iCollaborativeClient = EFalse; sl@0: sl@0: TOpenCameraPckg openCamBuf(openCam); sl@0: sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamOpenCamera, openCamBuf)); sl@0: // since this call is synchronous, providing reference to local sl@0: // varialbe is not a problem. sl@0: sl@0: iCameraAccessHandler = CMMCameraAccessHandler::NewL(this, CActive::EPriorityStandard); sl@0: iCameraPowerHandler = CMMCameraPowerHandler::NewL(this, CActive::EPriorityStandard); sl@0: } sl@0: sl@0: /** sl@0: * Derived from CCameraPlugin. Second Phase contruction for collaborative clients sl@0: * sl@0: * @see CCameraPlugin sl@0: */ sl@0: void CMMCameraClientSession::Construct2DupL(MCameraObserver2& /*aObserver*/, TInt /*aCameraHandle*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: sl@0: // sl@0: // from CCamera itself sl@0: // sl@0: sl@0: /** sl@0: * Retrieves information about the currectly reserved camera device sl@0: * sl@0: * @see CCamera::CameraInfo() sl@0: */ sl@0: void CMMCameraClientSession::CameraInfo(TCameraInfo& /*aInfo*/) const sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Reserves the camera sl@0: * sl@0: * @see CCamera::Reserve() sl@0: */ sl@0: void CMMCameraClientSession::Reserve() sl@0: { sl@0: iCameraAccessHandler->Reserve(); sl@0: } sl@0: sl@0: /** sl@0: * Relinquishes control of the camera device sl@0: * sl@0: * @see CCamera::Release() sl@0: */ sl@0: void CMMCameraClientSession::Release() sl@0: { sl@0: iCameraSession.SendMessage(ECamCameraAccessControl, ECameraRelease); sl@0: iPoweredUp = EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Powers on the camera device sl@0: * sl@0: * @see CCamera::PowerOn() sl@0: */ sl@0: void CMMCameraClientSession::PowerOn() sl@0: { sl@0: iCameraPowerHandler->PowerOn(); sl@0: } sl@0: sl@0: /** sl@0: * Powers down the camera device sl@0: * sl@0: * @see CCamera::PowerOff() sl@0: */ sl@0: void CMMCameraClientSession::PowerOff() sl@0: { sl@0: iCameraSession.SendMessage(ECamPowerCamera, ECameraPowerOff); sl@0: iPoweredUp = EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the handle of the currently reserved camera sl@0: * sl@0: * @see CCamera::Handle() sl@0: */ sl@0: TInt CMMCameraClientSession::Handle() sl@0: { sl@0: TCameraHandle handle; sl@0: TCameraHandlePckg pckg(handle); sl@0: sl@0: iCameraSession.SendRxMessage(ECamCameraHandle, pckg); sl@0: sl@0: handle = pckg(); sl@0: return handle.iHandle; sl@0: } sl@0: sl@0: /** sl@0: * Sets the optical zoom level sl@0: * sl@0: * @see CCamera::SetZoomFactorL() sl@0: */ sl@0: void CMMCameraClientSession::SetZoomFactorL(TInt aZoomFactor) sl@0: { sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EZoomFactor, aZoomFactor)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves current optical zoom level sl@0: * sl@0: * @see CCamera::ZoomFactor() sl@0: */ sl@0: TInt CMMCameraClientSession::ZoomFactor() const sl@0: { sl@0: TCameraZoom zoomFactor; sl@0: TCameraZoomPckg pckg(zoomFactor); sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EZoomFactor, pckg); sl@0: zoomFactor = pckg(); sl@0: return zoomFactor.iZoom; sl@0: } sl@0: sl@0: /** sl@0: * Sets the digital zoom level sl@0: * sl@0: * @see CCamera::SetDigitalZoomFactorL() sl@0: */ sl@0: void CMMCameraClientSession::SetDigitalZoomFactorL(TInt aDigitalZoomFactor) sl@0: { sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EDigitalZoomFactor, aDigitalZoomFactor)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current digital zoom level sl@0: * sl@0: * @see CCamera::DigitalZoomFactor() sl@0: */ sl@0: TInt CMMCameraClientSession::DigitalZoomFactor() const sl@0: { sl@0: TCameraDigitalZoom digitalZoomFactor; sl@0: TCameraDigitalZoomPckg pckg(digitalZoomFactor); sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EDigitalZoomFactor, pckg); sl@0: digitalZoomFactor = pckg(); sl@0: return digitalZoomFactor.iDigitalZoom; sl@0: } sl@0: sl@0: /** sl@0: * Sets the contrast level sl@0: * sl@0: * @see CCamera::SetContrastL() sl@0: */ sl@0: void CMMCameraClientSession::SetContrastL(TInt aContrast) sl@0: { sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EContrast, aContrast)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current contrast level sl@0: * sl@0: * @see CCamera::Contrast() sl@0: */ sl@0: TInt CMMCameraClientSession::Contrast() const sl@0: { sl@0: TCameraContrast contrast; sl@0: TCameraContrastPckg pckg(contrast); sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EContrast, pckg); sl@0: contrast = pckg(); sl@0: return contrast.iContrast; sl@0: } sl@0: sl@0: /** sl@0: * Sets the brightness level sl@0: * sl@0: * @see CCamera::SetBrightnessL() sl@0: */ sl@0: void CMMCameraClientSession::SetBrightnessL(TInt aBrightness) sl@0: { sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EBrightness, aBrightness)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current brightness level sl@0: * sl@0: * @see CCamera::Brigthness() sl@0: */ sl@0: TInt CMMCameraClientSession::Brightness() const sl@0: { sl@0: TCameraBrightness brightness; sl@0: TCameraBrightnessPckg pckg(brightness); sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EBrightness, pckg); sl@0: brightness = pckg(); sl@0: return brightness.iBrightness; sl@0: } sl@0: sl@0: /** sl@0: * Sets the flash level sl@0: * sl@0: * @see CCamera::SetFlashL() sl@0: */ sl@0: void CMMCameraClientSession::SetFlashL(TFlash aFlash) sl@0: { sl@0: TCameraFlash flash; sl@0: flash.iFlash = aFlash; sl@0: TCameraFlashPckg pckg(flash); sl@0: sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EFlash, pckg)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current flash level sl@0: * sl@0: * @see CCamera::Flash() sl@0: */ sl@0: CCamera::TFlash CMMCameraClientSession::Flash() const sl@0: { sl@0: TCameraFlash flash; sl@0: TCameraFlashPckg pckg(flash); sl@0: sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EFlash, pckg); sl@0: flash = pckg(); sl@0: return flash.iFlash; sl@0: } sl@0: sl@0: /** sl@0: * Sets the exposure level sl@0: * sl@0: * @see CCamera::SetExposureL() sl@0: */ sl@0: void CMMCameraClientSession::SetExposureL(TExposure aExposure) sl@0: { sl@0: TCameraExposure exposure; sl@0: exposure.iExposure = aExposure; sl@0: TCameraExposurePckg pckg(exposure); sl@0: sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EExposure, pckg)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current exposure level sl@0: * sl@0: * @see CCamera::Exposure() sl@0: */ sl@0: CCamera::TExposure CMMCameraClientSession::Exposure() const sl@0: { sl@0: TCameraExposure exposure; sl@0: TCameraExposurePckg pckg(exposure); sl@0: sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EExposure, pckg); sl@0: exposure = pckg(); sl@0: return exposure.iExposure; sl@0: } sl@0: sl@0: /** sl@0: * Sets the white balance level sl@0: * sl@0: * @see CCamera::SetWhiteBalance() sl@0: */ sl@0: void CMMCameraClientSession::SetWhiteBalanceL(TWhiteBalance aWhiteBalance) sl@0: { sl@0: TCameraWhiteBalance whiteBalance; sl@0: whiteBalance.iWhiteBalance = aWhiteBalance; sl@0: TCameraWhiteBalancePckg pckg(whiteBalance); sl@0: sl@0: User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EWhiteBalance, pckg)); sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the current white balance level sl@0: * sl@0: * @see CCamera::WhiteBalance() sl@0: */ sl@0: CCamera::TWhiteBalance CMMCameraClientSession::WhiteBalance() const sl@0: { sl@0: TCameraWhiteBalance whiteBalance; sl@0: TCameraWhiteBalancePckg pckg(whiteBalance); sl@0: sl@0: iCameraSession.SendRxMessage(ECamGetParameter, EWhiteBalance, pckg); sl@0: whiteBalance = pckg(); sl@0: return whiteBalance.iWhiteBalance; sl@0: } sl@0: sl@0: /** sl@0: * Starts client direct viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderDirectL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderDirectL(RWsSession& /*aWs*/, CWsScreenDevice& /*aScreenDevice*/, RWindowBase& /*aWindow*/, TRect& /*aScreenRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts client direct viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderDirectL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderDirectL(RWsSession& /*aWs*/, CWsScreenDevice& /*aScreenDevice*/, RWindowBase& /*aWindow*/, TRect& /*aScreenRect*/, TRect& /*aClipRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts client viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderBitmapsL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderBitmapsL(TSize& /*aSize*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts client viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderBitmapsL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderBitmapsL(TSize& /*aSize*/, TRect& /*aClipRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts client viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderL(CCamera::TFormat /*aImageFormat*/, TSize& /*aSize*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts client viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StartViewFinderL() sl@0: */ sl@0: void CMMCameraClientSession::StartViewFinderL(CCamera::TFormat /*aImageFormat*/, TSize& /*aSize*/, TRect& /*aClipRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Stops client viewfinder. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::StopViewFinder() sl@0: */ sl@0: void CMMCameraClientSession::StopViewFinder() sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Queries if viewfinder is active. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::ViewFinderActive() sl@0: */ sl@0: TBool CMMCameraClientSession::ViewFinderActive() const sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Turns on/off viewfinder mirrorring. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::SetViewFinderMirrorL() sl@0: */ sl@0: void CMMCameraClientSession::SetViewFinderMirrorL(TBool /*aMirror*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Queries whether viewfinder mirrorring is on or off. sl@0: * Not supported in this implementation. sl@0: * sl@0: * @see CCamera::ViewFinderMirrorL() sl@0: */ sl@0: TBool CMMCameraClientSession::ViewFinderMirror() const sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Prepares image capture. sl@0: * sl@0: * @see CCamera::PrepareImageCapture() sl@0: */ sl@0: void CMMCameraClientSession::PrepareImageCaptureL(CCamera::TFormat /*aImageFormat*/, TInt /*aSizeIndex*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Prepares image capture. sl@0: * sl@0: * @see CCamera::PrepareImageCapture() sl@0: */ sl@0: void CMMCameraClientSession::PrepareImageCaptureL(CCamera::TFormat /*aImageFormat*/, TInt /*aSizeIndex*/, const TRect& /*aClipRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Captures image. sl@0: * sl@0: * @see CCamera::CaptureImage() sl@0: */ sl@0: void CMMCameraClientSession::CaptureImage() sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Cancels any ongoing image capture. sl@0: * sl@0: * @see CCamera::CaptureImage() sl@0: */ sl@0: void CMMCameraClientSession::CancelCaptureImage() sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Enumerates image capture sizes. sl@0: * sl@0: * @see CCamera::EnumerateCaptureSizes() sl@0: */ sl@0: void CMMCameraClientSession::EnumerateCaptureSizes(TSize& /*aSize*/, TInt /*aSizeIndex*/, CCamera::TFormat /*aFormat*/) const sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Prepares video capture. sl@0: * sl@0: * @see CCamera::PrepareVideoCaptureL() sl@0: */ sl@0: void CMMCameraClientSession::PrepareVideoCaptureL(CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TInt /*aRateIndex*/, TInt /*aBuffersToUse*/, TInt /*aFramesPerBuffer*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Prepares video capture. sl@0: * sl@0: * @see CCamera::PrepareVideoCaptureL() sl@0: */ sl@0: void CMMCameraClientSession::PrepareVideoCaptureL(CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TInt /*aRateIndex*/, TInt /*aBuffersToUse*/, TInt /*aFramesPerBuffer*/, const TRect& /*aClipRect*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /** sl@0: * Starts video capture. sl@0: * sl@0: * @see CCamera::StartVideoCapture() sl@0: */ sl@0: void CMMCameraClientSession::StartVideoCapture() sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Stops video capture. sl@0: * sl@0: * @see CCamera::StopVideoCapture() sl@0: */ sl@0: void CMMCameraClientSession::StopVideoCapture() sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Queries whether video capture is active. sl@0: * sl@0: * @see CCamera::VideoCaptureActive() sl@0: */ sl@0: TBool CMMCameraClientSession::VideoCaptureActive() const sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Enumerates video frame sizes. sl@0: * sl@0: * @see CCamera::EnumerateVideoFrameSizes() sl@0: */ sl@0: void CMMCameraClientSession::EnumerateVideoFrameSizes(TSize& /*aSize*/, TInt /*aSizeIndex*/, CCamera::TFormat /*aFormat*/) const sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Enumerates video frame rates. sl@0: * sl@0: * @see CCamera::EnumerateVideoFrameRates() sl@0: */ sl@0: void CMMCameraClientSession::EnumerateVideoFrameRates(TReal32& /*aRate*/, TInt /*aRateIndex*/, CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TExposure /*aExposure*/) const sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Retrieve the frame size. sl@0: * sl@0: * @see CCamera::GetFrameSize() sl@0: */ sl@0: void CMMCameraClientSession::GetFrameSize(TSize& /*aSize*/) const sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Retrieve the frame rate. sl@0: * sl@0: * @see CCamera::FrameRate() sl@0: */ sl@0: TReal32 CMMCameraClientSession::FrameRate() const sl@0: { sl@0: return static_cast(0); sl@0: } sl@0: sl@0: /** sl@0: * Retrieve the number of buffers currently in use. sl@0: * sl@0: * @see CCamera::BuffersInUse() sl@0: */ sl@0: TInt CMMCameraClientSession::BuffersInUse() const sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: /** sl@0: * Retrieve the number of frames per buffer. sl@0: * sl@0: * @see CCamera::FramesPerBuffer() sl@0: */ sl@0: TInt CMMCameraClientSession::FramesPerBuffer() const sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: /** sl@0: * Set the Jpeg quality. sl@0: * sl@0: * @see CCamera::SetJpegQuality() sl@0: */ sl@0: void CMMCameraClientSession::SetJpegQuality(TInt /*aQuality*/) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: * Retrieve the Jpeg quality. sl@0: * sl@0: * @see CCamera::JpegQuality() sl@0: */ sl@0: TInt CMMCameraClientSession::JpegQuality() const sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: /** sl@0: * Retrieves a custom interface based on the id passed in by the client. sl@0: * sl@0: * @see CCamera::CustomInterface() sl@0: */ sl@0: TAny* CMMCameraClientSession::CustomInterface(TUid aInterface) sl@0: { sl@0: switch (aInterface.iUid) sl@0: { sl@0: // The framework retrieves KECamMCameraV2DirectViewFinderUidValue followed by KECamMCameraBaseV2DirectViewFinderUidValue sl@0: // We take care to initialise iDirectViewFinder in the first case and use it in the subsequent call sl@0: case KECamMCameraV2DirectViewFinderUidValue: sl@0: { sl@0: ASSERT(!iDirectViewFinder); sl@0: TRAPD(err, iDirectViewFinder = CMMDirectViewFinder::NewL(*this)); sl@0: if (err != KErrNone) sl@0: { sl@0: return NULL; sl@0: } sl@0: sl@0: return static_cast(iDirectViewFinder); sl@0: } sl@0: sl@0: case KECamMCameraBaseV2DirectViewFinderUidValue: sl@0: { sl@0: ASSERT(iDirectViewFinder); sl@0: iVF = static_cast(iDirectViewFinder); sl@0: //delete iDirectViewFinder; sl@0: iDirectViewFinder = NULL; sl@0: return iVF; sl@0: } sl@0: sl@0: default: sl@0: { sl@0: return NULL; sl@0: } sl@0: } sl@0: } sl@0: sl@0: // sl@0: // From CCameraInfoPlugin sl@0: // sl@0: CMMCameraClientSessionInfo* CMMCameraClientSessionInfo::NewL() sl@0: { sl@0: FileDependencyUtil::CheckFileDependencyL(); sl@0: return new (ELeave) CMMCameraClientSessionInfo; sl@0: } sl@0: sl@0: CMMCameraClientSessionInfo::~CMMCameraClientSessionInfo() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Retrieves the number of cameras available. sl@0: * sl@0: * @see CCameraInfoPlugin::CamerasAvailable() sl@0: */ sl@0: TInt CMMCameraClientSessionInfo::CamerasAvailable() sl@0: { sl@0: // One-off connection to the server sl@0: RMMCameraSession cameraSession; sl@0: TInt error = cameraSession.Connect(); sl@0: if (error != KErrNone) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TCamerasAvailable info; sl@0: TCamerasAvailablePckg pckg(info); sl@0: sl@0: error = cameraSession.SendMessage(ECamQueryCamerasAvailable, pckg); sl@0: cameraSession.Close(); sl@0: if (error != KErrNone) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: info = pckg(); sl@0: return info.iCameraCount; sl@0: } sl@0: sl@0: CMMCameraClientSessionInfo::CMMCameraClientSessionInfo() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: void FileDependencyUtil::CheckFileDependencyL() sl@0: { sl@0: RFs fsSession; sl@0: RFile file; sl@0: CleanupClosePushL(fsSession); sl@0: User::LeaveIfError(fsSession.Connect()); sl@0: TInt err = file.Open(fsSession, KMMCameraPluginName, EFileRead); sl@0: file.Close(); sl@0: if(err != KErrNone) sl@0: { sl@0: User::LeaveIfError(KErrNotSupported); sl@0: } sl@0: CleanupStack::PopAndDestroy(&fsSession); sl@0: } sl@0: sl@0: sl@0: // sl@0: // CLASS CMMCameraAccessHandler sl@0: // sl@0: sl@0: CMMCameraAccessHandler::CMMCameraAccessHandler(CMMCameraClientSession* aPlugin, TInt aPriority): CActive(aPriority), sl@0: iPlugin(aPlugin) sl@0: { sl@0: } sl@0: sl@0: CMMCameraAccessHandler* CMMCameraAccessHandler::NewL(CMMCameraClientSession* aPlugin, TInt aPriority) sl@0: { sl@0: CMMCameraAccessHandler* self = new (ELeave) CMMCameraAccessHandler(aPlugin, aPriority); sl@0: CActiveScheduler::Add(self); sl@0: return self; sl@0: } sl@0: sl@0: CMMCameraAccessHandler::~CMMCameraAccessHandler() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CMMCameraAccessHandler::Reserve() sl@0: { sl@0: if(!IsActive()) sl@0: { sl@0: // Reserve the camera sl@0: iPlugin->iCameraSession.ReceiveMessage(ECamCameraAccessControl, ECameraReservedNotification, iStatus); sl@0: SetActive(); sl@0: } sl@0: else sl@0: { sl@0: // Reserve has been called again before first call has completed so notify the client sl@0: TECAMEvent ecamEvent(KUidECamEventReserveComplete, KErrInUse); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: } sl@0: sl@0: void CMMCameraAccessHandler::RunL() sl@0: { sl@0: TInt ret = iStatus.Int(); sl@0: sl@0: if(!iPlugin->iReserved) sl@0: { sl@0: if(KErrNone == ret) sl@0: { sl@0: iPlugin->iReserved = ETrue; sl@0: if(!IsActive()) sl@0: { sl@0: // Continue monitoring for overthrow messages should a higher priority client reserve the same camera index sl@0: iPlugin->iCameraSession.ReceiveMessage(ECamCameraAccessControl, ECameraOverthrowNotification, iStatus); sl@0: SetActive(); sl@0: } sl@0: } sl@0: sl@0: // notify the client that reserve has completed, successfully or otherwise sl@0: TECAMEvent ecamEvent(KUidECamEventReserveComplete, ret); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: else sl@0: { sl@0: iPlugin->iReserved = EFalse; sl@0: sl@0: if (ret == KErrNone) sl@0: { sl@0: // Client has been overthrown by a second client with higher priority sl@0: TECAMEvent ecamEvent(KUidECamEventCameraNoLongerReserved, ret); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CMMCameraAccessHandler::DoCancel() sl@0: { sl@0: if(!iPlugin->iReserved) sl@0: { sl@0: iPlugin->iCameraSession.SendMessage(ECamCameraAccessControl, ECameraCancelReservedNotification); sl@0: sl@0: // Notify client that ongoing reserve request was cancelled sl@0: TECAMEvent ecamEvent(KUidECamEventReserveComplete, KErrCancel); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: else sl@0: { sl@0: iPlugin->iCameraSession.SendMessage(ECamCameraAccessControl, ECameraCancelOverthrowNotification); sl@0: iPlugin->iReserved = EFalse; sl@0: } sl@0: } sl@0: sl@0: sl@0: // sl@0: // sl@0: // CLASS CMMCameraPowerHandler sl@0: // sl@0: sl@0: CMMCameraPowerHandler::CMMCameraPowerHandler(CMMCameraClientSession* aPlugin, TInt aPriority): CActive(aPriority), sl@0: iPlugin(aPlugin) sl@0: { sl@0: } sl@0: sl@0: CMMCameraPowerHandler* CMMCameraPowerHandler::NewL(CMMCameraClientSession* aPlugin, TInt aPriority) sl@0: { sl@0: CMMCameraPowerHandler* self = new (ELeave) CMMCameraPowerHandler(aPlugin, aPriority); sl@0: CActiveScheduler::Add(self); sl@0: return self; sl@0: } sl@0: sl@0: CMMCameraPowerHandler::~CMMCameraPowerHandler() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CMMCameraPowerHandler::PowerOn() sl@0: { sl@0: if(!IsActive()) sl@0: { sl@0: iPlugin->iCameraSession.ReceiveMessage(ECamPowerCamera, ECameraPowerOnNotification, iStatus); sl@0: SetActive(); sl@0: } sl@0: else sl@0: { sl@0: // PowerOn has been called again before first call has completed so notify the client sl@0: TECAMEvent ecamEvent(KUidECamEventPowerOnComplete, KErrAlreadyExists); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: } sl@0: sl@0: void CMMCameraPowerHandler::RunL() sl@0: { sl@0: TInt ret = iStatus.Int(); sl@0: sl@0: if(!iPlugin->iPoweredUp) sl@0: { sl@0: if (ret == KErrNone) sl@0: { sl@0: iPlugin->iPoweredUp = ETrue; sl@0: } sl@0: } sl@0: sl@0: TECAMEvent ecamEvent(KUidECamEventPowerOnComplete, ret); sl@0: iPlugin->iCameraObserver2->HandleEvent(ecamEvent); sl@0: } sl@0: sl@0: void CMMCameraPowerHandler::DoCancel() sl@0: { sl@0: if(!iPlugin->iPoweredUp) sl@0: { sl@0: iPlugin->iCameraSession.SendMessage(ECamPowerCamera, ECameraCancelPowerOnNotification); sl@0: } sl@0: } sl@0: sl@0: sl@0: // __________________________________________________________________________ sl@0: // Exported proxy for instantiation method resolution sl@0: // Define the interface UIDs sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(KUidMMCameraClientSession, CMMCameraClientSession::NewL), sl@0: IMPLEMENTATION_PROXY_ENTRY(KUidMMCameraClientSessionInfo, CMMCameraClientSessionInfo::NewL) sl@0: }; sl@0: sl@0: EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) sl@0: { sl@0: aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); sl@0: sl@0: return ImplementationTable; sl@0: }