os/mm/mmplugins/cameraplugins/source/mmcameraclientplugin/mmcameraclientsession/src/mmcameraclientsession.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmplugins/cameraplugins/source/mmcameraclientplugin/mmcameraclientsession/src/mmcameraclientsession.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,951 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @internalComponent
    1.22 +*/
    1.23 +
    1.24 +#include <ecom/ecom.h>
    1.25 +#include <ecom/implementationproxy.h>
    1.26 +#include <f32file.h>
    1.27 +
    1.28 +#include "mmcameraclientsession.h"
    1.29 +#include "mmdirectviewfinder.h"
    1.30 +
    1.31 +#include <graphics/surfaceconfiguration.h>
    1.32 +#include "w32std.h"
    1.33 +
    1.34 +/**
    1.35 + * First-phase constructor
    1.36 + */
    1.37 +CMMCameraClientSession::CMMCameraClientSession():iCameraObserver2(NULL),
    1.38 +									 iReserved(EFalse),
    1.39 +									 iPoweredUp(EFalse),
    1.40 +									 iPrepareCompleted(EFalse),
    1.41 +									 iCollaborativeClient(EFalse)
    1.42 +	{
    1.43 +	}
    1.44 +
    1.45 +/**
    1.46 + * NewL() factory function
    1.47 + */
    1.48 +CMMCameraClientSession* CMMCameraClientSession::NewL()
    1.49 +	{
    1.50 +	FileDependencyUtil::CheckFileDependencyL();
    1.51 +	return new (ELeave) CMMCameraClientSession;
    1.52 +	}
    1.53 +
    1.54 +/**
    1.55 + * Destructor
    1.56 + */
    1.57 +CMMCameraClientSession::~CMMCameraClientSession()
    1.58 +	{
    1.59 +	delete iCameraPowerHandler;
    1.60 +	delete iCameraAccessHandler;
    1.61 +
    1.62 +	iHashMap.Close();
    1.63 +	iCameraSession.Close();
    1.64 +	}
    1.65 +
    1.66 +
    1.67 +//
    1.68 +// from CCameraPlugin
    1.69 +//
    1.70 +
    1.71 +/**
    1.72 + * Derived from CCameraPlugin. Second Phase contruction
    1.73 + *
    1.74 + * @see CCameraPlugin
    1.75 + */
    1.76 +void CMMCameraClientSession::Construct2L(MCameraObserver& /*aObserver*/, TInt /*aCameraIndex*/)
    1.77 +	{
    1.78 +	User::Leave(KErrNotSupported);
    1.79 +	}
    1.80 +
    1.81 +/**
    1.82 + * Derived from CCameraPlugin. Second Phase contruction for collaborative clients
    1.83 + *
    1.84 + * @see CCameraPlugin
    1.85 + */
    1.86 +void CMMCameraClientSession::Construct2DupL(MCameraObserver& /*aObserver*/, TInt /*aCameraHandle*/)
    1.87 +	{
    1.88 +	User::Leave(KErrNotSupported);
    1.89 +	}
    1.90 +
    1.91 +/**
    1.92 + * Derived from CCameraPlugin. Second Phase contruction
    1.93 + *
    1.94 + * @see CCameraPlugin
    1.95 + */
    1.96 +void CMMCameraClientSession::Construct2L(MCameraObserver2& aObserver, TInt aCameraIndex, TInt aPriority)
    1.97 +	{
    1.98 +	if (aCameraIndex > CamerasAvailable())
    1.99 +		{
   1.100 +		User::Leave(KErrNotSupported);
   1.101 +		}
   1.102 +
   1.103 +	iCameraIndex = aCameraIndex;
   1.104 +	iPriority = aPriority;
   1.105 +	iCameraObserver2 = &aObserver;
   1.106 +
   1.107 +	//initialize server
   1.108 +	//create session
   1.109 +	User::LeaveIfError(iCameraSession.Connect());
   1.110 +
   1.111 +	//open camera
   1.112 +	TOpenCamera openCam;
   1.113 +
   1.114 +	openCam.iCameraIndex = iCameraIndex;
   1.115 +	openCam.iPriority = iPriority;
   1.116 +	openCam.iHandle = KECamHandleNotKnown;
   1.117 +	openCam.iMMCapability = ETrue;  //could be changed.
   1.118 +	openCam.iCollaborativeClient = EFalse;
   1.119 +
   1.120 +	TOpenCameraPckg openCamBuf(openCam);
   1.121 +
   1.122 +	User::LeaveIfError(iCameraSession.SendMessage(ECamOpenCamera, openCamBuf));
   1.123 +					// since this call is synchronous, providing reference to local
   1.124 +					//  varialbe is not a problem.
   1.125 +												   
   1.126 +	iCameraAccessHandler = CMMCameraAccessHandler::NewL(this, CActive::EPriorityStandard);
   1.127 +	iCameraPowerHandler = CMMCameraPowerHandler::NewL(this, CActive::EPriorityStandard);
   1.128 +	}
   1.129 +
   1.130 +/**
   1.131 + * Derived from CCameraPlugin. Second Phase contruction for collaborative clients
   1.132 + *
   1.133 + * @see CCameraPlugin
   1.134 + */
   1.135 +void CMMCameraClientSession::Construct2DupL(MCameraObserver2& /*aObserver*/, TInt /*aCameraHandle*/)
   1.136 +	{
   1.137 +	User::Leave(KErrNotSupported);	
   1.138 +	}
   1.139 +
   1.140 +
   1.141 +//
   1.142 +// from CCamera itself
   1.143 +//
   1.144 +
   1.145 +/**
   1.146 + * Retrieves information about the currectly reserved camera device
   1.147 + *
   1.148 + * @see CCamera::CameraInfo()
   1.149 + */
   1.150 +void CMMCameraClientSession::CameraInfo(TCameraInfo& /*aInfo*/) const
   1.151 +	{ 
   1.152 +	return;
   1.153 +	}
   1.154 +
   1.155 +/**
   1.156 + * Reserves the camera
   1.157 + *
   1.158 + * @see CCamera::Reserve()
   1.159 + */
   1.160 +void CMMCameraClientSession::Reserve()
   1.161 +	{
   1.162 +	iCameraAccessHandler->Reserve();
   1.163 +	}
   1.164 +
   1.165 +/**
   1.166 + * Relinquishes control of the camera device
   1.167 + *
   1.168 + * @see CCamera::Release()
   1.169 + */
   1.170 +void CMMCameraClientSession::Release()
   1.171 +	{
   1.172 +	iCameraSession.SendMessage(ECamCameraAccessControl, ECameraRelease);
   1.173 +	iPoweredUp = EFalse;
   1.174 +	}
   1.175 +
   1.176 +/**
   1.177 + * Powers on the camera device
   1.178 + *
   1.179 + * @see CCamera::PowerOn()
   1.180 + */
   1.181 +void CMMCameraClientSession::PowerOn()
   1.182 +	{
   1.183 +	iCameraPowerHandler->PowerOn();
   1.184 +	}
   1.185 +
   1.186 +/**
   1.187 + * Powers down the camera device
   1.188 + *
   1.189 + * @see CCamera::PowerOff()
   1.190 + */
   1.191 +void CMMCameraClientSession::PowerOff()
   1.192 +	{	
   1.193 +	iCameraSession.SendMessage(ECamPowerCamera, ECameraPowerOff);
   1.194 +	iPoweredUp = EFalse;
   1.195 +	}
   1.196 +
   1.197 +/**
   1.198 + * Retrieves the handle of the currently reserved camera
   1.199 + *
   1.200 + * @see CCamera::Handle()
   1.201 + */
   1.202 +TInt CMMCameraClientSession::Handle()
   1.203 +	{
   1.204 +	TCameraHandle handle;
   1.205 +	TCameraHandlePckg pckg(handle);
   1.206 +
   1.207 +	iCameraSession.SendRxMessage(ECamCameraHandle, pckg);
   1.208 +
   1.209 +	handle = pckg();
   1.210 +	return handle.iHandle;
   1.211 +	}
   1.212 +
   1.213 +/**
   1.214 + * Sets the optical zoom level
   1.215 + *
   1.216 + * @see CCamera::SetZoomFactorL()
   1.217 + */
   1.218 +void CMMCameraClientSession::SetZoomFactorL(TInt aZoomFactor)
   1.219 +	{
   1.220 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EZoomFactor, aZoomFactor));
   1.221 +	}
   1.222 +
   1.223 +/**
   1.224 + *  Retrieves current optical zoom level
   1.225 + *
   1.226 + * @see CCamera::ZoomFactor()
   1.227 + */
   1.228 +TInt CMMCameraClientSession::ZoomFactor() const
   1.229 +	{
   1.230 +	TCameraZoom zoomFactor;
   1.231 +	TCameraZoomPckg pckg(zoomFactor);
   1.232 +	iCameraSession.SendRxMessage(ECamGetParameter, EZoomFactor, pckg);
   1.233 +	zoomFactor = pckg();
   1.234 +	return zoomFactor.iZoom;
   1.235 +	}
   1.236 +
   1.237 +/**
   1.238 + * Sets the digital zoom level
   1.239 + *
   1.240 + * @see CCamera::SetDigitalZoomFactorL()
   1.241 + */
   1.242 +void CMMCameraClientSession::SetDigitalZoomFactorL(TInt aDigitalZoomFactor)
   1.243 +	{
   1.244 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EDigitalZoomFactor, aDigitalZoomFactor));
   1.245 +	}
   1.246 +
   1.247 +/**
   1.248 + * Retrieves the current digital zoom level
   1.249 + *
   1.250 + * @see CCamera::DigitalZoomFactor()
   1.251 + */
   1.252 +TInt CMMCameraClientSession::DigitalZoomFactor() const
   1.253 +	{
   1.254 +	TCameraDigitalZoom digitalZoomFactor;
   1.255 +	TCameraDigitalZoomPckg pckg(digitalZoomFactor);
   1.256 +	iCameraSession.SendRxMessage(ECamGetParameter, EDigitalZoomFactor, pckg);
   1.257 +	digitalZoomFactor = pckg();
   1.258 +	return digitalZoomFactor.iDigitalZoom;
   1.259 +	}
   1.260 +
   1.261 +/**
   1.262 + * Sets the contrast level
   1.263 + *
   1.264 + * @see CCamera::SetContrastL()
   1.265 + */
   1.266 +void CMMCameraClientSession::SetContrastL(TInt aContrast)
   1.267 +	{
   1.268 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EContrast, aContrast));
   1.269 +	}
   1.270 +
   1.271 +/**
   1.272 + * Retrieves the current contrast level
   1.273 + *
   1.274 + * @see CCamera::Contrast()
   1.275 + */
   1.276 +TInt CMMCameraClientSession::Contrast() const
   1.277 +	{
   1.278 +	TCameraContrast contrast;
   1.279 +	TCameraContrastPckg pckg(contrast);
   1.280 +	iCameraSession.SendRxMessage(ECamGetParameter, EContrast, pckg);
   1.281 +	contrast = pckg();
   1.282 +	return contrast.iContrast;
   1.283 +	}
   1.284 +
   1.285 +/**
   1.286 + * Sets the brightness level
   1.287 + *
   1.288 + * @see CCamera::SetBrightnessL()
   1.289 + */
   1.290 +void CMMCameraClientSession::SetBrightnessL(TInt aBrightness)
   1.291 +	{
   1.292 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EBrightness, aBrightness));
   1.293 +	}
   1.294 +
   1.295 +/**
   1.296 + * Retrieves the current brightness level
   1.297 + *
   1.298 + * @see CCamera::Brigthness()
   1.299 + */
   1.300 +TInt CMMCameraClientSession::Brightness() const
   1.301 +	{
   1.302 +	TCameraBrightness brightness;
   1.303 +	TCameraBrightnessPckg pckg(brightness);
   1.304 +	iCameraSession.SendRxMessage(ECamGetParameter, EBrightness, pckg);
   1.305 +	brightness = pckg();
   1.306 +	return brightness.iBrightness;
   1.307 +	}
   1.308 +
   1.309 +/**
   1.310 + * Sets the flash level
   1.311 + *
   1.312 + * @see CCamera::SetFlashL()
   1.313 + */
   1.314 +void CMMCameraClientSession::SetFlashL(TFlash aFlash)
   1.315 +	{
   1.316 +	TCameraFlash flash;
   1.317 +	flash.iFlash = aFlash;
   1.318 +	TCameraFlashPckg pckg(flash);
   1.319 +
   1.320 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EFlash, pckg));
   1.321 +	}
   1.322 +
   1.323 +/**
   1.324 + * Retrieves the current flash level
   1.325 + *
   1.326 + * @see CCamera::Flash()
   1.327 + */
   1.328 +CCamera::TFlash CMMCameraClientSession::Flash() const
   1.329 +	{
   1.330 +	TCameraFlash flash;
   1.331 +	TCameraFlashPckg pckg(flash);
   1.332 +	
   1.333 +	iCameraSession.SendRxMessage(ECamGetParameter, EFlash, pckg);
   1.334 +	flash = pckg();
   1.335 +	return flash.iFlash;
   1.336 +	}
   1.337 +
   1.338 +/**
   1.339 + * Sets the exposure level
   1.340 + *
   1.341 + * @see CCamera::SetExposureL()
   1.342 + */
   1.343 +void CMMCameraClientSession::SetExposureL(TExposure aExposure)
   1.344 +	{
   1.345 +	TCameraExposure exposure;
   1.346 +	exposure.iExposure = aExposure;
   1.347 +	TCameraExposurePckg pckg(exposure);
   1.348 +
   1.349 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EExposure, pckg));
   1.350 +	}
   1.351 +
   1.352 +/**
   1.353 + * Retrieves the current exposure level
   1.354 + *
   1.355 + * @see CCamera::Exposure()
   1.356 + */
   1.357 +CCamera::TExposure CMMCameraClientSession::Exposure() const
   1.358 +	{
   1.359 +	TCameraExposure exposure;
   1.360 +	TCameraExposurePckg pckg(exposure);
   1.361 +	
   1.362 +	iCameraSession.SendRxMessage(ECamGetParameter, EExposure, pckg);
   1.363 +	exposure = pckg();
   1.364 +	return exposure.iExposure;
   1.365 +	}
   1.366 +
   1.367 +/**
   1.368 + * Sets the white balance level
   1.369 + *
   1.370 + * @see CCamera::SetWhiteBalance()
   1.371 + */
   1.372 +void CMMCameraClientSession::SetWhiteBalanceL(TWhiteBalance aWhiteBalance)
   1.373 +	{
   1.374 +	TCameraWhiteBalance whiteBalance;
   1.375 +	whiteBalance.iWhiteBalance = aWhiteBalance;
   1.376 +	TCameraWhiteBalancePckg pckg(whiteBalance);
   1.377 +
   1.378 +	User::LeaveIfError(iCameraSession.SendMessage(ECamSetParameter, EWhiteBalance, pckg));
   1.379 +	}
   1.380 +
   1.381 +/**
   1.382 + * Retrieves the current white balance level
   1.383 + *
   1.384 + * @see CCamera::WhiteBalance()
   1.385 + */
   1.386 +CCamera::TWhiteBalance CMMCameraClientSession::WhiteBalance() const
   1.387 +	{
   1.388 +	TCameraWhiteBalance whiteBalance;
   1.389 +	TCameraWhiteBalancePckg pckg(whiteBalance);
   1.390 +	
   1.391 +	iCameraSession.SendRxMessage(ECamGetParameter, EWhiteBalance, pckg);
   1.392 +	whiteBalance = pckg();
   1.393 +	return whiteBalance.iWhiteBalance;	
   1.394 +	}
   1.395 +
   1.396 +/**
   1.397 + * Starts client direct viewfinder.
   1.398 + * Not supported in this implementation.
   1.399 + * 
   1.400 + * @see CCamera::StartViewFinderDirectL()
   1.401 + */
   1.402 +void CMMCameraClientSession::StartViewFinderDirectL(RWsSession& /*aWs*/, CWsScreenDevice& /*aScreenDevice*/, RWindowBase& /*aWindow*/, TRect& /*aScreenRect*/)
   1.403 +	{
   1.404 +	User::Leave(KErrNotSupported);	
   1.405 +	}
   1.406 +
   1.407 +/**
   1.408 + * Starts client direct viewfinder.
   1.409 + * Not supported in this implementation.
   1.410 + * 
   1.411 + * @see CCamera::StartViewFinderDirectL()
   1.412 + */
   1.413 +void CMMCameraClientSession::StartViewFinderDirectL(RWsSession& /*aWs*/, CWsScreenDevice& /*aScreenDevice*/, RWindowBase& /*aWindow*/, TRect& /*aScreenRect*/, TRect& /*aClipRect*/)
   1.414 +	{
   1.415 +	User::Leave(KErrNotSupported);
   1.416 +	}
   1.417 +
   1.418 +/**
   1.419 + * Starts client viewfinder.
   1.420 + * Not supported in this implementation.
   1.421 + * 
   1.422 + * @see CCamera::StartViewFinderBitmapsL()
   1.423 + */
   1.424 +void CMMCameraClientSession::StartViewFinderBitmapsL(TSize& /*aSize*/)
   1.425 +	{
   1.426 +	User::Leave(KErrNotSupported);
   1.427 +	}
   1.428 +
   1.429 +/**
   1.430 + * Starts client viewfinder.
   1.431 + * Not supported in this implementation.
   1.432 + * 
   1.433 + * @see CCamera::StartViewFinderBitmapsL()
   1.434 + */
   1.435 +void CMMCameraClientSession::StartViewFinderBitmapsL(TSize& /*aSize*/, TRect& /*aClipRect*/)
   1.436 +	{
   1.437 +	User::Leave(KErrNotSupported);	
   1.438 +	}
   1.439 +
   1.440 +/**
   1.441 + * Starts client viewfinder.
   1.442 + * Not supported in this implementation.
   1.443 + * 
   1.444 + * @see CCamera::StartViewFinderL()
   1.445 + */
   1.446 +void CMMCameraClientSession::StartViewFinderL(CCamera::TFormat /*aImageFormat*/, TSize& /*aSize*/)
   1.447 +	{
   1.448 +	User::Leave(KErrNotSupported);
   1.449 +	}
   1.450 +
   1.451 +/**
   1.452 + * Starts client viewfinder.
   1.453 + * Not supported in this implementation.
   1.454 + * 
   1.455 + * @see CCamera::StartViewFinderL()
   1.456 + */
   1.457 +void CMMCameraClientSession::StartViewFinderL(CCamera::TFormat /*aImageFormat*/, TSize& /*aSize*/, TRect& /*aClipRect*/)
   1.458 +	{
   1.459 +	User::Leave(KErrNotSupported);	
   1.460 +	}
   1.461 +
   1.462 +/**
   1.463 + * Stops client viewfinder.
   1.464 + * Not supported in this implementation.
   1.465 + * 
   1.466 + * @see CCamera::StopViewFinder()
   1.467 + */
   1.468 +void CMMCameraClientSession::StopViewFinder()
   1.469 +	{
   1.470 +	return;
   1.471 +	}
   1.472 +
   1.473 +/**
   1.474 + * Queries if viewfinder is active.
   1.475 + * Not supported in this implementation.
   1.476 + * 
   1.477 + * @see CCamera::ViewFinderActive()
   1.478 + */
   1.479 +TBool CMMCameraClientSession::ViewFinderActive() const
   1.480 +	{
   1.481 +	return EFalse;
   1.482 +	}
   1.483 +
   1.484 +/**
   1.485 + * Turns on/off viewfinder mirrorring.
   1.486 + * Not supported in this implementation.
   1.487 + * 
   1.488 + * @see CCamera::SetViewFinderMirrorL()
   1.489 + */
   1.490 +void CMMCameraClientSession::SetViewFinderMirrorL(TBool /*aMirror*/)
   1.491 +	{
   1.492 +	User::Leave(KErrNotSupported);
   1.493 +	}
   1.494 +
   1.495 +/**
   1.496 + * Queries whether viewfinder mirrorring is on or off.
   1.497 + * Not supported in this implementation.
   1.498 + * 
   1.499 + * @see CCamera::ViewFinderMirrorL()
   1.500 + */
   1.501 +TBool CMMCameraClientSession::ViewFinderMirror() const
   1.502 +	{
   1.503 +	return EFalse;
   1.504 +	}
   1.505 +
   1.506 +/**
   1.507 + * Prepares image capture.
   1.508 + * 
   1.509 + * @see CCamera::PrepareImageCapture()
   1.510 + */
   1.511 +void CMMCameraClientSession::PrepareImageCaptureL(CCamera::TFormat /*aImageFormat*/, TInt /*aSizeIndex*/)
   1.512 +	{
   1.513 +	User::Leave(KErrNotSupported);
   1.514 +	}
   1.515 +
   1.516 +/**
   1.517 + * Prepares image capture.
   1.518 + * 
   1.519 + * @see CCamera::PrepareImageCapture()
   1.520 + */
   1.521 +void CMMCameraClientSession::PrepareImageCaptureL(CCamera::TFormat /*aImageFormat*/, TInt /*aSizeIndex*/, const TRect& /*aClipRect*/)
   1.522 +	{
   1.523 +	User::Leave(KErrNotSupported);
   1.524 +	}
   1.525 +
   1.526 +/**
   1.527 + * Captures image.
   1.528 + * 
   1.529 + * @see CCamera::CaptureImage()
   1.530 + */
   1.531 +void CMMCameraClientSession::CaptureImage()
   1.532 +	{
   1.533 +	return;
   1.534 +	}
   1.535 +
   1.536 +/**
   1.537 + * Cancels any ongoing image capture.
   1.538 + * 
   1.539 + * @see CCamera::CaptureImage()
   1.540 + */
   1.541 +void CMMCameraClientSession::CancelCaptureImage()
   1.542 +	{
   1.543 +	return;
   1.544 +	}
   1.545 +
   1.546 +/**
   1.547 + * Enumerates image capture sizes.
   1.548 + * 
   1.549 + * @see CCamera::EnumerateCaptureSizes()
   1.550 + */
   1.551 +void CMMCameraClientSession::EnumerateCaptureSizes(TSize& /*aSize*/, TInt /*aSizeIndex*/, CCamera::TFormat /*aFormat*/) const
   1.552 +	{
   1.553 +	return;
   1.554 +	}
   1.555 +
   1.556 +/**
   1.557 + * Prepares video capture.
   1.558 + * 
   1.559 + * @see CCamera::PrepareVideoCaptureL()
   1.560 + */
   1.561 +void CMMCameraClientSession::PrepareVideoCaptureL(CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TInt /*aRateIndex*/, TInt /*aBuffersToUse*/, TInt /*aFramesPerBuffer*/)
   1.562 +	{
   1.563 +	User::Leave(KErrNotSupported);
   1.564 +	}
   1.565 +
   1.566 +/**
   1.567 + * Prepares video capture.
   1.568 + * 
   1.569 + * @see CCamera::PrepareVideoCaptureL()
   1.570 + */
   1.571 +void CMMCameraClientSession::PrepareVideoCaptureL(CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TInt /*aRateIndex*/, TInt /*aBuffersToUse*/, TInt /*aFramesPerBuffer*/, const TRect& /*aClipRect*/)
   1.572 +	{
   1.573 +	User::Leave(KErrNotSupported);
   1.574 +	}
   1.575 +
   1.576 +/**
   1.577 + * Starts video capture.
   1.578 + * 
   1.579 + * @see CCamera::StartVideoCapture()
   1.580 + */
   1.581 +void CMMCameraClientSession::StartVideoCapture()
   1.582 +	{
   1.583 +	return;
   1.584 +	}
   1.585 +
   1.586 +/**
   1.587 + * Stops video capture.
   1.588 + * 
   1.589 + * @see CCamera::StopVideoCapture()
   1.590 + */
   1.591 +void CMMCameraClientSession::StopVideoCapture()
   1.592 +	{
   1.593 +	return;
   1.594 +	}
   1.595 +
   1.596 +/**
   1.597 + * Queries whether video capture is active.
   1.598 + * 
   1.599 + * @see CCamera::VideoCaptureActive()
   1.600 + */
   1.601 +TBool CMMCameraClientSession::VideoCaptureActive() const
   1.602 +	{
   1.603 +	return EFalse;	
   1.604 +	}
   1.605 +
   1.606 +/**
   1.607 + * Enumerates video frame sizes.
   1.608 + * 
   1.609 + * @see CCamera::EnumerateVideoFrameSizes()
   1.610 + */
   1.611 +void CMMCameraClientSession::EnumerateVideoFrameSizes(TSize& /*aSize*/, TInt /*aSizeIndex*/, CCamera::TFormat /*aFormat*/) const
   1.612 +	{
   1.613 +	return;
   1.614 +	}
   1.615 +
   1.616 +/**
   1.617 + * Enumerates video frame rates.
   1.618 + * 
   1.619 + * @see CCamera::EnumerateVideoFrameRates()
   1.620 + */
   1.621 +void CMMCameraClientSession::EnumerateVideoFrameRates(TReal32& /*aRate*/, TInt /*aRateIndex*/, CCamera::TFormat /*aFormat*/, TInt /*aSizeIndex*/, TExposure /*aExposure*/) const
   1.622 +	{
   1.623 +	return;
   1.624 +	}
   1.625 +
   1.626 +/**
   1.627 + * Retrieve the frame size.
   1.628 + * 
   1.629 + * @see CCamera::GetFrameSize()
   1.630 + */
   1.631 +void CMMCameraClientSession::GetFrameSize(TSize& /*aSize*/) const
   1.632 +	{
   1.633 +	return;	
   1.634 +	}
   1.635 +
   1.636 +/**
   1.637 + * Retrieve the frame rate.
   1.638 + * 
   1.639 + * @see CCamera::FrameRate()
   1.640 + */
   1.641 +TReal32 CMMCameraClientSession::FrameRate() const
   1.642 +	{
   1.643 +	return static_cast<TReal32>(0);
   1.644 +	}
   1.645 +
   1.646 +/**
   1.647 + * Retrieve the number of buffers currently in use.
   1.648 + * 
   1.649 + * @see CCamera::BuffersInUse()
   1.650 + */
   1.651 +TInt CMMCameraClientSession::BuffersInUse() const
   1.652 +	{
   1.653 +	return 0;
   1.654 +	}
   1.655 +
   1.656 +/**
   1.657 + * Retrieve the number of frames per buffer.
   1.658 + * 
   1.659 + * @see CCamera::FramesPerBuffer()
   1.660 + */
   1.661 +TInt CMMCameraClientSession::FramesPerBuffer() const
   1.662 +	{
   1.663 +	return 0;	
   1.664 +	}
   1.665 +
   1.666 +/**
   1.667 + * Set the Jpeg quality.
   1.668 + * 
   1.669 + * @see CCamera::SetJpegQuality()
   1.670 + */
   1.671 +void CMMCameraClientSession::SetJpegQuality(TInt /*aQuality*/)
   1.672 +	{
   1.673 +	return;
   1.674 +	}
   1.675 +
   1.676 +/**
   1.677 + * Retrieve the Jpeg quality.
   1.678 + * 
   1.679 + * @see CCamera::JpegQuality()
   1.680 + */
   1.681 +TInt CMMCameraClientSession::JpegQuality() const
   1.682 +	{
   1.683 +	return 0;	
   1.684 +	}
   1.685 +
   1.686 +/**
   1.687 + * Retrieves a custom interface based on the id passed in by the client.
   1.688 + * 
   1.689 + * @see CCamera::CustomInterface()
   1.690 + */
   1.691 +TAny* CMMCameraClientSession::CustomInterface(TUid aInterface)
   1.692 +	{
   1.693 +	switch (aInterface.iUid)
   1.694 +		{
   1.695 +		// The framework retrieves KECamMCameraV2DirectViewFinderUidValue followed by KECamMCameraBaseV2DirectViewFinderUidValue
   1.696 +		// We take care to initialise iDirectViewFinder in the first case and use it in the subsequent call
   1.697 +		case KECamMCameraV2DirectViewFinderUidValue:
   1.698 +			{
   1.699 +			ASSERT(!iDirectViewFinder);
   1.700 +			TRAPD(err, iDirectViewFinder = CMMDirectViewFinder::NewL(*this));
   1.701 +			if (err != KErrNone)
   1.702 +				{
   1.703 +				return NULL;
   1.704 +				}
   1.705 +
   1.706 +			return static_cast<MCameraV2DirectViewFinder*>(iDirectViewFinder);
   1.707 +	        }
   1.708 +
   1.709 +		case KECamMCameraBaseV2DirectViewFinderUidValue:
   1.710 +			{
   1.711 +			ASSERT(iDirectViewFinder);
   1.712 +			iVF = static_cast<MCameraViewFinder*>(iDirectViewFinder);
   1.713 +			//delete iDirectViewFinder;
   1.714 +			iDirectViewFinder = NULL;
   1.715 +			return iVF;
   1.716 +	        }
   1.717 +
   1.718 +		default:
   1.719 +			{
   1.720 +			return NULL;
   1.721 +			}
   1.722 +		}
   1.723 +	}
   1.724 +
   1.725 +//
   1.726 +// From CCameraInfoPlugin
   1.727 +//
   1.728 +CMMCameraClientSessionInfo* CMMCameraClientSessionInfo::NewL()
   1.729 +	{
   1.730 +	FileDependencyUtil::CheckFileDependencyL();
   1.731 +	return new (ELeave) CMMCameraClientSessionInfo;
   1.732 +	}
   1.733 +
   1.734 +CMMCameraClientSessionInfo::~CMMCameraClientSessionInfo()
   1.735 +	{
   1.736 +	}
   1.737 +
   1.738 +/**
   1.739 + * Retrieves the number of cameras available.
   1.740 + * 
   1.741 + * @see CCameraInfoPlugin::CamerasAvailable()
   1.742 + */
   1.743 +TInt CMMCameraClientSessionInfo::CamerasAvailable()
   1.744 +	{
   1.745 +	// One-off connection to the server
   1.746 +	RMMCameraSession cameraSession;
   1.747 +	TInt error = cameraSession.Connect();
   1.748 +	if (error != KErrNone)
   1.749 +		{
   1.750 +		return 0;
   1.751 +		}
   1.752 +
   1.753 +	TCamerasAvailable info;
   1.754 +	TCamerasAvailablePckg pckg(info);
   1.755 +
   1.756 +	error = cameraSession.SendMessage(ECamQueryCamerasAvailable, pckg);
   1.757 +	cameraSession.Close();
   1.758 +	if (error != KErrNone)
   1.759 +		{
   1.760 +		return 0;
   1.761 +		}
   1.762 +
   1.763 +	info = pckg();
   1.764 +	return info.iCameraCount;
   1.765 +	}
   1.766 +
   1.767 +CMMCameraClientSessionInfo::CMMCameraClientSessionInfo()
   1.768 +	{
   1.769 +	}
   1.770 +
   1.771 +
   1.772 +
   1.773 +void FileDependencyUtil::CheckFileDependencyL()
   1.774 +	{	
   1.775 +	RFs fsSession;
   1.776 +  	RFile file;
   1.777 +    CleanupClosePushL(fsSession);
   1.778 +  	User::LeaveIfError(fsSession.Connect());
   1.779 +    TInt err = file.Open(fsSession, KMMCameraPluginName, EFileRead);
   1.780 +  	file.Close();
   1.781 +  	if(err != KErrNone)
   1.782 +  		{
   1.783 +	    User::LeaveIfError(KErrNotSupported);
   1.784 +  		}
   1.785 +  	CleanupStack::PopAndDestroy(&fsSession);
   1.786 +	}
   1.787 +
   1.788 +
   1.789 +//
   1.790 +// CLASS CMMCameraAccessHandler
   1.791 +//
   1.792 +
   1.793 +CMMCameraAccessHandler::CMMCameraAccessHandler(CMMCameraClientSession* aPlugin, TInt aPriority): CActive(aPriority), 
   1.794 +																					   iPlugin(aPlugin)
   1.795 +	{
   1.796 +	}
   1.797 +
   1.798 +CMMCameraAccessHandler* CMMCameraAccessHandler::NewL(CMMCameraClientSession* aPlugin, TInt aPriority)
   1.799 +	{
   1.800 +	CMMCameraAccessHandler* self = new (ELeave) CMMCameraAccessHandler(aPlugin, aPriority);
   1.801 +	CActiveScheduler::Add(self);
   1.802 +	return self;
   1.803 +	}
   1.804 +
   1.805 +CMMCameraAccessHandler::~CMMCameraAccessHandler()
   1.806 +	{
   1.807 +	Cancel();
   1.808 +	}
   1.809 +
   1.810 +void CMMCameraAccessHandler::Reserve()
   1.811 +	{
   1.812 +	if(!IsActive())
   1.813 +		{
   1.814 +		// Reserve the camera
   1.815 +		iPlugin->iCameraSession.ReceiveMessage(ECamCameraAccessControl, ECameraReservedNotification, iStatus);
   1.816 +		SetActive();
   1.817 +		}
   1.818 +	else
   1.819 +		{
   1.820 +		// Reserve has been called again before first call has completed so notify the client
   1.821 +		TECAMEvent ecamEvent(KUidECamEventReserveComplete, KErrInUse);
   1.822 +		iPlugin->iCameraObserver2->HandleEvent(ecamEvent);
   1.823 +		}
   1.824 +	}
   1.825 +
   1.826 +void CMMCameraAccessHandler::RunL()
   1.827 +	{ 
   1.828 +	TInt ret = iStatus.Int();
   1.829 +
   1.830 +	if(!iPlugin->iReserved)
   1.831 +		{
   1.832 +		if(KErrNone == ret)
   1.833 +			{
   1.834 +			iPlugin->iReserved = ETrue;
   1.835 +			if(!IsActive())
   1.836 +				{
   1.837 +				// Continue monitoring for overthrow messages should a higher priority client reserve the same camera index
   1.838 +				iPlugin->iCameraSession.ReceiveMessage(ECamCameraAccessControl, ECameraOverthrowNotification, iStatus);
   1.839 +				SetActive();
   1.840 +				}
   1.841 +			}
   1.842 +
   1.843 +		// notify the client that reserve has completed, successfully or otherwise
   1.844 +		TECAMEvent ecamEvent(KUidECamEventReserveComplete, ret);	
   1.845 +		iPlugin->iCameraObserver2->HandleEvent(ecamEvent);
   1.846 +		}
   1.847 +	else
   1.848 +		{
   1.849 +		iPlugin->iReserved = EFalse;
   1.850 +
   1.851 +		if (ret == KErrNone)
   1.852 +			{
   1.853 +			// Client has been overthrown by a second client with higher priority
   1.854 +			TECAMEvent ecamEvent(KUidECamEventCameraNoLongerReserved, ret);
   1.855 +			iPlugin->iCameraObserver2->HandleEvent(ecamEvent);		
   1.856 +			}
   1.857 +		}
   1.858 +	}
   1.859 +
   1.860 +void CMMCameraAccessHandler::DoCancel()
   1.861 +	{
   1.862 +	if(!iPlugin->iReserved)
   1.863 +		{
   1.864 +		iPlugin->iCameraSession.SendMessage(ECamCameraAccessControl, ECameraCancelReservedNotification);
   1.865 +
   1.866 +		// Notify client that ongoing reserve request was cancelled
   1.867 +		TECAMEvent ecamEvent(KUidECamEventReserveComplete, KErrCancel);
   1.868 +		iPlugin->iCameraObserver2->HandleEvent(ecamEvent);
   1.869 +		}
   1.870 +	else
   1.871 +		{
   1.872 +		iPlugin->iCameraSession.SendMessage(ECamCameraAccessControl, ECameraCancelOverthrowNotification);
   1.873 +		iPlugin->iReserved = EFalse;
   1.874 +		}
   1.875 +	}
   1.876 +
   1.877 +
   1.878 +//
   1.879 +//
   1.880 +// CLASS CMMCameraPowerHandler
   1.881 +//
   1.882 +
   1.883 +CMMCameraPowerHandler::CMMCameraPowerHandler(CMMCameraClientSession* aPlugin, TInt aPriority): CActive(aPriority), 
   1.884 +																					 iPlugin(aPlugin)
   1.885 +	{
   1.886 +	}
   1.887 +
   1.888 +CMMCameraPowerHandler* CMMCameraPowerHandler::NewL(CMMCameraClientSession* aPlugin, TInt aPriority)
   1.889 +	{
   1.890 +	CMMCameraPowerHandler* self = new (ELeave) CMMCameraPowerHandler(aPlugin, aPriority);
   1.891 +	CActiveScheduler::Add(self);
   1.892 +	return self;
   1.893 +	}
   1.894 +
   1.895 +CMMCameraPowerHandler::~CMMCameraPowerHandler()
   1.896 +	{
   1.897 +	Cancel();
   1.898 +	}
   1.899 +
   1.900 +void CMMCameraPowerHandler::PowerOn()
   1.901 +	{ 
   1.902 +	if(!IsActive())
   1.903 +		{
   1.904 +		iPlugin->iCameraSession.ReceiveMessage(ECamPowerCamera, ECameraPowerOnNotification, iStatus);
   1.905 +		SetActive();
   1.906 +		}
   1.907 +	else
   1.908 +		{
   1.909 +		// PowerOn has been called again before first call has completed so notify the client
   1.910 +		TECAMEvent ecamEvent(KUidECamEventPowerOnComplete, KErrAlreadyExists);	
   1.911 +		iPlugin->iCameraObserver2->HandleEvent(ecamEvent);	
   1.912 +		}
   1.913 +	}
   1.914 +
   1.915 +void CMMCameraPowerHandler::RunL()
   1.916 +	{ 
   1.917 +	TInt ret = iStatus.Int();
   1.918 +
   1.919 +	if(!iPlugin->iPoweredUp)
   1.920 +		{
   1.921 +		if (ret == KErrNone)
   1.922 +			{
   1.923 +			iPlugin->iPoweredUp = ETrue;
   1.924 +			}
   1.925 +		}
   1.926 +
   1.927 +	TECAMEvent ecamEvent(KUidECamEventPowerOnComplete, ret);	
   1.928 +	iPlugin->iCameraObserver2->HandleEvent(ecamEvent);
   1.929 +	}
   1.930 +
   1.931 +void CMMCameraPowerHandler::DoCancel()
   1.932 +	{
   1.933 +	if(!iPlugin->iPoweredUp)
   1.934 +		{
   1.935 +		iPlugin->iCameraSession.SendMessage(ECamPowerCamera, ECameraCancelPowerOnNotification);
   1.936 +		} 
   1.937 +	}
   1.938 +
   1.939 +
   1.940 +// __________________________________________________________________________
   1.941 +// Exported proxy for instantiation method resolution
   1.942 +// Define the interface UIDs
   1.943 +const TImplementationProxy ImplementationTable[] = 
   1.944 +	{
   1.945 +	IMPLEMENTATION_PROXY_ENTRY(KUidMMCameraClientSession, CMMCameraClientSession::NewL),
   1.946 +	IMPLEMENTATION_PROXY_ENTRY(KUidMMCameraClientSessionInfo, CMMCameraClientSessionInfo::NewL)
   1.947 +	};
   1.948 +
   1.949 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   1.950 +	{
   1.951 +	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   1.952 +
   1.953 +	return ImplementationTable;
   1.954 +	}