DirectShow: Refactor camera backend.

Almost entire rewrite of the camera backend. It doesn't provide new
features but is more stable and behave as it should.

- Correctly report camera state and status
- Correctly report if the camera is ready to capture
- Emit imageExposed() signal
- Save captured images in an appropriate directory
- Images can be captured even without a viewport
- Better error handling

Removed the custom QVideoWidgetControl as it doesn't provide anything more
than the QVideoWidget's renderer control fallback.

Task-number: QTBUG-33782
Change-Id: I9baf6f83e7c69619f20a101921f7865a1c90d5e4
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2014-04-07 14:24:51 +02:00
parent f352e44df9
commit 389d66b3ed
15 changed files with 707 additions and 1509 deletions

View File

@@ -46,15 +46,19 @@
QT_BEGIN_NAMESPACE
DSImageCaptureControl::DSImageCaptureControl(DSCameraSession *session)
:QCameraImageCaptureControl(session), m_session(session), m_ready(false)
: QCameraImageCaptureControl(session)
, m_session(session)
{
connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState()));
connect(m_session, SIGNAL(imageExposed(int)),
this, SIGNAL(imageExposed(int)));
connect(m_session, SIGNAL(imageCaptured(int,QImage)),
this, SIGNAL(imageCaptured(int,QImage)));
connect(m_session, SIGNAL(imageSaved(int,QString)),
this, SIGNAL(imageSaved(int,QString)));
connect(m_session, SIGNAL(readyForCaptureChanged(bool)),
this, SIGNAL(readyForCaptureChanged(bool)));
connect(m_session, SIGNAL(captureError(int,int,QString)),
this, SIGNAL(error(int,int,QString)));
}
DSImageCaptureControl::~DSImageCaptureControl()
@@ -63,7 +67,7 @@ DSImageCaptureControl::~DSImageCaptureControl()
bool DSImageCaptureControl::isReadyForCapture() const
{
return m_ready;
return m_session->isReadyForCapture();
}
int DSImageCaptureControl::capture(const QString &fileName)
@@ -71,12 +75,15 @@ int DSImageCaptureControl::capture(const QString &fileName)
return m_session->captureImage(fileName);
}
void DSImageCaptureControl::updateState()
QCameraImageCapture::DriveMode DSImageCaptureControl::driveMode() const
{
bool ready = (m_session->state() == QCamera::ActiveState) &&
!m_session->pictureInProgress();
if(m_ready != ready)
emit readyForCaptureChanged(m_ready = ready);
return QCameraImageCapture::SingleImageCapture;
}
void DSImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode)
{
if (mode != QCameraImageCapture::SingleImageCapture)
qWarning("Drive mode not supported.");
}
QT_END_NAMESPACE