Restructure the source code a little.
Change-Id: I995b0fb33bdda7f01bf6266c1c50a1b17eba6760 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
6ee1977d60
commit
502d3c8eb3
275
src/multimedia/recording/qaudiocapturesource.cpp
Normal file
275
src/multimedia/recording/qaudiocapturesource.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Toolkit.
|
||||
**
|
||||
** $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 "qmediaobject_p.h"
|
||||
#include <qaudiocapturesource.h>
|
||||
#include "qaudioendpointselector.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QAudioCaptureSource
|
||||
\brief The QAudioCaptureSource class provides an interface to query and select an audio input endpoint.
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
QAudioCaptureSource provides access to the audio inputs available on your system.
|
||||
|
||||
You can query these inputs and select one to use.
|
||||
|
||||
A typical implementation example:
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Audio capture source
|
||||
|
||||
The audiocapturesource interface is then used to:
|
||||
|
||||
- Get and Set the audio input to use.
|
||||
|
||||
The capture interface is then used to:
|
||||
|
||||
- Set the destination using setOutputLocation()
|
||||
|
||||
- Set the format parameters using setAudioCodec(),
|
||||
|
||||
- Control the recording using record(),stop()
|
||||
|
||||
\sa QMediaRecorder
|
||||
*/
|
||||
|
||||
class QAudioCaptureSourcePrivate : public QMediaObjectPrivate
|
||||
{
|
||||
public:
|
||||
Q_DECLARE_PUBLIC(QAudioCaptureSource)
|
||||
|
||||
void initControls()
|
||||
{
|
||||
Q_Q(QAudioCaptureSource);
|
||||
|
||||
if (service != 0)
|
||||
audioEndpointSelector = qobject_cast<QAudioEndpointSelector*>(service->requestControl(QAudioEndpointSelector_iid));
|
||||
|
||||
if (audioEndpointSelector) {
|
||||
q->connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)),
|
||||
SIGNAL(activeAudioInputChanged(const QString&)));
|
||||
q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()),
|
||||
SIGNAL(availableAudioInputsChanged()));
|
||||
q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()),
|
||||
SLOT(statusChanged()));
|
||||
errorState = QtMultimedia::NoError;
|
||||
}
|
||||
}
|
||||
|
||||
QAudioCaptureSourcePrivate():provider(0), audioEndpointSelector(0), errorState(QtMultimedia::ServiceMissingError) {}
|
||||
QMediaServiceProvider *provider;
|
||||
QAudioEndpointSelector *audioEndpointSelector;
|
||||
QtMultimedia::AvailabilityError errorState;
|
||||
};
|
||||
|
||||
/*!
|
||||
Construct a QAudioCaptureSource using the QMediaService from \a provider, with \a parent.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QAudioCaptureSource::QAudioCaptureSource(QObject *parent, QMediaServiceProvider *provider):
|
||||
QMediaObject(*new QAudioCaptureSourcePrivate, parent, provider->requestService(Q_MEDIASERVICE_AUDIOSOURCE))
|
||||
{
|
||||
Q_D(QAudioCaptureSource);
|
||||
|
||||
d->provider = provider;
|
||||
d->initControls();
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the audiocapturesource object.
|
||||
*/
|
||||
|
||||
QAudioCaptureSource::~QAudioCaptureSource()
|
||||
{
|
||||
Q_D(QAudioCaptureSource);
|
||||
|
||||
if (d->service && d->audioEndpointSelector)
|
||||
d->service->releaseControl(d->audioEndpointSelector);
|
||||
|
||||
if (d->provider)
|
||||
d->provider->releaseService(d->service);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the error state of the audio capture service.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QtMultimedia::AvailabilityError QAudioCaptureSource::availabilityError() const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
return d->errorState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the audio capture service is available, otherwise returns false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QAudioCaptureSource::isAvailable() const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
if (d->service != NULL) {
|
||||
if (d->audioEndpointSelector && d->audioEndpointSelector->availableEndpoints().size() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns a list of available audio inputs
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QList<QString> QAudioCaptureSource::audioInputs() const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
QList<QString> list;
|
||||
if (d && d->audioEndpointSelector)
|
||||
list <<d->audioEndpointSelector->availableEndpoints();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the description of the audio input device with \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QAudioCaptureSource::audioDescription(const QString& name) const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
if(d->audioEndpointSelector)
|
||||
return d->audioEndpointSelector->endpointDescription(name);
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default audio input name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QAudioCaptureSource::defaultAudioInput() const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
if(d->audioEndpointSelector)
|
||||
return d->audioEndpointSelector->defaultEndpoint();
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the active audio input name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QAudioCaptureSource::activeAudioInput() const
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
if(d->audioEndpointSelector)
|
||||
return d->audioEndpointSelector->activeEndpoint();
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the active audio input to \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QAudioCaptureSource::setAudioInput(const QString& name)
|
||||
{
|
||||
Q_D(const QAudioCaptureSource);
|
||||
|
||||
if(d->audioEndpointSelector)
|
||||
return d->audioEndpointSelector->setActiveEndpoint(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QAudioCaptureSource::activeAudioInputChanged(const QString& name)
|
||||
|
||||
Signal emitted when active audio input changes to \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAudioCaptureSource::availableAudioInputsChanged()
|
||||
|
||||
Signal is emitted when the available audio inputs change.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioCaptureSource::statusChanged()
|
||||
{
|
||||
Q_D(QAudioCaptureSource);
|
||||
|
||||
if (d->audioEndpointSelector) {
|
||||
if (d->audioEndpointSelector->availableEndpoints().size() > 0) {
|
||||
d->errorState = QtMultimedia::NoError;
|
||||
emit availabilityChanged(true);
|
||||
} else {
|
||||
d->errorState = QtMultimedia::BusyError;
|
||||
emit availabilityChanged(false);
|
||||
}
|
||||
} else {
|
||||
d->errorState = QtMultimedia::ServiceMissingError;
|
||||
emit availabilityChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_qaudiocapturesource.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
103
src/multimedia/recording/qaudiocapturesource.h
Normal file
103
src/multimedia/recording/qaudiocapturesource.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Toolkit.
|
||||
**
|
||||
** $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 QAUDIOCAPTURESOURCE_H
|
||||
#define QAUDIOCAPTURESOURCE_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qsize.h>
|
||||
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include "qmediarecorder.h"
|
||||
#include "qmediacontrol.h"
|
||||
#include "qmediaobject.h"
|
||||
#include "qmediaservice.h"
|
||||
|
||||
#include "qmediaserviceprovider.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QAudioCaptureSourcePrivate;
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QAudioCaptureSource : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QAudioCaptureSource(QObject *parent = 0, QMediaServiceProvider *service = QMediaServiceProvider::defaultServiceProvider());
|
||||
~QAudioCaptureSource();
|
||||
|
||||
bool isAvailable() const;
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
QList<QString> audioInputs() const;
|
||||
|
||||
QString audioDescription(const QString& name) const;
|
||||
QString defaultAudioInput() const;
|
||||
QString activeAudioInput() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setAudioInput(const QString& name);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activeAudioInputChanged(const QString& name);
|
||||
void availableAudioInputsChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void statusChanged();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QAudioCaptureSource)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QAUDIOCAPTURESOURCE_H
|
||||
822
src/multimedia/recording/qmediaencodersettings.cpp
Normal file
822
src/multimedia/recording/qmediaencodersettings.cpp
Normal file
@@ -0,0 +1,822 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Toolkit.
|
||||
**
|
||||
** $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 "qmediaencodersettings.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAudioEncoderSettingsPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QAudioEncoderSettingsPrivate() :
|
||||
isNull(true),
|
||||
encodingMode(QtMultimedia::ConstantQualityEncoding),
|
||||
bitrate(-1),
|
||||
sampleRate(-1),
|
||||
channels(-1),
|
||||
quality(QtMultimedia::NormalQuality)
|
||||
{
|
||||
}
|
||||
|
||||
QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other):
|
||||
QSharedData(other),
|
||||
isNull(other.isNull),
|
||||
encodingMode(other.encodingMode),
|
||||
codec(other.codec),
|
||||
bitrate(other.bitrate),
|
||||
sampleRate(other.sampleRate),
|
||||
channels(other.channels),
|
||||
quality(other.quality)
|
||||
{
|
||||
}
|
||||
|
||||
bool isNull;
|
||||
QtMultimedia::EncodingMode encodingMode;
|
||||
QString codec;
|
||||
int bitrate;
|
||||
int sampleRate;
|
||||
int channels;
|
||||
QtMultimedia::EncodingQuality quality;
|
||||
|
||||
private:
|
||||
QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other);
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QAudioEncoderSettings
|
||||
|
||||
\brief The QAudioEncoderSettings class provides a set of audio encoder settings.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
A audio encoder settings object is used to specify the audio encoder
|
||||
settings used by QMediaRecorder. Audio encoder settings are selected by
|
||||
constructing a QAudioEncoderSettings object, setting the desired properties
|
||||
and then passing it to a QMediaRecorder instance using the
|
||||
QMediaRecorder::setEncodingSettings() function.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Audio encoder settings
|
||||
|
||||
\sa QMediaRecorder, QAudioEncoderControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Construct a null audio encoder settings object.
|
||||
*/
|
||||
QAudioEncoderSettings::QAudioEncoderSettings()
|
||||
:d(new QAudioEncoderSettingsPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of the audio encoder settings object \a other.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QAudioEncoderSettings::QAudioEncoderSettings(const QAudioEncoderSettings& other)
|
||||
:d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys an audio encoder settings object.
|
||||
*/
|
||||
|
||||
QAudioEncoderSettings::~QAudioEncoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns the value of \a other to an audio encoder settings object.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QAudioEncoderSettings& QAudioEncoderSettings::operator=(const QAudioEncoderSettings &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to an audio encoder settings
|
||||
object.
|
||||
|
||||
Returns true if the settings objects are of equal value, and false if they
|
||||
are not of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const
|
||||
{
|
||||
return (d == other.d) ||
|
||||
(d->isNull == other.d->isNull &&
|
||||
d->encodingMode == other.d->encodingMode &&
|
||||
d->bitrate == other.d->bitrate &&
|
||||
d->sampleRate == other.d->sampleRate &&
|
||||
d->channels == other.d->channels &&
|
||||
d->quality == other.d->quality &&
|
||||
d->codec == other.d->codec);
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to an audio encoder settings
|
||||
object.
|
||||
|
||||
Returns true if the settings objects are not of equal value, and true if
|
||||
they are of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/*!
|
||||
Identifies if an audio settings object is initialized.
|
||||
|
||||
Returns true if the settings object is null, and false if it is not.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QAudioEncoderSettings::isNull() const
|
||||
{
|
||||
return d->isNull;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio encoding mode.
|
||||
|
||||
\since 1.0
|
||||
\sa QtMultimedia::EncodingMode
|
||||
*/
|
||||
QtMultimedia::EncodingMode QAudioEncoderSettings::encodingMode() const
|
||||
{
|
||||
return d->encodingMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio encoding \a mode setting.
|
||||
|
||||
If QtMultimedia::ConstantQualityEncoding is set, the quality
|
||||
encoding parameter is used and bit rate is ignored,
|
||||
otherwise the bitrate is used.
|
||||
|
||||
The audio codec, channels count and sample rate settings are used in all
|
||||
the encoding modes.
|
||||
|
||||
\since 1.0
|
||||
\sa encodingMode(), QtMultimedia::EncodingMode
|
||||
*/
|
||||
void QAudioEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode)
|
||||
{
|
||||
d->encodingMode = mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio codec.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QAudioEncoderSettings::codec() const
|
||||
{
|
||||
return d->codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio \a codec.
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioEncoderSettings::setCodec(const QString& codec)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->codec = codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the bit rate of the compressed audio stream in bits per second.
|
||||
\since 1.0
|
||||
*/
|
||||
int QAudioEncoderSettings::bitRate() const
|
||||
{
|
||||
return d->bitrate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of audio channels.
|
||||
\since 1.0
|
||||
*/
|
||||
int QAudioEncoderSettings::channelCount() const
|
||||
{
|
||||
return d->channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the number of audio \a channels.
|
||||
|
||||
A value of -1 indicates the encoder should make an optimal choice based on
|
||||
what is available from the audio source and the limitations of the codec.
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioEncoderSettings::setChannelCount(int channels)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->channels = channels;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio bit \a rate in bits per second.
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioEncoderSettings::setBitRate(int rate)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->bitrate = rate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio sample rate in Hz.
|
||||
\since 1.0
|
||||
*/
|
||||
int QAudioEncoderSettings::sampleRate() const
|
||||
{
|
||||
return d->sampleRate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio sample \a rate in Hz.
|
||||
|
||||
A value of -1 indicates the encoder should make an optimal choice based on what is avaialbe
|
||||
from the audio source and the limitations of the codec.
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioEncoderSettings::setSampleRate(int rate)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->sampleRate = rate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio encoding quality.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QtMultimedia::EncodingQuality QAudioEncoderSettings::quality() const
|
||||
{
|
||||
return d->quality;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the audio encoding \a quality.
|
||||
|
||||
Setting the audio quality parameter allows backend to choose the balanced
|
||||
set of encoding parameters to achieve the desired quality level.
|
||||
|
||||
The \a quality settings parameter is only used in the
|
||||
\l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
|
||||
\since 1.0
|
||||
*/
|
||||
void QAudioEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->quality = quality;
|
||||
}
|
||||
|
||||
class QVideoEncoderSettingsPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QVideoEncoderSettingsPrivate() :
|
||||
isNull(true),
|
||||
encodingMode(QtMultimedia::ConstantQualityEncoding),
|
||||
bitrate(-1),
|
||||
frameRate(0),
|
||||
quality(QtMultimedia::NormalQuality)
|
||||
{
|
||||
}
|
||||
|
||||
QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other):
|
||||
QSharedData(other),
|
||||
isNull(other.isNull),
|
||||
encodingMode(other.encodingMode),
|
||||
codec(other.codec),
|
||||
bitrate(other.bitrate),
|
||||
resolution(other.resolution),
|
||||
frameRate(other.frameRate),
|
||||
quality(other.quality)
|
||||
{
|
||||
}
|
||||
|
||||
bool isNull;
|
||||
QtMultimedia::EncodingMode encodingMode;
|
||||
QString codec;
|
||||
int bitrate;
|
||||
QSize resolution;
|
||||
qreal frameRate;
|
||||
QtMultimedia::EncodingQuality quality;
|
||||
|
||||
private:
|
||||
QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other);
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QVideoEncoderSettings
|
||||
|
||||
\brief The QVideoEncoderSettings class provides a set of video encoder settings.
|
||||
\since 1.0
|
||||
|
||||
A video encoder settings object is used to specify the video encoder
|
||||
settings used by QMediaRecorder. Video encoder settings are selected by
|
||||
constructing a QVideoEncoderSettings object, setting the desired properties
|
||||
and then passing it to a QMediaRecorder instance using the
|
||||
QMediaRecorder::setEncodingSettings() function.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Video encoder settings
|
||||
|
||||
\sa QMediaRecorder, QVideoEncoderControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a null video encoder settings object.
|
||||
*/
|
||||
|
||||
QVideoEncoderSettings::QVideoEncoderSettings()
|
||||
:d(new QVideoEncoderSettingsPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of the video encoder settings object \a other.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QVideoEncoderSettings::QVideoEncoderSettings(const QVideoEncoderSettings& other)
|
||||
:d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a video encoder settings object.
|
||||
*/
|
||||
|
||||
QVideoEncoderSettings::~QVideoEncoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns the value of \a other to a video encoder settings object.
|
||||
\since 1.0
|
||||
*/
|
||||
QVideoEncoderSettings &QVideoEncoderSettings::operator=(const QVideoEncoderSettings &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to a video encoder settings object.
|
||||
|
||||
Returns true if the settings objects are of equal value, and false if they
|
||||
are not of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const
|
||||
{
|
||||
return (d == other.d) ||
|
||||
(d->isNull == other.d->isNull &&
|
||||
d->encodingMode == other.d->encodingMode &&
|
||||
d->bitrate == other.d->bitrate &&
|
||||
d->quality == other.d->quality &&
|
||||
d->codec == other.d->codec &&
|
||||
d->resolution == other.d->resolution &&
|
||||
qFuzzyCompare(d->frameRate, other.d->frameRate));
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to a video encoder settings object.
|
||||
|
||||
Returns true if the settings objects are not of equal value, and false if
|
||||
they are of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/*!
|
||||
Identifies if a video encoder settings object is uninitalized.
|
||||
|
||||
Returns true if the settings are null, and false if they are not.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QVideoEncoderSettings::isNull() const
|
||||
{
|
||||
return d->isNull;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video encoding mode.
|
||||
|
||||
\since 1.0
|
||||
\sa QtMultimedia::EncodingMode
|
||||
*/
|
||||
QtMultimedia::EncodingMode QVideoEncoderSettings::encodingMode() const
|
||||
{
|
||||
return d->encodingMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the video encoding \a mode.
|
||||
|
||||
If QtMultimedia::ConstantQualityEncoding is set,
|
||||
the quality encoding parameter is used and bit rate is ignored,
|
||||
otherwise the bitrate is used.
|
||||
|
||||
The rest of encoding settings are respected regardless of encoding mode.
|
||||
|
||||
\since 1.0
|
||||
\sa QtMultimedia::EncodingMode
|
||||
*/
|
||||
void QVideoEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->encodingMode = mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video codec.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QVideoEncoderSettings::codec() const
|
||||
{
|
||||
return d->codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the video \a codec.
|
||||
\since 1.0
|
||||
*/
|
||||
void QVideoEncoderSettings::setCodec(const QString& codec)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->codec = codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns bit rate of the encoded video stream in bits per second.
|
||||
\since 1.0
|
||||
*/
|
||||
int QVideoEncoderSettings::bitRate() const
|
||||
{
|
||||
return d->bitrate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the bit rate of the encoded video stream to \a value.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QVideoEncoderSettings::setBitRate(int value)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->bitrate = value;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video frame rate.
|
||||
\since 1.0
|
||||
*/
|
||||
qreal QVideoEncoderSettings::frameRate() const
|
||||
{
|
||||
return d->frameRate;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QVideoEncoderSettings::setFrameRate(qreal rate)
|
||||
|
||||
Sets the video frame \a rate.
|
||||
|
||||
A value of 0 indicates the encoder should make an optimal choice based on what is available
|
||||
from the video source and the limitations of the codec.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QVideoEncoderSettings::setFrameRate(qreal rate)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->frameRate = rate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the resolution of the encoded video.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QSize QVideoEncoderSettings::resolution() const
|
||||
{
|
||||
return d->resolution;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a resolution of the encoded video.
|
||||
|
||||
An empty QSize indicates the encoder should make an optimal choice based on
|
||||
what is available from the video source and the limitations of the codec.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QVideoEncoderSettings::setResolution(const QSize &resolution)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->resolution = resolution;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a width and \a height of the resolution of the encoded video.
|
||||
|
||||
\overload
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QVideoEncoderSettings::setResolution(int width, int height)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->resolution = QSize(width, height);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video encoding quality.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QtMultimedia::EncodingQuality QVideoEncoderSettings::quality() const
|
||||
{
|
||||
return d->quality;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the video encoding \a quality.
|
||||
|
||||
Setting the video quality parameter allows backend to choose the balanced
|
||||
set of encoding parameters to achieve the desired quality level.
|
||||
|
||||
The \a quality settings parameter is only used in the
|
||||
\l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
|
||||
The \a quality settings parameter is only used in the \l
|
||||
{QtMultimedia::ConstantQualityEncoding}{constant quality}
|
||||
\l{encodingMode()}{encoding mode}.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QVideoEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->quality = quality;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class QImageEncoderSettingsPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QImageEncoderSettingsPrivate() :
|
||||
isNull(true),
|
||||
quality(QtMultimedia::NormalQuality)
|
||||
{
|
||||
}
|
||||
|
||||
QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other):
|
||||
QSharedData(other),
|
||||
isNull(other.isNull),
|
||||
codec(other.codec),
|
||||
resolution(other.resolution),
|
||||
quality(other.quality)
|
||||
{
|
||||
}
|
||||
|
||||
bool isNull;
|
||||
QString codec;
|
||||
QSize resolution;
|
||||
QtMultimedia::EncodingQuality quality;
|
||||
|
||||
private:
|
||||
QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other);
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QImageEncoderSettings
|
||||
|
||||
|
||||
\brief The QImageEncoderSettings class provides a set of image encoder
|
||||
settings.
|
||||
\since 1.0
|
||||
|
||||
A image encoder settings object is used to specify the image encoder
|
||||
settings used by QCameraImageCapture. Image encoder settings are selected
|
||||
by constructing a QImageEncoderSettings object, setting the desired
|
||||
properties and then passing it to a QCameraImageCapture instance using the
|
||||
QCameraImageCapture::setImageSettings() function.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Image encoder settings
|
||||
|
||||
\sa QImageEncoderControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a null image encoder settings object.
|
||||
*/
|
||||
|
||||
QImageEncoderSettings::QImageEncoderSettings()
|
||||
:d(new QImageEncoderSettingsPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of the image encoder settings object \a other.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QImageEncoderSettings::QImageEncoderSettings(const QImageEncoderSettings& other)
|
||||
:d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a image encoder settings object.
|
||||
*/
|
||||
|
||||
QImageEncoderSettings::~QImageEncoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns the value of \a other to a image encoder settings object.
|
||||
\since 1.0
|
||||
*/
|
||||
QImageEncoderSettings &QImageEncoderSettings::operator=(const QImageEncoderSettings &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to a image encoder settings
|
||||
object.
|
||||
|
||||
Returns true if the settings objects are of equal value, and false if they
|
||||
are not of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const
|
||||
{
|
||||
return (d == other.d) ||
|
||||
(d->isNull == other.d->isNull &&
|
||||
d->quality == other.d->quality &&
|
||||
d->codec == other.d->codec &&
|
||||
d->resolution == other.d->resolution);
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Determines if \a other is of equal value to a image encoder settings
|
||||
object.
|
||||
|
||||
Returns true if the settings objects are not of equal value, and false if
|
||||
they are of equal value.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/*!
|
||||
Identifies if a image encoder settings object is uninitalized.
|
||||
|
||||
Returns true if the settings are null, and false if they are not.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QImageEncoderSettings::isNull() const
|
||||
{
|
||||
return d->isNull;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the image codec.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QImageEncoderSettings::codec() const
|
||||
{
|
||||
return d->codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the image \a codec.
|
||||
\since 1.0
|
||||
*/
|
||||
void QImageEncoderSettings::setCodec(const QString& codec)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->codec = codec;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the resolution of the encoded image.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QSize QImageEncoderSettings::resolution() const
|
||||
{
|
||||
return d->resolution;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a resolution of the encoded image.
|
||||
|
||||
An empty QSize indicates the encoder should make an optimal choice based on
|
||||
what is available from the image source and the limitations of the codec.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QImageEncoderSettings::setResolution(const QSize &resolution)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->resolution = resolution;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a width and \a height of the resolution of the encoded image.
|
||||
|
||||
\overload
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QImageEncoderSettings::setResolution(int width, int height)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->resolution = QSize(width, height);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the image encoding quality.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QtMultimedia::EncodingQuality QImageEncoderSettings::quality() const
|
||||
{
|
||||
return d->quality;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the image encoding \a quality.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QImageEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
|
||||
{
|
||||
d->isNull = false;
|
||||
d->quality = quality;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
168
src/multimedia/recording/qmediaencodersettings.h
Normal file
168
src/multimedia/recording/qmediaencodersettings.h
Normal file
@@ -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 Toolkit.
|
||||
**
|
||||
** $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 QMEDIAENCODERSETTINGS_H
|
||||
#define QMEDIAENCODERSETTINGS_H
|
||||
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qsize.h>
|
||||
#include <qtmultimediadefs.h>
|
||||
#include "qtmedianamespace.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
|
||||
class QAudioEncoderSettingsPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QAudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
QAudioEncoderSettings();
|
||||
QAudioEncoderSettings(const QAudioEncoderSettings& other);
|
||||
|
||||
~QAudioEncoderSettings();
|
||||
|
||||
QAudioEncoderSettings& operator=(const QAudioEncoderSettings &other);
|
||||
bool operator==(const QAudioEncoderSettings &other) const;
|
||||
bool operator!=(const QAudioEncoderSettings &other) const;
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
QtMultimedia::EncodingMode encodingMode() const;
|
||||
void setEncodingMode(QtMultimedia::EncodingMode);
|
||||
|
||||
QString codec() const;
|
||||
void setCodec(const QString& codec);
|
||||
|
||||
int bitRate() const;
|
||||
void setBitRate(int bitrate);
|
||||
|
||||
int channelCount() const;
|
||||
void setChannelCount(int channels);
|
||||
|
||||
int sampleRate() const;
|
||||
void setSampleRate(int rate);
|
||||
|
||||
QtMultimedia::EncodingQuality quality() const;
|
||||
void setQuality(QtMultimedia::EncodingQuality quality);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QAudioEncoderSettingsPrivate> d;
|
||||
};
|
||||
|
||||
class QVideoEncoderSettingsPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QVideoEncoderSettings
|
||||
{
|
||||
public:
|
||||
QVideoEncoderSettings();
|
||||
QVideoEncoderSettings(const QVideoEncoderSettings& other);
|
||||
|
||||
~QVideoEncoderSettings();
|
||||
|
||||
QVideoEncoderSettings& operator=(const QVideoEncoderSettings &other);
|
||||
bool operator==(const QVideoEncoderSettings &other) const;
|
||||
bool operator!=(const QVideoEncoderSettings &other) const;
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
QtMultimedia::EncodingMode encodingMode() const;
|
||||
void setEncodingMode(QtMultimedia::EncodingMode);
|
||||
|
||||
QString codec() const;
|
||||
void setCodec(const QString &);
|
||||
|
||||
QSize resolution() const;
|
||||
void setResolution(const QSize &);
|
||||
void setResolution(int width, int height);
|
||||
|
||||
qreal frameRate() const;
|
||||
void setFrameRate(qreal rate);
|
||||
|
||||
int bitRate() const;
|
||||
void setBitRate(int bitrate);
|
||||
|
||||
QtMultimedia::EncodingQuality quality() const;
|
||||
void setQuality(QtMultimedia::EncodingQuality quality);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QVideoEncoderSettingsPrivate> d;
|
||||
};
|
||||
|
||||
class QImageEncoderSettingsPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QImageEncoderSettings
|
||||
{
|
||||
public:
|
||||
QImageEncoderSettings();
|
||||
QImageEncoderSettings(const QImageEncoderSettings& other);
|
||||
|
||||
~QImageEncoderSettings();
|
||||
|
||||
QImageEncoderSettings& operator=(const QImageEncoderSettings &other);
|
||||
bool operator==(const QImageEncoderSettings &other) const;
|
||||
bool operator!=(const QImageEncoderSettings &other) const;
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
QString codec() const;
|
||||
void setCodec(const QString &);
|
||||
|
||||
QSize resolution() const;
|
||||
void setResolution(const QSize &);
|
||||
void setResolution(int width, int height);
|
||||
|
||||
QtMultimedia::EncodingQuality quality() const;
|
||||
void setQuality(QtMultimedia::EncodingQuality quality);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QImageEncoderSettingsPrivate> d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
904
src/multimedia/recording/qmediarecorder.cpp
Normal file
904
src/multimedia/recording/qmediarecorder.cpp
Normal file
@@ -0,0 +1,904 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Toolkit.
|
||||
**
|
||||
** $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 "qmediarecorder.h"
|
||||
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include "qmediaobject_p.h"
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaserviceprovider.h>
|
||||
#include <qmetadatawritercontrol.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qvideoencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qcamera.h>
|
||||
#include <qcameracontrol.h>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qmetaobject.h>
|
||||
|
||||
#include <qaudioformat.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMediaRecorder
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
|
||||
\brief The QMediaRecorder class is used for the recording of media content.
|
||||
|
||||
The QMediaRecorder class is a high level media recording class. It's not
|
||||
intended to be used alone but for accessing the media recording functions
|
||||
of other media objects, like QRadioTuner, or QAudioCaptureSource.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Media recorder
|
||||
|
||||
\sa QAudioCaptureSource
|
||||
*/
|
||||
|
||||
namespace
|
||||
{
|
||||
class MediaRecorderRegisterMetaTypes
|
||||
{
|
||||
public:
|
||||
MediaRecorderRegisterMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
|
||||
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
|
||||
}
|
||||
} _registerRecorderMetaTypes;
|
||||
}
|
||||
|
||||
|
||||
class QMediaRecorderPrivate
|
||||
{
|
||||
Q_DECLARE_NON_CONST_PUBLIC(QMediaRecorder)
|
||||
|
||||
public:
|
||||
QMediaRecorderPrivate();
|
||||
|
||||
QMediaObject *mediaObject;
|
||||
|
||||
QMediaRecorderControl *control;
|
||||
QMediaContainerControl *formatControl;
|
||||
QAudioEncoderControl *audioControl;
|
||||
QVideoEncoderControl *videoControl;
|
||||
QMetaDataWriterControl *metaDataControl;
|
||||
|
||||
QTimer* notifyTimer;
|
||||
|
||||
QMediaRecorder::State state;
|
||||
QMediaRecorder::Error error;
|
||||
QString errorString;
|
||||
|
||||
void _q_stateChanged(QMediaRecorder::State state);
|
||||
void _q_error(int error, const QString &errorString);
|
||||
void _q_serviceDestroyed();
|
||||
void _q_notify();
|
||||
void _q_updateNotifyInterval(int ms);
|
||||
|
||||
QMediaRecorder *q_ptr;
|
||||
};
|
||||
|
||||
QMediaRecorderPrivate::QMediaRecorderPrivate():
|
||||
mediaObject(0),
|
||||
control(0),
|
||||
formatControl(0),
|
||||
audioControl(0),
|
||||
videoControl(0),
|
||||
metaDataControl(0),
|
||||
notifyTimer(0),
|
||||
state(QMediaRecorder::StoppedState),
|
||||
error(QMediaRecorder::NoError)
|
||||
{
|
||||
}
|
||||
|
||||
#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v)))
|
||||
|
||||
void QMediaRecorderPrivate::_q_stateChanged(QMediaRecorder::State ps)
|
||||
{
|
||||
Q_Q(QMediaRecorder);
|
||||
|
||||
if (ps == QMediaRecorder::RecordingState)
|
||||
notifyTimer->start();
|
||||
else
|
||||
notifyTimer->stop();
|
||||
|
||||
// qDebug() << "Recorder state changed:" << ENUM_NAME(QMediaRecorder,"State",ps);
|
||||
if (state != ps) {
|
||||
emit q->stateChanged(ps);
|
||||
}
|
||||
|
||||
state = ps;
|
||||
}
|
||||
|
||||
|
||||
void QMediaRecorderPrivate::_q_error(int error, const QString &errorString)
|
||||
{
|
||||
Q_Q(QMediaRecorder);
|
||||
|
||||
this->error = QMediaRecorder::Error(error);
|
||||
this->errorString = errorString;
|
||||
|
||||
emit q->error(this->error);
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_serviceDestroyed()
|
||||
{
|
||||
mediaObject = 0;
|
||||
control = 0;
|
||||
formatControl = 0;
|
||||
audioControl = 0;
|
||||
videoControl = 0;
|
||||
metaDataControl = 0;
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_notify()
|
||||
{
|
||||
emit q_func()->durationChanged(q_func()->duration());
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_updateNotifyInterval(int ms)
|
||||
{
|
||||
notifyTimer->setInterval(ms);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a media recorder which records the media produced by \a mediaObject.
|
||||
|
||||
The \a parent is passed to QMediaObject.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaRecorder::QMediaRecorder(QMediaObject *mediaObject, QObject *parent):
|
||||
QObject(parent),
|
||||
d_ptr(new QMediaRecorderPrivate)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
d->q_ptr = this;
|
||||
setMediaObject(mediaObject);
|
||||
|
||||
d->notifyTimer = new QTimer(this);
|
||||
d->notifyTimer->setInterval(mediaObject->notifyInterval());
|
||||
connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify()));
|
||||
connect(mediaObject, SIGNAL(notifyIntervalChanged(int)), SLOT(_q_updateNotifyInterval(int)));
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media recorder object.
|
||||
*/
|
||||
|
||||
QMediaRecorder::~QMediaRecorder()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the QMediaObject instance that this QMediaRecorder is bound too,
|
||||
or 0 otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaObject *QMediaRecorder::mediaObject() const
|
||||
{
|
||||
return d_func()->mediaObject;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
if (object == d->mediaObject)
|
||||
return true;
|
||||
|
||||
if (d->mediaObject) {
|
||||
if (d->control) {
|
||||
disconnect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)),
|
||||
this, SLOT(_q_stateChanged(QMediaRecorder::State)));
|
||||
|
||||
disconnect(d->control, SIGNAL(mutedChanged(bool)),
|
||||
this, SIGNAL(mutedChanged(bool)));
|
||||
|
||||
disconnect(d->control, SIGNAL(durationChanged(qint64)),
|
||||
this, SIGNAL(durationChanged(qint64)));
|
||||
|
||||
disconnect(d->control, SIGNAL(error(int,QString)),
|
||||
this, SLOT(_q_error(int,QString)));
|
||||
}
|
||||
|
||||
QMediaService *service = d->mediaObject->service();
|
||||
|
||||
if (service) {
|
||||
disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
|
||||
|
||||
if (d->control)
|
||||
service->releaseControl(d->control);
|
||||
if (d->formatControl)
|
||||
service->releaseControl(d->formatControl);
|
||||
if (d->audioControl)
|
||||
service->releaseControl(d->audioControl);
|
||||
if (d->videoControl)
|
||||
service->releaseControl(d->videoControl);
|
||||
if (d->metaDataControl) {
|
||||
disconnect(d->metaDataControl, SIGNAL(metaDataChanged()),
|
||||
this, SIGNAL(metaDataChanged()));
|
||||
disconnect(d->metaDataControl, SIGNAL(metaDataAvailableChanged(bool)),
|
||||
this, SIGNAL(metaDataAvailableChanged(bool)));
|
||||
disconnect(d->metaDataControl, SIGNAL(writableChanged(bool)),
|
||||
this, SIGNAL(metaDataWritableChanged(bool)));
|
||||
|
||||
service->releaseControl(d->metaDataControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d->control = 0;
|
||||
d->formatControl = 0;
|
||||
d->audioControl = 0;
|
||||
d->videoControl = 0;
|
||||
d->metaDataControl = 0;
|
||||
|
||||
d->mediaObject = object;
|
||||
|
||||
if (d->mediaObject) {
|
||||
QMediaService *service = d->mediaObject->service();
|
||||
|
||||
if (service) {
|
||||
d->control = qobject_cast<QMediaRecorderControl*>(service->requestControl(QMediaRecorderControl_iid));
|
||||
|
||||
if (d->control) {
|
||||
d->formatControl = qobject_cast<QMediaContainerControl *>(service->requestControl(QMediaContainerControl_iid));
|
||||
d->audioControl = qobject_cast<QAudioEncoderControl *>(service->requestControl(QAudioEncoderControl_iid));
|
||||
d->videoControl = qobject_cast<QVideoEncoderControl *>(service->requestControl(QVideoEncoderControl_iid));
|
||||
|
||||
QMediaControl *control = service->requestControl(QMetaDataWriterControl_iid);
|
||||
if (control) {
|
||||
d->metaDataControl = qobject_cast<QMetaDataWriterControl *>(control);
|
||||
if (!d->metaDataControl) {
|
||||
service->releaseControl(control);
|
||||
} else {
|
||||
connect(d->metaDataControl,
|
||||
SIGNAL(metaDataChanged()),
|
||||
SIGNAL(metaDataChanged()));
|
||||
connect(d->metaDataControl,
|
||||
SIGNAL(metaDataAvailableChanged(bool)),
|
||||
SIGNAL(metaDataAvailableChanged(bool)));
|
||||
connect(d->metaDataControl,
|
||||
SIGNAL(writableChanged(bool)),
|
||||
SIGNAL(metaDataWritableChanged(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
connect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)),
|
||||
this, SLOT(_q_stateChanged(QMediaRecorder::State)));
|
||||
|
||||
connect(d->control, SIGNAL(mutedChanged(bool)),
|
||||
this, SIGNAL(mutedChanged(bool)));
|
||||
|
||||
connect(d->control, SIGNAL(durationChanged(qint64)),
|
||||
this, SIGNAL(durationChanged(qint64)));
|
||||
|
||||
connect(d->control, SIGNAL(error(int,QString)),
|
||||
this, SLOT(_q_error(int,QString)));
|
||||
|
||||
connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
d->mediaObject = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::outputLocation
|
||||
\brief the destination location of media content.
|
||||
|
||||
Setting the location can fail, for example when the service supports only
|
||||
local file system locations but a network URL was passed. If the service
|
||||
does not support media recording this setting the output location will
|
||||
always fail.
|
||||
|
||||
The \a location can be relative or empty;
|
||||
in this case the recorder uses the system specific place and file naming scheme.
|
||||
After recording has stated, QMediaRecorder::outputLocation() returns the actual output location.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns true if media recorder service ready to use.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaRecorder::isAvailable() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the availability error code.
|
||||
\since 1.0
|
||||
*/
|
||||
QtMultimedia::AvailabilityError QMediaRecorder::availabilityError() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return QtMultimedia::NoError;
|
||||
else
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
}
|
||||
|
||||
QUrl QMediaRecorder::outputLocation() const
|
||||
{
|
||||
return d_func()->control ? d_func()->control->outputLocation() : QUrl();
|
||||
}
|
||||
|
||||
bool QMediaRecorder::setOutputLocation(const QUrl &location)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
return d->control ? d->control->setOutputLocation(location) : false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current media recorder state.
|
||||
|
||||
\since 1.0
|
||||
\sa QMediaRecorder::State
|
||||
*/
|
||||
|
||||
QMediaRecorder::State QMediaRecorder::state() const
|
||||
{
|
||||
return d_func()->control ? QMediaRecorder::State(d_func()->control->state()) : StoppedState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current error state.
|
||||
|
||||
\since 1.0
|
||||
\sa errorString()
|
||||
*/
|
||||
|
||||
QMediaRecorder::Error QMediaRecorder::error() const
|
||||
{
|
||||
return d_func()->error;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a string describing the current error state.
|
||||
|
||||
\since 1.0
|
||||
\sa error()
|
||||
*/
|
||||
|
||||
QString QMediaRecorder::errorString() const
|
||||
{
|
||||
return d_func()->errorString;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::duration
|
||||
|
||||
\brief the recorded media duration in milliseconds.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
qint64 QMediaRecorder::duration() const
|
||||
{
|
||||
return d_func()->control ? d_func()->control->duration() : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::muted
|
||||
|
||||
\brief whether a recording audio stream is muted.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaRecorder::isMuted() const
|
||||
{
|
||||
return d_func()->control ? d_func()->control->isMuted() : 0;
|
||||
}
|
||||
|
||||
void QMediaRecorder::setMuted(bool muted)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
if (d->control)
|
||||
d->control->setMuted(muted);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of MIME types of supported container formats.
|
||||
\since 1.0
|
||||
*/
|
||||
QStringList QMediaRecorder::supportedContainers() const
|
||||
{
|
||||
return d_func()->formatControl ?
|
||||
d_func()->formatControl->supportedContainers() : QStringList();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a description of a container format \a mimeType.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaRecorder::containerDescription(const QString &mimeType) const
|
||||
{
|
||||
return d_func()->formatControl ?
|
||||
d_func()->formatControl->containerDescription(mimeType) : QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the MIME type of the selected container format.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QString QMediaRecorder::containerMimeType() const
|
||||
{
|
||||
return d_func()->formatControl ?
|
||||
d_func()->formatControl->containerMimeType() : QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of supported audio codecs.
|
||||
\since 1.0
|
||||
*/
|
||||
QStringList QMediaRecorder::supportedAudioCodecs() const
|
||||
{
|
||||
return d_func()->audioControl ?
|
||||
d_func()->audioControl->supportedAudioCodecs() : QStringList();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a description of an audio \a codec.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaRecorder::audioCodecDescription(const QString &codec) const
|
||||
{
|
||||
return d_func()->audioControl ?
|
||||
d_func()->audioControl->codecDescription(codec) : QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of supported audio sample rates.
|
||||
|
||||
If non null audio \a settings parameter is passed, the returned list is
|
||||
reduced to sample rates supported with partial settings applied.
|
||||
|
||||
This can be used to query the list of sample rates, supported by specific
|
||||
audio codec.
|
||||
|
||||
If the encoder supports arbitrary sample rates within the supported rates
|
||||
range, *\a continuous is set to true, otherwise *\a continuous is set to
|
||||
false.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QList<int> QMediaRecorder::supportedAudioSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return d_func()->audioControl ?
|
||||
d_func()->audioControl->supportedSampleRates(settings, continuous) : QList<int>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of resolutions video can be encoded at.
|
||||
|
||||
If non null video \a settings parameter is passed, the returned list is
|
||||
reduced to resolution supported with partial settings like video codec or
|
||||
framerate applied.
|
||||
|
||||
If the encoder supports arbitrary resolutions within the supported range,
|
||||
*\a continuous is set to true, otherwise *\a continuous is set to false.
|
||||
|
||||
\since 1.0
|
||||
\sa QVideoEncoderSettings::resolution()
|
||||
*/
|
||||
QList<QSize> QMediaRecorder::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return d_func()->videoControl ?
|
||||
d_func()->videoControl->supportedResolutions(settings, continuous) : QList<QSize>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of frame rates video can be encoded at.
|
||||
|
||||
If non null video \a settings parameter is passed, the returned list is
|
||||
reduced to frame rates supported with partial settings like video codec or
|
||||
resolution applied.
|
||||
|
||||
If the encoder supports arbitrary frame rates within the supported range,
|
||||
*\a continuous is set to true, otherwise *\a continuous is set to false.
|
||||
|
||||
\since 1.0
|
||||
\sa QVideoEncoderSettings::frameRate()
|
||||
*/
|
||||
QList<qreal> QMediaRecorder::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return d_func()->videoControl ?
|
||||
d_func()->videoControl->supportedFrameRates(settings, continuous) : QList<qreal>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of supported video codecs.
|
||||
\since 1.0
|
||||
*/
|
||||
QStringList QMediaRecorder::supportedVideoCodecs() const
|
||||
{
|
||||
return d_func()->videoControl ?
|
||||
d_func()->videoControl->supportedVideoCodecs() : QStringList();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a description of a video \a codec.
|
||||
|
||||
\since 1.0
|
||||
\sa setEncodingSettings()
|
||||
*/
|
||||
QString QMediaRecorder::videoCodecDescription(const QString &codec) const
|
||||
{
|
||||
return d_func()->videoControl ?
|
||||
d_func()->videoControl->videoCodecDescription(codec) : QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio encoder settings being used.
|
||||
|
||||
\since 1.0
|
||||
\sa setEncodingSettings()
|
||||
*/
|
||||
|
||||
QAudioEncoderSettings QMediaRecorder::audioSettings() const
|
||||
{
|
||||
return d_func()->audioControl ?
|
||||
d_func()->audioControl->audioSettings() : QAudioEncoderSettings();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video encoder settings being used.
|
||||
|
||||
\since 1.0
|
||||
\sa setEncodingSettings()
|
||||
*/
|
||||
|
||||
QVideoEncoderSettings QMediaRecorder::videoSettings() const
|
||||
{
|
||||
return d_func()->videoControl ?
|
||||
d_func()->videoControl->videoSettings() : QVideoEncoderSettings();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a audio and \a video encoder settings and \a container format MIME type.
|
||||
|
||||
If some parameters are not specified, or null settings are passed, the
|
||||
encoder will choose default encoding parameters, depending on media
|
||||
source properties.
|
||||
While setEncodingSettings is optional, the backend can preload
|
||||
encoding pipeline to improve recording startup time.
|
||||
|
||||
It's only possible to change settings when the encoder is in the
|
||||
QMediaEncoder::StoppedState state.
|
||||
|
||||
\since 1.0
|
||||
\sa audioSettings(), videoSettings(), containerMimeType()
|
||||
*/
|
||||
|
||||
void QMediaRecorder::setEncodingSettings(const QAudioEncoderSettings &audio,
|
||||
const QVideoEncoderSettings &video,
|
||||
const QString &container)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
QCamera *camera = qobject_cast<QCamera*>(d->mediaObject);
|
||||
if (camera && camera->captureMode() == QCamera::CaptureVideo) {
|
||||
QMetaObject::invokeMethod(camera,
|
||||
"_q_preparePropertyChange",
|
||||
Qt::DirectConnection,
|
||||
Q_ARG(int, QCameraControl::VideoEncodingSettings));
|
||||
}
|
||||
|
||||
if (d->audioControl)
|
||||
d->audioControl->setAudioSettings(audio);
|
||||
|
||||
if (d->videoControl)
|
||||
d->videoControl->setVideoSettings(video);
|
||||
|
||||
if (d->formatControl)
|
||||
d->formatControl->setContainerMimeType(container);
|
||||
|
||||
if (d->control)
|
||||
d->control->applySettings();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Start recording.
|
||||
|
||||
This is an asynchronous call, with signal
|
||||
stateCahnged(QMediaRecorder::RecordingState) being emitted when recording
|
||||
started, otherwise the error() signal is emitted.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QMediaRecorder::record()
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
// reset error
|
||||
d->error = NoError;
|
||||
d->errorString = QString();
|
||||
|
||||
if (d->control)
|
||||
d->control->record();
|
||||
}
|
||||
|
||||
/*!
|
||||
Pause recording.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QMediaRecorder::pause()
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
if (d->control)
|
||||
d->control->pause();
|
||||
}
|
||||
|
||||
/*!
|
||||
Stop recording.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QMediaRecorder::stop()
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
if (d->control)
|
||||
d->control->stop();
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QMediaRecorder::State
|
||||
|
||||
\value StoppedState The recorder is not active.
|
||||
\value RecordingState The recorder is currently active and producing data.
|
||||
\value PausedState The recorder is paused.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QMediaRecorder::Error
|
||||
|
||||
\value NoError No Errors.
|
||||
\value ResourceError Device is not ready or not available.
|
||||
\value FormatError Current format is not supported.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::stateChanged(State state)
|
||||
|
||||
Signals that a media recorder's \a state has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::durationChanged(qint64 duration)
|
||||
|
||||
Signals that the \a duration of the recorded media has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::error(QMediaRecorder::Error error)
|
||||
|
||||
Signals that an \a error has occurred.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::mutedChanged(bool muted)
|
||||
|
||||
Signals that the \a muted state has changed. If true the recording is being muted.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::metaDataAvailable
|
||||
\brief whether access to a media object's meta-data is available.
|
||||
|
||||
If this is true there is meta-data available, otherwise there is no meta-data available.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaRecorder::isMetaDataAvailable() const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->isMetaDataAvailable()
|
||||
: false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::metaDataAvailableChanged(bool available)
|
||||
|
||||
Signals that the \a available state of a media object's meta-data has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::metaDataWritable
|
||||
\brief whether a media object's meta-data is writable.
|
||||
|
||||
If this is true the meta-data is writable, otherwise the meta-data is read-only.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaRecorder::isMetaDataWritable() const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->isWritable()
|
||||
: false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::metaDataWritableChanged(bool writable)
|
||||
|
||||
Signals that the \a writable state of a media object's meta-data has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the value associated with a meta-data \a key.
|
||||
\since 1.0
|
||||
*/
|
||||
QVariant QMediaRecorder::metaData(QtMultimedia::MetaData key) const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->metaData(key)
|
||||
: QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets a \a value for a meta-data \a key.
|
||||
|
||||
\note To ensure that meta data is set corretly, it should be set before starting the recording.
|
||||
Once the recording is stopped, any meta data set will be attached to the next recording.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaRecorder::setMetaData(QtMultimedia::MetaData key, const QVariant &value)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
if (d->metaDataControl)
|
||||
d->metaDataControl->setMetaData(key, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of keys there is meta-data available for.
|
||||
\since 1.0
|
||||
*/
|
||||
QList<QtMultimedia::MetaData> QMediaRecorder::availableMetaData() const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->availableMetaData()
|
||||
: QList<QtMultimedia::MetaData>();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::metaDataChanged()
|
||||
|
||||
Signals that a media object's meta-data has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the value associated with a meta-data \a key.
|
||||
|
||||
The naming and type of extended meta-data is not standardized, so the values and meaning
|
||||
of keys may vary between backends.
|
||||
\since 1.0
|
||||
*/
|
||||
QVariant QMediaRecorder::extendedMetaData(const QString &key) const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->extendedMetaData(key)
|
||||
: QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets a \a value for a meta-data \a key.
|
||||
|
||||
The naming and type of extended meta-data is not standardized, so the values and meaning
|
||||
of keys may vary between backends.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaRecorder::setExtendedMetaData(const QString &key, const QVariant &value)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
if (d->metaDataControl)
|
||||
d->metaDataControl->setExtendedMetaData(key, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of keys there is extended meta-data available for.
|
||||
\since 1.0
|
||||
*/
|
||||
QStringList QMediaRecorder::availableExtendedMetaData() const
|
||||
{
|
||||
Q_D(const QMediaRecorder);
|
||||
|
||||
return d->metaDataControl
|
||||
? d->metaDataControl->availableExtendedMetaData()
|
||||
: QStringList();
|
||||
}
|
||||
|
||||
#include "moc_qmediarecorder.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
197
src/multimedia/recording/qmediarecorder.h
Normal file
197
src/multimedia/recording/qmediarecorder.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Toolkit.
|
||||
**
|
||||
** $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 QMEDIARECORDER_H
|
||||
#define QMEDIARECORDER_H
|
||||
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaserviceprovider.h>
|
||||
#include <qmediaencodersettings.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
#include <qmediaenumdebug.h>
|
||||
|
||||
#include <QtCore/qpair.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QUrl;
|
||||
class QSize;
|
||||
class QAudioFormat;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMediaRecorderService;
|
||||
class QAudioEncoderSettings;
|
||||
class QVideoEncoderSettings;
|
||||
|
||||
class QMediaRecorderPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaBindableInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaBindableInterface)
|
||||
Q_ENUMS(State)
|
||||
Q_ENUMS(Error)
|
||||
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
|
||||
Q_PROPERTY(QUrl outputLocation READ outputLocation WRITE setOutputLocation)
|
||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||
Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged)
|
||||
Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged)
|
||||
public:
|
||||
|
||||
enum State
|
||||
{
|
||||
StoppedState,
|
||||
RecordingState,
|
||||
PausedState
|
||||
};
|
||||
|
||||
enum Error
|
||||
{
|
||||
NoError,
|
||||
ResourceError,
|
||||
FormatError
|
||||
};
|
||||
|
||||
QMediaRecorder(QMediaObject *mediaObject, QObject *parent = 0);
|
||||
~QMediaRecorder();
|
||||
|
||||
QMediaObject *mediaObject() const;
|
||||
|
||||
bool isAvailable() const;
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl &location);
|
||||
|
||||
State state() const;
|
||||
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
qint64 duration() const;
|
||||
|
||||
bool isMuted() const;
|
||||
|
||||
QStringList supportedContainers() const;
|
||||
QString containerDescription(const QString &containerMimeType) const;
|
||||
|
||||
QStringList supportedAudioCodecs() const;
|
||||
QString audioCodecDescription(const QString &codecName) const;
|
||||
|
||||
QList<int> supportedAudioSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(),
|
||||
bool *continuous = 0) const;
|
||||
|
||||
QStringList supportedVideoCodecs() const;
|
||||
QString videoCodecDescription(const QString &codecName) const;
|
||||
|
||||
QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(),
|
||||
bool *continuous = 0) const;
|
||||
|
||||
QList<qreal> supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(),
|
||||
bool *continuous = 0) const;
|
||||
|
||||
QAudioEncoderSettings audioSettings() const;
|
||||
QVideoEncoderSettings videoSettings() const;
|
||||
QString containerMimeType() const;
|
||||
|
||||
void setEncodingSettings(const QAudioEncoderSettings &audioSettings,
|
||||
const QVideoEncoderSettings &videoSettings = QVideoEncoderSettings(),
|
||||
const QString &containerMimeType = QString());
|
||||
|
||||
|
||||
bool isMetaDataAvailable() const;
|
||||
bool isMetaDataWritable() const;
|
||||
|
||||
QVariant metaData(QtMultimedia::MetaData key) const;
|
||||
void setMetaData(QtMultimedia::MetaData key, const QVariant &value);
|
||||
QList<QtMultimedia::MetaData> availableMetaData() const;
|
||||
|
||||
QVariant extendedMetaData(const QString &key) const;
|
||||
void setExtendedMetaData(const QString &key, const QVariant &value);
|
||||
QStringList availableExtendedMetaData() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void record();
|
||||
void pause();
|
||||
void stop();
|
||||
void setMuted(bool muted);
|
||||
|
||||
Q_SIGNALS:
|
||||
void stateChanged(QMediaRecorder::State state);
|
||||
void durationChanged(qint64 duration);
|
||||
void mutedChanged(bool muted);
|
||||
|
||||
void error(QMediaRecorder::Error error);
|
||||
|
||||
void metaDataAvailableChanged(bool available);
|
||||
void metaDataWritableChanged(bool writable);
|
||||
void metaDataChanged();
|
||||
|
||||
protected:
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
|
||||
private:
|
||||
QMediaRecorderPrivate *d_ptr;
|
||||
Q_DISABLE_COPY(QMediaRecorder)
|
||||
Q_DECLARE_PRIVATE(QMediaRecorder)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaRecorder::State))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_notify())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateNotifyInterval(int))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QMediaRecorder::State)
|
||||
Q_DECLARE_METATYPE(QMediaRecorder::Error)
|
||||
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaRecorder, State)
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaRecorder, Error)
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMEDIARECORDER_H
|
||||
11
src/multimedia/recording/recording.pri
Normal file
11
src/multimedia/recording/recording.pri
Normal file
@@ -0,0 +1,11 @@
|
||||
INCLUDEPATH += recording
|
||||
|
||||
PUBLIC_HEADERS += \
|
||||
recording/qaudiocapturesource.h \
|
||||
recording/qmediaencodersettings.h \
|
||||
recording/qmediarecorder.h \
|
||||
|
||||
SOURCES += \
|
||||
recording/qaudiocapturesource.cpp \
|
||||
recording/qmediaencodersettings.cpp \
|
||||
recording/qmediarecorder.cpp
|
||||
Reference in New Issue
Block a user