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, "msg: 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(); |
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); |
|
122 |
|
123 mSettings = new CxeSettingsImp(*mSettingsModel); |
|
124 |
120 |
125 // Loading current camera mode value from settings store and updating |
121 // Loading current camera mode value from settings store and updating |
126 // devicecontrol |
122 // 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()); |
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 |
199 { |
197 { |
200 CX_DEBUG_ENTER_FUNCTION(); |
198 CX_DEBUG_ENTER_FUNCTION(); |
201 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "msg: 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); |
|
277 |
|
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())); |
282 |
300 |
283 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); |
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 } |
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(); |
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, "msg: e_CX_ENGINE_DO_INIT 0"); |
452 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "msg: e_CX_ENGINE_DO_INIT 0"); |
442 |
453 |
597 void CxeEngineSymbian::saveMode() |
609 void CxeEngineSymbian::saveMode() |
598 { |
610 { |
599 CX_DEBUG_ENTER_FUNCTION(); |
611 CX_DEBUG_ENTER_FUNCTION(); |
600 |
612 |
601 if (mCameraDeviceControl && mSettings) { |
613 if (mCameraDeviceControl && mSettings) { |
602 int value = mCameraDeviceControl->mode(); |
614 try { |
603 mSettings->set(CxeSettingIds::CAMERA_MODE, value); |
615 mSettings->set(CxeSettingIds::CAMERA_MODE, mCameraDeviceControl->mode()); |
604 } |
616 } catch (CxeException &e) { |
605 |
617 CX_DEBUG(("Failed to save camera mode, error=%d", e.error())); |
606 CX_DEBUG_EXIT_FUNCTION(); |
618 } |
607 } |
619 } |
608 |
620 |
609 |
621 CX_DEBUG_EXIT_FUNCTION(); |
610 /*! |
622 } |
611 * Start geotagging trail. |
623 |
612 */ |
624 |
613 void CxeEngineSymbian::startGeotaggingTrail() |
625 /*! |
|
626 * Initialize geotagging. |
|
627 * Check if we are allowed to start the geotagging and if it's supported in current mode. |
|
628 */ |
|
629 void CxeEngineSymbian::initGeotagging() |
614 { |
630 { |
615 CX_DEBUG_ENTER_FUNCTION(); |
631 CX_DEBUG_ENTER_FUNCTION(); |
616 OstTrace0(camerax_performance, CXEENGINE_START_GEO_IN, "msg: e_CX_ENGINE_START_GEOTAGGING 1"); |
632 OstTrace0(camerax_performance, CXEENGINE_START_GEO_IN, "msg: e_CX_ENGINE_START_GEOTAGGING 1"); |
617 |
633 |
618 if (mGeoTaggingTrail && mSettings) { |
634 if (mGeoTaggingTrail && mSettings) { |
619 // location trail is limited to image mode only for now. |
635 if (mode() == Cxe::ImageMode) { |
620 int value = Cxe::GeoTaggingDisclaimerDisabled; |
636 // Location trail is limited to image mode only for now. |
621 mSettings->get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value); |
637 Cxe::GeoTaggingDisclaimer value = |
622 |
638 mSettings->get<Cxe::GeoTaggingDisclaimer>( |
623 // we start location trail only when Geotagging First-time-use note is accepted by user. |
639 CxeSettingIds::GEOTAGGING_DISCLAIMER, Cxe::GeoTaggingDisclaimerDisabled); |
624 if (value == Cxe::GeoTaggingDisclaimerDisabled) { |
640 |
625 mGeoTaggingTrail->start(); |
641 // we start location trail only when Geotagging First-time-use note is accepted by user. |
|
642 if (value == Cxe::GeoTaggingDisclaimerDisabled) { |
|
643 mGeoTaggingTrail->start(); |
|
644 } |
|
645 } else { |
|
646 // Geotagging is not (yet) supported in video mode. |
|
647 mGeoTaggingTrail->stop(); |
626 } |
648 } |
627 } |
649 } |
628 |
650 |
629 OstTrace0(camerax_performance, CXEENGINE_START_GEO_OUT, "msg: e_CX_ENGINE_START_GEOTAGGING 0"); |
651 OstTrace0(camerax_performance, CXEENGINE_START_GEO_OUT, "msg: e_CX_ENGINE_START_GEOTAGGING 0"); |
630 CX_DEBUG_EXIT_FUNCTION(); |
652 CX_DEBUG_EXIT_FUNCTION(); |