QCameraExposure API refactoring

QCameraExposureControl:
 Separated requested from actual exposure values.
 Removed ParameterFlags, it's confusing and seldom used.
 Moved ExposureMode and MeteringMode to parameters.

QCameraExposure:
 Added requestedAperture/ShutterSpeed/Iso getters

Change-Id: I408586d85e6c9de0c8a711c32b3c90ea46052270
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Dmytro Poplavskiy
2012-01-10 13:32:24 +10:00
committed by Qt by Nokia
parent a9d78fbec9
commit 2db9b4b1c8
7 changed files with 289 additions and 274 deletions

View File

@@ -80,7 +80,7 @@ QDeclarativeTorch::QDeclarativeTorch(QObject *parent)
m_flash = service ? service->requestControl<QCameraFlashControl*>() : 0;
if (m_exposure)
connect(m_exposure, SIGNAL(exposureParameterChanged(int)), SLOT(parameterChanged(int)));
connect(m_exposure, SIGNAL(valueChanged(int)), SLOT(parameterChanged(int)));
// XXX There's no signal for flash mode changed
}
@@ -153,7 +153,7 @@ int QDeclarativeTorch::power() const
if (!m_exposure)
return 0;
return m_exposure->exposureParameter(QCameraExposureControl::FlashPower).toInt();
return m_exposure->requestedValue(QCameraExposureControl::TorchPower).toInt();
}
/*!
@@ -166,10 +166,8 @@ void QDeclarativeTorch::setPower(int power)
return;
power = qBound(0, power, 100);
if (this->power() != power) {
m_exposure->setExposureParameter(QCameraExposureControl::FlashPower, power);
emit powerChanged();
}
if (this->power() != power)
m_exposure->setValue(QCameraExposureControl::TorchPower, power);
}
/* Check for changes in flash power */

View File

