Qmmp
Loading...
Searching...
No Matches
qmmp.h
1/***************************************************************************
2 * Copyright (C) 2008-2025 by Ilya Kotov *
3 * forkotov02@ya.ru *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#ifndef QMMP_H
21#define QMMP_H
22
23#include <QString>
24#include <QLoggingCategory>
25#include "qmmp_export.h"
26
27#define QMMP_VERSION_MAJOR 2
28#define QMMP_VERSION_MINOR 3
29#define QMMP_VERSION_PATCH 1
30#define QMMP_VERSION_STABLE 1
31
32#define QMMP_VERSION_INT (QMMP_VERSION_MAJOR<<16 | QMMP_VERSION_MINOR<<8 | QMMP_VERSION_PATCH)
33
37#ifdef Q_OS_WIN
38#define QStringToFileName(s) TagLib::FileName(reinterpret_cast<const wchar_t *>(s.utf16()))
39#else
40#define QStringToFileName(s) s.toLocal8Bit().constData()
41#endif
42
43#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
44
45#include <QLatin1String>
46
47namespace Qt {
48inline namespace Literals {
49inline namespace StringLiterals {
50
51inline QString operator""_s(const char16_t *str, size_t size) noexcept
52{
53 return QString(QStringPrivate(nullptr, const_cast<char16_t *>(str), qsizetype(size)));
54}
55
56constexpr inline QLatin1String operator""_L1(const char *str, size_t size) noexcept
57{
58 return QLatin1String(str, int(size));
59}
60
61inline QByteArray operator""_ba(const char *str, size_t size) noexcept
62{
63 return QByteArray(QByteArrayData(nullptr, const_cast<char *>(str), qsizetype(size)));
64}
65
66} // StringLiterals
67} // Literals
68} // Qt
69
70using QLatin1StringView = QLatin1String;
71
72#endif
73
74using namespace Qt::Literals::StringLiterals;
75
76QMMP_EXPORT Q_DECLARE_LOGGING_CATEGORY(core)
77QMMP_EXPORT Q_DECLARE_LOGGING_CATEGORY(plugin)
78
79#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
80#define qCFatal qCCritical
81#endif
82
83
87class QMMP_EXPORT Qmmp
88{
89public:
93 enum State
94 {
95 Playing = 0,
96 Paused,
97 Stopped,
98 Buffering,
99 NormalError,
100 FatalError
101 };
105 enum MetaData
106 {
107 UNKNOWN = -1,
108 TITLE = 0,
109 ARTIST,
110 ALBUMARTIST,
111 ALBUM,
112 COMMENT,
113 GENRE,
114 COMPOSER,
115 YEAR,
116 TRACK,
117 DISCNUMBER
118 };
122 enum TrackProperty
123 {
124 UNKNOWN_PROPERTY = -1,
125 BITRATE = 0,
126 SAMPLERATE,
127 CHANNELS,
128 BITS_PER_SAMPLE,
129 FORMAT_NAME,
130 DECODER,
131 FILE_SIZE
132 };
136 enum ReplayGainKey
137 {
138 REPLAYGAIN_TRACK_GAIN = 0,
139 REPLAYGAIN_TRACK_PEAK,
140 REPLAYGAIN_ALBUM_GAIN,
141 REPLAYGAIN_ALBUM_PEAK
142 };
146 enum AudioFormat
147 {
148 PCM_UNKNOWN = -1,
149 PCM_S8 = 0,
150 PCM_U8,
151 PCM_S16LE,
152 PCM_S16BE,
153 PCM_U16LE,
154 PCM_U16BE,
155 PCM_S24LE,
156 PCM_S24BE,
157 PCM_U24LE,
158 PCM_U24BE,
159 PCM_S32LE,
160 PCM_S32BE,
161 PCM_U32LE,
162 PCM_U32BE,
163 PCM_FLOAT
164 };
165
169 enum ChannelPosition
170 {
171 CHAN_NULL = 0x00,
172 CHAN_FRONT_LEFT = 0x01,
173 CHAN_FRONT_RIGHT = 0x02,
174 CHAN_REAR_LEFT = 0x04,
175 CHAN_REAR_RIGHT = 0x08,
176 CHAN_FRONT_CENTER = 0x10,
177 CHAN_REAR_CENTER = 0x20,
178 CHAN_SIDE_LEFT = 0x40,
179 CHAN_SIDE_RIGHT = 0x80,
180 CHAN_LFE = 0x100,
181 };
185 static QString configDir();
189 static void setConfigDir(const QString &path);
193 static QString cacheDir();
197 static QString strVersion();
201 static QString pluginPath();
206 static QStringList findPlugins(const QString &prefix);
210 static QString systemLanguageID();
214 static QString uiLanguageID();
219 static void setUiLanguageID(const QString &code);
223 static QString dataPath();
228 static QString userDataPath();
229#ifdef Q_OS_WIN
233 static bool isPortable();
234#endif
235
236private:
237 static QString m_configDir;
238 static QString m_langID;
239#ifdef Q_OS_WIN
240 static QString m_appDir;
241#endif
242
243};
244
245#endif