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 | QT_BEGIN_NAMESPACE |
7 | |
8 | QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) : QObject(parent), m_sink(parent) { } |
9 | |
10 | QPlatformVideoSink::~QPlatformVideoSink() = default; |
11 | |
12 | QSize QPlatformVideoSink::nativeSize() const |
13 | { |
14 | QMutexLocker locker(&m_mutex); |
15 | return m_nativeSize; |
16 | } |
17 | |
18 | void QPlatformVideoSink::setNativeSize(QSize s) |
19 | { |
20 | { |
21 | QMutexLocker locker(&m_mutex); |
22 | if (m_nativeSize == s) |
23 | return; |
24 | m_nativeSize = s; |
25 | } |
26 | emit m_sink->videoSizeChanged(); |
27 | } |
28 | |
29 | void QPlatformVideoSink::setVideoFrame(const QVideoFrame &frame) |
30 | { |
31 | bool sizeChanged = false; |
32 | |
33 | { |
34 | QMutexLocker locker(&m_mutex); |
35 | if (frame == m_currentVideoFrame) |
36 | return; |
37 | m_currentVideoFrame = frame; |
38 | m_currentVideoFrame.setSubtitleText(m_subtitleText); |
39 | sizeChanged = m_nativeSize != frame.size(); |
40 | m_nativeSize = frame.size(); |
41 | } |
42 | |
43 | if (sizeChanged) |
44 | emit m_sink->videoSizeChanged(); |
45 | emit m_sink->videoFrameChanged(frame); |
46 | } |
47 | |
48 | QVideoFrame QPlatformVideoSink::currentVideoFrame() const |
49 | { |
50 | QMutexLocker locker(&m_mutex); |
51 | return m_currentVideoFrame; |
52 | } |
53 | |
54 | void QPlatformVideoSink::setSubtitleText(const QString &subtitleText) |
55 | { |
56 | { |
57 | QMutexLocker locker(&m_mutex); |
58 | if (m_subtitleText == subtitleText) |
59 | return; |
60 | m_subtitleText = subtitleText; |
61 | } |
62 | emit m_sink->subtitleTextChanged(subtitleText); |
63 | } |
64 | |
65 | QString QPlatformVideoSink::subtitleText() const |
66 | { |
67 | QMutexLocker locker(&m_mutex); |
68 | return m_subtitleText; |
69 | } |
70 | |
71 | QT_END_NAMESPACE |
72 | |
73 | #include "moc_qplatformvideosink_p.cpp" |
74 |