Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
37using AVFormatContextUPtr = std::unique_ptr<AVFormatContext, AVDeleter<decltype(&avformat_close_input), &avformat_close_input>>;
38
40{
41public:
43 {
44 int avStreamIndex = -1;
45 bool isDefault = false;
47 };
48
50 {
51 int code = 0;
53 };
54
55 using StreamsMap = std::array<QList<StreamInfo>, QPlatformMediaPlayer::NTrackTypes>;
56 using StreamIndexes = std::array<int, QPlatformMediaPlayer::NTrackTypes>;
57
58 MediaDataHolder() = default;
59 MediaDataHolder(AVFormatContextUPtr context, const std::shared_ptr<ICancelToken> &cancelToken);
60
62
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
78
79 using Maybe = QMaybe<QSharedPointer<MediaDataHolder>, ContextError>;
81 const std::shared_ptr<ICancelToken> &cancelToken);
82
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)
QtVideo::Rotation rotation() const
const QList< StreamInfo > & streamInfo(QPlatformMediaPlayer::TrackType trackType) const
static QPlatformMediaPlayer::TrackType trackTypeFromMediaType(int mediaType)
int currentStreamIndex(QPlatformMediaPlayer::TrackType trackType) const
AVFormatContext * avContext()
const QMediaMetaData & metaData() const
std::array< int, QPlatformMediaPlayer::NTrackTypes > StreamIndexes
int activeTrack(QPlatformMediaPlayer::TrackType type) const
std::array< QList< StreamInfo >, QPlatformMediaPlayer::NTrackTypes > StreamsMap
static Maybe create(const QUrl &url, QIODevice *stream, const std::shared_ptr< ICancelToken > &cancelToken)
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtMultimedia
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
std::unique_ptr< AVFormatContext, AVDeleter< decltype(&avformat_close_input), &avformat_close_input > > AVFormatContextUPtr
std::array< int, 3 > StreamIndexes
Combined button and popup list for selecting options.
static void * context
EGLStreamKHR stream
GLenum type
long long qint64
Definition qtypes.h:60
QUrl url("example.com")
[constructor-url-reference]
virtual bool isCancelled() const =0
virtual ~ICancelToken()=default