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#ifndef QGRAPHICSVIDEOITEM_H
5#define QGRAPHICSVIDEOITEM_H
6
7#include <QtWidgets/qgraphicsitem.h>
8
9#include <QtMultimediaWidgets/qvideowidget.h>
10
11#if QT_CONFIG(graphicsview)
12
13QT_BEGIN_NAMESPACE
14
15class QVideoFrameFormat;
16class QGraphicsVideoItemPrivate;
17class Q_MULTIMEDIAWIDGETS_EXPORT QGraphicsVideoItem : public QGraphicsObject
18{
19 Q_OBJECT
20 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
21 Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
22 Q_PROPERTY(QSizeF size READ size WRITE setSize)
23 Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged)
24 Q_PROPERTY(QVideoSink* videoSink READ videoSink CONSTANT)
25public:
26 explicit QGraphicsVideoItem(QGraphicsItem *parent = nullptr);
27 ~QGraphicsVideoItem();
28
29 Q_INVOKABLE QVideoSink *videoSink() const;
30
31 Qt::AspectRatioMode aspectRatioMode() const;
32 void setAspectRatioMode(Qt::AspectRatioMode mode);
33
34 QPointF offset() const;
35 void setOffset(const QPointF &offset);
36
37 QSizeF size() const;
38 void setSize(const QSizeF &size);
39
40 QSizeF nativeSize() const;
41
42 QRectF boundingRect() const override;
43
44 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
45
46 enum { Type = 14 };
47 int type() const override
48 {
49 // Enable the use of qgraphicsitem_cast with this item.
50 return Type;
51 }
52
53Q_SIGNALS:
54 void nativeSizeChanged(const QSizeF &size);
55
56protected:
57 void timerEvent(QTimerEvent *event) override;
58 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
59
60 QGraphicsVideoItemPrivate *d_ptr;
61
62private:
63 Q_DECLARE_PRIVATE(QGraphicsVideoItem)
64 Q_PRIVATE_SLOT(d_func(), void _q_present(const QVideoFrame &))
65};
66
67QT_END_NAMESPACE
68
69#endif // QT_CONFIG(graphicsview)
70
71#endif // QGRAPHICSVIDEOITEM_H
72

source code of qtmultimedia/src/multimediawidgets/qgraphicsvideoitem.h