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
qplatformvideosink.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
"qplatformvideosink_p.h"
5
6
#
include
<
QtMultimedia
/
private
/
qmultimediautils_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) : QObject(parent), m_sink(parent) { }
11
12
QPlatformVideoSink::~QPlatformVideoSink() =
default
;
13
14
QSize QPlatformVideoSink::nativeSize()
const
15
{
16
std::lock_guard locker(m_mutex);
17
return
m_nativeSize;
18
}
19
20
void
QPlatformVideoSink::setNativeSize(QSize s)
21
{
22
{
23
std::lock_guard locker(m_mutex);
24
if
(m_nativeSize == s)
25
return
;
26
m_nativeSize = s;
27
}
28
Q_EMIT m_sink->videoSizeChanged();
29
}
30
31
void
QPlatformVideoSink::setVideoFrame(
const
QVideoFrame &frame)
32
{
33
bool
sizeChanged =
false
;
34
QVideoFrame currentFrame;
35
{
36
std::lock_guard locker(m_mutex);
37
if
(frame == m_currentVideoFrame)
38
return
;
39
m_currentVideoFrame = frame;
40
m_currentVideoFrame.setSubtitleText(m_subtitleText);
41
const
QSize size = qRotatedFramePresentationSize(frame);
42
if
(size != m_nativeSize) {
43
m_nativeSize = size;
44
sizeChanged =
true
;
45
}
46
currentFrame = m_currentVideoFrame;
47
}
48
49
onVideoFrameChanged(currentFrame);
50
51
// emit signals outside the mutex to avoid deadlocks on the user side
52
if
(sizeChanged)
53
Q_EMIT m_sink->videoSizeChanged();
54
Q_EMIT m_sink->videoFrameChanged(frame);
55
}
56
57
QVideoFrame QPlatformVideoSink::currentVideoFrame()
const
58
{
59
std::lock_guard locker(m_mutex);
60
return
m_currentVideoFrame;
61
}
62
63
void
QPlatformVideoSink::setSubtitleText(
const
QString &subtitleText)
64
{
65
{
66
std::lock_guard locker(m_mutex);
67
if
(m_subtitleText == subtitleText)
68
return
;
69
m_subtitleText = subtitleText;
70
}
71
Q_EMIT m_sink->subtitleTextChanged(subtitleText);
72
}
73
74
QString QPlatformVideoSink::subtitleText()
const
75
{
76
std::lock_guard locker(m_mutex);
77
return
m_subtitleText;
78
}
79
80
QRhiVideoSink::QRhiVideoSink(QVideoSink *sink) : QPlatformVideoSink(sink) {}
81
82
void
QRhiVideoSink::setRhi(QRhi *rhi)
83
{
84
if
(rhi && !isBackendSupported(rhi->backend()))
85
rhi =
nullptr
;
86
{
87
QMutexLocker guard{ &mutex() };
88
if
(m_rhi == rhi)
89
return
;
90
m_rhi = rhi;
91
}
92
93
Q_EMIT rhiChanged(rhi);
94
}
95
96
bool
QOpenGLRhiVideoSink::isBackendSupported(QRhi::Implementation backend)
const
97
{
98
return
backend == QRhi::OpenGLES2;
99
}
100
101
QT_END_NAMESPACE
102
103
#
include
"moc_qplatformvideosink_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
multimedia
platform
qplatformvideosink.cpp
Generated on
for Qt by
1.18.0