summaryrefslogtreecommitdiffstats
path: root/src/multimedia/recording/qmediarecorder.cpp
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2012-03-02 00:21:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-02 09:30:34 +0100
commit2a8463711c7fd683ddf46f716bfff47c1603e863 (patch)
tree88a504ca27afe1891cce66f678cee5be9cba7993 /src/multimedia/recording/qmediarecorder.cpp
parentd1b6bf5fac54a39d911079ba792ca95424c5c70c (diff)
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>
Diffstat (limited to 'src/multimedia/recording/qmediarecorder.cpp')
-rw-r--r--src/multimedia/recording/qmediarecorder.cpp60
1 files changed, 52 insertions, 8 deletions
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp
index d1f3bdd1a..d57ca0b3e 100644
--- a/src/multimedia/recording/qmediarecorder.cpp
+++ b/src/multimedia/recording/qmediarecorder.cpp
@@ -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.
*/
@@ -852,6 +884,18 @@ void QMediaRecorder::stop()
*/
/*!
+ \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)
Signals that the \a muted state has changed. If true the recording is being muted.