29 #include "cxezoomcontrolsymbian.h" |
29 #include "cxezoomcontrolsymbian.h" |
30 #include "cxequalitypresetssymbian.h" |
30 #include "cxequalitypresetssymbian.h" |
31 #include "cxutils.h" |
31 #include "cxutils.h" |
32 #include "cxesettingsimp.h" |
32 #include "cxesettingsimp.h" |
33 #include "cxefeaturemanagerimp.h" |
33 #include "cxefeaturemanagerimp.h" |
34 #include "cxesettingsmodelimp.h" |
|
35 #include "cxesettingscenrepstore.h" |
34 #include "cxesettingscenrepstore.h" |
36 #include "cxesoundplayersymbian.h" |
35 #include "cxesoundplayersymbian.h" |
37 #include "cxesensoreventhandlersymbian.h" |
36 #include "cxesensoreventhandlersymbian.h" |
38 #include "cxefilesavethread.h" |
37 #include "cxefilesavethread.h" |
39 #include "cxecameradevice.h" |
38 #include "cxecameradevice.h" |
40 #include "cxememorymonitor.h" |
39 #include "cxememorymonitor.h" |
41 #include "cxediskmonitor.h" |
40 #include "cxediskmonitor.h" |
42 #include "cxegeotaggingtrail.h" |
41 #include "cxegeotaggingtrail.h" |
|
42 #include "cxeexception.h" |
43 |
43 |
44 #include "OstTraceDefinitions.h" |
44 #include "OstTraceDefinitions.h" |
45 #ifdef OST_TRACE_COMPILER_IN_USE |
45 #ifdef OST_TRACE_COMPILER_IN_USE |
46 #include "cxeenginesymbianTraces.h" |
46 #include "cxeenginesymbianTraces.h" |
47 #endif |
47 #endif |
59 mSettingsControl(NULL), |
59 mSettingsControl(NULL), |
60 mAutoFocusControl(NULL), |
60 mAutoFocusControl(NULL), |
61 mZoomControl(NULL), |
61 mZoomControl(NULL), |
62 mSettings(NULL), |
62 mSettings(NULL), |
63 mFeatureManager(NULL), |
63 mFeatureManager(NULL), |
64 mSettingsModel(NULL), |
|
65 mFilenameGenerator(NULL), |
64 mFilenameGenerator(NULL), |
66 mSensorEventHandler(NULL), |
65 mSensorEventHandler(NULL), |
67 mQualityPresets(NULL), |
66 mQualityPresets(NULL), |
68 mFileSaveThread(NULL), |
67 mFileSaveThread(NULL), |
69 mDiskMonitor(NULL), |
68 mDiskMonitor(NULL), |
95 void CxeEngineSymbian::createControls() |
94 void CxeEngineSymbian::createControls() |
96 { |
95 { |
97 CX_DEBUG_ENTER_FUNCTION(); |
96 CX_DEBUG_ENTER_FUNCTION(); |
98 |
97 |
99 // Check we do this only once. |
98 // Check we do this only once. |
100 if (!mSettingsModel) { |
99 if (!mSettings) { |
101 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "e_CX_ENGINE_CREATE_CONTROLS 1"); |
100 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "msg: e_CX_ENGINE_CREATE_CONTROLS 1"); |
102 |
101 |
103 CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian(); |
102 CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian(); |
104 mCameraDeviceControl = deviceControl; |
103 mCameraDeviceControl = deviceControl; |
105 mCameraDevice = deviceControl->cameraDevice(); |
104 mCameraDevice = deviceControl->cameraDevice(); |
106 |
105 |
113 if (XQServiceUtil::isService()) { |
112 if (XQServiceUtil::isService()) { |
114 settingsStore = new CxeSettingsLocalStore(); |
113 settingsStore = new CxeSettingsLocalStore(); |
115 } else { |
114 } else { |
116 settingsStore = new CxeSettingsCenRepStore(); |
115 settingsStore = new CxeSettingsCenRepStore(); |
117 } |
116 } |
118 //ownership of settings store transferred to the settings model. |
117 |
119 mSettingsModel = new CxeSettingsModelImp(settingsStore); |
118 //ownership of settings store transferred to the settings |
120 // assert if settings model fails to intialize |
119 mSettings = new CxeSettingsImp(settingsStore); |
121 CX_DEBUG_ASSERT(mSettingsModel); |
120 |
122 |
121 // Loading current camera mode value from settings store and updating |
123 mSettings = new CxeSettingsImp(*mSettingsModel); |
122 // devicecontrol |
124 |
|
125 // Loading current camera mode value from settings store and updating |
|
126 // devicecontrol |
|
127 Cxe::CameraMode cameraMode = Cxe::ImageMode; |
123 Cxe::CameraMode cameraMode = Cxe::ImageMode; |
128 int value; |
124 |
129 CxeError::Id err = mSettings->get(CxeSettingIds::CAMERA_MODE, value); |
125 try { |
130 if (!err) { |
126 cameraMode = mSettings->get<Cxe::CameraMode>(CxeSettingIds::CAMERA_MODE); |
131 cameraMode = static_cast<Cxe::CameraMode>(value); |
127 } catch (CxeException &e) { |
132 } |
128 CX_DEBUG(("Failed to read camera mode from settings, using image mode. Error code: %d", e.error())); |
|
129 } |
|
130 |
133 // set current camera mode to devicecontrol. |
131 // set current camera mode to devicecontrol. |
134 mCameraDeviceControl->setMode(cameraMode); |
132 mCameraDeviceControl->setMode(cameraMode); |
135 |
133 |
136 //! @todo a temporary hack to change the startup sequence to avoid GOOM problems |
134 //! @todo a temporary hack to change the startup sequence to avoid GOOM problems |
137 static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode()); |
135 static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode()); |
138 |
136 |
139 |
137 |
140 // Connect P&S key updates to settings signal. |
138 // Connect P&S key updates to settings signal. |
141 connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
139 connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
142 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant))); |
140 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant))); |
143 |
141 |
144 mFeatureManager = new CxeFeatureManagerImp(*mSettingsModel); |
142 mFeatureManager = new CxeFeatureManagerImp(*mSettings); |
145 |
143 |
146 // Memory monitor needed as early as possible to request free memory. |
144 // Memory monitor needed as early as possible to request free memory. |
147 // Note: Throws error if enough memory cannot be freed! |
145 // Note: Throws error if enough memory cannot be freed! |
148 mMemoryMonitor = new CxeMemoryMonitor(*mFeatureManager); |
146 mMemoryMonitor = new CxeMemoryMonitor(*mFeatureManager); |
149 |
147 |
161 mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice, |
159 mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice, |
162 *mCameraDeviceControl); |
160 *mCameraDeviceControl); |
163 |
161 |
164 mSnapshotControl = new CxeSnapshotControl(*mCameraDevice); |
162 mSnapshotControl = new CxeSnapshotControl(*mCameraDevice); |
165 |
163 |
166 mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice, |
164 mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice, |
167 *mSettings); |
165 *mSettings); |
168 |
166 |
169 mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread(); |
167 mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread(); |
170 |
168 |
171 mStillCaptureControl = new CxeStillCaptureControlSymbian( |
169 mStillCaptureControl = new CxeStillCaptureControlSymbian( |
196 Connect internal signals for control classes |
194 Connect internal signals for control classes |
197 */ |
195 */ |
198 void CxeEngineSymbian::connectSignals() |
196 void CxeEngineSymbian::connectSignals() |
199 { |
197 { |
200 CX_DEBUG_ENTER_FUNCTION(); |
198 CX_DEBUG_ENTER_FUNCTION(); |
201 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "e_CX_ENGINE_CONNECT_SIGNALS 1"); |
199 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "msg: e_CX_ENGINE_CONNECT_SIGNALS 1"); |
202 |
200 |
203 // enabling scene setting change callbacks to Autofocus control |
201 // enabling scene setting change callbacks to Autofocus control |
204 connect(mSettings, |
202 mSettings->listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, mAutoFocusControl, SLOT(handleSceneChanged(const QVariant&))); |
205 SIGNAL(sceneChanged(CxeScene&)), |
203 mSettings->listenForSetting(CxeSettingIds::VIDEO_SCENE_DATA, mAutoFocusControl, SLOT(handleSceneChanged(const QVariant&))); |
206 mAutoFocusControl, |
|
207 SLOT(handleSceneChanged(CxeScene&))); |
|
208 |
204 |
209 // connecting Autofocus state change callbacks to stillcapturecontrol |
205 // connecting Autofocus state change callbacks to stillcapturecontrol |
210 connect(mAutoFocusControl, |
206 connect(mAutoFocusControl, |
211 SIGNAL(stateChanged(CxeAutoFocusControl::State, CxeError::Id)), |
207 SIGNAL(stateChanged(CxeAutoFocusControl::State, CxeError::Id)), |
212 mStillCaptureControl, |
208 mStillCaptureControl, |
270 connect(mVideoCaptureControl, |
266 connect(mVideoCaptureControl, |
271 SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)), |
267 SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)), |
272 mFileSaveThread, |
268 mFileSaveThread, |
273 SLOT(handleSnapshotReady(CxeError::Id, const QImage&, const QString&))); |
269 SLOT(handleSnapshotReady(CxeError::Id, const QImage&, const QString&))); |
274 |
270 |
275 |
|
276 // stop location trail when releasing camera. |
271 // stop location trail when releasing camera. |
277 connect(mCameraDevice, |
272 connect(mCameraDevice, |
278 SIGNAL(prepareForRelease()), |
273 SIGNAL(prepareForRelease()), |
279 mGeoTaggingTrail, |
274 mGeoTaggingTrail, |
280 SLOT(stop()), |
275 SLOT(stop()), |
281 Qt::UniqueConnection); |
276 Qt::UniqueConnection); |
282 |
277 |
283 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0"); |
278 // Use MCameraUseCaseHint API before calling Reserve() |
|
279 connect(mCameraDevice, |
|
280 SIGNAL(aboutToReserve()), |
|
281 mStillCaptureControl, |
|
282 SLOT(hintUseCase()), |
|
283 Qt::UniqueConnection); |
|
284 connect(mCameraDevice, |
|
285 SIGNAL(aboutToReserve()), |
|
286 mVideoCaptureControl, |
|
287 SLOT(hintUseCase()), |
|
288 Qt::UniqueConnection); |
|
289 |
|
290 // Start / stop geotagging based on mode. |
|
291 // Do this later to reduce startup time. |
|
292 connect(mStillCaptureControl, |
|
293 SIGNAL(imagePrepareComplete(CxeError::Id)), |
|
294 this, |
|
295 SLOT(initGeotagging())); |
|
296 connect(mVideoCaptureControl, |
|
297 SIGNAL(videoPrepareComplete(CxeError::Id)), |
|
298 this, |
|
299 SLOT(initGeotagging())); |
|
300 |
|
301 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); |
284 |
302 |
285 CX_DEBUG_EXIT_FUNCTION(); |
303 CX_DEBUG_EXIT_FUNCTION(); |
286 } |
304 } |
287 |
305 |
288 CxeEngineSymbian::~CxeEngineSymbian() |
306 CxeEngineSymbian::~CxeEngineSymbian() |
289 { |
307 { |
290 CX_DEBUG_ENTER_FUNCTION(); |
308 CX_DEBUG_ENTER_FUNCTION(); |
291 |
309 |
292 // Saving current camera mode to cenrep |
310 // Saving current camera mode to cenrep |
293 saveMode(); |
311 saveMode(); |
294 |
312 |
295 delete mGeoTaggingTrail; |
313 delete mGeoTaggingTrail; |
296 delete mAutoFocusControl; |
314 delete mAutoFocusControl; |
297 delete mZoomControl; |
315 delete mZoomControl; |
298 delete mSettingsControl; |
316 delete mSettingsControl; |
299 delete mStillCaptureControl; |
317 delete mStillCaptureControl; |
303 delete mFilenameGenerator; |
321 delete mFilenameGenerator; |
304 delete mDiskMonitor; |
322 delete mDiskMonitor; |
305 delete mMemoryMonitor; |
323 delete mMemoryMonitor; |
306 delete mFeatureManager; |
324 delete mFeatureManager; |
307 delete mSettings; |
325 delete mSettings; |
308 delete mSettingsModel; |
|
309 delete mCameraDeviceControl; |
326 delete mCameraDeviceControl; |
310 delete mQualityPresets; |
327 delete mQualityPresets; |
311 delete mFileSaveThread; |
328 delete mFileSaveThread; |
312 |
329 |
313 CX_DEBUG_EXIT_FUNCTION(); |
330 CX_DEBUG_EXIT_FUNCTION(); |
413 CxeStillCaptureControl in still image mode). |
430 CxeStillCaptureControl in still image mode). |
414 */ |
431 */ |
415 void CxeEngineSymbian::doInit() |
432 void CxeEngineSymbian::doInit() |
416 { |
433 { |
417 CX_DEBUG_ENTER_FUNCTION(); |
434 CX_DEBUG_ENTER_FUNCTION(); |
418 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "e_CX_ENGINE_DO_INIT 1"); |
435 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "msg: e_CX_ENGINE_DO_INIT 1"); |
419 |
436 |
420 mFilenameGenerator->init(mode()); |
437 mFilenameGenerator->init(mode()); |
421 // load settings whenever we change mode or start camera or switch camera |
438 // load settings whenever we change mode or start camera or switch camera |
422 CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings); |
439 CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings); |
423 if (settingsImp) { |
440 if (settingsImp) { |
424 settingsImp->loadSettings(mode()); |
441 settingsImp->loadSettings(mode()); |
425 } |
442 } |
426 |
443 |
427 if (mode() == Cxe::ImageMode) { |
444 if (mode() == Cxe::ImageMode) { |
428 // start geotagging trail in image mode. |
|
429 startGeotaggingTrail(); |
|
430 mVideoCaptureControl->deinit(); |
445 mVideoCaptureControl->deinit(); |
431 mStillCaptureControl->init(); |
446 mStillCaptureControl->init(); |
432 } else if (mode() == Cxe::VideoMode) { |
447 } else if (mode() == Cxe::VideoMode) { |
433 mStillCaptureControl->deinit(); |
448 mStillCaptureControl->deinit(); |
434 if (mGeoTaggingTrail) { |
|
435 // in video mode, Geotagging is not supported for now. |
|
436 mGeoTaggingTrail->stop(); |
|
437 } |
|
438 mVideoCaptureControl->init(); |
449 mVideoCaptureControl->init(); |
439 } |
450 } |
440 |
451 |
441 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0"); |
452 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "msg: e_CX_ENGINE_DO_INIT 0"); |
442 |
453 |
443 CX_DEBUG_EXIT_FUNCTION(); |
454 CX_DEBUG_EXIT_FUNCTION(); |
444 } |
455 } |
445 |
456 |
446 /*! |
457 /*! |
524 } |
535 } |
525 |
536 |
526 void CxeEngineSymbian::initMode(Cxe::CameraMode cameraMode) |
537 void CxeEngineSymbian::initMode(Cxe::CameraMode cameraMode) |
527 { |
538 { |
528 CX_DEBUG_ENTER_FUNCTION(); |
539 CX_DEBUG_ENTER_FUNCTION(); |
|
540 OstTrace0(camerax_performance, CXEENGINE_INITMODE_IN, "msg: e_CX_ENGINE_INIT_MODE 1"); |
529 |
541 |
530 if (mode() == cameraMode) { |
542 if (mode() == cameraMode) { |
531 CX_DEBUG(("initMode() called for current mode")); |
543 CX_DEBUG(("initMode() called for current mode")); |
532 |
544 |
533 // We're already in the requested mode. However, it is possible |
545 // We're already in the requested mode. However, it is possible |
575 // Camera device control is in Initializing state. Initialization will continue |
587 // Camera device control is in Initializing state. Initialization will continue |
576 // when we get the deviceReady() callback. |
588 // when we get the deviceReady() callback. |
577 } |
589 } |
578 } |
590 } |
579 |
591 |
|
592 OstTrace0(camerax_performance, CXEENGINE_INITMODE_OUT, "msg: e_CX_ENGINE_INIT_MODE 0"); |
580 CX_DEBUG_EXIT_FUNCTION(); |
593 CX_DEBUG_EXIT_FUNCTION(); |
581 } |
594 } |
582 |
595 |
583 void CxeEngineSymbian::reserve() |
596 void CxeEngineSymbian::reserve() |
584 { |
597 { |
585 CX_DEBUG_ENTER_FUNCTION(); |
598 CX_DEBUG_ENTER_FUNCTION(); |
|
599 // Start reserving camera HW. |
586 mCameraDeviceControl->reserve(); |
600 mCameraDeviceControl->reserve(); |
587 emit reserveStarted(); |
601 emit reserveStarted(); |
588 CX_DEBUG_EXIT_FUNCTION(); |
602 CX_DEBUG_EXIT_FUNCTION(); |
589 } |
603 } |
590 |
604 |
595 void CxeEngineSymbian::saveMode() |
609 void CxeEngineSymbian::saveMode() |
596 { |
610 { |
597 CX_DEBUG_ENTER_FUNCTION(); |
611 CX_DEBUG_ENTER_FUNCTION(); |
598 |
612 |
599 if (mCameraDeviceControl && mSettings) { |
613 if (mCameraDeviceControl && mSettings) { |
600 int value = mCameraDeviceControl->mode(); |
614 try { |
601 mSettings->set(CxeSettingIds::CAMERA_MODE, value); |
615 mSettings->set(CxeSettingIds::CAMERA_MODE, mCameraDeviceControl->mode()); |
602 } |
616 } catch (CxeException &e) { |
603 |
617 CX_DEBUG(("Failed to save camera mode, error=%d", e.error())); |
604 CX_DEBUG_EXIT_FUNCTION(); |
618 } |
605 } |
619 } |
606 |
620 |
607 |
621 CX_DEBUG_EXIT_FUNCTION(); |
608 /*! |
622 } |
609 * Start geotagging trail. |
623 |
610 */ |
624 |
611 void CxeEngineSymbian::startGeotaggingTrail() |
625 /*! |
612 { |
626 * Initialize geotagging. |
613 CX_DEBUG_ENTER_FUNCTION(); |
627 * Check if we are allowed to start the geotagging and if it's supported in current mode. |
614 |
628 */ |
|
629 void CxeEngineSymbian::initGeotagging() |
|
630 { |
|
631 CX_DEBUG_ENTER_FUNCTION(); |
|
632 OstTrace0(camerax_performance, CXEENGINE_START_GEO_IN, "msg: e_CX_ENGINE_START_GEOTAGGING 1"); |
|
633 |
615 if (mGeoTaggingTrail && mSettings) { |
634 if (mGeoTaggingTrail && mSettings) { |
616 // location trail is limited to image mode only for now. |
635 if (mode() == Cxe::ImageMode) { |
617 int value = Cxe::GeoTaggingDisclaimerDisabled; |
636 // Location trail is limited to image mode only for now. |
618 mSettings->get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value); |
637 Cxe::GeoTaggingDisclaimer value = |
619 |
638 mSettings->get<Cxe::GeoTaggingDisclaimer>( |
620 // we start location trail only when Geotagging First-time-use note is accepted by user. |
639 CxeSettingIds::GEOTAGGING_DISCLAIMER, Cxe::GeoTaggingDisclaimerDisabled); |
621 if (value == Cxe::GeoTaggingDisclaimerDisabled) { |
640 |
622 mGeoTaggingTrail->start(); |
641 // we start location trail only when Geotagging First-time-use note is accepted by user. |
623 } |
642 if (value == Cxe::GeoTaggingDisclaimerDisabled) { |
624 } |
643 mGeoTaggingTrail->start(); |
625 |
644 } |
|
645 } else { |
|
646 // Geotagging is not (yet) supported in video mode. |
|
647 mGeoTaggingTrail->stop(); |
|
648 } |
|
649 } |
|
650 |
|
651 OstTrace0(camerax_performance, CXEENGINE_START_GEO_OUT, "msg: e_CX_ENGINE_START_GEOTAGGING 0"); |
626 CX_DEBUG_EXIT_FUNCTION(); |
652 CX_DEBUG_EXIT_FUNCTION(); |
627 } |
653 } |
628 |
654 |
629 // End of file |
655 // End of file |