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_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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#ifndef QPLATFORMVIDEOSINK_H
5#define QPLATFORMVIDEOSINK_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 <QtMultimedia/qtmultimediaglobal.h>
19#include <QtMultimedia/qvideoframe.h>
20#include <QtMultimedia/qvideosink.h>
21#include <QtGui/qwindowdefs.h>
22#include <QtCore/private/qglobal_p.h>
23#include <QtCore/qdebug.h>
24#include <QtCore/qmutex.h>
25#include <QtCore/qobject.h>
26#include <QtCore/qrect.h>
27#include <QtCore/qsize.h>
28#include <QtGui/rhi/qrhi.h>
29
30QT_BEGIN_NAMESPACE
31
32// Required for QDoc workaround
33class QString;
34
35class Q_MULTIMEDIA_EXPORT QPlatformVideoSink : public QObject
36{
37 Q_OBJECT
38
39public:
40 ~QPlatformVideoSink() override;
41
42 explicit QPlatformVideoSink(QVideoSink *parent);
43
44 virtual void setRhi(QRhi * /*rhi*/) {}
45
46 QSize nativeSize() const;
47
48 QVideoSink *videoSink() { return m_sink; }
49
50 void setNativeSize(QSize s);
51
52 void setVideoFrame(const QVideoFrame &frame);
53
54 QVideoFrame currentVideoFrame() const;
55
56 void setSubtitleText(const QString &subtitleText);
57
58 QString subtitleText() const;
59
60protected:
61 virtual void onVideoFrameChanged(const QVideoFrame &) { }
62
63 QMutex &mutex() const { return m_mutex; }
64
65private:
66 QVideoSink *const m_sink = nullptr;
67 mutable QMutex m_mutex; // Protects all members below
68 QSize m_nativeSize;
69 QString m_subtitleText;
70 QVideoFrame m_currentVideoFrame;
71};
72
73class Q_MULTIMEDIA_EXPORT QRhiVideoSink : public QPlatformVideoSink
74{
75 Q_OBJECT
76
77public:
78 explicit QRhiVideoSink(QVideoSink *sink);
79 void setRhi(QRhi *rhi) override final;
80
81 template <typename Functor>
82 auto withRhi(Functor &&functor) const
83 {
84 std::lock_guard guard{ mutex() };
85 return functor(m_rhi);
86 }
87
88Q_SIGNALS:
89 void rhiChanged(QRhi *rhi);
90
91protected:
92 virtual bool isBackendSupported(QRhi::Implementation) const { return true; }
93
94private:
95 QRhi *m_rhi = nullptr;
96};
97
98class Q_MULTIMEDIA_EXPORT QOpenGLRhiVideoSink final : public QRhiVideoSink
99{
100public:
101 using QRhiVideoSink::QRhiVideoSink;
102
103protected:
104 bool isBackendSupported(QRhi::Implementation backend) const override;
105};
106
107QT_END_NAMESPACE
108
109#endif
Combined button and popup list for selecting options.