@@ -65,10 +65,6 @@ QT_BEGIN_NAMESPACE
//#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
@@ -92,6 +88,11 @@ public:
void initControls();
QCameraExposure *q_ptr;
template<typename T> T actualExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &defaultValue) const;
template<typename T> T requestedExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &defaultValue) const;
template<typename T> void setExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &value);
void resetExposureParameter(QCameraExposureControl::ExposureParameter parameter);
QCamera *camera;
QCameraExposureControl *exposureControl;
QCameraFlashControl *flashControl;
@@ -112,9 +113,9 @@ void QCameraExposurePrivate::initControls()
flashControl = qobject_cast<QCameraFlashControl *>(service->requestControl(QCameraFlashControl_iid));
}
if (exposureControl) {
q->connect(exposureControl, SIGNAL(exposureParameterChanged(int)),
q->connect(exposureControl, SIGNAL(actualValueChanged(int)),
q, SLOT(_q_exposureParameterChanged(int)));
q->connect(exposureControl, SIGNAL(exposureParameterRangeChanged(int)),
q->connect(exposureControl, SIGNAL(parameterRangeChanged(int)),
q, SLOT(_q_exposureParameterRangeChanged(int)));
}
@@ -122,14 +123,44 @@ void QCameraExposurePrivate::initControls()
q->connect(flashControl, SIGNAL(flashReady(bool)), q, SIGNAL(flashReady(bool)));
}
template<typename T>
T QCameraExposurePrivate::actualExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &defaultValue) const
{
QVariant value = exposureControl ? exposureControl->actualValue(parameter) : QVariant();
return value.isValid() ? value.value<T>() : defaultValue;
}
template<typename T>
T QCameraExposurePrivate::requestedExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &defaultValue) const
{
QVariant value = exposureControl ? exposureControl->requestedValue(parameter) : QVariant();
return value.isValid() ? value.value<T>() : defaultValue;
}
template<typename T>
void QCameraExposurePrivate::setExposureParameter(QCameraExposureControl::ExposureParameter parameter, const T &value)
{
if (exposureControl)
exposureControl->setValue(parameter, QVariant::fromValue<T>(value));
}
void QCameraExposurePrivate::resetExposureParameter(QCameraExposureControl::ExposureParameter parameter)
{
if (exposureControl)
exposureControl->setValue(parameter, QVariant());
}
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));
<< QCameraExposureControl::ExposureParameter(parameter)
<< exposureControl->actualValue(QCameraExposureControl::ExposureParameter(parameter));
#endif
switch (parameter) {
@@ -236,7 +267,6 @@ bool QCameraExposure::isFlashReady() const
return d_func()->flashControl ? d_func()->flashControl->isFlashReady() : false;
}
/*!
\property QCameraExposure::exposureMode
\brief The exposure mode being used.
@@ -246,13 +276,12 @@ bool QCameraExposure::isFlashReady() const
QCameraExposure::ExposureMode QCameraExposure::exposureMode() const
{
return d_func()->exposureControl ? d_func()->exposureControl->exposureMode() : QCameraExposure::ExposureAuto;
return d_func()->actualExposureParameter<QCameraExposure::ExposureMode>(QCameraExposureControl::ExposureMode, QCameraExposure::ExposureAuto);
}
void QCameraExposure::setExposureMode(QCameraExposure::ExposureMode mode)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureMode(mode);
d_func()->setExposureParameter<QCameraExposure::ExposureMode>(QCameraExposureControl::ExposureMode, mode);
}
/*!
@@ -261,8 +290,12 @@ void QCameraExposure::setExposureMode(QCameraExposure::ExposureMode mode)
bool QCameraExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const
{
return d_func()->exposureControl ?
d_func()->exposureControl->isExposureModeSupported(mode) : false;
if (!d_func()->exposureControl)
return false;
bool continuous = false;
return d_func()->exposureControl->supportedParameterRange(QCameraExposureControl::ExposureMode, &continuous)
.contains(QVariant::fromValue<QCameraExposure::ExposureMode>(mode));
}
/*!
@@ -274,16 +307,12 @@ bool QCameraExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode
qreal QCameraExposure::exposureCompensation() const
{
if (d_func()->exposureControl)
return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ExposureCompensation).toReal();
else
return 0;
return d_func()->actualExposureParameter<qreal>(QCameraExposureControl::ExposureCompensation, 0.0);
}
void QCameraExposure::setExposureCompensation(qreal ev)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ExposureCompensation, QVariant(ev));
d_func()->setExposureParameter<qreal>(QCameraExposureControl::ExposureCompensation, ev);
}
/*!
@@ -295,13 +324,12 @@ void QCameraExposure::setExposureCompensation(qreal ev)
QCameraExposure::MeteringMode QCameraExposure::meteringMode() const
{
return d_func()->exposureControl ? d_func()->exposureControl->meteringMode() : QCameraExposure::MeteringMatrix;
return d_func()->actualExposureParameter<QCameraExposure::MeteringMode>(QCameraExposureControl::MeteringMode, QCameraExposure::MeteringMatrix);
}
void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setMeteringMode(mode);
d_func()->setExposureParameter<QCameraExposure::MeteringMode>(QCameraExposureControl::MeteringMode, mode);
}
/*!
@@ -320,13 +348,13 @@ void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
QPointF QCameraExposure::spotMeteringPoint() const
{
return d_func()->exposureControl ? d_func()->exposureControl->exposureParameter(QCameraExposureControl::SpotMeteringPoint).toPointF() : QPointF();
return d_func()->exposureControl ? d_func()->exposureControl->actualValue(QCameraExposureControl::SpotMeteringPoint).toPointF() : QPointF();
}
void QCameraExposure::setSpotMeteringPoint(const QPointF &point)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::SpotMeteringPoint, point);
d_func()->exposureControl->setValue(QCameraExposureControl::SpotMeteringPoint, point);
}
@@ -335,15 +363,26 @@ void QCameraExposure::setSpotMeteringPoint(const QPointF &point)
*/
bool QCameraExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
{
return d_func()->exposureControl ? d_func()->exposureControl->isMeteringModeSupported(mode) : false;
if (!d_func()->exposureControl)
return false;
bool continuous = false;
return d_func()->exposureControl->supportedParameterRange(QCameraExposureControl::MeteringMode, &continuous)
.contains(QVariant::fromValue<QCameraExposure::MeteringMode>(mode));
}
int QCameraExposure::isoSensitivity() const
{
if (d_func()->exposureControl)
return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ISO).toInt();
return d_func()->actualExposureParameter<int>(QCameraExposureControl::ISO, -1);
}
return -1;
/*!
Returns the requested ISO sensitivity
or -1 if automatic ISO is turned on.
*/
int QCameraExposure::requestedIsoSensitivity() const
{
return d_func()->requestedExposureParameter<int>(QCameraExposureControl::ISO, -1);
}
/*!
@@ -357,11 +396,15 @@ QList<int> QCameraExposure::supportedIsoSensitivities(bool *continuous) const
QList<int> res;
QCameraExposureControl *control = d_func()->exposureControl;
bool tmp = false;
if (!continuous)
continuous = &tmp;
if (!control)
return res;
foreach (const QVariant &value,
control->supportedParameterRange(QCameraExposureControl::ISO)) {
control->supportedParameterRange(QCameraExposureControl::ISO, continuous)) {
bool ok = false;
int intValue = value.toInt(&ok);
if (ok)
@@ -370,10 +413,6 @@ QList<int> QCameraExposure::supportedIsoSensitivities(bool *continuous) const
qWarning() << "Incompatible ISO value type, int is expected";
}
if (continuous)
*continuous = control->exposureParameterFlags(QCameraExposureControl::ISO) &
QCameraExposureControl::ContinuousRange;
return res;
}
@@ -384,8 +423,7 @@ QList<int> QCameraExposure::supportedIsoSensitivities(bool *continuous) const
void QCameraExposure::setManualIsoSensitivity(int iso)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant(iso));
d_func()->setExposureParameter<int>(QCameraExposureControl::ISO, iso);
}
/*!
@@ -395,8 +433,7 @@ void QCameraExposure::setManualIsoSensitivity(int iso)
void QCameraExposure::setAutoIsoSensitivity()
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant());
d_func()->resetExposureParameter(QCameraExposureControl::ISO);
}
/*!
@@ -423,18 +460,25 @@ void QCameraExposure::setAutoIsoSensitivity()
\property QCameraExposure::aperture
\brief Lens aperture is specified as an F number, the ratio of the focal length to effective aperture diameter.
\sa supportedApertures(), setAutoAperture(), setManualAperture()
\sa supportedApertures(), setAutoAperture(), setManualAperture(), requestedAperture()
*/
qreal QCameraExposure::aperture() const
{
if (d_func()->exposureControl)
return d_func()->exposureControl->exposureParameter(QCameraExposureControl::Aperture).toReal();
return -1.0;
return d_func()->actualExposureParameter<qreal>(QCameraExposureControl::Aperture, -1.0);
}
/*!
Returns the requested manual aperture
or -1.0 if automatic aperture is turned on.
*/
qreal QCameraExposure::requestedAperture() const
{
return d_func()->requestedExposureParameter<qreal>(QCameraExposureControl::Aperture, -1.0);
}
/*!
Returns the list of aperture values camera supports.
The apertures list can change depending on the focal length,
@@ -448,11 +492,15 @@ QList<qreal> QCameraExposure::supportedApertures(bool * continuous) const
QList<qreal> res;
QCameraExposureControl *control = d_func()->exposureControl;
bool tmp = false;
if (!continuous)
continuous = &tmp;
if (!control)
return res;
foreach (const QVariant &value,
control->supportedParameterRange(QCameraExposureControl::Aperture)) {
control->supportedParameterRange(QCameraExposureControl::Aperture, continuous)) {
bool ok = false;
qreal realValue = value.toReal(&ok);
if (ok)
@@ -461,10 +509,6 @@ QList<qreal> QCameraExposure::supportedApertures(bool * continuous) const
qWarning() << "Incompatible aperture value type, qreal is expected";
}
if (continuous)
*continuous = control->exposureParameterFlags(QCameraExposureControl::Aperture) &
QCameraExposureControl::ContinuousRange;
return res;
}
@@ -475,8 +519,7 @@ QList<qreal> QCameraExposure::supportedApertures(bool * continuous) const
void QCameraExposure::setManualAperture(qreal aperture)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant(aperture));
d_func()->setExposureParameter<qreal>(QCameraExposureControl::Aperture, aperture);
}
/*!
@@ -486,8 +529,7 @@ void QCameraExposure::setManualAperture(qreal aperture)
void QCameraExposure::setAutoAperture()
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant());
d_func()->resetExposureParameter(QCameraExposureControl::Aperture);
}
/*!
@@ -496,10 +538,16 @@ void QCameraExposure::setAutoAperture()
qreal QCameraExposure::shutterSpeed() const
{
if (d_func()->exposureControl)
return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ShutterSpeed).toReal();
return d_func()->actualExposureParameter<qreal>(QCameraExposureControl::ShutterSpeed, -1.0);
}
return -1.0;
/*!
Returns the requested manual shutter speed in seconds
or -1.0 if automatic shutter speed is turned on.
*/
qreal QCameraExposure::requestedShutterSpeed() const
{
return d_func()->requestedExposureParameter<qreal>(QCameraExposureControl::ShutterSpeed, -1.0);
}
/*!
@@ -511,13 +559,17 @@ qreal QCameraExposure::shutterSpeed() const
QList<qreal> QCameraExposure::supportedShutterSpeeds(bool *continuous) const
{
QList<qreal> res;
QCameraExposureControl *control = d_func()->exposureControl;
bool tmp = false;
if (!continuous)
continuous = &tmp;
if (!control)
return res;
foreach (const QVariant &value,
control->supportedParameterRange(QCameraExposureControl::ShutterSpeed)) {
control->supportedParameterRange(QCameraExposureControl::ShutterSpeed, continuous)) {
bool ok = false;
qreal realValue = value.toReal(&ok);
if (ok)
@@ -526,10 +578,6 @@ QList<qreal> QCameraExposure::supportedShutterSpeeds(bool *continuous) const
qWarning() << "Incompatible shutter speed value type, qreal is expected";
}
if (continuous)
*continuous = control->exposureParameterFlags(QCameraExposureControl::ShutterSpeed) &
QCameraExposureControl::ContinuousRange;
return res;
}
@@ -539,8 +587,7 @@ QList<qreal> QCameraExposure::supportedShutterSpeeds(bool *continuous) const
void QCameraExposure::setManualShutterSpeed(qreal seconds)
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant(seconds));
d_func()->setExposureParameter<qreal>(QCameraExposureControl::ShutterSpeed, seconds);
}
/*!
@@ -549,8 +596,7 @@ void QCameraExposure::setManualShutterSpeed(qreal seconds)
void QCameraExposure::setAutoShutterSpeed()
{
if (d_func()->exposureControl)
d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant());
d_func()->resetExposureParameter(QCameraExposureControl::ShutterSpeed);
}

View File

@@ -117,29 +117,30 @@ public:
qreal exposureCompensation() const;
MeteringMode meteringMode() const;
bool isMeteringModeSupported(MeteringMode mode) const;
QPointF spotMeteringPoint() const;
void setSpotMeteringPoint(const QPointF &point);
int isoSensitivity() const;
QList<int> supportedIsoSensitivities(bool *continuous = 0) const;
qreal aperture() const;
QList<qreal> supportedApertures(bool *continuous = 0) const;
qreal shutterSpeed() const;
int requestedIsoSensitivity() const;
qreal requestedAperture() const;
qreal requestedShutterSpeed() const;
QList<int> supportedIsoSensitivities(bool *continuous = 0) const;
QList<qreal> supportedApertures(bool * continuous = 0) const;
QList<qreal> supportedShutterSpeeds(bool *continuous = 0) const;
public Q_SLOTS:
void setFlashMode(FlashModes mode);
void setExposureMode(ExposureMode mode);
void setMeteringMode(MeteringMode mode);
void setExposureCompensation(qreal ev);
void setMeteringMode(MeteringMode mode);
void setManualIsoSensitivity(int iso);
void setAutoIsoSensitivity();

View File

@@ -90,53 +90,14 @@ QCameraExposureControl::QCameraExposureControl(QObject *parent):
}
/*!
Destroys the camera control object.
Destroys the camera exposure control object.
*/
QCameraExposureControl::~QCameraExposureControl()
{
}
/*!
\fn QCamera::ExposureMode QCameraExposureControl::exposureMode() const
Returns the exposure mode.
*/
/*!
\fn void QCameraExposureControl::setExposureMode(QCameraExposure::ExposureMode mode)
Set the exposure mode to \a mode.
*/
/*!
\fn bool QCameraExposureControl::isExposureModeSupported(QCameraExposure::ExposureMode mode) const
Returns true if the exposure \a mode is supported.
*/
/*!
\fn QCameraExposure::MeteringMode QCameraExposureControl::meteringMode() const
Returns the current metering mode.
*/
/*!
\fn void QCameraExposureControl::setMeteringMode(QCameraExposure::MeteringMode mode)
Set the metering mode to \a mode.
*/
/*!
\fn bool QCameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
Returns true if the metering \a mode is supported.
*/
/*!
\enum QCameraExposureControl::ExposureParameter
\value InvalidParameter
Parameter is invalid.
\value ISO
Camera ISO sensitivity, specified as integer value.
\value Aperture
@@ -153,84 +114,97 @@ QCameraExposureControl::~QCameraExposureControl()
with 0 value means no flash and 1.0 corresponds to full flash power.
This value is only used in the \l{QCameraExposure::FlashManual}{manual flash mode}.
\value TorchPower
Manual torch power, specified as qreal value.
Accepted power range is [0..1.0],
with 0 value means no light and 1.0 corresponds to full torch power.
This value is only used in the \l{QCameraExposure::FlashTorch}{torch flash mode}.
\value FlashCompensation
Flash compensation, specified as qreal EV value.
\value SpotMeteringPoint
The relative frame coordinate of the point to use for exposure metering
in spot metering mode, specified as a QPointF.
\value ExposureMode
Camera exposure mode.
\value MeteringMode
Camera metering mode.
\value ExtendedExposureParameter
The base value for platform specific extended parameters.
For such parameters the sequential values starting from ExtendedExposureParameter shuld be used.
*/
/*!
\enum QCameraExposureControl::ParameterFlag
\value AutomaticValue
Use the automatic values for parameters.
\value ReadOnly
Parameters are read only.
\value ContinuousRange
Parameters are continuous in their range.
*/
/*!
\fn QCameraExposureControl::isParameterSupported(ExposureParameter parameter) const
Returns true is exposure \a parameter is supported by backend.
\since 5.0
*/
/*!
\fn QCameraExposureControl::exposureParameter(ExposureParameter parameter) const
\fn QCameraExposureControl::requestedValue(ExposureParameter parameter) const
Returns the exposure \a parameter value, or invalid QVariant() if the value is unknown or not supported.
Returns the requested exposure \a parameter value.
\since 5.0
*/
/*!
\fn QCameraExposureControl::exposureParameterFlags(ExposureParameter parameter) const
\fn QCameraExposureControl::actualValue(ExposureParameter parameter) const
Returns the properties of exposure \a parameter.
Returns the actual exposure \a parameter value, or invalid QVariant() if the value is unknown or not supported.
The actual parameter value may differ for the requested one if automatic mode is selected or
camera supports only limited set of values within the supported range.
\since 5.0
*/
/*!
\fn QCameraExposureControl::supportedParameterRange(ExposureParameter parameter) const
\fn QCameraExposureControl::supportedParameterRange(ExposureParameter parameter, bool *continuous = 0) const
Returns the list of supported \a parameter values;
If the camera supports arbitrary exposure parameter value within the supported range,
*\a continuous is set to true, otherwise *\a continuous is set to false.
\since 5.0
*/
/*!
\fn bool QCameraExposureControl::setExposureParameter(ExposureParameter parameter, const QVariant& value)
\fn bool QCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value)
Set the exposure \a parameter to \a value.
If a null or invalid QVariant is passed, backend should choose the value automatically,
and if possible report the actual value to user with QCameraExposureControl::exposureParameter().
and if possible report the actual value to user with QCameraExposureControl::actualValue().
Returns true if parameter is supported and value is correct.
\since 5.0
*/
/*!
\fn QCameraExposureControl::extendedParameterName(ExposureParameter parameter)
\fn void QCameraExposureControl::requestedValueChanged(int parameter)
Returns the extended exposure \a parameter name.
Signal emitted when the requested exposure \a parameter value has changed,
usually in result of setValue() call.
\since 5.0
*/
/*!
\fn void QCameraExposureControl::flashReady(bool ready)
\fn void QCameraExposureControl::actualValueChanged(int parameter)
Signal emitted when flash state changes, flash is charged \a ready.
Signal emitted when the actual exposure \a parameter value has changed,
usually in result of auto exposure algorithms or manual exposure parameter applied.
\since 5.0
*/
/*!
\fn void QCameraExposureControl::exposureParameterChanged(int parameter)
\fn void QCameraExposureControl::parameterRangeChanged(int parameter)
Signal emitted when the exposure \a parameter has changed.
*/
Signal emitted when the supported range of exposure \a parameter values has changed.
/*!
\fn void QCameraExposureControl::exposureParameterRangeChanged(int parameter)
Signal emitted when the exposure \a parameter range has changed.
\since 5.0
*/

