Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qvideoframe_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QVIDEOFRAME_P_H
5#define QVIDEOFRAME_P_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 "qvideoframe.h"
20#include "private/qvideotransformation_p.h"
21
22#include <qmutex.h>
23
25
27{
28public:
29 QVideoFramePrivate() = default;
30
32 {
33 if (videoBuffer && mapMode != QVideoFrame::NotMapped)
34 videoBuffer->unmap();
35 }
36
37 template <typename Buffer>
38 static QVideoFrame createFrame(std::unique_ptr<Buffer> buffer, QVideoFrameFormat format)
39 {
40 QVideoFrame result;
41 result.d.reset(new QVideoFramePrivate(std::move(format), std::move(buffer)));
42 return result;
43 }
44
45 template <typename Buffer = QAbstractVideoBuffer>
46 QVideoFramePrivate(QVideoFrameFormat format, std::unique_ptr<Buffer> buffer = nullptr)
48 {
49 if constexpr (std::is_base_of_v<QHwVideoBuffer, Buffer>)
50 hwVideoBuffer = static_cast<QHwVideoBuffer *>(videoBuffer.get());
51 else if constexpr (std::is_same_v<QAbstractVideoBuffer, Buffer>)
52 hwVideoBuffer = dynamic_cast<QHwVideoBuffer *>(videoBuffer.get());
53 // else hwVideoBuffer == nullptr
54 }
55
56 static QVideoFramePrivate *handle(QVideoFrame &frame) { return frame.d.get(); };
57
58 static QHwVideoBuffer *hwBuffer(const QVideoFrame &frame)
59 {
60 return frame.d ? frame.d->hwVideoBuffer : nullptr;
61 };
62
63 static QAbstractVideoBuffer *buffer(const QVideoFrame &frame)
64 {
65 return frame.d ? frame.d->videoBuffer.get() : nullptr;
66 };
67
69 {
70 QVideoFrame frame;
71 frame.d = QExplicitlySharedDataPointer(this, QAdoptSharedDataTag{});
72 return frame;
73 }
74
82 int mappedCount = 0;
83 QMutex mapMutex;
86 QMutex imageMutex;
88
89private:
91};
92
93QT_END_NAMESPACE
94
95#endif // QVIDEOFRAMEPRIVATE_P_H
QVideoFrameFormat format
QVideoFrame::MapMode mapMode
static QVideoFramePrivate * handle(QVideoFrame &frame)
static QAbstractVideoBuffer * buffer(const QVideoFrame &frame)
QAbstractVideoBuffer::MapData mapData
QVideoFramePrivate()=default
QHwVideoBuffer * hwVideoBuffer
QVideoFrame adoptThisByVideoFrame()
static QVideoFrame createFrame(std::unique_ptr< Buffer > buffer, QVideoFrameFormat format)
std::unique_ptr< QAbstractVideoBuffer > videoBuffer
VideoTransformation presentationTransformation
QVideoFramePrivate(QVideoFrameFormat format, std::unique_ptr< Buffer > buffer=nullptr)
static QHwVideoBuffer * hwBuffer(const QVideoFrame &frame)
Combined button and popup list for selecting options.
static QString qFormatTimeStamps(qint64 start, qint64 end)