46
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cxeenginedesktop.h"
|
|
18 |
#include "cxecameradevicecontroldesktop.h"
|
|
19 |
#include "cxestillcapturecontroldesktop.h"
|
|
20 |
#include "cxevideocapturecontroldesktop.h"
|
|
21 |
#include "cxeviewfindercontroldesktop.h"
|
|
22 |
#include "cxefilenamegeneratordesktop.h"
|
|
23 |
#include "cxeautofocuscontroldesktop.h"
|
|
24 |
#include "cxezoomcontroldesktop.h"
|
|
25 |
#include "cxequalitypresetsdesktop.h"
|
|
26 |
#include "cxutils.h"
|
|
27 |
#include "cxesettingsimp.h"
|
|
28 |
#include "cxefeaturemanagerimp.h"
|
|
29 |
#include "cxesettingsstoredesktop.h"
|
|
30 |
#include "cxesensoreventhandlerdesktop.h"
|
|
31 |
#include "cxefilesavethreaddesktop.h"
|
|
32 |
#include "cxecameradevicedesktop.h"
|
|
33 |
#include "cxememorymonitor.h"
|
|
34 |
#include "cxegeotaggingtrail.h"
|
|
35 |
|
|
36 |
|
|
37 |
// Member Functions
|
|
38 |
|
|
39 |
CxeEngineDesktop::CxeEngineDesktop()
|
|
40 |
: mCameraDeviceControl(NULL),
|
|
41 |
mViewfinderControl(NULL),
|
|
42 |
mSnapshotControl(NULL),
|
|
43 |
mStillCaptureControl(NULL),
|
|
44 |
mVideoCaptureControl(NULL),
|
|
45 |
mAutoFocusControl(NULL),
|
|
46 |
mZoomControl(NULL),
|
|
47 |
mImageDataQueue(NULL),
|
|
48 |
mSettings(NULL),
|
|
49 |
mFeatureManager(NULL),
|
|
50 |
mFilenameGenerator(NULL),
|
|
51 |
mSensorEventHandler(NULL),
|
|
52 |
mQualityPresets(NULL),
|
|
53 |
mFileSaveThread(NULL),
|
|
54 |
mCameraDevice(NULL),
|
|
55 |
mDiskMonitor(NULL),
|
|
56 |
mMemoryMonitor(NULL),
|
|
57 |
mGeoTaggingTrail(NULL)
|
|
58 |
{
|
|
59 |
CX_DEBUG_IN_FUNCTION();
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
/*!
|
|
64 |
Create all control classes and connect relevant signals
|
|
65 |
*/
|
|
66 |
void CxeEngineDesktop::construct()
|
|
67 |
{
|
|
68 |
CX_DEBUG_ENTER_FUNCTION();
|
|
69 |
|
|
70 |
createControls();
|
|
71 |
connectSignals();
|
|
72 |
|
|
73 |
CX_DEBUG_EXIT_FUNCTION();
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
/*!
|
|
78 |
Create all control classes
|
|
79 |
*/
|
|
80 |
void CxeEngineDesktop::createControls()
|
|
81 |
{
|
|
82 |
CX_DEBUG_ENTER_FUNCTION();
|
|
83 |
|
|
84 |
if (!mVideoCaptureControl) {
|
|
85 |
CxeCameraDeviceControlDesktop *deviceControl =
|
|
86 |
new CxeCameraDeviceControlDesktop();
|
|
87 |
|
|
88 |
mCameraDeviceControl = deviceControl;
|
|
89 |
|
|
90 |
mQualityPresets = new CxeQualityPresetsDesktop();
|
|
91 |
CX_DEBUG_ASSERT(mQualityPresets);
|
|
92 |
|
|
93 |
CxeSettingsStoreDesktop *settingsStore = new CxeSettingsStoreDesktop();
|
|
94 |
|
|
95 |
//ownership of settings store transferred to the settings.
|
|
96 |
mSettings = new CxeSettingsImp(settingsStore);
|
|
97 |
|
|
98 |
// Loading current camera mode value from settings store and updating
|
|
99 |
// devicecontrol
|
|
100 |
Cxe::CameraMode cameraMode = mSettings->get<Cxe::CameraMode>(CxeSettingIds::CAMERA_MODE, Cxe::ImageMode);
|
|
101 |
// set current camera mode to devicecontrol.
|
|
102 |
mCameraDeviceControl->setMode(cameraMode);
|
|
103 |
|
|
104 |
static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode());
|
|
105 |
|
|
106 |
mFeatureManager = new CxeFeatureManagerImp(*mSettings);
|
|
107 |
|
|
108 |
mMemoryMonitor = new CxeMemoryMonitor(*mFeatureManager);
|
|
109 |
|
|
110 |
// sensor event handler initialization
|
|
111 |
mSensorEventHandler = new CxeSensorEventHandlerDesktop();
|
|
112 |
|
|
113 |
mFilenameGenerator = new CxeFilenameGeneratorDesktop();
|
|
114 |
|
|
115 |
mFileSaveThread = new CxeFileSaveThreadDesktop(this);
|
|
116 |
|
|
117 |
mCameraDevice = new CxeCameraDeviceDesktop();
|
|
118 |
|
|
119 |
mViewfinderControl = new CxeViewfinderControlDesktop(*mCameraDevice);
|
|
120 |
|
|
121 |
mAutoFocusControl = new CxeAutoFocusControlDesktop();
|
|
122 |
|
|
123 |
mStillCaptureControl = new CxeStillCaptureControlDesktop(
|
|
124 |
*mCameraDevice, *mViewfinderControl,
|
|
125 |
*mCameraDeviceControl, *mFilenameGenerator,
|
|
126 |
*mAutoFocusControl, *mFileSaveThread);
|
|
127 |
|
|
128 |
mZoomControl = new CxeZoomControlDesktop(*mCameraDeviceControl);
|
|
129 |
|
|
130 |
mVideoCaptureControl = new CxeVideoCaptureControlDesktop(
|
|
131 |
*mCameraDevice,*mViewfinderControl,
|
|
132 |
*mCameraDeviceControl, *mFilenameGenerator,
|
|
133 |
*mQualityPresets);
|
|
134 |
|
|
135 |
mGeoTaggingTrail = new CxeGeoTaggingTrail(*mStillCaptureControl,
|
|
136 |
*mVideoCaptureControl, *mSettings);
|
|
137 |
}
|
|
138 |
|
|
139 |
CX_DEBUG_EXIT_FUNCTION();
|
|
140 |
}
|
|
141 |
|
|
142 |
/*!
|
|
143 |
Connect internal signals for control classes
|
|
144 |
*/
|
|
145 |
|
|
146 |
void CxeEngineDesktop::connectSignals()
|
|
147 |
{
|
|
148 |
CX_DEBUG_ENTER_FUNCTION();
|
|
149 |
|
|
150 |
// connecting scene setting change callbacks to ViewfinderControl
|
|
151 |
connect(mSettings,
|
|
152 |
SIGNAL(settingValueChanged(const QString&,QVariant)),
|
|
153 |
mViewfinderControl,
|
|
154 |
SLOT(handleSettingValueChanged(const QString&,QVariant)));
|
|
155 |
|
|
156 |
connect(mSettings,
|
|
157 |
SIGNAL(sceneChanged(CxeScene&)),
|
|
158 |
mViewfinderControl,
|
|
159 |
SLOT(handleSceneChanged(CxeScene&)));
|
|
160 |
|
|
161 |
// enabling scene setting change callbacks to Autofocus control
|
|
162 |
connect(mSettings,
|
|
163 |
SIGNAL(sceneChanged(CxeScene&)),
|
|
164 |
mAutoFocusControl,
|
|
165 |
SLOT(handleSceneChanged(CxeScene&)));
|
|
166 |
|
|
167 |
// connecting Autofocus state change callbacks to stillcapturecontrol
|
|
168 |
connect(mAutoFocusControl,
|
|
169 |
SIGNAL(stateChanged(CxeAutoFocusControl::State, CxeError::Id)),
|
|
170 |
mStillCaptureControl,
|
|
171 |
SLOT(handleAutofocusStateChanged(CxeAutoFocusControl::State,CxeError::Id)));
|
|
172 |
|
|
173 |
// Connect signals for ECam events
|
|
174 |
connect(mCameraDeviceControl,
|
|
175 |
SIGNAL(cameraEvent(int,int)),
|
|
176 |
mVideoCaptureControl,
|
|
177 |
SLOT(handleCameraEvent(int,int)));
|
|
178 |
|
|
179 |
connect(mCameraDeviceControl,
|
|
180 |
SIGNAL(cameraEvent(int,int)),
|
|
181 |
mAutoFocusControl,
|
|
182 |
SLOT(handleCameraEvent(int,int)));
|
|
183 |
|
|
184 |
// Connect signal for device ready events
|
|
185 |
connect(mCameraDeviceControl,
|
|
186 |
SIGNAL(deviceReady()),
|
|
187 |
this,
|
|
188 |
SLOT(doInit()));
|
|
189 |
|
|
190 |
// Connect image and video init complete signals to
|
|
191 |
// CameraDeviceControl initModeComplete
|
|
192 |
connect(mStillCaptureControl,
|
|
193 |
SIGNAL(imagePrepareComplete(CxeError::Id)),
|
|
194 |
mCameraDeviceControl,
|
|
195 |
SIGNAL(initModeComplete(CxeError::Id)));
|
|
196 |
|
|
197 |
connect(mVideoCaptureControl,
|
|
198 |
SIGNAL(videoPrepareComplete(CxeError::Id)),
|
|
199 |
mCameraDeviceControl,
|
|
200 |
SIGNAL(initModeComplete(CxeError::Id)));
|
|
201 |
|
|
202 |
// Zoom is prepared once the image/video emits prepare zoom signals
|
|
203 |
connect(mStillCaptureControl,
|
|
204 |
SIGNAL(prepareZoomForStill(int)),
|
|
205 |
mZoomControl,
|
|
206 |
SLOT(prepareZoomForStill(int)));
|
|
207 |
|
|
208 |
connect(mVideoCaptureControl,
|
|
209 |
SIGNAL(prepareZoomForVideo()),
|
|
210 |
mZoomControl,
|
|
211 |
SLOT(prepareZoomForVideo()));
|
|
212 |
|
|
213 |
// connect camera device control prepare for release signal to stop location trail slot
|
|
214 |
connect(mCameraDevice,
|
|
215 |
SIGNAL(prepareForRelease()),
|
|
216 |
mGeoTaggingTrail,
|
|
217 |
SLOT(stop()), Qt::UniqueConnection);
|
|
218 |
|
|
219 |
// init camera device control. We init the camera device control
|
|
220 |
// when all necessary engine classes are constructed.
|
|
221 |
mCameraDeviceControl->init();
|
|
222 |
|
|
223 |
CX_DEBUG_EXIT_FUNCTION();
|
|
224 |
}
|
|
225 |
|
|
226 |
CxeEngineDesktop::~CxeEngineDesktop()
|
|
227 |
{
|
|
228 |
CX_DEBUG_ENTER_FUNCTION();
|
|
229 |
|
|
230 |
delete mGeoTaggingTrail;
|
|
231 |
delete mAutoFocusControl;
|
|
232 |
delete mZoomControl;
|
|
233 |
delete mStillCaptureControl;
|
|
234 |
delete mVideoCaptureControl;
|
|
235 |
delete mViewfinderControl;
|
|
236 |
delete mFilenameGenerator;
|
|
237 |
delete mMemoryMonitor;
|
|
238 |
delete mFeatureManager;
|
|
239 |
delete mSettings;
|
|
240 |
delete mCameraDeviceControl;
|
|
241 |
delete mQualityPresets;
|
|
242 |
delete mCameraDevice;
|
|
243 |
CX_DEBUG_EXIT_FUNCTION();
|
|
244 |
}
|
|
245 |
|
|
246 |
CxeCameraDeviceControl &CxeEngineDesktop::cameraDeviceControl()
|
|
247 |
{
|
|
248 |
return *mCameraDeviceControl;
|
|
249 |
}
|
|
250 |
|
|
251 |
CxeViewfinderControl &CxeEngineDesktop::viewfinderControl()
|
|
252 |
{
|
|
253 |
return *mViewfinderControl;
|
|
254 |
}
|
|
255 |
|
|
256 |
CxeSnapshotControl &CxeEngineDesktop::snapshotControl()
|
|
257 |
{
|
|
258 |
return *mSnapshotControl;
|
|
259 |
}
|
|
260 |
|
|
261 |
CxeStillCaptureControl &CxeEngineDesktop::stillCaptureControl()
|
|
262 |
{
|
|
263 |
return *mStillCaptureControl;
|
|
264 |
}
|
|
265 |
|
|
266 |
CxeVideoCaptureControl &CxeEngineDesktop::videoCaptureControl()
|
|
267 |
{
|
|
268 |
return *mVideoCaptureControl;
|
|
269 |
}
|
|
270 |
|
|
271 |
CxeAutoFocusControl &CxeEngineDesktop::autoFocusControl()
|
|
272 |
{
|
|
273 |
return *mAutoFocusControl;
|
|
274 |
}
|
|
275 |
|
|
276 |
CxeZoomControl &CxeEngineDesktop::zoomControl()
|
|
277 |
{
|
|
278 |
return *mZoomControl;
|
|
279 |
}
|
|
280 |
|
|
281 |
// Get the settings handle
|
|
282 |
CxeSettings &CxeEngineDesktop::settings()
|
|
283 |
{
|
|
284 |
return *mSettings;
|
|
285 |
}
|
|
286 |
|
|
287 |
CxeFeatureManager& CxeEngineDesktop::featureManager()
|
|
288 |
{
|
|
289 |
return *mFeatureManager;
|
|
290 |
}
|
|
291 |
|
|
292 |
/*
|
|
293 |
* Returns true, if the engine is ready or else false.
|
|
294 |
*/
|
|
295 |
bool CxeEngineDesktop::isEngineReady()
|
|
296 |
{
|
|
297 |
bool ready = true;
|
|
298 |
return ready;
|
|
299 |
}
|
|
300 |
|
|
301 |
/*!
|
|
302 |
* Get memory monitor utility handle.
|
|
303 |
*/
|
|
304 |
CxeMemoryMonitor &CxeEngineDesktop::memoryMonitor()
|
|
305 |
{
|
|
306 |
return *mMemoryMonitor;
|
|
307 |
}
|
|
308 |
|
|
309 |
/*!
|
|
310 |
* Get geotaggingtrail handle
|
|
311 |
*/
|
|
312 |
CxeGeoTaggingTrail &CxeEngineDesktop::geoTaggingTrail()
|
|
313 |
{
|
|
314 |
return *mGeoTaggingTrail;
|
|
315 |
}
|
|
316 |
|
|
317 |
Cxe::CameraMode CxeEngineDesktop::mode() const
|
|
318 |
{
|
|
319 |
return mCameraDeviceControl->mode();
|
|
320 |
}
|
|
321 |
|
|
322 |
/*!
|
|
323 |
* Set camera mode.
|
|
324 |
*/
|
|
325 |
void CxeEngineDesktop::setMode(Cxe::CameraMode mode)
|
|
326 |
{
|
|
327 |
CX_DEBUG_ENTER_FUNCTION();
|
|
328 |
mCameraDeviceControl->setMode(mode);
|
|
329 |
CX_DEBUG_EXIT_FUNCTION();
|
|
330 |
}
|
|
331 |
|
|
332 |
void CxeEngineDesktop::initMode(Cxe::CameraMode cameraMode)
|
|
333 |
{
|
|
334 |
CX_DEBUG_ENTER_FUNCTION();
|
|
335 |
|
|
336 |
mCameraDeviceControl->setMode(cameraMode);
|
|
337 |
|
|
338 |
// load settings whenever we change mode or start camera or switch camera
|
|
339 |
CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings);
|
|
340 |
if (settingsImp) {
|
|
341 |
settingsImp->loadSettings(mode());
|
|
342 |
}
|
|
343 |
|
|
344 |
if (cameraMode == Cxe::ImageMode) {
|
|
345 |
mVideoCaptureControl->deinit();
|
|
346 |
mStillCaptureControl->init();
|
|
347 |
} else {
|
|
348 |
mStillCaptureControl->deinit();
|
|
349 |
mVideoCaptureControl->init();
|
|
350 |
}
|
|
351 |
mFilenameGenerator->init(cameraMode);
|
|
352 |
|
|
353 |
CX_DEBUG_EXIT_FUNCTION();
|
|
354 |
}
|
|
355 |
|
|
356 |
// End of file
|