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
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
5
6#include <QtMultimedia/private/qmultimediautils_p.h>
7
9
10QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) : QObject(parent), m_sink(parent) { }
11
12QPlatformVideoSink::~QPlatformVideoSink() = default;
13
14QSize QPlatformVideoSink::nativeSize() const
15{
16 QMutexLocker locker(&m_mutex);
17 return m_nativeSize;
18}
19
20void QPlatformVideoSink::setNativeSize(QSize s)
21{
22 {
23 QMutexLocker locker(&m_mutex);
24 if (m_nativeSize == s)
25 return;
26 m_nativeSize = s;
27 }
28 emit m_sink->videoSizeChanged();
29}
30
31void QPlatformVideoSink::setVideoFrame(const QVideoFrame &frame)
32{
33 bool sizeChanged = false;
34 QVideoFrame currentFrame;
35 {
36 QMutexLocker 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 emit m_sink->videoSizeChanged();
54 emit m_sink->videoFrameChanged(frame);
55}
56
57QVideoFrame QPlatformVideoSink::currentVideoFrame() const
58{
59 QMutexLocker locker(&m_mutex);
60 return m_currentVideoFrame;
61}
62
63void QPlatformVideoSink::setSubtitleText(const QString &subtitleText)
64{
65 {
66 QMutexLocker locker(&m_mutex);
67 if (m_subtitleText == subtitleText)
68 return;
69 m_subtitleText = subtitleText;
70 }
71 emit m_sink->subtitleTextChanged(subtitleText);
72}
73
74QString QPlatformVideoSink::subtitleText() const
75{
76 QMutexLocker locker(&m_mutex);
77 return m_subtitleText;
78}
79
80QT_END_NAMESPACE
81
82#include "moc_qplatformvideosink_p.cpp"
Combined button and popup list for selecting options.