1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QDECLARATIVECAMERARECORDER_H
41#define QDECLARATIVECAMERARECORDER_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of other Qt classes. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <qcamera.h>
55#include <qmediarecorder.h>
56#include <qmediaencodersettings.h>
57
58QT_BEGIN_NAMESPACE
59
60class QDeclarativeCamera;
61
62class QDeclarativeCameraRecorder : public QObject
63{
64 Q_OBJECT
65 Q_ENUMS(RecorderState)
66 Q_ENUMS(RecorderStatus)
67 Q_ENUMS(EncodingMode)
68 Q_ENUMS(Error)
69
70 Q_PROPERTY(RecorderState recorderState READ recorderState WRITE setRecorderState NOTIFY recorderStateChanged)
71 Q_PROPERTY(RecorderStatus recorderStatus READ recorderStatus NOTIFY recorderStatusChanged)
72
73 Q_PROPERTY(QString videoCodec READ videoCodec WRITE setVideoCodec NOTIFY videoCodecChanged)
74 Q_PROPERTY(QSize resolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
75 Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged)
76 Q_PROPERTY(int videoBitRate READ videoBitRate WRITE setVideoBitRate NOTIFY videoBitRateChanged)
77 Q_PROPERTY(EncodingMode videoEncodingMode READ videoEncodingMode WRITE setVideoEncodingMode NOTIFY videoEncodingModeChanged)
78
79 Q_PROPERTY(QString audioCodec READ audioCodec WRITE setAudioCodec NOTIFY audioCodecChanged)
80 Q_PROPERTY(int audioBitRate READ audioBitRate WRITE setAudioBitRate NOTIFY audioBitRateChanged)
81 Q_PROPERTY(int audioChannels READ audioChannels WRITE setAudioChannels NOTIFY audioChannelsChanged)
82 Q_PROPERTY(int audioSampleRate READ audioSampleRate WRITE setAudioSampleRate NOTIFY audioSampleRateChanged)
83 Q_PROPERTY(EncodingMode audioEncodingMode READ audioEncodingMode WRITE setAudioEncodingMode NOTIFY audioEncodingModeChanged)
84
85 Q_PROPERTY(QString mediaContainer READ mediaContainer WRITE setMediaContainer NOTIFY mediaContainerChanged)
86
87 Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
88 Q_PROPERTY(QString outputLocation READ outputLocation WRITE setOutputLocation NOTIFY outputLocationChanged)
89 Q_PROPERTY(QString actualLocation READ actualLocation NOTIFY actualLocationChanged)
90 Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
91 Q_PROPERTY(QString errorString READ errorString NOTIFY error)
92 Q_PROPERTY(Error errorCode READ errorCode NOTIFY error)
93
94public:
95 enum RecorderState
96 {
97 StoppedState = QMediaRecorder::StoppedState,
98 RecordingState = QMediaRecorder::RecordingState
99 };
100
101 enum RecorderStatus
102 {
103 UnavailableStatus = QMediaRecorder::UnavailableStatus,
104 UnloadedStatus = QMediaRecorder::UnloadedStatus,
105 LoadingStatus = QMediaRecorder::LoadingStatus,
106 LoadedStatus = QMediaRecorder::LoadedStatus,
107 StartingStatus = QMediaRecorder::StartingStatus,
108 RecordingStatus = QMediaRecorder::RecordingStatus,
109 PausedStatus = QMediaRecorder::PausedStatus,
110 FinalizingStatus = QMediaRecorder::FinalizingStatus
111 };
112
113 enum EncodingMode
114 {
115 ConstantQualityEncoding = QMultimedia::ConstantQualityEncoding,
116 ConstantBitRateEncoding = QMultimedia::ConstantBitRateEncoding,
117 AverageBitRateEncoding = QMultimedia::AverageBitRateEncoding
118 };
119
120 enum Error {
121 NoError = QMediaRecorder::NoError,
122 ResourceError = QMediaRecorder::ResourceError,
123 FormatError = QMediaRecorder::FormatError,
124 OutOfSpaceError = QMediaRecorder::OutOfSpaceError
125 };
126
127 ~QDeclarativeCameraRecorder();
128
129 RecorderState recorderState() const;
130 RecorderStatus recorderStatus() const;
131
132 QSize captureResolution();
133
134 QString outputLocation() const;
135 QString actualLocation() const;
136
137 qint64 duration() const;
138 bool isMuted() const;
139
140 QString audioCodec() const;
141 QString videoCodec() const;
142 QString mediaContainer() const;
143
144 Error errorCode() const;
145 QString errorString() const;
146
147 qreal frameRate() const;
148 int videoBitRate() const;
149 int audioBitRate() const;
150 int audioChannels() const;
151 int audioSampleRate() const;
152
153 EncodingMode videoEncodingMode() const;
154 EncodingMode audioEncodingMode() const;
155
156public Q_SLOTS:
157 void setOutputLocation(const QString &location);
158
159 void record();
160 void stop();
161 void setRecorderState(QDeclarativeCameraRecorder::RecorderState state);
162
163 void setMuted(bool muted);
164 void setMetadata(const QString &key, const QVariant &value);
165
166 void setCaptureResolution(const QSize &resolution);
167 void setAudioCodec(const QString &codec);
168 void setVideoCodec(const QString &codec);
169 void setMediaContainer(const QString &container);
170
171 void setFrameRate(qreal frameRate);
172 void setVideoBitRate(int rate);
173 void setAudioBitRate(int rate);
174 void setAudioChannels(int channels);
175 void setAudioSampleRate(int rate);
176
177 void setVideoEncodingMode(EncodingMode encodingMode);
178 void setAudioEncodingMode(EncodingMode encodingMode);
179
180Q_SIGNALS:
181 void recorderStateChanged(QDeclarativeCameraRecorder::RecorderState state);
182 void recorderStatusChanged();
183 void durationChanged(qint64 duration);
184 void mutedChanged(bool muted);
185 void outputLocationChanged(const QString &location);
186 void actualLocationChanged(const QString &location);
187
188 void error(QDeclarativeCameraRecorder::Error errorCode, const QString &errorString);
189
190 void metaDataChanged(const QString &key, const QVariant &value);
191
192 void captureResolutionChanged(const QSize &);
193 void audioCodecChanged(const QString &codec);
194 void videoCodecChanged(const QString &codec);
195 void mediaContainerChanged(const QString &container);
196
197 void frameRateChanged(qreal arg);
198 void videoBitRateChanged(int arg);
199 void audioBitRateChanged(int arg);
200 void audioChannelsChanged(int arg);
201 void audioSampleRateChanged(int arg);
202
203 void audioEncodingModeChanged(EncodingMode encodingMode);
204 void videoEncodingModeChanged(EncodingMode encodingMode);
205
206private slots:
207 void updateRecorderState(QMediaRecorder::State);
208 void updateRecorderError(QMediaRecorder::Error);
209 void updateActualLocation(const QUrl&);
210
211private:
212 friend class QDeclarativeCamera;
213 QDeclarativeCameraRecorder(QCamera *camera, QObject *parent = 0);
214
215 QMediaRecorder *m_recorder;
216
217 QAudioEncoderSettings m_audioSettings;
218 QVideoEncoderSettings m_videoSettings;
219 QString m_mediaContainer;
220};
221
222QT_END_NAMESPACE
223
224QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraRecorder))
225
226#endif
227

source code of qtmultimedia/src/imports/multimedia/qdeclarativecamerarecorder_p.h