Initial copy of QtMultimediaKit.
Comes from original repo, with SHA1: 2c82d5611655e5967f5c5095af50c0991c4378b2
This commit is contained in:
80
tests/auto/qmediarecorder/main.cpp
Executable file
80
tests/auto/qmediarecorder/main.cpp
Executable file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "tst_qmediarecorder.h"
|
||||
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
#include "s60common.h"
|
||||
#include "tst_qmediarecorder_xa.h"
|
||||
#include "tst_qmediarecorder_mmf.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QApplication app(argc,argv);
|
||||
int ret;
|
||||
tst_QMediaRecorder test_api;
|
||||
ret = QTest::qExec(&test_api, argc, argv);
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
char *new_argv[3];
|
||||
QString str = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + ".log";
|
||||
QByteArray bytes = str.toAscii();
|
||||
char arg1[] = "-o";
|
||||
new_argv[0] = argv[0];
|
||||
new_argv[1] = arg1;
|
||||
new_argv[2] = bytes.data();
|
||||
tst_QMediaRecorder_xa test_xa;
|
||||
ret = QTest::qExec(&test_xa, 3, new_argv);
|
||||
char *new_argv1[3];
|
||||
QString str1 = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + "_s60.log";
|
||||
QByteArray bytes1 = str1.toAscii();
|
||||
char arg2[] = "-o";
|
||||
new_argv1[0] = argv[0];
|
||||
new_argv1[1] = arg2;
|
||||
new_argv1[2] = bytes1.data();
|
||||
tst_QMediaRecorder_mmf test_mmf;
|
||||
ret = QTest::qExec(&test_mmf, 3, new_argv1);
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
18
tests/auto/qmediarecorder/qmediarecorder.pro
Normal file
18
tests/auto/qmediarecorder/qmediarecorder.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
load(qttest_p4)
|
||||
|
||||
QT += multimediakit-private
|
||||
|
||||
# TARGET = tst_qmediarecorder
|
||||
# CONFIG += testcase
|
||||
|
||||
symbian {
|
||||
HEADERS += s60common.h
|
||||
HEADERS += tst_qmediarecorder_xa.h
|
||||
SOURCES += tst_qmediarecorder_xa.cpp
|
||||
HEADERS += tst_qmediarecorder_mmf.h
|
||||
SOURCES += tst_qmediarecorder_mmf.cpp
|
||||
TARGET.CAPABILITY = UserEnvironment ReadDeviceData WriteDeviceData AllFiles
|
||||
}
|
||||
HEADERS += tst_qmediarecorder.h
|
||||
SOURCES += main.cpp tst_qmediarecorder.cpp
|
||||
|
||||
61
tests/auto/qmediarecorder/s60common.h
Executable file
61
tests/auto/qmediarecorder/s60common.h
Executable file
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60COMMON_H
|
||||
#define S60COMMON_H
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#define QTRY_COMPARE(a,e) \
|
||||
for (int _i = 0; _i < 5000; _i += 100) { \
|
||||
if ((a) == (e)) break; \
|
||||
QTest::qWait(100); \
|
||||
} \
|
||||
QCOMPARE(a, e)
|
||||
|
||||
#define QTRY_VERIFY(a) \
|
||||
for (int _i = 0; _i < 5000; _i += 100) { \
|
||||
if (a) break; \
|
||||
QTest::qWait(100); \
|
||||
} \
|
||||
QVERIFY(a)
|
||||
|
||||
#endif //S60COMMON_H
|
||||
796
tests/auto/qmediarecorder/tst_qmediarecorder.cpp
Normal file
796
tests/auto/qmediarecorder/tst_qmediarecorder.cpp
Normal file
@@ -0,0 +1,796 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
#include "tst_qmediarecorder.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaRecorder::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
|
||||
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
|
||||
|
||||
mock = new MockProvider(this);
|
||||
service = new MockService(this, mock);
|
||||
object = new MockObject(this, service);
|
||||
capture = new QMediaRecorder(object);
|
||||
|
||||
audio = qobject_cast<QAudioEndpointSelector*>(service->requestControl(QAudioEndpointSelector_iid));
|
||||
encode = qobject_cast<QAudioEncoderControl*>(service->requestControl(QAudioEncoderControl_iid));
|
||||
videoEncode = qobject_cast<QVideoEncoderControl*>(service->requestControl(QVideoEncoderControl_iid));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::cleanupTestCase()
|
||||
{
|
||||
delete capture;
|
||||
delete object;
|
||||
delete service;
|
||||
delete mock;
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testNullService()
|
||||
{
|
||||
const QString id(QLatin1String("application/x-format"));
|
||||
|
||||
MockObject object(0, 0);
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||
QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(recorder.error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(recorder.duration(), qint64(0));
|
||||
QCOMPARE(recorder.supportedContainers(), QStringList());
|
||||
QCOMPARE(recorder.containerDescription(id), QString());
|
||||
QCOMPARE(recorder.supportedAudioCodecs(), QStringList());
|
||||
QCOMPARE(recorder.audioCodecDescription(id), QString());
|
||||
QCOMPARE(recorder.supportedAudioSampleRates(), QList<int>());
|
||||
QCOMPARE(recorder.supportedVideoCodecs(), QStringList());
|
||||
QCOMPARE(recorder.videoCodecDescription(id), QString());
|
||||
bool continuous = true;
|
||||
QCOMPARE(recorder.supportedResolutions(QVideoEncoderSettings(), &continuous), QList<QSize>());
|
||||
QCOMPARE(continuous, false);
|
||||
continuous = true;
|
||||
QCOMPARE(recorder.supportedFrameRates(QVideoEncoderSettings(), &continuous), QList<qreal>());
|
||||
QCOMPARE(continuous, false);
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
QVERIFY(!recorder.isMuted());
|
||||
recorder.setMuted(true);
|
||||
QVERIFY(!recorder.isMuted());
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testNullControls()
|
||||
{
|
||||
const QString id(QLatin1String("application/x-format"));
|
||||
|
||||
MockService service(0, 0);
|
||||
service.hasControls = false;
|
||||
MockObject object(0, &service);
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||
QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(recorder.error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(recorder.duration(), qint64(0));
|
||||
QCOMPARE(recorder.supportedContainers(), QStringList());
|
||||
QCOMPARE(recorder.containerDescription(id), QString());
|
||||
QCOMPARE(recorder.supportedAudioCodecs(), QStringList());
|
||||
QCOMPARE(recorder.audioCodecDescription(id), QString());
|
||||
QCOMPARE(recorder.supportedAudioSampleRates(), QList<int>());
|
||||
QCOMPARE(recorder.supportedVideoCodecs(), QStringList());
|
||||
QCOMPARE(recorder.videoCodecDescription(id), QString());
|
||||
bool continuous = true;
|
||||
QCOMPARE(recorder.supportedResolutions(QVideoEncoderSettings(), &continuous), QList<QSize>());
|
||||
QCOMPARE(continuous, false);
|
||||
continuous = true;
|
||||
QCOMPARE(recorder.supportedFrameRates(QVideoEncoderSettings(), &continuous), QList<qreal>());
|
||||
QCOMPARE(continuous, false);
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
|
||||
recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
|
||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||
|
||||
QAudioEncoderSettings audio;
|
||||
audio.setCodec(id);
|
||||
audio.setQuality(QtMultimediaKit::LowQuality);
|
||||
|
||||
QVideoEncoderSettings video;
|
||||
video.setCodec(id);
|
||||
video.setResolution(640, 480);
|
||||
|
||||
recorder.setEncodingSettings(audio, video, id);
|
||||
|
||||
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
|
||||
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
|
||||
QCOMPARE(recorder.containerMimeType(), QString());
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
|
||||
recorder.record();
|
||||
QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(recorder.error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
|
||||
recorder.pause();
|
||||
QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(recorder.error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
|
||||
recorder.stop();
|
||||
QCOMPARE(recorder.state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(recorder.error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testError()
|
||||
{
|
||||
const QString errorString(QLatin1String("format error"));
|
||||
|
||||
QSignalSpy spy(capture, SIGNAL(error(QMediaRecorder::Error)));
|
||||
|
||||
QCOMPARE(capture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(capture->errorString(), QString());
|
||||
|
||||
mock->error(QMediaRecorder::FormatError, errorString);
|
||||
QCOMPARE(capture->error(), QMediaRecorder::FormatError);
|
||||
QCOMPARE(capture->errorString(), errorString);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::FormatError);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testSink()
|
||||
{
|
||||
capture->setOutputLocation(QUrl("test.tmp"));
|
||||
QUrl s = capture->outputLocation();
|
||||
QCOMPARE(s.toString(), QString("test.tmp"));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testRecord()
|
||||
{
|
||||
QSignalSpy stateSignal(capture,SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
QSignalSpy progressSignal(capture, SIGNAL(durationChanged(qint64)));
|
||||
capture->record();
|
||||
QCOMPARE(capture->state(), QMediaRecorder::RecordingState);
|
||||
QCOMPARE(capture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(capture->errorString(), QString());
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
QCOMPARE(stateSignal.count(), 1);
|
||||
QCOMPARE(stateSignal.last()[0].value<QMediaRecorder::State>(), QMediaRecorder::RecordingState);
|
||||
QVERIFY(progressSignal.count() > 0);
|
||||
capture->pause();
|
||||
QCOMPARE(capture->state(), QMediaRecorder::PausedState);
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
QCOMPARE(stateSignal.count(), 2);
|
||||
capture->stop();
|
||||
QCOMPARE(capture->state(), QMediaRecorder::StoppedState);
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
QCOMPARE(stateSignal.count(), 3);
|
||||
mock->stop();
|
||||
QCOMPARE(stateSignal.count(), 3);
|
||||
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testMute()
|
||||
{
|
||||
QSignalSpy mutedChanged(capture, SIGNAL(mutedChanged(bool)));
|
||||
QVERIFY(!capture->isMuted());
|
||||
capture->setMuted(true);
|
||||
|
||||
QCOMPARE(mutedChanged.size(), 1);
|
||||
QCOMPARE(mutedChanged[0][0].toBool(), true);
|
||||
QVERIFY(capture->isMuted());
|
||||
|
||||
capture->setMuted(false);
|
||||
|
||||
QCOMPARE(mutedChanged.size(), 2);
|
||||
QCOMPARE(mutedChanged[1][0].toBool(), false);
|
||||
QVERIFY(!capture->isMuted());
|
||||
|
||||
capture->setMuted(false);
|
||||
QCOMPARE(mutedChanged.size(), 2);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testAudioDeviceControl()
|
||||
{
|
||||
QSignalSpy readSignal(audio,SIGNAL(activeEndpointChanged(QString)));
|
||||
QVERIFY(audio->availableEndpoints().size() == 3);
|
||||
QVERIFY(audio->defaultEndpoint().compare("device1") == 0);
|
||||
audio->setActiveEndpoint("device2");
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
QVERIFY(audio->activeEndpoint().compare("device2") == 0);
|
||||
QVERIFY(readSignal.count() == 1);
|
||||
QVERIFY(audio->endpointDescription("device2").compare("dev2 comment") == 0);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testAudioEncodeControl()
|
||||
{
|
||||
QStringList codecs = capture->supportedAudioCodecs();
|
||||
QVERIFY(codecs.count() == 2);
|
||||
QVERIFY(capture->audioCodecDescription("audio/pcm") == "Pulse Code Modulation");
|
||||
QStringList options = encode->supportedEncodingOptions("audio/mpeg");
|
||||
QCOMPARE(options.count(), 4);
|
||||
QVERIFY(encode->encodingOption("audio/mpeg","bitrate").isNull());
|
||||
encode->setEncodingOption("audio/mpeg", "bitrate", QString("vbr"));
|
||||
QCOMPARE(encode->encodingOption("audio/mpeg","bitrate").toString(), QString("vbr"));
|
||||
QCOMPARE(capture->supportedAudioSampleRates(), QList<int>() << 44100);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testMediaFormatsControl()
|
||||
{
|
||||
QCOMPARE(capture->supportedContainers(), QStringList() << "wav" << "mp3" << "mov");
|
||||
|
||||
QCOMPARE(capture->containerDescription("wav"), QString("WAV format"));
|
||||
QCOMPARE(capture->containerDescription("mp3"), QString("MP3 format"));
|
||||
QCOMPARE(capture->containerDescription("ogg"), QString());
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testVideoEncodeControl()
|
||||
{
|
||||
bool continuous = false;
|
||||
QList<QSize> sizes = capture->supportedResolutions(QVideoEncoderSettings(), &continuous);
|
||||
QCOMPARE(sizes.count(), 2);
|
||||
QCOMPARE(continuous, true);
|
||||
|
||||
QList<qreal> rates = capture->supportedFrameRates(QVideoEncoderSettings(), &continuous);
|
||||
QCOMPARE(rates.count(), 3);
|
||||
QCOMPARE(continuous, false);
|
||||
|
||||
QStringList vCodecs = capture->supportedVideoCodecs();
|
||||
QVERIFY(vCodecs.count() == 2);
|
||||
QCOMPARE(capture->videoCodecDescription("video/3gpp"), QString("video/3gpp"));
|
||||
|
||||
QStringList options = videoEncode->supportedEncodingOptions("video/3gpp");
|
||||
QCOMPARE(options.count(), 2);
|
||||
|
||||
QVERIFY(encode->encodingOption("video/3gpp","me").isNull());
|
||||
encode->setEncodingOption("video/3gpp", "me", QString("dia"));
|
||||
QCOMPARE(encode->encodingOption("video/3gpp","me").toString(), QString("dia"));
|
||||
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testEncodingSettings()
|
||||
{
|
||||
QAudioEncoderSettings audioSettings = capture->audioSettings();
|
||||
QCOMPARE(audioSettings.codec(), QString("audio/pcm"));
|
||||
QCOMPARE(audioSettings.bitRate(), 128*1024);
|
||||
QCOMPARE(audioSettings.sampleRate(), -1);
|
||||
QCOMPARE(audioSettings.quality(), QtMultimediaKit::NormalQuality);
|
||||
QCOMPARE(audioSettings.channelCount(), -1);
|
||||
|
||||
QCOMPARE(audioSettings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding);
|
||||
|
||||
QVideoEncoderSettings videoSettings = capture->videoSettings();
|
||||
QCOMPARE(videoSettings.codec(), QString());
|
||||
QCOMPARE(videoSettings.bitRate(), -1);
|
||||
QCOMPARE(videoSettings.resolution(), QSize());
|
||||
QCOMPARE(videoSettings.frameRate(), 0.0);
|
||||
QCOMPARE(videoSettings.quality(), QtMultimediaKit::NormalQuality);
|
||||
QCOMPARE(videoSettings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding);
|
||||
|
||||
QString format = capture->containerMimeType();
|
||||
QCOMPARE(format, QString());
|
||||
|
||||
audioSettings.setCodec("audio/mpeg");
|
||||
audioSettings.setSampleRate(44100);
|
||||
audioSettings.setBitRate(256*1024);
|
||||
audioSettings.setQuality(QtMultimediaKit::HighQuality);
|
||||
audioSettings.setEncodingMode(QtMultimediaKit::AverageBitRateEncoding);
|
||||
|
||||
videoSettings.setCodec("video/3gpp");
|
||||
videoSettings.setBitRate(800);
|
||||
videoSettings.setFrameRate(24*1024);
|
||||
videoSettings.setResolution(QSize(800,600));
|
||||
videoSettings.setQuality(QtMultimediaKit::HighQuality);
|
||||
audioSettings.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||
|
||||
format = QString("mov");
|
||||
|
||||
capture->setEncodingSettings(audioSettings,videoSettings,format);
|
||||
|
||||
QCOMPARE(capture->audioSettings(), audioSettings);
|
||||
QCOMPARE(capture->videoSettings(), videoSettings);
|
||||
QCOMPARE(capture->containerMimeType(), format);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testAudioSettings()
|
||||
{
|
||||
QAudioEncoderSettings settings;
|
||||
QVERIFY(settings.isNull());
|
||||
QVERIFY(settings == QAudioEncoderSettings());
|
||||
|
||||
QCOMPARE(settings.codec(), QString());
|
||||
settings.setCodec(QLatin1String("codecName"));
|
||||
QCOMPARE(settings.codec(), QLatin1String("codecName"));
|
||||
QVERIFY(!settings.isNull());
|
||||
QVERIFY(settings != QAudioEncoderSettings());
|
||||
|
||||
settings = QAudioEncoderSettings();
|
||||
QCOMPARE(settings.bitRate(), -1);
|
||||
settings.setBitRate(128000);
|
||||
QCOMPARE(settings.bitRate(), 128000);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QAudioEncoderSettings();
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality);
|
||||
settings.setQuality(QtMultimediaKit::HighQuality);
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QAudioEncoderSettings();
|
||||
QCOMPARE(settings.sampleRate(), -1);
|
||||
settings.setSampleRate(44100);
|
||||
QCOMPARE(settings.sampleRate(), 44100);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QAudioEncoderSettings();
|
||||
QCOMPARE(settings.channelCount(), -1);
|
||||
settings.setChannelCount(2);
|
||||
QCOMPARE(settings.channelCount(), 2);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QAudioEncoderSettings();
|
||||
QVERIFY(settings.isNull());
|
||||
QCOMPARE(settings.codec(), QString());
|
||||
QCOMPARE(settings.bitRate(), -1);
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality);
|
||||
QCOMPARE(settings.sampleRate(), -1);
|
||||
|
||||
{
|
||||
QAudioEncoderSettings settings1;
|
||||
QAudioEncoderSettings settings2;
|
||||
QCOMPARE(settings2, settings1);
|
||||
|
||||
settings2 = settings1;
|
||||
QCOMPARE(settings2, settings1);
|
||||
QVERIFY(settings2.isNull());
|
||||
|
||||
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||
|
||||
QVERIFY(settings2.isNull());
|
||||
QVERIFY(!settings1.isNull());
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
{
|
||||
QAudioEncoderSettings settings1;
|
||||
QAudioEncoderSettings settings2(settings1);
|
||||
QCOMPARE(settings2, settings1);
|
||||
|
||||
settings2 = settings1;
|
||||
QCOMPARE(settings2, settings1);
|
||||
QVERIFY(settings2.isNull());
|
||||
|
||||
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||
|
||||
QVERIFY(settings2.isNull());
|
||||
QVERIFY(!settings1.isNull());
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
QAudioEncoderSettings settings1;
|
||||
settings1.setBitRate(1);
|
||||
QAudioEncoderSettings settings2;
|
||||
settings2.setBitRate(1);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setBitRate(2);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QAudioEncoderSettings();
|
||||
settings1.setChannelCount(1);
|
||||
settings2 = QAudioEncoderSettings();
|
||||
settings2.setChannelCount(1);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setChannelCount(2);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QAudioEncoderSettings();
|
||||
settings1.setCodec("codec1");
|
||||
settings2 = QAudioEncoderSettings();
|
||||
settings2.setCodec("codec1");
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setCodec("codec2");
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QAudioEncoderSettings();
|
||||
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||
settings2 = QAudioEncoderSettings();
|
||||
settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QAudioEncoderSettings();
|
||||
settings1.setQuality(QtMultimediaKit::NormalQuality);
|
||||
settings2 = QAudioEncoderSettings();
|
||||
settings2.setQuality(QtMultimediaKit::NormalQuality);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setQuality(QtMultimediaKit::LowQuality);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QAudioEncoderSettings();
|
||||
settings1.setSampleRate(1);
|
||||
settings2 = QAudioEncoderSettings();
|
||||
settings2.setSampleRate(1);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setSampleRate(2);
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testVideoSettings()
|
||||
{
|
||||
QVideoEncoderSettings settings;
|
||||
QVERIFY(settings.isNull());
|
||||
QVERIFY(settings == QVideoEncoderSettings());
|
||||
|
||||
QCOMPARE(settings.codec(), QString());
|
||||
settings.setCodec(QLatin1String("codecName"));
|
||||
QCOMPARE(settings.codec(), QLatin1String("codecName"));
|
||||
QVERIFY(!settings.isNull());
|
||||
QVERIFY(settings != QVideoEncoderSettings());
|
||||
|
||||
settings = QVideoEncoderSettings();
|
||||
QCOMPARE(settings.bitRate(), -1);
|
||||
settings.setBitRate(128000);
|
||||
QCOMPARE(settings.bitRate(), 128000);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QVideoEncoderSettings();
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality);
|
||||
settings.setQuality(QtMultimediaKit::HighQuality);
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality);
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QVideoEncoderSettings();
|
||||
QCOMPARE(settings.frameRate(), qreal());
|
||||
settings.setFrameRate(30000.0/10001);
|
||||
QVERIFY(qFuzzyCompare(settings.frameRate(), qreal(30000.0/10001)));
|
||||
settings.setFrameRate(24.0);
|
||||
QVERIFY(qFuzzyCompare(settings.frameRate(), qreal(24.0)));
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QVideoEncoderSettings();
|
||||
QCOMPARE(settings.resolution(), QSize());
|
||||
settings.setResolution(QSize(320,240));
|
||||
QCOMPARE(settings.resolution(), QSize(320,240));
|
||||
settings.setResolution(800,600);
|
||||
QCOMPARE(settings.resolution(), QSize(800,600));
|
||||
QVERIFY(!settings.isNull());
|
||||
|
||||
settings = QVideoEncoderSettings();
|
||||
QVERIFY(settings.isNull());
|
||||
QCOMPARE(settings.codec(), QString());
|
||||
QCOMPARE(settings.bitRate(), -1);
|
||||
QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality);
|
||||
QCOMPARE(settings.frameRate(), qreal());
|
||||
QCOMPARE(settings.resolution(), QSize());
|
||||
|
||||
{
|
||||
QVideoEncoderSettings settings1;
|
||||
QVideoEncoderSettings settings2;
|
||||
QCOMPARE(settings2, settings1);
|
||||
|
||||
settings2 = settings1;
|
||||
QCOMPARE(settings2, settings1);
|
||||
QVERIFY(settings2.isNull());
|
||||
|
||||
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||
|
||||
QVERIFY(settings2.isNull());
|
||||
QVERIFY(!settings1.isNull());
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
{
|
||||
QVideoEncoderSettings settings1;
|
||||
QVideoEncoderSettings settings2(settings1);
|
||||
QCOMPARE(settings2, settings1);
|
||||
|
||||
settings2 = settings1;
|
||||
QCOMPARE(settings2, settings1);
|
||||
QVERIFY(settings2.isNull());
|
||||
|
||||
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||
|
||||
QVERIFY(settings2.isNull());
|
||||
QVERIFY(!settings1.isNull());
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
QVideoEncoderSettings settings1;
|
||||
settings1.setBitRate(1);
|
||||
QVideoEncoderSettings settings2;
|
||||
settings2.setBitRate(1);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setBitRate(2);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QVideoEncoderSettings();
|
||||
settings1.setResolution(800,600);
|
||||
settings2 = QVideoEncoderSettings();
|
||||
settings2.setResolution(QSize(800,600));
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setResolution(QSize(400,300));
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QVideoEncoderSettings();
|
||||
settings1.setCodec("codec1");
|
||||
settings2 = QVideoEncoderSettings();
|
||||
settings2.setCodec("codec1");
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setCodec("codec2");
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QVideoEncoderSettings();
|
||||
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||
settings2 = QVideoEncoderSettings();
|
||||
settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QVideoEncoderSettings();
|
||||
settings1.setQuality(QtMultimediaKit::NormalQuality);
|
||||
settings2 = QVideoEncoderSettings();
|
||||
settings2.setQuality(QtMultimediaKit::NormalQuality);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setQuality(QtMultimediaKit::LowQuality);
|
||||
QVERIFY(settings1 != settings2);
|
||||
|
||||
settings1 = QVideoEncoderSettings();
|
||||
settings1.setFrameRate(1);
|
||||
settings2 = QVideoEncoderSettings();
|
||||
settings2.setFrameRate(1);
|
||||
QVERIFY(settings1 == settings2);
|
||||
settings2.setFrameRate(2);
|
||||
QVERIFY(settings1 != settings2);
|
||||
}
|
||||
|
||||
|
||||
void tst_QMediaRecorder::nullMetaDataControl()
|
||||
{
|
||||
const QString titleKey(QLatin1String("Title"));
|
||||
const QString title(QLatin1String("Host of Seraphim"));
|
||||
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.hasControls = false;
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(metaDataChanged()));
|
||||
|
||||
QCOMPARE(recorder.isMetaDataAvailable(), false);
|
||||
QCOMPARE(recorder.isMetaDataWritable(), false);
|
||||
|
||||
recorder.setMetaData(QtMultimediaKit::Title, title);
|
||||
recorder.setExtendedMetaData(titleKey, title);
|
||||
|
||||
QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), QString());
|
||||
QCOMPARE(recorder.extendedMetaData(titleKey).toString(), QString());
|
||||
QCOMPARE(recorder.availableMetaData(), QList<QtMultimediaKit::MetaData>());
|
||||
QCOMPARE(recorder.availableExtendedMetaData(), QStringList());
|
||||
QCOMPARE(spy.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::isMetaDataAvailable()
|
||||
{
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->setMetaDataAvailable(false);
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
QCOMPARE(recorder.isMetaDataAvailable(), false);
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(metaDataAvailableChanged(bool)));
|
||||
service.mockMetaDataControl->setMetaDataAvailable(true);
|
||||
|
||||
QCOMPARE(recorder.isMetaDataAvailable(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.at(0).at(0).toBool(), true);
|
||||
|
||||
service.mockMetaDataControl->setMetaDataAvailable(false);
|
||||
|
||||
QCOMPARE(recorder.isMetaDataAvailable(), false);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
QCOMPARE(spy.at(1).at(0).toBool(), false);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::isWritable()
|
||||
{
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->setWritable(false);
|
||||
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(metaDataWritableChanged(bool)));
|
||||
|
||||
QCOMPARE(recorder.isMetaDataWritable(), false);
|
||||
|
||||
service.mockMetaDataControl->setWritable(true);
|
||||
|
||||
QCOMPARE(recorder.isMetaDataWritable(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.at(0).at(0).toBool(), true);
|
||||
|
||||
service.mockMetaDataControl->setWritable(false);
|
||||
|
||||
QCOMPARE(recorder.isMetaDataWritable(), false);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
QCOMPARE(spy.at(1).at(0).toBool(), false);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::metaDataChanged()
|
||||
{
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QSignalSpy spy(&recorder, SIGNAL(metaDataChanged()));
|
||||
|
||||
service.mockMetaDataControl->metaDataChanged();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
service.mockMetaDataControl->metaDataChanged();
|
||||
QCOMPARE(spy.count(), 2);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::metaData_data()
|
||||
{
|
||||
QTest::addColumn<QString>("artist");
|
||||
QTest::addColumn<QString>("title");
|
||||
QTest::addColumn<QString>("genre");
|
||||
|
||||
QTest::newRow("")
|
||||
<< QString::fromLatin1("Dead Can Dance")
|
||||
<< QString::fromLatin1("Host of Seraphim")
|
||||
<< QString::fromLatin1("Awesome");
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::metaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->populateMetaData();
|
||||
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
QVERIFY(object.availableMetaData().isEmpty());
|
||||
|
||||
service.mockMetaDataControl->m_data.insert(QtMultimediaKit::AlbumArtist, artist);
|
||||
service.mockMetaDataControl->m_data.insert(QtMultimediaKit::Title, title);
|
||||
service.mockMetaDataControl->m_data.insert(QtMultimediaKit::Genre, genre);
|
||||
|
||||
QCOMPARE(recorder.metaData(QtMultimediaKit::AlbumArtist).toString(), artist);
|
||||
QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), title);
|
||||
|
||||
QList<QtMultimediaKit::MetaData> metaDataKeys = recorder.availableMetaData();
|
||||
QCOMPARE(metaDataKeys.size(), 3);
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::AlbumArtist));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::Title));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimediaKit::Genre));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::setMetaData_data()
|
||||
{
|
||||
QTest::addColumn<QString>("title");
|
||||
|
||||
QTest::newRow("")
|
||||
<< QString::fromLatin1("In the Kingdom of the Blind the One eyed are Kings");
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::setMetaData()
|
||||
{
|
||||
QFETCH(QString, title);
|
||||
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->populateMetaData();
|
||||
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
recorder.setMetaData(QtMultimediaKit::Title, title);
|
||||
QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), title);
|
||||
QCOMPARE(service.mockMetaDataControl->m_data.value(QtMultimediaKit::Title).toString(), title);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::extendedMetaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
QVERIFY(recorder.availableExtendedMetaData().isEmpty());
|
||||
|
||||
service.mockMetaDataControl->m_extendedData.insert(QLatin1String("Artist"), artist);
|
||||
service.mockMetaDataControl->m_extendedData.insert(QLatin1String("Title"), title);
|
||||
service.mockMetaDataControl->m_extendedData.insert(QLatin1String("Genre"), genre);
|
||||
|
||||
QCOMPARE(recorder.extendedMetaData(QLatin1String("Artist")).toString(), artist);
|
||||
QCOMPARE(recorder.extendedMetaData(QLatin1String("Title")).toString(), title);
|
||||
|
||||
QStringList extendedKeys = recorder.availableExtendedMetaData();
|
||||
QCOMPARE(extendedKeys.size(), 3);
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Artist")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Title")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Genre")));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::setExtendedMetaData()
|
||||
{
|
||||
MockProvider recorderControl(0);
|
||||
MockService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->populateMetaData();
|
||||
|
||||
MockObject object(0, &service);
|
||||
|
||||
QMediaRecorder recorder(&object);
|
||||
|
||||
QString title(QLatin1String("In the Kingdom of the Blind the One eyed are Kings"));
|
||||
|
||||
recorder.setExtendedMetaData(QLatin1String("Title"), title);
|
||||
QCOMPARE(recorder.extendedMetaData(QLatin1String("Title")).toString(), title);
|
||||
QCOMPARE(service.mockMetaDataControl->m_extendedData.value(QLatin1String("Title")).toString(), title);
|
||||
}
|
||||
516
tests/auto/qmediarecorder/tst_qmediarecorder.h
Executable file
516
tests/auto/qmediarecorder/tst_qmediarecorder.h
Executable file
@@ -0,0 +1,516 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef TST_QMEDIARECORDER_H
|
||||
#define TST_QMEDIARECORDER_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qmetadatawritercontrol.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qvideoencodercontrol.h>
|
||||
|
||||
#include <qaudioformat.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class MockMediaContainerControl : public QMediaContainerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockMediaContainerControl(QObject *parent):
|
||||
QMediaContainerControl(parent)
|
||||
{
|
||||
m_supportedContainers.append("wav");
|
||||
m_supportedContainers.append("mp3");
|
||||
m_supportedContainers.append("mov");
|
||||
|
||||
m_descriptions.insert("wav", "WAV format");
|
||||
m_descriptions.insert("mp3", "MP3 format");
|
||||
m_descriptions.insert("mov", "MOV format");
|
||||
}
|
||||
|
||||
virtual ~MockMediaContainerControl() {};
|
||||
|
||||
QStringList supportedContainers() const
|
||||
{
|
||||
return m_supportedContainers;
|
||||
}
|
||||
|
||||
QString containerMimeType() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void setContainerMimeType(const QString &formatMimeType)
|
||||
{
|
||||
if (m_supportedContainers.contains(formatMimeType))
|
||||
m_format = formatMimeType;
|
||||
}
|
||||
|
||||
QString containerDescription(const QString &formatMimeType) const
|
||||
{
|
||||
return m_descriptions.value(formatMimeType);
|
||||
}
|
||||
|
||||
private:
|
||||
QStringList m_supportedContainers;
|
||||
QMap<QString, QString> m_descriptions;
|
||||
QString m_format;
|
||||
};
|
||||
|
||||
class MockVideoEncodeProvider : public QVideoEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockVideoEncodeProvider(QObject *parent):
|
||||
QVideoEncoderControl(parent)
|
||||
{
|
||||
m_supportedEncodeOptions.insert("video/3gpp", QStringList() << "quantizer" << "me");
|
||||
m_supportedEncodeOptions.insert("video/H264", QStringList() << "quantizer" << "me" << "bframes");
|
||||
m_videoCodecs << "video/3gpp" << "video/H264";
|
||||
m_sizes << QSize(320,240) << QSize(640,480);
|
||||
m_framerates << 30 << 15 << 1;
|
||||
}
|
||||
~MockVideoEncodeProvider() {}
|
||||
|
||||
QVideoEncoderSettings videoSettings() const { return m_videoSettings; }
|
||||
void setVideoSettings(const QVideoEncoderSettings &settings) { m_videoSettings = settings; };
|
||||
|
||||
QList<QSize> supportedResolutions(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
||||
bool *continuous = 0) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = true;
|
||||
|
||||
return m_sizes;
|
||||
}
|
||||
|
||||
QList<qreal> supportedFrameRates(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
||||
bool *continuous = 0) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return m_framerates;
|
||||
}
|
||||
|
||||
QStringList supportedVideoCodecs() const { return m_videoCodecs; }
|
||||
QString videoCodecDescription(const QString &codecName) const { return codecName; }
|
||||
|
||||
QStringList supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
return m_supportedEncodeOptions.value(codec);
|
||||
}
|
||||
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
return m_encodeOptions[codec].value(name);
|
||||
}
|
||||
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
m_encodeOptions[codec][name] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
QVideoEncoderSettings m_videoSettings;
|
||||
|
||||
QMap<QString, QStringList> m_supportedEncodeOptions;
|
||||
QMap< QString, QMap<QString, QVariant> > m_encodeOptions;
|
||||
|
||||
QStringList m_videoCodecs;
|
||||
QList<QSize> m_sizes;
|
||||
QList<qreal> m_framerates;
|
||||
};
|
||||
|
||||
class MockAudioEncodeProvider : public QAudioEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockAudioEncodeProvider(QObject *parent):
|
||||
QAudioEncoderControl(parent)
|
||||
{
|
||||
m_codecs << "audio/pcm" << "audio/mpeg";
|
||||
m_supportedEncodeOptions.insert("audio/pcm", QStringList());
|
||||
m_supportedEncodeOptions.insert("audio/mpeg", QStringList() << "quality" << "bitrate" << "mode" << "vbr");
|
||||
m_audioSettings.setCodec("audio/pcm");
|
||||
m_audioSettings.setBitRate(128*1024);
|
||||
}
|
||||
|
||||
~MockAudioEncodeProvider() {}
|
||||
|
||||
QAudioEncoderSettings audioSettings() const { return m_audioSettings; }
|
||||
void setAudioSettings(const QAudioEncoderSettings &settings) { m_audioSettings = settings; }
|
||||
|
||||
QList<int> supportedSampleRates(const QAudioEncoderSettings & = QAudioEncoderSettings(), bool *continuous = 0) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return QList<int>() << 44100;
|
||||
}
|
||||
|
||||
QStringList supportedAudioCodecs() const
|
||||
{
|
||||
return m_codecs;
|
||||
}
|
||||
|
||||
QString codecDescription(const QString &codecName) const
|
||||
{
|
||||
if (codecName == "audio/pcm")
|
||||
return QString("Pulse Code Modulation");
|
||||
|
||||
if (codecName == "audio/mpeg")
|
||||
return QString("MP3 audio format");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QStringList supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
return m_supportedEncodeOptions.value(codec);
|
||||
}
|
||||
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
return m_encodeOptions[codec].value(name);
|
||||
}
|
||||
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
m_encodeOptions[codec][name] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
QAudioEncoderSettings m_audioSettings;
|
||||
|
||||
QStringList m_codecs;
|
||||
QStringList m_codecsDesc;
|
||||
|
||||
QMap<QString, QStringList> m_supportedEncodeOptions;
|
||||
QMap< QString, QMap<QString, QVariant> > m_encodeOptions;
|
||||
|
||||
};
|
||||
|
||||
class MockAudioEndpointSelectorProvider : public QAudioEndpointSelector
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockAudioEndpointSelectorProvider(QObject *parent):
|
||||
QAudioEndpointSelector(parent)
|
||||
{
|
||||
m_names << "device1" << "device2" << "device3";
|
||||
m_descriptions << "dev1 comment" << "dev2 comment" << "dev3 comment";
|
||||
emit availableEndpointsChanged();
|
||||
}
|
||||
~MockAudioEndpointSelectorProvider() {};
|
||||
|
||||
QList<QString> availableEndpoints() const
|
||||
{
|
||||
return m_names;
|
||||
}
|
||||
|
||||
QString endpointDescription(const QString& name) const
|
||||
{
|
||||
QString desc;
|
||||
|
||||
for(int i = 0; i < m_names.count(); i++) {
|
||||
if (m_names.at(i).compare(name) == 0) {
|
||||
desc = m_descriptions.at(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
QString defaultEndpoint() const
|
||||
{
|
||||
return m_names.at(0);
|
||||
}
|
||||
|
||||
QString activeEndpoint() const
|
||||
{
|
||||
return m_audioInput;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void setActiveEndpoint(const QString& name)
|
||||
{
|
||||
m_audioInput = name;
|
||||
emit activeEndpointChanged(name);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_audioInput;
|
||||
QList<QString> m_names;
|
||||
QList<QString> m_descriptions;
|
||||
};
|
||||
|
||||
class MockProvider : public QMediaRecorderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MockProvider(QObject *parent):
|
||||
QMediaRecorderControl(parent),
|
||||
m_state(QMediaRecorder::StoppedState),
|
||||
m_position(0),
|
||||
m_muted(false) {}
|
||||
|
||||
QUrl outputLocation() const
|
||||
{
|
||||
return m_sink;
|
||||
}
|
||||
|
||||
bool setOutputLocation(const QUrl &sink)
|
||||
{
|
||||
m_sink = sink;
|
||||
return true;
|
||||
}
|
||||
|
||||
QMediaRecorder::State state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
qint64 duration() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
bool isMuted() const
|
||||
{
|
||||
return m_muted;
|
||||
}
|
||||
|
||||
void applySettings() {}
|
||||
|
||||
using QMediaRecorderControl::error;
|
||||
|
||||
public slots:
|
||||
void record()
|
||||
{
|
||||
m_state = QMediaRecorder::RecordingState;
|
||||
m_position=1;
|
||||
emit stateChanged(m_state);
|
||||
emit durationChanged(m_position);
|
||||
}
|
||||
|
||||
void pause()
|
||||
{
|
||||
m_state = QMediaRecorder::PausedState;
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
m_position=0;
|
||||
m_state = QMediaRecorder::StoppedState;
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
|
||||
void setMuted(bool muted)
|
||||
{
|
||||
if (m_muted != muted)
|
||||
emit mutedChanged(m_muted = muted);
|
||||
}
|
||||
|
||||
public:
|
||||
QUrl m_sink;
|
||||
QMediaRecorder::State m_state;
|
||||
qint64 m_position;
|
||||
bool m_muted;
|
||||
};
|
||||
|
||||
|
||||
class QtTestMetaDataProvider : public QMetaDataWriterControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMetaDataProvider(QObject *parent = 0)
|
||||
: QMetaDataWriterControl(parent)
|
||||
, m_available(false)
|
||||
, m_writable(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool isMetaDataAvailable() const { return m_available; }
|
||||
void setMetaDataAvailable(bool available) {
|
||||
if (m_available != available)
|
||||
emit metaDataAvailableChanged(m_available = available);
|
||||
}
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const { return m_data.keys(); }
|
||||
|
||||
bool isWritable() const { return m_writable; }
|
||||
void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
|
||||
|
||||
QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }
|
||||
void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) {
|
||||
m_data.insert(key, value); }
|
||||
|
||||
QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); }
|
||||
void setExtendedMetaData(const QString &key, const QVariant &value) {
|
||||
m_extendedData.insert(key, value); }
|
||||
|
||||
QStringList availableExtendedMetaData() const { return m_extendedData.keys(); }
|
||||
|
||||
using QMetaDataWriterControl::metaDataChanged;
|
||||
|
||||
void populateMetaData()
|
||||
{
|
||||
m_available = true;
|
||||
}
|
||||
|
||||
bool m_available;
|
||||
bool m_writable;
|
||||
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
||||
QMap<QString, QVariant> m_extendedData;
|
||||
};
|
||||
|
||||
class MockService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockService(QObject *parent, QMediaControl *control):
|
||||
QMediaService(parent),
|
||||
mockControl(control),
|
||||
hasControls(true)
|
||||
{
|
||||
mockAudioEndpointSelector = new MockAudioEndpointSelectorProvider(parent);
|
||||
mockAudioEncodeControl = new MockAudioEncodeProvider(parent);
|
||||
mockFormatControl = new MockMediaContainerControl(parent);
|
||||
mockVideoEncodeControl = new MockVideoEncodeProvider(parent);
|
||||
mockMetaDataControl = new QtTestMetaDataProvider(parent);
|
||||
}
|
||||
|
||||
QMediaControl* requestControl(const char *name)
|
||||
{
|
||||
if(hasControls && qstrcmp(name,QAudioEncoderControl_iid) == 0)
|
||||
return mockAudioEncodeControl;
|
||||
if(hasControls && qstrcmp(name,QAudioEndpointSelector_iid) == 0)
|
||||
return mockAudioEndpointSelector;
|
||||
if(hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
|
||||
return mockControl;
|
||||
if(hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
|
||||
return mockFormatControl;
|
||||
if(hasControls && qstrcmp(name,QVideoEncoderControl_iid) == 0)
|
||||
return mockVideoEncodeControl;
|
||||
if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
|
||||
return mockMetaDataControl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl*) {}
|
||||
|
||||
QMediaControl *mockControl;
|
||||
QAudioEndpointSelector *mockAudioEndpointSelector;
|
||||
QAudioEncoderControl *mockAudioEncodeControl;
|
||||
QMediaContainerControl *mockFormatControl;
|
||||
QVideoEncoderControl *mockVideoEncodeControl;
|
||||
QtTestMetaDataProvider *mockMetaDataControl;
|
||||
bool hasControls;
|
||||
};
|
||||
|
||||
class MockObject : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockObject(QObject *parent, MockService *service):
|
||||
QMediaObject(parent, service)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class tst_QMediaRecorder: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testNullService();
|
||||
void testNullControls();
|
||||
void testError();
|
||||
void testSink();
|
||||
void testRecord();
|
||||
void testMute();
|
||||
void testAudioDeviceControl();
|
||||
void testAudioEncodeControl();
|
||||
void testMediaFormatsControl();
|
||||
void testVideoEncodeControl();
|
||||
void testEncodingSettings();
|
||||
void testAudioSettings();
|
||||
void testVideoSettings();
|
||||
|
||||
void nullMetaDataControl();
|
||||
void isMetaDataAvailable();
|
||||
void isWritable();
|
||||
void metaDataChanged();
|
||||
void metaData_data();
|
||||
void metaData();
|
||||
void setMetaData_data();
|
||||
void setMetaData();
|
||||
void extendedMetaData_data() { metaData_data(); }
|
||||
void extendedMetaData();
|
||||
void setExtendedMetaData_data() { extendedMetaData_data(); }
|
||||
void setExtendedMetaData();
|
||||
|
||||
private:
|
||||
QAudioEncoderControl* encode;
|
||||
QAudioEndpointSelector* audio;
|
||||
MockObject *object;
|
||||
MockService *service;
|
||||
MockProvider *mock;
|
||||
QMediaRecorder *capture;
|
||||
QVideoEncoderControl* videoEncode;
|
||||
};
|
||||
#endif //TST_QMEDIARECORDER_H
|
||||
180
tests/auto/qmediarecorder/tst_qmediarecorder_mmf.cpp
Executable file
180
tests/auto/qmediarecorder/tst_qmediarecorder_mmf.cpp
Executable file
@@ -0,0 +1,180 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "tst_qmediarecorder_mmf.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaRecorder_mmf::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
|
||||
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
|
||||
|
||||
captureSource = new QAudioCaptureSource;
|
||||
audiocapture = new QMediaRecorder(captureSource);
|
||||
|
||||
QVERIFY(captureSource->service());
|
||||
|
||||
audioEndpoint = qobject_cast<QAudioEndpointSelector*>(captureSource->service()->requestControl(QAudioEndpointSelector_iid));
|
||||
audioEncoder = qobject_cast<QAudioEncoderControl*>(captureSource->service()->requestControl(QAudioEncoderControl_iid));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::cleanupTestCase()
|
||||
{
|
||||
delete audiocapture;
|
||||
delete captureSource;
|
||||
}
|
||||
|
||||
QUrl tst_QMediaRecorder_mmf::recordPathAudio(QDir outputDir)
|
||||
{
|
||||
int lastImage = 0;
|
||||
int fileCount = 0;
|
||||
foreach( QString fileName, outputDir.entryList(QStringList() << "testclip_*.amr") ) {
|
||||
int imgNumber = fileName.mid(5, fileName.size()-9).toInt();
|
||||
lastImage = qMax(lastImage, imgNumber);
|
||||
if (outputDir.exists(fileName))
|
||||
fileCount+=1;
|
||||
}
|
||||
lastImage+=fileCount;
|
||||
|
||||
QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath()+QString("/testclip_%1.amr").arg(lastImage+1,4,10,QLatin1Char('0'))));
|
||||
return location;
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testAudioSink()
|
||||
{
|
||||
audiocapture->setOutputLocation(QUrl("test.tmp"));
|
||||
QUrl s = audiocapture->outputLocation();
|
||||
QCOMPARE(s.toString(), QString("test.tmp"));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testAudioRecord()
|
||||
{
|
||||
QSignalSpy stateSignal(audiocapture,SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QTest::qWait(500); // wait for recorder to initialize itself
|
||||
audiocapture->setOutputLocation(recordPathAudio(QDir::rootPath()));
|
||||
audiocapture->record();
|
||||
QTRY_COMPARE(stateSignal.count(), 1); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::RecordingState);
|
||||
QCOMPARE(audiocapture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(audiocapture->errorString(), QString());
|
||||
QCOMPARE(stateSignal.count(), 1);
|
||||
audiocapture->pause();
|
||||
QTRY_COMPARE(stateSignal.count(), 2); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::PausedState);
|
||||
QCOMPARE(stateSignal.count(), 2);
|
||||
audiocapture->stop();
|
||||
QTRY_COMPARE(stateSignal.count(), 3); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(stateSignal.count(), 3);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testAudioRecordWithAMR()
|
||||
{
|
||||
QSignalSpy stateSignal(audiocapture,SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
audiocapture->setOutputLocation(recordPathAudio(QDir::rootPath()));
|
||||
QAudioEncoderSettings audioSettings;
|
||||
QVideoEncoderSettings videoSettings;
|
||||
audioSettings.setCodec("AMR");
|
||||
QString format = audiocapture->containerMimeType();
|
||||
format = QString("audio/amr");
|
||||
audiocapture->setEncodingSettings(audioSettings,videoSettings,format);
|
||||
audiocapture->record();
|
||||
QTRY_COMPARE(stateSignal.count(), 1); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::RecordingState);
|
||||
QCOMPARE(audiocapture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(audiocapture->errorString(), QString());
|
||||
QCOMPARE(stateSignal.count(), 1);
|
||||
audiocapture->pause();
|
||||
QTRY_COMPARE(stateSignal.count(), 2); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::PausedState);
|
||||
QCOMPARE(stateSignal.count(), 2);
|
||||
audiocapture->stop();
|
||||
QTRY_COMPARE(stateSignal.count(), 3); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(stateSignal.count(), 3);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testAudioEndPointSelector()
|
||||
{
|
||||
QSignalSpy audioSignal(audioEndpoint,SIGNAL(activeEndpointChanged(QString)));
|
||||
QVERIFY(audioEndpoint->availableEndpoints().count() == 1);
|
||||
QVERIFY(audioEndpoint->defaultEndpoint().compare("default") == 0);
|
||||
audioEndpoint->setActiveEndpoint("device2");
|
||||
QVERIFY(audioEndpoint->activeEndpoint().compare("device2") == 0);
|
||||
QVERIFY(audioSignal.count() == 1);
|
||||
QVERIFY(audioEndpoint->endpointDescription("device2").compare("") == 0);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testAudioEncoderControl()
|
||||
{
|
||||
QStringList codecs = audiocapture->supportedAudioCodecs();
|
||||
QVERIFY(codecs.count() == 2);
|
||||
QVERIFY(audiocapture->audioCodecDescription("PCM") == "Pulse code modulation");
|
||||
QStringList options = audioEncoder->supportedEncodingOptions("PCM");
|
||||
QCOMPARE(options.count(), 3);
|
||||
QCOMPARE(audiocapture->supportedAudioSampleRates().count(), 12);
|
||||
audioEncoder->setEncodingOption("PCM", "channels", QVariant(2));
|
||||
QCOMPARE(audioEncoder->encodingOption("PCM","channels").toInt(), 2);
|
||||
audioEncoder->setEncodingOption("PCM", "quality", QVariant(int(QtMultimediaKit::NormalQuality)));
|
||||
QCOMPARE(audioEncoder->encodingOption("PCM","quality").toInt(), int(QtMultimediaKit::NormalQuality));
|
||||
audioEncoder->setEncodingOption("PCM", "samplerate", QVariant(44100));
|
||||
QCOMPARE(audioEncoder->encodingOption("PCM","samplerate").toInt(), 44100);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testMediaFormatsControl()
|
||||
{
|
||||
//audioocontainer types
|
||||
// Containers supported are dynamically queried from MMF. We cannot guarentee that 2 platforms
|
||||
// will support the same set.
|
||||
//QCOMPARE(audiocapture->supportedContainers(), QStringList() << "audio/wav" << "audio/amr");
|
||||
QCOMPARE(audiocapture->containerDescription("audio/wav"), QString("WAV Write Format"));
|
||||
QCOMPARE(audiocapture->containerDescription("audio/amr"), QString("AMR Write Format"));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_mmf::testDefaultAudioEncodingSettings()
|
||||
{
|
||||
QAudioEncoderSettings audioSettings = audiocapture->audioSettings();
|
||||
QCOMPARE(audioSettings.codec(), QString("AMR"));
|
||||
QString format = audiocapture->containerMimeType();
|
||||
QCOMPARE(format, QString("audio/amr"));
|
||||
}
|
||||
85
tests/auto/qmediarecorder/tst_qmediarecorder_mmf.h
Executable file
85
tests/auto/qmediarecorder/tst_qmediarecorder_mmf.h
Executable file
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef TST_QMEDIARECORDER_MMF
|
||||
#define TST_QMEDIARECORDER_MMF
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qaudioformat.h>
|
||||
#include <qaudiocapturesource.h>
|
||||
|
||||
#include "s60common.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaRecorder_mmf: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testAudioSink();
|
||||
void testAudioRecord();
|
||||
void testAudioRecordWithAMR();
|
||||
void testAudioEndPointSelector();
|
||||
void testAudioEncoderControl();
|
||||
void testMediaFormatsControl();
|
||||
void testDefaultAudioEncodingSettings();
|
||||
|
||||
private:
|
||||
QUrl recordPathAudio(QDir outputDir);
|
||||
|
||||
QAudioEncoderControl *audioEncoder;
|
||||
QAudioEndpointSelector *audioEndpoint;
|
||||
QMediaRecorder *audiocapture;
|
||||
QAudioCaptureSource *captureSource;
|
||||
};
|
||||
#endif
|
||||
323
tests/auto/qmediarecorder/tst_qmediarecorder_xa.cpp
Executable file
323
tests/auto/qmediarecorder/tst_qmediarecorder_xa.cpp
Executable file
@@ -0,0 +1,323 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "tst_qmediarecorder_xa.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaRecorder_xa::initTestCase()
|
||||
{
|
||||
audiosource = new QAudioCaptureSource;
|
||||
audiocapture = new QMediaRecorder(audiosource);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::cleanupTestCase()
|
||||
{
|
||||
delete audiocapture;
|
||||
delete audiosource;
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testMediaRecorderObject()
|
||||
{
|
||||
//audioocontainer types
|
||||
QCOMPARE(audiocapture->audioCodecDescription("pcm"), QString("pcm"));
|
||||
QCOMPARE(audiocapture->audioCodecDescription("amr"), QString("amr"));
|
||||
QCOMPARE(audiocapture->audioCodecDescription("aac"), QString("aac"));
|
||||
QCOMPARE(audiocapture->containerDescription("audio/wav"), QString("wav container"));
|
||||
QCOMPARE(audiocapture->containerDescription("audio/amr"), QString("amr File format"));
|
||||
QCOMPARE(audiocapture->containerDescription("audio/mpeg"), QString("mpeg container"));
|
||||
QCOMPARE(audiocapture->containerMimeType(), QString("audio/wav"));
|
||||
QCOMPARE(audiocapture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(audiocapture->errorString(), QString());
|
||||
QCOMPARE(audiocapture->outputLocation().toLocalFile(), QString());
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(audiocapture->supportedAudioCodecs().count(), 3); // "pcm", "amr", "aac"
|
||||
QAudioEncoderSettings settings;
|
||||
settings.setCodec("pcm");
|
||||
QCOMPARE(audiocapture->supportedAudioSampleRates(settings).count(), 5);
|
||||
bool isContinuous;
|
||||
audiocapture->supportedAudioSampleRates(settings, &isContinuous);
|
||||
QCOMPARE(isContinuous, false);
|
||||
QCOMPARE(audiocapture->supportedContainers().count(), 3); // "audio/wav", "audio/amr", "audio/mpeg"
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testDefaultAudioEncodingSettings()
|
||||
{
|
||||
QAudioEncoderSettings audioSettings = audiocapture->audioSettings();
|
||||
QCOMPARE(audioSettings.codec(), QString("pcm"));
|
||||
QCOMPARE(audiocapture->containerMimeType(), QString("audio/wav"));
|
||||
QCOMPARE(audioSettings.bitRate(), 0);
|
||||
QCOMPARE(audioSettings.channelCount(), -1);
|
||||
QCOMPARE(audioSettings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding);
|
||||
QCOMPARE(audioSettings.quality(), QtMultimediaKit::NormalQuality);
|
||||
QCOMPARE(audioSettings.sampleRate(), -1);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testAudioRecordingLocationOnly()
|
||||
{
|
||||
QSignalSpy stateSignal(audiocapture,SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QTest::qWait(500); // wait for recorder to initialize itself
|
||||
audiocapture->setOutputLocation(nextFileName(QDir::rootPath(), "locationonly", "wav"));
|
||||
audiocapture->record();
|
||||
QTRY_COMPARE(stateSignal.count(), 1); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::RecordingState);
|
||||
QCOMPARE(audiocapture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(audiocapture->errorString(), QString());
|
||||
QCOMPARE(stateSignal.count(), 1);
|
||||
QTest::qWait(5000); // wait for 5 seconds
|
||||
audiocapture->pause();
|
||||
QTRY_COMPARE(stateSignal.count(), 2); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::PausedState);
|
||||
QCOMPARE(stateSignal.count(), 2);
|
||||
audiocapture->stop();
|
||||
QTRY_COMPARE(stateSignal.count(), 3); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(stateSignal.count(), 3);
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testAudioRecording_data()
|
||||
{
|
||||
QTest::addColumn<QString>("mime"); // "audio/wav", "audio/amr", "audio/mpeg"
|
||||
QTest::addColumn<QString>("codec"); // "pcm", "amr", "aac"
|
||||
QTest::addColumn<QString>("filename_desc");
|
||||
QTest::addColumn<QString>("filename_ext"); // "wav", "amr", "mp4"
|
||||
QTest::addColumn<QString>("settings");
|
||||
QTest::addColumn<int>("bitrate");
|
||||
QTest::addColumn<int>("samplerate");
|
||||
QTest::addColumn<int>("channels");
|
||||
|
||||
QTest::newRow("wav default") << "audio/wav" << "pcm" << "default" << "wav" << "default" << 0 << 0 << 0;
|
||||
QTest::newRow("amr default") << "audio/amr" << "amr" << "default" << "amr" << "default" << 4750 << 8000 << -1;
|
||||
QTest::newRow("aac default") << "audio/mpeg" << "aac" << "default" << "mp4" << "default" << 0 << 48000 << -1;
|
||||
QTest::newRow("wav 08kHz Mono") << "audio/wav" << "pcm" << "Sr08kHzMono" << "wav" << "user" << 0 << 8000 << 1;
|
||||
QTest::newRow("wav 08kHz Stereo") << "audio/wav" << "pcm" << "Sr08kHzStereo" << "wav" << "user" << 0 << 8000 << 2;
|
||||
QTest::newRow("wav 16kHz Mono") << "audio/wav" << "pcm" << "Sr16kHzMono" << "wav" << "user" << 0 << 16000 << 1;
|
||||
QTest::newRow("wav 16kHz Stereo") << "audio/wav" << "pcm" << "Sr16kHzStereo" << "wav" << "user" << 0 << 16000 << 2;
|
||||
QTest::newRow("wav 32kHz Mono") << "audio/wav" << "pcm" << "Sr32kHzMono" << "wav" << "user" << 0 << 32000 << 1;
|
||||
QTest::newRow("wav 32kHz Stereo") << "audio/wav" << "pcm" << "Sr32kHzStereo" << "wav" << "user" << 0<< 32000 << 2;
|
||||
QTest::newRow("wav 48kHz Mono") << "audio/wav" << "pcm" << "Sr48kHzMono" << "wav" << "user" << 0 << 48000 << 1;
|
||||
QTest::newRow("wav 48kHz Stereo") << "audio/wav" << "pcm" << "Sr48kHzStereo" << "wav" << "user" << 0 << 48000 << 2;
|
||||
QTest::newRow("amr Br04750bps") << "audio/amr" << "amr" << "Br04750bps" << "amr" << "user" << 4750 << 8000 << 1;
|
||||
QTest::newRow("amr Br05150bps") << "audio/amr" << "amr" << "Br05150bps" << "amr" << "user" << 5150 << 8000 << 1;
|
||||
QTest::newRow("amr Br05900bps") << "audio/amr" << "amr" << "Br05900bps" << "amr" << "user" << 5900 << 8000 << 1;
|
||||
QTest::newRow("amr Br06700bps") << "audio/amr" << "amr" << "Br06700bps" << "amr" << "user" << 6700 << 8000 << 1;
|
||||
QTest::newRow("amr Br07400bps") << "audio/amr" << "amr" << "Br07400bps" << "amr" << "user" << 7400 << 8000 << 1;
|
||||
QTest::newRow("amr Br07950bps") << "audio/amr" << "amr" << "Br07950bps" << "amr" << "user" << 7950 << 8000 << 1;
|
||||
QTest::newRow("amr Br10200bps") << "audio/amr" << "amr" << "Br10200bps" << "amr" << "user" << 10200 << 8000 << 1;
|
||||
QTest::newRow("amr Br12200bps") << "audio/amr" << "amr" << "Br12200bps" << "amr" << "user" << 10200 << 8000 << 1;
|
||||
QTest::newRow("amr verylowqual") << "audio/amr" << "amr" << "verylowqual" << "amr" << "preset" << -1 << 8000 << -1;
|
||||
QTest::newRow("amr lowqual") << "audio/amr" << "amr" << "lowqual" << "amr" << "preset" << -2 << 8000 << -1;
|
||||
QTest::newRow("amr normalqual") << "audio/amr" << "amr" << "normalqual" << "amr" << "preset" << -3 << 8000 << -1;
|
||||
QTest::newRow("amr highqual") << "audio/amr" << "amr" << "highqual" << "amr" << "preset" << -4 << 8000 << -1;
|
||||
QTest::newRow("amr veryhighqual") << "audio/amr" << "amr" << "veryhighqual" << "amr" << "preset" << -5 << 8000 << -1;
|
||||
|
||||
// Combinations supported for sample rate 8kHz
|
||||
QTest::newRow("aac Br32k Sr8kHz Mono") << "audio/mpeg" << "aac" << "Br32kSr8kHzMono" << "mp4" << "user" << 32000 << 8000 << 1;
|
||||
QTest::newRow("aac Br32k Sr8kHz Stereo") << "audio/mpeg" << "aac" << "Br32kSr8kHzStereo" << "mp4" << "user" << 32000 << 8000 << 2;
|
||||
QTest::newRow("aac Br64k Sr8kHz Stereo") << "audio/mpeg" << "aac" << "Br64kSr8kHzStereo" << "mp4" << "user" << 64000 << 8000 << 2;
|
||||
// Combinations supported for sample rate 16kHz
|
||||
QTest::newRow("aac Br32k Sr16kHz Mono") << "audio/mpeg" << "aac" << "Br32kSr16kHzMono" << "mp4" << "user" << 32000 << 16000 << 1;
|
||||
QTest::newRow("aac Br64k Sr16kHz Mono") << "audio/mpeg" << "aac" << "Br64kSr16kHzMonoo" << "mp4" << "user" << 64000 << 16000 << 1;
|
||||
QTest::newRow("aac Br32k Sr16kHz Stereo") << "audio/mpeg" << "aac" << "Br32kSr16kHzStereo" << "mp4" << "user" << 32000 << 16000 << 2;
|
||||
QTest::newRow("aac Br64k Sr16kHz Stereo") << "audio/mpeg" << "aac" << "Br64kSr16kHzStereo" << "mp4" << "user" << 64000 << 16000 << 2;
|
||||
QTest::newRow("aac Br96k Sr16kHz Stereo") << "audio/mpeg" << "aac" << "Br96kSr16kHzStereo" << "mp4" << "user" << 96000 << 16000 << 2;
|
||||
QTest::newRow("aac Br128k Sr16kHz Stereo") << "audio/mpeg" << "aac" << "Br128kSr16kHzStereo" << "mp4" << "user" << 128000 << 16000 << 2;
|
||||
QTest::newRow("aac Br160k Sr16kHz Stereo") << "audio/mpeg" << "aac" << "Br160kSr16kHzStereo" << "mp4" << "user" << 160000 << 16000 << 2;
|
||||
// Combinations supported for sample rate 24kHz
|
||||
QTest::newRow("aac Br32k Sr24kHz Mono") << "audio/mpeg" << "aac" << "Br32kSr24kHzMono" << "mp4" << "user" << 32000 << 24000 << 1;
|
||||
QTest::newRow("aac Br64k Sr24kHz Mono") << "audio/mpeg" << "aac" << "Br64kSr24kHzMono" << "mp4" << "user" << 64000 << 24000 << 1;
|
||||
QTest::newRow("aac Br96k Sr24kHz Mono") << "audio/mpeg" << "aac" << "Br96kSr24kHzMono" << "mp4" << "user" << 96000 << 24000 << 1;
|
||||
QTest::newRow("aac Br32k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br32kSr24kHzStereo" << "mp4" << "user" << 32000 << 24000 << 2;
|
||||
QTest::newRow("aac Br64k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br64kSr24kHzStereo" << "mp4" << "user" << 64000 << 24000 << 2;
|
||||
QTest::newRow("aac Br96k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br96kSr24kHzStereo" << "mp4" << "user" << 96000 << 24000 << 2;
|
||||
QTest::newRow("aac Br128k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br128kSr24kHzStereo" << "mp4" << "user" << 128000 << 24000 << 2;
|
||||
QTest::newRow("aac Br160k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br160kSr24kHzStereo" << "mp4" << "user" << 160000 << 24000 << 2;
|
||||
QTest::newRow("aac Br192k Sr24kHz Stereo") << "audio/mpeg" << "aac" << "Br192kSr24kHzStereo" << "mp4" << "user" << 192000 << 24000 << 2;
|
||||
// Combinations supported for sample rate 32kHz
|
||||
QTest::newRow("aac Br32k Sr32kHz Mono") << "audio/mpeg" << "aac" << "Br32kSr32kHzMono" << "mp4" << "user" << 32000 << 32000 << 1;
|
||||
QTest::newRow("aac Br64k Sr32kHz Mono") << "audio/mpeg" << "aac" << "Br64kSr32kHzMono" << "mp4" << "user" << 64000 << 32000 << 1;
|
||||
QTest::newRow("aac Br96k Sr32kHz Mono") << "audio/mpeg" << "aac" << "Br96kSr32kHzMono" << "mp4" << "user" << 96000 << 32000 << 1;
|
||||
QTest::newRow("aac Br128k Sr32kHz Mono") << "audio/mpeg" << "aac" << "Br128kSr32kHzMono" << "mp4" << "user" << 128000 << 32000 << 1;
|
||||
QTest::newRow("aac Br160k Sr32kHz Mono") << "audio/mpeg" << "aac" << "Br160kSr32kHzMono" << "mp4" << "user" << 160000 << 32000 << 1;
|
||||
QTest::newRow("aac Br32k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br32kSr32kHzStereo" << "mp4" << "user" << 32000 << 32000 << 2;
|
||||
QTest::newRow("aac Br64k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br64kSr32kHzStereo" << "mp4" << "user" << 64000 << 32000 << 2;
|
||||
QTest::newRow("aac Br96k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br96kSr32kHzStereo" << "mp4" << "user" << 96000 << 32000 << 2;
|
||||
QTest::newRow("aac Br128k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br128kSr32kHzStereo" << "mp4" << "user" << 128000 << 32000 << 2;
|
||||
QTest::newRow("aac Br160k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br160kSr32kHzStereo" << "mp4" << "user" << 160000 << 32000 << 2;
|
||||
QTest::newRow("aac Br192k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br192kSr32kHzStereo" << "mp4" << "user" << 192000 << 32000 << 2;
|
||||
QTest::newRow("aac Br224k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br224kSr32kHzStereo" << "mp4" << "user" << 224000 << 32000 << 2;
|
||||
QTest::newRow("aac Br256k Sr32kHz Stereo") << "audio/mpeg" << "aac" << "Br256kSr32kHzStereo" << "mp4" << "user" << 256000 << 32000 << 2;
|
||||
// Combinations supported for sample rate 48kHz
|
||||
QTest::newRow("aac Br32k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br32kSr48kHzMono" << "mp4" << "user" << 32000 << 48000 << 1;
|
||||
QTest::newRow("aac Br64k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br64kSr48kHzMono" << "mp4" << "user" << 64000 << 48000 << 1;
|
||||
QTest::newRow("aac Br96k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br96kSr48kHzMono" << "mp4" << "user" << 96000 << 48000 << 1;
|
||||
QTest::newRow("aac Br128k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br128kSr48kHzMono" << "mp4" << "user" << 128000 << 48000 << 1;
|
||||
QTest::newRow("aac Br160k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br160kSr48kHzMono" << "mp4" << "user" << 160000 << 48000 << 1;
|
||||
QTest::newRow("aac Br192k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br192kSr48kHzMono" << "mp4" << "user" << 192000 << 48000 << 1;
|
||||
QTest::newRow("aac Br224k Sr48kHz Mono") << "audio/mpeg" << "aac" << "Br224kSr48kHzMono" << "mp4" << "user" << 224000 << 48000 << 1;
|
||||
QTest::newRow("aac Br32k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br32kSr48kHzStereo" << "mp4" << "user" << 32000 << 48000 << 2;
|
||||
QTest::newRow("aac Br64k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br64kSr48kHzStereo" << "mp4" << "user" << 64000 << 48000 << 2;
|
||||
QTest::newRow("aac Br96k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br96kSr48kHzStereo" << "mp4" << "user" << 96000 << 48000 << 2;
|
||||
QTest::newRow("aac Br128k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br128kSr48kHzStereo" << "mp4" << "user" << 128000 << 48000 << 2;
|
||||
QTest::newRow("aac Br160k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br160kSr48kHzStereo" << "mp4" << "user" << 160000 << 48000 << 2;
|
||||
QTest::newRow("aac Br192k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br192kSr48kHzStereo" << "mp4" << "user" << 192000 << 48000 << 2;
|
||||
QTest::newRow("aac Br224k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br224kSr48kHzStereo" << "mp4" << "user" << 224000 << 48000 << 2;
|
||||
QTest::newRow("aac Br256k Sr48kHz Stereo") << "audio/mpeg" << "aac" << "Br256kSr48kHzStereo" << "mp4" << "user" << 256000 << 48000 << 2;
|
||||
QTest::newRow("aac verylowqual") << "audio/mpeg" << "aac" << "verylowqual" << "mp4" << "preset" << -1 << 8000 << -1;
|
||||
QTest::newRow("aac lowqual") << "audio/mpeg" << "aac" << "lowqual" << "mp4" << "preset" << -2 << 24000 << -1;
|
||||
QTest::newRow("aac normalqual") << "audio/mpeg" << "aac" << "normalqual" << "mp4" << "preset" << -3 << 32000 << -1;
|
||||
QTest::newRow("aac highqual") << "audio/mpeg" << "aac" << "highqual" << "mp4" << "preset" << -4 << 48000 << -1;
|
||||
QTest::newRow("aac veryhighqual") << "audio/mpeg" << "aac" << "veryhighqual" << "mp4" << "preset" << -5 << 48000 << -1;
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testAudioRecording()
|
||||
{
|
||||
QFETCH(QString, mime);
|
||||
QFETCH(QString, codec);
|
||||
QFETCH(QString, filename_desc);
|
||||
QFETCH(QString, filename_ext);
|
||||
QFETCH(QString, settings);
|
||||
|
||||
QSignalSpy stateSignal(audiocapture,SIGNAL(stateChanged(QMediaRecorder::State)));
|
||||
audiocapture->setOutputLocation(nextFileName(QDir::rootPath(), filename_desc, filename_ext));
|
||||
QAudioEncoderSettings audioSettings;
|
||||
audioSettings.setCodec(codec);
|
||||
if (settings.compare("default") == 0) {
|
||||
audioSettings.setSampleRate(-1);
|
||||
}
|
||||
else if (settings.compare("user") == 0) {
|
||||
QFETCH(int, bitrate);
|
||||
QFETCH(int, samplerate);
|
||||
QFETCH(int, channels);
|
||||
audioSettings.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||
if (bitrate > 0)
|
||||
audioSettings.setBitRate(bitrate);
|
||||
if (samplerate > 0)
|
||||
audioSettings.setSampleRate(samplerate);
|
||||
if ((channels > 0) || (channels == -1))
|
||||
audioSettings.setChannelCount(channels);
|
||||
}
|
||||
else if (settings.compare("preset") == 0) {
|
||||
QFETCH(int, bitrate);
|
||||
QFETCH(int, samplerate);
|
||||
QFETCH(int, channels);
|
||||
audioSettings.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding);
|
||||
QtMultimediaKit::EncodingQuality quality = QtMultimediaKit::NormalQuality;
|
||||
switch(bitrate) {
|
||||
case -1:
|
||||
quality = QtMultimediaKit::VeryLowQuality;
|
||||
break;
|
||||
case -2:
|
||||
quality = QtMultimediaKit::LowQuality;
|
||||
break;
|
||||
default:
|
||||
case -3:
|
||||
quality = QtMultimediaKit::NormalQuality;
|
||||
break;
|
||||
case -4:
|
||||
quality = QtMultimediaKit::HighQuality;
|
||||
break;
|
||||
case -5:
|
||||
quality = QtMultimediaKit::VeryHighQuality;
|
||||
break;
|
||||
}
|
||||
audioSettings.setQuality(quality);
|
||||
if (samplerate > 0)
|
||||
audioSettings.setSampleRate(samplerate);
|
||||
if ((channels > 0) || (channels == -1))
|
||||
audioSettings.setChannelCount(channels);
|
||||
}
|
||||
QVideoEncoderSettings videoSettings;
|
||||
audiocapture->setEncodingSettings(audioSettings, videoSettings, mime);
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QTest::qWait(500); // wait for recorder to initialize itself
|
||||
int expectedSignalCount = 1;
|
||||
audiocapture->record();
|
||||
QTRY_COMPARE(stateSignal.count(), expectedSignalCount); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::RecordingState);
|
||||
QCOMPARE(audiocapture->error(), QMediaRecorder::NoError);
|
||||
QCOMPARE(audiocapture->errorString(), QString());
|
||||
QCOMPARE(stateSignal.count(), expectedSignalCount);
|
||||
QTest::qWait(5000); // wait for 5 seconds
|
||||
// If we are not testing aac recording to mp4 container
|
||||
if (!((mime.compare("audio/mpeg") == 0) && (codec.compare("aac") == 0))) {
|
||||
expectedSignalCount++;
|
||||
audiocapture->pause();
|
||||
QTRY_COMPARE(stateSignal.count(), expectedSignalCount); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::PausedState);
|
||||
QCOMPARE(stateSignal.count(), expectedSignalCount);
|
||||
}
|
||||
expectedSignalCount++;
|
||||
audiocapture->stop();
|
||||
QTRY_COMPARE(stateSignal.count(), expectedSignalCount); // wait for callbacks to complete in symbian API
|
||||
QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState);
|
||||
QCOMPARE(stateSignal.count(), expectedSignalCount);
|
||||
/* testAudioRecording() function gets executed for each rown in the table.
|
||||
* If and when all tests in the table passes, test log will just contain one
|
||||
* entry 'PASS : tst_QMediaRecorder_xa::testAudioRecording()'. To figure out
|
||||
* which test in the loop completed successfully, just print a debug message
|
||||
* which also goes into the test log generated.*/
|
||||
qDebug() << "----> PASS";
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder_xa::testOutputLocation()
|
||||
{
|
||||
audiocapture->setOutputLocation(QUrl("test.wav"));
|
||||
QUrl s = audiocapture->outputLocation();
|
||||
QCOMPARE(s.toString(), QString("test.wav"));
|
||||
}
|
||||
|
||||
QUrl tst_QMediaRecorder_xa::nextFileName(QDir outputDir, QString appendName, QString ext)
|
||||
{
|
||||
int lastImage = 0;
|
||||
int fileCount = 0;
|
||||
foreach( QString fileName, outputDir.entryList(QStringList() << "testclip_*." + ext) ) {
|
||||
int imgNumber = fileName.mid(5, fileName.size()-9).toInt();
|
||||
lastImage = qMax(lastImage, imgNumber);
|
||||
if (outputDir.exists(fileName))
|
||||
fileCount+=1;
|
||||
}
|
||||
lastImage+=fileCount;
|
||||
|
||||
QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath() + QString("/testclip_%1").arg(lastImage+1 , 4, 10, QLatin1Char('0')) + appendName + "." + ext));
|
||||
return location;
|
||||
}
|
||||
78
tests/auto/qmediarecorder/tst_qmediarecorder_xa.h
Executable file
78
tests/auto/qmediarecorder/tst_qmediarecorder_xa.h
Executable file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef TST_QMEDIARECORDER_XA_H
|
||||
#define TST_QMEDIARECORDER_XA_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qaudiocapturesource.h>
|
||||
|
||||
#include "s60common.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QMediaRecorder_xa: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testMediaRecorderObject(); //1
|
||||
void testDefaultAudioEncodingSettings(); //2
|
||||
void testOutputLocation(); //3
|
||||
void testAudioRecordingLocationOnly(); //4
|
||||
void testAudioRecording_data(); //5
|
||||
void testAudioRecording(); //6
|
||||
|
||||
private:
|
||||
QUrl nextFileName(QDir outputDir, QString appendName, QString ext);
|
||||
|
||||
private:
|
||||
QAudioCaptureSource* audiosource;
|
||||
QMediaRecorder* audiocapture;
|
||||
|
||||
};
|
||||
|
||||
#endif /* TST_QMEDIARECORDER_XA_H */
|
||||
Reference in New Issue
Block a user