Add support for Opus tags.
This commit is contained in:
parent
a3dbfc0674
commit
d05041dfa1
|
@ -111,6 +111,13 @@ if (USE_BUILTIN_TAGLIB AND
|
|||
add_subdirectory(3rdparty/taglib)
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES "${TAGLIB_INCLUDE_DIRS}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${TAGLIB_LIBRARIES}")
|
||||
check_cxx_source_compiles("#include <opusfile.h>
|
||||
int main() { char *s; TagLib::Ogg::Opus::File opusfile(s); return 0;}" TAGLIB_HAS_OPUS)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
if(LASTFM_INCLUDE_DIRS AND LASTFM1_INCLUDE_DIRS)
|
||||
set(HAVE_LIBLASTFM1 ON)
|
||||
endif()
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#include <mpcfile.h>
|
||||
#include <mpegfile.h>
|
||||
#include <oggfile.h>
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
#include <opusfile.h>
|
||||
#endif
|
||||
#include <oggflacfile.h>
|
||||
#include <speexfile.h>
|
||||
#include <tag.h>
|
||||
|
@ -232,7 +235,16 @@ void TagReaderWorker::ReadFile(const QString& filename,
|
|||
ParseOggTag(file->tag()->fieldListMap(), NULL, &disc, &compilation, song);
|
||||
}
|
||||
Decode(tag->comment(), NULL, song->mutable_comment());
|
||||
} else if (TagLib::FLAC::File* file = dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
|
||||
}
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
else if (TagLib::Ogg::Opus::File* file = dynamic_cast<TagLib::Ogg::Opus::File*>(fileref->file())) {
|
||||
if (file->tag()) {
|
||||
ParseOggTag(file->tag()->fieldListMap(), NULL, &disc, &compilation, song);
|
||||
}
|
||||
Decode(tag->comment(), NULL, song->mutable_comment());
|
||||
}
|
||||
#endif
|
||||
else if (TagLib::FLAC::File* file = dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
|
||||
if ( file->xiphComment() ) {
|
||||
ParseOggTag(file->xiphComment()->fieldListMap(), NULL, &disc, &compilation, song);
|
||||
#ifdef TAGLIB_HAS_FLAC_PICTURELIST
|
||||
|
@ -422,6 +434,10 @@ pb::tagreader::SongMetadata_Type TagReaderWorker::GuessFileType(
|
|||
return pb::tagreader::SongMetadata_Type_OGGSPEEX;
|
||||
if (dynamic_cast<TagLib::Ogg::Vorbis::File*>(fileref->file()))
|
||||
return pb::tagreader::SongMetadata_Type_OGGVORBIS;
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
if (dynamic_cast<TagLib::Ogg::Opus::File*>(fileref->file()))
|
||||
return pb::tagreader::SongMetadata_Type_OGGOPUS;
|
||||
#endif
|
||||
if (dynamic_cast<TagLib::RIFF::AIFF::File*>(fileref->file()))
|
||||
return pb::tagreader::SongMetadata_Type_AIFF;
|
||||
if (dynamic_cast<TagLib::RIFF::WAV::File*>(fileref->file()))
|
||||
|
@ -467,6 +483,15 @@ bool TagReaderWorker::SaveFile(const QString& filename,
|
|||
tag->addField("DISCNUMBER", QStringToTaglibString(song.disc() <= 0 -1 ? QString() : QString::number(song.disc())), true);
|
||||
tag->addField("COMPILATION", StdStringToTaglibString(song.compilation() ? "1" : "0"), true);
|
||||
}
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
else if (TagLib::Ogg::Opus::File* file = dynamic_cast<TagLib::Ogg::Opus::File*>(fileref->file())) {
|
||||
TagLib::Ogg::XiphComment* tag = file->tag();
|
||||
tag->addField("COMPOSER", StdStringToTaglibString(song.composer()), true);
|
||||
tag->addField("BPM", QStringToTaglibString(song.bpm() <= 0 -1 ? QString() : QString::number(song.bpm())), true);
|
||||
tag->addField("DISCNUMBER", QStringToTaglibString(song.disc() <= 0 -1 ? QString() : QString::number(song.disc())), true);
|
||||
tag->addField("COMPILATION", StdStringToTaglibString(song.compilation() ? "1" : "0"), true);
|
||||
}
|
||||
#endif
|
||||
else if (TagLib::FLAC::File* file = dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
|
||||
TagLib::Ogg::XiphComment* tag = file->xiphComment();
|
||||
tag->addField("COMPOSER", StdStringToTaglibString(song.composer()), true);
|
||||
|
@ -641,7 +666,17 @@ bool TagReaderWorker::ReadCloudFile(const QUrl& download_url,
|
|||
stream,
|
||||
true,
|
||||
TagLib::AudioProperties::Accurate));
|
||||
} else if (mime_type == "application/x-flac" ||
|
||||
}
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
else if (mime_type == "application/opus" ||
|
||||
mime_type == "audio/opus") {
|
||||
tag.reset(new TagLib::Ogg::Opus::File(
|
||||
stream,
|
||||
true,
|
||||
TagLib::AudioProperties::Accurate));
|
||||
}
|
||||
#endif
|
||||
else if (mime_type == "application/x-flac" ||
|
||||
mime_type == "audio/flac") {
|
||||
tag.reset(new TagLib::FLAC::File(
|
||||
stream,
|
||||
|
|
|
@ -15,6 +15,7 @@ message SongMetadata {
|
|||
WAV = 10;
|
||||
TRUEAUDIO = 11;
|
||||
CDDA = 12;
|
||||
OGGOPUS = 13;
|
||||
STREAM = 99;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#cmakedefine HAVE_UBUNTU_ONE
|
||||
#cmakedefine HAVE_WIIMOTEDEV
|
||||
#cmakedefine IMOBILEDEVICE_USES_UDIDS
|
||||
#cmakedefine TAGLIB_HAS_OPUS
|
||||
#cmakedefine USE_INSTALL_PREFIX
|
||||
#cmakedefine USE_SYSTEM_PROJECTM
|
||||
#cmakedefine USE_STD_UNORDERED_MAP
|
||||
|
|
|
@ -320,6 +320,7 @@ QString Song::TextForFiletype(FileType type) {
|
|||
case Song::Type_OggFlac: return QObject::tr("Ogg Flac");
|
||||
case Song::Type_OggSpeex: return QObject::tr("Ogg Speex");
|
||||
case Song::Type_OggVorbis: return QObject::tr("Ogg Vorbis");
|
||||
case Song::Type_OggOpus: return QObject::tr("Ogg Opus");
|
||||
case Song::Type_Aiff: return QObject::tr("AIFF");
|
||||
case Song::Type_Wav: return QObject::tr("Wav");
|
||||
case Song::Type_TrueAudio: return QObject::tr("TrueAudio");
|
||||
|
|
|
@ -94,6 +94,7 @@ class Song {
|
|||
Type_Wav = 10,
|
||||
Type_TrueAudio = 11,
|
||||
Type_Cdda = 12,
|
||||
Type_OggOpus = 13,
|
||||
|
||||
Type_Stream = 99,
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
const char* FileView::kFileFilter = "*.mp3 *.ogg *.flac *.mpc *.m4a *.aac *.wma "
|
||||
"*.mp4 *.spx *.wav *.m3u *.m3u8 *.pls *.xspf "
|
||||
"*.asx *.asxini *.cue *.ape *.wv *.mka";
|
||||
"*.asx *.asxini *.cue *.ape *.wv *.mka *.opus";
|
||||
|
||||
FileView::FileView(QWidget* parent)
|
||||
: QWidget(parent),
|
||||
|
|
Loading…
Reference in New Issue