summaryrefslogtreecommitdiffstats
path: root/src/multimedia/camera
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2012-01-04 16:05:55 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-05 01:13:44 +0100
commit502d3c8eb353f45f988e371aa6d7938d5ec9d51e (patch)
treef8f2108e825bc13755aad7ae6cef6f9c044ffba7 /src/multimedia/camera
parent6ee1977d60b131ae00919e1f37796c1efc4906f7 (diff)
Restructure the source code a little.
Change-Id: I995b0fb33bdda7f01bf6266c1c50a1b17eba6760 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
Diffstat (limited to 'src/multimedia/camera')
-rw-r--r--src/multimedia/camera/camera.pri16
-rw-r--r--src/multimedia/camera/qcamera.cpp1035
-rw-r--r--src/multimedia/camera/qcamera.h238
-rw-r--r--src/multimedia/camera/qcameraexposure.cpp646
-rw-r--r--src/multimedia/camera/qcameraexposure.h185
-rw-r--r--src/multimedia/camera/qcamerafocus.cpp478
-rw-r--r--src/multimedia/camera/qcamerafocus.h183
-rw-r--r--src/multimedia/camera/qcameraimagecapture.cpp681
-rw-r--r--src/multimedia/camera/qcameraimagecapture.h170
-rw-r--r--src/multimedia/camera/qcameraimageprocessing.cpp365
-rw-r--r--src/multimedia/camera/qcameraimageprocessing.h124
11 files changed, 4121 insertions, 0 deletions
diff --git a/src/multimedia/camera/camera.pri b/src/multimedia/camera/camera.pri
new file mode 100644
index 000000000..be7868cd4
--- /dev/null
+++ b/src/multimedia/camera/camera.pri
@@ -0,0 +1,16 @@
+INCLUDEPATH += camera
+
+PUBLIC_HEADERS += \
+ camera/qcamera.h \
+ camera/qcameraimagecapture.h \
+ camera/qcameraexposure.h \
+ camera/qcamerafocus.h \
+ camera/qcameraimageprocessing.h
+
+SOURCES += \
+ camera/qcamera.cpp \
+ camera/qcameraexposure.cpp \
+ camera/qcamerafocus.cpp \
+ camera/qcameraimageprocessing.cpp \
+ camera/qcameraimagecapture.cpp
+
diff --git a/src/multimedia/camera/qcamera.cpp b/src/multimedia/camera/qcamera.cpp
new file mode 100644
index 000000000..8ba3aa6ee
--- /dev/null
+++ b/src/multimedia/camera/qcamera.cpp
@@ -0,0 +1,1035 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvideosurfaceoutput_p.h"
+#include "qmediaobject_p.h"
+
+#include <qcamera.h>
+#include <qcameracontrol.h>
+#include <qcameralockscontrol.h>
+#include <qcameraexposurecontrol.h>
+#include <qcamerafocuscontrol.h>
+#include <qmediarecordercontrol.h>
+#include <qcameraimageprocessingcontrol.h>
+#include <qcameraimagecapturecontrol.h>
+#include <qvideodevicecontrol.h>
+
+#include <QDebug>
+
+namespace
+{
+class CameraRegisterMetaTypes
+{
+public:
+ CameraRegisterMetaTypes()
+ {
+ qRegisterMetaType<QCamera::Error>("QCamera::Error");
+ qRegisterMetaType<QCamera::State>("QCamera::State");
+ qRegisterMetaType<QCamera::Status>("QCamera::Status");
+ qRegisterMetaType<QCamera::CaptureMode>("QCamera::CaptureMode");
+ qRegisterMetaType<QCamera::LockType>("QCamera::LockType");
+ qRegisterMetaType<QCamera::LockStatus>("QCamera::LockStatus");
+ qRegisterMetaType<QCamera::LockChangeReason>("QCamera::LockChangeReason");
+ }
+} _registerCameraMetaTypes;
+}
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCamera
+
+
+ \brief The QCamera class provides interface for system camera devices.
+
+ \inmodule QtMultimedia
+ \ingroup camera
+ \since 1.1
+
+ QCamera can be used with QVideoWidget for viewfinder display,
+ QMediaRecorder for video recording and QCameraImageCapture for image taking.
+
+ \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control
+
+*/
+
+
+class QCameraPrivate : public QMediaObjectPrivate
+{
+ Q_DECLARE_NON_CONST_PUBLIC(QCamera)
+public:
+ QCameraPrivate():
+ QMediaObjectPrivate(),
+ provider(0),
+ control(0),
+ deviceControl(0),
+ viewfinder(0),
+ capture(0),
+ state(QCamera::UnloadedState),
+ error(QCamera::NoError),
+ supportedLocks(QCamera::NoLock),
+ requestedLocks(QCamera::NoLock),
+ lockStatus(QCamera::Unlocked),
+ lockChangeReason(QCamera::UserRequest),
+ supressLockChangedSignal(false),
+ restartPending(false)
+ {
+ }
+
+ void initControls();
+
+ QMediaServiceProvider *provider;
+
+ QCameraControl *control;
+ QVideoDeviceControl *deviceControl;
+ QCameraLocksControl *locksControl;
+
+ QCameraExposure *cameraExposure;
+ QCameraFocus *cameraFocus;
+ QCameraImageProcessing *imageProcessing;
+
+ QObject *viewfinder;
+ QObject *capture;
+
+ QCamera::State state;
+
+ QCamera::Error error;
+ QString errorString;
+
+ QCamera::LockTypes supportedLocks;
+ QCamera::LockTypes requestedLocks;
+
+ QCamera::LockStatus lockStatus;
+ QCamera::LockChangeReason lockChangeReason;
+ bool supressLockChangedSignal;
+
+ bool restartPending;
+
+ QVideoSurfaceOutput surfaceViewfinder;
+
+ void _q_error(int error, const QString &errorString);
+ void unsetError() { error = QCamera::NoError; errorString.clear(); }
+
+ void setState(QCamera::State);
+
+ void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
+ void _q_updateState(QCamera::State newState);
+ void _q_preparePropertyChange(int changeType);
+ void _q_restartCamera();
+ void updateLockStatus();
+};
+
+
+void QCameraPrivate::_q_error(int error, const QString &errorString)
+{
+ Q_Q(QCamera);
+
+ this->error = QCamera::Error(error);
+ this->errorString = errorString;
+
+ qWarning() << "Camera error:" << errorString;
+
+ emit q->error(this->error);
+}
+
+void QCameraPrivate::setState(QCamera::State newState)
+{
+ Q_Q(QCamera);
+
+ unsetError();
+
+ if (!control) {
+ _q_error(QCamera::ServiceMissingError, q_ptr->tr("The camera service is missing"));
+ return;
+ }
+
+ if (state == newState)
+ return;
+
+ restartPending = false;
+ state = newState;
+ control->setState(state);
+ emit q->stateChanged(state);
+}
+
+void QCameraPrivate::_q_updateState(QCamera::State newState)
+{
+ Q_Q(QCamera);
+
+ //omit changins state to Loaded when the camera is temporarily
+ //stopped to apply shanges
+ if (restartPending)
+ return;
+
+ if (newState != state) {
+ qDebug() << "Camera state changed:" << newState;
+ state = newState;
+ emit q->stateChanged(state);
+ }
+}
+
+void QCameraPrivate::_q_preparePropertyChange(int changeType)
+{
+ if (!control)
+ return;
+
+ QCamera::Status status = control->status();
+
+ //all the changes are allowed until the camera is starting
+ if (control->state() != QCamera::ActiveState)
+ return;
+
+ if (control->canChangeProperty(QCameraControl::PropertyChangeType(changeType), status))
+ return;
+
+ restartPending = true;
+ control->setState(QCamera::LoadedState);
+ QMetaObject::invokeMethod(q_ptr, "_q_restartCamera", Qt::QueuedConnection);
+}
+
+void QCameraPrivate::_q_restartCamera()
+{
+ if (restartPending) {
+ restartPending = false;
+ control->setState(QCamera::ActiveState);
+ }
+}
+
+void QCameraPrivate::initControls()
+{
+ Q_Q(QCamera);
+
+ supportedLocks = 0;
+
+ if (service) {
+ control = qobject_cast<QCameraControl *>(service->requestControl(QCameraControl_iid));
+ locksControl = qobject_cast<QCameraLocksControl *>(service->requestControl(QCameraLocksControl_iid));
+ deviceControl = qobject_cast<QVideoDeviceControl*>(service->requestControl(QVideoDeviceControl_iid));
+
+ if (control) {
+ q->connect(control, SIGNAL(stateChanged(QCamera::State)), q, SLOT(_q_updateState(QCamera::State)));
+ q->connect(control, SIGNAL(statusChanged(QCamera::Status)), q, SIGNAL(statusChanged(QCamera::Status)));
+ q->connect(control, SIGNAL(captureModeChanged(QCamera::CaptureMode)),
+ q, SIGNAL(captureModeChanged(QCamera::CaptureMode)));
+ q->connect(control, SIGNAL(error(int,QString)), q, SLOT(_q_error(int,QString)));
+
+ }
+
+ if (locksControl) {
+ q->connect(locksControl, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)),
+ q, SLOT(_q_updateLockStatus(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
+ supportedLocks = locksControl->supportedLocks();
+ }
+
+ error = QCamera::NoError;
+ } else {
+ control = 0;
+ locksControl = 0;
+ deviceControl = 0;
+
+ error = QCamera::ServiceMissingError;
+ errorString = QCamera::tr("The camera service is missing");
+ }
+}
+
+void QCameraPrivate::updateLockStatus()
+{
+ Q_Q(QCamera);
+
+ QCamera::LockStatus oldStatus = lockStatus;
+
+ QMap<QCamera::LockStatus, int> lockStatusPriority;
+ lockStatusPriority.insert(QCamera::Locked, 1);
+ lockStatusPriority.insert(QCamera::Searching, 2);
+ lockStatusPriority.insert(QCamera::Unlocked, 3);
+
+ lockStatus = requestedLocks ? QCamera::Locked : QCamera::Unlocked;
+ int priority = 0;
+
+ QList<QCamera::LockStatus> lockStatuses;
+
+ if (requestedLocks & QCamera::LockFocus)
+ lockStatuses << q->lockStatus(QCamera::LockFocus);
+
+ if (requestedLocks & QCamera::LockExposure)
+ lockStatuses << q->lockStatus(QCamera::LockExposure);
+
+ if (requestedLocks & QCamera::LockWhiteBalance)
+ lockStatuses << q->lockStatus(QCamera::LockWhiteBalance);
+
+
+ foreach (QCamera::LockStatus currentStatus, lockStatuses) {
+ int currentPriority = lockStatusPriority.value(currentStatus, -1);
+ if (currentPriority > priority) {
+ priority = currentPriority;
+ lockStatus = currentStatus;
+ }
+ }
+
+ if (!supressLockChangedSignal && oldStatus != lockStatus) {
+ emit q->lockStatusChanged(lockStatus, lockChangeReason);
+
+ if (lockStatus == QCamera::Locked)
+ emit q->locked();
+ else if (lockStatus == QCamera::Unlocked && lockChangeReason == QCamera::LockFailed)
+ emit q->lockFailed();
+ }
+/*
+ qDebug() << "Requested locks:" << (requestedLocks & QCamera::LockExposure ? 'e' : ' ')
+ << (requestedLocks & QCamera::LockFocus ? 'f' : ' ')
+ << (requestedLocks & QCamera::LockWhiteBalance ? 'w' : ' ');
+ qDebug() << "Lock status: f:" << q->lockStatus(QCamera::LockFocus)
+ << " e:" << q->lockStatus(QCamera::LockExposure)
+ << " w:" << q->lockStatus(QCamera::LockWhiteBalance)
+ << " composite:" << lockStatus;
+*/
+}
+
+void QCameraPrivate::_q_updateLockStatus(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason)
+{
+ Q_Q(QCamera);
+ lockChangeReason = reason;
+ updateLockStatus();
+ emit q->lockStatusChanged(type, status, reason);
+}
+
+
+/*!
+ Construct a QCamera from service \a provider and \a parent.
+*/
+
+QCamera::QCamera(QObject *parent, QMediaServiceProvider *provider):
+ QMediaObject(*new QCameraPrivate, parent, provider->requestService(Q_MEDIASERVICE_CAMERA))
+{
+ Q_D(QCamera);
+ d->provider = provider;
+ d->initControls();
+ d->cameraExposure = new QCameraExposure(this);
+ d->cameraFocus = new QCameraFocus(this);
+ d->imageProcessing = new QCameraImageProcessing(this);
+}
+
+/*!
+ Construct a QCamera from device name \a device and \a parent.
+*/
+
+QCamera::QCamera(const QByteArray& device, QObject *parent):
+ QMediaObject(*new QCameraPrivate, parent,
+ QMediaServiceProvider::defaultServiceProvider()->requestService(Q_MEDIASERVICE_CAMERA, QMediaServiceProviderHint(device)))
+{
+ Q_D(QCamera);
+ d->provider = QMediaServiceProvider::defaultServiceProvider();
+ d->initControls();
+
+ if (d->service != 0) {
+ //pass device name to service
+ if (d->deviceControl) {
+ QString deviceName = QString::fromLatin1(device);
+
+ for (int i=0; i<d->deviceControl->deviceCount(); i++) {
+ if (d->deviceControl->deviceName(i) == deviceName) {
+ d->deviceControl->setSelectedDevice(i);
+ break;
+ }
+ }
+ }
+ }
+
+ d->cameraExposure = new QCameraExposure(this);
+ d->cameraFocus = new QCameraFocus(this);
+ d->imageProcessing = new QCameraImageProcessing(this);
+}
+
+/*!
+ Destroys the camera object.
+*/
+
+QCamera::~QCamera()
+{
+ Q_D(QCamera);
+ delete d->cameraExposure;
+ d->cameraExposure = 0;
+ delete d->cameraFocus;
+ d->cameraFocus = 0;
+ delete d->imageProcessing;
+ d->imageProcessing = 0;
+
+ if (d->service) {
+ if (d->control)
+ d->service->releaseControl(d->control);
+ if (d->locksControl)
+ d->service->releaseControl(d->locksControl);
+ if (d->deviceControl)
+ d->service->releaseControl(d->deviceControl);
+
+ d->provider->releaseService(d->service);
+ }
+}
+
+
+/*!
+ Return true if the camera service is ready to use.
+ \since 1.1
+*/
+bool QCamera::isAvailable() const
+{
+ return availabilityError() == QtMultimedia::NoError;
+}
+
+/*!
+ Returns the error state of the camera service.
+ \since 1.1
+*/
+
+QtMultimedia::AvailabilityError QCamera::availabilityError() const
+{
+ Q_D(const QCamera);
+ if (d->control == NULL)
+ return QtMultimedia::ServiceMissingError;
+
+ if (d->deviceControl && d->deviceControl->deviceCount() == 0)
+ return QtMultimedia::ResourceError;
+
+ if (d->error != QCamera::NoError)
+ return QtMultimedia::ResourceError;
+
+ return QtMultimedia::NoError;
+}
+
+
+/*!
+ Returns the camera exposure control object.
+ \since 1.1
+*/
+QCameraExposure *QCamera::exposure() const
+{
+ return d_func()->cameraExposure;
+}
+
+/*!
+ Returns the camera focus control object.
+ \since 1.1
+*/
+QCameraFocus *QCamera::focus() const
+{
+ return d_func()->cameraFocus;
+}
+
+/*!
+ Returns the camera image processing control object.
+ \since 1.1
+*/
+QCameraImageProcessing *QCamera::imageProcessing() const
+{
+ return d_func()->imageProcessing;
+}
+
+/*!
+ Sets the QVideoWidget based camera \a viewfinder.
+ The previously set viewfinder is detached.
+ \since 1.1
+*/
+
+// QVideoWidget is forward declared
+void QCamera::setViewfinder(QVideoWidget *viewfinder)
+{
+ Q_D(QCamera);
+ d->_q_preparePropertyChange(QCameraControl::Viewfinder);
+
+ if (d->viewfinder)
+ unbind(d->viewfinder);
+
+ // We don't know (in this library) that QVideoWidget inherits QObject
+ QObject *viewFinderObject = reinterpret_cast<QObject*>(viewfinder);
+
+ d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0;
+}
+
+/*!
+ Sets the QGraphicsVideoItem based camera \a viewfinder.
+ The previously set viewfinder is detached.
+ \since 1.1
+*/
+// QGraphicsVideoItem is forward declared
+void QCamera::setViewfinder(QGraphicsVideoItem *viewfinder)
+{
+ Q_D(QCamera);
+ d->_q_preparePropertyChange(QCameraControl::Viewfinder);
+
+ if (d->viewfinder)
+ unbind(d->viewfinder);
+
+ // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject
+ // but QObject inheritance depends on QObject coming first, so try this out.
+ QObject *viewFinderObject = reinterpret_cast<QObject*>(viewfinder);
+
+ d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0;
+}
+
+/*!
+ Sets a video \a surface as the viewfinder of a camera.
+
+ If a viewfinder has already been set on the camera the new surface
+ will replace it.
+ \since 1.2
+*/
+
+void QCamera::setViewfinder(QAbstractVideoSurface *surface)
+{
+ Q_D(QCamera);
+
+ d->surfaceViewfinder.setVideoSurface(surface);
+
+ if (d->viewfinder != &d->surfaceViewfinder) {
+ if (d->viewfinder)
+ unbind(d->viewfinder);
+
+ d->viewfinder = bind(&d->surfaceViewfinder) ? &d->surfaceViewfinder : 0;
+ }
+}
+
+/*!
+ Returns the error state of the object.
+ \since 1.1
+*/
+
+QCamera::Error QCamera::error() const
+{
+ return d_func()->error;
+}
+
+/*!
+ Returns a string describing a camera's error state.
+ \since 1.1
+*/
+QString QCamera::errorString() const
+{
+ return d_func()->errorString;
+}
+
+
+/*!
+ Returns true if the capture \a mode is suported.
+ \since 1.1
+*/
+bool QCamera::isCaptureModeSupported(QCamera::CaptureMode mode) const
+{
+ return d_func()->control ? d_func()->control->isCaptureModeSupported(mode) : false;
+}
+
+/*!
+ \property QCamera::captureMode
+
+ The type of media (video or still images),
+ the camera is configured to capture.
+
+ It's allowed to change capture mode in any camera state,
+ but if the camera is currently active,
+ chaging capture mode is likely to lead to camera status
+ chaged to QCamera::LoadedStatus, QCamera::LoadingStatus,
+ and when the camera is ready to QCamera::ActiveStatus.
+ \since 1.1
+*/
+
+QCamera::CaptureMode QCamera::captureMode() const
+{
+ return d_func()->control ? d_func()->control->captureMode() : QCamera::CaptureStillImage;
+}
+
+void QCamera::setCaptureMode(QCamera::CaptureMode mode)
+{
+ Q_D(QCamera);
+
+ if (mode != captureMode()) {
+ if (d->control) {
+ d->_q_preparePropertyChange(QCameraControl::CaptureMode);
+ d->control->setCaptureMode(mode);
+ }
+ }
+}
+
+
+/*!
+ Starts the camera.
+
+ State is changed to QCamera::ActiveState if camera is started
+ successfully, otherwise error() signal is emitted.
+
+ While the camera state is changed to QCamera::ActiveState,
+ starting the camera service can be asynchronous with the actual
+ status reported with QCamera::status property.
+ \since 1.1
+*/
+void QCamera::start()
+{
+ Q_D(QCamera);
+ d->setState(QCamera::ActiveState);
+}
+
+/*!
+ Stops the camera.
+ The camera state is changed from QCamera::ActiveState to QCamera::LoadedState.
+ \since 1.1
+*/
+void QCamera::stop()
+{
+ Q_D(QCamera);
+ d->setState(QCamera::LoadedState);
+}
+
+/*!
+ Open the camera device.
+ The camera state is changed to QCamera::LoadedStatus.
+
+ It's not necessary to explcitly load the camera,
+ unless unless the application have to read the supported camera
+ settings and change the default depending on the camera capabilities.
+
+ In all the other cases it's possible to start the camera directly
+ from unloaded state.
+ \since 1.1
+*/
+void QCamera::load()
+{
+ Q_D(QCamera);
+ d->setState(QCamera::LoadedState);
+}
+
+/*!
+ Close the camera device and deallocate the related resources.
+ The camera state is changed to QCamera::UnloadedStatus.
+ \since 1.1
+*/
+void QCamera::unload()
+{
+ Q_D(QCamera);
+ d->setState(QCamera::UnloadedState);
+}
+
+
+/*!
+ Returns a list of camera device's available from the default service provider.
+ \since 1.1
+*/
+
+QList<QByteArray> QCamera::availableDevices()
+{
+ return QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA));
+}
+
+/*!
+ Returns the description of the \a device.
+ \since 1.1
+*/
+
+QString QCamera::deviceDescription(const QByteArray &device)
+{
+ return QMediaServiceProvider::defaultServiceProvider()->deviceDescription(QByteArray(Q_MEDIASERVICE_CAMERA), device);
+}
+
+QCamera::State QCamera::state() const
+{
+ return d_func()->state;
+}
+
+QCamera::Status QCamera::status() const
+{
+ if(d_func()->control)
+ return (QCamera::Status)d_func()->control->status();
+
+ return QCamera::UnavailableStatus;
+}
+
+
+/*!
+ Returns the lock types, camera supports.
+ \since 1.1
+*/
+QCamera::LockTypes QCamera::supportedLocks() const
+{
+ return d_func()->supportedLocks;
+}
+
+/*!
+ Returns the requested lock types.
+ \since 1.1
+*/
+QCamera::LockTypes QCamera::requestedLocks() const
+{
+ return d_func()->requestedLocks;
+}
+
+/*!
+ Returns the status of requested camera settings locks.
+ \since 1.1
+*/
+QCamera::LockStatus QCamera::lockStatus() const
+{
+ return d_func()->lockStatus;
+}
+
+/*!
+ Returns the status of camera settings \a lock.
+ \since 1.1
+*/
+QCamera::LockStatus QCamera::lockStatus(QCamera::LockType lockType) const
+{
+ const QCameraPrivate *d = d_func();
+
+ if (!(lockType & d->supportedLocks))
+ return lockType & d->requestedLocks ? QCamera::Locked : QCamera::Unlocked;
+
+ if (!(lockType & d->requestedLocks))
+ return QCamera::Unlocked;
+
+ if (d->locksControl)
+ return d->locksControl->lockStatus(lockType);
+
+ return QCamera::Unlocked;
+}
+
+/*!
+ \fn void QCamera::searchAndLock(QCamera::LockTypes locks)
+
+ Locks the camera settings with the requested \a locks, including focusing in the single autofocus mode,
+ exposure and white balance if the exposure and white balance modes are not manual.
+
+ The camera settings are usually locked before taking one or multiple still images,
+ in responce to the shutter button being half pressed.
+
+ The QCamera::locked() signal is emitted when camera settings are successfully locked,
+ otherwise QCamera::lockFailed() is emitted.
+
+ QCamera also emits lockStatusChanged(QCamera::LockType, QCamera::LockStatus)
+ on individual lock status changes and lockStatusChanged(QCamera::LockStatus) signal on composite status changes.
+
+ Locking serves two roles: it initializes calculation of automatic parameter
+ (focusing, calculating the correct exposure and white balance) and allows
+ to keep some or all of those parameters during number of shots.
+
+ If the camera doesn't support keeping one of parameters between shots, the related
+ lock state changes to QCamera::Unlocked.
+
+ It's also acceptable to relock already locked settings,
+ depending on the lock parameter this initiates new focusing, exposure or white balance calculation.
+ \since 1.1
+ */
+void QCamera::searchAndLock(QCamera::LockTypes locks)
+{
+ Q_D(QCamera);
+
+ QCamera::LockStatus oldStatus = d->lockStatus;
+ d->supressLockChangedSignal = true;
+
+ d->requestedLocks |= locks;
+
+ locks &= d->supportedLocks;
+
+ if (d->locksControl)
+ d->locksControl->searchAndLock(locks);
+
+ d->supressLockChangedSignal = false;
+
+ d->lockStatus = oldStatus;
+ d->updateLockStatus();
+}
+
+/*!
+ Lock all the supported camera settings.
+ \since 1.1
+ */
+void QCamera::searchAndLock()
+{
+ searchAndLock(LockExposure | LockWhiteBalance | LockFocus);
+}
+
+/*!
+ Unlocks the camera settings specified with \a locks or cancel the current locking if one is active.
+ \since 1.1
+ */
+void QCamera::unlock(QCamera::LockTypes locks)
+{
+ Q_D(QCamera);
+
+ QCamera::LockStatus oldStatus = d->lockStatus;
+ d->supressLockChangedSignal = true;
+
+ d->requestedLocks &= ~locks;
+
+ locks &= d->supportedLocks;
+
+ if (d->locksControl)
+ d->locksControl->unlock(locks);
+
+ d->supressLockChangedSignal = false;
+
+ d->lockStatus = oldStatus;
+ d->updateLockStatus();
+}
+
+/*!
+ Unlock all the requested camera locks.
+ \since 1.1
+ */
+void QCamera::unlock()
+{
+ unlock(d_func()->requestedLocks);
+}
+
+
+/*!
+ \enum QCamera::State
+ \value UnloadedState
+ The initial camera state, with camera not loaded,
+ the camera capabilities except of supported capture modes
+ are unknown.
+
+ While the supported settings are unknown in this state,
+ it's allowed to set the camera capture settings like codec,
+ resolution, or frame rate.
+
+ \value LoadedState
+ The camera is loaded and ready to be configured.
+
+ In the Idle state it's allowed to query camera capabilities,
+ set capture resolution, codecs, etc.
+
+ The viewfinder is not active in the loaded state.
+
+ \value ActiveState
+ In the active state as soon as camera is started
+ the viewfinder displays video frames and the
+ camera is ready for capture.
+*/
+
+
+/*!
+ \property QCamera::state
+ \brief The current state of the camera object.
+ \since 1.1
+*/
+
+/*!
+ \enum QCamera::Status
+ \value ActiveStatus
+ The camera has been started and can produce data.
+ The viewfinder displays video frames in active state.
+
+ Depending on backend, changing some camera settings like
+ capture mode, codecs or resolution in ActiveState may lead
+ to changing the camera status to LoadedStatus and StartingStatus while
+ the settings are applied and back to ActiveStatus when the camera is ready.
+
+ \value StartingStatus
+ The camera is starting in result of state transition to QCamera::ActiveState.
+ The camera service is not ready to capture yet.
+
+ \value StandbyStatus
+ The camera is in the power saving standby mode.
+ The camera may come to the standby mode after some time of inactivity
+ in the QCamera::LoadedState state.
+
+ \value LoadedStatus
+ The camera is loaded and ready to be configured.
+ This status indicates the camera device is opened and
+ it's possible to query for supported image and video capture settings,
+ like resolution, framerate and codecs.
+
+ \value LoadingStatus
+ The camera device loading in result of state transition from
+ QCamera::UnloadedState to QCamera::LoadedState or QCamera::ActiveState.
+
+ \value UnloadedStatus
+ The initial camera status, with camera not loaded.
+ The camera capabilities including supported capture settings may be unknown.
+
+ \value UnavailableStatus
+ The camera or camera backend is not available.
+*/
+
+
+/*!
+ \property QCamera::status
+ \brief The current status of the camera object.
+ \since 1.1
+*/
+
+
+/*!
+ \enum QCamera::CaptureMode
+ \value CaptureStillImage Camera is configured for still frames capture.
+ \value CaptureVideo Camera is configured for video capture.
+ \since 1.1
+*/
+
+/*!
+ \enum QCamera::LockType
+
+ \value NoLock
+ \value LockExposure
+ Lock camera exposure.
+ \value LockWhiteBalance
+ Lock the white balance.
+ \value LockFocus
+ Lock camera focus.
+*/
+
+
+/*!
+ \property QCamera::lockStatus
+ \brief The overall status for all the requested camera locks.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCamera::locked()
+
+ Signals all the requested camera settings are locked.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCamera::lockFailed()
+
+ Signals locking of at least one requested camera settings failed.
+ \since 1.1
+*/
+
+/*!
+ \fn QCamera::lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason)
+
+ Signals the overall \a status for all the requested camera locks was changed with specified \a reason.
+ \since 1.1
+*/
+
+/*!
+ \fn QCamera::lockStatusChanged(QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason)
+ Signals the \a lock \a status was changed with specified \a reason.
+ \since 1.1
+*/
+
+/*!
+ \enum QCamera::LockStatus
+ \value Unlocked
+ The application is not interested in camera settings value.
+ The camera may keep this parameter without changes, this is common with camera focus,
+ or adjust exposure and white balance constantly to keep the viewfinder image nice.
+
+ \value Searching
+ The application has requested the camera focus, exposure or white balance lock with
+ QCamera::searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
+
+ \value Locked
+ The camera focus, exposure or white balance is locked.
+ The camera is ready to capture, application may check the exposure parameters.
+
+ The locked state usually means the requested parameter stays the same,
+ except of the cases when the parameter is requested to be constantly updated.
+ For example in continuous focusing mode, the focus is considered locked as long
+ and the object is in focus, even while the actual focusing distance may be constantly changing.
+*/
+
+/*!
+ \enum QCamera::LockChangeReason
+
+ \value UserRequest
+ The lock status changed in result of user request, usually to unlock camera settings.
+ \value LockAcquired
+ The lock status successfuly changed to QCamera::Locked.
+ \value LockFailed
+ The camera failed to acquire the requested lock in result of
+ autofocus failure, exposure out of supported range, etc.
+ \value LockLost
+ The camera is not able to maintain the requested lock any more.
+ Lock status is changed to QCamera::Unlocked.
+ \value LockTemporaryLost
+ The lock is lost, but the camera is working hard to reacquire it.
+ This value may be used in continuous focusing mode,
+ when the camera loses the focus, the focus lock state is changed to Qcamera::Searching
+ with LockTemporaryLost reason.
+*/
+
+/*!
+ \enum QCamera::Error
+
+ \value NoError No errors have occurred.
+ \value CameraError An error has occurred.
+ \value InvalidRequestError System resource doesn't support requested functionality.
+ \value ServiceMissingError No camera service available.
+ \value NotSupportedFeatureError The feature is not supported.
+*/
+
+/*!
+ \fn void QCamera::error(QCamera::Error value)
+
+ Signal emitted when error state changes to \a value.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCamera::captureModeChanged(QCamera::CaptureMode mode)
+
+ Signals the capture \a mode has changed.
+ \since 1.1
+*/
+
+/*!
+ \fn QCamera::stateChanged(QCamera::State state)
+
+ Signals the camera \a state has changed.
+
+ Usually the state changes is caused by calling
+ load(), unload(), start() and stop(),
+ but the state can also be changed change as a result of camera error.
+ \since 1.1
+*/
+
+/*!
+ \fn QCamera::statusChanged(QCamera::Status status)
+
+ Signals the camera \a status has changed.
+
+ \since 1.1
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qcamera.cpp"
diff --git a/src/multimedia/camera/qcamera.h b/src/multimedia/camera/qcamera.h
new file mode 100644
index 000000000..da009e161
--- /dev/null
+++ b/src/multimedia/camera/qcamera.h
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCAMERA_H
+#define QCAMERA_H
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+
+#include <qmediacontrol.h>
+#include <qmediaobject.h>
+#include <qmediaservice.h>
+
+#include <qcameraexposure.h>
+#include <qcamerafocus.h>
+#include <qcameraimageprocessing.h>
+
+#include <qmediaserviceprovider.h>
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class QAbstractVideoSurface;
+class QVideoWidget;
+class QGraphicsVideoItem;
+
+class QCameraPrivate;
+class Q_MULTIMEDIA_EXPORT QCamera : public QMediaObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QCamera::State state READ state NOTIFY stateChanged)
+ Q_PROPERTY(QCamera::Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QCamera::CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged)
+ Q_PROPERTY(QCamera::LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged)
+
+ Q_ENUMS(Status)
+ Q_ENUMS(State)
+ Q_ENUMS(CaptureMode)
+ Q_ENUMS(Error)
+ Q_ENUMS(LockStatus)
+ Q_ENUMS(LockChangeReason)
+ Q_ENUMS(LockType)
+public:
+ enum Status {
+ UnavailableStatus,
+ UnloadedStatus,
+ LoadingStatus,
+ LoadedStatus,
+ StandbyStatus,
+ StartingStatus,
+ ActiveStatus
+ };
+
+ enum State {
+ UnloadedState,
+ LoadedState,
+ ActiveState
+ };
+
+ enum CaptureMode
+ {
+ CaptureStillImage,
+ CaptureVideo
+ };
+
+ enum Error
+ {
+ NoError,
+ CameraError,
+ InvalidRequestError,
+ ServiceMissingError,
+ NotSupportedFeatureError
+ };
+
+ enum LockStatus
+ {
+ Unlocked,
+ Searching,
+ Locked
+ };
+
+ enum LockChangeReason {
+ UserRequest,
+ LockAcquired,
+ LockFailed,
+ LockLost,
+ LockTemporaryLost
+ };
+
+ enum LockType
+ {
+ NoLock = 0,
+ LockExposure = 0x01,
+ LockWhiteBalance = 0x02,
+ LockFocus = 0x04
+ };
+ Q_DECLARE_FLAGS(LockTypes, LockType)
+
+ QCamera(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
+ QCamera(const QByteArray& device, QObject *parent = 0);
+ ~QCamera();
+
+ static QList<QByteArray> availableDevices();
+ static QString deviceDescription(const QByteArray &device);
+
+ bool isAvailable() const;
+ QtMultimedia::AvailabilityError availabilityError() const;
+
+ State state() const;
+ Status status() const;
+
+ CaptureMode captureMode() const;
+ bool isCaptureModeSupported(CaptureMode mode) const;
+
+ QCameraExposure *exposure() const;
+ QCameraFocus *focus() const;
+ QCameraImageProcessing *imageProcessing() const;
+
+ void setViewfinder(QVideoWidget *viewfinder);
+ void setViewfinder(QGraphicsVideoItem *viewfinder);
+ void setViewfinder(QAbstractVideoSurface *surface);
+
+ Error error() const;
+ QString errorString() const;
+
+ QCamera::LockTypes supportedLocks() const;
+ QCamera::LockTypes requestedLocks() const;
+
+ QCamera::LockStatus lockStatus() const;
+ QCamera::LockStatus lockStatus(QCamera::LockType lock) const;
+
+public Q_SLOTS:
+ void setCaptureMode(QCamera::CaptureMode mode);
+
+ void load();
+ void unload();
+
+ void start();
+ void stop();
+
+ void searchAndLock();
+ void unlock();
+
+ void searchAndLock(QCamera::LockTypes locks);
+ void unlock(QCamera::LockTypes locks);
+
+Q_SIGNALS:
+ void stateChanged(QCamera::State);
+ void captureModeChanged(QCamera::CaptureMode);
+ void statusChanged(QCamera::Status);
+
+ void locked();
+ void lockFailed();
+
+ void lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason);
+ void lockStatusChanged(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
+
+ void error(QCamera::Error);
+
+private:
+ Q_DISABLE_COPY(QCamera)
+ Q_DECLARE_PRIVATE(QCamera)
+ Q_PRIVATE_SLOT(d_func(), void _q_preparePropertyChange(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_restartCamera())
+ Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateState(QCamera::State))
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::LockTypes)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QCamera::State)
+Q_DECLARE_METATYPE(QCamera::Status)
+Q_DECLARE_METATYPE(QCamera::Error)
+Q_DECLARE_METATYPE(QCamera::CaptureMode)
+Q_DECLARE_METATYPE(QCamera::LockType)
+Q_DECLARE_METATYPE(QCamera::LockStatus)
+Q_DECLARE_METATYPE(QCamera::LockChangeReason)
+
+Q_MEDIA_ENUM_DEBUG(QCamera, State)
+Q_MEDIA_ENUM_DEBUG(QCamera, Status)
+Q_MEDIA_ENUM_DEBUG(QCamera, Error)
+Q_MEDIA_ENUM_DEBUG(QCamera, CaptureMode)
+Q_MEDIA_ENUM_DEBUG(QCamera, LockType)
+Q_MEDIA_ENUM_DEBUG(QCamera, LockStatus)
+Q_MEDIA_ENUM_DEBUG(QCamera, LockChangeReason)
+
+QT_END_HEADER
+
+#endif // QCAMERA_H
diff --git a/src/multimedia/camera/qcameraexposure.cpp b/src/multimedia/camera/qcameraexposure.cpp
new file mode 100644
index 000000000..5c75ad9e2
--- /dev/null
+++ b/src/multimedia/camera/qcameraexposure.cpp
@@ -0,0 +1,646 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcameraexposure.h"
+#include "qmediaobject_p.h"
+
+#include <qcamera.h>
+#include <qcameraexposurecontrol.h>
+#include <qcameraflashcontrol.h>
+
+#include <QtCore/QMetaObject>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCameraExposure
+
+
+ \brief The QCameraExposure class provides interface for exposure related camera settings.
+
+ \inmodule QtMultimedia
+ \ingroup camera
+ \since 1.1
+
+*/
+
+//#define DEBUG_EXPOSURE_CHANGES 1
+
+#ifdef DEBUG_EXPOSURE_CHANGES
+#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v)))
+#endif
+
+namespace
+{
+class CameraExposureRegisterMetaTypes
+{
+public:
+ CameraExposureRegisterMetaTypes()
+ {
+ qRegisterMetaType<QCameraExposure::ExposureMode>("QCameraExposure::ExposureMode");
+ qRegisterMetaType<QCameraExposure::FlashModes>("QCameraExposure::FlashModes");
+ qRegisterMetaType<QCameraExposure::MeteringMode>("QCameraExposure::MeteringMode");
+ }
+} _registerCameraExposureMetaTypes;
+}
+
+
+
+class QCameraExposurePrivate
+{
+ Q_DECLARE_NON_CONST_PUBLIC(QCameraExposure)
+public:
+ void initControls();
+ QCameraExposure *q_ptr;
+
+ QCamera *camera;
+ QCameraExposureControl *exposureControl;
+ QCameraFlashControl *flashControl;
+
+ void _q_exposureParameterChanged(int parameter);
+ void _q_exposureParameterRangeChanged(int parameter);
+};
+
+void QCameraExposurePrivate::initControls()
+{
+ Q_Q(QCameraExposure);
+
+ QMediaService *service = camera->service();
+ exposureControl = 0;
+ flashControl = 0;
+ if (service) {
+ exposureControl = qobject_cast<QCameraExposureControl *>(service->requestControl(QCameraExposureControl_iid));
+ flashControl = qobject_cast<QCameraFlashControl *>(service->requestControl(QCameraFlashControl_iid));
+ }
+ if (exposureControl) {
+ q->connect(exposureControl, SIGNAL(exposureParameterChanged(int)),
+ q, SLOT(_q_exposureParameterChanged(int)));
+ q->connect(exposureControl, SIGNAL(exposureParameterRangeChanged(int)),
+ q, SLOT(_q_exposureParameterRangeChanged(int)));
+ }
+
+ if (flashControl)
+ q->connect(flashControl, SIGNAL(flashReady(bool)), q, SIGNAL(flashReady(bool)));
+}
+
+void QCameraExposurePrivate::_q_exposureParameterChanged(int parameter)
+{
+ Q_Q(QCameraExposure);
+
+#if DEBUG_EXPOSURE_CHANGES
+ qDebug() << "Exposure parameter changed:"
+ << ENUM_NAME(QCameraExposureControl, "ExposureParameter", parameter)
+ << exposureControl->exposureParameter(QCameraExposureControl::ExposureParameter(parameter));
+#endif
+
+ switch (parameter) {
+ case QCameraExposureControl::ISO:
+ emit q->isoSensitivityChanged(q->isoSensitivity());
+ break;
+ case QCameraExposureControl::Aperture:
+ emit q->apertureChanged(q->aperture());
+ break;
+ case QCameraExposureControl::ShutterSpeed:
+ emit q->shutterSpeedChanged(q->shutterSpeed());
+ break;
+ case QCameraExposureControl::ExposureCompensation:
+ emit q->exposureCompensationChanged(q->exposureCompensation());
+ break;
+ }
+}
+
+void QCameraExposurePrivate::_q_exposureParameterRangeChanged(int parameter)
+{
+ Q_Q(QCameraExposure);
+
+ switch (parameter) {
+ case QCameraExposureControl::Aperture:
+ emit q->apertureRangeChanged();
+ break;
+ case QCameraExposureControl::ShutterSpeed:
+ emit q->shutterSpeedRangeChanged();
+ break;
+ }
+}
+
+/*!
+ Construct a QCameraExposure from service \a provider and \a parent.
+*/
+
+QCameraExposure::QCameraExposure(QCamera *parent):
+ QObject(parent), d_ptr(new QCameraExposurePrivate)
+{
+ Q_D(QCameraExposure);
+ d->camera = parent;
+ d->q_ptr = this;
+ d->initControls();
+}
+
+
+/*!
+ Destroys the camera exposure object.
+*/
+
+QCameraExposure::~QCameraExposure()
+{
+ Q_D(QCameraExposure);
+ if (d->exposureControl)
+ d->camera->service()->releaseControl(d->exposureControl);
+}
+
+/*!
+ Returns true if exposure settings are supported by this camera.
+ \since 1.1
+*/
+bool QCameraExposure::isAvailable() const
+{
+ return d_func()->exposureControl != 0;
+}
+
+
+/*!
+ \property QCameraExposure::flashMode
+ \brief The flash mode being used.
+
+ Usually the single QCameraExposure::FlashMode flag is used,
+ but some non conflicting flags combination are also allowed,
+ like QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain.
+
+ \since 1.1
+ \sa QCameraExposure::isFlashModeSupported(), QCameraExposure::isFlashReady()
+*/
+
+QCameraExposure::FlashModes QCameraExposure::flashMode() const
+{
+ return d_func()->flashControl ? d_func()->flashControl->flashMode() : QCameraExposure::FlashOff;
+}
+
+void QCameraExposure::setFlashMode(QCameraExposure::FlashModes mode)
+{
+ if (d_func()->flashControl)
+ d_func()->flashControl->setFlashMode(mode);
+}
+
+/*!
+ Returns true if the flash \a mode is supported.
+ \since 1.1
+*/
+
+bool QCameraExposure::isFlashModeSupported(QCameraExposure::FlashModes mode) const
+{
+ return d_func()->flashControl ? d_func()->flashControl->isFlashModeSupported(mode) : false;
+}
+
+/*!
+ Returns true if flash is charged.
+*/
+
+bool QCameraExposure::isFlashReady() const
+{
+ return d_func()->flashControl ? d_func()->flashControl->isFlashReady() : false;
+}
+
+
+/*!
+ \property QCameraExposure::exposureMode
+ \brief The exposure mode being used.
+
+ \since 1.1
+ \sa QCameraExposure::isExposureModeSupported()
+*/
+
+QCameraExposure::ExposureMode QCameraExposure::exposureMode() const
+{
+ return d_func()->exposureControl ? d_func()->exposureControl->exposureMode() : QCameraExposure::ExposureAuto;
+}
+
+void QCameraExposure::setExposureMode(QCameraExposure::ExposureMode mode)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureMode(mode);
+}
+
+/*!
+ Returns true if the exposure \a mode is supported.
+ \since 1.1
+*/
+
+bool QCameraExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const
+{
+ return d_func()->exposureControl ?
+ d_func()->exposureControl->isExposureModeSupported(mode) : false;
+}
+
+/*!
+ \property QCameraExposure::exposureCompensation
+ \brief Exposure compensation in EV units.
+
+ Exposure compensation property allows to adjust the automatically calculated exposure.
+ \since 1.1
+*/
+
+qreal QCameraExposure::exposureCompensation() const
+{
+ if (d_func()->exposureControl)
+ return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ExposureCompensation).toReal();
+ else
+ return 0;
+}
+
+void QCameraExposure::setExposureCompensation(qreal ev)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ExposureCompensation, QVariant(ev));
+}
+
+/*!
+ \property QCameraExposure::meteringMode
+ \brief The metering mode being used.
+
+ \since 1.1
+ \sa QCameraExposure::isMeteringModeSupported()
+*/
+
+QCameraExposure::MeteringMode QCameraExposure::meteringMode() const
+{
+ return d_func()->exposureControl ? d_func()->exposureControl->meteringMode() : QCameraExposure::MeteringMatrix;
+}
+
+void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setMeteringMode(mode);
+}
+
+/*!
+ Returns true if the metering \a mode is supported.
+ \since 1.1
+*/
+bool QCameraExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
+{
+ return d_func()->exposureControl ? d_func()->exposureControl->isMeteringModeSupported(mode) : false;
+}
+
+int QCameraExposure::isoSensitivity() const
+{
+ if (d_func()->exposureControl)
+ return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ISO).toInt();
+
+ return -1;
+}
+
+/*!
+ Returns the list of ISO senitivities camera supports.
+
+ If the camera supports arbitrary ISO sensitivities within the supported range,
+ *\a continuous is set to true, otherwise *\a continuous is set to false.
+ \since 1.1
+*/
+QList<int> QCameraExposure::supportedIsoSensitivities(bool *continuous) const
+{
+ QList<int> res;
+ QCameraExposureControl *control = d_func()->exposureControl;
+
+ if (!control)
+ return res;
+
+ foreach (const QVariant &value,
+ control->supportedParameterRange(QCameraExposureControl::ISO)) {
+ bool ok = false;
+ int intValue = value.toInt(&ok);
+ if (ok)
+ res.append(intValue);
+ else
+ qWarning() << "Incompatible ISO value type, int is expected";
+ }
+
+ if (continuous)
+ *continuous = control->exposureParameterFlags(QCameraExposureControl::ISO) &
+ QCameraExposureControl::ContinuousRange;
+
+ return res;
+}
+
+/*!
+ \fn QCameraExposure::setManualIsoSensitivity(int iso)
+ Sets the manual sensitivity to \a iso
+ \since 1.1
+*/
+
+void QCameraExposure::setManualIsoSensitivity(int iso)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant(iso));
+}
+
+/*!
+ \fn QCameraExposure::setAutoIsoSensitivity()
+ Turn on auto sensitivity
+ \since 1.1
+*/
+
+void QCameraExposure::setAutoIsoSensitivity()
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant());
+}
+
+/*!
+ \property QCameraExposure::shutterSpeed
+ \brief Camera's shutter speed in seconds.
+
+ \since 1.1
+ \sa supportedShutterSpeeds(), setAutoShutterSpeed(), setManualShutterSpeed()
+*/
+
+/*!
+ \fn QCameraExposure::shutterSpeedChanged(qreal speed)
+
+ Signals that a camera's shutter \a speed has changed.
+ \since 1.1
+*/
+
+/*!
+ \property QCameraExposure::isoSensitivity
+ \brief The sensor ISO sensitivity.
+
+ \sa supportedIsoSensitivities(), setAutoIsoSensitivity(), setManualIsoSensitivity()
+ \since 1.1
+*/
+
+/*!
+ \property QCameraExposure::aperture
+ \brief Lens aperture is specified as an F number, the ratio of the focal length to effective aperture diameter.
+
+ \since 1.1
+ \sa supportedApertures(), setAutoAperture(), setManualAperture()
+*/
+
+
+qreal QCameraExposure::aperture() const
+{
+ if (d_func()->exposureControl)
+ return d_func()->exposureControl->exposureParameter(QCameraExposureControl::Aperture).toReal();
+
+ return -1.0;
+}
+
+/*!
+ Returns the list of aperture values camera supports.
+ The apertures list can change depending on the focal length,
+ in such a case the apertureRangeChanged() signal is emitted.
+
+ If the camera supports arbitrary aperture values within the supported range,
+ *\a continuous is set to true, otherwise *\a continuous is set to false.
+ \since 1.1
+*/
+QList<qreal> QCameraExposure::supportedApertures(bool * continuous) const
+{
+ QList<qreal> res;
+ QCameraExposureControl *control = d_func()->exposureControl;
+
+ if (!control)
+ return res;
+
+ foreach (const QVariant &value,
+ control->supportedParameterRange(QCameraExposureControl::Aperture)) {
+ bool ok = false;
+ qreal realValue = value.toReal(&ok);
+ if (ok)
+ res.append(realValue);
+ else
+ qWarning() << "Incompatible aperture value type, qreal is expected";
+ }
+
+ if (continuous)
+ *continuous = control->exposureParameterFlags(QCameraExposureControl::Aperture) &
+ QCameraExposureControl::ContinuousRange;
+
+ return res;
+}
+
+/*!
+ \fn QCameraExposure::setManualAperture(qreal aperture)
+ Sets the manual camera \a aperture value.
+ \since 1.1
+*/
+
+void QCameraExposure::setManualAperture(qreal aperture)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant(aperture));
+}
+
+/*!
+ \fn QCameraExposure::setAutoAperture()
+ Turn on auto aperture
+ \since 1.1
+*/
+
+void QCameraExposure::setAutoAperture()
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant());
+}
+
+/*!
+ Returns the current shutter speed in seconds.
+ \since 1.1
+*/
+
+qreal QCameraExposure::shutterSpeed() const
+{
+ if (d_func()->exposureControl)
+ return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ShutterSpeed).toReal();
+
+ return -1.0;
+}
+
+/*!
+ Returns the list of shutter speed values in seconds camera supports.
+
+ If the camera supports arbitrary shutter speed values within the supported range,
+ *\a continuous is set to true, otherwise *\a continuous is set to false.
+ \since 1.1
+*/
+QList<qreal> QCameraExposure::supportedShutterSpeeds(bool *continuous) const
+{
+ QList<qreal> res;
+
+ QCameraExposureControl *control = d_func()->exposureControl;
+ if (!control)
+ return res;
+
+ foreach (const QVariant &value,
+ control->supportedParameterRange(QCameraExposureControl::ShutterSpeed)) {
+ bool ok = false;
+ qreal realValue = value.toReal(&ok);
+ if (ok)
+ res.append(realValue);
+ else
+ qWarning() << "Incompatible shutter speed value type, qreal is expected";
+ }
+
+ if (continuous)
+ *continuous = control->exposureParameterFlags(QCameraExposureControl::ShutterSpeed) &
+ QCameraExposureControl::ContinuousRange;
+
+ return res;
+}
+
+/*!
+ Set the manual shutter speed to \a seconds
+ \since 1.1
+*/
+
+void QCameraExposure::setManualShutterSpeed(qreal seconds)
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant(seconds));
+}
+
+/*!
+ Turn on auto shutter speed
+ \since 1.1
+*/
+
+void QCameraExposure::setAutoShutterSpeed()
+{
+ if (d_func()->exposureControl)
+ d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant());
+}
+
+
+/*!
+ \enum QCameraExposure::FlashMode
+
+ \value FlashOff Flash is Off.
+ \value FlashOn Flash is On.
+ \value FlashAuto Automatic flash.
+ \value FlashRedEyeReduction Red eye reduction flash.
+ \value FlashFill Use flash to fillin shadows.
+ \value FlashTorch Constant light source, useful for focusing and video capture.
+ \value FlashSlowSyncFrontCurtain
+ Use the flash in conjunction with a slow shutter speed.
+ This mode allows better exposure of distant objects and/or motion blur effect.
+ \value FlashSlowSyncRearCurtain
+ The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure.
+ \value FlashManual Flash power is manualy set.
+*/
+
+/*!
+ \enum QCameraExposure::ExposureMode
+
+ \value ExposureManual Manual mode.
+ \value ExposureAuto Automatic mode.
+ \value ExposureNight Night mode.
+ \value ExposureBacklight Backlight exposure mode.
+ \value ExposureSpotlight Spotlight exposure mode.
+ \value ExposureSports Spots exposure mode.
+ \value ExposureSnow Snow exposure mode.
+ \value ExposureBeach Beach exposure mode.
+ \value ExposureLargeAperture Use larger aperture with small depth of field.
+ \value ExposureSmallAperture Use smaller aperture.
+ \value ExposurePortrait Portrait exposure mode.
+ \value ExposureModeVendor The base value for device specific exposure modes.
+*/
+
+/*!
+ \enum QCameraExposure::MeteringMode
+
+ \value MeteringAverage Center weighted average metering mode.
+ \value MeteringSpot Spot metering mode.
+ \value MeteringMatrix Matrix metering mode.
+*/
+
+/*!
+ \property QCameraExposure::flashReady
+ \brief Indicates if the flash is charged and ready to use.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraExposure::flashReady(bool ready)
+
+ Signal the flash \a ready status has changed.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraExposure::apertureChanged(qreal value)
+
+ Signal emitted when aperature changes to \a value.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraExposure::apertureRangeChanged()
+
+ Signal emitted when aperature range has changed.
+ \since 1.1
+*/
+
+
+/*!
+ \fn void QCameraExposure::shutterSpeedRangeChanged()
+
+ Signal emitted when the shutter speed range has changed.
+ \since 1.1
+*/
+
+
+/*!
+ \fn void QCameraExposure::isoSensitivityChanged(int value)
+
+ Signal emitted when sensitivity changes to \a value.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraExposure::exposureCompensationChanged(qreal value)
+
+ Signal emitted when the exposure compensation changes to \a value.
+ \since 1.1
+*/
+
+#include "moc_qcameraexposure.cpp"
+QT_END_NAMESPACE
diff --git a/src/multimedia/camera/qcameraexposure.h b/src/multimedia/camera/qcameraexposure.h
new file mode 100644
index 000000000..088e7c036
--- /dev/null
+++ b/src/multimedia/camera/qcameraexposure.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCAMERAEXPOSURE_H
+#define QCAMERAEXPOSURE_H
+
+#include <qmediaobject.h>
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class QCamera;
+class QCameraExposurePrivate;
+
+class Q_MULTIMEDIA_EXPORT QCameraExposure : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
+ Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
+ Q_PROPERTY(int isoSensitivity READ isoSensitivity NOTIFY isoSensitivityChanged)
+ Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
+ Q_PROPERTY(bool flashReady READ isFlashReady NOTIFY flashReady)
+ Q_PROPERTY(QCameraExposure::FlashModes flashMode READ flashMode WRITE setFlashMode)
+ Q_PROPERTY(QCameraExposure::ExposureMode exposureMode READ exposureMode WRITE setExposureMode)
+ Q_PROPERTY(QCameraExposure::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode)
+
+ Q_ENUMS(FlashMode)
+ Q_ENUMS(ExposureMode)
+ Q_ENUMS(MeteringMode)
+public:
+ enum FlashMode {
+ FlashAuto = 0x1,
+ FlashOff = 0x2,
+ FlashOn = 0x4,
+ FlashRedEyeReduction = 0x8,
+ FlashFill = 0x10,
+ FlashTorch = 0x20,
+ FlashSlowSyncFrontCurtain = 0x40,
+ FlashSlowSyncRearCurtain = 0x80,
+ FlashManual = 0x100
+ };
+ Q_DECLARE_FLAGS(FlashModes, FlashMode)
+
+ enum ExposureMode {
+ ExposureAuto = 0,
+ ExposureManual = 1,
+ ExposurePortrait = 2,
+ ExposureNight = 3,
+ ExposureBacklight = 4,
+ ExposureSpotlight = 5,
+ ExposureSports = 6,
+ ExposureSnow = 7,
+ ExposureBeach = 8,
+ ExposureLargeAperture = 9,
+ ExposureSmallAperture = 10,
+ ExposureModeVendor = 1000
+ };
+
+ enum MeteringMode {
+ MeteringMatrix = 1,
+ MeteringAverage = 2,
+ MeteringSpot = 3
+ };
+
+ bool isAvailable() const;
+
+ FlashModes flashMode() const;
+ bool isFlashModeSupported(FlashModes mode) const;
+ bool isFlashReady() const;
+
+ ExposureMode exposureMode() const;
+ bool isExposureModeSupported(ExposureMode mode) const;
+
+ qreal exposureCompensation() const;
+
+ MeteringMode meteringMode() const;
+
+ bool isMeteringModeSupported(MeteringMode mode) const;
+
+ int isoSensitivity() const;
+ QList<int> supportedIsoSensitivities(bool *continuous = 0) const;
+
+ qreal aperture() const;
+ QList<qreal> supportedApertures(bool *continuous = 0) const;
+
+ qreal shutterSpeed() const;
+ QList<qreal> supportedShutterSpeeds(bool *continuous = 0) const;
+
+public Q_SLOTS:
+ void setFlashMode(FlashModes mode);
+ void setExposureMode(ExposureMode mode);
+
+ void setExposureCompensation(qreal ev);
+
+ void setMeteringMode(MeteringMode mode);
+
+ void setManualIsoSensitivity(int iso);
+ void setAutoIsoSensitivity();
+
+ void setManualAperture(qreal aperture);
+ void setAutoAperture();
+
+ void setManualShutterSpeed(qreal seconds);
+ void setAutoShutterSpeed();
+
+Q_SIGNALS:
+ void flashReady(bool);
+
+ void apertureChanged(qreal);
+ void apertureRangeChanged();
+ void shutterSpeedChanged(qreal);
+ void shutterSpeedRangeChanged();
+ void isoSensitivityChanged(int);
+ void exposureCompensationChanged(qreal);
+
+private:
+ friend class QCamera;
+ explicit QCameraExposure(QCamera *parent = 0);
+ virtual ~QCameraExposure();
+
+ Q_DISABLE_COPY(QCameraExposure)
+ Q_DECLARE_PRIVATE(QCameraExposure)
+ Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterChanged(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterRangeChanged(int))
+ QCameraExposurePrivate *d_ptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposure::FlashModes)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QCameraExposure::ExposureMode)
+Q_DECLARE_METATYPE(QCameraExposure::FlashModes)
+Q_DECLARE_METATYPE(QCameraExposure::MeteringMode)
+
+Q_MEDIA_ENUM_DEBUG(QCameraExposure, ExposureMode)
+Q_MEDIA_ENUM_DEBUG(QCameraExposure, FlashMode)
+Q_MEDIA_ENUM_DEBUG(QCameraExposure, MeteringMode)
+
+QT_END_HEADER
+
+#endif // QCAMERAEXPOSURE_H
diff --git a/src/multimedia/camera/qcamerafocus.cpp b/src/multimedia/camera/qcamerafocus.cpp
new file mode 100644
index 000000000..9b9caed9e
--- /dev/null
+++ b/src/multimedia/camera/qcamerafocus.cpp
@@ -0,0 +1,478 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcamerafocus.h"
+#include "qmediaobject_p.h"
+
+#include <qcamera.h>
+#include <qcameracontrol.h>
+#include <qcameraexposurecontrol.h>
+#include <qcamerafocuscontrol.h>
+#include <qmediarecordercontrol.h>
+#include <qcameraimagecapturecontrol.h>
+#include <qvideodevicecontrol.h>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+namespace
+{
+class CameraFocusRegisterMetaTypes
+{
+public:
+ CameraFocusRegisterMetaTypes()
+ {
+ qRegisterMetaType<QCameraFocus::FocusModes>("QCameraFocus::FocusModes");
+ qRegisterMetaType<QCameraFocus::FocusPointMode>("QCameraFocus::FocusPointMode");
+ }
+} _registerCameraFocusMetaTypes;
+}
+
+
+class QCameraFocusZoneData : public QSharedData
+{
+public:
+ QCameraFocusZoneData():
+ status(QCameraFocusZone::Invalid)
+ {
+
+ }
+
+ QCameraFocusZoneData(const QRectF &_area, QCameraFocusZone::FocusZoneStatus _status):
+ area(_area),
+ status(_status)
+ {
+
+ }
+
+
+ QCameraFocusZoneData(const QCameraFocusZoneData &other):
+ QSharedData(other),
+ area(other.area),
+ status(other.status)
+ {
+ }
+
+ QCameraFocusZoneData& operator=(const QCameraFocusZoneData &other)
+ {
+ area = other.area;
+ status = other.status;
+ return *this;
+ }
+
+ QRectF area;
+ QCameraFocusZone::FocusZoneStatus status;
+};
+
+QCameraFocusZone::QCameraFocusZone()
+ :d(new QCameraFocusZoneData)
+{
+
+}
+
+QCameraFocusZone::QCameraFocusZone(const QRectF &area, QCameraFocusZone::FocusZoneStatus status)
+ :d(new QCameraFocusZoneData(area, status))
+{
+}
+
+QCameraFocusZone::QCameraFocusZone(const QCameraFocusZone &other)
+ :d(other.d)
+{
+
+}
+
+QCameraFocusZone::~QCameraFocusZone()
+{
+
+}
+
+QCameraFocusZone& QCameraFocusZone::operator=(const QCameraFocusZone &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QCameraFocusZone::operator==(const QCameraFocusZone &other) const
+{
+ return d == other.d ||
+ (d->area == other.d->area && d->status == other.d->status);
+}
+
+bool QCameraFocusZone::operator!=(const QCameraFocusZone &other) const
+{
+ return !(*this == other);
+}
+
+bool QCameraFocusZone::isValid() const
+{
+ return d->status != Invalid && !d->area.isValid();
+}
+
+QRectF QCameraFocusZone::area() const
+{
+ return d->area;
+}
+
+QCameraFocusZone::FocusZoneStatus QCameraFocusZone::status() const
+{
+ return d->status;
+}
+
+void QCameraFocusZone::setStatus(QCameraFocusZone::FocusZoneStatus status)
+{
+ d->status = status;
+}
+
+
+/*!
+ \class QCameraFocus
+
+
+ \brief The QCameraFocus class provides interface for
+ focus and zoom related camera settings.
+
+ \inmodule QtMultimedia
+ \ingroup camera
+ \since 1.1
+
+*/
+
+
+class QCameraFocusPrivate : public QMediaObjectPrivate
+{
+ Q_DECLARE_NON_CONST_PUBLIC(QCameraFocus)
+public:
+ void initControls();
+
+ QCameraFocus *q_ptr;
+
+ QCamera *camera;
+ QCameraFocusControl *focusControl;
+};
+
+
+void QCameraFocusPrivate::initControls()
+{
+ Q_Q(QCameraFocus);
+
+ focusControl = 0;
+
+ QMediaService *service = camera->service();
+ if (service)
+ focusControl = qobject_cast<QCameraFocusControl *>(service->requestControl(QCameraFocusControl_iid));
+
+ if (focusControl) {
+ q->connect(focusControl, SIGNAL(opticalZoomChanged(qreal)), q, SIGNAL(opticalZoomChanged(qreal)));
+ q->connect(focusControl, SIGNAL(digitalZoomChanged(qreal)), q, SIGNAL(digitalZoomChanged(qreal)));
+ q->connect(focusControl, SIGNAL(maximumOpticalZoomChanged(qreal)),
+ q, SIGNAL(maximumOpticalZoomChanged(qreal)));
+ q->connect(focusControl, SIGNAL(maximumDigitalZoomChanged(qreal)),
+ q, SIGNAL(maximumDigitalZoomChanged(qreal)));
+ q->connect(focusControl, SIGNAL(focusZonesChanged()), q, SIGNAL(focusZonesChanged()));
+ }
+}
+
+/*!
+ Construct a QCameraFocus for \a camera.
+*/
+
+QCameraFocus::QCameraFocus(QCamera *camera):
+ QObject(camera), d_ptr(new QCameraFocusPrivate)
+{
+ Q_D(QCameraFocus);
+ d->camera = camera;
+ d->q_ptr = this;
+ d->initControls();
+}
+
+
+/*!
+ Destroys the camera focus object.
+*/
+
+QCameraFocus::~QCameraFocus()
+{
+}
+
+/*!
+ Returns true if focus related settings are supported by this camera.
+ \since 1.1
+*/
+bool QCameraFocus::isAvailable() const
+{
+ return d_func()->focusControl != 0;
+}
+
+/*!
+ \property QCameraFocus::focusMode
+ \brief The current camera focus mode.
+
+ \since 1.1
+ \sa QCameraFocus::isFocusModeSupported()
+*/
+
+QCameraFocus::FocusMode QCameraFocus::focusMode() const
+{
+ return d_func()->focusControl ? d_func()->focusControl->focusMode() : QCameraFocus::AutoFocus;
+}
+
+void QCameraFocus::setFocusMode(QCameraFocus::FocusMode mode)
+{
+ if (d_func()->focusControl)
+ d_func()->focusControl->setFocusMode(mode);
+}
+
+/*!
+ Returns true if the focus \a mode is supported by camera.
+ \since 1.1
+*/
+
+bool QCameraFocus::isFocusModeSupported(QCameraFocus::FocusMode mode) const
+{
+ return d_func()->focusControl ? d_func()->focusControl->isFocusModeSupported(mode) : false;
+}
+
+/*!
+ \property QCameraFocus::focusPointMode
+ \brief The current camera focus point selection mode.
+
+ \sa QCameraFocus::isFocusPointModeSupported()
+ \since 1.1
+*/
+
+QCameraFocus::FocusPointMode QCameraFocus::focusPointMode() const
+{
+ return d_func()->focusControl ?
+ d_func()->focusControl->focusPointMode() :
+ QCameraFocus::FocusPointAuto;
+}
+
+void QCameraFocus::setFocusPointMode(QCameraFocus::FocusPointMode mode)
+{
+ if (d_func()->focusControl)
+ d_func()->focusControl->setFocusPointMode(mode);
+ else
+ qWarning("Focus points mode selection is not supported");
+}
+
+/*!
+ Returns true if focus point \a mode is supported.
+ \since 1.1
+ */
+bool QCameraFocus::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
+{
+ return d_func()->focusControl ?
+ d_func()->focusControl->isFocusPointModeSupported(mode) :
+ false;
+
+}
+
+/*!
+ \property QCameraFocus::customFocusPoint
+
+ Position of custom focus point, in relative frame coordinates:
+ QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.
+
+ Custom focus point is used only in FocusPointCustom focus mode.
+ \since 1.1
+ */
+
+QPointF QCameraFocus::customFocusPoint() const
+{
+ return d_func()->focusControl ?
+ d_func()->focusControl->customFocusPoint() :
+ QPointF(0.5,0.5);
+}
+
+void QCameraFocus::setCustomFocusPoint(const QPointF &point)
+{
+ if (d_func()->focusControl)
+ d_func()->focusControl->setCustomFocusPoint(point);
+ else
+ qWarning("Focus points selection is not supported");
+
+}
+
+/*!
+ \property QCameraFocus::focusZones
+
+ Returns the list of active focus zones.
+
+ If QCamera::FocusPointAuto or QCamera::FocusPointFaceDetection focus mode is selected
+ this method returns the list of zones the camera is actually focused on.
+
+ The coordinates system is the same as for custom focus points:
+ QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center.
+ \since 1.1
+ */
+QCameraFocusZoneList QCameraFocus::focusZones() const
+{
+ return d_func()->focusControl ?
+ d_func()->focusControl->focusZones() :
+ QCameraFocusZoneList();
+}
+
+/*!
+ Returns the maximum optical zoom
+ \since 1.1
+*/
+
+qreal QCameraFocus::maximumOpticalZoom() const
+{
+ return d_func()->focusControl ? d_func()->focusControl->maximumOpticalZoom() : 1.0;
+}
+
+/*!
+ Returns the maximum digital zoom
+ \since 1.1
+*/
+
+qreal QCameraFocus::maximumDigitalZoom() const
+{
+ return d_func()->focusControl ? d_func()->focusControl->maximumDigitalZoom() : 1.0;
+}
+
+/*!
+ \property QCameraFocus::opticalZoom
+ \brief The current optical zoom value.
+
+ \since 1.1
+ \sa QCameraFocus::digitalZoom
+*/
+
+qreal QCameraFocus::opticalZoom() const
+{
+ return d_func()->focusControl ? d_func()->focusControl->opticalZoom() : 1.0;
+}
+
+/*!
+ \property QCameraFocus::digitalZoom
+ \brief The current digital zoom value.
+
+ \since 1.1
+ \sa QCameraFocus::opticalZoom
+*/
+qreal QCameraFocus::digitalZoom() const
+{
+ return d_func()->focusControl ? d_func()->focusControl->digitalZoom() : 1.0;
+}
+
+
+/*!
+ Set the camera \a optical and \a digital zoom values.
+ \since 1.1
+*/
+void QCameraFocus::zoomTo(qreal optical, qreal digital)
+{
+ if (d_func()->focusControl)
+ d_func()->focusControl->zoomTo(optical, digital);
+ else
+ qWarning("The camera doesn't support zooming.");
+}
+
+/*!
+ \enum QCameraFocus::FocusMode
+
+ \value ManualFocus Manual or fixed focus mode.
+ \value AutoFocus One-shot auto focus mode.
+ \value ContinuousFocus Continuous auto focus mode.
+ \value InfinityFocus Focus strictly to infinity.
+ \value HyperfocalFocus Focus to hyperfocal distance, with with the maximum depth of field achieved.
+ All objects at distances from half of this
+ distance out to infinity will be acceptably sharp.
+ \value MacroFocus One shot auto focus to objects close to camera.
+*/
+
+/*!
+ \enum QCameraFocus::FocusPointMode
+
+ \value FocusPointAuto Automatically select one or multiple focus points.
+ \value FocusPointCenter Focus to the frame center.
+ \value FocusPointFaceDetection Focus on faces in the frame.
+ \value FocusPointCustom Focus to the custom point, defined by QCameraFocus::customFocusPoint property.
+*/
+
+/*!
+ \fn void QCameraFocus::opticalZoomChanged(qreal value)
+
+ Signal emitted when optical zoom value changes to new \a value.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraFocus::digitalZoomChanged(qreal value)
+
+ Signal emitted when digital zoom value changes to new \a value.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraFocus::maximumOpticalZoomChanged(qreal zoom)
+
+ Signal emitted when the maximum supported optical \a zoom value changed.
+ \since 1.1
+*/
+
+/*!
+ \fn void QCameraFocus::maximumDigitalZoomChanged(qreal zoom)
+
+ Signal emitted when the maximum supported digital \a zoom value changed.
+
+ The maximum supported zoom value can depend on other camera settings,
+ like capture mode or resolution.
+ \since 1.1
+*/
+
+
+
+/*!
+ \fn QCameraFocus::focusZonesChanged()
+
+ Signal is emitted when the set of zones, camera focused on is changed.
+
+ Usually the zones list is changed when the camera is focused.
+ \since 1.1
+*/
+
+
+#include "moc_qcamerafocus.cpp"
+QT_END_NAMESPACE
diff --git a/src/multimedia/camera/qcamerafocus.h b/src/multimedia/camera/qcamerafocus.h
new file mode 100644
index 000000000..064af7aa1
--- /dev/null
+++ b/src/multimedia/camera/qcamerafocus.h
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCAMERAFOCUS_H
+#define QCAMERAFOCUS_H
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qshareddata.h>
+
+#include <qmediaobject.h>
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class QCamera;
+
+class QCameraFocusZoneData;
+
+class Q_MULTIMEDIA_EXPORT QCameraFocusZone {
+public:
+ enum FocusZoneStatus {
+ Invalid,
+ Unused,
+ Selected,
+ Focused
+ };
+
+ QCameraFocusZone();
+ QCameraFocusZone(const QRectF &area, FocusZoneStatus status = Selected);
+ QCameraFocusZone(const QCameraFocusZone &other);
+
+ QCameraFocusZone& operator=(const QCameraFocusZone &other);
+ bool operator==(const QCameraFocusZone &other) const;
+ bool operator!=(const QCameraFocusZone &other) const;
+
+ ~QCameraFocusZone();
+
+ bool isValid() const;
+
+ QRectF area() const;
+
+ FocusZoneStatus status() const;
+ void setStatus(FocusZoneStatus status);
+
+private:
+ QSharedDataPointer<QCameraFocusZoneData> d;
+};
+
+typedef QList<QCameraFocusZone> QCameraFocusZoneList;
+
+
+class QCameraFocusPrivate;
+class Q_MULTIMEDIA_EXPORT QCameraFocus : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(FocusMode focusMode READ focusMode WRITE setFocusMode)
+ Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode)
+ Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint)
+ Q_PROPERTY(QCameraFocusZoneList focusZones READ focusZones NOTIFY focusZonesChanged)
+ Q_PROPERTY(qreal opticalZoom READ opticalZoom NOTIFY opticalZoomChanged)
+ Q_PROPERTY(qreal digitalZoom READ digitalZoom NOTIFY digitalZoomChanged)
+
+ Q_ENUMS(FocusMode)
+ Q_ENUMS(FocusPointMode)
+public:
+ enum FocusMode {
+ ManualFocus = 0x1,
+ HyperfocalFocus = 0x02,
+ InfinityFocus = 0x04,
+ AutoFocus = 0x8,
+ ContinuousFocus = 0x10,
+ MacroFocus = 0x20
+ };
+ Q_DECLARE_FLAGS(FocusModes, FocusMode)
+
+ enum FocusPointMode {
+ FocusPointAuto,
+ FocusPointCenter,
+ FocusPointFaceDetection,
+ FocusPointCustom
+ };
+
+ bool isAvailable() const;
+
+ FocusMode focusMode() const;
+ void setFocusMode(FocusMode mode);
+ bool isFocusModeSupported(FocusMode mode) const;
+
+ FocusPointMode focusPointMode() const;
+ void setFocusPointMode(FocusPointMode mode);
+ bool isFocusPointModeSupported(FocusPointMode) const;
+ QPointF customFocusPoint() const;
+ void setCustomFocusPoint(const QPointF &point);
+
+ QCameraFocusZoneList focusZones() const;
+
+ qreal maximumOpticalZoom() const;
+ qreal maximumDigitalZoom() const;
+ qreal opticalZoom() const;
+ qreal digitalZoom() const;
+
+ void zoomTo(qreal opticalZoom, qreal digitalZoom);
+
+Q_SIGNALS:
+ void opticalZoomChanged(qreal);
+ void digitalZoomChanged(qreal);
+
+ void focusZonesChanged();
+
+ void maximumOpticalZoomChanged(qreal);
+ void maximumDigitalZoomChanged(qreal);
+
+private:
+ friend class QCamera;
+ QCameraFocus(QCamera *camera);
+ ~QCameraFocus();
+
+ Q_DISABLE_COPY(QCameraFocus)
+ Q_DECLARE_PRIVATE(QCameraFocus)
+ QCameraFocusPrivate *d_ptr;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraFocus::FocusModes)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QCameraFocus::FocusModes)
+Q_DECLARE_METATYPE(QCameraFocus::FocusPointMode)
+
+Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusMode)
+Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusPointMode)
+
+QT_END_HEADER
+
+#endif // QCAMERAFOCUS_H
diff --git a/src/multimedia/camera/qcameraimagecapture.cpp b/src/multimedia/camera/qcameraimagecapture.cpp
new file mode 100644
index 000000000..f49531e20
--- /dev/null
+++ b/src/multimedia/camera/qcameraimagecapture.cpp
@@ -0,0 +1,681 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qcameraimagecapture.h>
+#include <qcameraimagecapturecontrol.h>
+#include <qmediaencodersettings.h>
+#include <qcameracapturedestinationcontrol.h>
+#include <qcameracapturebufferformatcontrol.h>
+
+#include <qimageencodercontrol.h>
+#include "qmediaobject_p.h"
+#include <qmediaservice.h>
+#include <qcamera.h>
+#include <qcameracontrol.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCameraImageCapture
+ \inmodule QtMultimedia
+ \ingroup camera
+ \since 1.1
+
+
+ \brief The QCameraImageCapture class is used for the recording of media content.
+
+ The QCameraImageCapture class is a high level images recording class.
+ It's not intended to be used alone but for accessing the media
+ recording functions of other media objects, like QCamera.
+
+ \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera
+
+ \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera keys
+
+ \sa QCamera
+*/
+
+namespace
+{
+class MediaRecorderRegisterMetaTypes
+{
+public:
+ MediaRecorderRegisterMetaTypes()
+ {
+ qRegisterMetaType<QCameraImageCapture::Error>("QCameraImageCapture::Error");
+ qRegisterMetaType<QCameraImageCapture::CaptureDestination>("QCameraImageCapture::CaptureDestination");
+ qRegisterMetaType<QCameraImageCapture::CaptureDestinations>("QCameraImageCapture::CaptureDestinations");
+ }
+} _registerRecorderMetaTypes;
+}
+
+
+class QCameraImageCapturePrivate
+{
+ Q_DECLARE_NON_CONST_PUBLIC(QCameraImageCapture)
+public:
+ QCameraImageCapturePrivate();
+
+ QMediaObject *mediaObject;
+
+ QCameraImageCaptureControl *control;
+ QImageEncoderControl *encoderControl;
+ QCameraCaptureDestinationControl *captureDestinationControl;
+ QCameraCaptureBufferFormatControl *bufferFormatControl;
+
+ QCameraImageCapture::Error error;
+ QString errorString;
+
+ void _q_error(int id, int error, const QString &errorString);
+ void _q_readyChanged(bool);
+ void _q_serviceDestroyed();
+
+ void unsetError() { error = QCameraImageCapture::NoError; errorString.clear(); }
+
+ QCameraImageCapture *q_ptr;
+};
+
+QCameraImageCapturePrivate::QCameraImageCapturePrivate():
+ mediaObject(0),
+ control(0),
+ encoderControl(0),
+ captureDestinationControl(0),
+ bufferFormatControl(0),
+ error(QCameraImageCapture::NoError)
+{
+}
+
+void QCameraImageCapturePrivate::_q_error(int id, int error, const QString &errorString)
+{
+ Q_Q(QCameraImageCapture);
+
+ this->error = QCameraImageCapture::Error(error);
+ this->errorString = errorString;
+
+ emit q->error(id, this->error, errorString);
+}
+
+void QCameraImageCapturePrivate::_q_readyChanged(bool ready)
+{
+ Q_Q(QCameraImageCapture);
+ emit q->readyForCaptureChanged(ready);
+}
+
+void QCameraImageCapturePrivate::_q_serviceDestroyed()
+{
+ mediaObject = 0;
+ control = 0;
+ encoderControl = 0;
+ captureDestinationControl = 0;
+ bufferFormatControl = 0;
+}
+
+/*!
+ Constructs a media recorder which records the media produced by \a mediaObject.
+
+ The \a parent is passed to QMediaObject.
+*/
+
+QCameraImageCapture::QCameraImageCapture(QMediaObject *mediaObject, QObject *parent):
+ QObject(parent), d_ptr(new QCameraImageCapturePrivate)
+{
+ Q_D(QCameraImageCapture);
+
+ d->q_ptr = this;
+
+ if (mediaObject)
+ mediaObject->bind(this);
+}
+
+/*!
+ Destroys images capture object.
+*/
+
+QCameraImageCapture::~QCameraImageCapture()
+{
+ Q_D(QCameraImageCapture);
+
+ if (d->mediaObject)
+ d->mediaObject->unbind(this);
+}
+
+/*!
+ \reimp
+ \since 1.1
+*/
+QMediaObject *QCameraImageCapture::mediaObject() const
+{
+ return d_func()->mediaObject;
+}
+
+/*!
+ \reimp
+ \since 1.1
+*/
+bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject)
+{
+ Q_D(QCameraImageCapture);
+
+ if (d->mediaObject) {
+ if (d->control) {
+ disconnect(d->control, SIGNAL(imageExposed(int)),
+ this, SIGNAL(imageExposed(int)));
+ disconnect(d->control, SIGNAL(imageCaptured(int,QImage)),
+ this, SIGNAL(imageCaptured(int,QImage)));
+ disconnect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)),
+ this, SIGNAL(imageAvailable(int,QVideoFrame)));
+ disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)),
+ this, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)));
+ disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)),
+ this, SIGNAL(imageMetadataAvailable(int,QString,QVariant)));
+ disconnect(d->control, SIGNAL(imageSaved(int,QString)),
+ this, SIGNAL(imageSaved(int,QString)));
+ disconnect(d->control, SIGNAL(readyForCaptureChanged(bool)),
+ this, SLOT(_q_readyChanged(bool)));
+ disconnect(d->control, SIGNAL(error(int,int,QString)),
+ this, SLOT(_q_error(int,int,QString)));
+
+ if (d->captureDestinationControl) {
+ disconnect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)),
+ this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)));
+ }
+
+ if (d->bufferFormatControl) {
+ disconnect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)),
+ this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)));
+ }
+
+ QMediaService *service = d->mediaObject->service();
+ service->releaseControl(d->control);
+ if (d->encoderControl)
+ service->releaseControl(d->encoderControl);
+ if (d->captureDestinationControl)
+ service->releaseControl(d->captureDestinationControl);
+ if (d->bufferFormatControl)
+ service->releaseControl(d->bufferFormatControl);
+
+ disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
+ }
+ }
+
+ d->mediaObject = mediaObject;
+
+ if (d->mediaObject) {
+ QMediaService *service = mediaObject->service();
+ if (service) {
+ d->control = qobject_cast<QCameraImageCaptureControl*>(service->requestControl(QCameraImageCaptureControl_iid));
+
+ if (d->control) {
+ d->encoderControl = qobject_cast<QImageEncoderControl *>(service->requestControl(QImageEncoderControl_iid));
+ d->captureDestinationControl = qobject_cast<QCameraCaptureDestinationControl *>(
+ service->requestControl(QCameraCaptureDestinationControl_iid));
+ d->bufferFormatControl = qobject_cast<QCameraCaptureBufferFormatControl *>(
+ service->requestControl(QCameraCaptureBufferFormatControl_iid));
+
+ connect(d->control, SIGNAL(imageExposed(int)),
+ this, SIGNAL(imageExposed(int)));
+ connect(d->control, SIGNAL(imageCaptured(int,QImage)),
+ this, SIGNAL(imageCaptured(int,QImage)));
+ connect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)),
+ this, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)));
+ connect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)),
+ this, SIGNAL(imageMetadataAvailable(int,QString,QVariant)));
+ connect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)),
+ this, SIGNAL(imageAvailable(int,QVideoFrame)));
+ connect(d->control, SIGNAL(imageSaved(int, QString)),
+ this, SIGNAL(imageSaved(int, QString)));
+ connect(d->control, SIGNAL(readyForCaptureChanged(bool)),
+ this, SLOT(_q_readyChanged(bool)));
+ connect(d->control, SIGNAL(error(int,int,QString)),
+ this, SLOT(_q_error(int,int,QString)));
+
+ if (d->captureDestinationControl) {
+ connect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)),
+ this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)));
+ }
+
+ if (d->bufferFormatControl) {
+ connect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)),
+ this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)));
+ }
+
+ connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
+
+ return true;
+ }
+ }
+ }
+
+ // without QCameraImageCaptureControl discard the media object
+ d->mediaObject = 0;
+ d->control = 0;
+ d->encoderControl = 0;
+ d->captureDestinationControl = 0;
+ d->bufferFormatControl = 0;
+
+ return false;
+}
+
+/*!
+ Returns true if the images capture service ready to use.
+ \since 1.1
+*/
+bool QCameraImageCapture::isAvailable() const
+{
+ if (d_func()->control != NULL)
+ return true;
+ else
+ return false;
+}
+
+/*!
+ Returns the availability error code.
+ \since 1.1
+*/
+QtMultimedia::AvailabilityError QCameraImageCapture::availabilityError() const
+{
+ if (d_func()->control != NULL)
+ return QtMultimedia::NoError;
+ else
+ return QtMultimedia::ServiceMissingError;
+}
+
+/*!
+ Returns the current error state.
+
+ \since 1.1
+ \sa errorString()
+*/
+
+QCameraImageCapture::Error QCameraImageCapture::error() const
+{
+ return d_func()->error;
+}
+
+/*!
+ Returns a string describing the current error state.
+
+ \since 1.1
+ \sa error()
+*/
+
+QString QCameraImageCapture::errorString() const
+{
+ return d_func()->errorString;
+}
+
+
+/*!
+ Returns a list of supported image codecs.
+ \since 1.1
+*/
+QStringList QCameraImageCapture::supportedImageCodecs() const
+{
+ return d_func()->encoderControl ?
+ d_func()->encoderControl->supportedImageCodecs() : QStringList();
+}
+
+/*!
+ Returns a description of an image \a codec.
+ \since 1.1
+*/
+QString QCameraImageCapture::imageCodecDescription(const QString &codec) const
+{
+ return d_func()->encoderControl ?
+ d_func()->encoderControl->imageCodecDescription(codec) : QString();
+}
+
+/*!
+ Returns a list of resolutions images can be encoded at.
+
+ If non null image \a settings parameter is passed,
+ the returned list is reduced to resolution supported with partial settings like image codec or quality applied.
+
+ If the encoder supports arbitrary resolutions within the supported range,
+ *\a continuous is set to true, otherwise *\a continuous is set to false.
+
+ \since 1.1
+ \sa QImageEncoderSettings::resolution()
+*/
+QList<QSize> QCameraImageCapture::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
+{
+ if (continuous)
+ *continuous = false;
+
+ return d_func()->encoderControl ?
+ d_func()->encoderControl->supportedResolutions(settings, continuous) : QList<QSize>();
+}
+
+/*!
+ Returns the image encoder settings being used.
+
+ \since 1.1
+ \sa setEncodingSettings()
+*/
+
+QImageEncoderSettings QCameraImageCapture::encodingSettings() const
+{
+ return d_func()->encoderControl ?
+ d_func()->encoderControl->imageSettings() : QImageEncoderSettings();
+}
+
+/*!
+ Sets the image encoding \a settings.
+
+ If some parameters are not specified, or null settings are passed,
+ the encoder choose the default encoding parameters.
+
+ \since 1.1
+ \sa encodingSettings()
+*/
+
+void QCameraImageCapture::setEncodingSettings(const QImageEncoderSettings &settings)
+{
+ Q_D(QCameraImageCapture);
+
+ if (d->encoderControl) {
+ QCamera *camera = qobject_cast<QCamera*>(d->mediaObject);
+ if (camera && camera->captureMode() == QCamera::CaptureStillImage) {
+ QMetaObject::invokeMethod(camera,
+ "_q_preparePropertyChange",
+ Qt::DirectConnection,
+ Q_ARG(int, QCameraControl::ImageEncodingSettings));
+ }
+
+ d->encoderControl->setImageSettings(settings);
+ }
+}
+
+/*!
+ Returns the list of supported buffer image capture formats.
+
+ \since 1.1
+ \sa bufferFormat() setBufferFormat()
+*/
+QList<QVideoFrame::PixelFormat> QCameraImageCapture::supportedBufferFormats() const
+{
+ if (d_func()->bufferFormatControl)
+ return d_func()->bufferFormatControl->supportedBufferFormats();
+ else
+ return QList<QVideoFrame::PixelFormat>();
+}
+
+/*!
+ Returns the buffer image capture format being used.
+
+ \since 1.2
+ \sa supportedBufferCaptureFormats() setBufferCaptureFormat()
+*/
+QVideoFrame::PixelFormat QCameraImageCapture::bufferFormat() const
+{
+ if (d_func()->bufferFormatControl)
+ return d_func()->bufferFormatControl->bufferFormat();
+ else
+ return QVideoFrame::Format_Invalid;
+}
+
+/*!
+ Sets the buffer image capture format to be used.
+
+ \since 1.2
+ \sa bufferCaptureFormat() supportedBufferCaptureFormats() captureDestination()
+*/
+void QCameraImageCapture::setBufferFormat(const QVideoFrame::PixelFormat format)
+{
+ if (d_func()->bufferFormatControl)
+ d_func()->bufferFormatControl->setBufferFormat(format);
+}
+
+/*!
+ Returns true if the image capture \a destination is supported; otherwise returns false.
+
+ \since 1.2
+ \sa captureDestination() setCaptureDestination()
+*/
+bool QCameraImageCapture::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const
+{
+ if (d_func()->captureDestinationControl)
+ return d_func()->captureDestinationControl->isCaptureDestinationSupported(destination);
+ else
+ return destination == CaptureToFile;
+}
+
+/*!
+ Returns the image capture destination being used.
+
+ \since 1.2
+ \sa isCaptureDestinationSupported() setCaptureDestination()
+*/
+QCameraImageCapture::CaptureDestinations QCameraImageCapture::captureDestination() const
+{
+ if (d_func()->captureDestinationControl)
+ return d_func()->captureDestinationControl->captureDestination();
+ else
+ return CaptureToFile;
+}
+
+/*!
+ Sets the capture \a destination to be used.
+
+ \since 1.2
+ \sa isCaptureDestinationSupported() captureDestination()
+*/
+void QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination)
+{
+ Q_D(QCameraImageCapture);
+
+ if (d->captureDestinationControl)
+ d->captureDestinationControl->setCaptureDestination(destination);
+}
+
+/*!
+ \property QCameraImageCapture::readyForCapture
+ Indicates the service is ready to capture a an image immediately.
+ \since 1.1
+*/
+
+bool QCameraImageCapture::isReadyForCapture() const
+{
+ if (d_func()->control)
+ return d_func()->control->isReadyForCapture();
+ else
+ return false;
+}
+
+/*!
+ \fn QCameraImageCapture::readyForCaptureChanged(bool ready)
+
+ Signals that a camera's \a ready for capture state has changed.
+ \since 1.1
+*/
+
+
+/*!
+ Capture the image and save it to \a file.
+ This operation is asynchronous in majority of cases,
+ followed by signals QCameraImageCapture::imageCaptured(), QCameraImageCapture::imageSaved()
+ or QCameraImageCapture::error().
+
+ If an empty \a file is passed, the camera backend choses
+ the default location and naming scheme for photos on the system,
+ if only file name without full path is specified, the image will be saved to
+ the default directory, with a full path reported with imageCaptured() and imageSaved() signals.
+
+ QCameraImageCapture::capture returns the capture Id parameter, used with
+ imageExposed(), imageCaptured() and imageSaved() signals.
+ \since 1.1
+*/
+int QCameraImageCapture::capture(const QString &file)
+{
+ Q_D(QCameraImageCapture);
+
+ d->unsetError();
+
+ if (d->control) {
+ return d->control->capture(file);
+ } else {
+ d->error = NotSupportedFeatureError;
+ d->errorString = tr("Device does not support images capture.");
+
+ emit error(-1, d->error, d->errorString);
+ }
+
+ return -1;
+}
+
+/*!
+ Cancel incomplete capture requests.
+ Already captured and queused for proicessing images may be discarded.
+ \since 1.1
+*/
+void QCameraImageCapture::cancelCapture()
+{
+ Q_D(QCameraImageCapture);
+
+ d->unsetError();
+
+ if (d->control) {
+ d->control->cancelCapture();
+ } else {
+ d->error = NotSupportedFeatureError;
+ d->errorString = tr("Device does not support images capture.");
+
+ emit error(-1, d->error, d->errorString);
+ }
+}
+
+
+/*!
+ \enum QCameraImageCapture::Error
+
+ \value NoError No Errors.
+ \value NotReadyError The service is not ready for capture yet.
+ \value ResourceError Device is not ready or not available.
+ \value NotSupportedFeatureError Device does not support stillimages capture.
+ \value FormatError Current format is not supported.
+ \value OutOfSpaceError No space left on device.
+*/
+
+/*!
+ \enum QCameraImageCapture::DriveMode
+
+ \value SingleImageCapture Drive mode is capturing a single picture.
+*/
+
+/*!
+ \fn QCameraImageCapture::error(int id, QCameraImageCapture::Error error, const QString &errorString)
+
+ Signals that the capture request \a id has failed with an \a error
+ and \a errorString description.
+ \since 1.1
+*/
+
+/*!
+ \fn QCameraImageCapture::bufferFormatChanged(QVideoFrame::PixelFormat format)
+
+ Signal emitted when the buffer \a format for the buffer image capture has changed.
+ \since 1.2
+*/
+
+/*!
+ \fn QCameraImageCapture::captureDestinationChanged(CaptureDestinations destination)
+
+ Signal emitted when the capture \a destination has changed.
+ \since 1.2
+*/
+
+/*!
+ \fn QCameraImageCapture::imageExposed(int id)
+
+ Signal emitted when the frame with request \a id was exposed.
+ \since 1.1
+*/
+
+/*!
+ \fn QCameraImageCapture::imageCaptured(int id, const QImage &preview);
+
+ Signal emitted when the frame with request \a id was captured, but not processed and saved yet.
+ Frame \a preview can be displayed to user.
+ \since 1.1
+*/
+
+/*!
+ \fn QCameraImageCapture::imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value)
+
+ Signals that a metadata for an image with request \a id is available.
+ This signal is emitted for metadata \a value with a \a key listed in QtMultimedia::MetaData enum.
+
+ This signal is emitted between imageExposed and imageSaved signals.
+ \since 1.2
+*/
+
+/*!
+ \fn QCameraImageCapture::imageMetadataAvailable(int id, const QString &key, const QVariant &value)
+
+ Signals that a metadata for an image with request \a id is available.
+ This signal is emitted for extended metadata \a value with a \a key not listed in QtMultimedia::MetaData enum.
+
+ This signal is emitted between imageExposed and imageSaved signals.
+ \since 1.2
+*/
+
+
+/*!
+ \fn QCameraImageCapture::imageAvailable(int id, const QVideoFrame &buffer)
+
+ Signal emitted when the frame with request \a id is available as \a buffer.
+ \since 1.2
+*/
+
+/*!
+ \fn QCameraImageCapture::imageSaved(int id, const QString &fileName)
+
+ Signal emitted when the frame with request \a id was saved to \a fileName.
+ \since 1.1
+*/
+
+
+#include "moc_qcameraimagecapture.cpp"
+QT_END_NAMESPACE
+
diff --git a/src/multimedia/camera/qcameraimagecapture.h b/src/multimedia/camera/qcameraimagecapture.h
new file mode 100644
index 000000000..bc4162287
--- /dev/null
+++ b/src/multimedia/camera/qcameraimagecapture.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCAMERAIMAGECAPTURE_H
+#define QCAMERAIMAGECAPTURE_H
+
+#include <qmediaobject.h>
+#include <qmediaencodersettings.h>
+#include <qmediabindableinterface.h>
+#include <qvideoframe.h>
+
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+class QSize;
+QT_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+
+class QImageEncoderSettings;
+
+class QCameraImageCapturePrivate;
+class Q_MULTIMEDIA_EXPORT QCameraImageCapture : public QObject, public QMediaBindableInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QMediaBindableInterface)
+ Q_ENUMS(Error)
+ Q_ENUMS(CaptureDestination)
+ Q_PROPERTY(bool readyForCapture READ isReadyForCapture NOTIFY readyForCaptureChanged)
+public:
+ enum Error
+ {
+ NoError,
+ NotReadyError,
+ ResourceError,
+ OutOfSpaceError,
+ NotSupportedFeatureError,
+ FormatError
+ };
+
+ enum DriveMode
+ {
+ SingleImageCapture
+ };
+
+ enum CaptureDestination
+ {
+ CaptureToFile = 0x01,
+ CaptureToBuffer = 0x02
+ };
+ Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination)
+
+ QCameraImageCapture(QMediaObject *mediaObject, QObject *parent = 0);
+ ~QCameraImageCapture();
+
+ bool isAvailable() const;
+ QtMultimedia::AvailabilityError availabilityError() const;
+
+ QMediaObject *mediaObject() const;
+
+ Error error() const;
+ QString errorString() const;
+
+ bool isReadyForCapture() const;
+
+ QStringList supportedImageCodecs() const;
+ QString imageCodecDescription(const QString &codecName) const;
+
+ QList<QSize> supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(),
+ bool *continuous = 0) const;
+
+ QImageEncoderSettings encodingSettings() const;
+ void setEncodingSettings(const QImageEncoderSettings& settings);
+
+ QList<QVideoFrame::PixelFormat> supportedBufferFormats() const;
+ QVideoFrame::PixelFormat bufferFormat() const;
+ void setBufferFormat(QVideoFrame::PixelFormat format);
+
+ bool isCaptureDestinationSupported(CaptureDestinations destination) const;
+ CaptureDestinations captureDestination() const;
+ void setCaptureDestination(CaptureDestinations destination);
+
+public Q_SLOTS:
+ int capture(const QString &location = QString());
+ void cancelCapture();
+
+Q_SIGNALS:
+ void error(int id, QCameraImageCapture::Error error, const QString &errorString);
+
+ void readyForCaptureChanged(bool);
+ void bufferFormatChanged(QVideoFrame::PixelFormat);
+ void captureDestinationChanged(QCameraImageCapture::CaptureDestinations);
+
+ void imageExposed(int id);
+ void imageCaptured(int id, const QImage &preview);
+ void imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value);
+ void imageMetadataAvailable(int id, const QString &key, const QVariant &value);
+ void imageAvailable(int id, const QVideoFrame &image);
+ void imageSaved(int id, const QString &fileName);
+
+protected:
+ bool setMediaObject(QMediaObject *);
+
+ QCameraImageCapturePrivate *d_ptr;
+private:
+ Q_DISABLE_COPY(QCameraImageCapture)
+ Q_DECLARE_PRIVATE(QCameraImageCapture)
+ Q_PRIVATE_SLOT(d_func(), void _q_error(int, int, const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_readyChanged(bool))
+ Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraImageCapture::CaptureDestinations)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QCameraImageCapture::Error)
+Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestination)
+Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestinations)
+
+Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, Error)
+Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, CaptureDestination)
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/multimedia/camera/qcameraimageprocessing.cpp b/src/multimedia/camera/qcameraimageprocessing.cpp
new file mode 100644
index 000000000..850606792
--- /dev/null
+++ b/src/multimedia/camera/qcameraimageprocessing.cpp
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcameraimageprocessing.h"
+#include "qmediaobject_p.h"
+
+#include <qcameracontrol.h>
+#include <qcameraexposurecontrol.h>
+#include <qcamerafocuscontrol.h>
+#include <qmediarecordercontrol.h>
+#include <qcameraimageprocessingcontrol.h>
+#include <qcameraimagecapturecontrol.h>
+#include <qvideodevicecontrol.h>
+
+#include <QtCore/QDebug>
+
+namespace
+{
+ class QCameraImageProcessingPrivateRegisterMetaTypes
+ {
+ public:
+ QCameraImageProcessingPrivateRegisterMetaTypes()
+ {
+ qRegisterMetaType<QCameraImageProcessing::WhiteBalanceMode>();
+ }
+ } _registerMetaTypes;
+}
+
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCameraImageProcessing
+
+
+ \brief The QCameraImageProcessing class provides interface for
+ focus and zoom related camera settings.
+
+ \inmodule QtMultimedia
+ \ingroup camera
+ \since 1.1
+
+*/
+
+
+class QCameraImageProcessingPrivate : public QMediaObjectPrivate
+{
+ Q_DECLARE_NON_CONST_PUBLIC(QCameraImageProcessing)
+public:
+ void initControls();
+
+ QCameraImageProcessing *q_ptr;
+
+ QCamera *camera;
+ QCameraImageProcessingControl *imageControl;
+};
+
+
+void QCameraImageProcessingPrivate::initControls()
+{
+ imageControl = 0;
+
+ QMediaService *service = camera->service();
+ if (service)
+ imageControl = qobject_cast<QCameraImageProcessingControl *>(service->requestControl(QCameraImageProcessingControl_iid));
+}
+
+/*!
+ Construct a QCameraImageProcessing for \a camera.
+*/
+
+QCameraImageProcessing::QCameraImageProcessing(QCamera *camera):
+ QObject(camera), d_ptr(new QCameraImageProcessingPrivate)
+{
+ Q_D(QCameraImageProcessing);
+ d->camera = camera;
+ d->q_ptr = this;
+ d->initControls();
+}
+
+
+/*!
+ Destroys the camera focus object.
+*/
+
+QCameraImageProcessing::~QCameraImageProcessing()
+{
+}
+
+
+/*!
+ Returns true if image processing related settings are supported by this camera.
+ \since 1.1
+*/
+bool QCameraImageProcessing::isAvailable() const
+{
+ return d_func()->imageControl != 0;
+}
+
+
+/*!
+ Returns the white balance mode being used.
+ \since 1.1
+*/
+
+QCameraImageProcessing::WhiteBalanceMode QCameraImageProcessing::whiteBalanceMode() const
+{
+ return d_func()->imageControl ? d_func()->imageControl->whiteBalanceMode() : QCameraImageProcessing::WhiteBalanceAuto;
+}
+
+/*!
+ Sets the white balance to \a mode.
+ \since 1.1
+*/
+
+void QCameraImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
+{
+ if (d_func()->imageControl)
+ d_func()->imageControl->setWhiteBalanceMode(mode);
+}
+
+/*!
+ Returns true if the white balance \a mode is supported.
+ \since 1.1
+*/
+
+bool QCameraImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
+{
+ return d_func()->imageControl ? d_func()->imageControl->isWhiteBalanceModeSupported(mode) : false;
+}
+
+/*!
+ Returns the current color temperature if the
+ manual white balance is active, otherwise the
+ return value is undefined.
+ \since 1.1
+*/
+
+int QCameraImageProcessing::manualWhiteBalance() const
+{
+ QVariant value;
+
+ if (d_func()->imageControl)
+ value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::ColorTemperature);
+
+ return value.toInt();
+}
+
+/*!
+ Sets manual white balance to \a colorTemperature
+ \since 1.1
+*/
+
+void QCameraImageProcessing::setManualWhiteBalance(int colorTemperature)
+{
+ if (d_func()->imageControl) {
+ d_func()->imageControl->setProcessingParameter(
+ QCameraImageProcessingControl::ColorTemperature,
+ QVariant(colorTemperature));
+ }
+}
+
+/*!
+ Return the contrast.
+ \since 1.1
+*/
+int QCameraImageProcessing::contrast() const
+{
+ QVariant value;
+
+ if (d_func()->imageControl)
+ value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Contrast);
+
+ return value.toInt();
+}
+
+/*!
+ Set the contrast to \a value.
+
+ Valid contrast values range between -100 and 100, the default is 0.
+ \since 1.1
+*/
+void QCameraImageProcessing::setContrast(int value)
+{
+ if (d_func()->imageControl)
+ d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Contrast,
+ QVariant(value));
+}
+
+/*!
+ Returns the saturation value.
+ \since 1.1
+*/
+int QCameraImageProcessing::saturation() const
+{
+ QVariant value;
+
+ if (d_func()->imageControl)
+ value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Saturation);
+
+ return value.toInt();
+}
+
+/*!
+ Sets the saturation value to \a value.
+
+ Valid saturation values range between -100 and 100, the default is 0.
+ \since 1.1
+*/
+
+void QCameraImageProcessing::setSaturation(int value)
+{
+ if (d_func()->imageControl)
+ d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Saturation,
+ QVariant(value));
+}
+
+/*!
+ Identifies if sharpening is supported.
+
+ Returns true if sharpening is supported; and false if it is not.
+ \since 1.1
+*/
+bool QCameraImageProcessing::isSharpeningSupported() const
+{
+ if (d_func()->imageControl)
+ return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Sharpening);
+ else
+ return false;
+}
+
+/*!
+ Returns the sharpening level.
+ \since 1.1
+*/
+int QCameraImageProcessing::sharpeningLevel() const
+{
+ QVariant value;
+
+ if (d_func()->imageControl)
+ value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Sharpening);
+
+ if (value.isNull())
+ return -1;
+ else
+ return value.toInt();
+}
+
+/*!
+ Sets the sharpening \a level.
+
+ Valid sharpening level values range between -1 for default sharpening level,
+ 0 for sharpening disabled and 100 for maximum sharpening applied.
+ \since 1.1
+*/
+
+void QCameraImageProcessing::setSharpeningLevel(int level)
+{
+ Q_D(QCameraImageProcessing);
+ if (d->imageControl)
+ d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Sharpening,
+ level == -1 ? QVariant() : QVariant(level));
+}
+
+/*!
+ Returns true if denoising is supported.
+ \since 1.1
+*/
+bool QCameraImageProcessing::isDenoisingSupported() const
+{
+ if (d_func()->imageControl)
+ return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Denoising);
+ else
+ return false;
+}
+
+/*!
+ Returns the denoising level.
+ \since 1.1
+*/
+int QCameraImageProcessing::denoisingLevel() const
+{
+ QVariant value;
+
+ if (d_func()->imageControl)
+ value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Denoising);
+
+ if (value.isNull())
+ return -1;
+ else
+ return value.toInt();
+}
+
+/*!
+ Sets the denoising \a level.
+
+ Valid denoising level values range between -1 for default denoising level,
+ 0 for denoising disabled and 100 for maximum denoising applied.
+ \since 1.1
+*/
+void QCameraImageProcessing::setDenoisingLevel(int level)
+{
+ Q_D(QCameraImageProcessing);
+ if (d->imageControl)
+ d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Denoising,
+ level == -1 ? QVariant() : QVariant(level));
+}
+
+
+/*!
+ \enum QCameraImageProcessing::WhiteBalanceMode
+
+ \value WhiteBalanceManual Manual white balance. In this mode the white balance should be set with
+ setManualWhiteBalance()
+ \value WhiteBalanceAuto Auto white balance mode.
+ \value WhiteBalanceSunlight Sunlight white balance mode.
+ \value WhiteBalanceCloudy Cloudy white balance mode.
+ \value WhiteBalanceShade Shade white balance mode.
+ \value WhiteBalanceTungsten Tungsten white balance mode.
+ \value WhiteBalanceFluorescent Fluorescent white balance mode.
+ \value WhiteBalanceFlash Flash white balance mode.
+ \value WhiteBalanceSunset Sunset white balance mode.
+ \value WhiteBalanceVendor Vendor defined white balance mode.
+*/
+
+#include "moc_qcameraimageprocessing.cpp"
+QT_END_NAMESPACE
diff --git a/src/multimedia/camera/qcameraimageprocessing.h b/src/multimedia/camera/qcameraimageprocessing.h
new file mode 100644
index 000000000..42a7eb589
--- /dev/null
+++ b/src/multimedia/camera/qcameraimageprocessing.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCAMERAIMAGEPROCESSING_H
+#define QCAMERAIMAGEPROCESSING_H
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+
+#include <qmediacontrol.h>
+#include <qmediaobject.h>
+#include <qmediaservice.h>
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+
+class QCamera;
+
+class QCameraImageProcessingPrivate;
+class Q_MULTIMEDIA_EXPORT QCameraImageProcessing : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(WhiteBalanceMode)
+public:
+ enum WhiteBalanceMode {
+ WhiteBalanceAuto = 0,
+ WhiteBalanceManual = 1,
+ WhiteBalanceSunlight = 2,
+ WhiteBalanceCloudy = 3,
+ WhiteBalanceShade = 4,
+ WhiteBalanceTungsten = 5,
+ WhiteBalanceFluorescent = 6,
+ WhiteBalanceFlash = 7,
+ WhiteBalanceSunset = 8,
+ WhiteBalanceVendor = 1000
+ };
+
+ bool isAvailable() const;
+
+ WhiteBalanceMode whiteBalanceMode() const;
+ void setWhiteBalanceMode(WhiteBalanceMode mode);
+ bool isWhiteBalanceModeSupported(WhiteBalanceMode mode) const;
+ int manualWhiteBalance() const;
+ void setManualWhiteBalance(int colorTemperature);
+
+ int contrast() const;
+ void setContrast(int value);
+
+ int saturation() const;
+ void setSaturation(int value);
+
+ bool isSharpeningSupported() const;
+ int sharpeningLevel() const;
+ void setSharpeningLevel(int value);
+
+ bool isDenoisingSupported() const;
+ int denoisingLevel() const;
+ void setDenoisingLevel(int value);
+
+private:
+ friend class QCamera;
+ QCameraImageProcessing(QCamera *camera);
+ ~QCameraImageProcessing();
+
+ Q_DISABLE_COPY(QCameraImageProcessing)
+ Q_DECLARE_PRIVATE(QCameraImageProcessing)
+ QCameraImageProcessingPrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QCameraImageProcessing::WhiteBalanceMode)
+
+Q_MEDIA_ENUM_DEBUG(QCameraImageProcessing, WhiteBalanceMode)
+
+QT_END_HEADER
+
+#endif // QCAMERAIMAGEPROCESSING_H