|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QCAMERA_H |
|
43 #define QCAMERA_H |
|
44 |
|
45 #include <QtCore/qstringlist.h> |
|
46 #include <QtCore/qpair.h> |
|
47 #include <QtCore/qsize.h> |
|
48 |
|
49 #include <qmediacontrol.h> |
|
50 #include <qmediaobject.h> |
|
51 #include <qmediaservice.h> |
|
52 |
|
53 #include <qmediaserviceprovider.h> |
|
54 |
|
55 QTM_BEGIN_NAMESPACE |
|
56 |
|
57 class QCameraControl; |
|
58 |
|
59 |
|
60 class QCameraPrivate; |
|
61 class Q_MEDIA_EXPORT QCamera : public QMediaObject |
|
62 { |
|
63 Q_OBJECT |
|
64 |
|
65 Q_ENUMS(CaptureMode State Error FocusStatus) |
|
66 |
|
67 Q_PROPERTY(CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged) |
|
68 Q_PROPERTY(qreal aperture READ aperture WRITE setManualAperture NOTIFY apertureChanged) |
|
69 Q_PROPERTY(qreal shutterSpeed READ shutterSpeed WRITE setManualShutterSpeed NOTIFY shutterSpeedChanged) |
|
70 Q_PROPERTY(int isoSensitivity READ isoSensitivity WRITE setManualIsoSensitivity NOTIFY isoSensitivityChanged) |
|
71 |
|
72 public: |
|
73 enum State { ActiveState, SuspendedState, StoppedState }; |
|
74 |
|
75 enum CaptureMode |
|
76 { |
|
77 CaptureDisabled = 0, |
|
78 CaptureStillImage = 0x1, |
|
79 CaptureVideo = 0x2 |
|
80 }; |
|
81 Q_DECLARE_FLAGS(CaptureModes, CaptureMode) |
|
82 |
|
83 enum Error |
|
84 { |
|
85 NoError, |
|
86 CameraError, |
|
87 NotReadyToCaptureError, |
|
88 InvalidRequestError, |
|
89 ServiceMissingError, |
|
90 NotSupportedFeatureError |
|
91 }; |
|
92 |
|
93 enum FlashMode { |
|
94 FlashOff = 0x1, |
|
95 FlashOn = 0x2, |
|
96 FlashAuto = 0x4, |
|
97 FlashRedEyeReduction = 0x8, |
|
98 FlashFill = 0x10 |
|
99 }; |
|
100 Q_DECLARE_FLAGS(FlashModes, FlashMode) |
|
101 |
|
102 enum FocusMode { |
|
103 ManualFocus = 0x1, |
|
104 HyperfocalFocus = 0x02, |
|
105 InfinityFocus = 0x04, |
|
106 AutoFocus = 0x8, |
|
107 ContinuousFocus = 0x10 |
|
108 }; |
|
109 Q_DECLARE_FLAGS(FocusModes, FocusMode) |
|
110 |
|
111 enum FocusStatus { |
|
112 FocusInitial, |
|
113 FocusRequested, |
|
114 FocusCanceled, |
|
115 FocusReached, |
|
116 FocusLost, |
|
117 FocusUnableToReach |
|
118 }; |
|
119 |
|
120 enum ExposureMode { |
|
121 ExposureManual = 0x1, |
|
122 ExposureAuto = 0x2, |
|
123 ExposureNight = 0x4, |
|
124 ExposureBacklight = 0x8, |
|
125 ExposureSpotlight = 0x10, |
|
126 ExposureSports = 0x20, |
|
127 ExposureSnow = 0x40, |
|
128 ExposureBeach = 0x80, |
|
129 ExposureLargeAperture = 0x100, |
|
130 ExposureSmallAperture = 0x200, |
|
131 ExposurePortrait = 0x400 |
|
132 }; |
|
133 Q_DECLARE_FLAGS(ExposureModes, ExposureMode) |
|
134 |
|
135 enum ExposureStatus { |
|
136 CorrectExposure, |
|
137 UnderExposure, |
|
138 OverExposure |
|
139 }; |
|
140 |
|
141 enum MeteringMode { |
|
142 MeteringAverage = 0x1, |
|
143 MeteringSpot = 0x2, |
|
144 MeteringMatrix = 0x4 |
|
145 }; |
|
146 Q_DECLARE_FLAGS(MeteringModes, MeteringMode) |
|
147 |
|
148 enum WhiteBalanceMode { |
|
149 WhiteBalanceManual = 0x1, |
|
150 WhiteBalanceAuto = 0x2, |
|
151 WhiteBalanceSunlight = 0x4, |
|
152 WhiteBalanceCloudy = 0x8, |
|
153 WhiteBalanceShade = 0x10, |
|
154 WhiteBalanceTungsten = 0x20, |
|
155 WhiteBalanceFluorescent = 0x40, |
|
156 WhiteBalanceIncandescent = 0x80, |
|
157 WhiteBalanceFlash = 0x100, |
|
158 WhiteBalanceSunset = 0x200 |
|
159 }; |
|
160 Q_DECLARE_FLAGS(WhiteBalanceModes, WhiteBalanceMode) |
|
161 |
|
162 Q_PROPERTY(QCamera::State state READ state NOTIFY stateChanged) |
|
163 |
|
164 QCamera(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); |
|
165 QCamera(const QByteArray& device, QObject *parent = 0); |
|
166 ~QCamera(); |
|
167 |
|
168 static QList<QByteArray> availableDevices(); |
|
169 static QString deviceDescription(const QByteArray &device); |
|
170 |
|
171 bool isAvailable() const; |
|
172 QtMedia::AvailabilityError availabilityError() const; |
|
173 |
|
174 State state() const; |
|
175 |
|
176 CaptureMode captureMode() const; |
|
177 CaptureModes supportedCaptureModes() const; |
|
178 |
|
179 FlashMode flashMode() const; |
|
180 void setFlashMode(FlashMode mode); |
|
181 FlashModes supportedFlashModes() const; |
|
182 bool isFlashReady() const; |
|
183 |
|
184 FocusMode focusMode() const; |
|
185 void setFocusMode(FocusMode mode); |
|
186 FocusModes supportedFocusModes() const; |
|
187 FocusStatus focusStatus() const; |
|
188 |
|
189 bool macroFocusingEnabled() const; |
|
190 bool isMacroFocusingSupported() const; |
|
191 void setMacroFocusingEnabled(bool); |
|
192 |
|
193 ExposureMode exposureMode() const; |
|
194 void setExposureMode(ExposureMode mode); |
|
195 ExposureModes supportedExposureModes() const; |
|
196 |
|
197 qreal exposureCompensation() const; |
|
198 void setExposureCompensation(qreal ev); |
|
199 |
|
200 MeteringMode meteringMode() const; |
|
201 void setMeteringMode(MeteringMode mode); |
|
202 MeteringModes supportedMeteringModes() const; |
|
203 |
|
204 WhiteBalanceMode whiteBalanceMode() const; |
|
205 void setWhiteBalanceMode(WhiteBalanceMode mode); |
|
206 WhiteBalanceModes supportedWhiteBalanceModes() const; |
|
207 int manualWhiteBalance() const; |
|
208 void setManualWhiteBalance(int colorTemperature); |
|
209 |
|
210 int isoSensitivity() const; |
|
211 QList<int> supportedIsoSensitivities(bool *continuous = 0) const; |
|
212 void setManualIsoSensitivity(int iso); |
|
213 void setAutoIsoSensitivity(); |
|
214 |
|
215 qreal aperture() const; |
|
216 QList<qreal> supportedApertures(bool *continuous = 0) const; |
|
217 void setManualAperture(qreal aperture); |
|
218 void setAutoAperture(); |
|
219 |
|
220 qreal shutterSpeed() const; |
|
221 QList<qreal> supportedShutterSpeeds(bool *continuous = 0) const; |
|
222 void setManualShutterSpeed(qreal seconds); |
|
223 void setAutoShutterSpeed(); |
|
224 |
|
225 qreal maximumOpticalZoom() const; |
|
226 qreal maximumDigitalZoom() const; |
|
227 qreal opticalZoom() const; |
|
228 qreal digitalZoom() const; |
|
229 |
|
230 void zoomTo(qreal opticalZoom, qreal digitalZoom); |
|
231 |
|
232 bool isExposureLocked() const; |
|
233 |
|
234 Error error() const; |
|
235 QString errorString() const; |
|
236 |
|
237 public Q_SLOTS: |
|
238 void start(); |
|
239 void stop(); |
|
240 |
|
241 void setCaptureMode(QCamera::CaptureMode mode); |
|
242 |
|
243 void lockExposure(); |
|
244 void unlockExposure(); |
|
245 |
|
246 void startFocusing(); |
|
247 void cancelFocusing(); |
|
248 |
|
249 Q_SIGNALS: |
|
250 void captureModeChanged(QCamera::CaptureMode); |
|
251 void flashReady(bool); |
|
252 void focusStatusChanged(QCamera::FocusStatus); |
|
253 void opticalZoomChanged(qreal); |
|
254 void digitalZoomChanged(qreal); |
|
255 |
|
256 void apertureChanged(qreal); |
|
257 void apertureRangeChanged(); |
|
258 void shutterSpeedChanged(qreal); |
|
259 void isoSensitivityChanged(int); |
|
260 |
|
261 void exposureLocked(); |
|
262 |
|
263 void focusReached(); |
|
264 void focusUnableToReach(); |
|
265 |
|
266 void stateChanged(QCamera::State); |
|
267 void error(QCamera::Error); |
|
268 |
|
269 private: |
|
270 Q_DISABLE_COPY(QCamera) |
|
271 Q_DECLARE_PRIVATE(QCamera) |
|
272 Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) |
|
273 Q_PRIVATE_SLOT(d_func(), void _q_updateFocusStatus(QCamera::FocusStatus)) |
|
274 }; |
|
275 |
|
276 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::CaptureModes) |
|
277 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::FlashModes) |
|
278 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::FocusModes) |
|
279 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::WhiteBalanceModes) |
|
280 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::MeteringModes) |
|
281 Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::ExposureModes) |
|
282 |
|
283 QTM_END_NAMESPACE |
|
284 |
|
285 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QCamera)::State) |
|
286 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QCamera)::Error) |
|
287 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QCamera)::FocusStatus) |
|
288 |
|
289 |
|
290 #endif // QCAMERA_H |