View File

@@ -65,45 +65,30 @@ public:
~QCameraExposureControl();
enum ExposureParameter {
InvalidParameter = 0,
ISO = 1,
Aperture = 2,
ShutterSpeed = 3,
ExposureCompensation = 4,
FlashPower = 5,
FlashCompensation = 6,
SpotMeteringPoint = 7,
ISO,
Aperture,
ShutterSpeed,
ExposureCompensation,
FlashPower,
FlashCompensation,
TorchPower,
SpotMeteringPoint,
ExposureMode,
MeteringMode,
ExtendedExposureParameter = 1000
};
enum ParameterFlag {
AutomaticValue = 0x01,
ReadOnly = 0x02,
ContinuousRange = 0x04
};
Q_DECLARE_FLAGS(ParameterFlags, ParameterFlag)
virtual QCameraExposure::ExposureMode exposureMode() const = 0;
virtual void setExposureMode(QCameraExposure::ExposureMode mode) = 0;
virtual bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const = 0;
virtual QCameraExposure::MeteringMode meteringMode() const = 0;
virtual void setMeteringMode(QCameraExposure::MeteringMode mode) = 0;
virtual bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const = 0;
virtual bool isParameterSupported(ExposureParameter parameter) const = 0;
virtual QVariant exposureParameter(ExposureParameter parameter) const = 0;
virtual ParameterFlags exposureParameterFlags(ExposureParameter parameter) const = 0;
virtual QVariantList supportedParameterRange(ExposureParameter parameter) const = 0;
virtual bool setExposureParameter(ExposureParameter parameter, const QVariant& value) = 0;
virtual QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const = 0;
virtual QString extendedParameterName(ExposureParameter parameter) = 0;
virtual QVariant requestedValue(ExposureParameter parameter) const = 0;
virtual QVariant actualValue(ExposureParameter parameter) const = 0;
virtual bool setValue(ExposureParameter parameter, const QVariant& value) = 0;
Q_SIGNALS:
void flashReady(bool);
void exposureParameterChanged(int parameter);
void exposureParameterRangeChanged(int parameter);
void requestedValueChanged(int parameter);
void actualValueChanged(int parameter);
void parameterRangeChanged(int parameter);
protected:
QCameraExposureControl(QObject* parent = 0);
@@ -112,12 +97,12 @@ protected:
#define QCameraExposureControl_iid "com.nokia.Qt.QCameraExposureControl/1.0"
Q_MEDIA_DECLARE_CONTROL(QCameraExposureControl, QCameraExposureControl_iid)
Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposureControl::ParameterFlags)
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QCameraExposureControl::ExposureParameter)
Q_MEDIA_ENUM_DEBUG(QCameraExposureControl, ExposureParameter)
QT_END_NAMESPACE
QT_END_HEADER

