Blackberry: Improve camera focus handling
Use different state variables for focus/exposure/whitebalance locks and update the exposure and whitebalance variables explicitly, since BB10 doesn't provide a status callback method as for focus. Change-Id: Ie6ba8f6a2a27f317c39994d21be8549c99daef6d Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
committed by
The Qt Project
parent
1235fb9910
commit
43bc5f65d2
@@ -47,29 +47,212 @@ QT_BEGIN_NAMESPACE
|
|||||||
BbCameraLocksControl::BbCameraLocksControl(BbCameraSession *session, QObject *parent)
|
BbCameraLocksControl::BbCameraLocksControl(BbCameraSession *session, QObject *parent)
|
||||||
: QCameraLocksControl(parent)
|
: QCameraLocksControl(parent)
|
||||||
, m_session(session)
|
, m_session(session)
|
||||||
|
, m_locksApplyMode(IndependentMode)
|
||||||
|
, m_focusLockStatus(QCamera::Unlocked)
|
||||||
|
, m_exposureLockStatus(QCamera::Unlocked)
|
||||||
|
, m_whiteBalanceLockStatus(QCamera::Unlocked)
|
||||||
|
, m_currentLockTypes(QCamera::NoLock)
|
||||||
|
, m_supportedLockTypes(QCamera::NoLock)
|
||||||
{
|
{
|
||||||
connect(m_session, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)),
|
connect(m_session, SIGNAL(cameraOpened()), SLOT(cameraOpened()));
|
||||||
this, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
|
connect(m_session, SIGNAL(focusStatusChanged(int)), SLOT(focusStatusChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QCamera::LockTypes BbCameraLocksControl::supportedLocks() const
|
QCamera::LockTypes BbCameraLocksControl::supportedLocks() const
|
||||||
{
|
{
|
||||||
return m_session->supportedLocks();
|
return (QCamera::LockFocus | QCamera::LockExposure | QCamera::LockWhiteBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
QCamera::LockStatus BbCameraLocksControl::lockStatus(QCamera::LockType lock) const
|
QCamera::LockStatus BbCameraLocksControl::lockStatus(QCamera::LockType lock) const
|
||||||
{
|
{
|
||||||
return m_session->lockStatus(lock);
|
if (!m_supportedLockTypes.testFlag(lock) || (m_session->handle() == CAMERA_HANDLE_INVALID))
|
||||||
|
return QCamera::Locked;
|
||||||
|
|
||||||
|
switch (lock) {
|
||||||
|
case QCamera::LockExposure:
|
||||||
|
return m_exposureLockStatus;
|
||||||
|
case QCamera::LockWhiteBalance:
|
||||||
|
return m_whiteBalanceLockStatus;
|
||||||
|
case QCamera::LockFocus:
|
||||||
|
return m_focusLockStatus;
|
||||||
|
default:
|
||||||
|
return QCamera::Locked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BbCameraLocksControl::searchAndLock(QCamera::LockTypes locks)
|
void BbCameraLocksControl::searchAndLock(QCamera::LockTypes locks)
|
||||||
{
|
{
|
||||||
m_session->searchAndLock(locks);
|
if (m_session->handle() == CAMERA_HANDLE_INVALID)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// filter out unsupported locks
|
||||||
|
locks &= m_supportedLockTypes;
|
||||||
|
|
||||||
|
m_currentLockTypes |= locks;
|
||||||
|
|
||||||
|
uint32_t lockModes = CAMERA_3A_NONE;
|
||||||
|
|
||||||
|
switch (m_locksApplyMode) {
|
||||||
|
case IndependentMode:
|
||||||
|
if (m_currentLockTypes & QCamera::LockExposure)
|
||||||
|
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||||
|
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||||
|
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||||
|
if (m_currentLockTypes & QCamera::LockFocus)
|
||||||
|
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||||
|
break;
|
||||||
|
case FocusExposureBoundMode:
|
||||||
|
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||||
|
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||||
|
break;
|
||||||
|
case AllBoundMode:
|
||||||
|
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||||
|
break;
|
||||||
|
case FocusOnlyMode:
|
||||||
|
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes);
|
||||||
|
|
||||||
|
if (result != CAMERA_EOK) {
|
||||||
|
qWarning() << "Unable to set lock modes:" << result;
|
||||||
|
} else {
|
||||||
|
if (lockModes & CAMERA_3A_AUTOFOCUS) {
|
||||||
|
// handled by focusStatusChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lockModes & CAMERA_3A_AUTOEXPOSURE) {
|
||||||
|
m_exposureLockStatus = QCamera::Locked;
|
||||||
|
emit lockStatusChanged(QCamera::LockExposure, QCamera::Locked, QCamera::LockAcquired);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lockModes & CAMERA_3A_AUTOWHITEBALANCE) {
|
||||||
|
m_whiteBalanceLockStatus = QCamera::Locked;
|
||||||
|
emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Locked, QCamera::LockAcquired);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BbCameraLocksControl::unlock(QCamera::LockTypes locks)
|
void BbCameraLocksControl::unlock(QCamera::LockTypes locks)
|
||||||
{
|
{
|
||||||
m_session->unlock(locks);
|
// filter out unsupported locks
|
||||||
|
locks &= m_supportedLockTypes;
|
||||||
|
|
||||||
|
m_currentLockTypes &= ~locks;
|
||||||
|
|
||||||
|
uint32_t lockModes = CAMERA_3A_NONE;
|
||||||
|
|
||||||
|
switch (m_locksApplyMode) {
|
||||||
|
case IndependentMode:
|
||||||
|
if (m_currentLockTypes & QCamera::LockExposure)
|
||||||
|
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
||||||
|
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
||||||
|
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
||||||
|
if (m_currentLockTypes & QCamera::LockFocus)
|
||||||
|
lockModes |= CAMERA_3A_AUTOFOCUS;
|
||||||
|
break;
|
||||||
|
case FocusExposureBoundMode:
|
||||||
|
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
||||||
|
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
||||||
|
break;
|
||||||
|
case AllBoundMode:
|
||||||
|
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
||||||
|
break;
|
||||||
|
case FocusOnlyMode:
|
||||||
|
lockModes = CAMERA_3A_AUTOFOCUS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes);
|
||||||
|
|
||||||
|
if (result != CAMERA_EOK) {
|
||||||
|
qWarning() << "Unable to set lock modes:" << result;
|
||||||
|
} else {
|
||||||
|
if (locks.testFlag(QCamera::LockFocus)) {
|
||||||
|
// handled by focusStatusChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locks.testFlag(QCamera::LockExposure)) {
|
||||||
|
m_exposureLockStatus = QCamera::Unlocked;
|
||||||
|
emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::UserRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locks.testFlag(QCamera::LockWhiteBalance)) {
|
||||||
|
m_whiteBalanceLockStatus = QCamera::Unlocked;
|
||||||
|
emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Unlocked, QCamera::UserRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BbCameraLocksControl::cameraOpened()
|
||||||
|
{
|
||||||
|
// retrieve information about lock apply modes
|
||||||
|
int supported = 0;
|
||||||
|
uint32_t modes[20];
|
||||||
|
|
||||||
|
const camera_error_t result = camera_get_3a_lock_modes(m_session->handle(), 20, &supported, modes);
|
||||||
|
|
||||||
|
if (result == CAMERA_EOK) {
|
||||||
|
// see API documentation of camera_get_3a_lock_modes for explanation of case discrimination below
|
||||||
|
if (supported == 4) {
|
||||||
|
m_locksApplyMode = IndependentMode;
|
||||||
|
} else if (supported == 3) {
|
||||||
|
m_locksApplyMode = FocusExposureBoundMode;
|
||||||
|
} else if (supported == 2) {
|
||||||
|
if (modes[0] == (CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOWHITEBALANCE))
|
||||||
|
m_locksApplyMode = AllBoundMode;
|
||||||
|
else
|
||||||
|
m_locksApplyMode = FocusOnlyMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve information about supported lock types
|
||||||
|
m_supportedLockTypes = QCamera::NoLock;
|
||||||
|
|
||||||
|
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS))
|
||||||
|
m_supportedLockTypes |= QCamera::LockFocus;
|
||||||
|
|
||||||
|
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOEXPOSURE))
|
||||||
|
m_supportedLockTypes |= QCamera::LockExposure;
|
||||||
|
|
||||||
|
if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOWHITEBALANCE))
|
||||||
|
m_supportedLockTypes |= QCamera::LockWhiteBalance;
|
||||||
|
|
||||||
|
m_focusLockStatus = QCamera::Unlocked;
|
||||||
|
m_exposureLockStatus = QCamera::Unlocked;
|
||||||
|
m_whiteBalanceLockStatus = QCamera::Unlocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BbCameraLocksControl::focusStatusChanged(int value)
|
||||||
|
{
|
||||||
|
const camera_focusstate_t focusState = static_cast<camera_focusstate_t>(value);
|
||||||
|
|
||||||
|
switch (focusState) {
|
||||||
|
case CAMERA_FOCUSSTATE_NONE:
|
||||||
|
m_focusLockStatus = QCamera::Unlocked;
|
||||||
|
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
||||||
|
break;
|
||||||
|
case CAMERA_FOCUSSTATE_WAITING:
|
||||||
|
case CAMERA_FOCUSSTATE_SEARCHING:
|
||||||
|
m_focusLockStatus = QCamera::Searching;
|
||||||
|
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
||||||
|
break;
|
||||||
|
case CAMERA_FOCUSSTATE_FAILED:
|
||||||
|
m_focusLockStatus = QCamera::Unlocked;
|
||||||
|
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||||
|
break;
|
||||||
|
case CAMERA_FOCUSSTATE_LOCKED:
|
||||||
|
m_focusLockStatus = QCamera::Locked;
|
||||||
|
emit lockStatusChanged(QCamera::LockFocus, QCamera::Locked, QCamera::LockAcquired);
|
||||||
|
break;
|
||||||
|
case CAMERA_FOCUSSTATE_SCENECHANGE:
|
||||||
|
m_focusLockStatus = QCamera::Unlocked;
|
||||||
|
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockTemporaryLost);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ class BbCameraLocksControl : public QCameraLocksControl
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum LocksApplyMode
|
||||||
|
{
|
||||||
|
IndependentMode,
|
||||||
|
FocusExposureBoundMode,
|
||||||
|
AllBoundMode,
|
||||||
|
FocusOnlyMode
|
||||||
|
};
|
||||||
|
|
||||||
explicit BbCameraLocksControl(BbCameraSession *session, QObject *parent = 0);
|
explicit BbCameraLocksControl(BbCameraSession *session, QObject *parent = 0);
|
||||||
|
|
||||||
QCamera::LockTypes supportedLocks() const Q_DECL_OVERRIDE;
|
QCamera::LockTypes supportedLocks() const Q_DECL_OVERRIDE;
|
||||||
@@ -58,8 +66,19 @@ public:
|
|||||||
void searchAndLock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
void searchAndLock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
||||||
void unlock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
void unlock(QCamera::LockTypes locks) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void cameraOpened();
|
||||||
|
void focusStatusChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BbCameraSession *m_session;
|
BbCameraSession *m_session;
|
||||||
|
|
||||||
|
LocksApplyMode m_locksApplyMode;
|
||||||
|
QCamera::LockStatus m_focusLockStatus;
|
||||||
|
QCamera::LockStatus m_exposureLockStatus;
|
||||||
|
QCamera::LockStatus m_whiteBalanceLockStatus;
|
||||||
|
QCamera::LockTypes m_currentLockTypes;
|
||||||
|
QCamera::LockTypes m_supportedLockTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -121,8 +121,6 @@ BbCameraSession::BbCameraSession(QObject *parent)
|
|||||||
, m_captureImageDriveMode(QCameraImageCapture::SingleImageCapture)
|
, m_captureImageDriveMode(QCameraImageCapture::SingleImageCapture)
|
||||||
, m_lastImageCaptureId(0)
|
, m_lastImageCaptureId(0)
|
||||||
, m_captureDestination(QCameraImageCapture::CaptureToFile)
|
, m_captureDestination(QCameraImageCapture::CaptureToFile)
|
||||||
, m_locksApplyMode(IndependentMode)
|
|
||||||
, m_focusLockStatus(QCamera::Unlocked)
|
|
||||||
, m_videoState(QMediaRecorder::StoppedState)
|
, m_videoState(QMediaRecorder::StoppedState)
|
||||||
, m_videoStatus(QMediaRecorder::LoadedStatus)
|
, m_videoStatus(QMediaRecorder::LoadedStatus)
|
||||||
, m_handle(CAMERA_HANDLE_INVALID)
|
, m_handle(CAMERA_HANDLE_INVALID)
|
||||||
@@ -444,95 +442,6 @@ void BbCameraSession::setImageSettings(const QImageEncoderSettings &settings)
|
|||||||
m_imageEncoderSettings.setCodec(QLatin1String("jpeg"));
|
m_imageEncoderSettings.setCodec(QLatin1String("jpeg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QCamera::LockTypes BbCameraSession::supportedLocks() const
|
|
||||||
{
|
|
||||||
if (m_locksApplyMode == FocusOnlyMode)
|
|
||||||
return QCamera::LockFocus;
|
|
||||||
else
|
|
||||||
return (QCamera::LockExposure | QCamera::LockWhiteBalance | QCamera::LockFocus);
|
|
||||||
}
|
|
||||||
|
|
||||||
QCamera::LockStatus BbCameraSession::lockStatus(QCamera::LockType lock) const
|
|
||||||
{
|
|
||||||
switch (lock) {
|
|
||||||
case QCamera::LockExposure:
|
|
||||||
return QCamera::Unlocked;
|
|
||||||
case QCamera::LockWhiteBalance:
|
|
||||||
return QCamera::Unlocked;
|
|
||||||
case QCamera::LockFocus:
|
|
||||||
return m_focusLockStatus;
|
|
||||||
default:
|
|
||||||
return QCamera::Unlocked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BbCameraSession::searchAndLock(QCamera::LockTypes locks)
|
|
||||||
{
|
|
||||||
m_currentLockTypes |= locks;
|
|
||||||
|
|
||||||
uint32_t lockModes = CAMERA_3A_NONE;
|
|
||||||
|
|
||||||
switch (m_locksApplyMode) {
|
|
||||||
case IndependentMode:
|
|
||||||
if (m_currentLockTypes & QCamera::LockExposure)
|
|
||||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
|
||||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
|
||||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
|
||||||
if (m_currentLockTypes & QCamera::LockFocus)
|
|
||||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
|
||||||
break;
|
|
||||||
case FocusExposureBoundMode:
|
|
||||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
|
||||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
|
||||||
break;
|
|
||||||
case AllBoundMode:
|
|
||||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
|
||||||
break;
|
|
||||||
case FocusOnlyMode:
|
|
||||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const camera_error_t result = camera_set_3a_lock(m_handle, lockModes);
|
|
||||||
|
|
||||||
if (result != CAMERA_EOK) {
|
|
||||||
qWarning() << "Unable to set lock modes:" << result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BbCameraSession::unlock(QCamera::LockTypes locks)
|
|
||||||
{
|
|
||||||
m_currentLockTypes &= ~locks;
|
|
||||||
|
|
||||||
uint32_t lockModes = CAMERA_3A_NONE;
|
|
||||||
|
|
||||||
switch (m_locksApplyMode) {
|
|
||||||
case IndependentMode:
|
|
||||||
if (m_currentLockTypes & QCamera::LockExposure)
|
|
||||||
lockModes |= CAMERA_3A_AUTOEXPOSURE;
|
|
||||||
if (m_currentLockTypes & QCamera::LockWhiteBalance)
|
|
||||||
lockModes |= CAMERA_3A_AUTOWHITEBALANCE;
|
|
||||||
if (m_currentLockTypes & QCamera::LockFocus)
|
|
||||||
lockModes |= CAMERA_3A_AUTOFOCUS;
|
|
||||||
break;
|
|
||||||
case FocusExposureBoundMode:
|
|
||||||
if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus))
|
|
||||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS);
|
|
||||||
break;
|
|
||||||
case AllBoundMode:
|
|
||||||
lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE);
|
|
||||||
break;
|
|
||||||
case FocusOnlyMode:
|
|
||||||
lockModes = CAMERA_3A_AUTOFOCUS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const camera_error_t result = camera_set_3a_lock(m_handle, lockModes);
|
|
||||||
|
|
||||||
if (result != CAMERA_EOK)
|
|
||||||
qWarning() << "Unable to set lock modes:" << result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl BbCameraSession::outputLocation() const
|
QUrl BbCameraSession::outputLocation() const
|
||||||
{
|
{
|
||||||
return QUrl::fromLocalFile(m_videoOutputLocation);
|
return QUrl::fromLocalFile(m_videoOutputLocation);
|
||||||
@@ -822,37 +731,6 @@ void BbCameraSession::imageCaptured(int requestId, const QImage &rawImage, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BbCameraSession::handleFocusStatusChanged(int value)
|
|
||||||
{
|
|
||||||
const camera_focusstate_t focusState = static_cast<camera_focusstate_t>(value);
|
|
||||||
|
|
||||||
switch (focusState) {
|
|
||||||
case CAMERA_FOCUSSTATE_NONE:
|
|
||||||
case CAMERA_FOCUSSTATE_WAITING:
|
|
||||||
m_focusLockStatus = QCamera::Unlocked;
|
|
||||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
|
||||||
break;
|
|
||||||
case CAMERA_FOCUSSTATE_SEARCHING:
|
|
||||||
m_focusLockStatus = QCamera::Searching;
|
|
||||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
|
||||||
break;
|
|
||||||
case CAMERA_FOCUSSTATE_FAILED:
|
|
||||||
m_focusLockStatus = QCamera::Unlocked;
|
|
||||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
|
||||||
break;
|
|
||||||
case CAMERA_FOCUSSTATE_LOCKED:
|
|
||||||
m_focusLockStatus = QCamera::Locked;
|
|
||||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Locked, QCamera::LockAcquired);
|
|
||||||
break;
|
|
||||||
case CAMERA_FOCUSSTATE_SCENECHANGE:
|
|
||||||
m_focusLockStatus = QCamera::Unlocked;
|
|
||||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockTemporaryLost);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BbCameraSession::handleVideoRecordingPaused()
|
void BbCameraSession::handleVideoRecordingPaused()
|
||||||
{
|
{
|
||||||
//TODO: implement once BB10 API supports pausing a video
|
//TODO: implement once BB10 API supports pausing a video
|
||||||
@@ -942,6 +820,8 @@ bool BbCameraSession::openCamera()
|
|||||||
m_status = QCamera::LoadedStatus;
|
m_status = QCamera::LoadedStatus;
|
||||||
emit statusChanged(m_status);
|
emit statusChanged(m_status);
|
||||||
|
|
||||||
|
emit cameraOpened();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -975,7 +855,7 @@ static void viewFinderStatusCallback(camera_handle_t handle, camera_devstatus_t
|
|||||||
|
|
||||||
if (status == CAMERA_STATUS_FOCUS_CHANGE) {
|
if (status == CAMERA_STATUS_FOCUS_CHANGE) {
|
||||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||||
QMetaObject::invokeMethod(session, "handleFocusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
QMetaObject::invokeMethod(session, "focusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifndef Q_OS_BLACKBERRY_TABLET
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
@@ -1006,28 +886,6 @@ bool BbCameraSession::startViewFinder()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve information about lock apply modes
|
|
||||||
{
|
|
||||||
int supported = 0;
|
|
||||||
uint32_t modes[20];
|
|
||||||
|
|
||||||
const camera_error_t result = camera_get_3a_lock_modes(m_handle, 20, &supported, modes);
|
|
||||||
|
|
||||||
if (result == CAMERA_EOK) {
|
|
||||||
// see API documentation of camera_get_3a_lock_modes for explanation of case discrimination below
|
|
||||||
if (supported == 4) {
|
|
||||||
m_locksApplyMode = IndependentMode;
|
|
||||||
} else if (supported == 3) {
|
|
||||||
m_locksApplyMode = FocusExposureBoundMode;
|
|
||||||
} else if (supported == 2) {
|
|
||||||
if (modes[0] == (CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOWHITEBALANCE))
|
|
||||||
m_locksApplyMode = AllBoundMode;
|
|
||||||
else
|
|
||||||
m_locksApplyMode = FocusOnlyMode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int angle = m_orientationHandler->orientation();
|
const int angle = m_orientationHandler->orientation();
|
||||||
|
|
||||||
const QSize rotatedSize = ((angle == 0 || angle == 180) ? viewfinderResolution
|
const QSize rotatedSize = ((angle == 0 || angle == 180) ? viewfinderResolution
|
||||||
|
|||||||
@@ -105,20 +105,6 @@ public:
|
|||||||
QImageEncoderSettings imageSettings() const;
|
QImageEncoderSettings imageSettings() const;
|
||||||
void setImageSettings(const QImageEncoderSettings &settings);
|
void setImageSettings(const QImageEncoderSettings &settings);
|
||||||
|
|
||||||
// locks control
|
|
||||||
enum LocksApplyMode
|
|
||||||
{
|
|
||||||
IndependentMode,
|
|
||||||
FocusExposureBoundMode,
|
|
||||||
AllBoundMode,
|
|
||||||
FocusOnlyMode
|
|
||||||
};
|
|
||||||
|
|
||||||
QCamera::LockTypes supportedLocks() const;
|
|
||||||
QCamera::LockStatus lockStatus(QCamera::LockType lock) const;
|
|
||||||
void searchAndLock(QCamera::LockTypes locks);
|
|
||||||
void unlock(QCamera::LockTypes locks);
|
|
||||||
|
|
||||||
// media recorder control
|
// media recorder control
|
||||||
QUrl outputLocation() const;
|
QUrl outputLocation() const;
|
||||||
bool setOutputLocation(const QUrl &location);
|
bool setOutputLocation(const QUrl &location);
|
||||||
@@ -157,9 +143,6 @@ Q_SIGNALS:
|
|||||||
// capture destination control
|
// capture destination control
|
||||||
void captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination);
|
void captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination);
|
||||||
|
|
||||||
// locks control
|
|
||||||
void lockStatusChanged(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason);
|
|
||||||
|
|
||||||
// media recorder control
|
// media recorder control
|
||||||
void videoStateChanged(QMediaRecorder::State state);
|
void videoStateChanged(QMediaRecorder::State state);
|
||||||
void videoStatusChanged(QMediaRecorder::Status status);
|
void videoStatusChanged(QMediaRecorder::Status status);
|
||||||
@@ -167,10 +150,12 @@ Q_SIGNALS:
|
|||||||
void actualLocationChanged(const QUrl &location);
|
void actualLocationChanged(const QUrl &location);
|
||||||
void videoError(int error, const QString &errorString);
|
void videoError(int error, const QString &errorString);
|
||||||
|
|
||||||
|
void cameraOpened();
|
||||||
|
void focusStatusChanged(int status);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateReadyForCapture();
|
void updateReadyForCapture();
|
||||||
void imageCaptured(int, const QImage&, const QString&);
|
void imageCaptured(int, const QImage&, const QString&);
|
||||||
void handleFocusStatusChanged(int);
|
|
||||||
void handleVideoRecordingPaused();
|
void handleVideoRecordingPaused();
|
||||||
void handleVideoRecordingResumed();
|
void handleVideoRecordingResumed();
|
||||||
void deviceOrientationChanged(int);
|
void deviceOrientationChanged(int);
|
||||||
@@ -210,10 +195,6 @@ private:
|
|||||||
|
|
||||||
QImageEncoderSettings m_imageEncoderSettings;
|
QImageEncoderSettings m_imageEncoderSettings;
|
||||||
|
|
||||||
LocksApplyMode m_locksApplyMode;
|
|
||||||
QCamera::LockStatus m_focusLockStatus;
|
|
||||||
QCamera::LockTypes m_currentLockTypes;
|
|
||||||
|
|
||||||
QString m_videoOutputLocation;
|
QString m_videoOutputLocation;
|
||||||
QMediaRecorder::State m_videoState;
|
QMediaRecorder::State m_videoState;
|
||||||
QMediaRecorder::Status m_videoStatus;
|
QMediaRecorder::Status m_videoStatus;
|
||||||
|
|||||||
Reference in New Issue
Block a user