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 #include <QDebug> |
|
43 |
|
44 #include <experimental/qcamera.h> |
|
45 |
|
46 #include <qmediaobject_p.h> |
|
47 #include <experimental/qcameracontrol.h> |
|
48 #include <experimental/qcameraexposurecontrol.h> |
|
49 #include <experimental/qcamerafocuscontrol.h> |
|
50 #include <qmediarecordercontrol.h> |
|
51 #include <experimental/qimageprocessingcontrol.h> |
|
52 #include <experimental/qimagecapturecontrol.h> |
|
53 #include <qvideodevicecontrol.h> |
|
54 |
|
55 QTM_BEGIN_NAMESPACE |
|
56 |
|
57 /*! |
|
58 \class QCamera |
|
59 |
|
60 \preliminary |
|
61 \brief The QCamera class provides interface for system camera devices. |
|
62 |
|
63 \ingroup camera |
|
64 |
|
65 QCamera can be used with QVideoWidget for viewfinder display |
|
66 and QMediaRecorder for video recording. |
|
67 |
|
68 \code |
|
69 camera = new QCamera; |
|
70 viewFinder = new QVideoWidget(camera); |
|
71 viewFinder->show(); |
|
72 |
|
73 recorder = new QMediaRecorder(camera); |
|
74 imageCapture = new QStillImageCapture(camera); |
|
75 |
|
76 camera->start(); |
|
77 \endcode |
|
78 |
|
79 The Camera API of Qt Mobility is still in \bold Technology Preview. It has |
|
80 not undergone the same level of review and testing as the rest of the APIs. |
|
81 |
|
82 The API exposed by the classes in this component are not stable, and will |
|
83 undergo modification or removal prior to the final release of Qt Mobility. |
|
84 */ |
|
85 |
|
86 |
|
87 class QCameraPrivate : public QMediaObjectPrivate |
|
88 { |
|
89 Q_DECLARE_NON_CONST_PUBLIC(QCamera) |
|
90 public: |
|
91 void initControls(); |
|
92 |
|
93 QCameraControl *control; |
|
94 QCameraExposureControl *exposureControl; |
|
95 QCameraFocusControl *focusControl; |
|
96 QImageProcessingControl *imageControl; |
|
97 QImageCaptureControl *captureControl; |
|
98 |
|
99 QCamera::Error error; |
|
100 QString errorString; |
|
101 |
|
102 void _q_error(int error, const QString &errorString); |
|
103 void _q_updateFocusStatus(QCamera::FocusStatus); |
|
104 void unsetError() { error = QCamera::NoError; errorString.clear(); } |
|
105 }; |
|
106 |
|
107 void QCameraPrivate::_q_error(int error, const QString &errorString) |
|
108 { |
|
109 Q_Q(QCamera); |
|
110 |
|
111 this->error = QCamera::Error(error); |
|
112 this->errorString = errorString; |
|
113 |
|
114 emit q->error(this->error); |
|
115 } |
|
116 |
|
117 void QCameraPrivate::_q_updateFocusStatus(QCamera::FocusStatus status) |
|
118 { |
|
119 Q_Q(QCamera); |
|
120 |
|
121 emit q->focusStatusChanged(status); |
|
122 |
|
123 if (status == QCamera::FocusReached) |
|
124 emit q->focusReached(); |
|
125 else if (status == QCamera::FocusUnableToReach) |
|
126 emit q->focusUnableToReach(); |
|
127 } |
|
128 |
|
129 void QCameraPrivate::initControls() |
|
130 { |
|
131 Q_Q(QCamera); |
|
132 |
|
133 if (service) { |
|
134 control = qobject_cast<QCameraControl *>(service->control(QCameraControl_iid)); |
|
135 exposureControl = qobject_cast<QCameraExposureControl *>(service->control(QCameraExposureControl_iid)); |
|
136 focusControl = qobject_cast<QCameraFocusControl *>(service->control(QCameraFocusControl_iid)); |
|
137 imageControl = qobject_cast<QImageProcessingControl *>(service->control(QImageProcessingControl_iid)); |
|
138 captureControl = qobject_cast<QImageCaptureControl *>(service->control(QImageCaptureControl_iid)); |
|
139 |
|
140 if (control) { |
|
141 q->connect(control, SIGNAL(stateChanged(QCamera::State)), q, SIGNAL(stateChanged(QCamera::State))); |
|
142 q->connect(control, SIGNAL(captureModeChanged(QCamera::CaptureMode)), |
|
143 q, SIGNAL(captureModeChanged(QCamera::CaptureMode))); |
|
144 q->connect(control, SIGNAL(error(int,QString)), q, SLOT(_q_error(int,QString))); |
|
145 } |
|
146 |
|
147 error = QCamera::NoError; |
|
148 } else { |
|
149 control = 0; |
|
150 exposureControl = 0; |
|
151 focusControl = 0; |
|
152 imageControl = 0; |
|
153 captureControl = 0; |
|
154 |
|
155 error = QCamera::ServiceMissingError; |
|
156 errorString = QCamera::tr("The camera service is missing"); |
|
157 } |
|
158 |
|
159 if (exposureControl) { |
|
160 q->connect(exposureControl, SIGNAL(flashReady(bool)), q, SIGNAL(flashReady(bool))); |
|
161 q->connect(exposureControl, SIGNAL(exposureLocked()), q, SIGNAL(exposureLocked())); |
|
162 |
|
163 q->connect(exposureControl, SIGNAL(apertureChanged(qreal)), |
|
164 q, SIGNAL(apertureChanged(qreal))); |
|
165 q->connect(exposureControl, SIGNAL(apertureRangeChanged()), |
|
166 q, SIGNAL(apertureRangeChanged())); |
|
167 q->connect(exposureControl, SIGNAL(shutterSpeedChanged(qreal)), |
|
168 q, SIGNAL(shutterSpeedChanged(qreal))); |
|
169 q->connect(exposureControl, SIGNAL(isoSensitivityChanged(int)), |
|
170 q, SIGNAL(isoSensitivityChanged(int))); |
|
171 } |
|
172 |
|
173 if (focusControl) { |
|
174 q->connect(focusControl, SIGNAL(focusStatusChanged(QCamera::FocusStatus)), |
|
175 q, SLOT(_q_updateFocusStatus(QCamera::FocusStatus))); |
|
176 q->connect(focusControl, SIGNAL(opticalZoomChanged(qreal)), q, SIGNAL(opticalZoomChanged(qreal))); |
|
177 q->connect(focusControl, SIGNAL(digitalZoomChanged(qreal)), q, SIGNAL(digitalZoomChanged(qreal))); |
|
178 } |
|
179 } |
|
180 |
|
181 /*! |
|
182 Construct a QCamera from service \a provider and \a parent. |
|
183 */ |
|
184 |
|
185 QCamera::QCamera(QObject *parent, QMediaServiceProvider *provider): |
|
186 QMediaObject(*new QCameraPrivate, parent, provider->requestService(Q_MEDIASERVICE_CAMERA)) |
|
187 { |
|
188 Q_D(QCamera); |
|
189 d->initControls(); |
|
190 } |
|
191 |
|
192 /*! |
|
193 Construct a QCamera from device name \a device and \a parent. |
|
194 */ |
|
195 |
|
196 QCamera::QCamera(const QByteArray& device, QObject *parent): |
|
197 QMediaObject(*new QCameraPrivate, parent, |
|
198 QMediaServiceProvider::defaultServiceProvider()->requestService(Q_MEDIASERVICE_CAMERA, QMediaServiceProviderHint(device))) |
|
199 { |
|
200 Q_D(QCamera); |
|
201 d->initControls(); |
|
202 |
|
203 if (d->service != 0) { |
|
204 //pass device name to service |
|
205 QVideoDeviceControl *deviceControl = |
|
206 qobject_cast<QVideoDeviceControl*>(d->service->control(QVideoDeviceControl_iid)); |
|
207 |
|
208 if (deviceControl) { |
|
209 QString deviceName(device); |
|
210 |
|
211 for (int i=0; i<deviceControl->deviceCount(); i++) { |
|
212 if (deviceControl->deviceName(i) == deviceName) { |
|
213 deviceControl->setSelectedDevice(i); |
|
214 break; |
|
215 } |
|
216 } |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 /*! |
|
222 Destroys the camera object. |
|
223 */ |
|
224 |
|
225 QCamera::~QCamera() |
|
226 { |
|
227 } |
|
228 |
|
229 |
|
230 /*! |
|
231 Returne true if the camera service is ready to use. |
|
232 */ |
|
233 bool QCamera::isAvailable() const |
|
234 { |
|
235 if (d_func()->control != NULL) |
|
236 return true; |
|
237 else |
|
238 return false; |
|
239 } |
|
240 |
|
241 /*! |
|
242 Returns the error state of the camera service. |
|
243 */ |
|
244 |
|
245 QtMedia::AvailabilityError QCamera::availabilityError() const |
|
246 { |
|
247 if (d_func()->control != NULL) { |
|
248 if (d_func()->error == QCamera::NoError) |
|
249 return QtMedia::NoError; |
|
250 else |
|
251 return QtMedia::ResourceError; |
|
252 } else |
|
253 return QtMedia::ServiceMissingError; |
|
254 } |
|
255 |
|
256 /*! |
|
257 Returns the error state of the object. |
|
258 */ |
|
259 |
|
260 QCamera::Error QCamera::error() const |
|
261 { |
|
262 return d_func()->error; |
|
263 } |
|
264 |
|
265 /*! |
|
266 Returns a string describing a camera's error state. |
|
267 */ |
|
268 QString QCamera::errorString() const |
|
269 { |
|
270 return d_func()->errorString; |
|
271 } |
|
272 |
|
273 |
|
274 /*! |
|
275 Returns the supported capture modes. |
|
276 */ |
|
277 QCamera::CaptureModes QCamera::supportedCaptureModes() const |
|
278 { |
|
279 return d_func()->control ? d_func()->control->supportedCaptureModes() : QCamera::CaptureDisabled; |
|
280 } |
|
281 |
|
282 /*! |
|
283 \property QCamera::captureMode |
|
284 |
|
285 Returns the type of media (video or still images), |
|
286 the camera is configured to capture. |
|
287 */ |
|
288 |
|
289 QCamera::CaptureMode QCamera::captureMode() const |
|
290 { |
|
291 return d_func()->control ? d_func()->control->captureMode() : QCamera::CaptureDisabled; |
|
292 } |
|
293 |
|
294 void QCamera::setCaptureMode(QCamera::CaptureMode mode) |
|
295 { |
|
296 Q_D(QCamera); |
|
297 if (d->control) |
|
298 d->control->setCaptureMode(mode); |
|
299 } |
|
300 |
|
301 |
|
302 /*! |
|
303 Starts the camera. |
|
304 |
|
305 This can involve powering up the camera device and can be asynchronyous. |
|
306 |
|
307 State is changed to QCamera::ActiveState if camera is started |
|
308 succesfuly, otherwise error() signal is emited. |
|
309 */ |
|
310 |
|
311 void QCamera::start() |
|
312 { |
|
313 Q_D(QCamera); |
|
314 |
|
315 d->unsetError(); |
|
316 |
|
317 if (d->control) |
|
318 d->control->start(); |
|
319 else { |
|
320 d->errorString = tr("The camera service is missing"); |
|
321 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, |
|
322 Q_ARG(QCamera::Error, QCamera::ServiceMissingError)); |
|
323 } |
|
324 } |
|
325 |
|
326 /*! |
|
327 Stops the camera. |
|
328 */ |
|
329 |
|
330 void QCamera::stop() |
|
331 { |
|
332 Q_D(QCamera); |
|
333 |
|
334 d->unsetError(); |
|
335 |
|
336 if(d->control) |
|
337 d->control->stop(); |
|
338 else |
|
339 d->_q_error(QCamera::ServiceMissingError, tr("The camera service is missing")); |
|
340 } |
|
341 |
|
342 /*! |
|
343 Lock the exposure. |
|
344 */ |
|
345 |
|
346 void QCamera::lockExposure() |
|
347 { |
|
348 Q_D(QCamera); |
|
349 |
|
350 d->unsetError(); |
|
351 |
|
352 if(d->exposureControl) |
|
353 d->exposureControl->lockExposure(); |
|
354 else |
|
355 d->_q_error(NotSupportedFeatureError, tr("Exposure locking is not supported")); |
|
356 } |
|
357 |
|
358 /*! |
|
359 Unlock the exposure. |
|
360 */ |
|
361 |
|
362 void QCamera::unlockExposure() |
|
363 { |
|
364 Q_D(QCamera); |
|
365 |
|
366 d->unsetError(); |
|
367 |
|
368 if(d->exposureControl) |
|
369 d->exposureControl->unlockExposure(); |
|
370 } |
|
371 |
|
372 /*! |
|
373 Starts single or continuous autofocus. |
|
374 |
|
375 Does nothing in hyperfocal or infinity focus modes. |
|
376 |
|
377 If supported by camera, startFocusing() turns on the manual focusing notifications, |
|
378 otherwise it does nothing in manual mode. |
|
379 */ |
|
380 |
|
381 void QCamera::startFocusing() |
|
382 { |
|
383 Q_D(QCamera); |
|
384 |
|
385 d->unsetError(); |
|
386 |
|
387 if(d->focusControl) |
|
388 d->focusControl->startFocusing(); |
|
389 else |
|
390 d->_q_error(NotSupportedFeatureError, tr("Focus locking is not supported")); |
|
391 } |
|
392 |
|
393 /*! |
|
394 Cancels the single autofocus request or stops continuous focusing. |
|
395 |
|
396 Does nothing in hyperfocal or infinity focus modes. |
|
397 |
|
398 If supported by camera, startFocusing() turns off the manual focusing notifications, |
|
399 otherwise it does nothing in manual mode. |
|
400 */ |
|
401 |
|
402 void QCamera::cancelFocusing() |
|
403 { |
|
404 Q_D(QCamera); |
|
405 |
|
406 if(d->focusControl) |
|
407 d->focusControl->cancelFocusing(); |
|
408 } |
|
409 |
|
410 /*! |
|
411 Returns a list of camera device's available from the default service provider. |
|
412 */ |
|
413 |
|
414 QList<QByteArray> QCamera::availableDevices() |
|
415 { |
|
416 return QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA)); |
|
417 } |
|
418 |
|
419 /*! |
|
420 Returns the description of the \a device. |
|
421 */ |
|
422 |
|
423 QString QCamera::deviceDescription(const QByteArray &device) |
|
424 { |
|
425 return QMediaServiceProvider::defaultServiceProvider()->deviceDescription(QByteArray(Q_MEDIASERVICE_CAMERA), device); |
|
426 } |
|
427 |
|
428 QCamera::State QCamera::state() const |
|
429 { |
|
430 if(d_func()->control) |
|
431 return (QCamera::State)d_func()->control->state(); |
|
432 |
|
433 return QCamera::StoppedState; |
|
434 } |
|
435 |
|
436 /*! |
|
437 Returns the flash mode being used. |
|
438 */ |
|
439 |
|
440 QCamera::FlashMode QCamera::flashMode() const |
|
441 { |
|
442 return d_func()->exposureControl ? d_func()->exposureControl->flashMode() : QCamera::FlashOff; |
|
443 } |
|
444 |
|
445 /*! |
|
446 Set the flash mode to \a mode |
|
447 */ |
|
448 |
|
449 void QCamera::setFlashMode(QCamera::FlashMode mode) |
|
450 { |
|
451 if (d_func()->exposureControl) |
|
452 d_func()->exposureControl->setFlashMode(mode); |
|
453 } |
|
454 |
|
455 /*! |
|
456 Returns the flash modes available. |
|
457 */ |
|
458 |
|
459 QCamera::FlashModes QCamera::supportedFlashModes() const |
|
460 { |
|
461 return d_func()->exposureControl ? d_func()->exposureControl->supportedFlashModes() : QCamera::FlashOff; |
|
462 } |
|
463 |
|
464 /*! |
|
465 Returns true if flash is charged. |
|
466 */ |
|
467 |
|
468 bool QCamera::isFlashReady() const |
|
469 { |
|
470 return d_func()->exposureControl ? d_func()->exposureControl->isFlashReady() : false; |
|
471 } |
|
472 |
|
473 /*! |
|
474 Returns the focus mode being used. |
|
475 */ |
|
476 |
|
477 QCamera::FocusMode QCamera::focusMode() const |
|
478 { |
|
479 return d_func()->focusControl ? d_func()->focusControl->focusMode() : QCamera::AutoFocus; |
|
480 } |
|
481 |
|
482 /*! |
|
483 Set the focus mode to \a mode |
|
484 */ |
|
485 |
|
486 void QCamera::setFocusMode(QCamera::FocusMode mode) |
|
487 { |
|
488 if (d_func()->focusControl) |
|
489 d_func()->focusControl->setFocusMode(mode); |
|
490 } |
|
491 |
|
492 /*! |
|
493 Returns the focus modes available. |
|
494 */ |
|
495 |
|
496 QCamera::FocusModes QCamera::supportedFocusModes() const |
|
497 { |
|
498 return d_func()->focusControl ? d_func()->focusControl->supportedFocusModes() : QCamera::AutoFocus; |
|
499 } |
|
500 |
|
501 /*! |
|
502 Returns the focus status |
|
503 */ |
|
504 |
|
505 QCamera::FocusStatus QCamera::focusStatus() const |
|
506 { |
|
507 return d_func()->focusControl ? d_func()->focusControl->focusStatus() : QCamera::FocusInitial; |
|
508 } |
|
509 |
|
510 /*! |
|
511 Returns true if macro focusing enabled. |
|
512 */ |
|
513 |
|
514 bool QCamera::macroFocusingEnabled() const |
|
515 { |
|
516 return d_func()->focusControl ? d_func()->focusControl->macroFocusingEnabled() : false; |
|
517 } |
|
518 |
|
519 /*! |
|
520 Returns true if macro focusing is supported. |
|
521 */ |
|
522 |
|
523 bool QCamera::isMacroFocusingSupported() const |
|
524 { |
|
525 return d_func()->focusControl ? d_func()->focusControl->isMacroFocusingSupported() : false; |
|
526 } |
|
527 |
|
528 /*! |
|
529 Set macro focusing to \a enabled. |
|
530 */ |
|
531 |
|
532 void QCamera::setMacroFocusingEnabled(bool enabled) |
|
533 { |
|
534 if (d_func()->focusControl) |
|
535 d_func()->focusControl->setMacroFocusingEnabled(enabled); |
|
536 } |
|
537 |
|
538 /*! |
|
539 Returns the exposure mode being used. |
|
540 */ |
|
541 |
|
542 QCamera::ExposureMode QCamera::exposureMode() const |
|
543 { |
|
544 return d_func()->exposureControl ? d_func()->exposureControl->exposureMode() : QCamera::ExposureAuto; |
|
545 } |
|
546 |
|
547 /*! |
|
548 Set exposure mode to \a mode |
|
549 */ |
|
550 |
|
551 void QCamera::setExposureMode(QCamera::ExposureMode mode) |
|
552 { |
|
553 if (d_func()->exposureControl) |
|
554 d_func()->exposureControl->setExposureMode(mode); |
|
555 } |
|
556 |
|
557 /*! |
|
558 Return the exposure modes available. |
|
559 */ |
|
560 |
|
561 QCamera::ExposureModes QCamera::supportedExposureModes() const |
|
562 { |
|
563 return d_func()->exposureControl ? d_func()->exposureControl->supportedExposureModes() : QCamera::ExposureAuto; |
|
564 } |
|
565 |
|
566 /*! |
|
567 Returns the exposure compensation. |
|
568 */ |
|
569 |
|
570 qreal QCamera::exposureCompensation() const |
|
571 { |
|
572 return d_func()->exposureControl ? d_func()->exposureControl->exposureCompensation() : 0; |
|
573 } |
|
574 |
|
575 /*! |
|
576 Sets the exposure compensation to \a ev |
|
577 */ |
|
578 |
|
579 void QCamera::setExposureCompensation(qreal ev) |
|
580 { |
|
581 if (d_func()->exposureControl) |
|
582 d_func()->exposureControl->setExposureCompensation(ev); |
|
583 } |
|
584 |
|
585 /*! |
|
586 Returns the metering mode being used. |
|
587 */ |
|
588 |
|
589 QCamera::MeteringMode QCamera::meteringMode() const |
|
590 { |
|
591 return d_func()->exposureControl ? d_func()->exposureControl->meteringMode() : QCamera::MeteringMatrix; |
|
592 } |
|
593 |
|
594 /*! |
|
595 Sets the metering mode to \a mode. |
|
596 */ |
|
597 |
|
598 void QCamera::setMeteringMode(QCamera::MeteringMode mode) |
|
599 { |
|
600 if (d_func()->exposureControl) |
|
601 d_func()->exposureControl->setMeteringMode(mode); |
|
602 } |
|
603 |
|
604 /*! |
|
605 Returns the metering modes available. |
|
606 */ |
|
607 |
|
608 QCamera::MeteringModes QCamera::supportedMeteringModes() const |
|
609 { |
|
610 return d_func()->exposureControl ? d_func()->exposureControl->supportedMeteringModes() : QCamera::MeteringMatrix; |
|
611 } |
|
612 |
|
613 /*! |
|
614 Returns the white balance mode being used. |
|
615 */ |
|
616 |
|
617 QCamera::WhiteBalanceMode QCamera::whiteBalanceMode() const |
|
618 { |
|
619 return d_func()->imageControl ? d_func()->imageControl->whiteBalanceMode() : QCamera::WhiteBalanceAuto; |
|
620 } |
|
621 |
|
622 /*! |
|
623 Sets the white balance to \a mode. |
|
624 */ |
|
625 |
|
626 void QCamera::setWhiteBalanceMode(QCamera::WhiteBalanceMode mode) |
|
627 { |
|
628 if (d_func()->imageControl) |
|
629 d_func()->imageControl->setWhiteBalanceMode(mode); |
|
630 } |
|
631 |
|
632 /*! |
|
633 Returns the white balance modes available. |
|
634 */ |
|
635 |
|
636 QCamera::WhiteBalanceModes QCamera::supportedWhiteBalanceModes() const |
|
637 { |
|
638 return d_func()->imageControl ? d_func()->imageControl->supportedWhiteBalanceModes() : QCamera::WhiteBalanceAuto; |
|
639 } |
|
640 |
|
641 /*! |
|
642 Returns the current color temperature if the |
|
643 manual white balance is active, otherwise the |
|
644 return value is undefined. |
|
645 */ |
|
646 |
|
647 int QCamera::manualWhiteBalance() const |
|
648 { |
|
649 return d_func()->imageControl ? d_func()->imageControl->manualWhiteBalance() : -1; |
|
650 } |
|
651 |
|
652 /*! |
|
653 Sets manual white balance to \a colorTemperature |
|
654 */ |
|
655 |
|
656 void QCamera::setManualWhiteBalance(int colorTemperature) |
|
657 { |
|
658 if (d_func()->imageControl) |
|
659 d_func()->imageControl->setManualWhiteBalance(colorTemperature); |
|
660 } |
|
661 |
|
662 /*! |
|
663 Returns the ISO sensitivity. |
|
664 */ |
|
665 |
|
666 int QCamera::isoSensitivity() const |
|
667 { |
|
668 return d_func()->exposureControl ? d_func()->exposureControl->isoSensitivity() : -1; |
|
669 } |
|
670 |
|
671 /*! |
|
672 Returns the list of ISO senitivities camera supports. |
|
673 |
|
674 If the camera supports arbitrary ISO sensitivities within the supported range, |
|
675 *\a continuous is set to true, otherwise *\a continuous is set to false. |
|
676 */ |
|
677 QList<int> QCamera::supportedIsoSensitivities(bool *continuous) const |
|
678 { |
|
679 if (continuous) |
|
680 *continuous = 0; |
|
681 |
|
682 return d_func()->exposureControl ? d_func()->exposureControl->supportedIsoSensitivities(continuous) |
|
683 : QList<int>(); |
|
684 } |
|
685 |
|
686 /*! |
|
687 Sets the manual sensitivity to \a iso |
|
688 */ |
|
689 |
|
690 void QCamera::setManualIsoSensitivity(int iso) |
|
691 { |
|
692 if (d_func()->exposureControl) |
|
693 d_func()->exposureControl->setManualIsoSensitivity(iso); |
|
694 } |
|
695 |
|
696 /*! |
|
697 Turn on auto sensitivity |
|
698 */ |
|
699 |
|
700 void QCamera::setAutoIsoSensitivity() |
|
701 { |
|
702 if (d_func()->exposureControl) |
|
703 d_func()->exposureControl->setAutoIsoSensitivity(); |
|
704 } |
|
705 |
|
706 /*! |
|
707 \property QCamera::shutterSpeed |
|
708 \brief The effective length of time the shutter is open in seconds. |
|
709 */ |
|
710 |
|
711 /*! |
|
712 \fn QCamera::shutterSpeedChanged(qreal speed) |
|
713 |
|
714 Signals that a camera's shutter \a speed has changed. |
|
715 */ |
|
716 |
|
717 /*! |
|
718 \property QCamera::isoSensitivity |
|
719 \brief The sensor ISO sensitivity. Lower sensitivity, the noise is lower, but more light is needed. |
|
720 */ |
|
721 |
|
722 /*! |
|
723 \property QCamera::aperture |
|
724 \brief Lens aperture is specified as an F number, the ratio of the focal length to effective aperture diameter. |
|
725 */ |
|
726 |
|
727 qreal QCamera::aperture() const |
|
728 { |
|
729 return d_func()->exposureControl ? d_func()->exposureControl->aperture() : -1.0; |
|
730 } |
|
731 |
|
732 /*! |
|
733 Returns the list of aperture values camera supports. |
|
734 The apertures list can change depending on the focal length, |
|
735 in such a case the apertureRangeChanged() signal is emited. |
|
736 |
|
737 If the camera supports arbitrary aperture values within the supported range, |
|
738 *\a continuous is set to true, otherwise *\a continuous is set to false. |
|
739 */ |
|
740 QList<qreal> QCamera::supportedApertures(bool * continuous) const |
|
741 { |
|
742 if (continuous) |
|
743 *continuous = 0; |
|
744 |
|
745 return d_func()->exposureControl ? \ |
|
746 d_func()->exposureControl->supportedApertures(continuous) : QList<qreal>(); |
|
747 } |
|
748 |
|
749 /*! |
|
750 Sets the aperture to \a aperture |
|
751 */ |
|
752 |
|
753 void QCamera::setManualAperture(qreal aperture) |
|
754 { |
|
755 if (d_func()->exposureControl) |
|
756 d_func()->exposureControl->setManualAperture(aperture); |
|
757 } |
|
758 |
|
759 /*! |
|
760 Turn on auto aperture |
|
761 */ |
|
762 |
|
763 void QCamera::setAutoAperture() |
|
764 { |
|
765 if (d_func()->exposureControl) |
|
766 d_func()->exposureControl->setAutoAperture(); |
|
767 } |
|
768 |
|
769 /*! |
|
770 Return the current shutter speed in seconds. |
|
771 */ |
|
772 |
|
773 qreal QCamera::shutterSpeed() const |
|
774 { |
|
775 return d_func()->exposureControl ? d_func()->exposureControl->shutterSpeed() : -1; |
|
776 } |
|
777 |
|
778 /*! |
|
779 Returns the list of shutter speed values in seconds camera supports. |
|
780 |
|
781 If the camera supports arbitrary shutter speed values within the supported range, |
|
782 *\a continuous is set to true, otherwise *\a continuous is set to false. |
|
783 */ |
|
784 QList<qreal> QCamera::supportedShutterSpeeds(bool *continuous) const |
|
785 { |
|
786 if (continuous) |
|
787 *continuous = false; |
|
788 |
|
789 return d_func()->exposureControl ? |
|
790 d_func()->exposureControl->supportedShutterSpeeds(continuous) : QList<qreal>(); |
|
791 } |
|
792 |
|
793 /*! |
|
794 Set the shutter speed to \a seconds |
|
795 */ |
|
796 |
|
797 void QCamera::setManualShutterSpeed(qreal seconds) |
|
798 { |
|
799 if (d_func()->exposureControl) |
|
800 d_func()->exposureControl->setManualShutterSpeed(seconds); |
|
801 } |
|
802 |
|
803 /*! |
|
804 Turn on auto shutter speed |
|
805 */ |
|
806 |
|
807 void QCamera::setAutoShutterSpeed() |
|
808 { |
|
809 if (d_func()->exposureControl) |
|
810 d_func()->exposureControl->setAutoShutterSpeed(); |
|
811 } |
|
812 |
|
813 /*! |
|
814 Returns the maximum optical zoom |
|
815 */ |
|
816 |
|
817 qreal QCamera::maximumOpticalZoom() const |
|
818 { |
|
819 return d_func()->focusControl ? d_func()->focusControl->maximumOpticalZoom() : 1.0; |
|
820 } |
|
821 |
|
822 /*! |
|
823 Returns the maximum digital zoom |
|
824 */ |
|
825 |
|
826 qreal QCamera::maximumDigitalZoom() const |
|
827 { |
|
828 return d_func()->focusControl ? d_func()->focusControl->maximumDigitalZoom() : 1.0; |
|
829 } |
|
830 |
|
831 /*! |
|
832 Returns the current optical zoom value. |
|
833 |
|
834 \sa QCamera::opticalZoomChanged(qreal), QCamera::digitalZoom() |
|
835 */ |
|
836 |
|
837 qreal QCamera::opticalZoom() const |
|
838 { |
|
839 return d_func()->focusControl ? d_func()->focusControl->opticalZoom() : 1.0; |
|
840 } |
|
841 |
|
842 /*! |
|
843 Returns the current digital zoom value. |
|
844 |
|
845 \sa QCamera::digitalZoomChanged(qreal), QCamera::opticalZoom() |
|
846 */ |
|
847 qreal QCamera::digitalZoom() const |
|
848 { |
|
849 return d_func()->focusControl ? d_func()->focusControl->digitalZoom() : 1.0; |
|
850 } |
|
851 |
|
852 |
|
853 /*! |
|
854 Set the camera \a optical and \a digital zoom values. |
|
855 */ |
|
856 void QCamera::zoomTo(qreal optical, qreal digital) |
|
857 { |
|
858 if (d_func()->focusControl) |
|
859 d_func()->focusControl->zoomTo(optical, digital); |
|
860 else |
|
861 d_func()->_q_error(NotSupportedFeatureError, tr("The camera doesn't support zooming.")); |
|
862 |
|
863 } |
|
864 |
|
865 /*! |
|
866 Return true if exposure locked. |
|
867 */ |
|
868 |
|
869 bool QCamera::isExposureLocked() const |
|
870 { |
|
871 return d_func()->exposureControl ? d_func()->exposureControl->isExposureLocked() : true; |
|
872 } |
|
873 |
|
874 /*! |
|
875 \enum QCamera::State |
|
876 \value ActiveState The camera has been started and can produce data. |
|
877 \value SuspendedState The camera is temporary not available, |
|
878 usually as a result of higher priority client requested |
|
879 the camera device. |
|
880 \value StoppedState The camera has been stopped. |
|
881 */ |
|
882 |
|
883 /*! |
|
884 \enum QCamera::FlashMode |
|
885 |
|
886 \value FlashOff Flash is Off. |
|
887 \value FlashOn Flash is On. |
|
888 \value FlashAuto Automatic flash. |
|
889 \value FlashRedEyeReduction Red eye reduction flash. |
|
890 \value FlashFill Use flash to fillin shadows. |
|
891 */ |
|
892 |
|
893 /*! |
|
894 \enum QCamera::FocusMode |
|
895 |
|
896 \value ManualFocus Manual focus mode. |
|
897 \value AutoFocus One-shot auto focus mode. |
|
898 \value ContinuousFocus Continuous auto focus mode. |
|
899 \value InfinityFocus Focus strictly to infinity. |
|
900 \value HyperfocalFocus Focus to hyperfocal distance, with with the maximum depth of field achieved. |
|
901 All objects at distances from half of this |
|
902 distance out to infinity will be acceptably sharp. |
|
903 */ |
|
904 |
|
905 /*! |
|
906 \enum QCamera::FocusStatus |
|
907 |
|
908 \value FocusIntial The initial focus state. |
|
909 \value FocusRequested Focus request is in progress. |
|
910 \value FocusCanceled The focus request was canceled. |
|
911 \value FocusReached Focus has been reached. |
|
912 \value FocusLost Focus has been lost. |
|
913 \value FocusUnableToReach Unable to achieve focus. |
|
914 |
|
915 When the QCamera::InfinityFocus or QCamera::HyperfocalFocus mode |
|
916 is requested, the focus status changes to QCamera::FocusRequested |
|
917 until the requested state is reached |
|
918 and stays in the QCamera::FocusReached status after. |
|
919 |
|
920 In manual focusing mode the focus stays in the QCamera::FocusReached status, |
|
921 or, when supported by camera, QCamera::FocusLost and QCamera::FocusReached values |
|
922 could be used for manual focus notifications. |
|
923 |
|
924 In autofocus mode, on focus request the status changes to QCamera::FocusRequested, |
|
925 and then depending on request results the focus status |
|
926 changes to QCamera::FocusReached, QCamera::FocusUnableToReach or QCamera::FocusCanceled. |
|
927 |
|
928 In countinous autofocus mode, the status changes to QCamera::FocusRequested, |
|
929 and since the focus is reached is stays in QCamera::FocusReached and QCamera::FocusLost states |
|
930 until continous focusing is canceled with cancelAutofocus() or setFocusMode(). |
|
931 */ |
|
932 |
|
933 /*! |
|
934 \enum QCamera::ExposureMode |
|
935 |
|
936 \value ExposureManual Manual mode. |
|
937 \value ExposureAuto Automatic mode. |
|
938 \value ExposureNight Night mode. |
|
939 \value ExposureBacklight Backlight exposure mode. |
|
940 \value ExposureSpotlight Spotlight exposure mode. |
|
941 \value ExposureSports Spots exposure mode. |
|
942 \value ExposureSnow Snow exposure mode. |
|
943 \value ExposureBeach Beach exposure mode. |
|
944 \value ExposureLargeAperture Use larger aperture with small depth of field. |
|
945 \value ExposureSmallAperture Use smaller aperture. |
|
946 \value ExposurePortrait Portrait exposure mode. |
|
947 */ |
|
948 |
|
949 /*! |
|
950 \enum QCamera::ExposureStatus |
|
951 |
|
952 \value CorrectExposure The exposure is correct. |
|
953 \value UnderExposure The photo will be underexposed. |
|
954 \value OverExposure The photo will be overexposed. |
|
955 */ |
|
956 |
|
957 /*! |
|
958 \enum QCamera::MeteringMode |
|
959 |
|
960 \value MeteringAverage Center weighted average metering mode. |
|
961 \value MeteringSpot Spot metering mode. |
|
962 \value MeteringMatrix Matrix metering mode. |
|
963 */ |
|
964 |
|
965 /*! |
|
966 \enum QCamera::WhiteBalanceMode |
|
967 |
|
968 \value WhiteBalanceManual Manual white balance. In this mode the white balance should be set with |
|
969 setManualWhiteBalance() |
|
970 \value WhiteBalanceAuto Auto white balance mode. |
|
971 \value WhiteBalanceSunlight Sunlight white balance mode. |
|
972 \value WhiteBalanceCloudy Cloudy white balance mode. |
|
973 \value WhiteBalanceShade Shade white balance mode. |
|
974 \value WhiteBalanceTungsten Tungsten white balance mode. |
|
975 \value WhiteBalanceFluorescent Fluorescent white balance mode. |
|
976 \value WhiteBalanceIncandescent Incandescent white balance mode. |
|
977 \value WhiteBalanceFlash Flash white balance mode. |
|
978 \value WhiteBalanceSunset Sunset white balance mode. |
|
979 */ |
|
980 |
|
981 /*! |
|
982 \property QCamera::state |
|
983 \brief The current state of the camera object. |
|
984 */ |
|
985 |
|
986 /*! |
|
987 \fn void QCamera::stateChanged(State state) |
|
988 |
|
989 Signal emitted when \a state of the Camera object has changed. |
|
990 */ |
|
991 |
|
992 /*! |
|
993 \fn void QCamera::exposureLocked() |
|
994 |
|
995 Signal emitted when exposure locked. |
|
996 */ |
|
997 |
|
998 /*! |
|
999 \fn void QCamera::focusStatusChanged(FocusStatus status) |
|
1000 |
|
1001 Signal emitted when focus \a status changed. |
|
1002 */ |
|
1003 |
|
1004 /*! |
|
1005 \fn void QCamera::flashReady(bool ready) |
|
1006 |
|
1007 Signal emitted when flash status changed, flash is ready if \a ready true. |
|
1008 */ |
|
1009 |
|
1010 /*! |
|
1011 \fn void QCamera::zoomValueChanged(qreal value) |
|
1012 |
|
1013 Signal emitted when zoom value changes to new \a value. |
|
1014 */ |
|
1015 |
|
1016 /*! |
|
1017 \fn void QCamera::apertureChanged(qreal value) |
|
1018 |
|
1019 Signal emitted when aperature changes to \a value. |
|
1020 */ |
|
1021 |
|
1022 /*! |
|
1023 \fn void QCamera::apertureRangeChanged() |
|
1024 |
|
1025 Signal emitted when aperature range has changed. |
|
1026 */ |
|
1027 |
|
1028 /*! |
|
1029 \fn QCamera::imageCaptured(const QString &fileName, const QImage &preview) |
|
1030 |
|
1031 Signals that an image intendec to be saved to to \a fileName |
|
1032 has been captured and a \a preview is available. |
|
1033 */ |
|
1034 |
|
1035 |
|
1036 /*! |
|
1037 \fn QCamera::imageSaved(const QString &fileName) |
|
1038 |
|
1039 Signals that an captured image has been saved to \a fileName. |
|
1040 */ |
|
1041 |
|
1042 |
|
1043 /*! |
|
1044 \fn void QCamera::isoSensitivityChanged(int value) |
|
1045 |
|
1046 Signal emitted when sensitivity changes to \a value. |
|
1047 */ |
|
1048 |
|
1049 /*! |
|
1050 \enum QCamera::Error |
|
1051 |
|
1052 \value NoError No errors have occurred. |
|
1053 \value CameraError An error has occurred. |
|
1054 \value NotReadyToCaptureError System resource not available. |
|
1055 \value InvalidRequestError System resource doesn't support functionality. |
|
1056 \value ServiceMissingError No service available. |
|
1057 \value NotSupportedFeatureError The feature is not supported. |
|
1058 */ |
|
1059 |
|
1060 /*! |
|
1061 \fn void QCamera::error(QCamera::Error value) |
|
1062 |
|
1063 Signal emitted when error state changes to \a value. |
|
1064 */ |
|
1065 |
|
1066 |
|
1067 /*! |
|
1068 \fn void QCamera::focusReached() |
|
1069 |
|
1070 Signals the focus was reached. |
|
1071 This signal is emited after focusStatus changes to QCamera::FocusReached state. |
|
1072 */ |
|
1073 |
|
1074 /*! |
|
1075 \fn void QCamera::focusUnableToReach() |
|
1076 |
|
1077 Signals the focus was unable to reach. |
|
1078 This signal is emited after focusStatus changes to QCamera::FocusUnableToReach state. |
|
1079 */ |
|
1080 |
|
1081 #include "moc_qcamera.cpp" |
|
1082 QTM_END_NAMESPACE |
|