| 1 | // Copyright (C) 2021 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 QFFMPEGPACKET_P_H |
| 5 | #define QFFMPEGPACKET_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 <QtFFmpegMediaPluginImpl/private/qffmpeg_p.h> |
| 19 | #include <QtFFmpegMediaPluginImpl/private/qffmpegplaybackutils_p.h> |
| 20 | #include <QtCore/qshareddata.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | namespace QFFmpeg { |
| 25 | |
| 26 | struct Packet |
| 27 | { |
| 28 | struct Data : QSharedData |
| 29 | { |
| 30 | Data(const LoopOffset &offset, AVPacketUPtr p, quint64 sourceId) |
| 31 | : loopOffset(offset), packet(std::move(p)), sourceId(sourceId) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | LoopOffset loopOffset; |
| 36 | AVPacketUPtr packet; |
| 37 | quint64 sourceId; |
| 38 | }; |
| 39 | Packet() = default; |
| 40 | Packet(const LoopOffset &offset, AVPacketUPtr p, quint64 sourceId) |
| 41 | : d(new Data(offset, std::move(p), sourceId)) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | bool isValid() const { return !!d; } |
| 46 | AVPacket *avPacket() const { return d->packet.get(); } |
| 47 | const LoopOffset &loopOffset() const { return d->loopOffset; } |
| 48 | quint64 sourceId() const { return d->sourceId; } |
| 49 | |
| 50 | private: |
| 51 | QExplicitlySharedDataPointer<Data> d; |
| 52 | }; |
| 53 | |
| 54 | } // namespace QFFmpeg |
| 55 | |
| 56 | QT_END_NAMESPACE |
| 57 | |
| 58 | Q_DECLARE_METATYPE(QFFmpeg::Packet) |
| 59 | |
| 60 | #endif // QFFMPEGPACKET_P_H |
| 61 |
