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
formatutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
7
8std::set<QMediaFormat::VideoCodec> allVideoCodecs(bool includeUnspecified)
9{
10 using VideoCodec = QMediaFormat::VideoCodec;
11 std::set<VideoCodec> codecs;
12
13 const int firstCodec = qToUnderlying(VideoCodec::Unspecified) + (includeUnspecified ? 0 : 1);
14 constexpr int lastCodec = qToUnderlying(VideoCodec::LastVideoCodec);
15
16 for (int i = firstCodec; i <= lastCodec; ++i)
17 codecs.insert(static_cast<VideoCodec>(i));
18
19 return codecs;
20}
21
22std::set<QMediaFormat::AudioCodec> allAudioCodecs(bool includeUnspecified)
23{
24 using AudioCodec = QMediaFormat::AudioCodec;
25 std::set<AudioCodec> codecs;
26
27 const int firstCodec = qToUnderlying(AudioCodec::Unspecified) + (includeUnspecified ? 0 : 1);
28 constexpr int lastCodec = qToUnderlying(AudioCodec::LastAudioCodec);
29
30 for (int i = firstCodec; i <= lastCodec; ++i)
31 codecs.insert(static_cast<AudioCodec>(i));
32
33 return codecs;
34}
35
36std::set<QMediaFormat::FileFormat> allFileFormats(bool includeUnspecified)
37{
38 using FileFormat = QMediaFormat::FileFormat;
39
40 std::set<FileFormat> videoFormats;
41 const int firstFormat = FileFormat::UnspecifiedFormat + (includeUnspecified ? 0 : 1);
42 for (int i = firstFormat; i <= FileFormat::LastFileFormat; ++i) {
43 const FileFormat format = static_cast<FileFormat>(i);
44 videoFormats.insert(format);
45 }
46 return videoFormats;
47}
48
49std::vector<QMediaFormat> allMediaFormats(bool includeUnspecified)
50{
51 std::vector<QMediaFormat> formats;
52 for (const auto &fileFormat : allFileFormats(includeUnspecified)) {
53 for (const auto &audioCodec : allAudioCodecs(includeUnspecified)) {
54 for (const auto &videoCodec : allVideoCodecs(includeUnspecified)) {
55 QMediaFormat format{ fileFormat };
56 format.setAudioCodec(audioCodec);
57 format.setVideoCodec(videoCodec);
58 formats.push_back(format);
59 }
60 }
61 }
62 return formats;
63}
64
65
66QT_END_NAMESPACE
QT_BEGIN_NAMESPACE std::set< QMediaFormat::VideoCodec > allVideoCodecs(bool includeUnspecified)
std::set< QMediaFormat::FileFormat > allFileFormats(bool includeUnspecified)
std::set< QMediaFormat::AudioCodec > allAudioCodecs(bool includeUnspecified)
std::vector< QMediaFormat > allMediaFormats(bool includeUnspecified)