diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-05-30 17:49:34 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-05-30 17:49:34 +0000 |
| commit | 6e2d0b2231c3a3537ea6bb2c27874e6f15b2dcda (patch) | |
| tree | 7e60e20d7ddbb7a028a147af6e80215ba0608d8d /src/plugins/Input | |
| parent | 9b80a143f0ba56ba50a0108c94f005df62cbeade (diff) | |
| download | qmmp-6e2d0b2231c3a3537ea6bb2c27874e6f15b2dcda.tar.gz qmmp-6e2d0b2231c3a3537ea6bb2c27874e6f15b2dcda.tar.bz2 qmmp-6e2d0b2231c3a3537ea6bb2c27874e6f15b2dcda.zip | |
enabled opus plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7976 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
| -rw-r--r-- | src/plugins/Input/Input.pro | 2 | ||||
| -rw-r--r-- | src/plugins/Input/opus/decoder_opus.cpp | 3 | ||||
| -rw-r--r-- | src/plugins/Input/opus/decoderopusfactory.cpp | 82 | ||||
| -rw-r--r-- | src/plugins/Input/opus/decoderopusfactory.h | 13 | ||||
| -rw-r--r-- | src/plugins/Input/opus/opus.pro | 6 | ||||
| -rw-r--r-- | src/plugins/Input/opus/replaygainreader.cpp | 63 | ||||
| -rw-r--r-- | src/plugins/Input/opus/replaygainreader.h | 44 |
7 files changed, 46 insertions, 167 deletions
diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro index bc82b29c8..bef91bc20 100644 --- a/src/plugins/Input/Input.pro +++ b/src/plugins/Input/Input.pro @@ -28,7 +28,7 @@ contains(CONFIG, GME_PLUGIN){ } contains(CONFIG, OPUS_PLUGIN){ - #SUBDIRS += opus + SUBDIRS += opus } contains(CONFIG, CDAUDIO_PLUGIN){ diff --git a/src/plugins/Input/opus/decoder_opus.cpp b/src/plugins/Input/opus/decoder_opus.cpp index d4d3883f6..1c68f7e55 100644 --- a/src/plugins/Input/opus/decoder_opus.cpp +++ b/src/plugins/Input/opus/decoder_opus.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,7 +22,6 @@ #include <QIODevice> #include <qmmp/buffer.h> #include <qmmp/output.h> -#include <qmmp/fileinfo.h> #include "decoder_opus.h" // ic functions for libopusfile diff --git a/src/plugins/Input/opus/decoderopusfactory.cpp b/src/plugins/Input/opus/decoderopusfactory.cpp index 6a0444751..859175beb 100644 --- a/src/plugins/Input/opus/decoderopusfactory.cpp +++ b/src/plugins/Input/opus/decoderopusfactory.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -23,7 +23,6 @@ #include <taglib/tag.h> #include <taglib/fileref.h> #include <taglib/opusfile.h> -#include "replaygainreader.h" #include "decoder_opus.h" #include "opusmetadatamodel.h" #include "decoderopusfactory.h" @@ -54,13 +53,7 @@ const DecoderProperties DecoderOpusFactory::properties() const Decoder *DecoderOpusFactory::create(const QString &url, QIODevice *input) { - Decoder *d = new DecoderOpus(url, input); - if(!url.contains("://")) //local file - { - ReplayGainReader rg(url); - d->setReplayGainInfo(rg.replayGainInfo()); - } - return d; + return new DecoderOpus(url, input); } MetaDataModel* DecoderOpusFactory::createMetaDataModel(const QString &path, QObject *parent) @@ -68,49 +61,52 @@ MetaDataModel* DecoderOpusFactory::createMetaDataModel(const QString &path, QObj return new OpusMetaDataModel(path, parent); } -QList<FileInfo *> DecoderOpusFactory::createPlayList(const QString &fileName, bool useMetaData, QStringList *) +QList<TrackInfo *> DecoderOpusFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *) { - FileInfo *info = new FileInfo(fileName); + TrackInfo *info = new TrackInfo(path); + + TagLib::Ogg::Opus::File fileRef(QStringToFileName(path)); + - TagLib::Ogg::Opus::File fileRef(QStringToFileName(fileName)); - TagLib::Ogg::XiphComment *tag = useMetaData ? fileRef.tag() : 0; + if(fileRef.audioProperties()) + info->setDuration(fileRef.audioProperties()->lengthInMilliseconds()); + + if((parts & TrackInfo::MetaData) && fileRef.tag() && !fileRef.tag()->isEmpty()) + { + TagLib::Ogg::XiphComment *tag = fileRef.tag(); + info->setValue(Qmmp::ALBUM, TStringToQString(tag->album())); + info->setValue(Qmmp::ARTIST, TStringToQString(tag->artist())); + info->setValue(Qmmp::COMMENT, TStringToQString(tag->comment())); + info->setValue(Qmmp::GENRE, TStringToQString(tag->genre())); + info->setValue(Qmmp::TITLE, TStringToQString(tag->title())); + info->setValue(Qmmp::YEAR, tag->year()); + info->setValue(Qmmp::TRACK, tag->track()); + } - if (tag && !tag->isEmpty()) + if((parts & TrackInfo::Properties) && fileRef.audioProperties()) { - info->setMetaData(Qmmp::ALBUM, - QString::fromUtf8(tag->album().toCString(true)).trimmed()); - info->setMetaData(Qmmp::ARTIST, - QString::fromUtf8(tag->artist().toCString(true)).trimmed()); - info->setMetaData(Qmmp::COMMENT, - QString::fromUtf8(tag->comment().toCString(true)).trimmed()); - info->setMetaData(Qmmp::GENRE, - QString::fromUtf8(tag->genre().toCString(true)).trimmed()); - info->setMetaData(Qmmp::TITLE, - QString::fromUtf8(tag->title().toCString(true)).trimmed()); - info->setMetaData(Qmmp::YEAR, tag->year()); - info->setMetaData(Qmmp::TRACK, tag->track()); + info->setValue(Qmmp::BITRATE, fileRef.audioProperties()->bitrate()); + info->setValue(Qmmp::SAMPLERATE, fileRef.audioProperties()->sampleRate()); + info->setValue(Qmmp::CHANNELS, fileRef.audioProperties()->channels()); + info->setValue(Qmmp::BITS_PER_SAMPLE, 16); + info->setValue(Qmmp::FORMAT_NAME, "Ogg Vorbis"); } - if (fileRef.audioProperties()) - info->setLength(fileRef.audioProperties()->length()); - //additional metadata - if(tag) + if((parts & TrackInfo::ReplayGainInfo) && fileRef.tag() && !fileRef.tag()->isEmpty()) { - TagLib::StringList fld; - if(!(fld = tag->fieldListMap()["ALBUMARTIST"]).isEmpty()) - info->setMetaData(Qmmp::ALBUMARTIST, - QString::fromUtf8(fld.front().toCString(true)).trimmed()); - if(!(fld = tag->fieldListMap()["COMPOSER"]).isEmpty()) - info->setMetaData(Qmmp::COMPOSER, - QString::fromUtf8(fld.front().toCString(true)).trimmed()); - if(!(fld = tag->fieldListMap()["DISCNUMBER"]).isEmpty()) - info->setMetaData(Qmmp::DISCNUMBER, - QString::fromUtf8(fld.front().toCString(true)).trimmed()); + TagLib::Ogg::XiphComment *tag = fileRef.tag(); + TagLib::Ogg::FieldListMap items = tag->fieldListMap(); + if(items.contains("REPLAYGAIN_TRACK_GAIN")) + info->setValue(Qmmp::REPLAYGAIN_TRACK_GAIN, TStringToQString(items["REPLAYGAIN_TRACK_GAIN"].front())); + if(items.contains("REPLAYGAIN_TRACK_PEAK")) + info->setValue(Qmmp::REPLAYGAIN_TRACK_PEAK, TStringToQString(items["REPLAYGAIN_TRACK_PEAK"].front())); + if(items.contains("REPLAYGAIN_ALBUM_GAIN")) + info->setValue(Qmmp::REPLAYGAIN_ALBUM_GAIN, TStringToQString(items["REPLAYGAIN_ALBUM_GAIN"].front())); + if(items.contains("REPLAYGAIN_ALBUM_PEAK")) + info->setValue(Qmmp::REPLAYGAIN_ALBUM_PEAK, TStringToQString(items["REPLAYGAIN_ALBUM_PEAK"].front())); } - QList <FileInfo*> list; - list << info; - return list; + return QList<TrackInfo*>() << info; } void DecoderOpusFactory::showSettings(QWidget *) diff --git a/src/plugins/Input/opus/decoderopusfactory.h b/src/plugins/Input/opus/decoderopusfactory.h index efee2f2dd..539014832 100644 --- a/src/plugins/Input/opus/decoderopusfactory.h +++ b/src/plugins/Input/opus/decoderopusfactory.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -20,15 +20,8 @@ #ifndef DECODEROPUSFACTORY_H #define DECODEROPUSFACTORY_H -#include <QObject> -#include <QString> -#include <QIODevice> -#include <QWidget> -#include <qmmp/decoder.h> -#include <qmmp/output.h> #include <qmmp/decoderfactory.h> -#include <qmmp/fileinfo.h> -#include <qmmp/metadatamodel.h> + /** @author Ilya Kotov <forkotov02@ya.ru> @@ -44,7 +37,7 @@ public: const DecoderProperties properties() const; Decoder *create(const QString &path, QIODevice *input); MetaDataModel* createMetaDataModel(const QString &path, QObject *parent = 0); - QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData, QStringList *); + QList<TrackInfo *> createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *); QObject* showDetails(QWidget *parent, const QString &path); void showSettings(QWidget *parent); void showAbout(QWidget *parent); diff --git a/src/plugins/Input/opus/opus.pro b/src/plugins/Input/opus/opus.pro index 5cd5f321f..bb78a15f1 100644 --- a/src/plugins/Input/opus/opus.pro +++ b/src/plugins/Input/opus/opus.pro @@ -4,13 +4,11 @@ TARGET = $$PLUGINS_PREFIX/Input/opus HEADERS += decoderopusfactory.h \ decoder_opus.h \ - opusmetadatamodel.h \ - replaygainreader.h + opusmetadatamodel.h SOURCES += decoder_opus.cpp \ decoderopusfactory.cpp \ - opusmetadatamodel.cpp \ - replaygainreader.cpp + opusmetadatamodel.cpp RESOURCES = translations/translations.qrc diff --git a/src/plugins/Input/opus/replaygainreader.cpp b/src/plugins/Input/opus/replaygainreader.cpp deleted file mode 100644 index e125764d7..000000000 --- a/src/plugins/Input/opus/replaygainreader.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * - * forkotov02@ya.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include <QtGlobal> -#include <taglib/tag.h> -#include <taglib/fileref.h> -#include <taglib/opusfile.h> -#include <taglib/tfilestream.h> -#include "replaygainreader.h" - -ReplayGainReader::ReplayGainReader(const QString &path) -{ - TagLib::FileStream stream(QStringToFileName(path), true); - TagLib::Ogg::Opus::File fileRef(&stream); - if(fileRef.tag()) - readVorbisComment(fileRef.tag()); -} - -QMap <Qmmp::ReplayGainKey, double> ReplayGainReader::replayGainInfo() const -{ - return m_values; -} - -void ReplayGainReader::readVorbisComment(TagLib::Ogg::XiphComment *comment) -{ - TagLib::Ogg::FieldListMap items = comment->fieldListMap(); - if (items.contains("REPLAYGAIN_TRACK_GAIN")) - setValue(Qmmp::REPLAYGAIN_TRACK_GAIN,TStringToQString(items["REPLAYGAIN_TRACK_GAIN"].front())); - if (items.contains("REPLAYGAIN_TRACK_PEAK")) - setValue(Qmmp::REPLAYGAIN_TRACK_PEAK,TStringToQString(items["REPLAYGAIN_TRACK_PEAK"].front())); - if (items.contains("REPLAYGAIN_ALBUM_GAIN")) - setValue(Qmmp::REPLAYGAIN_ALBUM_GAIN,TStringToQString(items["REPLAYGAIN_ALBUM_GAIN"].front())); - if (items.contains("REPLAYGAIN_ALBUM_PEAK")) - setValue(Qmmp::REPLAYGAIN_ALBUM_PEAK,TStringToQString(items["REPLAYGAIN_ALBUM_PEAK"].front())); -} - -void ReplayGainReader::setValue(Qmmp::ReplayGainKey key, QString value) -{ - value.remove(" dB"); - if(value.isEmpty()) - return; - bool ok; - double v = value.toDouble(&ok); - if(ok) - m_values[key] = v; -} diff --git a/src/plugins/Input/opus/replaygainreader.h b/src/plugins/Input/opus/replaygainreader.h deleted file mode 100644 index 1f08d7002..000000000 --- a/src/plugins/Input/opus/replaygainreader.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013 by Ilya Kotov * - * forkotov02@ya.ru * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef REPLAYGAINREADER_H -#define REPLAYGAINREADER_H - -#include <QMap> -#include <QString> -#include <taglib/xiphcomment.h> -#include <qmmp/qmmp.h> - -/** - @author Ilya Kotov <forkotov02@ya.ru> -*/ -class ReplayGainReader -{ -public: - ReplayGainReader(const QString &path); - QMap <Qmmp::ReplayGainKey, double> replayGainInfo() const; - -private: - void readVorbisComment(TagLib::Ogg::XiphComment *comment); - void setValue(Qmmp::ReplayGainKey key, QString value); - QMap <Qmmp::ReplayGainKey, double> m_values; -}; - -#endif // REPLAYGAINREADER_H |
