Split QMediaRecorder::setEncodingSettings to separate setters.
It's easier to change only the necessary part of encoding settings. The settings are applied during the next event loop or before recording starts. Change-Id: Ia2b5c93826a302212aa7f79a0c75e4cbaaf1dd7a Reviewed-by: Ling Hu <ling.hu@nokia.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
9d3102efe2
commit
a22a0195f1
@@ -66,9 +66,9 @@ private slots:
|
||||
QVERIFY(strlist[1]==strlist1[1]); //checking with "mp3" mime type
|
||||
QVERIFY(strlist[2]==strlist1[2]); //checking with "mov" mime type
|
||||
|
||||
control.setContainerMimeType("wav");
|
||||
control.setContainerFormat("wav");
|
||||
const QString str("wav");
|
||||
QVERIFY2(control.containerMimeType() == str,"Failed");
|
||||
QVERIFY2(control.containerFormat() == str,"Failed");
|
||||
|
||||
const QString str1("WAV format");
|
||||
QVERIFY2(control.containerDescription("wav") == str1,"FAILED");
|
||||
|
||||
@@ -83,6 +83,7 @@ private slots:
|
||||
void testEncodingSettings();
|
||||
void testAudioSettings();
|
||||
void testVideoSettings();
|
||||
void testSettingsApplied();
|
||||
|
||||
void nullMetaDataControl();
|
||||
void isMetaDataAvailable();
|
||||
@@ -171,7 +172,7 @@ void tst_QMediaRecorder::testNullService()
|
||||
QCOMPARE(continuous, false);
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
QCOMPARE(recorder.containerFormat(), QString());
|
||||
QVERIFY(!recorder.isMuted());
|
||||
recorder.setMuted(true);
|
||||
QVERIFY(!recorder.isMuted());
|
||||
@@ -205,7 +206,7 @@ void tst_QMediaRecorder::testNullControls()
|
||||
QCOMPARE(continuous, false);
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
QCOMPARE(recorder.containerFormat(), QString());
|
||||
|
||||
recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
|
||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||
@@ -222,7 +223,7 @@ void tst_QMediaRecorder::testNullControls()
|
||||
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
QCOMPARE(recorder.containerFormat(), QString());
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
|
||||
@@ -410,7 +411,7 @@ void tst_QMediaRecorder::testEncodingSettings()
|
||||
QCOMPARE(videoSettings.quality(), QtMultimedia::NormalQuality);
|
||||
QCOMPARE(videoSettings.encodingMode(), QtMultimedia::ConstantQualityEncoding);
|
||||
|
||||
QString format = capture->containerMimeType();
|
||||
QString format = capture->containerFormat();
|
||||
QCOMPARE(format, QString());
|
||||
|
||||
audioSettings.setCodec("audio/mpeg");
|
||||
@@ -428,11 +429,13 @@ void tst_QMediaRecorder::testEncodingSettings()
|
||||
|
||||
format = QString("mov");
|
||||
|
||||
capture->setEncodingSettings(audioSettings,videoSettings,format);
|
||||
capture->setAudioSettings(audioSettings);
|
||||
capture->setVideoSettings(videoSettings);
|
||||
capture->setContainerFormat(format);
|
||||
|
||||
QCOMPARE(capture->audioSettings(), audioSettings);
|
||||
QCOMPARE(capture->videoSettings(), videoSettings);
|
||||
QCOMPARE(capture->containerMimeType(), format);
|
||||
QCOMPARE(capture->containerFormat(), format);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testAudioSettings()
|
||||
@@ -688,6 +691,47 @@ void tst_QMediaRecorder::testVideoSettings()
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testSettingsApplied()
|
||||
{
|
||||
MockMediaRecorderControl recorderControl(0);
|
||||
MockMediaRecorderService service(0, &recorderControl);
|
||||
MockMediaObject object(0, &service);
|
||||
|
||||
//if the media recorder is not configured after construction
|
||||
//the settings are applied in the next event loop
|
||||
QMediaRecorder recorder(&object);
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 0);
|
||||
QTest::qWait(10);
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 1);
|
||||
|
||||
QVideoEncoderSettings videoSettings;
|
||||
videoSettings.setResolution(640,480);
|
||||
recorder.setVideoSettings(videoSettings);
|
||||
|
||||
QAudioEncoderSettings audioSettings;
|
||||
audioSettings.setQuality(QtMultimedia::HighQuality);
|
||||
recorder.setAudioSettings(audioSettings);
|
||||
|
||||
recorder.setContainerFormat("mkv");
|
||||
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 1);
|
||||
QTest::qWait(10);
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 2);
|
||||
|
||||
//encoder settings are applied before recording if changed
|
||||
audioSettings.setQuality(QtMultimedia::VeryHighQuality);
|
||||
recorder.setAudioSettings(audioSettings);
|
||||
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 2);
|
||||
recorder.record();
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 3);
|
||||
|
||||
recorder.stop();
|
||||
|
||||
//applySettings is not called if setting has not changes
|
||||
recorder.record();
|
||||
QCOMPARE(recorderControl.m_settingAppliedCount, 3);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::nullMetaDataControl()
|
||||
{
|
||||
|
||||
@@ -72,12 +72,12 @@ public:
|
||||
return m_supportedContainers;
|
||||
}
|
||||
|
||||
QString containerMimeType() const
|
||||
QString containerFormat() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void setContainerMimeType(const QString &formatMimeType)
|
||||
void setContainerFormat(const QString &formatMimeType)
|
||||
{
|
||||
if (m_supportedContainers.contains(formatMimeType))
|
||||
m_format = formatMimeType;
|
||||
|
||||
@@ -53,9 +53,12 @@ class MockMediaRecorderControl : public QMediaRecorderControl
|
||||
public:
|
||||
MockMediaRecorderControl(QObject *parent = 0):
|
||||
QMediaRecorderControl(parent),
|
||||
m_state(QMediaRecorder::StoppedState),
|
||||
m_position(0),
|
||||
m_muted(false) {}
|
||||
m_state(QMediaRecorder::StoppedState),
|
||||
m_position(0),
|
||||
m_muted(false),
|
||||
m_settingAppliedCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
QUrl outputLocation() const
|
||||
{
|
||||
@@ -83,7 +86,10 @@ public:
|
||||
return m_muted;
|
||||
}
|
||||
|
||||
void applySettings() {}
|
||||
void applySettings()
|
||||
{
|
||||
m_settingAppliedCount++;
|
||||
}
|
||||
|
||||
using QMediaRecorderControl::error;
|
||||
|
||||
@@ -120,6 +126,7 @@ public:
|
||||
QMediaRecorder::State m_state;
|
||||
qint64 m_position;
|
||||
bool m_muted;
|
||||
int m_settingAppliedCount;
|
||||
};
|
||||
|
||||
#endif // MOCKRECORDERCONTROL_H
|
||||
|
||||
Reference in New Issue
Block a user