1// Copyright (C) 2023 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 QV4L2MEMORYTRANSFER_P_H
5#define QV4L2MEMORYTRANSFER_P_H
6
7#include <private/qtmultimediaglobal_p.h>
8#include <qbytearray.h>
9#include <linux/videodev2.h>
10
11#include <memory>
12
13QT_BEGIN_NAMESPACE
14
15//
16// W A R N I N G
17// -------------
18//
19// This file is not part of the Qt API. It exists purely as an
20// implementation detail. This header file may change from version to
21// version without notice, or even be removed.
22//
23// We mean it.
24//
25
26class QV4L2FileDescriptor;
27using QV4L2FileDescriptorPtr = std::shared_ptr<QV4L2FileDescriptor>;
28
29class QV4L2MemoryTransfer
30{
31public:
32 struct Buffer
33 {
34 v4l2_buffer v4l2Buffer = {};
35 QByteArray data;
36 };
37
38 QV4L2MemoryTransfer(QV4L2FileDescriptorPtr fileDescriptor);
39
40 virtual ~QV4L2MemoryTransfer();
41
42 virtual std::optional<Buffer> dequeueBuffer() = 0;
43
44 virtual bool enqueueBuffer(quint32 index) = 0;
45
46 virtual quint32 buffersCount() const = 0;
47
48protected:
49 bool enqueueBuffers();
50
51 const QV4L2FileDescriptor &fileDescriptor() const { return *m_fileDescriptor; }
52
53private:
54 QV4L2FileDescriptorPtr m_fileDescriptor;
55};
56
57using QV4L2MemoryTransferUPtr = std::unique_ptr<QV4L2MemoryTransfer>;
58
59QV4L2MemoryTransferUPtr makeUserPtrMemoryTransfer(QV4L2FileDescriptorPtr fileDescriptor,
60 quint32 imageSize);
61
62QV4L2MemoryTransferUPtr makeMMapMemoryTransfer(QV4L2FileDescriptorPtr fileDescriptor);
63
64QT_END_NAMESPACE
65
66#endif // QV4L2MEMORYTRANSFER_P_H
67

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/qv4l2memorytransfer_p.h