1// Copyright (C) 2016 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 QMEDIAMETADATA_H
5#define QMEDIAMETADATA_H
6
7#if 0
8#pragma qt_class(QMediaMetaData)
9#endif
10
11#include <QtCore/qpair.h>
12#include <QtCore/qvariant.h>
13#include <QtCore/qstring.h>
14#include <QtCore/qhash.h>
15#include <QtMultimedia/qtmultimediaglobal.h>
16
17QT_BEGIN_NAMESPACE
18
19// Class forward declaration required for QDoc bug
20class QString;
21
22class Q_MULTIMEDIA_EXPORT QMediaMetaData
23{
24 Q_GADGET
25public:
26 enum Key {
27 Title,
28 Author,
29 Comment,
30 Description,
31 Genre,
32 Date,
33
34 Language,
35 Publisher,
36 Copyright,
37 Url,
38
39 Duration,
40 MediaType,
41 FileFormat,
42
43 AudioBitRate,
44 AudioCodec,
45 VideoBitRate,
46 VideoCodec,
47 VideoFrameRate,
48
49 AlbumTitle,
50 AlbumArtist,
51 ContributingArtist,
52 TrackNumber,
53 Composer,
54 LeadPerformer,
55
56 ThumbnailImage,
57 CoverArtImage,
58
59 Orientation,
60 Resolution,
61
62 HasHdrContent,
63 };
64 Q_ENUM(Key)
65
66 static constexpr int NumMetaData = HasHdrContent + 1;
67
68// QMetaType typeForKey(Key k);
69 Q_INVOKABLE QVariant value(Key k) const { return data.value(key: k); }
70 Q_INVOKABLE void insert(Key k, const QVariant &value) { data.insert(key: k, value); }
71 Q_INVOKABLE void remove(Key k) { data.remove(key: k); }
72 Q_INVOKABLE QList<Key> keys() const { return data.keys(); }
73
74 QVariant &operator[](Key k) { return data[k]; }
75 Q_INVOKABLE void clear() { data.clear(); }
76
77 Q_INVOKABLE bool isEmpty() const { return data.isEmpty(); }
78 Q_INVOKABLE QString stringValue(Key k) const;
79
80 Q_INVOKABLE static QString metaDataKeyToString(Key k);
81
82 QT_TECH_PREVIEW_API auto asKeyValueRange() const { return data.asKeyValueRange(); }
83
84protected:
85 Q_MULTIMEDIA_EXPORT friend QDebug operator<<(QDebug, const QMediaMetaData &);
86
87 friend bool operator==(const QMediaMetaData &a, const QMediaMetaData &b)
88 { return a.data == b.data; }
89 friend bool operator!=(const QMediaMetaData &a, const QMediaMetaData &b)
90 { return a.data != b.data; }
91
92 static QMetaType keyType(Key key);
93
94 QHash<Key, QVariant> data;
95};
96
97QT_END_NAMESPACE
98
99Q_DECLARE_METATYPE(QMediaMetaData)
100
101#endif // QMEDIAMETADATA_H
102

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtmultimedia/src/multimedia/qmediametadata.h