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
qmediaformat.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 QMEDIAFORMAT_H
5#define QMEDIAFORMAT_H
6
7#include <QtCore/qsharedpointer.h>
8#include <QtMultimedia/qtmultimediaglobal.h>
9
11
12class QMimeType;
13class QMediaFormat;
15
16QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QMediaFormatPrivate, Q_MULTIMEDIA_EXPORT)
17
18class Q_MULTIMEDIA_EXPORT QMediaFormat
19{
20 Q_GADGET
21 Q_PROPERTY(FileFormat fileFormat READ fileFormat WRITE setFileFormat)
22 Q_PROPERTY(AudioCodec audioCodec READ audioCodec WRITE setAudioCodec)
23 Q_PROPERTY(VideoCodec videoCodec READ videoCodec WRITE setVideoCodec)
24 Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
25public:
26 enum FileFormat {
27 UnspecifiedFormat = -1,
28 // Video Formats
29 WMV,
30 AVI,
31 Matroska,
32 MPEG4,
33 Ogg,
34 QuickTime,
35 WebM,
36 // Audio Only Formats
37 Mpeg4Audio,
38 AAC,
39 WMA,
40 MP3,
41 FLAC,
42 Wave,
43 LastFileFormat = Wave
44 };
45 Q_ENUM(FileFormat)
46
47 enum class AudioCodec {
48 Unspecified = -1,
49 MP3,
50 AAC,
51 AC3,
52 EAC3,
53 FLAC,
54 DolbyTrueHD,
55 Opus,
56 Vorbis,
57 Wave,
58 WMA,
59 ALAC,
60 LastAudioCodec = ALAC
61 };
62 Q_ENUM(AudioCodec)
63
64 enum class VideoCodec {
65 Unspecified = -1,
66 MPEG1,
67 MPEG2,
68 MPEG4,
69 H264,
70 H265,
71 VP8,
72 VP9,
73 AV1,
74 Theora,
75 WMV,
76 MotionJPEG,
77 LastVideoCodec = MotionJPEG
78 };
79 Q_ENUM(VideoCodec)
80
81 enum ConversionMode {
82 Encode,
83 Decode
84 };
85 Q_ENUM(ConversionMode)
86
87 enum ResolveFlags
88 {
89 NoFlags,
90 RequiresVideo
91 };
92
93 QMediaFormat(FileFormat format = UnspecifiedFormat);
94 ~QMediaFormat();
95 QMediaFormat(const QMediaFormat &other) noexcept;
96 QMediaFormat &operator=(const QMediaFormat &other) noexcept;
97
98 QMediaFormat(QMediaFormat &&other) noexcept = default;
99 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QMediaFormat)
100 void swap(QMediaFormat &other) noexcept
101 {
102 std::swap(fmt, other.fmt);
103 std::swap(audio, other.audio);
104 std::swap(video, other.video);
105 d.swap(other.d);
106 }
107
108 FileFormat fileFormat() const { return fmt; }
109 void setFileFormat(FileFormat f) { fmt = f; }
110
111 void setVideoCodec(VideoCodec codec) { video = codec; }
112 VideoCodec videoCodec() const { return video; }
113
114 void setAudioCodec(AudioCodec codec) { audio = codec; }
115 AudioCodec audioCodec() const { return audio; }
116
117 Q_INVOKABLE bool isSupported(ConversionMode mode) const;
118
119 QMimeType mimeType() const;
120
121 Q_INVOKABLE QList<FileFormat> supportedFileFormats(ConversionMode m);
122 Q_INVOKABLE QList<VideoCodec> supportedVideoCodecs(ConversionMode m);
123 Q_INVOKABLE QList<AudioCodec> supportedAudioCodecs(ConversionMode m);
124
125 Q_INVOKABLE static QString fileFormatName(FileFormat fileFormat);
126 Q_INVOKABLE static QString audioCodecName(AudioCodec codec);
127 Q_INVOKABLE static QString videoCodecName(VideoCodec codec);
128
129 Q_INVOKABLE static QString fileFormatDescription(QMediaFormat::FileFormat fileFormat);
130 Q_INVOKABLE static QString audioCodecDescription(QMediaFormat::AudioCodec codec);
131 Q_INVOKABLE static QString videoCodecDescription(QMediaFormat::VideoCodec codec);
132
133 bool operator==(const QMediaFormat &other) const;
134 bool operator!=(const QMediaFormat &other) const
135 { return !operator==(other); }
136
137 void resolveForEncoding(ResolveFlags flags);
138
139protected:
140 friend class QMediaFormatPrivate;
141 FileFormat fmt;
142 AudioCodec audio = AudioCodec::Unspecified;
143 VideoCodec video = VideoCodec::Unspecified;
144 QExplicitlySharedDataPointer<QMediaFormatPrivate> d;
145};
146
147QT_END_NAMESPACE
148
149#endif
\inmodule QtMultimedia
Combined button and popup list for selecting options.