Restructure the source code a little.

Change-Id: I995b0fb33bdda7f01bf6266c1c50a1b17eba6760
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Michael Goddard
2012-01-04 16:05:55 +10:00
committed by Qt by Nokia
parent 6ee1977d60
commit 502d3c8eb3
123 changed files with 198 additions and 169 deletions

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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