Expose availability from the backend to C++ and QML.
The availabilityError property was static based on the service, but it can change at run time, so add the plumbing to allow the backend to report it itself. Also make sure that both QML and C++ expose the availability. The radio tuner and data controls previously had properties (but no signals) for availability - these have been removed. Change-Id: I9240cf93e2a51b14cd38642f9312ae3c75f05361 Reviewed-by: Ling Hu <ling.hu@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
d1b6bf5fac
commit
2a8463711c
@@ -409,19 +409,9 @@ QCamera::~QCamera()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Return true if the camera service is ready to use.
|
||||
Returns the availability state of the camera service.
|
||||
*/
|
||||
bool QCamera::isAvailable() const
|
||||
{
|
||||
return availabilityError() == QtMultimedia::NoError;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the error state of the camera service.
|
||||
*/
|
||||
|
||||
QtMultimedia::AvailabilityError QCamera::availabilityError() const
|
||||
{
|
||||
Q_D(const QCamera);
|
||||
@@ -434,7 +424,7 @@ QtMultimedia::AvailabilityError QCamera::availabilityError() const
|
||||
if (d->error != QCamera::NoError)
|
||||
return QtMultimedia::ResourceError;
|
||||
|
||||
return QtMultimedia::NoError;
|
||||
return QMediaObject::availabilityError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ public:
|
||||
static QList<QByteArray> availableDevices();
|
||||
static QString deviceDescription(const QByteArray &device);
|
||||
|
||||
bool isAvailable() const;
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
State state() const;
|
||||
|
||||
@@ -33,7 +33,8 @@ PUBLIC_HEADERS += \
|
||||
controls/qvideoencodercontrol.h \
|
||||
controls/qvideorenderercontrol.h \
|
||||
controls/qmediaaudioprobecontrol.h \
|
||||
controls/qmediavideoprobecontrol.h
|
||||
controls/qmediavideoprobecontrol.h \
|
||||
controls/qmediaavailabilitycontrol.h
|
||||
|
||||
PRIVATE_HEADERS += \
|
||||
controls/qaudiodecodercontrol_p.h
|
||||
@@ -71,4 +72,7 @@ SOURCES += \
|
||||
controls/qvideorenderercontrol.cpp \
|
||||
controls/qmediaaudioprobecontrol.cpp \
|
||||
controls/qmediavideoprobecontrol.cpp \
|
||||
controls/qaudiodecodercontrol_p.cpp
|
||||
controls/qaudiodecodercontrol_p.cpp \
|
||||
controls/qmediaavailabilitycontrol.cpp
|
||||
|
||||
|
||||
|
||||
109
src/multimedia/controls/qmediaavailabilitycontrol.cpp
Normal file
109
src/multimedia/controls/qmediaavailabilitycontrol.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** 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 "qmediaavailabilitycontrol.h"
|
||||
#include "qmediacontrol_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMediaAvailabilityControl
|
||||
|
||||
\brief The QMediaAvailabilityControl class supplies a control for reporting availability of a service.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
|
||||
\ingroup multimedia
|
||||
\ingroup multimedia_control
|
||||
|
||||
An instance of QMediaObject (or its derived classes) can report any changes
|
||||
in availability via this control.
|
||||
|
||||
The interface name of QMediaAvailabilityControl is \c com.nokia.Qt.QMediaAvailabilityControl/1.0 as
|
||||
defined in QMediaAvailabilityControl_iid.
|
||||
|
||||
\sa QMediaService::requestControl(), QMediaObject
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QMediaAvailabilityControl_iid
|
||||
|
||||
\c com.nokia.Qt.QMediaAvailabilityControl/1.0
|
||||
|
||||
Defines the interface name of the QMediaAvailabilityControl class.
|
||||
|
||||
\relates QMediaAvailabilityControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an availability control object with \a parent.
|
||||
*/
|
||||
QMediaAvailabilityControl::QMediaAvailabilityControl(QObject *parent)
|
||||
: QMediaControl(*new QMediaControlPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destruct the availability control object.
|
||||
*/
|
||||
QMediaAvailabilityControl::~QMediaAvailabilityControl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn QtMultimedia::AvailabilityError QMediaAvailabilityControl::availability() const
|
||||
|
||||
Returns the current availability of this instance of the media service.
|
||||
If the availability changes at run time (for example, some other media
|
||||
client takes all media resources) the availabilityChanges() signal
|
||||
should be emitted.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QMediaAvailabilityControl::availabilityChanged(QtMultimedia::AvailabilityError availability)
|
||||
|
||||
Signal emitted when the current \a availability value changed.
|
||||
*/
|
||||
|
||||
#include "moc_qmediaavailabilitycontrol.cpp"
|
||||
QT_END_NAMESPACE
|
||||
78
src/multimedia/controls/qmediaavailabilitycontrol.h
Normal file
78
src/multimedia/controls/qmediaavailabilitycontrol.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** 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 QMEDIAAVAILABILITYCONTROL_H
|
||||
#define QMEDIAAVAILABILITYCONTROL_H
|
||||
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaobject.h>
|
||||
#include <qtmedianamespace.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QMediaAvailabilityControl : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~QMediaAvailabilityControl();
|
||||
|
||||
virtual QtMultimedia::AvailabilityError availability() const = 0;
|
||||
|
||||
signals:
|
||||
void availabilityChanged(QtMultimedia::AvailabilityError availability);
|
||||
|
||||
protected:
|
||||
QMediaAvailabilityControl(QObject* parent = 0);
|
||||
};
|
||||
|
||||
#define QMediaAvailabilityControl_iid "com.nokia.Qt.QMediaAvailabilityControl/1.0"
|
||||
Q_MEDIA_DECLARE_CONTROL(QMediaAvailabilityControl, QMediaAvailabilityControl_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMEDIAAVAILABILITYCONTROL_H
|
||||
@@ -93,18 +93,6 @@ QRadioDataControl::~QRadioDataControl()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QRadioDataControl::isAvailable() const
|
||||
|
||||
Returns true if the radio service is ready to use.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QtMultimedia::AvailabilityError QRadioDataControl::availabilityError() const
|
||||
|
||||
Returns the error state of the radio service.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRadioData::Error QRadioDataControl::error() const
|
||||
|
||||
|
||||
@@ -59,9 +59,6 @@ class Q_MULTIMEDIA_EXPORT QRadioDataControl : public QMediaControl
|
||||
public:
|
||||
~QRadioDataControl();
|
||||
|
||||
virtual bool isAvailable() const = 0;
|
||||
virtual QtMultimedia::AvailabilityError availabilityError() const = 0;
|
||||
|
||||
virtual QString stationId() const = 0;
|
||||
virtual QRadioData::ProgramType programType() const = 0;
|
||||
virtual QString programTypeName() const = 0;
|
||||
|
||||
@@ -99,18 +99,6 @@ QRadioTunerControl::~QRadioTunerControl()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QRadioTunerControl::isAvailable() const
|
||||
|
||||
Returns true if the radio service is ready to use.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QtMultimedia::AvailabilityError QRadioTunerControl::availabilityError() const
|
||||
|
||||
Returns the error state of the radio service.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRadioTuner::State QRadioTunerControl::state() const
|
||||
|
||||
@@ -235,7 +223,7 @@ QRadioTunerControl::~QRadioTunerControl()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QRadioTunerControl::antennaConnected() const
|
||||
\fn bool QRadioTunerControl::isAntennaConnected() const
|
||||
|
||||
Identifies if there is an antenna connected to the device.
|
||||
|
||||
|
||||
@@ -59,9 +59,6 @@ class Q_MULTIMEDIA_EXPORT QRadioTunerControl : public QMediaControl
|
||||
public:
|
||||
~QRadioTunerControl();
|
||||
|
||||
virtual bool isAvailable() const = 0;
|
||||
virtual QtMultimedia::AvailabilityError availabilityError() const = 0;
|
||||
|
||||
virtual QRadioTuner::State state() const = 0;
|
||||
|
||||
virtual QRadioTuner::Band band() const = 0;
|
||||
|
||||
@@ -778,6 +778,17 @@ void QMediaPlayer::setVideoOutput(QAbstractVideoSurface *surface)
|
||||
}
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QtMultimedia::AvailabilityError QMediaPlayer::availabilityError() const
|
||||
{
|
||||
Q_D(const QMediaPlayer);
|
||||
|
||||
if (!d->control)
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
|
||||
return QMediaObject::availabilityError();
|
||||
}
|
||||
|
||||
// Enums
|
||||
/*!
|
||||
\enum QMediaPlayer::State
|
||||
|
||||
@@ -158,6 +158,8 @@ public:
|
||||
|
||||
QNetworkConfiguration currentNetworkConfiguration() const;
|
||||
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void play();
|
||||
void pause();
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <qmediaservice.h>
|
||||
#include <qmetadatareadercontrol.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
|
||||
#include <qmediaavailabilitycontrol.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -64,6 +64,17 @@ void QMediaObjectPrivate::_q_notify()
|
||||
}
|
||||
}
|
||||
|
||||
void QMediaObjectPrivate::_q_availabilityChanged()
|
||||
{
|
||||
Q_Q(QMediaObject);
|
||||
|
||||
// Really this should not always emit, but
|
||||
// we can't really tell from here (isAvailable
|
||||
// may not have changed, or the mediaobject's overridden
|
||||
// availabilityError() may not have changed).
|
||||
q->availabilityErrorChanged(q->availabilityError());
|
||||
q->availabilityChanged(q->isAvailable());
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QMediaObject
|
||||
@@ -104,7 +115,13 @@ QMediaObject::~QMediaObject()
|
||||
|
||||
QtMultimedia::AvailabilityError QMediaObject::availabilityError() const
|
||||
{
|
||||
return d_func()->service == 0 ? QtMultimedia::ServiceMissingError : QtMultimedia::NoError;
|
||||
if (d_func()->service == 0)
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
|
||||
if (d_func()->availabilityControl)
|
||||
return d_func()->availabilityControl->availability();
|
||||
|
||||
return QtMultimedia::NoError;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -113,7 +130,7 @@ QtMultimedia::AvailabilityError QMediaObject::availabilityError() const
|
||||
|
||||
bool QMediaObject::isAvailable() const
|
||||
{
|
||||
return d_func()->service != 0;
|
||||
return availabilityError() == QtMultimedia::NoError;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -216,7 +233,7 @@ QMediaObject::QMediaObject(QObject *parent, QMediaService *service):
|
||||
|
||||
d->service = service;
|
||||
|
||||
setupMetaData();
|
||||
setupControls();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -237,7 +254,7 @@ QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent,
|
||||
|
||||
d->service = service;
|
||||
|
||||
setupMetaData();
|
||||
setupControls();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -360,7 +377,7 @@ QStringList QMediaObject::availableMetaData() const
|
||||
*/
|
||||
|
||||
|
||||
void QMediaObject::setupMetaData()
|
||||
void QMediaObject::setupControls()
|
||||
{
|
||||
Q_D(QMediaObject);
|
||||
|
||||
@@ -377,6 +394,13 @@ void QMediaObject::setupMetaData()
|
||||
SIGNAL(metaDataAvailableChanged(bool)),
|
||||
SIGNAL(metaDataAvailableChanged(bool)));
|
||||
}
|
||||
|
||||
d->availabilityControl = d->service->requestControl<QMediaAvailabilityControl*>();
|
||||
if (d->availabilityControl) {
|
||||
connect(d->availabilityControl,
|
||||
SIGNAL(availabilityChanged(QtMultimedia::AvailabilityError)),
|
||||
SLOT(_q_availabilityChanged()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ Q_SIGNALS:
|
||||
void metaDataChanged(const QString &key, const QVariant &value);
|
||||
|
||||
void availabilityChanged(bool available);
|
||||
void availabilityErrorChanged(QtMultimedia::AvailabilityError error);
|
||||
|
||||
protected:
|
||||
QMediaObject(QObject *parent, QMediaService *service);
|
||||
@@ -101,10 +102,11 @@ protected:
|
||||
QMediaObjectPrivate *d_ptr;
|
||||
|
||||
private:
|
||||
void setupMetaData();
|
||||
void setupControls();
|
||||
|
||||
Q_DECLARE_PRIVATE(QMediaObject)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_notify())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_availabilityChanged())
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMetaDataReaderControl;
|
||||
class QMediaAvailabilityControl;
|
||||
|
||||
#define Q_DECLARE_NON_CONST_PUBLIC(Class) \
|
||||
inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
|
||||
@@ -82,9 +83,12 @@ public:
|
||||
virtual ~QMediaObjectPrivate() {}
|
||||
|
||||
void _q_notify();
|
||||
void _q_availabilityChanged();
|
||||
|
||||
QMediaService *service;
|
||||
QMetaDataReaderControl *metaDataControl;
|
||||
QMediaAvailabilityControl *availabilityControl;
|
||||
|
||||
QTimer* notifyTimer;
|
||||
QSet<int> notifyProperties;
|
||||
|
||||
|
||||
@@ -133,29 +133,16 @@ QRadioData::~QRadioData()
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the radio data service is ready to use.
|
||||
*/
|
||||
bool QRadioData::isAvailable() const
|
||||
{
|
||||
Q_D(const QRadioData);
|
||||
|
||||
if (d->control != 0)
|
||||
return d_func()->control->isAvailable();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the availability error state.
|
||||
Returns the availability of the radio data service.
|
||||
*/
|
||||
QtMultimedia::AvailabilityError QRadioData::availabilityError() const
|
||||
{
|
||||
Q_D(const QRadioData);
|
||||
|
||||
if (d->control != 0)
|
||||
return d_func()->control->availabilityError();
|
||||
else
|
||||
if (d->control == 0)
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
|
||||
return QMediaObject::availabilityError();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -90,7 +90,6 @@ public:
|
||||
QRadioData(QObject *parent = 0);
|
||||
~QRadioData();
|
||||
|
||||
bool isAvailable() const;
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
QString stationId() const;
|
||||
|
||||
@@ -149,25 +149,17 @@ QRadioTuner::~QRadioTuner()
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the radio tuner service is ready to use.
|
||||
*/
|
||||
bool QRadioTuner::isAvailable() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return d_func()->control->isAvailable();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the availability error state.
|
||||
Returns the availability of the radio tuner.
|
||||
*/
|
||||
QtMultimedia::AvailabilityError QRadioTuner::availabilityError() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return d_func()->control->availabilityError();
|
||||
else
|
||||
if (d_func()->control == 0)
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
|
||||
if (!d_func()->control->isAntennaConnected())
|
||||
return QtMultimedia::ResourceError;
|
||||
|
||||
return QMediaObject::availabilityError();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -86,7 +86,6 @@ public:
|
||||
QRadioTuner(QObject *parent = 0);
|
||||
~QRadioTuner();
|
||||
|
||||
bool isAvailable() const;
|
||||
QtMultimedia::AvailabilityError availabilityError() const;
|
||||
|
||||
State state() const;
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qvideoencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qmediaavailabilitycontrol.h>
|
||||
#include <qcamera.h>
|
||||
#include <qcameracontrol.h>
|
||||
|
||||
@@ -99,6 +100,7 @@ QMediaRecorderPrivate::QMediaRecorderPrivate():
|
||||
audioControl(0),
|
||||
videoControl(0),
|
||||
metaDataControl(0),
|
||||
availabilityControl(0),
|
||||
notifyTimer(0),
|
||||
state(QMediaRecorder::StoppedState),
|
||||
error(QMediaRecorder::NoError)
|
||||
@@ -143,6 +145,7 @@ void QMediaRecorderPrivate::_q_serviceDestroyed()
|
||||
audioControl = 0;
|
||||
videoControl = 0;
|
||||
metaDataControl = 0;
|
||||
availabilityControl = 0;
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_updateActualLocation(const QUrl &location)
|
||||
@@ -179,6 +182,19 @@ void QMediaRecorderPrivate::_q_applySettings()
|
||||
}
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_availabilityChanged(QtMultimedia::AvailabilityError error)
|
||||
{
|
||||
Q_Q(QMediaRecorder);
|
||||
Q_UNUSED(error);
|
||||
|
||||
// Really this should not always emit, but
|
||||
// we can't really tell from here (isAvailable
|
||||
// may not have changed, or the mediaobject's overridden
|
||||
// availabilityError() may not have changed).
|
||||
q->availabilityErrorChanged(q->availabilityError());
|
||||
q->availabilityChanged(q->isAvailable());
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::restartCamera()
|
||||
{
|
||||
//restart camera if it can't apply new settings in the Active state
|
||||
@@ -299,6 +315,11 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
|
||||
service->releaseControl(d->metaDataControl);
|
||||
}
|
||||
if (d->availabilityControl) {
|
||||
disconnect(d->availabilityControl, SIGNAL(availabilityChanged(QtMultimedia::AvailabilityError)),
|
||||
this, SLOT(_q_availabilityChanged(QtMultimedia::AvailabilityError)));
|
||||
service->releaseControl(d->availabilityControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +328,7 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
d->audioControl = 0;
|
||||
d->videoControl = 0;
|
||||
d->metaDataControl = 0;
|
||||
d->availabilityControl = 0;
|
||||
|
||||
d->mediaObject = object;
|
||||
|
||||
@@ -344,6 +366,12 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
}
|
||||
}
|
||||
|
||||
d->availabilityControl = service->requestControl<QMediaAvailabilityControl*>();
|
||||
if (d->availabilityControl) {
|
||||
connect(d->availabilityControl, SIGNAL(availabilityChanged(QtMultimedia::AvailabilityError)),
|
||||
this, SLOT(_q_availabilityChanged(QtMultimedia::AvailabilityError)));
|
||||
}
|
||||
|
||||
connect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)),
|
||||
this, SLOT(_q_stateChanged(QMediaRecorder::State)));
|
||||
|
||||
@@ -399,24 +427,28 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
|
||||
/*!
|
||||
Returns true if media recorder service ready to use.
|
||||
|
||||
\sa availabilityChanged()
|
||||
*/
|
||||
bool QMediaRecorder::isAvailable() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return availabilityError() == QtMultimedia::NoError;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the availability error code.
|
||||
|
||||
\sa availabilityErrorChanged()
|
||||
*/
|
||||
QtMultimedia::AvailabilityError QMediaRecorder::availabilityError() const
|
||||
{
|
||||
if (d_func()->control != NULL)
|
||||
return QtMultimedia::NoError;
|
||||
else
|
||||
if (d_func()->control == NULL)
|
||||
return QtMultimedia::ServiceMissingError;
|
||||
|
||||
if (d_func()->availabilityControl)
|
||||
return d_func()->availabilityControl->availability();
|
||||
|
||||
return QtMultimedia::NoError;
|
||||
}
|
||||
|
||||
QUrl QMediaRecorder::outputLocation() const
|
||||
@@ -767,7 +799,7 @@ void QMediaRecorder::setEncodingSettings(const QAudioEncoderSettings &audio,
|
||||
Start recording.
|
||||
|
||||
This is an asynchronous call, with signal
|
||||
stateCahnged(QMediaRecorder::RecordingState) being emitted when recording
|
||||
stateChanged(QMediaRecorder::RecordingState) being emitted when recording
|
||||
started, otherwise the error() signal is emitted.
|
||||
*/
|
||||
|
||||
@@ -851,6 +883,18 @@ void QMediaRecorder::stop()
|
||||
Signals that an \a error has occurred.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::availableChanged(bool available)
|
||||
|
||||
Signals that the media recorder is now available (if \a available is true), or not.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::availabilityErrorChanged(QtMultimedia::AvailabilityError availability)
|
||||
|
||||
Signals that the service availability has changed to \a availability.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::mutedChanged(bool muted)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#ifndef QMEDIARECORDER_H
|
||||
#define QMEDIARECORDER_H
|
||||
|
||||
#include <qtmedianamespace.h>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaencodersettings.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
@@ -173,6 +174,9 @@ Q_SIGNALS:
|
||||
void metaDataChanged();
|
||||
void metaDataChanged(const QString &key, const QVariant &value);
|
||||
|
||||
void availabilityChanged(bool available);
|
||||
void availabilityErrorChanged(QtMultimedia::AvailabilityError error);
|
||||
|
||||
protected:
|
||||
QMediaRecorder(QMediaRecorderPrivate &dd, QMediaObject *mediaObject, QObject *parent = 0);
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
@@ -188,6 +192,7 @@ private:
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateActualLocation(const QUrl &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateNotifyInterval(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_applySettings())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_availabilityChanged(QtMultimedia::AvailabilityError))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -53,6 +53,7 @@ class QMediaContainerControl;
|
||||
class QAudioEncoderControl;
|
||||
class QVideoEncoderControl;
|
||||
class QMetaDataWriterControl;
|
||||
class QMediaAvailabilityControl;
|
||||
class QTimer;
|
||||
|
||||
class QMediaRecorderPrivate
|
||||
@@ -73,6 +74,7 @@ public:
|
||||
QAudioEncoderControl *audioControl;
|
||||
QVideoEncoderControl *videoControl;
|
||||
QMetaDataWriterControl *metaDataControl;
|
||||
QMediaAvailabilityControl *availabilityControl;
|
||||
|
||||
bool settingsChanged;
|
||||
|
||||
@@ -90,6 +92,7 @@ public:
|
||||
void _q_notify();
|
||||
void _q_updateNotifyInterval(int ms);
|
||||
void _q_applySettings();
|
||||
void _q_availabilityChanged(QtMultimedia::AvailabilityError error);
|
||||
|
||||
QMediaRecorder *q_ptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user