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 Q_ENUM(Key)
63
64 static constexpr int NumMetaData = Resolution + 1;
65
66// QMetaType typeForKey(Key k);
67 Q_INVOKABLE QVariant value(Key k) const { return data.value(key: k); }
68 Q_INVOKABLE void insert(Key k, const QVariant &value) { data.insert(key: k, value); }
69 Q_INVOKABLE void remove(Key k) { data.remove(key: k); }
70 Q_INVOKABLE QList<Key> keys() const { return data.keys(); }
71
72 QVariant &operator[](Key k) { return data[k]; }
73 Q_INVOKABLE void clear() { data.clear(); }
74
75 Q_INVOKABLE bool isEmpty() const { return data.isEmpty(); }
76 Q_INVOKABLE QString stringValue(Key k) const;
77
78 Q_INVOKABLE static QString metaDataKeyToString(Key k);
79
80protected:
81 friend bool operator==(const QMediaMetaData &a, const QMediaMetaData &b)
82 { return a.data == b.data; }
83 friend bool operator!=(const QMediaMetaData &a, const QMediaMetaData &b)
84 { return a.data != b.data; }
85
86 static QMetaType keyType(Key key);
87
88 QHash<Key, QVariant> data;
89};
90
91QT_END_NAMESPACE
92
93Q_DECLARE_METATYPE(QMediaMetaData)
94
95#endif // QMEDIAMETADATA_H
96

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