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 "private/qplatformmediaplayer_p.h"
20#include "qffmpeg_p.h"
21#include "qvideoframe.h"
22#include <private/qmultimediautils_p.h>
23
24#include <array>
25#include <optional>
26
28
29namespace QFFmpeg {
30
32{
33 virtual ~ICancelToken() = default;
34 virtual bool isCancelled() const = 0;
35};
36
38
40{
41public:
43 {
44 int avStreamIndex = -1;
45 bool isDefault = false;
47 };
48
50 {
51 int code = 0;
52 QString description;
53 };
54
57
58 MediaDataHolder() = default;
59 MediaDataHolder(AVFormatContextUPtr context, const std::shared_ptr<ICancelToken> &cancelToken);
60
62
63 int activeTrack(QPlatformMediaPlayer::TrackType type) const;
64
65 const QList<StreamInfo> &streamInfo(QPlatformMediaPlayer::TrackType trackType) const;
66
67 qint64 duration() const { return m_duration; }
68
69 const QMediaMetaData &metaData() const { return m_metaData; }
70
71 bool isSeekable() const { return m_isSeekable; }
72
74
75 AVFormatContext *avContext();
76
77 int currentStreamIndex(QPlatformMediaPlayer::TrackType trackType) const;
78
80 static Maybe create(const QUrl &url, QIODevice *stream,
81 const std::shared_ptr<ICancelToken> &cancelToken);
82
83 bool setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber);
84
85private:
86 void updateMetaData();
87
88 std::shared_ptr<ICancelToken> m_cancelToken; // NOTE: Cancel token may be accessed by
89 // AVFormatContext during destruction and
90 // must outlive the context object
91 AVFormatContextUPtr m_context;
92
93 bool m_isSeekable = false;
94
95 StreamIndexes m_currentAVStreamIndex = { -1, -1, -1 };
96 StreamsMap m_streamMap;
97 StreamIndexes m_requestedStreams = { -1, -1, -1 };
98 qint64 m_duration = 0;
99 QMediaMetaData m_metaData;
100 std::optional<QImage> m_cachedThumbnail;
101};
102
103} // namespace QFFmpeg
104
106
107#endif // QFFMPEGMEDIADATAHOLDER_P_H
MediaDataHolder(AVFormatContextUPtr context, const std::shared_ptr< ICancelToken > &cancelToken)
bool setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber)
static Maybe create(const QUrl &url, QIODevice *stream, const std::shared_ptr< ICancelToken > &cancelToken)
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
Definition qlist.h:76
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< qint64 > streamDuration(const AVStream &stream)
int64_t seekQIODevice(void *opaque, int64_t offset, int whence)
static QTransform displayMatrixToTransform(const int32_t *displayMatrix)
int readQIODevice(void *opaque, uint8_t *buf, int buf_size)
const AVPacketSideData * streamSideData(const AVStream *stream, AVPacketSideDataType type)
Definition qffmpeg.cpp:121
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
virtual bool isCancelled() const =0
virtual ~ICancelToken()=default