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
qffmpegmediadataholder_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
4#ifndef QFFMPEGMEDIADATAHOLDER_P_H
5#define QFFMPEGMEDIADATAHOLDER_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 "qmediametadata.h"
19#include <QtFFmpegMediaPluginImpl/private/qffmpegtime_p.h>
20#include <QtMultimedia/private/qplatformmediaplayer_p.h>
21#include <QtFFmpegMediaPluginImpl/private/qffmpeg_p.h>
22#include "qvideoframe.h"
23#include <QtMultimedia/private/qmultimediautils_p.h>
24
25#include <array>
26#include <optional>
27
28QT_BEGIN_NAMESPACE
29
30namespace QFFmpeg {
31
33{
34 virtual ~ICancelToken() = default;
35 virtual bool isCancelled() const = 0;
36};
37
39
41{
42public:
44 {
45 int avStreamIndex = -1;
46 bool isDefault = false;
48 };
49
51 {
52 int code = 0;
53 QString description;
54 };
55
58
59 MediaDataHolder() = default;
60 MediaDataHolder(AVFormatContextUPtr context, const std::shared_ptr<ICancelToken> &cancelToken);
61
63
64 int activeTrack(QPlatformMediaPlayer::TrackType type) const;
65
66 const QList<StreamInfo> &streamInfo(QPlatformMediaPlayer::TrackType trackType) const;
67
68 TrackDuration duration() const { return m_duration; }
69
70 const QMediaMetaData &metaData() const { return m_metaData; }
71
72 bool isSeekable() const { return m_isSeekable; }
73
75
77
78 int currentStreamIndex(QPlatformMediaPlayer::TrackType trackType) const;
79
81 static Maybe create(const QUrl &url, QIODevice *stream, const QPlaybackOptions &options,
82 const std::shared_ptr<ICancelToken> &cancelToken);
83
84 bool setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber);
85
86private:
87 void updateMetaData();
88
89 std::shared_ptr<ICancelToken> m_cancelToken; // NOTE: Cancel token may be accessed by
90 // AVFormatContext during destruction and
91 // must outlive the context object
92 AVFormatContextUPtr m_context;
93
94 bool m_isSeekable = false;
95
96 StreamIndexes m_currentAVStreamIndex = { -1, -1, -1 };
97 StreamsMap m_streamMap;
98 StreamIndexes m_requestedStreams = { -1, -1, -1 };
99 TrackDuration m_duration = TrackDuration(0);
100 QMediaMetaData m_metaData;
101 std::optional<QImage> m_cachedThumbnail;
102};
103
104} // namespace QFFmpeg
105
106QT_END_NAMESPACE
107
108#endif // QFFMPEGMEDIADATAHOLDER_P_H
MediaDataHolder(AVFormatContextUPtr context, const std::shared_ptr< ICancelToken > &cancelToken)
bool setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber)
int currentStreamIndex(QPlatformMediaPlayer::TrackType trackType) const
VideoTransformation transformation() const
const QMediaMetaData & metaData() const
static QPlatformMediaPlayer::TrackType trackTypeFromMediaType(int mediaType)
const QList< StreamInfo > & streamInfo(QPlatformMediaPlayer::TrackType trackType) const
int activeTrack(QPlatformMediaPlayer::TrackType type) const
static Maybe create(const QUrl &url, QIODevice *stream, const QPlaybackOptions &options, const std::shared_ptr< ICancelToken > &cancelToken)
Definition qlist.h:80
static VideoTransformation streamTransformation(const AVStream *stream)
static bool colorTransferSupportsHdr(const AVStream *stream)
static void insertMediaData(QMediaMetaData &metaData, QPlatformMediaPlayer::TrackType trackType, const AVStream *stream)
static std::optional< TrackDuration > streamDuration(const AVStream &stream)
static QTransform displayMatrixToTransform(const int32_t *displayMatrix)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
virtual bool isCancelled() const =0
virtual ~ICancelToken()=default