1// Copyright (C) 2022 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 QABSTRACTVIDEOBUFFER_H
5#define QABSTRACTVIDEOBUFFER_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
21#include <QtCore/qmetatype.h>
22#include <QtGui/qmatrix4x4.h>
23#include <QtCore/private/qglobal_p.h>
24
25#include <memory>
26
27QT_BEGIN_NAMESPACE
28
29
30class QVariant;
31class QRhi;
32class QRhiTexture;
33
34class Q_MULTIMEDIA_EXPORT QVideoFrameTextures
35{
36public:
37 virtual ~QVideoFrameTextures() {}
38 virtual QRhiTexture *texture(uint plane) const = 0;
39};
40
41class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer
42{
43public:
44 QAbstractVideoBuffer(QVideoFrame::HandleType type, QRhi *rhi = nullptr);
45 virtual ~QAbstractVideoBuffer();
46
47 QVideoFrame::HandleType handleType() const;
48 QRhi *rhi() const;
49
50 struct MapData
51 {
52 int nPlanes = 0;
53 int bytesPerLine[4] = {};
54 uchar *data[4] = {};
55 int size[4] = {};
56 };
57
58 virtual QVideoFrame::MapMode mapMode() const = 0;
59 virtual MapData map(QVideoFrame::MapMode mode) = 0;
60 virtual void unmap() = 0;
61
62 virtual std::unique_ptr<QVideoFrameTextures> mapTextures(QRhi *) { return {}; }
63 virtual quint64 textureHandle(int /*plane*/) const { return 0; }
64
65 virtual QMatrix4x4 externalTextureMatrix() const { return {}; }
66protected:
67 QVideoFrame::HandleType m_type;
68 QRhi *m_rhi = nullptr;
69
70private:
71 Q_DISABLE_COPY(QAbstractVideoBuffer)
72};
73
74#ifndef QT_NO_DEBUG_STREAM
75Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::MapMode);
76#endif
77
78QT_END_NAMESPACE
79
80#endif
81

source code of qtmultimedia/src/multimedia/video/qabstractvideobuffer_p.h