Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
testvideosink_p.h
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
#
ifndef
TESTVIDEOSINK_H
5
#
define
TESTVIDEOSINK_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
qvideosink
.
h
>
19
#
include
<
qvideoframe
.
h
>
20
#
include
<
qelapsedtimer
.
h
>
21
#
include
<
qsignalspy
.
h
>
22
#
include
<
chrono
>
23
24
QT_BEGIN_NAMESPACE
25
26
/*
27
This is a simple video surface which records all presented frames.
28
*/
29
class
TestVideoSink
:
public
QVideoSink
30
{
31
Q_OBJECT
32
public
:
33
explicit
TestVideoSink
(
bool
storeFrames
=
false
) :
m_storeFrames
(
storeFrames
)
34
{
35
connect
(
this
, &
QVideoSink
::
videoFrameChanged
,
this
, &
TestVideoSink
::
addVideoFrame
);
36
connect
(
this
, &
QVideoSink
::
videoFrameChanged
,
this
, &
TestVideoSink
::
videoFrameChangedSync
);
37
}
38
39
QVideoFrame
waitForFrame
()
40
{
41
QSignalSpy
spy
(
this
, &
TestVideoSink
::
videoFrameChangedSync
);
42
return
spy
.
wait
() ?
spy
.
at
(0).
at
(0).
value
<
QVideoFrame
>() :
QVideoFrame
{};
43
}
44
45
void
setStoreFrames
(
bool
storeFrames
=
true
) {
m_storeFrames
=
storeFrames
; }
46
47
private
Q_SLOTS
:
48
void
addVideoFrame
(
const
QVideoFrame
&
frame
)
49
{
50
m_elapsedTimer
.
start
();
51
52
if
(
m_storeFrames
)
53
m_frameList
.
append
(
frame
);
54
55
if
(
frame
.
isValid
())
56
m_frameTimes
.
emplace_back
(
std
::
chrono
::
microseconds
(
frame
.
startTime
()));
57
58
++
m_totalFrames
;
59
}
60
61
signals
:
62
void
videoFrameChangedSync
(
const
QVideoFrame
&
frame
);
63
64
public
:
65
QList
<
QVideoFrame
>
m_frameList
;
66
int
m_totalFrames
= 0;
// used instead of the list when frames are not stored
67
QElapsedTimer
m_elapsedTimer
;
68
using
TimePoint
=
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>;
69
std
::
vector
<
TimePoint
>
m_frameTimes
;
70
71
private
:
72
bool
m_storeFrames;
73
};
74
75
QT_END_NAMESPACE
76
77
#
endif
// TESTVIDEOSINK_H
TestVideoSink
Definition
testvideosink_p.h:30
TestVideoSink::m_totalFrames
int m_totalFrames
Definition
testvideosink_p.h:66
TestVideoSink::m_frameTimes
std::vector< TimePoint > m_frameTimes
Definition
testvideosink_p.h:69
TestVideoSink::m_elapsedTimer
QElapsedTimer m_elapsedTimer
Definition
testvideosink_p.h:67
TestVideoSink::m_frameList
QList< QVideoFrame > m_frameList
Definition
testvideosink_p.h:65
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtmultimedia
src
multimediatestlib
testvideosink_p.h
Generated on
for Qt by
1.14.0