View File

@@ -626,11 +626,17 @@ void tst_QCamera::testCameraExposure()
cameraExposure->setFlashMode(QCameraExposure::FlashSlowSyncFrontCurtain);
QCOMPARE(cameraExposure->flashMode(), QCameraExposure::FlashSlowSyncFrontCurtain);
QVERIFY(!cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringAverage));
QVERIFY(cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringSpot));
QVERIFY(cameraExposure->isMeteringModeSupported(QCameraExposure::MeteringMatrix));
cameraExposure->setMeteringMode(QCameraExposure::MeteringMatrix);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
//MeteringAverage is not supported, metering mode should not be changed
cameraExposure->setMeteringMode(QCameraExposure::MeteringAverage);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringAverage);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringMatrix);
cameraExposure->setMeteringMode(QCameraExposure::MeteringSpot);
QCOMPARE(cameraExposure->meteringMode(), QCameraExposure::MeteringSpot);
@@ -650,17 +656,23 @@ void tst_QCamera::testCameraExposure()
int minIso = cameraExposure->supportedIsoSensitivities().first();
int maxIso = cameraExposure->supportedIsoSensitivities().last();
QVERIFY(cameraExposure->isoSensitivity() > 0);
QCOMPARE(cameraExposure->requestedIsoSensitivity(), -1);
QVERIFY(minIso > 0);
QVERIFY(maxIso > 0);
cameraExposure->setManualIsoSensitivity(minIso);
QCOMPARE(cameraExposure->isoSensitivity(), minIso);
cameraExposure->setManualIsoSensitivity(maxIso*10);
QCOMPARE(cameraExposure->isoSensitivity(), maxIso);
QCOMPARE(cameraExposure->requestedIsoSensitivity(), maxIso*10);
cameraExposure->setManualIsoSensitivity(-10);
QCOMPARE(cameraExposure->isoSensitivity(), minIso);
QCOMPARE(cameraExposure->requestedIsoSensitivity(), -10);
cameraExposure->setAutoIsoSensitivity();
QCOMPARE(cameraExposure->isoSensitivity(), 100);
QCOMPARE(cameraExposure->requestedIsoSensitivity(), -1);
QCOMPARE(cameraExposure->requestedAperture(), -1.0);
qreal minAperture = cameraExposure->supportedApertures().first();
qreal maxAperture = cameraExposure->supportedApertures().last();
QVERIFY(minAperture > 0);
@@ -671,14 +683,20 @@ void tst_QCamera::testCameraExposure()
cameraExposure->setAutoAperture();
QVERIFY(cameraExposure->aperture() >= minAperture);
QVERIFY(cameraExposure->aperture() <= maxAperture);
QCOMPARE(cameraExposure->requestedAperture(), -1.0);
cameraExposure->setManualAperture(0);
QCOMPARE(cameraExposure->aperture(), minAperture);
QCOMPARE(cameraExposure->requestedAperture()+1.0, 1.0);
cameraExposure->setManualAperture(10000);
QCOMPARE(cameraExposure->aperture(), maxAperture);
QCOMPARE(cameraExposure->requestedAperture(), 10000.0);
cameraExposure->setAutoAperture();
QCOMPARE(cameraExposure->requestedAperture(), -1.0);
QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
qreal minShutterSpeed = cameraExposure->supportedShutterSpeeds().first();
qreal maxShutterSpeed = cameraExposure->supportedShutterSpeeds().last();
QVERIFY(minShutterSpeed > 0);
@@ -689,12 +707,18 @@ void tst_QCamera::testCameraExposure()
cameraExposure->setAutoShutterSpeed();
QVERIFY(cameraExposure->shutterSpeed() >= minShutterSpeed);
QVERIFY(cameraExposure->shutterSpeed() <= maxShutterSpeed);
QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
cameraExposure->setManualShutterSpeed(0);
QCOMPARE(cameraExposure->shutterSpeed(), minShutterSpeed);
QCOMPARE(cameraExposure->requestedShutterSpeed()+1.0, 1.0);
cameraExposure->setManualShutterSpeed(10000);
QCOMPARE(cameraExposure->shutterSpeed(), maxShutterSpeed);
QCOMPARE(cameraExposure->requestedShutterSpeed(), 10000.0);
cameraExposure->setAutoShutterSpeed();
QCOMPARE(cameraExposure->requestedShutterSpeed(), -1.0);
}
void tst_QCamera::testCameraFocus()

