Qt 6.x
The Qt SDK
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;
34
35class Q_MULTIMEDIAQUICK_EXPORT QQuickVideoOutput : public QQuickItem
36{
38 Q_DISABLE_COPY(QQuickVideoOutput)
39 Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
40 Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
41 Q_PROPERTY(QRectF sourceRect READ sourceRect NOTIFY sourceRectChanged)
42 Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged)
43 Q_PROPERTY(QVideoSink* videoSink READ videoSink CONSTANT)
44 Q_MOC_INCLUDE(qvideosink.h)
45 Q_MOC_INCLUDE(qvideoframe.h)
46 QML_NAMED_ELEMENT(VideoOutput)
47
48public:
49
51 {
53 PreserveAspectFit = Qt::KeepAspectRatio,
54 PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
55 };
56 Q_ENUM(FillMode)
57
60
61 Q_INVOKABLE QVideoSink *videoSink() const;
62
63 FillMode fillMode() const;
64 void setFillMode(FillMode mode);
65
66 int orientation() const;
67 void setOrientation(int);
68
69 QRectF sourceRect() const;
70 QRectF contentRect() const;
71
79
80protected:
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 friend class QSGVideoItemSurface;
92 void setFrame(const QVideoFrame &frame);
93 void stop();
94
95 void invalidateSceneGraph();
96
97 void initRhiForSink();
98
99private Q_SLOTS:
100 void _q_newFrame(QSize);
101 void _q_updateGeometry();
102 void _q_invalidateSceneGraph();
103 void _q_sceneGraphInitialized();
104
105private:
106 QSize m_nativeSize;
107
108 bool m_geometryDirty = true;
109 QRectF m_lastRect; // Cache of last rect to avoid recalculating geometry
110 QRectF m_contentRect; // Destination pixel coordinates, unclipped
111 int m_orientation = 0;
112 int m_frameOrientation = 0;
113 Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
114
115 QPointer<QQuickWindow> m_window;
116 QVideoSink *m_sink = nullptr;
117 QVideoFrameFormat m_surfaceFormat;
118
119 QList<QVideoFrame> m_videoFrameQueue;
120 QVideoFrame m_frame;
121 bool m_frameChanged = false;
122 QMutex m_frameMutex;
123 QRectF m_renderedRect; // Destination pixel coordinates, clipped
124 QRectF m_sourceTextureRect; // Source texture coordinates
125};
126
128
129#endif // QQUICKVIDEOOUTPUT_P_H
Definition qlist.h:74
\inmodule QtCore
Definition qmutex.h:285
\inmodule QtCore
Definition qpointer.h:18
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
virtual QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *)
Called on the render thread when it is time to sync the state of the item with the scene graph.
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
virtual void releaseResources()
This function is called when an item should release graphics resources which are not already managed ...
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:143
Render video or camera viewfinder.
void frameUpdated(QSize)
void fillModeChanged(QQuickVideoOutput::FillMode)
void contentRectChanged()
void orientationChanged()
void sourceRectChanged()
\inmodule QtCore\reentrant
Definition qrect.h:483
\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:26
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
#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]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
\inmodule QtQuick
Definition qquickitem.h:158