|
1 /* |
|
2 * Copyright (c) 2009 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 #ifndef CXESTILLCAPTURECONTROLSYMBIAN_H |
|
18 #define CXESTILLCAPTURECONTROLSYMBIAN_H |
|
19 |
|
20 #include <QList> |
|
21 #include <ecam.h> |
|
22 #include <QPixmap> |
|
23 #include <QVariant> |
|
24 #include <driveinfo.h> |
|
25 |
|
26 #include "cxestillcapturecontrol.h" |
|
27 #include "cxeautofocuscontrol.h" |
|
28 #include "cxesensoreventhandler.h" |
|
29 #include "cxestatemachine.h" |
|
30 #include "cxenamespace.h" |
|
31 #include "cxeerror.h" |
|
32 |
|
33 class CxeSoundPlayerSymbian; |
|
34 class CxeFilenameGenerator; |
|
35 class CxeFileSaveThread; |
|
36 class CxeCameraDevice; |
|
37 class MCameraBuffer; |
|
38 class CxeStillImageSymbian; |
|
39 class CxeImageDataQueue; |
|
40 class CxeImageDataQueueSymbian; |
|
41 class CxeViewfinderControl; |
|
42 class CxeSensorEventHandler; |
|
43 class CxeCameraDeviceControl; |
|
44 class CxeAutoFocusControl; |
|
45 class CxeSettings; |
|
46 class CxeQualityPresets; |
|
47 |
|
48 |
|
49 |
|
50 /** |
|
51 * Class CxeStillCaptureControlSymbian. |
|
52 * Inherits/implements CxeStillCaptureControl. |
|
53 */ |
|
54 class CxeStillCaptureControlSymbian : public CxeStillCaptureControl, |
|
55 public CxeStateMachine |
|
56 { |
|
57 Q_OBJECT |
|
58 |
|
59 public: // constructors |
|
60 |
|
61 CxeStillCaptureControlSymbian(CxeCameraDevice &cameraDevice, |
|
62 CxeViewfinderControl &viewfinderControl, |
|
63 CxeCameraDeviceControl &cameraDeviceControl, |
|
64 CxeFilenameGenerator &nameGenerator, |
|
65 CxeSensorEventHandler &sensorEventHandler, |
|
66 CxeAutoFocusControl &autoFocusControl, |
|
67 CxeSettings &settings, |
|
68 CxeQualityPresets &qualityPresets, |
|
69 CxeFileSaveThread &fileSaveThread); |
|
70 |
|
71 virtual ~CxeStillCaptureControlSymbian(); |
|
72 |
|
73 public: // from CxeStillCaptureControl |
|
74 |
|
75 void capture(); |
|
76 State state() const; |
|
77 int imageCount() const; |
|
78 void reset(); |
|
79 void cancelAll(); |
|
80 void setMode( CaptureMode mode ); |
|
81 CaptureMode mode() const; |
|
82 CxeStillImage &operator[]( int index ); |
|
83 CxeImageDataQueue &imageDataQueue(); |
|
84 QList<CxeImageDetails> supportedImageQualities(); |
|
85 int imagesLeft(); |
|
86 |
|
87 public slots: |
|
88 void init(); |
|
89 void deinit(); |
|
90 |
|
91 signals: |
|
92 void imagePrepareComplete(CxeError::Id error); |
|
93 void prepareZoomForStill(int ecamStillResolutionIndex); |
|
94 |
|
95 protected: // from CxeStateMachine |
|
96 void handleStateChanged( int newStateId, CxeError::Id error ); |
|
97 |
|
98 |
|
99 protected slots: |
|
100 // notifications when camera reference is changed |
|
101 void prepareForCameraDelete(); |
|
102 void handleCameraAllocated(CxeError::Id error); |
|
103 |
|
104 // notification for when camera is released |
|
105 void prepareForRelease(); |
|
106 |
|
107 // ECam events |
|
108 void handleCameraEvent( int eventUid, int error ); |
|
109 void handleImageData( MCameraBuffer *buffer, int error ); |
|
110 |
|
111 // settings call back |
|
112 void handleSettingValueChanged(const QString& settingId,QVariant newValue); |
|
113 |
|
114 // Autofocus events |
|
115 void handleAutofocusStateChanged(CxeAutoFocusControl::State newState, CxeError::Id error); |
|
116 |
|
117 // sensor events |
|
118 void handleSensorEvent(CxeSensorEventHandler::SensorType type,QVariant data); |
|
119 |
|
120 private: // helper functions |
|
121 |
|
122 CxeError::Id prepareFilename(CxeStillImageSymbian *stillImage); |
|
123 void setOrientation(QVariant sensorData); |
|
124 CxeStillImageSymbian* getImageForIndex(int index); |
|
125 CCamera::TFormat supportedStillFormat(Cxe::CameraIndex cameraIndex); |
|
126 int prepareStillSnapshot(); |
|
127 CxeError::Id getImageQualityDetails(CxeImageDetails &imageInfo); |
|
128 TSize getSnapshotSize() const; |
|
129 void handleSnapshotEvent(CxeError::Id error); |
|
130 QPixmap extractSnapshot(); |
|
131 void initializeStates(); |
|
132 void prepare(); |
|
133 void updateRemainingImagesCounter(); |
|
134 int calculateRemainingImages(int estimatedImagesize) ; |
|
135 |
|
136 private: // private data |
|
137 |
|
138 CxeImageDataQueueSymbian *mImageDataQueue; // own |
|
139 CxeCameraDevice &mCameraDevice; |
|
140 CxeViewfinderControl &mViewfinderControl; |
|
141 CxeCameraDeviceControl &mCameraDeviceControl; |
|
142 CxeFilenameGenerator &mFilenameGenerator; //! @todo could be shared with video capture control? |
|
143 CxeSensorEventHandler &mSensorEventHandler; |
|
144 CxeAutoFocusControl &mAutoFocusControl; |
|
145 CxeSettings &mSettings; |
|
146 CxeQualityPresets &mQualityPresets; |
|
147 CxeFileSaveThread &mFileSaveThread; |
|
148 CxeSoundPlayerSymbian *mCaptureSoundPlayer; |
|
149 CxeSoundPlayerSymbian *mAutoFocusSoundPlayer; |
|
150 CaptureMode mMode; |
|
151 CxeAutoFocusControl::State mAfState; |
|
152 QList<CxeStillImageSymbian*> mImages; |
|
153 int mNextSnapshotIndex; |
|
154 int mNextImageDataIndex; |
|
155 //still resolutions supported by ICM |
|
156 QList<CxeImageDetails> mIcmSupportedImageResolutions; |
|
157 //still resolutions supported by ecam |
|
158 QList<TSize> mECamSupportedImageResolutions; |
|
159 //current image quality details in use |
|
160 CxeImageDetails mCurrentImageDetails; |
|
161 |
|
162 private: // Helper class |
|
163 |
|
164 class CxeCameraBufferCleanup |
|
165 { |
|
166 public: |
|
167 CxeCameraBufferCleanup(MCameraBuffer* buffer) : mBuffer(buffer) {} |
|
168 ~CxeCameraBufferCleanup() { if (mBuffer) { mBuffer->Release(); } } |
|
169 |
|
170 private: |
|
171 Q_DISABLE_COPY(CxeCameraBufferCleanup) |
|
172 |
|
173 MCameraBuffer* mBuffer; |
|
174 }; |
|
175 }; |
|
176 |
|
177 #endif // CXESTILLCAPTURECONTROLSYMBIAN_H |