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
qplaybackoptions.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
#
include
"qplaybackoptions.h"
5
#
include
<
chrono
>
6
7
QT_BEGIN_NAMESPACE
8
9
using
namespace
std::chrono_literals;
10
11
class
QPlaybackOptionsPrivate
:
public
QSharedData
12
{
13
public
:
14
QPlaybackOptionsPrivate
() =
default
;
15
16
friend
bool
comparesEqual
(
const
QPlaybackOptionsPrivate
&lhs,
17
const
QPlaybackOptionsPrivate
&rhs)
18
{
19
return
lhs.m_networkTimeout == rhs.m_networkTimeout
20
&& lhs.m_playbackIntent == rhs.m_playbackIntent
21
&& lhs
.
m_probeSizeBytes
== rhs
.
m_probeSizeBytes
;
22
}
23
24
friend
Qt
::
strong_ordering
compareThreeWay
(
const
QPlaybackOptionsPrivate
&lhs,
25
const
QPlaybackOptionsPrivate
&rhs)
26
{
27
if
(lhs.m_networkTimeout != rhs.m_networkTimeout)
28
return
qCompareThreeWay(lhs.m_networkTimeout.count(), rhs.m_networkTimeout.count());
29
if
(lhs.m_playbackIntent != rhs.m_playbackIntent)
30
return
qCompareThreeWay(lhs.m_playbackIntent, rhs.m_playbackIntent);
31
return
qCompareThreeWay(lhs
.
m_probeSizeBytes
, rhs
.
m_probeSizeBytes
);
32
}
33
34
std
::chrono::milliseconds
m_networkTimeout
= 20s;
35
QPlaybackOptions
::
PlaybackIntent
m_playbackIntent
=
QPlaybackOptions
::
PlaybackIntent
::
Playback
;
36
int
m_probeSizeBytes
= -1;
37
};
38
39
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QPlaybackOptionsPrivate)
40
41
/*!
42
\class QPlaybackOptions
43
\brief The QPlaybackOptions class enables low-level control of media playback options.
44
\inmodule QtMultimedia
45
\ingroup multimedia
46
\ingroup multimedia_playback
47
\ingroup multimedia_video
48
\since 6.10
49
50
QPlaybackOptions gives low-level control of media playback options. Although we strongly
51
recommend to rely on the default settings of \l QMediaPlayer, QPlaybackOptions can be used to
52
optimize media playback to specific use cases where the default options are not ideal.
53
54
Note that options are hints to the media backend, and may be ignored if they are not supported
55
by the current media format or codec.
56
57
Playback options rely on support in the media backend. Availability is documented per option.
58
59
\sa QMediaPlayer
60
*/
61
62
/*!
63
\qmltype PlaybackOptions
64
\nativetype QPlaybackOptions
65
\brief Low level media playback options.
66
67
\inqmlmodule QtMultimedia
68
\ingroup multimedia_qml
69
\ingroup multimedia_audio_qml
70
\ingroup multimedia_video_qml
71
\since 6.10
72
73
Playback options gives low-level control of media playback options. Although we strongly
74
recommend to rely on the default settings of \l MediaPlayer, PlaybackOptions can be used to
75
optimize media playback to specific use cases where the default options are not ideal.
76
77
Note that options are hints to the media backend, and may be ignored if they are not supported
78
by the current media format or codec.
79
80
Playback options rely on support in the media backend. Availability is documented per option.
81
82
\sa MediaPlayer
83
*/
84
85
QPlaybackOptions::QPlaybackOptions() : d{
new
QPlaybackOptionsPrivate } { }
86
QPlaybackOptions
::QPlaybackOptions(
const
QPlaybackOptions
&) =
default
;
87
QPlaybackOptions
&
QPlaybackOptions
::operator=(
const
QPlaybackOptions
&) =
default
;
88
QPlaybackOptions
::~QPlaybackOptions() =
default
;
89
90
bool
comparesEqual
(
const
QPlaybackOptions
&lhs,
const
QPlaybackOptions
&rhs)
noexcept
91
{
92
if
(lhs.d == rhs.d)
93
return
true
;
94
95
return
comparesEqual(*lhs.d, *rhs.d);
96
}
97
98
Qt
::
strong_ordering
compareThreeWay
(
const
QPlaybackOptions
&lhs,
const
QPlaybackOptions
&rhs)
noexcept
99
{
100
return
compareThreeWay(*lhs.d, *rhs.d);
101
}
102
103
/*!
104
\property QPlaybackOptions::networkTimeout
105
\since 6.10
106
107
Determines the network timeout used for socket I/O operations with some
108
network formats.
109
110
This option is only supported with the FFmpeg media backend.
111
*/
112
113
/*!
114
\qmlproperty qint64 PlaybackOptions::networkTimeoutMs
115
\since 6.10
116
117
Determines the network timeout (in milliseconds) used for socket I/O operations with some
118
network formats.
119
120
This option is only supported with the FFmpeg media backend.
121
*/
122
123
std
::chrono::milliseconds
QPlaybackOptions
::networkTimeout()
const
124
{
125
return
d->m_networkTimeout;
126
}
127
128
void
QPlaybackOptions
::setNetworkTimeout(
std
::chrono::milliseconds timeout)
129
{
130
d.detach();
131
d->m_networkTimeout = timeout;
132
}
133
134
void
QPlaybackOptions
::resetNetworkTimeout()
135
{
136
d.detach();
137
d->m_networkTimeout = QPlaybackOptionsPrivate{}.m_networkTimeout;
138
}
139
140
/*!
141
\enum QPlaybackOptions::PlaybackIntent
142
\since 6.10
143
144
Configures the intent of media playback, to focus on either high quality playback or
145
low latency media streaming.
146
147
\value Playback The intent is robust and high quality media playback, enabling sufficient
148
buffering to prevent glitches during playback.
149
\value LowLatencyStreaming Buffering is reduced to optimize for low latency streaming, but
150
with a higher likelihood of lost frames or other glitches during playback.
151
*/
152
153
/*!
154
\property QPlaybackOptions::playbackIntent
155
\since 6.10
156
157
Determines if \l QMediaPlayer should optimize for robust high quality video playback (default),
158
or low latency streaming.
159
160
This option is only supported with the FFmpeg media backend.
161
*/
162
163
/*!
164
\qmlproperty enumeration PlaybackOptions::playbackIntent
165
\since 6.10
166
167
Determines if \l MediaPlayer should optimize for robust high quality video playback (default),
168
or low latency streaming.
169
170
This option is only supported with the FFmpeg media backend.
171
172
\qmlenumeratorsfrom QPlaybackOptions::PlaybackIntent
173
*/
174
175
QPlaybackOptions::PlaybackIntent
QPlaybackOptions
::playbackIntent()
const
176
{
177
return
d->m_playbackIntent;
178
}
179
180
void
QPlaybackOptions
::setPlaybackIntent(PlaybackIntent intent)
181
{
182
d.detach();
183
d->m_playbackIntent = intent;
184
}
185
186
void
QPlaybackOptions
::resetPlaybackIntent()
187
{
188
d.detach();
189
d->m_playbackIntent = QPlaybackOptionsPrivate{}.m_playbackIntent;
190
}
191
192
/*!
193
\property QPlaybackOptions::probeSize
194
\since 6.10
195
196
Probesize defines the amount of data (in bytes) to analyze in order to gather stream
197
information before media playback starts.
198
199
A larger probesize value can give more robust playback but may increase latency. Conversely,
200
a smaller probesize can reduce latency but might miss some stream details. The default
201
probesize is -1, and the actual probesize is determined by the media backend.
202
203
This option is only supported with the FFmpeg media backend.
204
*/
205
206
/*!
207
\qmlproperty qsizetype PlaybackOptions::probeSize
208
\since 6.10
209
210
Probesize defines the amount of data (in bytes) to analyze in order to gather stream
211
information before media playback starts.
212
213
A larger probesize value can give more robust playback but may increase latency. Conversely,
214
a smaller probesize can reduce latency but might miss some stream details. The default
215
probesize is -1, and the actual probesize is then determined by the media backend.
216
217
Note that a too small probeSize can result in failure to play the media, while a too high
218
probeSize can increase latency.
219
220
This option is only supported with the FFmpeg media backend.
221
*/
222
223
qsizetype
QPlaybackOptions
::probeSize()
const
224
{
225
return
d->m_probeSizeBytes;
226
}
227
228
void
QPlaybackOptions
::setProbeSize(qsizetype probeSizeBytes)
229
{
230
d.detach();
231
d->m_probeSizeBytes =
static_cast
<
int
>(probeSizeBytes);
232
}
233
234
void
QPlaybackOptions
::resetProbeSize()
235
{
236
d.detach();
237
d->m_probeSizeBytes = QPlaybackOptionsPrivate{}.m_probeSizeBytes;
238
}
239
240
QT_END_NAMESPACE
241
242
#
include
"moc_qplaybackoptions.cpp"
QPlaybackOptionsPrivate
Definition
qplaybackoptions.cpp:12
QPlaybackOptionsPrivate::QPlaybackOptionsPrivate
QPlaybackOptionsPrivate()=default
QPlaybackOptionsPrivate::m_networkTimeout
std::chrono::milliseconds m_networkTimeout
Definition
qplaybackoptions.cpp:34
QPlaybackOptionsPrivate::m_probeSizeBytes
int m_probeSizeBytes
Definition
qplaybackoptions.cpp:36
QPlaybackOptionsPrivate::compareThreeWay
friend Qt::strong_ordering compareThreeWay(const QPlaybackOptionsPrivate &lhs, const QPlaybackOptionsPrivate &rhs)
Definition
qplaybackoptions.cpp:24
QPlaybackOptionsPrivate::m_playbackIntent
QPlaybackOptions::PlaybackIntent m_playbackIntent
Definition
qplaybackoptions.cpp:35
QPlaybackOptionsPrivate::comparesEqual
friend bool comparesEqual(const QPlaybackOptionsPrivate &lhs, const QPlaybackOptionsPrivate &rhs)
Definition
qplaybackoptions.cpp:16
QPlaybackOptions
The QPlaybackOptions class enables low-level control of media playback options.
Definition
qplaybackoptions.h:21
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
comparesEqual
bool comparesEqual(const QPlaybackOptions &lhs, const QPlaybackOptions &rhs) noexcept
Definition
qplaybackoptions.cpp:90
compareThreeWay
Qt::strong_ordering compareThreeWay(const QPlaybackOptions &lhs, const QPlaybackOptions &rhs) noexcept
Definition
qplaybackoptions.cpp:98
qtmultimedia
src
multimedia
playback
qplaybackoptions.cpp
Generated on
for Qt by
1.18.0