Updated the camerabin2 based camera with QtMultimedia changes
Moved it to the separate plugin as the rest of gstreamer based services; Updated with libqgsttools_p changes; Implemented QMediaRecorder::status property; Made gst_photography dependency optional, it's not always available on desktop; Added video recording case to auto integration test; Moved backend implementation into qt namespace Task-number: QTBUG-26046 Change-Id: Iacfc1a6e263a4c0201d5eb28d04c960b87a230c0 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
fdc197d614
commit
b6a8c713bc
@@ -91,6 +91,9 @@ private slots:
|
||||
void testCameraCaptureMetadata();
|
||||
void testExposureCompensation();
|
||||
void testExposureMode();
|
||||
|
||||
void testVideoRecording_data();
|
||||
void testVideoRecording();
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -565,6 +568,81 @@ void tst_QCameraBackend::testExposureMode()
|
||||
QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto);
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testVideoRecording_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("device");
|
||||
|
||||
QList<QByteArray> devices = QCamera::availableDevices();
|
||||
|
||||
foreach (const QByteArray &device, devices) {
|
||||
QTest::newRow(QCamera::deviceDescription(device).toUtf8())
|
||||
<< device;
|
||||
}
|
||||
|
||||
if (devices.isEmpty())
|
||||
QTest::newRow("Default device") << QByteArray();
|
||||
}
|
||||
|
||||
void tst_QCameraBackend::testVideoRecording()
|
||||
{
|
||||
QFETCH(QByteArray, device);
|
||||
|
||||
QCamera *camera = device.isEmpty() ? new QCamera : new QCamera(device);
|
||||
|
||||
QMediaRecorder recorder(camera);
|
||||
|
||||
QSignalSpy errorSignal(camera, SIGNAL(error(QCamera::Error)));
|
||||
QSignalSpy recorderErrorSignal(&recorder, SIGNAL(error(QMediaRecorder::Error)));
|
||||
QSignalSpy recorderStatusSignal(&recorder, SIGNAL(statusChanged(QMediaRecorder::Status)));
|
||||
|
||||
if (!camera->isCaptureModeSupported(QCamera::CaptureVideo)) {
|
||||
QSKIP("Video capture not supported");
|
||||
}
|
||||
|
||||
camera->setCaptureMode(QCamera::CaptureVideo);
|
||||
|
||||
QVideoEncoderSettings videoSettings;
|
||||
videoSettings.setResolution(640, 480);
|
||||
recorder.setVideoSettings(videoSettings);
|
||||
|
||||
recorder.setContainerFormat("ogg");
|
||||
|
||||
QCOMPARE(recorder.status(), QMediaRecorder::UnloadedStatus);
|
||||
|
||||
camera->start();
|
||||
QCOMPARE(recorder.status(), QMediaRecorder::LoadingStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
QTRY_COMPARE(camera->status(), QCamera::ActiveStatus);
|
||||
QTRY_COMPARE(recorder.status(), QMediaRecorder::LoadedStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
|
||||
//record 5 seconds clip
|
||||
recorder.record();
|
||||
QTRY_COMPARE(recorder.status(), QMediaRecorder::RecordingStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
QTest::qWait(5000);
|
||||
recorder.stop();
|
||||
QCOMPARE(recorder.status(), QMediaRecorder::FinalizingStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
QTRY_COMPARE(recorder.status(), QMediaRecorder::LoadedStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
|
||||
QVERIFY(errorSignal.isEmpty());
|
||||
QVERIFY(recorderErrorSignal.isEmpty());
|
||||
|
||||
QString fileName = recorder.actualLocation().toLocalFile();
|
||||
QVERIFY(!fileName.isEmpty());
|
||||
|
||||
QVERIFY(QFileInfo(fileName).size() > 0);
|
||||
QFile(fileName).remove();
|
||||
|
||||
camera->setCaptureMode(QCamera::CaptureStillImage);
|
||||
QTRY_COMPARE(recorder.status(), QMediaRecorder::UnloadedStatus);
|
||||
QCOMPARE(recorderStatusSignal.last().first().value<QMediaRecorder::Status>(), recorder.status());
|
||||
|
||||
delete camera;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QCameraBackend)
|
||||
|
||||
#include "tst_qcamerabackend.moc"
|
||||
|
||||
Reference in New Issue
Block a user