diff options
Diffstat (limited to 'src/multimedia/recording')
-rw-r--r-- | src/multimedia/recording/qmediarecorder.cpp | 74 | ||||
-rw-r--r-- | src/multimedia/recording/qmediarecorder.h | 18 |
2 files changed, 88 insertions, 4 deletions
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp index 78d518b7b..82f5133a0 100644 --- a/src/multimedia/recording/qmediarecorder.cpp +++ b/src/multimedia/recording/qmediarecorder.cpp @@ -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))); @@ -483,6 +490,17 @@ QMediaRecorder::State QMediaRecorder::state() const } /*! + 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. \sa errorString() @@ -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,11 +877,32 @@ 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 \value NoError No Errors. @@ -862,6 +911,23 @@ void QMediaRecorder::stop() */ /*! + \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) Signals that a media recorder's \a state has changed. diff --git a/src/multimedia/recording/qmediarecorder.h b/src/multimedia/recording/qmediarecorder.h index 84a6eca63..882334c80 100644 --- a/src/multimedia/recording/qmediarecorder.h +++ b/src/multimedia/recording/qmediarecorder.h @@ -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 |