Added QMediaRecorder::status property

QMediaRecorder::state property represents the user request and
changed synchronously during record(), pause() or stop() calls.

Recorder status is changed asynchronously
and represents the actual status of media recorder.

This also makes API more consistent with QMediaPlayer and QCamera.

Change-Id: I80b4aaa70bb88e555c492908da8c29d0fc5ed5ea
Reviewed-by: Ling Hu <ling.hu@nokia.com>
This commit is contained in:
Dmytro Poplavskiy
2012-05-01 13:10:33 +10:00
committed by Qt by Nokia
parent af932e8653
commit b7935a84d7
12 changed files with 324 additions and 37 deletions

View File

@@ -117,11 +117,17 @@ QMediaRecorderControl::~QMediaRecorderControl()
*/
/*!
\fn int QMediaRecorderControl::state() const
\fn QMediaRecorder::State QMediaRecorderControl::state() const
Return the current recording state.
*/
/*!
\fn QMediaRecorder::Status QMediaRecorderControl::status() const
Return the current recording status.
*/
/*!
\fn qint64 QMediaRecorderControl::duration() const
@@ -172,6 +178,13 @@ QMediaRecorderControl::~QMediaRecorderControl()
Signals that the \a state of a media recorder has changed.
*/
/*!
\fn void QMediaRecorderControl::statusChanged(QMediaRecorder::Status status)
Signals that the \a status of a media recorder has changed.
*/
/*!
\fn void QMediaRecorderControl::durationChanged(qint64 duration)

View File

@@ -67,6 +67,7 @@ public:
virtual bool setOutputLocation(const QUrl &location) = 0;
virtual QMediaRecorder::State state() const = 0;
virtual QMediaRecorder::Status status() const = 0;
virtual qint64 duration() const = 0;
@@ -76,6 +77,7 @@ public:
Q_SIGNALS:
void stateChanged(QMediaRecorder::State state);
void statusChanged(QMediaRecorder::Status status);
void durationChanged(qint64 position);
void mutedChanged(bool muted);
void actualLocationChanged(const QUrl &location);

View File

@@ -88,6 +88,7 @@ public:
MediaRecorderRegisterMetaTypes()
{
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::Status");
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
}
} _registerRecorderMetaTypes;
@@ -278,6 +279,9 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
disconnect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)),
this, SLOT(_q_stateChanged(QMediaRecorder::State)));
disconnect(d->control, SIGNAL(statusChanged(QMediaRecorder::Status)),
this, SIGNAL(statusChanged(QMediaRecorder::Status)));
disconnect(d->control, SIGNAL(mutedChanged(bool)),
this, SIGNAL(mutedChanged(bool)));
@@ -378,6 +382,9 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
connect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)),
this, SLOT(_q_stateChanged(QMediaRecorder::State)));
connect(d->control, SIGNAL(statusChanged(QMediaRecorder::Status)),
this, SIGNAL(statusChanged(QMediaRecorder::Status)));
connect(d->control, SIGNAL(mutedChanged(bool)),
this, SIGNAL(mutedChanged(bool)));
@@ -482,6 +489,17 @@ QMediaRecorder::State QMediaRecorder::state() const
return d_func()->control ? QMediaRecorder::State(d_func()->control->state()) : StoppedState;
}
/*!
Returns the current media recorder status.
\sa QMediaRecorder::Status
*/
QMediaRecorder::Status QMediaRecorder::status() const
{
return d_func()->control ? QMediaRecorder::Status(d_func()->control->status()) : UnavailableStatus;
}
/*!
Returns the current error state.
@@ -801,9 +819,12 @@ void QMediaRecorder::setEncodingSettings(const QAudioEncoderSettings &audio,
/*!
Start recording.
This is an asynchronous call, with signal
stateChanged(QMediaRecorder::RecordingState) being emitted when recording
started, otherwise the error() signal is emitted.
While the recorder state is changed immediately to QMediaRecorder::RecordingState,
recording may start asynchronously, with statusChanged(QMediaRecorder::RecordingStatus)
signal emitted when recording starts.
If recording fails error() signal is emitted
with recorder state being reset back to QMediaRecorder::StoppedState.
*/
void QMediaRecorder::record()
@@ -825,6 +846,11 @@ void QMediaRecorder::record()
/*!
Pause recording.
The recorder state is changed to QMediaRecorder::PausedState.
Depending on platform recording pause may be not supported,
in this case the recorder state stays unchanged.
*/
void QMediaRecorder::pause()
@@ -836,6 +862,8 @@ void QMediaRecorder::pause()
/*!
Stop recording.
The recorder state is changed to QMediaRecorder::StoppedState.
*/
void QMediaRecorder::stop()
@@ -849,10 +877,31 @@ void QMediaRecorder::stop()
\enum QMediaRecorder::State
\value StoppedState The recorder is not active.
\value RecordingState The recorder is currently active and producing data.
\value RecordingState The recording is requested.
\value PausedState The recorder is paused.
*/
/*!
\enum QMediaRecorder::Status
\value UnavailableStatus
The recorder is not available or not supported by connected media object.
\value UnloadedStatus
The recorder is avilable but not loaded.
\value LoadingStatus
The recorder is initializing.
\value LoadedStatus
The recorder is initialized and ready to record media.
\value StartingStatus
Recording is requested but not active yet.
\value RecordingStatus
Recording is active.
\value PausedStatus
Recording is paused.
\value FinalizingStatus
Recording is stopped with media being finalized.
*/
/*!
\enum QMediaRecorder::Error
@@ -861,6 +910,23 @@ void QMediaRecorder::stop()
\value FormatError Current format is not supported.
*/
/*!
\property QMediaRecorder::state
\brief The current state of the media recorder.
The state property represents the user request and is changed synchronously
during record(), pause() or stop() calls.
Recorder state may also change asynchronously when recording fails.
*/
/*!
\property QMediaRecorder::status
\brief The current status of the media recorder.
The status is changed asynchronously and represents the actual status
of media recorder.
*/
/*!
\fn QMediaRecorder::stateChanged(State state)

View File

@@ -73,7 +73,10 @@ class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaBindable
Q_OBJECT
Q_INTERFACES(QMediaBindableInterface)
Q_ENUMS(State)
Q_ENUMS(Status)
Q_ENUMS(Error)
Q_PROPERTY(QMediaRecorder::State state READ state NOTIFY stateChanged)
Q_PROPERTY(QMediaRecorder::Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
Q_PROPERTY(QUrl outputLocation READ outputLocation WRITE setOutputLocation)
Q_PROPERTY(QUrl actualLocation READ actualLocation NOTIFY actualLocationChanged)
@@ -89,6 +92,17 @@ public:
PausedState
};
enum Status {
UnavailableStatus,
UnloadedStatus,
LoadingStatus,
LoadedStatus,
StartingStatus,
RecordingStatus,
PausedStatus,
FinalizingStatus
};
enum Error
{
NoError,
@@ -110,6 +124,7 @@ public:
QUrl actualLocation() const;
State state() const;
Status status() const;
Error error() const;
QString errorString() const;
@@ -163,6 +178,7 @@ public Q_SLOTS:
Q_SIGNALS:
void stateChanged(QMediaRecorder::State state);
void statusChanged(QMediaRecorder::Status status);
void durationChanged(qint64 duration);
void mutedChanged(bool muted);
void actualLocationChanged(const QUrl &location);
@@ -198,9 +214,11 @@ private:
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QMediaRecorder::State)
Q_DECLARE_METATYPE(QMediaRecorder::Status)
Q_DECLARE_METATYPE(QMediaRecorder::Error)
Q_MEDIA_ENUM_DEBUG(QMediaRecorder, State)
Q_MEDIA_ENUM_DEBUG(QMediaRecorder, Status)
Q_MEDIA_ENUM_DEBUG(QMediaRecorder, Error)
QT_END_HEADER