summaryrefslogtreecommitdiffstats
path: root/src/plugins/audiocapture
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/audiocapture')
-rw-r--r--src/plugins/audiocapture/audiocapture.pro25
-rw-r--r--src/plugins/audiocapture/audiocaptureservice.cpp90
-rw-r--r--src/plugins/audiocapture/audiocaptureservice.h74
-rw-r--r--src/plugins/audiocapture/audiocaptureserviceplugin.cpp69
-rw-r--r--src/plugins/audiocapture/audiocaptureserviceplugin.h60
-rw-r--r--src/plugins/audiocapture/audiocapturesession.cpp358
-rw-r--r--src/plugins/audiocapture/audiocapturesession.h152
-rw-r--r--src/plugins/audiocapture/audiocontainercontrol.cpp74
-rw-r--r--src/plugins/audiocapture/audiocontainercontrol.h70
-rw-r--r--src/plugins/audiocapture/audioencodercontrol.cpp168
-rw-r--r--src/plugins/audiocapture/audioencodercontrol.h79
-rw-r--r--src/plugins/audiocapture/audioendpointselector.cpp110
-rw-r--r--src/plugins/audiocapture/audioendpointselector.h77
-rw-r--r--src/plugins/audiocapture/audiomediarecordercontrol.cpp102
-rw-r--r--src/plugins/audiocapture/audiomediarecordercontrol.h82
15 files changed, 1590 insertions, 0 deletions
diff --git a/src/plugins/audiocapture/audiocapture.pro b/src/plugins/audiocapture/audiocapture.pro
new file mode 100644
index 000000000..ceb554067
--- /dev/null
+++ b/src/plugins/audiocapture/audiocapture.pro
@@ -0,0 +1,25 @@
+load(qt_module)
+
+TARGET = qtmedia_audioengine
+QT += multimediakit-private
+PLUGIN_TYPE=mediaservice
+
+load(qt_plugin)
+DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE}
+
+# Input
+HEADERS += audioencodercontrol.h \
+ audiocontainercontrol.h \
+ audiomediarecordercontrol.h \
+ audioendpointselector.h \
+ audiocaptureservice.h \
+ audiocaptureserviceplugin.h \
+ audiocapturesession.h
+
+SOURCES += audioencodercontrol.cpp \
+ audiocontainercontrol.cpp \
+ audiomediarecordercontrol.cpp \
+ audioendpointselector.cpp \
+ audiocaptureservice.cpp \
+ audiocaptureserviceplugin.cpp \
+ audiocapturesession.cpp
diff --git a/src/plugins/audiocapture/audiocaptureservice.cpp b/src/plugins/audiocapture/audiocaptureservice.cpp
new file mode 100644
index 000000000..2859eb557
--- /dev/null
+++ b/src/plugins/audiocapture/audiocaptureservice.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "audiocaptureservice.h"
+#include "audiocapturesession.h"
+#include "audioendpointselector.h"
+#include "audioencodercontrol.h"
+#include "audiocontainercontrol.h"
+#include "audiomediarecordercontrol.h"
+
+AudioCaptureService::AudioCaptureService(QObject *parent):
+ QMediaService(parent)
+{
+ m_session = new AudioCaptureSession(this);
+ m_encoderControl = new AudioEncoderControl(m_session);
+ m_containerControl = new AudioContainerControl(m_session);
+ m_mediaControl = new AudioMediaRecorderControl(m_session);
+ m_endpointSelector = new AudioEndpointSelector(m_session);
+}
+
+AudioCaptureService::~AudioCaptureService()
+{
+ delete m_encoderControl;
+ delete m_containerControl;
+ delete m_endpointSelector;
+ delete m_mediaControl;
+ delete m_session;
+}
+
+QMediaControl *AudioCaptureService::requestControl(const char *name)
+{
+ if (qstrcmp(name,QMediaRecorderControl_iid) == 0)
+ return m_mediaControl;
+
+ if (qstrcmp(name,QAudioEncoderControl_iid) == 0)
+ return m_encoderControl;
+
+ if (qstrcmp(name,QAudioEndpointSelector_iid) == 0)
+ return m_endpointSelector;
+
+ if (qstrcmp(name,QMediaContainerControl_iid) == 0)
+ return m_containerControl;
+
+ return 0;
+}
+
+void AudioCaptureService::releaseControl(QMediaControl *control)
+{
+ Q_UNUSED(control)
+}
+
+
diff --git a/src/plugins/audiocapture/audiocaptureservice.h b/src/plugins/audiocapture/audiocaptureservice.h
new file mode 100644
index 000000000..22d70029d
--- /dev/null
+++ b/src/plugins/audiocapture/audiocaptureservice.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOCAPTURESERVICE_H
+#define AUDIOCAPTURESERVICE_H
+
+#include <QtCore/qobject.h>
+
+#include "qmediaservice.h"
+
+class AudioCaptureSession;
+class AudioEncoderControl;
+class AudioContainerControl;
+class AudioMediaRecorderControl;
+class AudioEndpointSelector;
+
+QT_USE_NAMESPACE
+
+class AudioCaptureService : public QMediaService
+{
+ Q_OBJECT
+public:
+ AudioCaptureService(QObject *parent = 0);
+ ~AudioCaptureService();
+
+ QMediaControl *requestControl(const char *interface);
+ void releaseControl(QMediaControl *control);
+private:
+ AudioCaptureSession *m_session;
+ AudioEncoderControl *m_encoderControl;
+ AudioContainerControl *m_containerControl;
+ AudioEndpointSelector *m_endpointSelector;
+ AudioMediaRecorderControl *m_mediaControl;
+};
+
+#endif
diff --git a/src/plugins/audiocapture/audiocaptureserviceplugin.cpp b/src/plugins/audiocapture/audiocaptureserviceplugin.cpp
new file mode 100644
index 000000000..5ebaf12b9
--- /dev/null
+++ b/src/plugins/audiocapture/audiocaptureserviceplugin.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qstring.h>
+
+#include "audiocaptureserviceplugin.h"
+#include "audiocaptureservice.h"
+
+#include "qmediaserviceprovider.h"
+
+
+QStringList AudioCaptureServicePlugin::keys() const
+{
+ return QStringList() << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
+}
+
+QMediaService* AudioCaptureServicePlugin::create(QString const& key)
+{
+ if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE))
+ return new AudioCaptureService;
+
+ return 0;
+}
+
+void AudioCaptureServicePlugin::release(QMediaService *service)
+{
+ delete service;
+}
+
+Q_EXPORT_PLUGIN2(qtmedia_audioengine, AudioCaptureServicePlugin);
+
diff --git a/src/plugins/audiocapture/audiocaptureserviceplugin.h b/src/plugins/audiocapture/audiocaptureserviceplugin.h
new file mode 100644
index 000000000..e244b9951
--- /dev/null
+++ b/src/plugins/audiocapture/audiocaptureserviceplugin.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef AUDIOCAPTURESERVICEPLUGIN_H
+#define AUDIOCAPTURESERVICEPLUGIN_H
+
+#include "qmediaserviceproviderplugin.h"
+
+QT_USE_NAMESPACE
+
+class AudioCaptureServicePlugin : public QMediaServiceProviderPlugin
+{
+ Q_OBJECT
+
+public:
+ QStringList keys() const;
+ QMediaService* create(QString const& key);
+ void release(QMediaService *service);
+};
+
+#endif // AUDIOCAPTURESERVICEPLUGIN_H
diff --git a/src/plugins/audiocapture/audiocapturesession.cpp b/src/plugins/audiocapture/audiocapturesession.cpp
new file mode 100644
index 000000000..da6268adc
--- /dev/null
+++ b/src/plugins/audiocapture/audiocapturesession.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qdir.h>
+#include <qaudiodeviceinfo.h>
+
+#include "qmediarecorder.h"
+
+#include "audiocapturesession.h"
+
+AudioCaptureSession::AudioCaptureSession(QObject *parent):
+ QObject(parent)
+{
+ m_deviceInfo = new QAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice());
+ m_audioInput = 0;
+ m_position = 0;
+ m_state = QMediaRecorder::StoppedState;
+
+ m_format.setFrequency(8000);
+ m_format.setChannels(1);
+ m_format.setSampleSize(8);
+ m_format.setSampleType(QAudioFormat::UnSignedInt);
+ m_format.setCodec("audio/pcm");
+ wavFile = true;
+}
+
+AudioCaptureSession::~AudioCaptureSession()
+{
+ stop();
+
+ if(m_audioInput)
+ delete m_audioInput;
+}
+
+QAudioDeviceInfo* AudioCaptureSession::deviceInfo() const
+{
+ return m_deviceInfo;
+}
+
+QAudioFormat AudioCaptureSession::format() const
+{
+ return m_format;
+}
+
+bool AudioCaptureSession::isFormatSupported(const QAudioFormat &format) const
+{
+ if(m_deviceInfo) {
+ if(format.codec().contains(QLatin1String("audio/x-wav"))) {
+ QAudioFormat fmt = format;
+ fmt.setCodec("audio/pcm");
+ return m_deviceInfo->isFormatSupported(fmt);
+ } else
+ return m_deviceInfo->isFormatSupported(format);
+ }
+ return false;
+}
+
+bool AudioCaptureSession::setFormat(const QAudioFormat &format)
+{
+ if(m_deviceInfo) {
+
+ QAudioFormat fmt = format;
+
+ if(m_deviceInfo->isFormatSupported(fmt)) {
+ m_format = fmt;
+ if(m_audioInput) delete m_audioInput;
+ m_audioInput = 0;
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
+ for(int i=0;i<devices.size();i++) {
+ if(qstrcmp(m_deviceInfo->deviceName().toLocal8Bit().constData(),
+ devices.at(i).deviceName().toLocal8Bit().constData()) == 0) {
+ m_audioInput = new QAudioInput(devices.at(i),m_format);
+ connect(m_audioInput,SIGNAL(stateChanged(QAudio::State)),this,SLOT(stateChanged(QAudio::State)));
+ connect(m_audioInput,SIGNAL(notify()),this,SLOT(notify()));
+ break;
+ }
+ }
+ } else {
+ m_format = m_deviceInfo->preferredFormat();
+ qWarning()<<"failed to setFormat using preferred...";
+ }
+ }
+ return false;
+}
+
+QStringList AudioCaptureSession::supportedContainers() const
+{
+ QStringList list;
+ if(m_deviceInfo) {
+ if (m_deviceInfo->supportedCodecs().size() > 0) {
+ list << "audio/x-wav";
+ list << "audio/pcm";
+ }
+ }
+ return list;
+}
+
+QString AudioCaptureSession::containerDescription(const QString &formatMimeType) const
+{
+ if(m_deviceInfo) {
+ if (formatMimeType.contains(QLatin1String("audio/pcm")))
+ return tr("RAW file format");
+ if (formatMimeType.contains(QLatin1String("audio/x-wav")))
+ return tr("WAV file format");
+ }
+ return QString();
+}
+
+void AudioCaptureSession::setContainerMimeType(const QString &formatMimeType)
+{
+ if (!formatMimeType.contains(QLatin1String("audio/x-wav")) &&
+ !formatMimeType.contains(QLatin1String("audio/pcm")) &&
+ !formatMimeType.isEmpty())
+ return;
+
+ if(m_deviceInfo) {
+ if (!m_deviceInfo->supportedCodecs().contains(QLatin1String("audio/pcm")))
+ return;
+
+ if (formatMimeType.isEmpty() || formatMimeType.contains(QLatin1String("audio/x-wav"))) {
+ wavFile = true;
+ m_format.setCodec("audio/pcm");
+ } else {
+ wavFile = false;
+ m_format.setCodec(formatMimeType);
+ }
+ }
+}
+
+QString AudioCaptureSession::containerMimeType() const
+{
+ if(wavFile)
+ return QString("audio/x-wav");
+
+ return QString("audio/pcm");
+}
+
+QUrl AudioCaptureSession::outputLocation() const
+{
+ return m_actualSink;
+}
+
+bool AudioCaptureSession::setOutputLocation(const QUrl& sink)
+{
+ m_sink = m_actualSink = sink;
+ return true;
+}
+
+qint64 AudioCaptureSession::position() const
+{
+ return m_position;
+}
+
+int AudioCaptureSession::state() const
+{
+ return int(m_state);
+}
+
+QDir AudioCaptureSession::defaultDir() const
+{
+ QStringList dirCandidates;
+
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ dirCandidates << QLatin1String("/home/user/MyDocs");
+#endif
+
+ dirCandidates << QDir::home().filePath("Documents");
+ dirCandidates << QDir::home().filePath("My Documents");
+ dirCandidates << QDir::homePath();
+ dirCandidates << QDir::currentPath();
+ dirCandidates << QDir::tempPath();
+
+ foreach (const QString &path, dirCandidates) {
+ QDir dir(path);
+ if (dir.exists() && QFileInfo(path).isWritable())
+ return dir;
+ }
+
+ return QDir();
+}
+
+QString AudioCaptureSession::generateFileName(const QDir &dir, const QString &ext) const
+{
+
+ int lastClip = 0;
+ foreach(QString fileName, dir.entryList(QStringList() << QString("clip_*.%1").arg(ext))) {
+ int imgNumber = fileName.mid(5, fileName.size()-6-ext.length()).toInt();
+ lastClip = qMax(lastClip, imgNumber);
+ }
+
+ QString name = QString("clip_%1.%2").arg(lastClip+1,
+ 4, //fieldWidth
+ 10,
+ QLatin1Char('0')).arg(ext);
+
+ return dir.absoluteFilePath(name);
+}
+
+void AudioCaptureSession::record()
+{
+ if(!m_audioInput) {
+ setFormat(m_format);
+ }
+
+ m_actualSink = m_sink;
+
+ if (m_actualSink.isEmpty()) {
+ QString ext = wavFile ? QLatin1String("wav") : QLatin1String("raw");
+ m_actualSink = generateFileName(defaultDir(), ext);
+ }
+
+ if(m_actualSink.toLocalFile().length() > 0)
+ file.setFileName(m_actualSink.toLocalFile());
+ else
+ file.setFileName(m_actualSink.toString());
+
+ if(m_audioInput) {
+ if(m_state == QMediaRecorder::StoppedState) {
+ if(file.open(QIODevice::WriteOnly)) {
+ memset(&header,0,sizeof(CombinedHeader));
+ memcpy(header.riff.descriptor.id,"RIFF",4);
+ header.riff.descriptor.size = 0xFFFFFFFF; // This should be updated on stop(), filesize-8
+ memcpy(header.riff.type,"WAVE",4);
+ memcpy(header.wave.descriptor.id,"fmt ",4);
+ header.wave.descriptor.size = 16;
+ header.wave.audioFormat = 1; // for PCM data
+ header.wave.numChannels = m_format.channels();
+ header.wave.sampleRate = m_format.frequency();
+ header.wave.byteRate = m_format.frequency()*m_format.channels()*m_format.sampleSize()/8;
+ header.wave.blockAlign = m_format.channels()*m_format.sampleSize()/8;
+ header.wave.bitsPerSample = m_format.sampleSize();
+ memcpy(header.data.descriptor.id,"data",4);
+ header.data.descriptor.size = 0xFFFFFFFF; // This should be updated on stop(),samples*channels*sampleSize/8
+ if (wavFile)
+ file.write((char*)&header,sizeof(CombinedHeader));
+
+ m_audioInput->start(qobject_cast<QIODevice*>(&file));
+ } else {
+ emit error(1,QString("can't open source, failed"));
+ m_state = QMediaRecorder::StoppedState;
+ emit stateChanged(m_state);
+ }
+ }
+ }
+
+ m_state = QMediaRecorder::RecordingState;
+}
+
+void AudioCaptureSession::pause()
+{
+ if(m_audioInput)
+ m_audioInput->stop();
+
+ m_state = QMediaRecorder::PausedState;
+}
+
+void AudioCaptureSession::stop()
+{
+ if(m_audioInput) {
+ m_audioInput->stop();
+ file.close();
+ if (wavFile) {
+ qint32 fileSize = file.size()-8;
+ file.open(QIODevice::ReadWrite | QIODevice::Unbuffered);
+ file.read((char*)&header,sizeof(CombinedHeader));
+ header.riff.descriptor.size = fileSize; // filesize-8
+ header.data.descriptor.size = fileSize-44; // samples*channels*sampleSize/8
+ file.seek(0);
+ file.write((char*)&header,sizeof(CombinedHeader));
+ file.close();
+ }
+ m_position = 0;
+ }
+ m_state = QMediaRecorder::StoppedState;
+}
+
+void AudioCaptureSession::stateChanged(QAudio::State state)
+{
+ switch(state) {
+ case QAudio::ActiveState:
+ emit stateChanged(QMediaRecorder::RecordingState);
+ break;
+ default:
+ if(!((m_state == QMediaRecorder::PausedState)||(m_state == QMediaRecorder::StoppedState)))
+ m_state = QMediaRecorder::StoppedState;
+
+ emit stateChanged(m_state);
+ break;
+ }
+}
+
+void AudioCaptureSession::notify()
+{
+ m_position += m_audioInput->notifyInterval();
+ emit positionChanged(m_position);
+}
+
+void AudioCaptureSession::setCaptureDevice(const QString &deviceName)
+{
+ m_captureDevice = deviceName;
+ if(m_deviceInfo)
+ delete m_deviceInfo;
+
+ m_deviceInfo = 0;
+
+ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
+ for(int i = 0; i < devices.size(); i++) {
+ if(qstrcmp(m_captureDevice.toLocal8Bit().constData(),
+ devices.at(i).deviceName().toLocal8Bit().constData())==0){
+ m_deviceInfo = new QAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice());
+ return;
+ }
+ }
+ m_deviceInfo = new QAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice());
+}
+
+
+
diff --git a/src/plugins/audiocapture/audiocapturesession.h b/src/plugins/audiocapture/audiocapturesession.h
new file mode 100644
index 000000000..0ce139f9a
--- /dev/null
+++ b/src/plugins/audiocapture/audiocapturesession.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOCAPTURESESSION_H
+#define AUDIOCAPTURESESSION_H
+
+#include <QFile>
+#include <QUrl>
+#include <QDir>
+
+#include "audioencodercontrol.h"
+#include "audioendpointselector.h"
+#include "audiomediarecordercontrol.h"
+
+#include <qaudioformat.h>
+#include <qaudioinput.h>
+#include <qaudiodeviceinfo.h>
+
+QT_USE_NAMESPACE
+
+class AudioCaptureSession : public QObject
+{
+ Q_OBJECT
+
+public:
+ AudioCaptureSession(QObject *parent = 0);
+ ~AudioCaptureSession();
+
+ QAudioFormat format() const;
+ QAudioDeviceInfo* deviceInfo() const;
+ bool isFormatSupported(const QAudioFormat &format) const;
+ bool setFormat(const QAudioFormat &format);
+ QStringList supportedContainers() const;
+ QString containerMimeType() const;
+ void setContainerMimeType(const QString &formatMimeType);
+ QString containerDescription(const QString &formatMimeType) const;
+
+ QUrl outputLocation() const;
+ bool setOutputLocation(const QUrl& sink);
+ qint64 position() const;
+ int state() const;
+ void record();
+ void pause();
+ void stop();
+
+public slots:
+ void setCaptureDevice(const QString &deviceName);
+
+signals:
+ void stateChanged(QMediaRecorder::State state);
+ void positionChanged(qint64 position);
+ void error(int error, const QString &errorString);
+
+private slots:
+ void stateChanged(QAudio::State state);
+ void notify();
+
+private:
+ QDir defaultDir() const;
+ QString generateFileName(const QDir &dir, const QString &ext) const;
+
+ QFile file;
+ QString m_captureDevice;
+ QUrl m_sink;
+ QUrl m_actualSink;
+ QMediaRecorder::State m_state;
+ QAudioInput *m_audioInput;
+ QAudioDeviceInfo *m_deviceInfo;
+ QAudioFormat m_format;
+ qint64 m_position;
+ bool wavFile;
+
+ // WAV header stuff
+
+ struct chunk
+ {
+ char id[4];
+ quint32 size;
+ };
+
+ struct RIFFHeader
+ {
+ chunk descriptor;
+ char type[4];
+ };
+
+ struct WAVEHeader
+ {
+ chunk descriptor;
+ quint16 audioFormat; // PCM = 1
+ quint16 numChannels;
+ quint32 sampleRate;
+ quint32 byteRate;
+ quint16 blockAlign;
+ quint16 bitsPerSample;
+ };
+
+ struct DATAHeader
+ {
+ chunk descriptor;
+// quint8 data[];
+ };
+
+ struct CombinedHeader
+ {
+ RIFFHeader riff;
+ WAVEHeader wave;
+ DATAHeader data;
+ };
+
+ CombinedHeader header;
+};
+
+#endif
diff --git a/src/plugins/audiocapture/audiocontainercontrol.cpp b/src/plugins/audiocapture/audiocontainercontrol.cpp
new file mode 100644
index 000000000..454f43eda
--- /dev/null
+++ b/src/plugins/audiocapture/audiocontainercontrol.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "audiocontainercontrol.h"
+#include "audiocapturesession.h"
+
+AudioContainerControl::AudioContainerControl(QObject *parent)
+ :QMediaContainerControl(parent)
+{
+ m_session = qobject_cast<AudioCaptureSession*>(parent);
+}
+
+AudioContainerControl::~AudioContainerControl()
+{
+}
+
+QStringList AudioContainerControl::supportedContainers() const
+{
+ return m_session->supportedContainers();
+}
+
+QString AudioContainerControl::containerMimeType() const
+{
+ return m_session->containerMimeType();
+}
+
+void AudioContainerControl::setContainerMimeType(const QString &formatMimeType)
+{
+ m_session->setContainerMimeType(formatMimeType);
+}
+
+QString AudioContainerControl::containerDescription(const QString &formatMimeType) const
+{
+ return m_session->containerDescription(formatMimeType);
+}
+
diff --git a/src/plugins/audiocapture/audiocontainercontrol.h b/src/plugins/audiocapture/audiocontainercontrol.h
new file mode 100644
index 000000000..5c8d7b267
--- /dev/null
+++ b/src/plugins/audiocapture/audiocontainercontrol.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOCONTAINERCONTROL_H
+#define AUDIOCONTAINERCONTROL_H
+
+#include "qmediacontainercontrol.h"
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qmap.h>
+
+class AudioCaptureSession;
+
+QT_USE_NAMESPACE
+
+class AudioContainerControl : public QMediaContainerControl
+{
+ Q_OBJECT
+public:
+ AudioContainerControl(QObject *parent);
+ virtual ~AudioContainerControl();
+
+ QStringList supportedContainers() const;
+ QString containerMimeType() const;
+ void setContainerMimeType(const QString &formatMimeType);
+ QString containerDescription(const QString &formatMimeType) const;
+
+private:
+ AudioCaptureSession* m_session;
+};
+
+#endif
diff --git a/src/plugins/audiocapture/audioencodercontrol.cpp b/src/plugins/audiocapture/audioencodercontrol.cpp
new file mode 100644
index 000000000..888deac45
--- /dev/null
+++ b/src/plugins/audiocapture/audioencodercontrol.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "audioencodercontrol.h"
+#include "audiocapturesession.h"
+
+#include <qaudioformat.h>
+
+#include <QtCore/qdebug.h>
+
+AudioEncoderControl::AudioEncoderControl(QObject *parent)
+ :QAudioEncoderControl(parent)
+{
+ m_session = qobject_cast<AudioCaptureSession*>(parent);
+
+ QT_PREPEND_NAMESPACE(QAudioFormat) fmt;
+ fmt.setSampleSize(8);
+ fmt.setChannels(1);
+ fmt.setFrequency(8000);
+ fmt.setSampleType(QT_PREPEND_NAMESPACE(QAudioFormat)::SignedInt);
+ fmt.setCodec("audio/pcm");
+ fmt.setByteOrder(QAudioFormat::LittleEndian);
+ m_session->setFormat(fmt);
+
+ m_settings.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding);
+ m_settings.setCodec("audio/pcm");
+ m_settings.setBitRate(8000);
+ m_settings.setChannelCount(1);
+ m_settings.setSampleRate(8000);
+ m_settings.setQuality(QtMultimediaKit::LowQuality);
+}
+
+AudioEncoderControl::~AudioEncoderControl()
+{
+}
+
+QStringList AudioEncoderControl::supportedAudioCodecs() const
+{
+ QStringList list;
+ if (m_session->supportedContainers().size() > 0)
+ list.append("audio/pcm");
+
+ return list;
+}
+
+QString AudioEncoderControl::codecDescription(const QString &codecName) const
+{
+ if (codecName.contains(QLatin1String("audio/pcm")))
+ return tr("PCM audio data");
+
+ return QString();
+}
+
+QStringList AudioEncoderControl::supportedEncodingOptions(const QString &codec) const
+{
+ Q_UNUSED(codec)
+
+ QStringList list;
+ return list;
+}
+
+QVariant AudioEncoderControl::encodingOption(const QString &codec, const QString &name) const
+{
+ Q_UNUSED(codec)
+ Q_UNUSED(name)
+
+ return QVariant();
+}
+
+void AudioEncoderControl::setEncodingOption(
+ const QString &codec, const QString &name, const QVariant &value)
+{
+ Q_UNUSED(value)
+ Q_UNUSED(codec)
+ Q_UNUSED(name)
+}
+
+QList<int> AudioEncoderControl::supportedSampleRates(const QAudioEncoderSettings &, bool *continuous) const
+{
+ if (continuous)
+ *continuous = false;
+
+ return m_session->deviceInfo()->supportedFrequencies();
+}
+
+QAudioEncoderSettings AudioEncoderControl::audioSettings() const
+{
+ return m_settings;
+}
+
+void AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
+{
+ QAudioFormat fmt = m_session->format();
+
+ if (settings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) {
+ if (settings.quality() == QtMultimediaKit::LowQuality) {
+ fmt.setSampleSize(8);
+ fmt.setChannels(1);
+ fmt.setFrequency(8000);
+ fmt.setSampleType(QAudioFormat::UnSignedInt);
+
+ } else if (settings.quality() == QtMultimediaKit::NormalQuality) {
+ fmt.setSampleSize(16);
+ fmt.setChannels(1);
+ fmt.setFrequency(22050);
+ fmt.setSampleType(QAudioFormat::SignedInt);
+
+ } else {
+ fmt.setSampleSize(16);
+ fmt.setChannels(1);
+ fmt.setFrequency(44100);
+ fmt.setSampleType(QAudioFormat::SignedInt);
+ }
+
+ } else {
+ fmt.setChannels(settings.channelCount());
+ fmt.setFrequency(settings.sampleRate());
+ if (settings.sampleRate() == 8000 && settings.bitRate() == 8000) {
+ fmt.setSampleType(QAudioFormat::UnSignedInt);
+ fmt.setSampleSize(8);
+ } else {
+ fmt.setSampleSize(16);
+ fmt.setSampleType(QAudioFormat::SignedInt);
+ }
+ }
+ fmt.setCodec("audio/pcm");
+
+ m_session->setFormat(fmt);
+ m_settings = settings;
+}
diff --git a/src/plugins/audiocapture/audioencodercontrol.h b/src/plugins/audiocapture/audioencodercontrol.h
new file mode 100644
index 000000000..09ac8b2b2
--- /dev/null
+++ b/src/plugins/audiocapture/audioencodercontrol.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOENCODERCONTROL_H
+#define AUDIOENCODERCONTROL_H
+
+#include "qaudioencodercontrol.h"
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qmap.h>
+
+#include <qaudioformat.h>
+
+class AudioCaptureSession;
+
+QT_USE_NAMESPACE
+
+class AudioEncoderControl : public QAudioEncoderControl
+{
+ Q_OBJECT
+public:
+ AudioEncoderControl(QObject *parent);
+ virtual ~AudioEncoderControl();
+
+ QStringList supportedAudioCodecs() const;
+ QString codecDescription(const QString &codecName) const;
+ QList<int> supportedSampleRates(const QAudioEncoderSettings &, bool *continuous = 0) const;
+
+ QAudioEncoderSettings audioSettings() const;
+ void setAudioSettings(const QAudioEncoderSettings&);
+
+ QStringList supportedEncodingOptions(const QString &codec) const;
+ QVariant encodingOption(const QString &codec, const QString &name) const;
+ void setEncodingOption(const QString &codec, const QString &name, const QVariant &value);
+
+private:
+ AudioCaptureSession* m_session;
+ QAudioEncoderSettings m_settings;
+};
+
+#endif
diff --git a/src/plugins/audiocapture/audioendpointselector.cpp b/src/plugins/audiocapture/audioendpointselector.cpp
new file mode 100644
index 000000000..dc7ca8e90
--- /dev/null
+++ b/src/plugins/audiocapture/audioendpointselector.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "audiocapturesession.h"
+#include "audioendpointselector.h"
+
+#include <qaudiodeviceinfo.h>
+
+
+AudioEndpointSelector::AudioEndpointSelector(QObject *parent)
+ :QAudioEndpointSelector(parent)
+{
+ m_session = qobject_cast<AudioCaptureSession*>(parent);
+
+ update();
+
+ m_audioInput = defaultEndpoint();
+}
+
+AudioEndpointSelector::~AudioEndpointSelector()
+{
+}
+
+QList<QString> AudioEndpointSelector::availableEndpoints() const
+{
+ return m_names;
+}
+
+QString AudioEndpointSelector::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_names.at(i);
+ break;
+ }
+ }
+ return desc;
+}
+
+QString AudioEndpointSelector::defaultEndpoint() const
+{
+ return QAudioDeviceInfo(QAudioDeviceInfo::defaultInputDevice()).deviceName();
+}
+
+QString AudioEndpointSelector::activeEndpoint() const
+{
+ return m_audioInput;
+}
+
+void AudioEndpointSelector::setActiveEndpoint(const QString& name)
+{
+ if (m_audioInput.compare(name) != 0) {
+ m_audioInput = name;
+ m_session->setCaptureDevice(name);
+ emit activeEndpointChanged(name);
+ }
+}
+
+void AudioEndpointSelector::update()
+{
+ m_names.clear();
+ m_descriptions.clear();
+
+ QList<QAudioDeviceInfo> devices;
+ devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
+ for(int i = 0; i < devices.size(); ++i) {
+ m_names.append(devices.at(i).deviceName());
+ m_descriptions.append(devices.at(i).deviceName());
+ }
+}
diff --git a/src/plugins/audiocapture/audioendpointselector.h b/src/plugins/audiocapture/audioendpointselector.h
new file mode 100644
index 000000000..dda3c59c7
--- /dev/null
+++ b/src/plugins/audiocapture/audioendpointselector.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOENDPOINTSELECTOR_H
+#define AUDIOENDPOINTSELECTOR_H
+
+#include <QStringList>
+
+#include "qaudioendpointselector.h"
+
+class AudioCaptureSession;
+
+QT_USE_NAMESPACE
+
+class AudioEndpointSelector : public QAudioEndpointSelector
+{
+Q_OBJECT
+public:
+ AudioEndpointSelector(QObject *parent);
+ virtual ~AudioEndpointSelector();
+
+ QList<QString> availableEndpoints() const;
+ QString endpointDescription(const QString& name) const;
+ QString defaultEndpoint() const;
+ QString activeEndpoint() const;
+
+public Q_SLOTS:
+ void setActiveEndpoint(const QString& name);
+
+private:
+ void update();
+
+ QString m_audioInput;
+ QList<QString> m_names;
+ QList<QString> m_descriptions;
+ AudioCaptureSession* m_session;
+};
+
+#endif // AUDIOENDPOINTSELECTOR_H
diff --git a/src/plugins/audiocapture/audiomediarecordercontrol.cpp b/src/plugins/audiocapture/audiomediarecordercontrol.cpp
new file mode 100644
index 000000000..b1f550a04
--- /dev/null
+++ b/src/plugins/audiocapture/audiomediarecordercontrol.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "audiocapturesession.h"
+#include "audiomediarecordercontrol.h"
+
+#include <QtCore/qdebug.h>
+
+AudioMediaRecorderControl::AudioMediaRecorderControl(QObject *parent)
+ :QMediaRecorderControl(parent)
+{
+ m_session = qobject_cast<AudioCaptureSession*>(parent);
+ connect(m_session,SIGNAL(positionChanged(qint64)),this,SIGNAL(durationChanged(qint64)));
+ connect(m_session,SIGNAL(stateChanged(QMediaRecorder::State)),this,SIGNAL(stateChanged(QMediaRecorder::State)));
+ connect(m_session,SIGNAL(error(int,QString)),this,SIGNAL(error(int,QString)));
+}
+
+AudioMediaRecorderControl::~AudioMediaRecorderControl()
+{
+}
+
+QUrl AudioMediaRecorderControl::outputLocation() const
+{
+ return m_session->outputLocation();
+}
+
+bool AudioMediaRecorderControl::setOutputLocation(const QUrl& sink)
+{
+ return m_session->setOutputLocation(sink);
+}
+
+QMediaRecorder::State AudioMediaRecorderControl::state() const
+{
+ return (QMediaRecorder::State)m_session->state();
+}
+
+qint64 AudioMediaRecorderControl::duration() const
+{
+ return m_session->position();
+}
+
+void AudioMediaRecorderControl::record()
+{
+ m_session->record();
+}
+
+void AudioMediaRecorderControl::pause()
+{
+ m_session->stop();
+}
+
+void AudioMediaRecorderControl::stop()
+{
+ m_session->stop();
+}
+
+bool AudioMediaRecorderControl::isMuted() const
+{
+ return false;
+}
+
+void AudioMediaRecorderControl::setMuted(bool)
+{
+}
diff --git a/src/plugins/audiocapture/audiomediarecordercontrol.h b/src/plugins/audiocapture/audiomediarecordercontrol.h
new file mode 100644
index 000000000..a3528a875
--- /dev/null
+++ b/src/plugins/audiocapture/audiomediarecordercontrol.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUDIOMEDIARECORDERCONTROL_H
+#define AUDIOMEDIARECORDERCONTROL_H
+
+#include <QtCore/qobject.h>
+
+#include "qmediarecorder.h"
+#include "qmediarecordercontrol.h"
+
+class AudioCaptureSession;
+
+QT_USE_NAMESPACE
+
+class AudioMediaRecorderControl : public QMediaRecorderControl
+{
+ Q_OBJECT
+public:
+ AudioMediaRecorderControl(QObject *parent = 0);
+ ~AudioMediaRecorderControl();
+
+ QUrl outputLocation() const;
+ bool setOutputLocation(const QUrl &sink);
+
+ QMediaRecorder::State state() const;
+
+ qint64 duration() const;
+
+ bool isMuted() const;
+
+ void applySettings() {}
+
+public slots:
+ void record();
+ void pause();
+ void stop();
+ void setMuted(bool);
+
+private:
+ AudioCaptureSession* m_session;
+};
+
+#endif