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
qffmpegdemuxer_p.h
Go to the documentation of this file.
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 QFFMPEGDEMUXER_P_H
4#define QFFMPEGDEMUXER_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
17#include <QtFFmpegMediaPluginImpl/private/qffmpegplaybackengineobject_p.h>
18#include <QtFFmpegMediaPluginImpl/private/qffmpegpacket_p.h>
19#include <QtFFmpegMediaPluginImpl/private/qffmpegplaybackutils_p.h>
20#include <QtFFmpegMediaPluginImpl/private/qffmpegtime_p.h>
21#include <QtMultimedia/private/qplatformmediaplayer_p.h>
22
23#include <unordered_map>
24
25QT_BEGIN_NAMESPACE
26
27namespace QFFmpeg {
28
30{
32public:
35 int loops);
36
37 using RequestingSignal = void (Demuxer::*)(Packet);
38 static RequestingSignal signalByTrackType(QPlatformMediaPlayer::TrackType trackType);
39
40 void setLoops(int loopsCount);
41
42public slots:
44
49 void firstPacketFound(PlaybackEngineObjectID id, TrackPosition absSeekPos);
51
52protected:
53 TimePoint nextTimePoint() const override;
54
55private:
56 bool canDoNextStep() const override;
57
58 void doNextStep() override;
59
60 void ensureSeeked();
61
62private:
63 struct StreamData
64 {
65 QPlatformMediaPlayer::TrackType trackType = QPlatformMediaPlayer::TrackType::NTrackTypes;
66 TrackDuration bufferedDuration = TrackDuration(0);
67 qint64 bufferedSize = 0;
68
69 TrackPosition maxSentPacketsPos = TrackPosition(0);
70 TrackPosition maxProcessedPacketPos = TrackPosition(0);
71
72 bool isDataLimitReached = false;
73 };
74
75 void updateStreamDataLimitFlag(StreamData &streamData);
76
77private:
78 AVFormatContext *m_context = nullptr;
79 bool m_seeked = false;
80 bool m_firstPacketFound = false;
81 std::unordered_map<int, StreamData> m_streams;
82 TrackPosition m_posInLoopUs = TrackPosition(0); // Position in current loop in [0, duration()]
83 LoopOffset m_loopOffset;
84 TrackPosition m_maxPacketsEndPos = TrackPosition(0);
85 QAtomicInt m_loops = QMediaPlayer::Once;
86 bool m_buffered = false;
87 qsizetype m_demuxerRetryCount = 0;
88 std::optional<TimePoint> m_failTimePoint;
89 static constexpr qsizetype s_maxDemuxerRetries = 10; // Arbitrarily chosen
90 static constexpr std::chrono::milliseconds s_demuxerRetryInterval = std::chrono::milliseconds(10);
91};
92
93} // namespace QFFmpeg
94
95QT_END_NAMESPACE // QFFMPEGDEMUXER_P_H
96
97#endif
void packetsBuffered()
void setLoops(int loopsCount)
void doNextStep() override
void firstPacketFound(PlaybackEngineObjectID id, TrackPosition absSeekPos)
void requestProcessVideoPacket(Packet)
void(Demuxer::*)(Packet) RequestingSignal
void requestProcessSubtitlePacket(Packet)
static RequestingSignal signalByTrackType(QPlatformMediaPlayer::TrackType trackType)
bool canDoNextStep() const override
TimePoint nextTimePoint() const override
static constexpr TrackDuration MaxBufferedDurationUs
static constexpr qint64 MaxBufferedSize
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
static TrackPosition packetEndPos(const Packet &packet, const AVStream *stream, const AVFormatContext *context)
static bool isPacketWithinStreamDuration(const AVFormatContext *context, const Packet &packet)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)