changeset 28 | 3075d9b614e6 |
parent 19 | d9aefe59d544 |
child 38 | 0f0b4c1d7744 |
child 43 | 0e652f8f1fbd |
19:d9aefe59d544 | 28:3075d9b614e6 |
---|---|
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 #include <xqserviceutil.h> |
|
19 |
|
17 #include "cxeenginesymbian.h" |
20 #include "cxeenginesymbian.h" |
18 #include "cxecameradevicecontrolsymbian.h" |
21 #include "cxecameradevicecontrolsymbian.h" |
19 #include "cxestillcapturecontrolsymbian.h" |
22 #include "cxestillcapturecontrolsymbian.h" |
20 #include "cxevideocapturecontrolsymbian.h" |
23 #include "cxevideocapturecontrolsymbian.h" |
21 #include "cxesettingscontrolsymbian.h" |
24 #include "cxesettingscontrolsymbian.h" |
31 #include "cxesettingscenrepstore.h" |
34 #include "cxesettingscenrepstore.h" |
32 #include "cxesoundplayersymbian.h" |
35 #include "cxesoundplayersymbian.h" |
33 #include "cxesensoreventhandlersymbian.h" |
36 #include "cxesensoreventhandlersymbian.h" |
34 #include "cxefilesavethread.h" |
37 #include "cxefilesavethread.h" |
35 #include "cxecameradevice.h" |
38 #include "cxecameradevice.h" |
39 #include "cxememorymonitor.h" |
|
40 #include "cxediskmonitor.h" |
|
36 |
41 |
37 #include "OstTraceDefinitions.h" |
42 #include "OstTraceDefinitions.h" |
38 #ifdef OST_TRACE_COMPILER_IN_USE |
43 #ifdef OST_TRACE_COMPILER_IN_USE |
39 #include "cxeenginesymbianTraces.h" |
44 #include "cxeenginesymbianTraces.h" |
40 #endif |
45 #endif |
41 #include <xqserviceutil.h> |
46 |
42 |
47 |
43 // Member Functions |
48 // Member Functions |
44 |
49 |
45 CxeEngineSymbian::CxeEngineSymbian() |
50 CxeEngineSymbian::CxeEngineSymbian() |
46 : mCameraDeviceControl(NULL), |
51 : mCameraDeviceControl(NULL), |
52 mCameraDevice(NULL), |
|
47 mViewfinderControl(NULL), |
53 mViewfinderControl(NULL), |
48 mStillCaptureControl(NULL), |
54 mStillCaptureControl(NULL), |
49 mVideoCaptureControl(NULL), |
55 mVideoCaptureControl(NULL), |
50 mSettingsControl(NULL), |
56 mSettingsControl(NULL), |
51 mAutoFocusControl(NULL), |
57 mAutoFocusControl(NULL), |
56 mFilenameGenerator(NULL), |
62 mFilenameGenerator(NULL), |
57 mSensorEventHandler(NULL), |
63 mSensorEventHandler(NULL), |
58 mQualityPresets(NULL), |
64 mQualityPresets(NULL), |
59 mFileSaveThread(NULL) |
65 mFileSaveThread(NULL) |
60 { |
66 { |
61 CX_DEBUG_IN_FUNCTION(); |
67 CX_DEBUG_ENTER_FUNCTION(); |
68 |
|
69 // Do secondary construction during reserve call. |
|
70 //! @todo temporarily commented as part of a hack to change the startup sequence |
|
71 // to avoid GOOM issues |
|
72 // connect(this, SIGNAL(reserveStarted()), this, SLOT(construct())); |
|
73 |
|
74 CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian(); |
|
75 mCameraDeviceControl = deviceControl; |
|
76 mCameraDevice = deviceControl->cameraDevice(); |
|
77 CX_ASSERT_ALWAYS(mCameraDeviceControl); |
|
78 CX_ASSERT_ALWAYS(mCameraDevice); |
|
79 |
|
80 mCameraDeviceControl->init(); |
|
81 //! @todo calling construct here is a hack to change the startup sequence |
|
82 // to avoid GOOM issues |
|
83 construct(); |
|
84 |
|
85 CX_DEBUG_EXIT_FUNCTION(); |
|
62 } |
86 } |
63 |
87 |
64 |
88 |
65 /*! |
89 /*! |
66 Create all control classes and connect relevant signals |
90 Create all control classes and connect relevant signals |
75 CX_DEBUG_EXIT_FUNCTION(); |
99 CX_DEBUG_EXIT_FUNCTION(); |
76 } |
100 } |
77 |
101 |
78 |
102 |
79 /*! |
103 /*! |
80 Create all control classes |
104 Create all control classes. |
105 Note: Throws an error, if free memory request by CxeMemoryMonitor constructor fails! |
|
81 */ |
106 */ |
82 void CxeEngineSymbian::createControls() |
107 void CxeEngineSymbian::createControls() |
83 { |
108 { |
84 CX_DEBUG_ENTER_FUNCTION(); |
109 CX_DEBUG_ENTER_FUNCTION(); |
85 |
110 |
86 if (!mVideoCaptureControl) { |
111 // Check we do this only once. |
87 CxeCameraDeviceControlSymbian *deviceControl = |
112 if (!mSettingsModel) { |
88 new CxeCameraDeviceControlSymbian(); |
113 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "e_CX_ENGINE_CREATE_CONTROLS 1"); |
89 |
114 |
90 mCameraDeviceControl = deviceControl; |
115 CxeSettingsCenRepStore *settingsStore(NULL); |
91 CxeCameraDevice *cameraDevice = deviceControl->cameraDevice(); |
|
92 |
|
93 CxeSettingsCenRepStore *settingsStore; |
|
94 |
|
95 if (XQServiceUtil::isService()) { |
116 if (XQServiceUtil::isService()) { |
96 settingsStore = new CxeSettingsLocalStore(); |
117 settingsStore = new CxeSettingsLocalStore(); |
97 } else { |
118 } else { |
98 settingsStore = new CxeSettingsCenRepStore(); |
119 settingsStore = new CxeSettingsCenRepStore(); |
99 } |
120 } |
100 |
|
101 //ownership of settings store transferred to the settings model. |
121 //ownership of settings store transferred to the settings model. |
102 mSettingsModel = new CxeSettingsModelImp( |
122 mSettingsModel = new CxeSettingsModelImp(settingsStore); |
103 settingsStore); |
|
104 |
|
105 // assert if settings model fails to intialize |
123 // assert if settings model fails to intialize |
106 CX_DEBUG_ASSERT(mSettingsModel); |
124 CX_DEBUG_ASSERT(mSettingsModel); |
125 |
|
107 mSettings = new CxeSettingsImp(*mSettingsModel); |
126 mSettings = new CxeSettingsImp(*mSettingsModel); |
108 |
127 |
128 //! @todo a temporary hack to change the startup sequence to avoid GOOM problems |
|
129 static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode()); |
|
130 |
|
131 |
|
132 // Connect P&S key updates to settings signal. |
|
109 connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
133 connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
110 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant))); |
134 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant))); |
111 |
135 |
136 mFeatureManager = new CxeFeatureManagerImp(*mSettingsModel); |
|
137 |
|
138 // Memory monitor needed as early as possible to request free memory. |
|
139 // Note: Throws error if enough memory cannot be freed! |
|
140 mMemoryMonitor = new CxeMemoryMonitor(*mFeatureManager); |
|
141 |
|
142 mDiskMonitor = new CxeDiskMonitor(*mSettings); |
|
143 |
|
112 mQualityPresets = new CxeQualityPresetsSymbian(*mSettings); |
144 mQualityPresets = new CxeQualityPresetsSymbian(*mSettings); |
113 CX_DEBUG_ASSERT(mQualityPresets); |
145 CX_DEBUG_ASSERT(mQualityPresets); |
114 |
146 |
115 mFeatureManager = new CxeFeatureManagerImp(*mSettingsModel); |
|
116 |
|
117 // sensor event handler initialization |
147 // sensor event handler initialization |
118 mSensorEventHandler = new CxeSensorEventHandlerSymbian(); |
148 mSensorEventHandler = new CxeSensorEventHandlerSymbian(); |
119 |
149 |
120 mFilenameGenerator = new CxeFilenameGeneratorSymbian(*mSettings, |
150 mFilenameGenerator = new CxeFilenameGeneratorSymbian(*mSettings, |
121 mode()); |
151 mode()); |
122 |
152 |
123 mViewfinderControl = new CxeViewfinderControlSymbian(*cameraDevice, |
153 mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice, |
124 *deviceControl); |
154 *mCameraDeviceControl); |
125 |
155 |
126 mAutoFocusControl = new CxeAutoFocusControlSymbian(*cameraDevice); |
156 mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice); |
127 |
157 |
128 mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread(); |
158 mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread(); |
129 |
159 |
130 mStillCaptureControl = new CxeStillCaptureControlSymbian( |
160 mStillCaptureControl = new CxeStillCaptureControlSymbian( |
131 *cameraDevice, *mViewfinderControl, *deviceControl, |
161 *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl, |
132 *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl, |
162 *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl, |
133 *mSettings, *mQualityPresets, *mFileSaveThread); |
163 *mSettings, *mQualityPresets, *mFileSaveThread, *mDiskMonitor); |
134 |
164 |
135 mZoomControl = new CxeZoomControlSymbian( *cameraDevice, |
165 mZoomControl = new CxeZoomControlSymbian( *mCameraDevice, |
136 *deviceControl, *mSettings, *mFeatureManager); |
166 *mCameraDeviceControl, *mSettings, *mFeatureManager); |
137 |
167 |
138 mVideoCaptureControl = new CxeVideoCaptureControlSymbian( |
168 mVideoCaptureControl = new CxeVideoCaptureControlSymbian( |
139 *cameraDevice, *mViewfinderControl, *deviceControl, |
169 *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl, |
140 *mFilenameGenerator, *mSettings, *mQualityPresets); |
170 *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor); |
141 |
171 |
142 mSettingsControl = new CxeSettingsControlSymbian(*cameraDevice, *mSettings); |
172 mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings); |
173 |
|
174 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "e_CX_ENGINE_CREATE_CONTROLS 0"); |
|
143 } |
175 } |
144 |
176 |
145 CX_DEBUG_EXIT_FUNCTION(); |
177 CX_DEBUG_EXIT_FUNCTION(); |
146 } |
178 } |
147 |
179 |
149 Connect internal signals for control classes |
181 Connect internal signals for control classes |
150 */ |
182 */ |
151 void CxeEngineSymbian::connectSignals() |
183 void CxeEngineSymbian::connectSignals() |
152 { |
184 { |
153 CX_DEBUG_ENTER_FUNCTION(); |
185 CX_DEBUG_ENTER_FUNCTION(); |
186 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "e_CX_ENGINE_CONNECT_SIGNALS 1"); |
|
154 |
187 |
155 // enabling scene setting change callbacks to Autofocus control |
188 // enabling scene setting change callbacks to Autofocus control |
156 connect(mSettings, |
189 connect(mSettings, |
157 SIGNAL(sceneChanged(CxeScene&)), |
190 SIGNAL(sceneChanged(CxeScene&)), |
158 mAutoFocusControl, |
191 mAutoFocusControl, |
217 connect(mVideoCaptureControl, |
250 connect(mVideoCaptureControl, |
218 SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)), |
251 SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)), |
219 mFileSaveThread, |
252 mFileSaveThread, |
220 SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&))); |
253 SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&))); |
221 |
254 |
222 |
255 OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0"); |
223 |
|
224 // init camera device control. We init the camera device control |
|
225 // when all necessary engine classes are constructed. |
|
226 mCameraDeviceControl->init(); |
|
227 |
256 |
228 CX_DEBUG_EXIT_FUNCTION(); |
257 CX_DEBUG_EXIT_FUNCTION(); |
229 } |
258 } |
230 |
259 |
231 CxeEngineSymbian::~CxeEngineSymbian() |
260 CxeEngineSymbian::~CxeEngineSymbian() |
237 delete mSettingsControl; |
266 delete mSettingsControl; |
238 delete mStillCaptureControl; |
267 delete mStillCaptureControl; |
239 delete mVideoCaptureControl; |
268 delete mVideoCaptureControl; |
240 delete mViewfinderControl; |
269 delete mViewfinderControl; |
241 delete mFilenameGenerator; |
270 delete mFilenameGenerator; |
271 delete mDiskMonitor; |
|
272 delete mMemoryMonitor; |
|
242 delete mFeatureManager; |
273 delete mFeatureManager; |
243 delete mSettings; |
274 delete mSettings; |
244 delete mSettingsModel; |
275 delete mSettingsModel; |
245 delete mCameraDeviceControl; |
276 delete mCameraDeviceControl; |
246 delete mQualityPresets; |
277 delete mQualityPresets; |
290 { |
321 { |
291 return *mSensorEventHandler; |
322 return *mSensorEventHandler; |
292 } |
323 } |
293 |
324 |
294 |
325 |
295 CxeFeatureManager& CxeEngineSymbian::featureManager() |
326 CxeFeatureManager &CxeEngineSymbian::featureManager() |
296 { |
327 { |
297 return *mFeatureManager; |
328 return *mFeatureManager; |
329 } |
|
330 |
|
331 /*! |
|
332 * Get memory monitor utility handle. |
|
333 */ |
|
334 CxeMemoryMonitor &CxeEngineSymbian::memoryMonitor() |
|
335 { |
|
336 return *mMemoryMonitor; |
|
298 } |
337 } |
299 |
338 |
300 /* |
339 /* |
301 * Returns true, if the engine is ready or else false. |
340 * Returns true, if the engine is ready or else false. |
302 */ |
341 */ |
323 CxeStillCaptureControl in still image mode). |
362 CxeStillCaptureControl in still image mode). |
324 */ |
363 */ |
325 void CxeEngineSymbian::doInit() |
364 void CxeEngineSymbian::doInit() |
326 { |
365 { |
327 CX_DEBUG_ENTER_FUNCTION(); |
366 CX_DEBUG_ENTER_FUNCTION(); |
328 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT, "e_CX_ENGINE_DO_INIT 1"); |
367 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "e_CX_ENGINE_DO_INIT 1"); |
329 |
368 |
330 mFilenameGenerator->init(mode()); |
369 mFilenameGenerator->init(mode()); |
331 // load settings whenever we change mode or start camera or switch camera |
370 // load settings whenever we change mode or start camera or switch camera |
332 CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings); |
371 CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings); |
333 if (settingsImp) { |
372 if (settingsImp) { |
341 } else if (mode() == Cxe::VideoMode) { |
380 } else if (mode() == Cxe::VideoMode) { |
342 mStillCaptureControl->deinit(); |
381 mStillCaptureControl->deinit(); |
343 mVideoCaptureControl->init(); |
382 mVideoCaptureControl->init(); |
344 } |
383 } |
345 |
384 |
346 OstTrace0(camerax_performance, DUP1_CXEENGINESYMBIAN_DOINIT, "e_CX_ENGINE_DO_INIT 0"); |
385 OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0"); |
347 |
386 |
348 CX_DEBUG_EXIT_FUNCTION(); |
387 CX_DEBUG_EXIT_FUNCTION(); |
349 } |
388 } |
350 |
389 |
351 Cxe::CameraMode CxeEngineSymbian::mode() const |
390 Cxe::CameraMode CxeEngineSymbian::mode() const |
427 // the capture control. |
466 // the capture control. |
428 if (reserveNeeded()) { |
467 if (reserveNeeded()) { |
429 // Camera needs to be reserved. Initialization will continue |
468 // Camera needs to be reserved. Initialization will continue |
430 // when we get the deviceReady() signal. |
469 // when we get the deviceReady() signal. |
431 CX_DEBUG(("initMode() - calling reserve()")); |
470 CX_DEBUG(("initMode() - calling reserve()")); |
432 mCameraDeviceControl->reserve(); |
471 reserve(); |
433 } else if (initNeeded()) { |
472 } else if (initNeeded()) { |
434 // Camera is reserved and ready, but we need to prepare still image control or |
473 // Camera is reserved and ready, but we need to prepare still image control or |
435 // video capture control |
474 // video capture control |
436 CX_DEBUG(("initMode() - calling doInit()")); |
475 CX_DEBUG(("initMode() - calling doInit()")); |
437 doInit(); |
476 doInit(); |
453 // stop the vf |
492 // stop the vf |
454 mViewfinderControl->stop(); |
493 mViewfinderControl->stop(); |
455 |
494 |
456 if (reserveNeeded()) { |
495 if (reserveNeeded()) { |
457 CX_DEBUG(("initMode() - calling reserve()")); |
496 CX_DEBUG(("initMode() - calling reserve()")); |
458 mCameraDeviceControl->reserve(); |
497 reserve(); |
459 } else if (mCameraDeviceControl->state() == CxeCameraDeviceControl::Ready) { |
498 } else if (mCameraDeviceControl->state() == CxeCameraDeviceControl::Ready) { |
460 CX_DEBUG(("initMode() - calling doInit()")); |
499 CX_DEBUG(("initMode() - calling doInit()")); |
461 // Camera device is ready... we only need to prepare video or still |
500 // Camera device is ready... we only need to prepare video or still |
462 // capture control, depending on current mode. |
501 // capture control, depending on current mode. |
463 doInit(); |
502 doInit(); |
470 } |
509 } |
471 |
510 |
472 CX_DEBUG_EXIT_FUNCTION(); |
511 CX_DEBUG_EXIT_FUNCTION(); |
473 } |
512 } |
474 |
513 |
514 void CxeEngineSymbian::reserve() |
|
515 { |
|
516 CX_DEBUG_ENTER_FUNCTION(); |
|
517 mCameraDeviceControl->reserve(); |
|
518 emit reserveStarted(); |
|
519 CX_DEBUG_EXIT_FUNCTION(); |
|
520 } |
|
521 |
|
475 // End of file |
522 // End of file |