Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickvideooutput_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// Copyright (C) 2016 Research In Motion
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QQUICKVIDEOOUTPUT_P_H
6#define QQUICKVIDEOOUTPUT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qrect.h>
20#include <QtCore/qsharedpointer.h>
21#include <QtQuick/qquickitem.h>
22#include <QtCore/qpointer.h>
23#include <QtCore/qmutex.h>
24
25#include <private/qtmultimediaquickglobal_p.h>
26#include <qvideoframe.h>
27#include <qvideoframeformat.h>
28
30
31class QQuickVideoBackend;
33class QVideoSink;
34class QSGVideoNode;
35
36class Q_MULTIMEDIAQUICK_EXPORT QQuickVideoOutput : public QQuickItem
37{
39 Q_DISABLE_COPY(QQuickVideoOutput)
40 Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
41 Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
42 Q_PROPERTY(QRectF sourceRect READ sourceRect NOTIFY sourceRectChanged)
43 Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged)
44 Q_PROPERTY(QVideoSink* videoSink READ videoSink CONSTANT)
45 Q_MOC_INCLUDE(qvideosink.h)
46 Q_MOC_INCLUDE(qvideoframe.h)
47 QML_NAMED_ELEMENT(VideoOutput)
48
49public:
50
52 {
54 PreserveAspectFit = Qt::KeepAspectRatio,
55 PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
56 };
57 Q_ENUM(FillMode)
58
59 QQuickVideoOutput(QQuickItem *parent = 0);
61
62 Q_INVOKABLE QVideoSink *videoSink() const;
63
64 FillMode fillMode() const;
65 void setFillMode(FillMode mode);
66
67 int orientation() const;
68 void setOrientation(int);
69
70 QRectF sourceRect() const;
71 QRectF contentRect() const;
72
79
80protected:
81 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
82 void itemChange(ItemChange change, const ItemChangeData &changeData) override;
83 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
84 void releaseResources() override;
85
86private:
87 QSize nativeSize() const;
88 void updateGeometry();
89 QRectF adjustedViewport() const;
90
91 void setFrame(const QVideoFrame &frame);
92
93 void invalidateSceneGraph();
94
95 void initRhiForSink();
96 void updateHdr(QSGVideoNode *videoNode);
97
98private Q_SLOTS:
99 void _q_newFrame(QSize);
100 void _q_updateGeometry();
101 void _q_invalidateSceneGraph();
102 void _q_sceneGraphInitialized();
103
104private:
105 QSize m_nativeSize;
106
107 bool m_geometryDirty = true;
108 QRectF m_lastRect; // Cache of last rect to avoid recalculating geometry
109 QRectF m_contentRect; // Destination pixel coordinates, unclipped
110 int m_orientation = 0;
111 int m_frameOrientation = 0;
112 Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
113
114 QPointer<QQuickWindow> m_window;
115 QVideoSink *m_sink = nullptr;
116 QVideoFrameFormat m_videoFormat;
117
118 QList<QVideoFrame> m_videoFrameQueue;
119 QVideoFrame m_frame;
120 bool m_frameChanged = false;
121 QMutex m_frameMutex;
122 QRectF m_renderedRect; // Destination pixel coordinates, clipped
123 QRectF m_sourceTextureRect; // Source texture coordinates
124};
125
127
128#endif // QQUICKVIDEOOUTPUT_P_H
\inmodule QtCore
Definition qmutex.h:281
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
Render video or camera viewfinder.
void fillModeChanged(QQuickVideoOutput::FillMode)
void contentRectChanged()
void orientationChanged()
void sourceRectChanged()
\inmodule QtCore\reentrant
Definition qrect.h:484
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
\inmodule QtCore
Definition qsize.h:25
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
Combined button and popup list for selecting options.
AspectRatioMode
@ KeepAspectRatioByExpanding
@ KeepAspectRatio
@ IgnoreAspectRatio
GLenum mode
GLenum fillMode
GLfloat GLfloat GLfloat GLfloat h
#define QML_NAMED_ELEMENT(NAME)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_MOC_INCLUDE(...)
#define Q_SIGNALS
QFrame frame
[0]
\inmodule QtQuick
Definition qquickitem.h:159