2
* Copyright (C) 2015 Canonical, Ltd.
5
* Arthur Renato Mello <arthur.mello@canonical.com>
7
* This file is part of messaging-app.
9
* messaging-app is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; version 3.
13
* messaging-app is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef AUDIORECORDER_H
23
#define AUDIORECORDER_H
26
#include <QAudioRecorder>
28
class AudioRecorder : public QObject
32
Q_ENUMS(EncodingQuality)
34
Q_ENUMS(RecorderState)
35
Q_ENUMS(RecorderStatus)
37
Q_PROPERTY(RecorderState recorderState READ recorderState WRITE setRecorderState NOTIFY recorderStateChanged)
38
Q_PROPERTY(RecorderStatus recorderStatus READ recorderStatus NOTIFY recorderStatusChanged)
39
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
40
Q_PROPERTY(Error errorCode READ errorCode NOTIFY errorChanged)
41
Q_PROPERTY(QString outputLocation READ outputLocation NOTIFY outputLocationChanged)
42
Q_PROPERTY(QString actualLocation READ actualLocation NOTIFY actualLocationChanged)
43
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
44
Q_PROPERTY(int bitRate READ bitRate WRITE setBitRate NOTIFY bitRateChanged);
45
Q_PROPERTY(int channelCount READ channelCount WRITE setChannelCount NOTIFY channelCountChanged);
46
Q_PROPERTY(QString codec READ codec WRITE setCodec NOTIFY codecChanged);
47
Q_PROPERTY(EncodingQuality quality READ quality WRITE setQuality NOTIFY qualityChanged);
48
Q_PROPERTY(int sampleRate READ sampleRate WRITE setSampleRate NOTIFY sampleRateChanged);
49
Q_PROPERTY(QString audioInput READ audioInput WRITE setAudioInput NOTIFY audioInputChanged);
54
VeryLowQuality = QMultimedia::VeryLowQuality,
55
LowQuality = QMultimedia::LowQuality,
56
NormalQuality = QMultimedia::NormalQuality,
57
HighQuality = QMultimedia::HighQuality,
58
VeryHighQuality = QMultimedia::VeryHighQuality
63
NoError = QMediaRecorder::NoError,
64
ResourceError = QMediaRecorder::ResourceError,
65
FormatError = QMediaRecorder::FormatError,
66
OutOfSpaceError = QMediaRecorder::OutOfSpaceError
71
StoppedState = QMediaRecorder::StoppedState,
72
RecordingState = QMediaRecorder::RecordingState,
73
PausedState = QMediaRecorder::PausedState
78
UnavailableStatus = QMediaRecorder::UnavailableStatus,
79
UnloadedStatus = QMediaRecorder::UnloadedStatus,
80
LoadingStatus = QMediaRecorder::LoadingStatus,
81
LoadedStatus = QMediaRecorder::LoadedStatus,
82
StartingStatus = QMediaRecorder::StartingStatus,
83
RecordingStatus = QMediaRecorder::RecordingStatus,
84
PausedStatus = QMediaRecorder::PausedStatus,
85
FinalizingStatus = QMediaRecorder::FinalizingStatus
88
AudioRecorder(QObject *parent = 0);
91
RecorderState recorderState() const;
92
RecorderStatus recorderStatus() const;
93
Error errorCode() const;
94
QString errorString() const;
95
QString outputLocation() const;
96
QString actualLocation() const;
97
qint64 duration() const;
99
int channelCount() const;
100
QString codec() const;
101
EncodingQuality quality() const;
102
int sampleRate() const;
103
QString audioInput() const;
109
void setRecorderState(AudioRecorder::RecorderState state);
110
void setOutputLocation(const QString &location);
111
void setBitRate(int rate);
112
void setChannelCount(int count);
113
void setCodec(const QString &audioCodec);
114
void setQuality(AudioRecorder::EncodingQuality encodingQuality);
115
void setSampleRate(int rate);
116
void setAudioInput(const QString &input);
119
void recorderStateChanged();
120
void recorderStatusChanged();
121
void errorChanged(AudioRecorder::Error errorCode, const QString &errorString);
122
void outputLocationChanged(const QString &location);
123
void actualLocationChanged(const QString &location);
124
void durationChanged(qint64 duration);
125
void bitRateChanged(int rate);
126
void channelCountChanged(int count);
127
void codecChanged(const QString &codec);
128
void qualityChanged(AudioRecorder::EncodingQuality quality);
129
void sampleRateChanged(int rate);
130
void audioInputChanged(const QString &input);
133
void updateRecorderError(QMediaRecorder::Error);
134
void updateActualLocation(const QUrl&);
137
QAudioRecorder *m_audioRecorder;
138
QAudioEncoderSettings m_audioSettings;
139
QString m_fileExtension;
142
#endif // AUDIORECORDER_H