diff options
Diffstat (limited to 'src')
7 files changed, 41 insertions, 46 deletions
diff --git a/src/multimedia/controls/qmediarecordercontrol.cpp b/src/multimedia/controls/qmediarecordercontrol.cpp index 3e56a5b89..f7a486cfb 100644 --- a/src/multimedia/controls/qmediarecordercontrol.cpp +++ b/src/multimedia/controls/qmediarecordercontrol.cpp @@ -135,21 +135,9 @@ QMediaRecorderControl::~QMediaRecorderControl() */ /*! - \fn void QMediaRecorderControl::record() + \fn void QMediaRecorderControl::setState(QMediaRecorder::State state) - Start recording. -*/ - -/*! - \fn void QMediaRecorderControl::pause() - - Pause recording. -*/ - -/*! - \fn void QMediaRecorderControl::stop() - - Stop recording. + Set the media recorder \a state. */ /*! diff --git a/src/multimedia/controls/qmediarecordercontrol.h b/src/multimedia/controls/qmediarecordercontrol.h index dccca6fe5..2783645e8 100644 --- a/src/multimedia/controls/qmediarecordercontrol.h +++ b/src/multimedia/controls/qmediarecordercontrol.h @@ -84,9 +84,7 @@ Q_SIGNALS: void error(int error, const QString &errorString); public Q_SLOTS: - virtual void record() = 0; - virtual void pause() = 0; - virtual void stop() = 0; + virtual void setState(QMediaRecorder::State state) = 0; virtual void setMuted(bool muted) = 0; protected: diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp index 82f5133a0..81b268d7e 100644 --- a/src/multimedia/recording/qmediarecorder.cpp +++ b/src/multimedia/recording/qmediarecorder.cpp @@ -841,7 +841,7 @@ void QMediaRecorder::record() d->errorString = QString(); if (d->control) - d->control->record(); + d->control->setState(RecordingState); } /*! @@ -857,7 +857,7 @@ void QMediaRecorder::pause() { Q_D(QMediaRecorder); if (d->control) - d->control->pause(); + d->control->setState(PausedState); } /*! @@ -870,7 +870,7 @@ void QMediaRecorder::stop() { Q_D(QMediaRecorder); if (d->control) - d->control->stop(); + d->control->setState(StoppedState); } /*! diff --git a/src/plugins/audiocapture/audiomediarecordercontrol.cpp b/src/plugins/audiocapture/audiomediarecordercontrol.cpp index e17157c6a..d5d094198 100644 --- a/src/plugins/audiocapture/audiomediarecordercontrol.cpp +++ b/src/plugins/audiocapture/audiomediarecordercontrol.cpp @@ -93,36 +93,31 @@ qint64 AudioMediaRecorderControl::duration() const return m_session->position(); } -void AudioMediaRecorderControl::record() +bool AudioMediaRecorderControl::isMuted() const { - if (m_state != QMediaRecorder::RecordingState) { - m_state = QMediaRecorder::RecordingState; - m_session->record(); - updateStatus(); - } + return false; } -void AudioMediaRecorderControl::pause() +void AudioMediaRecorderControl::setState(QMediaRecorder::State state) { - if (m_state != QMediaRecorder::PausedState) { - m_state = QMediaRecorder::PausedState; - m_session->pause(); - updateStatus(); - } -} + if (m_state == state) + return; -void AudioMediaRecorderControl::stop() -{ - if (m_state != QMediaRecorder::StoppedState) { - m_state = QMediaRecorder::StoppedState; + m_state = state; + + switch (state) { + case QMediaRecorder::StoppedState: + m_session->stop(); + break; + case QMediaRecorder::PausedState: m_session->pause(); - updateStatus(); + break; + case QMediaRecorder::RecordingState: + m_session->record(); + break; } -} -bool AudioMediaRecorderControl::isMuted() const -{ - return false; + updateStatus(); } void AudioMediaRecorderControl::setMuted(bool) @@ -141,5 +136,5 @@ void AudioMediaRecorderControl::updateStatus() void AudioMediaRecorderControl::handleSessionError(int code, const QString &description) { emit error(code, description); - stop(); + setState(QMediaRecorder::StoppedState); } diff --git a/src/plugins/audiocapture/audiomediarecordercontrol.h b/src/plugins/audiocapture/audiomediarecordercontrol.h index edd54ec83..2e9f91786 100644 --- a/src/plugins/audiocapture/audiomediarecordercontrol.h +++ b/src/plugins/audiocapture/audiomediarecordercontrol.h @@ -71,9 +71,7 @@ public: void applySettings() {} public slots: - void record(); - void pause(); - void stop(); + void setState(QMediaRecorder::State state); void setMuted(bool); private slots: diff --git a/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.cpp b/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.cpp index 700517a1c..2b7d77513 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.cpp @@ -126,6 +126,21 @@ qint64 QGstreamerRecorderControl::duration() const return m_session->duration(); } +void QGstreamerRecorderControl::setState(QMediaRecorder::State state) +{ + switch (state) { + case QMediaRecorder::StoppedState: + stop(); + break; + case QMediaRecorder::PausedState: + pause(); + break; + case QMediaRecorder::RecordingState: + record(); + break; + } +} + void QGstreamerRecorderControl::record() { if (m_state == QMediaRecorder::RecordingState) diff --git a/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.h b/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.h index c765c55fd..4696e1118 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.h +++ b/src/plugins/gstreamer/mediacapture/qgstreamerrecordercontrol.h @@ -71,6 +71,7 @@ public: void applySettings(); public slots: + void setState(QMediaRecorder::State state); void record(); void pause(); void stop(); |