Skip to content

Commit

Permalink
Get rid of QAudioRecorder and the audiocapture plugin
Browse files Browse the repository at this point in the history
QMediaRecorder will need to get an audio-only mode instead.

Change-Id: I7c4ee72e96de16cc1536f46a59ad18509607fa22
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
  • Loading branch information
laknoll committed Jan 22, 2021
1 parent 03364bd commit 805b106
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 1,944 deletions.
12 changes: 6 additions & 6 deletions examples/multimedia/audiorecorder/audiorecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "ui_audiorecorder.h"

#include <QAudioProbe>
#include <QAudioRecorder>
#include <QMediaRecorder>
#include <QDir>
#include <QFileDialog>
#include <QMediaRecorder>
Expand All @@ -71,7 +71,7 @@ AudioRecorder::AudioRecorder()
{
ui->setupUi(this);

m_audioRecorder = new QAudioRecorder(this);
m_audioRecorder = new QMediaRecorder(QMediaRecorder::AudioOnly, this);
m_probe = new QAudioProbe(this);
connect(m_probe, &QAudioProbe::audioBufferProbed,
this, &AudioRecorder::processBuffer);
Expand Down Expand Up @@ -120,10 +120,10 @@ AudioRecorder::AudioRecorder()
ui->bitrateBox->addItem(QStringLiteral("96000"), QVariant(96000));
ui->bitrateBox->addItem(QStringLiteral("128000"), QVariant(128000));

connect(m_audioRecorder, &QAudioRecorder::durationChanged, this, &AudioRecorder::updateProgress);
connect(m_audioRecorder, &QAudioRecorder::statusChanged, this, &AudioRecorder::updateStatus);
connect(m_audioRecorder, &QAudioRecorder::stateChanged, this, &AudioRecorder::onStateChanged);
connect(m_audioRecorder, QOverload<QMediaRecorder::Error>::of(&QAudioRecorder::error), this,
connect(m_audioRecorder, &QMediaRecorder::durationChanged, this, &AudioRecorder::updateProgress);
connect(m_audioRecorder, &QMediaRecorder::statusChanged, this, &AudioRecorder::updateStatus);
connect(m_audioRecorder, &QMediaRecorder::stateChanged, this, &AudioRecorder::onStateChanged);
connect(m_audioRecorder, QOverload<QMediaRecorder::Error>::of(&QMediaRecorder::error), this,
&AudioRecorder::displayErrorMessage);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/multimedia/audiorecorder/audiorecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

QT_BEGIN_NAMESPACE
namespace Ui { class AudioRecorder; }
class QAudioRecorder;
class QMediaRecorder;
class QAudioProbe;
class QAudioBuffer;
QT_END_NAMESPACE
Expand Down Expand Up @@ -89,7 +89,7 @@ private slots:

Ui::AudioRecorder *ui = nullptr;

QAudioRecorder *m_audioRecorder = nullptr;
QMediaRecorder *m_audioRecorder = nullptr;
QAudioProbe *m_probe = nullptr;
QList<AudioLevel*> m_audioLevels;
bool m_outputLocationSet = false;
Expand Down
2 changes: 1 addition & 1 deletion src/multimedia/qmediasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void QMediaSourcePrivate::_q_notify()
Most media objects when constructed will request a new
QMediaService instance, but some like
QMediaRecorder and QAudioRecorder will share a service with another object.
QMediaRecorder and QMediaRecorder will share a service with another object.
\sa QMediaService, QMediaControl
*/
Expand Down
130 changes: 0 additions & 130 deletions src/multimedia/recording/qaudiorecorder.cpp

This file was deleted.

74 changes: 0 additions & 74 deletions src/multimedia/recording/qaudiorecorder.h

This file was deleted.

30 changes: 27 additions & 3 deletions src/multimedia/recording/qmediarecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,40 @@ void QMediaRecorderPrivate::restartCamera()
}
}

class QAudioRecorderObject : public QMediaSource
{
public:
QAudioRecorderObject(QObject *parent, QMediaService *service)
: QMediaSource(parent, service)
{
}

~QAudioRecorderObject() override
{
}
};

/*!
Constructs a media recorder which records the media produced by \a mediaSource.
The \a parent is passed to QMediaSource.
*/

QMediaRecorder::QMediaRecorder(QMediaSource *mediaSource, QObject *parent):
QObject(parent),
d_ptr(new QMediaRecorderPrivate)
QMediaRecorder::QMediaRecorder(QMediaRecorder::Mode mode, QObject *parent)
: QObject(parent),
d_ptr(new QMediaRecorderPrivate)
{
if (mode == AudioOnly) {
auto provider = QMediaServiceProvider::defaultServiceProvider();

QMediaService *service = provider->requestService(Q_MEDIASERVICE_AUDIOSOURCE);
setMediaSource(new QAudioRecorderObject(this, service));
}
}

QMediaRecorder::QMediaRecorder(QMediaSource *mediaSource, QObject *parent)
: QObject(parent),
d_ptr(new QMediaRecorderPrivate)
{
Q_D(QMediaRecorder);
d->q_ptr = this;
Expand Down
6 changes: 6 additions & 0 deletions src/multimedia/recording/qmediarecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaSink
OutOfSpaceError
};

enum Mode {
AudioOnly,
AudioAndVideo
};

QMediaRecorder(Mode mode = AudioOnly, QObject *parent = nullptr);
explicit QMediaRecorder(QMediaSource *mediaSource, QObject *parent = nullptr);
~QMediaRecorder();

Expand Down
2 changes: 0 additions & 2 deletions src/multimedia/recording/recording.pri
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
INCLUDEPATH += recording

PUBLIC_HEADERS += \
recording/qaudiorecorder.h \
recording/qmediaencodersettings.h \
recording/qmediarecorder.h \

PRIVATE_HEADERS += \
recording/qmediarecorder_p.h \

SOURCES += \
recording/qaudiorecorder.cpp \
recording/qmediaencodersettings.cpp \
recording/qmediarecorder.cpp
25 changes: 0 additions & 25 deletions src/plugins/audiocapture/CMakeLists.txt

This file was deleted.

4 changes: 0 additions & 4 deletions src/plugins/audiocapture/audiocapture.json

This file was deleted.

25 changes: 0 additions & 25 deletions src/plugins/audiocapture/audiocapture.pro

This file was deleted.

Loading

0 comments on commit 805b106

Please sign in to comment.