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 | #ifndef QFFMPEGSTREAMDECODER_P_H |
4 | #define QFFMPEGSTREAMDECODER_P_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is not part of the Qt API. It exists purely as an |
11 | // implementation detail. This header file may change from version to |
12 | // version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | #include "playbackengine/qffmpegplaybackengineobject_p.h" |
17 | #include "playbackengine/qffmpegframe_p.h" |
18 | #include "playbackengine/qffmpegpacket_p.h" |
19 | #include "playbackengine/qffmpegpositionwithoffset_p.h" |
20 | #include "private/qplatformmediaplayer_p.h" |
21 | |
22 | #include <optional> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | namespace QFFmpeg { |
27 | |
28 | class StreamDecoder : public PlaybackEngineObject |
29 | { |
30 | Q_OBJECT |
31 | public: |
32 | StreamDecoder(const Codec &codec, qint64 absSeekPos); |
33 | |
34 | ~StreamDecoder(); |
35 | |
36 | QPlatformMediaPlayer::TrackType trackType() const; |
37 | |
38 | // Maximum number of frames that we are allowed to keep in render queue |
39 | static qint32 maxQueueSize(QPlatformMediaPlayer::TrackType type); |
40 | |
41 | public slots: |
42 | void setInitialPosition(TimePoint tp, qint64 trackPos); |
43 | |
44 | void decode(Packet); |
45 | |
46 | void onFinalPacketReceived(); |
47 | |
48 | void onFrameProcessed(Frame frame); |
49 | |
50 | signals: |
51 | void requestHandleFrame(Frame frame); |
52 | |
53 | void packetProcessed(Packet); |
54 | |
55 | protected: |
56 | bool canDoNextStep() const override; |
57 | |
58 | void doNextStep() override; |
59 | |
60 | private: |
61 | void decodeMedia(Packet); |
62 | |
63 | void decodeSubtitle(Packet); |
64 | |
65 | void onFrameFound(Frame frame); |
66 | |
67 | int sendAVPacket(Packet); |
68 | |
69 | void receiveAVFrames(bool flushPacket = false); |
70 | |
71 | private: |
72 | Codec m_codec; |
73 | qint64 m_absSeekPos = 0; |
74 | const QPlatformMediaPlayer::TrackType m_trackType; |
75 | |
76 | qint32 m_pendingFramesCount = 0; |
77 | |
78 | LoopOffset m_offset; |
79 | |
80 | QQueue<Packet> m_packets; |
81 | }; |
82 | |
83 | } // namespace QFFmpeg |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif // QFFMPEGSTREAMDECODER_P_H |
88 |