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
@@ -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