Remove external tagreader
This commit is contained in:
27
src/tagreader/albumcovertagdata.cpp
Normal file
27
src/tagreader/albumcovertagdata.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "albumcovertagdata.h"
|
||||
|
||||
AlbumCoverTagData::AlbumCoverTagData(const QByteArray &_data, const QString &_mimetype)
|
||||
: data(_data),
|
||||
mimetype(_mimetype) {}
|
||||
34
src/tagreader/albumcovertagdata.h
Normal file
34
src/tagreader/albumcovertagdata.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ALBUMCOVERTAGDATA_H
|
||||
#define ALBUMCOVERTAGDATA_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
class AlbumCoverTagData {
|
||||
public:
|
||||
explicit AlbumCoverTagData(const QByteArray &_data = QByteArray(), const QString &_mimetype = QString());
|
||||
QByteArray data;
|
||||
QString mimetype;
|
||||
QString error;
|
||||
};
|
||||
|
||||
#endif // ALBUMCOVERTAGDATA_H
|
||||
32
src/tagreader/savetagcoverdata.cpp
Normal file
32
src/tagreader/savetagcoverdata.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "savetagcoverdata.h"
|
||||
|
||||
SaveTagCoverData::SaveTagCoverData(const QString &_cover_filename, const QByteArray &_cover_data, const QString &_cover_mimetype)
|
||||
: cover_filename(_cover_filename),
|
||||
cover_data(_cover_data),
|
||||
cover_mimetype(_cover_mimetype) {}
|
||||
|
||||
SaveTagCoverData::SaveTagCoverData(const QByteArray &_cover_data, const QString &_cover_mimetype)
|
||||
: cover_data(_cover_data),
|
||||
cover_mimetype(_cover_mimetype) {}
|
||||
35
src/tagreader/savetagcoverdata.h
Normal file
35
src/tagreader/savetagcoverdata.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SAVETAGCOVERDATA_H
|
||||
#define SAVETAGCOVERDATA_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
class SaveTagCoverData {
|
||||
public:
|
||||
SaveTagCoverData(const QString &_cover_filename = QString(), const QByteArray &_cover_data = QByteArray(), const QString &_cover_mimetype = QString());
|
||||
SaveTagCoverData(const QByteArray &_cover_data, const QString &_cover_mimetype = QString());
|
||||
QString cover_filename;
|
||||
QByteArray cover_data;
|
||||
QString cover_mimetype;
|
||||
};
|
||||
|
||||
#endif // SAVETAGCOVERDATA_H
|
||||
34
src/tagreader/savetagsoptions.h
Normal file
34
src/tagreader/savetagsoptions.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SAVETAGSOPTIONS_H
|
||||
#define SAVETAGSOPTIONS_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
enum class SaveTagsOption {
|
||||
NoType = 0,
|
||||
Tags = 1,
|
||||
Playcount = 2,
|
||||
Rating = 4,
|
||||
Cover = 8
|
||||
};
|
||||
Q_DECLARE_FLAGS(SaveTagsOptions, SaveTagsOption)
|
||||
|
||||
#endif // SAVETAGSOPTIONS_H
|
||||
110
src/tagreader/tagreaderbase.cpp
Normal file
110
src/tagreader/tagreaderbase.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QIODevice>
|
||||
#include <QFile>
|
||||
#include <QBuffer>
|
||||
#include <QImage>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderbase.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
TagReaderBase::TagReaderBase() = default;
|
||||
TagReaderBase::~TagReaderBase() = default;
|
||||
|
||||
float TagReaderBase::ConvertPOPMRating(const int POPM_rating) {
|
||||
|
||||
if (POPM_rating < 0x01) return 0.0F;
|
||||
if (POPM_rating < 0x40) return 0.20F;
|
||||
if (POPM_rating < 0x80) return 0.40F;
|
||||
if (POPM_rating < 0xC0) return 0.60F;
|
||||
if (POPM_rating < 0xFC) return 0.80F;
|
||||
|
||||
return 1.0F;
|
||||
|
||||
}
|
||||
|
||||
int TagReaderBase::ConvertToPOPMRating(const float rating) {
|
||||
|
||||
if (rating < 0.20) return 0x00;
|
||||
if (rating < 0.40) return 0x01;
|
||||
if (rating < 0.60) return 0x40;
|
||||
if (rating < 0.80) return 0x80;
|
||||
if (rating < 1.0) return 0xC0;
|
||||
|
||||
return 0xFF;
|
||||
|
||||
}
|
||||
|
||||
AlbumCoverTagData TagReaderBase::LoadAlbumCoverTagData(const QString &song_filename, const SaveTagCoverData &save_tag_cover_data) {
|
||||
|
||||
const QString &cover_filename = save_tag_cover_data.cover_filename;
|
||||
QByteArray cover_data = save_tag_cover_data.cover_data;
|
||||
QString cover_mimetype = save_tag_cover_data.cover_mimetype;
|
||||
|
||||
if (cover_data.isEmpty() && !cover_filename.isEmpty()) {
|
||||
qLog(Debug) << "Loading cover from" << cover_filename << "for" << song_filename;
|
||||
QFile file(cover_filename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qLog(Error) << "Failed to open file" << cover_filename << "for reading:" << file.errorString();
|
||||
return AlbumCoverTagData();
|
||||
}
|
||||
cover_data = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!cover_data.isEmpty()) {
|
||||
if (cover_mimetype.isEmpty()) {
|
||||
cover_mimetype = QMimeDatabase().mimeTypeForData(cover_data).name();
|
||||
}
|
||||
if (cover_mimetype == "image/jpeg"_L1) {
|
||||
qLog(Debug) << "Using cover from JPEG data for" << song_filename;
|
||||
return AlbumCoverTagData(cover_data, cover_mimetype);
|
||||
}
|
||||
if (cover_mimetype == "image/png"_L1) {
|
||||
qLog(Debug) << "Using cover from PNG data for" << song_filename;
|
||||
return AlbumCoverTagData(cover_data, cover_mimetype);
|
||||
}
|
||||
// Convert image to JPEG.
|
||||
qLog(Debug) << "Converting cover to JPEG data for" << song_filename;
|
||||
QImage cover_image;
|
||||
if (!cover_image.loadFromData(cover_data)) {
|
||||
qLog(Error) << "Failed to load image from cover data for" << song_filename;
|
||||
return AlbumCoverTagData();
|
||||
}
|
||||
cover_data.clear();
|
||||
QBuffer buffer(&cover_data);
|
||||
if (buffer.open(QIODevice::WriteOnly)) {
|
||||
cover_image.save(&buffer, "JPEG");
|
||||
buffer.close();
|
||||
}
|
||||
return AlbumCoverTagData(cover_data, u"image/jpeg"_s);
|
||||
}
|
||||
|
||||
return AlbumCoverTagData();
|
||||
|
||||
}
|
||||
61
src/tagreader/tagreaderbase.h
Normal file
61
src/tagreader/tagreaderbase.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERBASE_H
|
||||
#define TAGREADERBASE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tagreaderresult.h"
|
||||
#include "savetagsoptions.h"
|
||||
#include "savetagcoverdata.h"
|
||||
#include "albumcovertagdata.h"
|
||||
|
||||
class TagReaderBase {
|
||||
public:
|
||||
explicit TagReaderBase();
|
||||
virtual ~TagReaderBase();
|
||||
|
||||
virtual TagReaderResult IsMediaFile(const QString &filename) const = 0;
|
||||
|
||||
virtual TagReaderResult ReadFile(const QString &filename, Song *song) const = 0;
|
||||
virtual TagReaderResult WriteFile(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) const = 0;
|
||||
|
||||
virtual TagReaderResult LoadEmbeddedCover(const QString &filename, QByteArray &data) const = 0;
|
||||
virtual TagReaderResult SaveEmbeddedCover(const QString &filename, const SaveTagCoverData &save_tag_cover_data) const = 0;
|
||||
|
||||
virtual TagReaderResult SaveSongPlaycount(const QString &filename, const uint playcount) const = 0;
|
||||
virtual TagReaderResult SaveSongRating(const QString &filename, const float rating) const = 0;
|
||||
|
||||
protected:
|
||||
static float ConvertPOPMRating(const int POPM_rating);
|
||||
static int ConvertToPOPMRating(const float rating);
|
||||
|
||||
static AlbumCoverTagData LoadAlbumCoverTagData(const QString &song_filename, const SaveTagCoverData &save_tag_cover_data);
|
||||
|
||||
Q_DISABLE_COPY(TagReaderBase)
|
||||
};
|
||||
|
||||
#endif // TAGREADERBASE_H
|
||||
423
src/tagreader/tagreaderclient.cpp
Normal file
423
src/tagreader/tagreaderclient.cpp
Normal file
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QScopeGuard>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tagreaderclient.h"
|
||||
#include "tagreadertaglib.h"
|
||||
#include "tagreaderresult.h"
|
||||
#include "tagreaderrequest.h"
|
||||
#include "tagreaderismediafilerequest.h"
|
||||
#include "tagreaderreadfilerequest.h"
|
||||
#include "tagreaderwritefilerequest.h"
|
||||
#include "tagreaderloadcoverdatarequest.h"
|
||||
#include "tagreaderloadcoverimagerequest.h"
|
||||
#include "tagreadersavecoverrequest.h"
|
||||
#include "tagreadersaveplaycountrequest.h"
|
||||
#include "tagreadersaveratingrequest.h"
|
||||
#include "tagreaderreply.h"
|
||||
#include "tagreaderreadfilereply.h"
|
||||
#include "tagreaderloadcoverdatareply.h"
|
||||
#include "tagreaderloadcoverimagereply.h"
|
||||
|
||||
using std::dynamic_pointer_cast;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
TagReaderClient *TagReaderClient::sInstance = nullptr;
|
||||
|
||||
TagReaderClient::TagReaderClient(QObject *parent)
|
||||
: QObject(parent),
|
||||
original_thread_(thread()),
|
||||
abort_(false),
|
||||
processing_(false) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
||||
sInstance = this;
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::ExitAsync() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
abort_ = true;
|
||||
QMetaObject::invokeMethod(this, &TagReaderClient::Exit, Qt::QueuedConnection);
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::Exit() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
moveToThread(original_thread_);
|
||||
Q_EMIT ExitFinished();
|
||||
|
||||
}
|
||||
|
||||
bool TagReaderClient::HaveRequests() const {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_requests_);
|
||||
return !requests_.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::EnqueueRequest(TagReaderRequestPtr request) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_requests_);
|
||||
requests_.enqueue(request);
|
||||
}
|
||||
|
||||
if (!processing_.value()) {
|
||||
ProcessRequestsAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TagReaderRequestPtr TagReaderClient::DequeueRequest() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
{
|
||||
QMutexLocker l(&mutex_requests_);
|
||||
if (requests_.isEmpty()) return TagReaderRequestPtr();
|
||||
return requests_.dequeue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::ProcessRequestsAsync() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
QMetaObject::invokeMethod(this, &TagReaderClient::ProcessRequests, Qt::QueuedConnection);
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::ProcessRequests() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
processing_ = true;
|
||||
|
||||
const QScopeGuard scopeguard_processing = qScopeGuard([this]() {
|
||||
processing_ = false;
|
||||
});
|
||||
|
||||
while (HaveRequests()) {
|
||||
if (abort_.value()) return;
|
||||
ProcessRequest(DequeueRequest());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::ProcessRequest(TagReaderRequestPtr request) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
TagReaderReplyPtr reply = request->reply;
|
||||
|
||||
TagReaderResult result;
|
||||
|
||||
if (TagReaderIsMediaFileRequestPtr is_media_file_request = std::dynamic_pointer_cast<TagReaderIsMediaFileRequest>(request)) {
|
||||
result = tagreader_.IsMediaFile(is_media_file_request->filename);
|
||||
if (result.error_code == TagReaderResult::ErrorCode::Unsupported) {
|
||||
result = gmereader_.IsMediaFile(is_media_file_request->filename);
|
||||
}
|
||||
}
|
||||
else if (TagReaderReadFileRequestPtr read_file_request = std::dynamic_pointer_cast<TagReaderReadFileRequest>(request)) {
|
||||
Song song;
|
||||
result = ReadFileBlocking(read_file_request->filename, &song);
|
||||
if (result.error_code == TagReaderResult::ErrorCode::Unsupported) {
|
||||
result = gmereader_.ReadFile(read_file_request->filename, &song);
|
||||
}
|
||||
if (result.success()) {
|
||||
if (TagReaderReadFileReplyPtr read_file_reply = std::dynamic_pointer_cast<TagReaderReadFileReply>(reply)) {
|
||||
read_file_reply->set_song(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TagReaderWriteFileRequestPtr write_file_request = dynamic_pointer_cast<TagReaderWriteFileRequest>(request)) {
|
||||
result = WriteFileBlocking(write_file_request->filename, write_file_request->song, write_file_request->save_tags_options, write_file_request->save_tag_cover_data);
|
||||
}
|
||||
else if (TagReaderLoadCoverDataRequestPtr load_cover_data_request = dynamic_pointer_cast<TagReaderLoadCoverDataRequest>(request)) {
|
||||
QByteArray cover_data;
|
||||
result = LoadCoverDataBlocking(load_cover_data_request->filename, cover_data);
|
||||
if (result.success()) {
|
||||
if (TagReaderLoadCoverDataReplyPtr load_cover_data_reply = std::dynamic_pointer_cast<TagReaderLoadCoverDataReply>(reply)) {
|
||||
load_cover_data_reply->set_data(cover_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TagReaderLoadCoverImageRequestPtr load_cover_image_request = dynamic_pointer_cast<TagReaderLoadCoverImageRequest>(request)) {
|
||||
QImage cover_image;
|
||||
result = LoadCoverImageBlocking(load_cover_image_request->filename, cover_image);
|
||||
if (result.success()) {
|
||||
if (TagReaderLoadCoverImageReplyPtr load_cover_image_reply = std::dynamic_pointer_cast<TagReaderLoadCoverImageReply>(reply)) {
|
||||
load_cover_image_reply->set_image(cover_image);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TagReaderSaveCoverRequestPtr save_cover_request = dynamic_pointer_cast<TagReaderSaveCoverRequest>(request)) {
|
||||
result = SaveCoverBlocking(save_cover_request->filename, save_cover_request->save_tag_cover_data);
|
||||
}
|
||||
else if (TagReaderSavePlaycountRequestPtr save_playcount_request = dynamic_pointer_cast<TagReaderSavePlaycountRequest>(request)) {
|
||||
result = SaveSongPlaycountBlocking(save_playcount_request->filename, save_playcount_request->playcount);
|
||||
}
|
||||
else if (TagReaderSaveRatingRequestPtr save_rating_request = dynamic_pointer_cast<TagReaderSaveRatingRequest>(request)) {
|
||||
result = SaveSongRatingBlocking(save_rating_request->filename, save_rating_request->rating);
|
||||
}
|
||||
|
||||
reply->set_result(result);
|
||||
|
||||
reply->Finish();
|
||||
|
||||
}
|
||||
|
||||
bool TagReaderClient::IsMediaFileBlocking(const QString &filename) const {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
return tagreader_.IsMediaFile(filename).success();
|
||||
|
||||
}
|
||||
|
||||
TagReaderReplyPtr TagReaderClient::IsMediaFileAsync(const QString &filename) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReplyPtr reply = TagReaderReply::Create<TagReaderReply>(filename);
|
||||
|
||||
TagReaderIsMediaFileRequestPtr request = TagReaderIsMediaFileRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::ReadFileBlocking(const QString &filename, Song *song) {
|
||||
|
||||
return tagreader_.ReadFile(filename, song);
|
||||
|
||||
}
|
||||
|
||||
TagReaderReadFileReplyPtr TagReaderClient::ReadFileAsync(const QString &filename) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReadFileReplyPtr reply = TagReaderReply::Create<TagReaderReadFileReply>(filename);
|
||||
|
||||
TagReaderReadFileRequestPtr request = TagReaderReadFileRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::WriteFileBlocking(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) {
|
||||
|
||||
return tagreader_.WriteFile(filename, song, save_tags_options, save_tag_cover_data);
|
||||
|
||||
}
|
||||
|
||||
TagReaderReplyPtr TagReaderClient::WriteFileAsync(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReplyPtr reply = TagReaderReply::Create<TagReaderReply>(filename);
|
||||
|
||||
TagReaderWriteFileRequestPtr request = TagReaderWriteFileRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
request->song = song;
|
||||
request->save_tags_options = save_tags_options;
|
||||
request->save_tag_cover_data = save_tag_cover_data;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::LoadCoverDataBlocking(const QString &filename, QByteArray &data) {
|
||||
|
||||
return tagreader_.LoadEmbeddedCover(filename, data);
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::LoadCoverImageBlocking(const QString &filename, QImage &image) {
|
||||
|
||||
QByteArray data;
|
||||
TagReaderResult result = LoadCoverDataBlocking(filename, data);
|
||||
if (result.error_code == TagReaderResult::ErrorCode::Success && !image.loadFromData(data)) {
|
||||
result.error_code = TagReaderResult::ErrorCode::Unsupported;
|
||||
result.error_text = QObject::tr("Failed to load image from data for %1").arg(filename);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
TagReaderLoadCoverDataReplyPtr TagReaderClient::LoadCoverDataAsync(const QString &filename) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderLoadCoverDataReplyPtr reply = TagReaderReply::Create<TagReaderLoadCoverDataReply>(filename);
|
||||
|
||||
TagReaderLoadCoverDataRequestPtr request = TagReaderLoadCoverDataRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderLoadCoverImageReplyPtr TagReaderClient::LoadCoverImageAsync(const QString &filename) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderLoadCoverImageReplyPtr reply = TagReaderReply::Create<TagReaderLoadCoverImageReply>(filename);
|
||||
|
||||
TagReaderLoadCoverImageRequestPtr request = TagReaderLoadCoverImageRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::SaveCoverBlocking(const QString &filename, const SaveTagCoverData &save_tag_cover_data) {
|
||||
|
||||
return tagreader_.SaveEmbeddedCover(filename, save_tag_cover_data);
|
||||
|
||||
}
|
||||
|
||||
TagReaderReplyPtr TagReaderClient::SaveCoverAsync(const QString &filename, const SaveTagCoverData &save_tag_cover_data) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReplyPtr reply = TagReaderReply::Create<TagReaderReply>(filename);
|
||||
|
||||
TagReaderSaveCoverRequestPtr request = TagReaderSaveCoverRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
request->save_tag_cover_data = save_tag_cover_data;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderReplyPtr TagReaderClient::SaveSongPlaycountAsync(const QString &filename, const uint playcount) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReplyPtr reply = TagReaderReply::Create<TagReaderReply>(filename);
|
||||
|
||||
TagReaderSavePlaycountRequestPtr request = TagReaderSavePlaycountRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
request->playcount = playcount;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::SaveSongPlaycountBlocking(const QString &filename, const uint playcount) {
|
||||
|
||||
return tagreader_.SaveSongPlaycount(filename, playcount);
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::SaveSongsPlaycountAsync(const SongList &songs) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
for (const Song &song : songs) {
|
||||
TagReaderReplyPtr reply = SaveSongPlaycountAsync(song.url().toLocalFile(), song.playcount());
|
||||
QObject::connect(&*reply, &TagReaderReply::Finished, &*reply, &TagReaderReply::deleteLater);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderClient::SaveSongRatingBlocking(const QString &filename, const float rating) {
|
||||
|
||||
return tagreader_.SaveSongRating(filename, rating);
|
||||
|
||||
}
|
||||
|
||||
TagReaderReplyPtr TagReaderClient::SaveSongRatingAsync(const QString &filename, const float rating) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
TagReaderReplyPtr reply = TagReaderReply::Create<TagReaderReply>(filename);
|
||||
|
||||
TagReaderSaveRatingRequestPtr request = TagReaderSaveRatingRequest::Create(filename);
|
||||
request->reply = reply;
|
||||
request->filename = filename;
|
||||
request->rating = rating;
|
||||
|
||||
EnqueueRequest(request);
|
||||
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
void TagReaderClient::SaveSongsRatingAsync(const SongList &songs) {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != thread());
|
||||
|
||||
for (const Song &song : songs) {
|
||||
TagReaderReplyPtr reply = SaveSongRatingAsync(song.url().toLocalFile(), song.rating());
|
||||
QObject::connect(&*reply, &TagReaderReply::Finished, &*reply, &TagReaderReply::deleteLater);
|
||||
}
|
||||
|
||||
}
|
||||
117
src/tagreader/tagreaderclient.h
Normal file
117
src/tagreader/tagreaderclient.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERCLIENT_H
|
||||
#define TAGREADERCLIENT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QQueue>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QMutex>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/mutex_protected.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tagreadertaglib.h"
|
||||
#include "tagreadergme.h"
|
||||
#include "tagreaderrequest.h"
|
||||
#include "tagreaderresult.h"
|
||||
#include "tagreaderreply.h"
|
||||
#include "tagreaderreadfilereply.h"
|
||||
#include "tagreaderloadcoverdatareply.h"
|
||||
#include "tagreaderloadcoverimagereply.h"
|
||||
#include "savetagsoptions.h"
|
||||
#include "savetagcoverdata.h"
|
||||
|
||||
class QThread;
|
||||
class Song;
|
||||
|
||||
class TagReaderClient : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderClient(QObject *parent = nullptr);
|
||||
|
||||
static TagReaderClient *Instance() { return sInstance; }
|
||||
|
||||
void Start();
|
||||
void ExitAsync();
|
||||
|
||||
using SaveOption = SaveTagsOption;
|
||||
using SaveOptions = SaveTagsOptions;
|
||||
|
||||
bool IsMediaFileBlocking(const QString &filename) const;
|
||||
TagReaderReplyPtr IsMediaFileAsync(const QString &filename);
|
||||
|
||||
TagReaderResult ReadFileBlocking(const QString &filename, Song *song);
|
||||
TagReaderReadFileReplyPtr ReadFileAsync(const QString &filename);
|
||||
|
||||
TagReaderResult WriteFileBlocking(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options = SaveTagsOption::Tags, const SaveTagCoverData &save_tag_cover_data = SaveTagCoverData());
|
||||
TagReaderReplyPtr WriteFileAsync(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options = SaveTagsOption::Tags, const SaveTagCoverData &save_tag_cover_data = SaveTagCoverData());
|
||||
|
||||
TagReaderResult LoadCoverDataBlocking(const QString &filename, QByteArray &data);
|
||||
TagReaderResult LoadCoverImageBlocking(const QString &filename, QImage &image);
|
||||
TagReaderLoadCoverDataReplyPtr LoadCoverDataAsync(const QString &filename);
|
||||
TagReaderLoadCoverImageReplyPtr LoadCoverImageAsync(const QString &filename);
|
||||
|
||||
TagReaderResult SaveCoverBlocking(const QString &filename, const SaveTagCoverData &save_tag_cover_data);
|
||||
TagReaderReplyPtr SaveCoverAsync(const QString &filename, const SaveTagCoverData &save_tag_cover_data);
|
||||
|
||||
TagReaderReplyPtr SaveSongPlaycountAsync(const QString &filename, const uint playcount);
|
||||
TagReaderResult SaveSongPlaycountBlocking(const QString &filename, const uint playcount);
|
||||
|
||||
TagReaderReplyPtr SaveSongRatingAsync(const QString &filename, const float rating);
|
||||
TagReaderResult SaveSongRatingBlocking(const QString &filename, const float rating);
|
||||
|
||||
private:
|
||||
bool HaveRequests() const;
|
||||
void EnqueueRequest(TagReaderRequestPtr request);
|
||||
TagReaderRequestPtr DequeueRequest();
|
||||
void ProcessRequestsAsync();
|
||||
void ProcessRequest(TagReaderRequestPtr request);
|
||||
|
||||
Q_SIGNALS:
|
||||
void ExitFinished();
|
||||
|
||||
private Q_SLOTS:
|
||||
void Exit();
|
||||
void ProcessRequests();
|
||||
|
||||
public Q_SLOTS:
|
||||
void SaveSongsPlaycountAsync(const SongList &songs);
|
||||
void SaveSongsRatingAsync(const SongList &songs);
|
||||
|
||||
private:
|
||||
static TagReaderClient *sInstance;
|
||||
|
||||
QThread *original_thread_;
|
||||
QQueue<TagReaderRequestPtr> requests_;
|
||||
mutable QMutex mutex_requests_;
|
||||
TagReaderTagLib tagreader_;
|
||||
TagReaderGME gmereader_;
|
||||
mutex_protected<bool> abort_;
|
||||
mutex_protected<bool> processing_;
|
||||
};
|
||||
|
||||
#endif // TAGREADERCLIENT_H
|
||||
349
src/tagreader/tagreadergme.cpp
Normal file
349
src/tagreader/tagreadergme.cpp
Normal file
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Eoin O'Neill <eoinoneill1991@gmail.com>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tagreadergme.h"
|
||||
|
||||
#include <taglib/apefile.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QChar>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderbase.h"
|
||||
#include "tagreadertaglib.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#undef TStringToQString
|
||||
#undef QStringToTString
|
||||
|
||||
bool GME::IsSupportedFormat(const QFileInfo &fileinfo) {
|
||||
return fileinfo.exists() && (fileinfo.completeSuffix().endsWith("spc"_L1, Qt::CaseInsensitive) || fileinfo.completeSuffix().endsWith("vgm"_L1), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
TagReaderResult GME::ReadFile(const QFileInfo &fileinfo, Song *song) {
|
||||
|
||||
if (fileinfo.completeSuffix().endsWith("spc"_L1), Qt::CaseInsensitive) {
|
||||
return SPC::Read(fileinfo, song);
|
||||
}
|
||||
if (fileinfo.completeSuffix().endsWith("vgm"_L1, Qt::CaseInsensitive)) {
|
||||
return VGM::Read(fileinfo, song);
|
||||
}
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
quint32 GME::UnpackBytes32(const char *const bytes, size_t length) {
|
||||
|
||||
Q_ASSERT(length <= 4 && length > 0);
|
||||
|
||||
quint32 value = 0;
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
value |= static_cast<unsigned char>(bytes[i]) << (8 * i);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult GME::SPC::Read(const QFileInfo &fileinfo, Song *song) {
|
||||
|
||||
QFile file(fileinfo.filePath());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return TagReaderResult(TagReaderResult::ErrorCode::FileOpenError, file.errorString());
|
||||
}
|
||||
|
||||
qLog(Debug) << "Reading tags from SPC file" << fileinfo.fileName();
|
||||
|
||||
// Check for header -- more reliable than file name alone.
|
||||
if (!file.read(33).startsWith("SNES-SPC700")) {
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
}
|
||||
|
||||
// First order of business -- get any tag values that exist within the core file information.
|
||||
// These only allow for a certain number of bytes per field,
|
||||
// so they will likely be overwritten either by the id666 standard or the APETAG format (as used by other players, such as foobar and winamp)
|
||||
//
|
||||
// Make sure to check id6 documentation before changing the read values!
|
||||
|
||||
file.seek(HAS_ID6_OFFSET);
|
||||
const QByteArray id6_status = file.read(1);
|
||||
const bool has_id6 = id6_status.length() >= 1 && id6_status[0] == static_cast<char>(xID6_STATUS::ON);
|
||||
|
||||
file.seek(SONG_TITLE_OFFSET);
|
||||
song->set_title(QString::fromLatin1(file.read(32)).toStdString());
|
||||
|
||||
file.seek(GAME_TITLE_OFFSET);
|
||||
song->set_album(QString::fromLatin1(file.read(32)).toStdString());
|
||||
|
||||
file.seek(ARTIST_OFFSET);
|
||||
song->set_artist(QString::fromLatin1(file.read(32)).toStdString());
|
||||
|
||||
file.seek(INTRO_LENGTH_OFFSET);
|
||||
QByteArray length_bytes = file.read(INTRO_LENGTH_SIZE);
|
||||
if (length_bytes.size() >= INTRO_LENGTH_SIZE) {
|
||||
quint64 length_in_sec = ConvertSPCStringToNum(length_bytes);
|
||||
|
||||
if (!length_in_sec || length_in_sec >= 0x1FFF) {
|
||||
// This means that parsing the length as a string failed, so get value LE.
|
||||
length_in_sec = length_bytes[0] | (length_bytes[1] << 8) | (length_bytes[2] << 16);
|
||||
}
|
||||
|
||||
if (length_in_sec < 0x1FFF) {
|
||||
song->set_length_nanosec(static_cast<qint64>(length_in_sec * kNsecPerSec));
|
||||
}
|
||||
}
|
||||
|
||||
file.seek(FADE_LENGTH_OFFSET);
|
||||
QByteArray fade_bytes = file.read(FADE_LENGTH_SIZE);
|
||||
if (fade_bytes.size() >= FADE_LENGTH_SIZE) {
|
||||
quint64 fade_length_in_ms = ConvertSPCStringToNum(fade_bytes);
|
||||
|
||||
if (fade_length_in_ms > 0x7FFF) {
|
||||
fade_length_in_ms = fade_bytes[0] | (fade_bytes[1] << 8) | (fade_bytes[2] << 16) | (fade_bytes[3] << 24);
|
||||
}
|
||||
Q_UNUSED(fade_length_in_ms)
|
||||
}
|
||||
|
||||
// Check for XID6 data -- this is infrequently used, but being able to fill in data from this is ideal before trying to rely on APETAG values.
|
||||
// XID6 format follows EA's binary file format standard named "IFF"
|
||||
file.seek(XID6_OFFSET);
|
||||
if (has_id6 && file.read(4) == "xid6") {
|
||||
QByteArray xid6_head_data = file.read(4);
|
||||
if (xid6_head_data.size() >= 4) {
|
||||
qint64 xid6_size = xid6_head_data[0] | (xid6_head_data[1] << 8) | (xid6_head_data[2] << 16) | xid6_head_data[3];
|
||||
// This should be the size remaining for entire ID6 block, but it seems that most files treat this as the size of the remaining header space...
|
||||
|
||||
qLog(Debug) << fileinfo.fileName() << "has ID6 tag.";
|
||||
|
||||
while ((file.pos()) + 4 < XID6_OFFSET + xid6_size) {
|
||||
QByteArray arr = file.read(4);
|
||||
if (arr.size() < 4) break;
|
||||
|
||||
qint8 id = arr[0];
|
||||
qint8 type = arr[1];
|
||||
Q_UNUSED(id);
|
||||
Q_UNUSED(type);
|
||||
qint16 length = static_cast<qint16>(arr[2] | (arr[3] << 8));
|
||||
|
||||
file.read(GetNextMemAddressAlign32bit(length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Music Players that support SPC tend to support additional tagging data as
|
||||
// an APETAG entry at the bottom of the file instead of writing into the xid6 tagging space.
|
||||
// This is where a lot of the extra data for a file is stored, such as genre or replaygain data.
|
||||
// This data is currently supported by TagLib, so we will simply use that for the remaining values.
|
||||
TagLib::APE::File ape(fileinfo.filePath().toStdString().data());
|
||||
if (ape.hasAPETag()) {
|
||||
TagLib::Tag *tag = ape.tag();
|
||||
if (!tag) {
|
||||
return TagReaderResult::ErrorCode::FileParseError;
|
||||
}
|
||||
|
||||
song->set_artist(tag->artist());
|
||||
song->set_album(tag->album());
|
||||
song->set_title(tag->title());
|
||||
song->set_genre(tag->genre());
|
||||
song->set_track(static_cast<std::int32_t>(tag->track()));
|
||||
song->set_year(static_cast<std::int32_t>(tag->year()));
|
||||
}
|
||||
|
||||
song->set_valid(true);
|
||||
song->set_filetype(Song::FileType::SPC);
|
||||
|
||||
return TagReaderResult::ErrorCode::Success;
|
||||
|
||||
}
|
||||
|
||||
qint16 GME::SPC::GetNextMemAddressAlign32bit(qint16 input) {
|
||||
return static_cast<qint16>((input + 0x3) & ~0x3);
|
||||
// Plus 0x3 for rounding up (not down), AND NOT to flatten out on a 32 bit level.
|
||||
}
|
||||
|
||||
quint64 GME::SPC::ConvertSPCStringToNum(const QByteArray &arr) {
|
||||
|
||||
quint64 result = 0;
|
||||
for (auto it = arr.begin(); it != arr.end(); it++) {
|
||||
unsigned int num = *it - '0';
|
||||
if (num > 9) break;
|
||||
result = (result * 10) + num; // Shift Left and add.
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult GME::VGM::Read(const QFileInfo &fileinfo, Song *song) {
|
||||
|
||||
QFile file(fileinfo.filePath());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return TagReaderResult(TagReaderResult::ErrorCode::FileOpenError, file.errorString());
|
||||
}
|
||||
|
||||
qLog(Debug) << "Reading tags from VGM file" << fileinfo.filePath();
|
||||
|
||||
if (!file.read(4).startsWith("Vgm ")) {
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
}
|
||||
|
||||
file.seek(GD3_TAG_PTR);
|
||||
QByteArray gd3_head = file.read(4);
|
||||
if (gd3_head.size() < 4) {
|
||||
return TagReaderResult::ErrorCode::FileParseError;
|
||||
}
|
||||
|
||||
quint64 pt = GME::UnpackBytes32(gd3_head.constData(), gd3_head.size());
|
||||
|
||||
file.seek(SAMPLE_COUNT);
|
||||
QByteArray sample_count_bytes = file.read(4);
|
||||
file.seek(LOOP_SAMPLE_COUNT);
|
||||
QByteArray loop_count_bytes = file.read(4);
|
||||
quint64 length = 0;
|
||||
|
||||
if (!GetPlaybackLength(sample_count_bytes, loop_count_bytes, length)) {
|
||||
return TagReaderResult::ErrorCode::FileParseError;
|
||||
}
|
||||
|
||||
file.seek(static_cast<qint64>(GD3_TAG_PTR + pt));
|
||||
QByteArray gd3_version = file.read(4);
|
||||
Q_UNUSED(gd3_version)
|
||||
|
||||
file.seek(file.pos() + 4);
|
||||
QByteArray gd3_length_bytes = file.read(4);
|
||||
quint32 gd3_length = GME::UnpackBytes32(gd3_length_bytes.constData(), gd3_length_bytes.size());
|
||||
|
||||
QByteArray gd3Data = file.read(gd3_length);
|
||||
QTextStream fileTagStream(gd3Data, QIODevice::ReadOnly);
|
||||
// Stored as 16 bit UTF string, two bytes per letter.
|
||||
fileTagStream.setEncoding(QStringConverter::Utf16);
|
||||
QStringList strings = fileTagStream.readLine(0).split(u'\0');
|
||||
if (strings.count() < 10) {
|
||||
return TagReaderResult::ErrorCode::FileParseError;
|
||||
}
|
||||
|
||||
// VGM standard dictates string tag data exist in specific order.
|
||||
// Order alternates between English and Japanese version of data.
|
||||
// Read GD3 tag standard for more details.
|
||||
song->set_title(strings[0].toStdString());
|
||||
song->set_album(strings[2].toStdString());
|
||||
song->set_artist(strings[6].toStdString());
|
||||
song->set_year(strings[8].left(4).toInt());
|
||||
song->set_length_nanosec(static_cast<qint64>(length * kNsecPerMsec));
|
||||
song->set_valid(true);
|
||||
song->set_filetype(Song::FileType::VGM);
|
||||
|
||||
return TagReaderResult::ErrorCode::Success;
|
||||
|
||||
}
|
||||
|
||||
bool GME::VGM::GetPlaybackLength(const QByteArray &sample_count_bytes, const QByteArray &loop_count_bytes, quint64 &out_length) {
|
||||
|
||||
if (sample_count_bytes.size() != 4) return false;
|
||||
if (loop_count_bytes.size() != 4) return false;
|
||||
|
||||
quint64 sample_count = GME::UnpackBytes32(sample_count_bytes.constData(), sample_count_bytes.size());
|
||||
|
||||
if (sample_count == 0) return false;
|
||||
|
||||
quint64 loop_sample_count = GME::UnpackBytes32(loop_count_bytes.constData(), loop_count_bytes.size());
|
||||
|
||||
if (loop_sample_count == 0) {
|
||||
out_length = sample_count * 1000 / SAMPLE_TIMEBASE;
|
||||
return true;
|
||||
}
|
||||
|
||||
quint64 intro_length_ms = (sample_count - loop_sample_count) * 1000 / SAMPLE_TIMEBASE;
|
||||
quint64 loop_length_ms = (loop_sample_count) * 1000 / SAMPLE_TIMEBASE;
|
||||
out_length = intro_length_ms + (loop_length_ms * 2) + GST_GME_LOOP_TIME_MS;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
TagReaderGME::TagReaderGME() = default;
|
||||
|
||||
|
||||
TagReaderResult TagReaderGME::IsMediaFile(const QString &filename) const {
|
||||
|
||||
QFileInfo fileinfo(filename);
|
||||
return GME::IsSupportedFormat(fileinfo) ? TagReaderResult::ErrorCode::Success : TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::ReadFile(const QString &filename, Song *song) const {
|
||||
|
||||
QFileInfo fileinfo(filename);
|
||||
return GME::ReadFile(fileinfo, song);
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::WriteFile(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) const {
|
||||
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(song);
|
||||
Q_UNUSED(save_tags_options);
|
||||
Q_UNUSED(save_tag_cover_data);
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::LoadEmbeddedCover(const QString &filename, QByteArray &data) const {
|
||||
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(data);
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::SaveEmbeddedCover(const QString &filename, const SaveTagCoverData &save_tag_cover_data) const {
|
||||
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(save_tag_cover_data);
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::SaveSongPlaycount(const QString &filename, const uint playcount) const {
|
||||
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(playcount);
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
|
||||
TagReaderResult TagReaderGME::SaveSongRating(const QString &filename, const float rating) const {
|
||||
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(rating);
|
||||
|
||||
return TagReaderResult::ErrorCode::Unsupported;
|
||||
|
||||
}
|
||||
114
src/tagreader/tagreadergme.h
Normal file
114
src/tagreader/tagreadergme.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Eoin O'Neill <eoinoneill1991@gmail.com>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERGME_H
|
||||
#define TAGREADERGME_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "tagreaderbase.h"
|
||||
|
||||
namespace GME {
|
||||
bool IsSupportedFormat(const QFileInfo &fileinfo);
|
||||
TagReaderResult ReadFile(const QFileInfo &fileinfo, Song *song);
|
||||
|
||||
uint32_t UnpackBytes32(const char *const bytes, size_t length);
|
||||
|
||||
namespace SPC {
|
||||
// SPC SPEC: http://vspcplay.raphnet.net/spc_file_format.txt
|
||||
|
||||
constexpr int HAS_ID6_OFFSET = 0x23;
|
||||
constexpr int SONG_TITLE_OFFSET = 0x2E;
|
||||
constexpr int GAME_TITLE_OFFSET = 0x4E;
|
||||
constexpr int DUMPER_OFFSET = 0x6E;
|
||||
constexpr int COMMENTS_OFFSET = 0x7E;
|
||||
// It seems that intro length and fade length are inconsistent from file to file.
|
||||
// It should be looked into within the GME source code to see how GStreamer gets its values for playback length.
|
||||
constexpr int INTRO_LENGTH_OFFSET = 0xA9;
|
||||
constexpr int INTRO_LENGTH_SIZE = 3;
|
||||
constexpr int FADE_LENGTH_OFFSET = 0xAC;
|
||||
constexpr int FADE_LENGTH_SIZE = 4;
|
||||
constexpr int ARTIST_OFFSET = 0xB1;
|
||||
constexpr int XID6_OFFSET = (0x101C0 + 64);
|
||||
|
||||
constexpr int NANO_PER_MS = 1000000;
|
||||
|
||||
enum class xID6_STATUS {
|
||||
ON = 0x26,
|
||||
OFF = 0x27
|
||||
};
|
||||
|
||||
enum class xID6_ID {
|
||||
SongName = 0x01,
|
||||
GameName = 0x02,
|
||||
ArtistName = 0x03
|
||||
};
|
||||
|
||||
enum class xID6_TYPE {
|
||||
Length = 0x0,
|
||||
String = 0x1,
|
||||
Integer = 0x4
|
||||
};
|
||||
|
||||
TagReaderResult Read(const QFileInfo &fileinfo, Song *song);
|
||||
qint16 GetNextMemAddressAlign32bit(qint16 input);
|
||||
quint64 ConvertSPCStringToNum(const QByteArray &arr);
|
||||
} // namespace SPC
|
||||
|
||||
namespace VGM {
|
||||
// VGM SPEC:
|
||||
// http://www.smspower.org/uploads/Music/vgmspec170.txt?sid=17c810c54633b6dd4982f92f718361c1
|
||||
// GD3 TAG SPEC:
|
||||
// http://www.smspower.org/uploads/Music/gd3spec100.txt
|
||||
constexpr int GD3_TAG_PTR = 0x14;
|
||||
constexpr int SAMPLE_COUNT = 0x18;
|
||||
constexpr int LOOP_SAMPLE_COUNT = 0x20;
|
||||
constexpr int SAMPLE_TIMEBASE = 44100;
|
||||
constexpr int GST_GME_LOOP_TIME_MS = 8000;
|
||||
|
||||
TagReaderResult Read(const QFileInfo &fileinfo, Song *song);
|
||||
// Takes in two QByteArrays, expected to be 4 bytes long. Desired length is returned via output parameter out_length. Returns false on error.
|
||||
bool GetPlaybackLength(const QByteArray &sample_count_bytes, const QByteArray &loop_count_bytes, quint64 &out_length);
|
||||
|
||||
} // namespace VGM
|
||||
|
||||
} // namespace GME
|
||||
|
||||
// TagReaderGME
|
||||
// Fulfills Strawberry's Intended interface for tag reading.
|
||||
class TagReaderGME : public TagReaderBase {
|
||||
|
||||
public:
|
||||
explicit TagReaderGME();
|
||||
|
||||
TagReaderResult IsMediaFile(const QString &filename) const override;
|
||||
|
||||
TagReaderResult ReadFile(const QString &filename, Song *song) const override;
|
||||
TagReaderResult WriteFile(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) const override;
|
||||
|
||||
TagReaderResult LoadEmbeddedCover(const QString &filename, QByteArray &data) const override;
|
||||
TagReaderResult SaveEmbeddedCover(const QString &filename, const SaveTagCoverData &save_tag_cover_data) const override;
|
||||
|
||||
TagReaderResult SaveSongPlaycount(const QString &filename, const uint playcount) const override;
|
||||
TagReaderResult SaveSongRating(const QString &filename, const float rating) const override;
|
||||
};
|
||||
|
||||
#endif // TAGREADERGME_H
|
||||
24
src/tagreader/tagreaderismediafilerequest.cpp
Normal file
24
src/tagreader/tagreaderismediafilerequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreaderismediafilerequest.h"
|
||||
|
||||
TagReaderIsMediaFileRequest::TagReaderIsMediaFileRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
38
src/tagreader/tagreaderismediafilerequest.h
Normal file
38
src/tagreader/tagreaderismediafilerequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERISMEDIAFILEREQUEST_H
|
||||
#define TAGREADERISMEDIAFILEREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderIsMediaFileRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderIsMediaFileRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderIsMediaFileRequest> Create(const QString &filename) { return make_shared<TagReaderIsMediaFileRequest>(filename); }
|
||||
};
|
||||
|
||||
using TagReaderIsMediaFileRequestPtr = std::shared_ptr<TagReaderIsMediaFileRequest>;
|
||||
|
||||
#endif // TAGREADERISMEDIAFILEREQUEST_H
|
||||
40
src/tagreader/tagreaderloadcoverdatareply.cpp
Normal file
40
src/tagreader/tagreaderloadcoverdatareply.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderloadcoverdatareply.h"
|
||||
|
||||
TagReaderLoadCoverDataReply::TagReaderLoadCoverDataReply(const QString &_filename, QObject *parent)
|
||||
: TagReaderReply(_filename, parent) {}
|
||||
|
||||
void TagReaderLoadCoverDataReply::Finish() {
|
||||
|
||||
qLog(Debug) << "Finishing tagreader reply for" << filename_;
|
||||
|
||||
finished_ = true;
|
||||
|
||||
Q_EMIT TagReaderReply::Finished(filename_, result_);
|
||||
Q_EMIT TagReaderLoadCoverDataReply::Finished(filename_, data_, result_);
|
||||
|
||||
QObject::disconnect(this, &TagReaderReply::Finished, nullptr, nullptr);
|
||||
QObject::disconnect(this, &TagReaderLoadCoverDataReply::Finished, nullptr, nullptr);
|
||||
|
||||
}
|
||||
51
src/tagreader/tagreaderloadcoverdatareply.h
Normal file
51
src/tagreader/tagreaderloadcoverdatareply.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERLOADCOVERDATAREPLY_H
|
||||
#define TAGREADERLOADCOVERDATAREPLY_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "tagreaderreply.h"
|
||||
#include "tagreaderresult.h"
|
||||
|
||||
class TagReaderLoadCoverDataReply : public TagReaderReply {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderLoadCoverDataReply(const QString &_filename, QObject *parent = nullptr);
|
||||
|
||||
void Finish() override;
|
||||
|
||||
QByteArray data() const { return data_; }
|
||||
void set_data(const QByteArray &data) { data_ = data; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void Finished(const QString &filename, const QByteArray &data, const TagReaderResult &result);
|
||||
|
||||
private:
|
||||
QByteArray data_;
|
||||
};
|
||||
|
||||
using TagReaderLoadCoverDataReplyPtr = SharedPtr<TagReaderLoadCoverDataReply>;
|
||||
|
||||
#endif // TAGREADERLOADCOVERDATAREPLY_H
|
||||
24
src/tagreader/tagreaderloadcoverdatarequest.cpp
Normal file
24
src/tagreader/tagreaderloadcoverdatarequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreaderloadcoverdatarequest.h"
|
||||
|
||||
TagReaderLoadCoverDataRequest::TagReaderLoadCoverDataRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
38
src/tagreader/tagreaderloadcoverdatarequest.h
Normal file
38
src/tagreader/tagreaderloadcoverdatarequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERLOADCOVERDATAREQUEST_H
|
||||
#define TAGREADERLOADCOVERDATAREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderLoadCoverDataRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderLoadCoverDataRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderLoadCoverDataRequest> Create(const QString &filename) { return make_shared<TagReaderLoadCoverDataRequest>(filename); }
|
||||
};
|
||||
|
||||
using TagReaderLoadCoverDataRequestPtr = SharedPtr<TagReaderLoadCoverDataRequest>;
|
||||
|
||||
#endif // TAGREADERLOADCOVERDATAREQUEST_H
|
||||
39
src/tagreader/tagreaderloadcoverimagereply.cpp
Normal file
39
src/tagreader/tagreaderloadcoverimagereply.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderloadcoverimagereply.h"
|
||||
|
||||
TagReaderLoadCoverImageReply::TagReaderLoadCoverImageReply(const QString &_filename, QObject *parent)
|
||||
: TagReaderReply(_filename, parent) {}
|
||||
|
||||
void TagReaderLoadCoverImageReply::Finish() {
|
||||
|
||||
qLog(Debug) << "Finishing tagreader reply for" << filename_;
|
||||
|
||||
finished_ = true;
|
||||
|
||||
Q_EMIT TagReaderReply::Finished(filename_, result_);
|
||||
Q_EMIT TagReaderLoadCoverImageReply::Finished(filename_, image_, result_);
|
||||
|
||||
QObject::disconnect(this, &TagReaderLoadCoverImageReply::Finished, nullptr, nullptr);
|
||||
|
||||
}
|
||||
51
src/tagreader/tagreaderloadcoverimagereply.h
Normal file
51
src/tagreader/tagreaderloadcoverimagereply.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERLOADCOVERIMAGEREPLY_H
|
||||
#define TAGREADERLOADCOVERIMAGEREPLY_H
|
||||
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "tagreaderreply.h"
|
||||
#include "tagreaderresult.h"
|
||||
|
||||
class TagReaderLoadCoverImageReply : public TagReaderReply {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderLoadCoverImageReply(const QString &_filename, QObject *parent = nullptr);
|
||||
|
||||
void Finish() override;
|
||||
|
||||
QImage image() const { return image_; }
|
||||
void set_image(const QImage &image) { image_ = image; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void Finished(const QString &filename, const QImage &image, const TagReaderResult &result);
|
||||
|
||||
private:
|
||||
QImage image_;
|
||||
};
|
||||
|
||||
using TagReaderLoadCoverImageReplyPtr = SharedPtr<TagReaderLoadCoverImageReply>;
|
||||
|
||||
#endif // TAGREADERLOADCOVERIMAGEREPLY_H
|
||||
24
src/tagreader/tagreaderloadcoverimagerequest.cpp
Normal file
24
src/tagreader/tagreaderloadcoverimagerequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreaderloadcoverimagerequest.h"
|
||||
|
||||
TagReaderLoadCoverImageRequest::TagReaderLoadCoverImageRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
38
src/tagreader/tagreaderloadcoverimagerequest.h
Normal file
38
src/tagreader/tagreaderloadcoverimagerequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERLOADCOVERIMAGEREQUEST_H
|
||||
#define TAGREADERLOADCOVERIMAGEREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderLoadCoverImageRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderLoadCoverImageRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderLoadCoverImageRequest> Create(const QString &filename) { return make_shared<TagReaderLoadCoverImageRequest>(filename); }
|
||||
};
|
||||
|
||||
using TagReaderLoadCoverImageRequestPtr = SharedPtr<TagReaderLoadCoverImageRequest>;
|
||||
|
||||
#endif // TAGREADERLOADEMBEDDEDCOVERASIMAGEREQUEST_H
|
||||
39
src/tagreader/tagreaderreadfilereply.cpp
Normal file
39
src/tagreader/tagreaderreadfilereply.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "tagreaderreadfilereply.h"
|
||||
|
||||
TagReaderReadFileReply::TagReaderReadFileReply(const QString &_filename, QObject *parent)
|
||||
: TagReaderReply(_filename, parent) {}
|
||||
|
||||
void TagReaderReadFileReply::Finish() {
|
||||
|
||||
qLog(Debug) << "Finishing tagreader reply for" << filename_;
|
||||
|
||||
finished_ = true;
|
||||
|
||||
Q_EMIT TagReaderReply::Finished(filename_, result_);
|
||||
Q_EMIT TagReaderReadFileReply::Finished(filename_, song_, result_);
|
||||
|
||||
QObject::disconnect(this, &TagReaderReadFileReply::Finished, nullptr, nullptr);
|
||||
|
||||
}
|
||||
50
src/tagreader/tagreaderreadfilereply.h
Normal file
50
src/tagreader/tagreaderreadfilereply.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERREADFILEREPLY_H
|
||||
#define TAGREADERREADFILEREPLY_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "tagreaderreply.h"
|
||||
#include "tagreaderresult.h"
|
||||
|
||||
class TagReaderReadFileReply : public TagReaderReply {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderReadFileReply(const QString &_filename, QObject *parent = nullptr);
|
||||
|
||||
void Finish() override;
|
||||
|
||||
Song song() const { return song_; }
|
||||
void set_song(const Song &song) { song_ = song; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void Finished(const QString &filename, const Song &song, const TagReaderResult &result);
|
||||
|
||||
private:
|
||||
Song song_;
|
||||
};
|
||||
|
||||
using TagReaderReadFileReplyPtr = SharedPtr<TagReaderReadFileReply>;
|
||||
|
||||
#endif // TAGREADERREADFILEREPLY_H
|
||||
24
src/tagreader/tagreaderreadfilerequest.cpp
Normal file
24
src/tagreader/tagreaderreadfilerequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreaderreadfilerequest.h"
|
||||
|
||||
TagReaderReadFileRequest::TagReaderReadFileRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
38
src/tagreader/tagreaderreadfilerequest.h
Normal file
38
src/tagreader/tagreaderreadfilerequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERREADFILEREQUEST_H
|
||||
#define TAGREADERREADFILEREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderReadFileRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderReadFileRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderReadFileRequest> Create(const QString &filename) { return make_shared<TagReaderReadFileRequest>(filename); }
|
||||
};
|
||||
|
||||
using TagReaderReadFileRequestPtr = SharedPtr<TagReaderReadFileRequest>;
|
||||
|
||||
#endif // TAGREADERREADFILEREQUEST_H
|
||||
51
src/tagreader/tagreaderreply.cpp
Normal file
51
src/tagreader/tagreaderreply.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "tagreaderreply.h"
|
||||
|
||||
TagReaderReply::TagReaderReply(const QString &filename, QObject *parent)
|
||||
: QObject(parent),
|
||||
filename_(filename),
|
||||
finished_(false) {
|
||||
|
||||
qLog(Debug) << "New tagreader reply for" << filename_;
|
||||
|
||||
}
|
||||
|
||||
TagReaderReply::~TagReaderReply() {
|
||||
|
||||
qLog(Debug) << "Deleting tagreader reply for" << filename_;
|
||||
|
||||
}
|
||||
|
||||
void TagReaderReply::Finish() {
|
||||
|
||||
qLog(Debug) << "Finishing tagreader reply for" << filename_;
|
||||
|
||||
finished_ = true;
|
||||
|
||||
Q_EMIT Finished(filename_, result_);
|
||||
|
||||
QObject::disconnect(this, &TagReaderReply::Finished, nullptr, nullptr);
|
||||
|
||||
}
|
||||
67
src/tagreader/tagreaderreply.h
Normal file
67
src/tagreader/tagreaderreply.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERREPLY_H
|
||||
#define TAGREADERREPLY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderresult.h"
|
||||
|
||||
class TagReaderReply : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagReaderReply(const QString &filename, QObject *parent = nullptr);
|
||||
virtual ~TagReaderReply() override;
|
||||
|
||||
template<typename T>
|
||||
static SharedPtr<T> Create(const QString &filename) {
|
||||
|
||||
SharedPtr<T> reply;
|
||||
reply.reset(new T(filename), [](QObject *obj) { obj->deleteLater(); });
|
||||
return reply;
|
||||
|
||||
}
|
||||
|
||||
QString filename() const { return filename_; }
|
||||
|
||||
TagReaderResult result() const { return result_; }
|
||||
void set_result(const TagReaderResult &result) { result_ = result; }
|
||||
|
||||
bool finished() const { return finished_; }
|
||||
bool success() const { return result_.success(); }
|
||||
QString error() const { return result_.error_string(); }
|
||||
|
||||
virtual void Finish();
|
||||
|
||||
Q_SIGNALS:
|
||||
void Finished(const QString &filename, const TagReaderResult &result);
|
||||
|
||||
protected:
|
||||
const QString filename_;
|
||||
bool finished_;
|
||||
TagReaderResult result_;
|
||||
};
|
||||
|
||||
using TagReaderReplyPtr = SharedPtr<TagReaderReply>;
|
||||
|
||||
#endif // TAGREADERREPLY_H
|
||||
34
src/tagreader/tagreaderrequest.cpp
Normal file
34
src/tagreader/tagreaderrequest.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
TagReaderRequest::TagReaderRequest(const QString &_filename) : filename(_filename) {
|
||||
|
||||
qLog(Debug) << "New tagreader request for" << filename;
|
||||
|
||||
}
|
||||
|
||||
TagReaderRequest::~TagReaderRequest() {
|
||||
|
||||
qLog(Debug) << "Deleting tagreader request for" << filename;
|
||||
|
||||
}
|
||||
38
src/tagreader/tagreaderrequest.h
Normal file
38
src/tagreader/tagreaderrequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERREQUEST_H
|
||||
#define TAGREADERREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderreply.h"
|
||||
|
||||
class TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderRequest(const QString &_filename);
|
||||
virtual ~TagReaderRequest();
|
||||
QString filename;
|
||||
TagReaderReplyPtr reply;
|
||||
};
|
||||
|
||||
using TagReaderRequestPtr = SharedPtr<TagReaderRequest>;
|
||||
|
||||
#endif // TAGREADERREQUEST_H
|
||||
47
src/tagreader/tagreaderresult.cpp
Normal file
47
src/tagreader/tagreaderresult.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "tagreaderresult.h"
|
||||
|
||||
QString TagReaderResult::error_string() const {
|
||||
|
||||
switch (error_code) {
|
||||
case ErrorCode::Success:
|
||||
return QObject::tr("Success");
|
||||
case ErrorCode::Unsupported:
|
||||
return QObject::tr("File is unsupported");
|
||||
case ErrorCode::FilenameMissing:
|
||||
return QObject::tr("Filename is missing");
|
||||
case ErrorCode::FileDoesNotExist:
|
||||
return QObject::tr("File does not exist");
|
||||
case ErrorCode::FileOpenError:
|
||||
return QObject::tr("File could not be opened");
|
||||
case ErrorCode::FileParseError:
|
||||
return QObject::tr("Could not parse file");
|
||||
case ErrorCode::FileSaveError:
|
||||
return QObject::tr("Could save file");
|
||||
case ErrorCode::CustomError:
|
||||
return error_text;
|
||||
}
|
||||
|
||||
return QObject::tr("Unknown error");
|
||||
|
||||
}
|
||||
44
src/tagreader/tagreaderresult.h
Normal file
44
src/tagreader/tagreaderresult.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERRESULT_H
|
||||
#define TAGREADERRESULT_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class TagReaderResult {
|
||||
public:
|
||||
enum class ErrorCode {
|
||||
Success,
|
||||
Unsupported,
|
||||
FilenameMissing,
|
||||
FileDoesNotExist,
|
||||
FileOpenError,
|
||||
FileParseError,
|
||||
FileSaveError,
|
||||
CustomError,
|
||||
};
|
||||
TagReaderResult(const ErrorCode _error_code = ErrorCode::Unsupported, const QString &_error_text = QString()) : error_code(_error_code), error_text(_error_text) {}
|
||||
ErrorCode error_code;
|
||||
QString error_text;
|
||||
bool success() const { return error_code == ErrorCode::Success; }
|
||||
QString error_string() const;
|
||||
};
|
||||
|
||||
#endif // TAGREADERRESULT_H
|
||||
24
src/tagreader/tagreadersavecoverrequest.cpp
Normal file
24
src/tagreader/tagreadersavecoverrequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreadersavecoverrequest.h"
|
||||
|
||||
TagReaderSaveCoverRequest::TagReaderSaveCoverRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
43
src/tagreader/tagreadersavecoverrequest.h
Normal file
43
src/tagreader/tagreadersavecoverrequest.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERSAVECOVERREQUEST_H
|
||||
#define TAGREADERSAVECOVERREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
#include "savetagcoverdata.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderSaveCoverRequest : public TagReaderRequest {
|
||||
public:
|
||||
|
||||
explicit TagReaderSaveCoverRequest(const QString &_filename);
|
||||
|
||||
static SharedPtr<TagReaderSaveCoverRequest> Create(const QString &filename) { return make_shared<TagReaderSaveCoverRequest>(filename); }
|
||||
|
||||
SaveTagCoverData save_tag_cover_data;
|
||||
};
|
||||
|
||||
using TagReaderSaveCoverRequestPtr = SharedPtr<TagReaderSaveCoverRequest>;
|
||||
|
||||
#endif // TAGREADERSAVECOVERREQUEST_H
|
||||
24
src/tagreader/tagreadersaveplaycountrequest.cpp
Normal file
24
src/tagreader/tagreadersaveplaycountrequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreadersaveplaycountrequest.h"
|
||||
|
||||
TagReaderSavePlaycountRequest::TagReaderSavePlaycountRequest(const QString &_filename) : TagReaderRequest(_filename), playcount(0) {}
|
||||
39
src/tagreader/tagreadersaveplaycountrequest.h
Normal file
39
src/tagreader/tagreadersaveplaycountrequest.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERSAVEPLAYCOUNTREQUEST_H
|
||||
#define TAGREADERSAVEPLAYCOUNTREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderSavePlaycountRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderSavePlaycountRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderSavePlaycountRequest> Create(const QString &filename) { return make_shared<TagReaderSavePlaycountRequest>(filename); }
|
||||
uint playcount;
|
||||
};
|
||||
|
||||
using TagReaderSavePlaycountRequestPtr = SharedPtr<TagReaderSavePlaycountRequest>;
|
||||
|
||||
#endif // TAGREADERSAVEPLAYCOUNTREQUEST_H
|
||||
24
src/tagreader/tagreadersaveratingrequest.cpp
Normal file
24
src/tagreader/tagreadersaveratingrequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreadersaveratingrequest.h"
|
||||
|
||||
TagReaderSaveRatingRequest::TagReaderSaveRatingRequest(const QString &_filename) : TagReaderRequest(_filename), rating(0.0F) {}
|
||||
39
src/tagreader/tagreadersaveratingrequest.h
Normal file
39
src/tagreader/tagreadersaveratingrequest.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERSAVERATINGREQUEST_H
|
||||
#define TAGREADERSAVERATINGREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "tagreaderrequest.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderSaveRatingRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderSaveRatingRequest(const QString &_filename);
|
||||
static SharedPtr<TagReaderSaveRatingRequest> Create(const QString &filename) { return make_shared<TagReaderSaveRatingRequest>(filename); }
|
||||
float rating;
|
||||
};
|
||||
|
||||
using TagReaderSaveRatingRequestPtr = SharedPtr<TagReaderSaveRatingRequest>;
|
||||
|
||||
#endif // TAGREADERSAVERATINGREQUEST_H
|
||||
1886
src/tagreader/tagreadertaglib.cpp
Normal file
1886
src/tagreader/tagreadertaglib.cpp
Normal file
File diff suppressed because it is too large
Load Diff
127
src/tagreader/tagreadertaglib.h
Normal file
127
src/tagreader/tagreadertaglib.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2013, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERTAGLIB_H
|
||||
#define TAGREADERTAGLIB_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include <taglib/tstring.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/xiphcomment.h>
|
||||
#include <taglib/flacfile.h>
|
||||
#include <taglib/mpegfile.h>
|
||||
#include <taglib/mp4file.h>
|
||||
#include <taglib/apetag.h>
|
||||
#include <taglib/apefile.h>
|
||||
#include <taglib/asffile.h>
|
||||
#include <taglib/id3v2tag.h>
|
||||
#include <taglib/popularimeterframe.h>
|
||||
#include <taglib/mp4tag.h>
|
||||
#include <taglib/asftag.h>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
#include "tagreaderbase.h"
|
||||
#include "savetagcoverdata.h"
|
||||
|
||||
#undef TStringToQString
|
||||
#undef QStringToTString
|
||||
|
||||
class FileRefFactory;
|
||||
|
||||
class TagReaderTagLib : public TagReaderBase {
|
||||
public:
|
||||
explicit TagReaderTagLib();
|
||||
~TagReaderTagLib() override;
|
||||
|
||||
static inline TagLib::String QStringToTagLibString(const QString &s) {
|
||||
return TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8);
|
||||
}
|
||||
|
||||
static inline QString TagLibStringToQString(const TagLib::String &s) {
|
||||
return QString::fromUtf8((s).toCString(true));
|
||||
}
|
||||
|
||||
TagReaderResult IsMediaFile(const QString &filename) const override;
|
||||
|
||||
TagReaderResult ReadFile(const QString &filename, Song *song) const override;
|
||||
TagReaderResult WriteFile(const QString &filename, const Song &song, const SaveTagsOptions save_tags_options, const SaveTagCoverData &save_tag_cover_data) const override;
|
||||
|
||||
TagReaderResult LoadEmbeddedCover(const QString &filename, QByteArray &data) const override;
|
||||
TagReaderResult SaveEmbeddedCover(const QString &filename, const SaveTagCoverData &save_tag_cover_data) const override;
|
||||
|
||||
TagReaderResult SaveSongPlaycount(const QString &filename, const uint playcount) const override;
|
||||
TagReaderResult SaveSongRating(const QString &filename, const float rating) const override;
|
||||
|
||||
private:
|
||||
Song::FileType GuessFileType(TagLib::FileRef *fileref) const;
|
||||
|
||||
void ParseID3v2Tags(TagLib::ID3v2::Tag *tag, QString *disc, QString *compilation, Song *song) const;
|
||||
void ParseVorbisComments(const TagLib::Ogg::FieldListMap &map, QString *disc, QString *compilation, Song *song) const;
|
||||
void ParseAPETags(const TagLib::APE::ItemListMap &map, QString *disc, QString *compilation, Song *song) const;
|
||||
void ParseMP4Tags(TagLib::MP4::Tag *tag, QString *disc, QString *compilation, Song *song) const;
|
||||
void ParseASFTags(TagLib::ASF::Tag *tag, QString *disc, QString *compilation, Song *song) const;
|
||||
void ParseASFAttribute(const TagLib::ASF::AttributeListMap &attributes_map, const char *attribute, QString *str) const;
|
||||
|
||||
void SetID3v2Tag(TagLib::ID3v2::Tag *tag, const Song &song) const;
|
||||
void SetTextFrame(const char *id, const QString &value, TagLib::ID3v2::Tag *tag) const;
|
||||
void SetUserTextFrame(const QString &description, const QString &value, TagLib::ID3v2::Tag *tag) const;
|
||||
void SetUnsyncLyricsFrame(const QString &value, TagLib::ID3v2::Tag *tag) const;
|
||||
|
||||
void SetVorbisComments(TagLib::Ogg::XiphComment *vorbis_comment, const Song &song) const;
|
||||
void SetAPETag(TagLib::APE::Tag *tag, const Song &song) const;
|
||||
void SetASFTag(TagLib::ASF::Tag *tag, const Song &song) const;
|
||||
void SetAsfAttribute(TagLib::ASF::Tag *tag, const char *attribute, const QString &value) const;
|
||||
void SetAsfAttribute(TagLib::ASF::Tag *tag, const char *attribute, const int value) const;
|
||||
|
||||
QByteArray LoadEmbeddedAPECover(const TagLib::APE::ItemListMap &map) const;
|
||||
|
||||
static TagLib::ID3v2::PopularimeterFrame *GetPOPMFrameFromTag(TagLib::ID3v2::Tag *tag);
|
||||
|
||||
void SetPlaycount(TagLib::Ogg::XiphComment *vorbis_comment, const uint playcount) const;
|
||||
void SetPlaycount(TagLib::APE::Tag *tag, const uint playcount) const;
|
||||
void SetPlaycount(TagLib::ID3v2::Tag *tag, const uint playcount) const;
|
||||
void SetPlaycount(TagLib::MP4::Tag *tag, const uint playcount) const;
|
||||
void SetPlaycount(TagLib::ASF::Tag *tag, const uint playcount) const;
|
||||
|
||||
void SetRating(TagLib::Ogg::XiphComment *vorbis_comment, const float rating) const;
|
||||
void SetRating(TagLib::APE::Tag *tag, const float rating) const;
|
||||
void SetRating(TagLib::ID3v2::Tag *tag, const float rating) const;
|
||||
void SetRating(TagLib::MP4::Tag *tag, const float rating) const;
|
||||
void SetRating(TagLib::ASF::Tag *tag, const float rating) const;
|
||||
|
||||
void SetEmbeddedCover(TagLib::FLAC::File *flac_file, TagLib::Ogg::XiphComment *vorbis_comment, const QByteArray &data, const QString &mimetype) const;
|
||||
void SetEmbeddedCover(TagLib::Ogg::XiphComment *vorbis_comment, const QByteArray &data, const QString &mimetype) const;
|
||||
void SetEmbeddedCover(TagLib::ID3v2::Tag *tag, const QByteArray &data, const QString &mimetype) const;
|
||||
void SetEmbeddedCover(TagLib::MP4::File *aac_file, TagLib::MP4::Tag *tag, const QByteArray &data, const QString &mimetype) const;
|
||||
|
||||
static TagLib::String TagLibStringListToSlashSeparatedString(const TagLib::StringList &taglib_string_list);
|
||||
|
||||
private:
|
||||
FileRefFactory *factory_;
|
||||
|
||||
Q_DISABLE_COPY(TagReaderTagLib)
|
||||
};
|
||||
|
||||
#endif // TAGREADERTAGLIB_H
|
||||
24
src/tagreader/tagreaderwritefilerequest.cpp
Normal file
24
src/tagreader/tagreaderwritefilerequest.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "tagreaderwritefilerequest.h"
|
||||
|
||||
TagReaderWriteFileRequest::TagReaderWriteFileRequest(const QString &_filename) : TagReaderRequest(_filename) {}
|
||||
46
src/tagreader/tagreaderwritefilerequest.h
Normal file
46
src/tagreader/tagreaderwritefilerequest.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TAGREADERWRITEFILEREQUEST_H
|
||||
#define TAGREADERWRITEFILEREQUEST_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "tagreaderrequest.h"
|
||||
#include "savetagsoptions.h"
|
||||
#include "savetagcoverdata.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
class TagReaderWriteFileRequest : public TagReaderRequest {
|
||||
public:
|
||||
explicit TagReaderWriteFileRequest(const QString &_filename);
|
||||
|
||||
static SharedPtr<TagReaderWriteFileRequest> Create(const QString &filename) { return make_shared<TagReaderWriteFileRequest>(filename); }
|
||||
|
||||
SaveTagsOptions save_tags_options;
|
||||
Song song;
|
||||
SaveTagCoverData save_tag_cover_data;
|
||||
};
|
||||
|
||||
using TagReaderWriteFileRequestPtr = SharedPtr<TagReaderWriteFileRequest>;
|
||||
|
||||
#endif // TAGREADERWRITEFILEREQUEST_H
|
||||
Reference in New Issue
Block a user