summaryrefslogtreecommitdiff
path: root/src/plugins/android
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2019-03-28 14:52:00 +0100
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-04-03 09:17:16 +0000
commit110dd5b405ce4f8146da4430e3180833610712ad (patch)
tree76eeb8770c86f399c84995e4dcd207572be2882d /src/plugins/android
parent82601d8b43faf560373b73674087955dcf427ead (diff)
downloadqtmultimedia-110dd5b405ce4f8146da4430e3180833610712ad.tar.gz
Android: Fix status of QMediaRecorder after start/stop
If the camera is ready for capture -> QMediaRecorder::LoadedStatus. If CaptureVideo is changed to CaptureStillImage -> StoppedState and UnloadedStatus. If camera's status is StoppingStatus -> StoppedState and UnloadedStatus. If camera's status is LoadingStatus -> LoadingStatus. If recording is requested -> RecordingState and RecordingStatus. If recording is audio-only -> immediately LoadedStatus, before start and after stop. Fixes tst_QCameraBackend::testVideoRecording Task-number: QTBUG-73582 Change-Id: I976c4e3afab529e0949571c4002e9ceba74cac97 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/android')
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcapturesession.cpp79
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcapturesession.h1
2 files changed, 35 insertions, 45 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
index bdc7ed403..bc9bc983e 100644
--- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
@@ -73,16 +73,41 @@ QAndroidCaptureSession::QAndroidCaptureSession(QAndroidCameraSession *cameraSess
QMediaStorageLocation::Sounds,
AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::Sounds));
- connect(this, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(updateStatus()));
-
if (cameraSession) {
connect(cameraSession, SIGNAL(opened()), this, SLOT(onCameraOpened()));
- connect(cameraSession, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(updateStatus()));
- connect(cameraSession, SIGNAL(captureModeChanged(QCamera::CaptureModes)),
- this, SLOT(updateStatus()));
- connect(cameraSession, SIGNAL(readyForCaptureChanged(bool)), this, SLOT(updateStatus()));
+ connect(cameraSession, &QAndroidCameraSession::statusChanged, this,
+ [this](QCamera::Status status) {
+ if (status == QCamera::UnavailableStatus) {
+ setState(QMediaRecorder::StoppedState);
+ setStatus(QMediaRecorder::UnavailableStatus);
+ return;
+ }
+
+ // Stop recording when stopping the camera.
+ if (status == QCamera::StoppingStatus) {
+ setState(QMediaRecorder::StoppedState);
+ setStatus(QMediaRecorder::UnloadedStatus);
+ return;
+ }
+
+ if (status == QCamera::LoadingStatus)
+ setStatus(QMediaRecorder::LoadingStatus);
+ });
+ connect(cameraSession, &QAndroidCameraSession::captureModeChanged, this,
+ [this](QCamera::CaptureModes mode) {
+ if (!mode.testFlag(QCamera::CaptureVideo)) {
+ setState(QMediaRecorder::StoppedState);
+ setStatus(QMediaRecorder::UnloadedStatus);
+ }
+ });
+ connect(cameraSession, &QAndroidCameraSession::readyForCaptureChanged, this,
+ [this](bool ready) {
+ if (ready)
+ setStatus(QMediaRecorder::LoadedStatus);
+ });
} else {
- updateStatus();
+ // Audio-only recording.
+ setStatus(QMediaRecorder::LoadedStatus);
}
m_notifyTimer.setInterval(1000);
@@ -277,6 +302,7 @@ void QAndroidCaptureSession::start()
m_state = QMediaRecorder::RecordingState;
emit stateChanged(m_state);
+ setStatus(QMediaRecorder::RecordingStatus);
}
void QAndroidCaptureSession::stop(bool error)
@@ -315,6 +341,8 @@ void QAndroidCaptureSession::stop(bool error)
m_state = QMediaRecorder::StoppedState;
emit stateChanged(m_state);
+ if (!m_cameraSession)
+ setStatus(QMediaRecorder::LoadedStatus);
}
void QAndroidCaptureSession::setStatus(QMediaRecorder::Status status)
@@ -539,43 +567,6 @@ QAndroidCaptureSession::CaptureProfile QAndroidCaptureSession::getProfile(int id
return profile;
}
-void QAndroidCaptureSession::updateStatus()
-{
- if (m_cameraSession) {
- // Video recording
-
- // stop recording when stopping the camera
- if (m_cameraSession->status() == QCamera::StoppingStatus
- || !m_cameraSession->captureMode().testFlag(QCamera::CaptureVideo)) {
- setState(QMediaRecorder::StoppedState);
- return;
- }
-
- if (m_state == QMediaRecorder::RecordingState) {
- setStatus(QMediaRecorder::RecordingStatus);
- } else if (m_cameraSession->status() == QCamera::UnavailableStatus) {
- setStatus(QMediaRecorder::UnavailableStatus);
- } else if (m_cameraSession->captureMode().testFlag(QCamera::CaptureVideo)
- && m_cameraSession->isReadyForCapture()) {
- if (m_cameraSession->status() == QCamera::StartingStatus)
- setStatus(QMediaRecorder::LoadingStatus);
- else if (m_cameraSession->status() == QCamera::ActiveStatus)
- setStatus(QMediaRecorder::LoadedStatus);
- else
- setStatus(QMediaRecorder::UnloadedStatus);
- } else {
- setStatus(QMediaRecorder::UnloadedStatus);
- }
-
- } else {
- // Audio-only recording
- if (m_state == QMediaRecorder::RecordingState)
- setStatus(QMediaRecorder::RecordingStatus);
- else
- setStatus(QMediaRecorder::LoadedStatus);
- }
-}
-
void QAndroidCaptureSession::onError(int what, int extra)
{
Q_UNUSED(what)
diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.h b/src/plugins/android/src/mediacapture/qandroidcapturesession.h
index 286fd1aa2..8cfb9ad2a 100644
--- a/src/plugins/android/src/mediacapture/qandroidcapturesession.h
+++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.h
@@ -97,7 +97,6 @@ Q_SIGNALS:
private Q_SLOTS:
void updateDuration();
void onCameraOpened();
- void updateStatus();
void onError(int what, int extra);
void onInfo(int what, int extra);