View File

@@ -63,46 +63,27 @@ public:
m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0;
m_shutterRanges << 0.001 << 0.01 << 0.1 << 1.0;
m_exposureRanges << -2.0 << 2.0;
QList<QCameraExposure::ExposureMode> exposureModes;
exposureModes << QCameraExposure::ExposureAuto << QCameraExposure::ExposureManual << QCameraExposure::ExposureBacklight
<< QCameraExposure::ExposureNight << QCameraExposure::ExposureSpotlight << QCameraExposure::ExposureSports
<< QCameraExposure::ExposureSnow << QCameraExposure:: ExposureLargeAperture << QCameraExposure::ExposureSmallAperture
<< QCameraExposure::ExposurePortrait << QCameraExposure::ExposureModeVendor << QCameraExposure::ExposureBeach;
foreach (QCameraExposure::ExposureMode mode, exposureModes)
m_exposureModes << QVariant::fromValue<QCameraExposure::ExposureMode>(mode);
m_meteringModes << QVariant::fromValue<QCameraExposure::MeteringMode>(QCameraExposure::MeteringMatrix)
<< QVariant::fromValue<QCameraExposure::MeteringMode>(QCameraExposure::MeteringSpot);
}
~MockCameraExposureControl() {}
QCameraExposure::FlashModes flashMode() const {return m_flashMode;}
void setFlashMode(QCameraExposure::FlashModes mode)
{
if (isFlashModeSupported(mode)) {
m_flashMode = mode;
}
}
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const
{
return mode & (QCameraExposure::FlashAuto | QCameraExposure::FlashOff | QCameraExposure::FlashOn);
}
bool isFlashReady() const { return true;}
QCameraExposure::ExposureMode exposureMode() const { return m_exposureMode; }
void setExposureMode(QCameraExposure::ExposureMode mode)
{
if (isExposureModeSupported(mode))
m_exposureMode = mode;
}
//Setting the Exposure Mode Supported Enum values
bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const
{
return ( mode == QCameraExposure::ExposureAuto || mode == QCameraExposure::ExposureManual || mode == QCameraExposure::ExposureBacklight ||
mode == QCameraExposure::ExposureNight || mode == QCameraExposure::ExposureSpotlight ||mode == QCameraExposure::ExposureSports ||
mode == QCameraExposure::ExposureSnow || mode == QCameraExposure:: ExposureLargeAperture ||mode == QCameraExposure::ExposureSmallAperture ||
mode == QCameraExposure::ExposurePortrait || mode == QCameraExposure::ExposureModeVendor ||mode == QCameraExposure::ExposureBeach );
}
bool isParameterSupported(ExposureParameter parameter) const
{
switch (parameter) {
case QCameraExposureControl::ExposureMode:
case QCameraExposureControl::MeteringMode:
case QCameraExposureControl::ExposureCompensation:
case QCameraExposureControl::ISO:
case QCameraExposureControl::Aperture:
@@ -114,9 +95,18 @@ public:
}
}
QVariant exposureParameter(ExposureParameter parameter) const
QVariant requestedValue(ExposureParameter param) const
{
switch (parameter) {
return m_requestedParameters.value(param);
}
QVariant actualValue(ExposureParameter param) const
{
switch (param) {
case QCameraExposureControl::ExposureMode:
return QVariant::fromValue<QCameraExposure::ExposureMode>(m_exposureMode);
case QCameraExposureControl::MeteringMode:
return QVariant::fromValue<QCameraExposure::MeteringMode>(m_meteringMode);
case QCameraExposureControl::ExposureCompensation:
return QVariant(m_exposureCompensation);
case QCameraExposureControl::ISO:
@@ -132,18 +122,27 @@ public:
}
}
QVariantList supportedParameterRange(ExposureParameter parameter) const
QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const
{
*continuous = false;
QVariantList res;
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
*continuous = true;
return m_exposureRanges;
case QCameraExposureControl::ISO:
return m_isoRanges;
case QCameraExposureControl::Aperture:
*continuous = true;
return m_apertureRanges;
case QCameraExposureControl::ShutterSpeed:
*continuous = true;
return m_shutterRanges;
case QCameraExposureControl::ExposureMode:
return m_exposureModes;
case QCameraExposureControl::MeteringMode:
return m_meteringModes;
default:
break;
}
@@ -151,39 +150,50 @@ public:
return res;
}
ParameterFlags exposureParameterFlags(ExposureParameter parameter) const
// Added valueChanged and parameterRangeChanged signal
bool setValue(ExposureParameter param, const QVariant& value)
{
ParameterFlags res = 0;
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
case QCameraExposureControl::Aperture:
case QCameraExposureControl::ShutterSpeed:
res |= ContinuousRange;
default:
break;
if (!isParameterSupported(param))
return false;
if (m_requestedParameters.value(param) != value) {
m_requestedParameters.insert(param, value);
emit requestedValueChanged(param);
}
return res;
}
// Added exposureParameterChanged and exposureParameterRangeChanged signal
bool setExposureParameter(ExposureParameter parameter, const QVariant& value)
{
switch (parameter) {
switch (param) {
case QCameraExposureControl::ExposureMode:
{
QCameraExposure::ExposureMode mode = value.value<QCameraExposure::ExposureMode>();
if (mode != m_exposureMode && m_exposureModes.contains(value)) {
m_exposureMode = mode;
emit actualValueChanged(param);
}
}
break;
case QCameraExposureControl::MeteringMode:
{
QCameraExposure::MeteringMode mode = value.value<QCameraExposure::MeteringMode>();
if (mode != m_meteringMode && m_meteringModes.contains(value)) {
m_meteringMode = mode;
emit actualValueChanged(param);
}
}
break;
case QCameraExposureControl::ExposureCompensation:
{
m_res.clear();
m_res << -4.0 << 4.0;
qreal exposureCompensationlocal = qBound<qreal>(-2.0, value.toReal(), 2.0);
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
if (actualValue(param).toReal() != exposureCompensationlocal) {
m_exposureCompensation = exposureCompensationlocal;
emit exposureParameterChanged(parameter);
emit actualValueChanged(param);
}
if (m_exposureRanges.last().toReal() != m_res.last().toReal()) {
m_exposureRanges.clear();
m_exposureRanges = m_res;
emit exposureParameterRangeChanged(parameter);
emit parameterRangeChanged(param);
}
}
break;
@@ -192,15 +202,15 @@ public:
m_res.clear();
m_res << 20 << 50;
qreal exposureCompensationlocal = 100*qRound(qBound(100, value.toInt(), 800)/100.0);
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
if (actualValue(param).toReal() != exposureCompensationlocal) {
m_isoSensitivity = exposureCompensationlocal;
emit exposureParameterChanged(parameter);
emit actualValueChanged(param);
}
if (m_isoRanges.last().toInt() != m_res.last().toInt()) {
m_isoRanges.clear();
m_isoRanges = m_res;
emit exposureParameterRangeChanged(parameter);
emit parameterRangeChanged(param);
}
}
break;
@@ -209,15 +219,15 @@ public:
m_res.clear();
m_res << 12.0 << 18.0 << 20.0;
qreal exposureCompensationlocal = qBound<qreal>(2.8, value.toReal(), 16.0);
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
if (actualValue(param).toReal() != exposureCompensationlocal) {
m_aperture = exposureCompensationlocal;
emit exposureParameterChanged(parameter);
emit actualValueChanged(param);
}
if (m_apertureRanges.last().toReal() != m_res.last().toReal()) {
m_apertureRanges.clear();
m_apertureRanges = m_res;
emit exposureParameterRangeChanged(parameter);
emit parameterRangeChanged(param);
}
}
break;
@@ -226,15 +236,15 @@ public:
m_res.clear();
m_res << 0.12 << 1.0 << 2.0;
qreal exposureCompensationlocal = qBound<qreal>(0.001, value.toReal(), 1.0);
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
if (actualValue(param).toReal() != exposureCompensationlocal) {
m_shutterSpeed = exposureCompensationlocal;
emit exposureParameterChanged(parameter);
emit actualValueChanged(param);
}
if (m_shutterRanges.last().toReal() != m_res.last().toReal()) {
m_shutterRanges.clear();
m_shutterRanges = m_res;
emit exposureParameterRangeChanged(parameter);
emit parameterRangeChanged(param);
}
}
break;
@@ -244,6 +254,7 @@ public:
static QRectF valid(0, 0, 1, 1);
if (valid.contains(value.toPointF())) {
m_spot = value.toPointF();
emit actualValueChanged(param);
return true;
}
return false;
@@ -253,35 +264,9 @@ public:
return false;
}
emit flashReady(true); // depends on Flashcontrol
return true;
}
QString extendedParameterName(ExposureParameter)
{
return QString();
}
QCameraExposure::MeteringMode meteringMode() const
{
return m_meteringMode;
}
void setMeteringMode(QCameraExposure::MeteringMode mode)
{
if (isMeteringModeSupported(mode))
m_meteringMode = mode;
}
//Setting the values for metering mode
bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
{
return mode == QCameraExposure::MeteringAverage
|| mode == QCameraExposure::MeteringMatrix
|| mode == QCameraExposure::MeteringSpot;
}
private:
qreal m_aperture;
qreal m_shutterSpeed;
@@ -290,8 +275,10 @@ private:
qreal m_exposureCompensation;
QCameraExposure::ExposureMode m_exposureMode;
QCameraExposure::FlashModes m_flashMode;
QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res;
QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res, m_exposureModes, m_meteringModes;
QPointF m_spot;
QMap<QCameraExposureControl::ExposureParameter, QVariant> m_requestedParameters;
};
#endif // MOCKCAMERAEXPOSURECONTROL_H