blob: abf82af0f88ac2f7c819bcdc55c4cd1fe676bf3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformvideosink_p.h"
#include "qmultimediautils_p.h"
QT_BEGIN_NAMESPACE
QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) : QObject(parent), m_sink(parent) { }
QPlatformVideoSink::~QPlatformVideoSink() = default;
QSize QPlatformVideoSink::nativeSize() const
{
QMutexLocker locker(&m_mutex);
return m_nativeSize;
}
void QPlatformVideoSink::setNativeSize(QSize s)
{
{
QMutexLocker locker(&m_mutex);
if (m_nativeSize == s)
return;
m_nativeSize = s;
}
emit m_sink->videoSizeChanged();
}
void QPlatformVideoSink::setVideoFrame(const QVideoFrame &frame)
{
bool sizeChanged = false;
{
QMutexLocker locker(&m_mutex);
if (frame == m_currentVideoFrame)
return;
m_currentVideoFrame = frame;
m_currentVideoFrame.setSubtitleText(m_subtitleText);
const auto size = qRotatedFrameSize(frame);
if (size != m_nativeSize) {
m_nativeSize = size;
sizeChanged = true;
}
}
// emit signals outside the mutex to avoid deadlocks on the user side
if (sizeChanged)
emit m_sink->videoSizeChanged();
emit m_sink->videoFrameChanged(frame);
}
QVideoFrame QPlatformVideoSink::currentVideoFrame() const
{
QMutexLocker locker(&m_mutex);
return m_currentVideoFrame;
}
void QPlatformVideoSink::setSubtitleText(const QString &subtitleText)
{
{
QMutexLocker locker(&m_mutex);
if (m_subtitleText == subtitleText)
return;
m_subtitleText = subtitleText;
}
emit m_sink->subtitleTextChanged(subtitleText);
}
QString QPlatformVideoSink::subtitleText() const
{
QMutexLocker locker(&m_mutex);
return m_subtitleText;
}
QT_END_NAMESPACE
#include "moc_qplatformvideosink_p.cpp"
|