Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qplatformmediarecorder_p.h
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
//
5
// W A R N I N G
6
// -------------
7
//
8
// This file is not part of the Qt API. It exists purely as an
9
// implementation detail. This header file may change from version to
10
// version without notice, or even be removed.
11
//
12
// We mean it.
13
//
14
15
#
ifndef
QPLATFORMMEDIARECORDER_H
16
#
define
QPLATFORMMEDIARECORDER_H
17
18
#
include
<
QtCore
/
qsize
.
h
>
19
#
include
<
QtCore
/
qurl
.
h
>
20
#
if
QT_CONFIG
(
mimetype
)
21
#
include
<
QtCore
/
qmimetype
.
h
>
22
#
endif
23
#
include
<
QtMultimedia
/
private
/
qerrorinfo_p
.
h
>
24
#
include
<
QtMultimedia
/
qmediaformat
.
h
>
25
#
include
<
QtMultimedia
/
qmediametadata
.
h
>
26
#
include
<
QtMultimedia
/
qmediarecorder
.
h
>
27
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
28
#
include
<
QtCore
/
qiodevice
.
h
>
29
#
include
<
QtCore
/
qpointer
.
h
>
30
31
QT_BEGIN_NAMESPACE
32
33
class
QUrl;
34
QT_END_NAMESPACE
35
36
QT_BEGIN_NAMESPACE
37
38
class
Q_MULTIMEDIA_EXPORT
QMediaEncoderSettings
39
{
40
QMediaRecorder::EncodingMode m_encodingMode = QMediaRecorder::ConstantQualityEncoding;
41
QMediaRecorder::Quality m_quality = QMediaRecorder::NormalQuality;
42
43
QMediaFormat m_format;
44
int
m_audioBitrate = -1;
45
int
m_audioSampleRate = -1;
46
int
m_audioChannels = -1;
47
48
QSize m_videoResolution = QSize(-1, -1);
49
int
m_videoFrameRate = -1;
50
int
m_videoBitRate = -1;
51
public
:
52
53
QMediaFormat mediaFormat()
const
{
return
m_format; }
54
void
setMediaFormat(
const
QMediaFormat &format) { m_format = format; }
55
void
resolveFormat(QMediaFormat::ResolveFlags flags = QMediaFormat::NoFlags)
56
{ m_format.resolveForEncoding(flags); }
57
58
QMediaFormat::FileFormat fileFormat()
const
{
return
mediaFormat().fileFormat(); }
59
QMediaFormat::VideoCodec videoCodec()
const
{
return
mediaFormat().videoCodec(); }
60
QMediaFormat::AudioCodec audioCodec()
const
{
return
mediaFormat().audioCodec(); }
61
#
if
QT_CONFIG
(
mimetype
)
62
QMimeType mimeType()
const
{
return
mediaFormat().mimeType(); }
63
#
endif
64
QString preferredSuffix()
const
65
{
66
#
if
QT_CONFIG
(
mimetype
)
67
return
mimeType().preferredSuffix();
68
#
else
69
return
QStringLiteral(
""
);
70
#
endif
71
}
72
73
QMediaRecorder::EncodingMode encodingMode()
const
{
return
m_encodingMode; }
74
void
setEncodingMode(QMediaRecorder::EncodingMode mode) { m_encodingMode = mode; }
75
76
QMediaRecorder::Quality quality()
const
{
return
m_quality; }
77
void
setQuality(QMediaRecorder::Quality quality) { m_quality = quality; }
78
79
QSize videoResolution()
const
{
return
m_videoResolution; }
80
void
setVideoResolution(
const
QSize &size) { m_videoResolution = size; }
81
82
qreal videoFrameRate()
const
{
return
m_videoFrameRate; }
83
void
setVideoFrameRate(qreal rate) { m_videoFrameRate = rate; }
84
85
int
videoBitRate()
const
{
return
m_videoBitRate; }
86
void
setVideoBitRate(
int
bitrate) { m_videoBitRate = bitrate; }
87
88
int
audioBitRate()
const
{
return
m_audioBitrate; }
89
void
setAudioBitRate(
int
bitrate) { m_audioBitrate = bitrate; }
90
91
int
audioChannelCount()
const
{
return
m_audioChannels; }
92
void
setAudioChannelCount(
int
channels) { m_audioChannels = channels; }
93
94
int
audioSampleRate()
const
{
return
m_audioSampleRate; }
95
void
setAudioSampleRate(
int
rate) { m_audioSampleRate = rate; }
96
97
bool
operator==(
const
QMediaEncoderSettings &other)
const
98
{
99
return
m_format == other.m_format &&
100
m_encodingMode == other.m_encodingMode &&
101
m_quality == other.m_quality &&
102
m_audioBitrate == other.m_audioBitrate &&
103
m_audioSampleRate == other.m_audioSampleRate &&
104
m_audioChannels == other.m_audioChannels &&
105
m_videoResolution == other.m_videoResolution &&
106
m_videoFrameRate == other.m_videoFrameRate &&
107
m_videoBitRate == other.m_videoBitRate;
108
}
109
110
bool
operator!=(
const
QMediaEncoderSettings &other)
const
111
{
return
!operator==(other); }
112
};
113
114
class
Q_MULTIMEDIA_EXPORT
QPlatformMediaRecorder
115
{
116
public
:
117
virtual
~QPlatformMediaRecorder() {}
118
119
virtual
bool
isLocationWritable(
const
QUrl &location)
const
= 0;
120
121
virtual
QMediaRecorder::RecorderState state()
const
{
return
m_state; }
122
virtual
void
record(QMediaEncoderSettings &settings) = 0;
123
virtual
void
pause();
124
virtual
void
resume();
125
virtual
void
stop() = 0;
126
127
virtual
qint64 duration()
const
{
return
m_duration; }
128
129
virtual
void
setMetaData(
const
QMediaMetaData &) {}
130
virtual
QMediaMetaData metaData()
const
{
return
{}; }
131
132
QMediaRecorder::Error error()
const
{
return
m_error.code(); }
133
QString errorString()
const
{
return
m_error.description(); }
134
135
QUrl outputLocation()
const
{
return
m_outputLocation; }
136
virtual
void
setOutputLocation(
const
QUrl &location) { m_outputLocation = location; }
137
QUrl actualLocation()
const
{
return
m_actualLocation; }
138
void
clearActualLocation() { m_actualLocation.clear(); }
139
void
clearError() { updateError(QMediaRecorder::NoError, QString()); }
140
141
QIODevice *outputDevice()
const
{
return
m_outputDevice; }
142
void
setOutputDevice(QIODevice *device) { m_outputDevice = device; }
143
144
virtual
void
updateAutoStop() { }
145
146
protected
:
147
explicit
QPlatformMediaRecorder(QMediaRecorder *parent);
148
149
void
stateChanged(QMediaRecorder::RecorderState state);
150
void
durationChanged(qint64 position);
151
void
actualLocationChanged(
const
QUrl &location);
152
void
updateError(QMediaRecorder::Error error,
const
QString &errorString);
153
void
metaDataChanged();
154
155
QMediaRecorder *mediaRecorder() {
return
q; }
156
157
QString findActualLocation(
const
QMediaEncoderSettings &settings)
const
;
158
159
private
:
160
QMediaRecorder *q =
nullptr
;
161
QErrorInfo<QMediaRecorder::Error> m_error;
162
QUrl m_actualLocation;
163
QUrl m_outputLocation;
164
QPointer<QIODevice> m_outputDevice;
165
qint64 m_duration = 0;
166
167
QMediaRecorder::RecorderState m_state = QMediaRecorder::StoppedState;
168
};
169
170
QT_END_NAMESPACE
171
172
#
endif
QMediaEncoderSettings
Definition
qplatformmediarecorder_p.h:39
QPlatformMediaRecorder
Definition
qplatformmediarecorder_p.h:115
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
multimedia
platform
qplatformmediarecorder_p.h
Generated on
for Qt by
1.18.0