246 return; |
248 return; |
247 } |
249 } |
248 |
250 |
249 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_IN, "msg: e_CX_STILLCAPCONT_PREPARE 1"); |
251 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_IN, "msg: e_CX_STILLCAPCONT_PREPARE 1"); |
250 |
252 |
251 int err = KErrNone; |
253 CxeError::Id status(CxeError::None); |
252 CxeError::Id cxErr = getImageQualityDetails(mCurrentImageDetails); |
254 |
253 int ecamStillResolutionIndex = 0; |
255 try { |
254 |
256 // Update capture parameters |
255 if (cxErr == CxeError::None) { |
257 updateStillCaptureParameters(); |
256 int imageWidth = mCurrentImageDetails.mWidth; |
|
257 int imageHeight = mCurrentImageDetails.mHeight; |
|
258 CX_DEBUG(("CxeStillCaptureControlSymbian::prepare <> resolution = (%d, %d)", imageWidth, imageHeight)); |
|
259 |
|
260 TSize imageSize; |
|
261 imageSize.SetSize(imageWidth, imageHeight); |
|
262 |
|
263 if (mECamSupportedImageResolutions.count() > 0) { |
|
264 ecamStillResolutionIndex = mECamSupportedImageResolutions.indexOf(imageSize); |
|
265 } |
|
266 |
|
267 if (ecamStillResolutionIndex < 0) { |
|
268 CX_DEBUG(("CxeStillCaptureControlSymbian::prepare - WARNING! resolution not supported, falling back to index 0")); |
|
269 ecamStillResolutionIndex = 0; |
|
270 } |
|
271 |
258 |
272 // Prepare Image capture |
259 // Prepare Image capture |
273 CCamera::TFormat imgFormat = supportedStillFormat(mCameraDeviceControl.cameraIndex()); |
260 CX_DEBUG(("Calling PrepareImageCaptureL, resolution index = %d", mSizeIndex)); |
274 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_MID1, "msg: e_CX_PREPARE_IMAGE_CAPTURE 1"); |
261 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_MID1, "msg: e_CX_PREPARE_IMAGE_CAPTURE 1"); |
275 TRAP(err, mCameraDevice.camera()->PrepareImageCaptureL(imgFormat, ecamStillResolutionIndex)); |
262 QT_TRAP_THROWING(mCameraDevice.camera()->PrepareImageCaptureL(mCaptureFormat, mSizeIndex)); |
276 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_MID2, "msg: e_CX_PREPARE_IMAGE_CAPTURE 0"); |
263 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_MID2, "msg: e_CX_PREPARE_IMAGE_CAPTURE 0"); |
277 |
264 |
278 CX_DEBUG(("PrepareImageCaptureL done, err=%d, resolution index = %d", err, ecamStillResolutionIndex)); |
|
279 |
|
280 if (!err) { |
|
281 // still capture prepare went fine, try preparing snapshot |
|
282 err = prepareStillSnapshot(); |
|
283 } |
|
284 } else { |
|
285 err = KErrNotFound; |
|
286 } |
|
287 |
|
288 if (!err) { |
|
289 // Start viewfinder before claiming to be ready, |
265 // Start viewfinder before claiming to be ready, |
290 // as e.g. pending capture might be started by state change, |
266 // as e.g. pending capture might be started by state change, |
291 // and viewfinder start might have problems with just started capturing. |
267 // and viewfinder start might have problems with just started capturing. |
292 // If viewfinder is already running, this call does nothing. |
268 // If viewfinder is already running, this call does nothing. |
293 mViewfinderControl.start(); |
269 mViewfinderControl.start(); |
294 |
270 |
|
271 // Prepare snapshot |
|
272 prepareSnapshot(); |
|
273 |
295 // Start monitoring disk space. |
274 // Start monitoring disk space. |
296 mDiskMonitor.start(); |
275 mDiskMonitor.start(); |
297 connect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged())); |
276 connect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged())); |
298 |
|
299 |
277 |
300 // Enable AF reticule drawing by adaptation |
278 // Enable AF reticule drawing by adaptation |
301 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
279 MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking(); |
302 if (faceTracking) { |
280 if (faceTracking) { |
303 TRAP_IGNORE(faceTracking->EnableFaceIndicatorsL(ETrue)); |
281 TRAP_IGNORE(faceTracking->EnableFaceIndicatorsL(ETrue)); |
306 // Still capture and still snapshot are OK. |
284 // Still capture and still snapshot are OK. |
307 // We can safely set state to READY. |
285 // We can safely set state to READY. |
308 setState(Ready); |
286 setState(Ready); |
309 |
287 |
310 // inform zoom control to prepare zoom |
288 // inform zoom control to prepare zoom |
311 emit prepareZoomForStill(ecamStillResolutionIndex); |
289 emit prepareZoomForStill(mSizeIndex); |
312 } else { |
290 |
313 CX_DEBUG(("Image Prepare FAILED! symbian error = %d", err)); |
291 } catch (const std::exception &e) { |
314 // release resources |
292 // Exception encountered, free resources. |
|
293 CX_DEBUG(("Image Prepare FAILED! symbian error = %d", qt_symbian_exception2Error(e))); |
|
294 status = CxeErrorHandlingSymbian::map(qt_symbian_exception2Error(e)); |
315 deinit(); |
295 deinit(); |
316 } |
296 } |
317 |
297 |
318 // Inform interested parties that image mode has been prepared for capture |
298 // Inform interested parties that image mode has been prepared for capture |
319 emit imagePrepareComplete(CxeErrorHandlingSymbian::map(err)); |
299 emit imagePrepareComplete(status); |
320 |
300 |
321 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 0"); |
301 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 0"); |
322 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_OUT, "msg: e_CX_STILLCAPCONT_PREPARE 0"); |
302 OstTrace0(camerax_performance, CXESTILLCAPTURECONTROL_PREPARE_OUT, "msg: e_CX_STILLCAPCONT_PREPARE 0"); |
323 |
|
324 CX_DEBUG_EXIT_FUNCTION(); |
303 CX_DEBUG_EXIT_FUNCTION(); |
325 } |
304 } |
326 |
305 |
327 |
306 |
328 |
307 |
329 /*! |
308 /*! |
330 Prepare still snapshot |
309 Prepare still snapshot |
331 Returns symbian error code. |
310 Throws exception on error. |
332 */ |
311 */ |
333 int CxeStillCaptureControlSymbian::prepareStillSnapshot() |
312 void CxeStillCaptureControlSymbian::prepareSnapshot() |
334 { |
313 { |
335 CX_DEBUG_ENTER_FUNCTION(); |
314 CX_DEBUG_ENTER_FUNCTION(); |
336 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_PREPARESNAP_1, "msg: e_CX_PREPARE_SNAPSHOT 1" ); |
315 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_PREPARESNAP_1, "msg: e_CX_PREPARE_SNAPSHOT 1" ); |
337 |
316 |
338 int status(KErrNone); |
317 QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( |
339 try { |
318 mViewfinderControl.deviceDisplayResolution(), |
340 QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( |
319 mCurrentImageDetails.mAspectRatio); |
341 mViewfinderControl.deviceDisplayResolution(), |
320 mSnapshotControl.start(snapshotSize); |
342 mCurrentImageDetails.mAspectRatio); |
321 |
343 mSnapshotControl.start(snapshotSize); |
|
344 } catch (...) { |
|
345 status = KErrGeneral; |
|
346 } |
|
347 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_PREPARESNAP_2, "msg: e_CX_PREPARE_SNAPSHOT 0" ); |
322 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_PREPARESNAP_2, "msg: e_CX_PREPARE_SNAPSHOT 0" ); |
348 |
323 CX_DEBUG_EXIT_FUNCTION(); |
349 CX_DEBUG_EXIT_FUNCTION(); |
324 } |
350 return status; |
325 |
351 } |
326 |
352 |
327 /*! |
353 |
328 Update image capture parameters. mCurrentImageDetails, mCaptureFormat and |
354 /*! |
329 mSizeIndex are updated based on the current settings. |
355 imageInfo contains image qualities details |
330 */ |
356 Returns CxeError error code. |
331 void CxeStillCaptureControlSymbian::updateStillCaptureParameters() |
357 */ |
332 { |
358 CxeError::Id CxeStillCaptureControlSymbian::getImageQualityDetails(CxeImageDetails &imageInfo) |
333 CX_DEBUG_ENTER_FUNCTION(); |
359 { |
334 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_UPDATESTILLCAPTUREPARAMETERS_1, "msg: e_CX_UPDATE_STILL_CAPTURE_PARAMETERS 1" ); |
360 CX_DEBUG_ENTER_FUNCTION(); |
|
361 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_GETQUALITYDETAILS_1, "msg: e_CX_GET_QUALITY_DETAILS 1" ); |
|
362 |
335 |
363 int imageQuality = 0; |
336 int imageQuality = 0; |
364 CxeError::Id err = CxeError::None; |
337 CxeError::Id err = CxeError::None; |
365 if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { |
338 if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { |
366 err = mSettings.get(CxeSettingIds::IMAGE_QUALITY, imageQuality); |
339 try { |
367 |
340 imageQuality = mSettings.get<int>(CxeSettingIds::IMAGE_QUALITY); |
368 bool validQuality = (imageQuality >= 0 && imageQuality < mIcmSupportedImageResolutions.count()); |
341 |
369 |
342 bool validQuality = (imageQuality >= 0 && |
370 if (err == CxeError::None && validQuality ) { |
343 imageQuality < mIcmSupportedImageResolutions.count()); |
371 // get image quality details |
344 |
372 imageInfo = mIcmSupportedImageResolutions.at(imageQuality); |
345 if (validQuality ) { |
373 } else { |
346 // get image quality details |
374 err = CxeError::NotFound; |
347 mCurrentImageDetails = mIcmSupportedImageResolutions.at(imageQuality); |
375 CX_DEBUG(("Invalid ImageQuality = %d", imageQuality)); |
348 } else { |
|
349 err = CxeError::NotFound; |
|
350 CX_DEBUG(("Invalid ImageQuality = %d", imageQuality)); |
|
351 } |
|
352 } catch (CxeException &e) { |
|
353 err = (CxeError::Id) e.error(); |
376 } |
354 } |
377 } else { |
355 } else { |
378 // we are in secondary camera |
356 // we are in secondary camera |
379 // get secondary camera image quality details |
357 // get secondary camera image quality details |
380 imageInfo = mIcmSupportedImageResolutions.at(imageQuality); |
358 mCurrentImageDetails = mIcmSupportedImageResolutions.at(imageQuality); |
381 } |
359 } |
382 |
360 |
383 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_GETQUALITYDETAILS_2, "msg: e_CX_GET_QUALITY_DETAILS 0" ); |
361 mSizeIndex = 0; |
384 CX_DEBUG_EXIT_FUNCTION(); |
362 |
385 return err; |
363 if (err == CxeError::None) { |
|
364 int imageWidth = mCurrentImageDetails.mWidth; |
|
365 int imageHeight = mCurrentImageDetails.mHeight; |
|
366 CX_DEBUG(("CxeStillCaptureControlSymbian::updateStillCaptureParameters <> resolution = (%d, %d)", imageWidth, imageHeight)); |
|
367 |
|
368 TSize imageSize; |
|
369 imageSize.SetSize(imageWidth, imageHeight); |
|
370 |
|
371 if (mECamSupportedImageResolutions.count() > 0) { |
|
372 mSizeIndex = mECamSupportedImageResolutions.indexOf(imageSize); |
|
373 } |
|
374 |
|
375 if (mSizeIndex < 0) { |
|
376 CX_DEBUG(("CxeStillCaptureControlSymbian::updateStillCaptureParameters - WARNING! resolution not supported, falling back to index 0")); |
|
377 mSizeIndex = 0; |
|
378 } |
|
379 |
|
380 mCaptureFormat = supportedStillFormat(mCameraDeviceControl.cameraIndex()); |
|
381 } |
|
382 |
|
383 OstTrace0( camerax_performance, CXESTILLCAPTURECONTROL_UPDATESTILLCAPTUREPARAMETERS_2, "msg: e_CX_UPDATE_STILL_CAPTURE_PARAMETERS 0" ); |
|
384 CX_DEBUG_EXIT_FUNCTION(); |
386 } |
385 } |
387 |
386 |
388 /*! |
387 /*! |
389 * Command to start image capture now. |
388 * Command to start image capture now. |
390 * @sa handleCameraEvent |
389 * @sa handleCameraEvent |