1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2023 LoRd_MuldeR <MuldeR2@GMX.de>
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; always including the non-optional
9 // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
26 #include <QReadWriteLock>
27 #include <QWaitCondition>
28 #include <QStringList>
35 class QXmlStreamReader;
36 class QXmlStreamAttributes;
38 ////////////////////////////////////////////////////////////
40 ////////////////////////////////////////////////////////////
42 class AnalyzeTask: public QObject, public QRunnable
47 AnalyzeTask(const int taskId, const QString &inputFile, QAtomicInt &abortFlag);
71 propertyId_container_profile,
77 propertyId_released_date,
78 propertyId_track_position,
81 propertyId_format_version,
82 propertyId_format_profile,
83 propertyId_channel_s_,
84 propertyId_samplingrate,
87 propertyId_bitrate_mode,
88 propertyId_encoded_library,
89 propertyId_cover_mime,
95 void fileAnalyzed(const unsigned int taskId, const int fileType, const AudioFileModel &file);
96 void taskCompleted(const unsigned int taskId);
103 const AudioFileModel& analyzeFile(const QString &filePath, AudioFileModel &audioFile, int *const type);
104 const AudioFileModel& analyzeMediaFile(const QString &filePath, AudioFileModel &audioFile);
105 const AudioFileModel& parseMediaInfo(const QByteArray &data, AudioFileModel &audioFile);
106 void parseFileInfo(QXmlStreamReader &xmlStream, AudioFileModel &audioFile);
107 void parseTrackInfo(QXmlStreamReader &xmlStream, const MI_trackType_t trackType, AudioFileModel &audioFile);
108 void parseProperty(const QString &value, const MI_propertyId_t propertyIdx, AudioFileModel &audioFile, QString &coverMimeType);
109 void retrieveCover(AudioFileModel &audioFile, const QString &coverType, const QString &coverData);
110 bool checkFile_CDDA(QFile &file);
111 bool analyzeAvisynthFile(const QString &filePath, AudioFileModel &info);
113 static QString decodeStr(const QString &str, const QString &encoding);
114 static bool parseUnsigned(const QString &str, quint32 &value);
115 static bool parseFloat(const QString &str, double &value);
116 static bool parseYear(const QString &st, quint32 &valuer);
117 static bool parseRCMode(const QString &str, quint32 &value);
118 static QString cleanAsciiStr(const QString &str);
119 static bool findNextElement(const QString &name, QXmlStreamReader &xmlStream);
120 static QString findAttribute(const QString &name, const QXmlStreamAttributes &xmlAttributes);
121 static bool checkVersionStr(const QString &str, const quint32 expectedMajor, const quint32 expectedMinor);
123 const QMap<QPair<MI_trackType_t, QString>, MI_propertyId_t> &m_mediaInfoIdx;
124 const QMap<QString, MI_propertyId_t> &m_avisynthIdx;
125 const QMap<QString, QString> &m_mimeTypes;
126 const QMap<QString, MI_trackType_t> &m_trackTypes;
128 const unsigned int m_taskId;
129 const QString m_mediaInfoBin;
130 const quint32 m_mediaInfoVer;
131 const QString m_avs2wavBin;
132 const QString m_inputFile;
134 QAtomicInt &m_abortFlag;