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 <QtFFmpegMediaPluginImpl/private/qffmpegplaybackengineobject_p.h>
17#include <QtFFmpegMediaPluginImpl/private/qffmpegframe_p.h>
18#include <QtFFmpegMediaPluginImpl/private/qffmpegpacket_p.h>
19#include <QtFFmpegMediaPluginImpl/private/qffmpegplaybackutils_p.h>
20#include <QtMultimedia/private/qplatformmediaplayer_p.h>
21
22#include <QtCore/qqueue.h>
23
24#include <optional>
25
26QT_BEGIN_NAMESPACE
27
28namespace QFFmpeg {
29
30class StreamDecoder : public PlaybackEngineObject
31{
32 Q_OBJECT
33public:
34 StreamDecoder(const CodecContext &codecContext, TrackPosition absSeekPos);
35
36 ~StreamDecoder() override;
37
38 QPlatformMediaPlayer::TrackType trackType() const;
39
40 // Maximum number of frames that we are allowed to keep in render queue
41 static qint32 maxQueueSize(QPlatformMediaPlayer::TrackType type);
42
43public slots:
44
45 void decode(Packet);
46
47 void onFinalPacketReceived();
48
49 void onFrameProcessed(Frame frame);
50
51signals:
52 void requestHandleFrame(Frame frame);
53
54 void packetProcessed(Packet);
55
56protected:
57 bool canDoNextStep() const override;
58
59 void doNextStep() override;
60
61private:
62 void decodeMedia(Packet);
63
64 void decodeSubtitle(Packet);
65
66 void onFrameFound(Frame frame);
67
68 int sendAVPacket(Packet);
69
70 void receiveAVFrames(bool flushPacket = false);
71
72private:
73 CodecContext m_codecContext;
74 TrackPosition m_absSeekPos = TrackPosition(0);
75 const QPlatformMediaPlayer::TrackType m_trackType;
76
77 qint32 m_pendingFramesCount = 0;
78
79 LoopOffset m_offset;
80
81 QQueue<Packet> m_packets;
82};
83
84} // namespace QFFmpeg
85
86QT_END_NAMESPACE
87
88#endif // QFFMPEGSTREAMDECODER_P_H
89

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/playbackengine/qffmpegstreamdecoder_p.h