aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/qmmp/Input/Input.pro8
-rw-r--r--lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp29
-rw-r--r--lib/qmmp/Input/ffmpeg/ffmpeg.pro6
-rw-r--r--lib/qmmp/Input/ffmpeg/tag.cpp98
-rw-r--r--lib/qmmp/Input/ffmpeg/tag.h64
-rw-r--r--lib/qmmp/Input/flac/decoderflacfactory.cpp28
-rw-r--r--lib/qmmp/Input/flac/flac.pro8
-rw-r--r--lib/qmmp/Input/flac/tag.cpp97
-rw-r--r--lib/qmmp/Input/flac/tag.h61
-rw-r--r--lib/qmmp/Input/mad/decodermadfactory.cpp96
-rw-r--r--lib/qmmp/Input/mad/id3tag.cpp172
-rw-r--r--lib/qmmp/Input/mad/id3tag.h70
-rw-r--r--lib/qmmp/Input/mad/mad.pro6
-rw-r--r--lib/qmmp/Input/mpc/decodermpcfactory.cpp30
-rw-r--r--lib/qmmp/Input/mpc/mpc.pro2
-rw-r--r--lib/qmmp/Input/mpc/tag.cpp97
-rw-r--r--lib/qmmp/Input/mpc/tag.h61
-rw-r--r--lib/qmmp/Input/vorbis/decoder_vorbis.cpp1
-rw-r--r--lib/qmmp/Input/vorbis/decodervorbisfactory.cpp4
19 files changed, 180 insertions, 758 deletions
diff --git a/lib/qmmp/Input/Input.pro b/lib/qmmp/Input/Input.pro
index 1c3147ef5..d3a12eb91 100644
--- a/lib/qmmp/Input/Input.pro
+++ b/lib/qmmp/Input/Input.pro
@@ -1,24 +1,24 @@
include(../../../qmmp.pri)
-SUBDIRS += vorbis
+SUBDIRS += mad vorbis
TEMPLATE = subdirs
contains(CONFIG, MUSEPACK_PLUGIN){
-# SUBDIRS += mpc
+ SUBDIRS += mpc
message(***************************)
message(* Musepack plugin enabled *)
message(***************************)
}
contains(CONFIG, FLAC_PLUGIN){
-# SUBDIRS += flac
+ SUBDIRS += flac
message(***********************)
message(* FLAC plugin enabled *)
message(***********************)
}
contains(CONFIG, FFMPEG_PLUGIN){
-# SUBDIRS += ffmpeg
+ SUBDIRS += ffmpeg
message(*************************)
message(* FFMPEG plugin enabled *)
message(*************************)
diff --git a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
index acd40c4e8..09d878990 100644
--- a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
+++ b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
@@ -1,8 +1,12 @@
#include <QtGui>
+extern "C"{
+#include <ffmpeg/avformat.h>
+#include <ffmpeg/avcodec.h>
+}
+
#include "detailsdialog.h"
#include "decoder_ffmpeg.h"
-#include "tag.h"
#include "decoderffmpegfactory.h"
@@ -14,7 +18,7 @@ bool DecoderFFmpegFactory::supports(const QString &source) const
return (source.right(4).toLower() == ".wma" || source.right(4).toLower() == ".wav");
}
-bool DecoderFFmpegFactory::canDecode(QIODevice *input) const
+bool DecoderFFmpegFactory::canDecode(QIODevice *) const
{
return FALSE;
}
@@ -39,8 +43,25 @@ Decoder *DecoderFFmpegFactory::create(QObject *parent, QIODevice *input,
FileTag *DecoderFFmpegFactory::createTag(const QString &source)
{
- FileTag *tag = new Tag(source);
- return tag;
+ FileTag *ftag = new FileTag();
+ avcodec_init();
+ avcodec_register_all();
+ av_register_all();
+ AVFormatContext *in;
+
+ if (av_open_input_file(&in, source.toLocal8Bit(), NULL,0, NULL) < 0)
+ return ftag;
+ av_find_stream_info(in);
+ ftag->setValue(FileTag::ALBUM, QString::fromUtf8(in->album).trimmed());
+ ftag->setValue(FileTag::ARTIST, QString::fromUtf8(in->author).trimmed());
+ ftag->setValue(FileTag::COMMENT, QString::fromUtf8(in->comment).trimmed());
+ ftag->setValue(FileTag::GENRE, QString::fromUtf8(in->genre).trimmed());
+ ftag->setValue(FileTag::TITLE, QString::fromUtf8(in->title).trimmed());
+ ftag->setValue(FileTag::YEAR, in->year);
+ ftag->setValue(FileTag::TRACK, in->track);
+ ftag->setValue(FileTag::LENGTH ,int(in->duration/AV_TIME_BASE));
+ av_close_input_file(in);
+ return ftag;
}
void DecoderFFmpegFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/lib/qmmp/Input/ffmpeg/ffmpeg.pro b/lib/qmmp/Input/ffmpeg/ffmpeg.pro
index e10985311..db96d3464 100644
--- a/lib/qmmp/Input/ffmpeg/ffmpeg.pro
+++ b/lib/qmmp/Input/ffmpeg/ffmpeg.pro
@@ -1,10 +1,8 @@
FORMS += detailsdialog.ui
HEADERS += decoderffmpegfactory.h \
- tag.h \
- detailsdialog.h \
+ detailsdialog.h \
decoder_ffmpeg.h
-SOURCES += tag.cpp \
- detailsdialog.cpp \
+SOURCES += detailsdialog.cpp \
decoder_ffmpeg.cpp \
decoderffmpegfactory.cpp
DESTDIR = ../
diff --git a/lib/qmmp/Input/ffmpeg/tag.cpp b/lib/qmmp/Input/ffmpeg/tag.cpp
deleted file mode 100644
index 7a642de87..000000000
--- a/lib/qmmp/Input/ffmpeg/tag.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "tag.h"
-
-Tag::Tag(const QString &source)
- : FileTag()
-{
- m_length = 0;
- m_year = 0;
- m_track = 0;
- m_empty = TRUE;
-
- avcodec_init();
- avcodec_register_all();
- av_register_all();
-
- if (av_open_input_file(&m_in, source.toLocal8Bit(), NULL,0, NULL) < 0)
- return;
- av_find_stream_info(m_in);
- m_album = QString::fromUtf8(m_in->album).trimmed();
- m_artist = QString::fromUtf8(m_in->author).trimmed();
- m_comment = QString::fromUtf8(m_in->comment).trimmed();
- m_genre = QString::fromUtf8(m_in->genre).trimmed();
- m_title = QString::fromUtf8(m_in->title).trimmed();
- m_year = m_in->year;
- m_track = m_in->track;
- m_length = int(m_in->duration/AV_TIME_BASE);
- m_empty = FALSE;
-
- av_close_input_file(m_in);
-}
-
-
-Tag::~Tag()
-{}
-
-
-bool Tag::isEmpty()
-{
- return m_empty;
-}
-
-QString Tag::album()
-{
- return m_album;
-}
-
-QString Tag::artist()
-{
- return m_artist;
-}
-
-QString Tag::comment()
-{
- return m_comment;
-}
-
-QString Tag::genre()
-{
- return m_genre;
-}
-
-QString Tag::title()
-{
- return m_title;
-}
-
-uint Tag::length()
-{
- return m_length;
-}
-
-uint Tag::track()
-{
- return m_track;
-}
-
-uint Tag::year()
-{
- return m_year;
-}
diff --git a/lib/qmmp/Input/ffmpeg/tag.h b/lib/qmmp/Input/ffmpeg/tag.h
deleted file mode 100644
index df55ae24e..000000000
--- a/lib/qmmp/Input/ffmpeg/tag.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifndef XIPHCOMMENT_H
-#define XIPHCOMMENT_H
-
-extern "C"{
-#include <ffmpeg/avformat.h>
-#include <ffmpeg/avcodec.h>
-}
-
-#include <filetag.h>
-
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class Tag : public FileTag
-{
-public:
- Tag(const QString &source);
-
- ~Tag();
-
- virtual QString album();
- virtual QString artist();
- virtual QString comment();
- virtual QString genre();
- virtual QString title();
- virtual uint length();
- virtual uint track();
- virtual uint year();
- virtual bool isEmpty();
-
-private:
- //TagLib::Tag *m_tag;
- AVFormatContext *m_in;
- QString m_album;
- QString m_artist;
- QString m_comment;
- QString m_genre;
- QString m_title;
- uint m_length;
- uint m_year;
- uint m_track;
- bool m_empty;
-};
-
-#endif
diff --git a/lib/qmmp/Input/flac/decoderflacfactory.cpp b/lib/qmmp/Input/flac/decoderflacfactory.cpp
index a6b5e1188..cf8643ce4 100644
--- a/lib/qmmp/Input/flac/decoderflacfactory.cpp
+++ b/lib/qmmp/Input/flac/decoderflacfactory.cpp
@@ -4,7 +4,6 @@
#include "detailsdialog.h"
#include "decoder_flac.h"
-#include "tag.h"
#include "decoderflacfactory.h"
@@ -41,8 +40,31 @@ Decoder *DecoderFLACFactory::create(QObject *parent, QIODevice *input,
FileTag *DecoderFLACFactory::createTag(const QString &source)
{
- FileTag *tag = new Tag(source);
- return tag;
+ FileTag *ftag = new FileTag();
+
+ TagLib::FileRef fileRef(source.toLocal8Bit ());
+ TagLib::Tag *tag = fileRef.tag();
+
+ if (tag && !tag->isEmpty())
+ {
+ ftag->setValue(FileTag::ALBUM,
+ QString::fromUtf8(tag->album().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::ARTIST,
+ QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::COMMENT,
+ QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::GENRE,
+ QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::TITLE,
+ QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::YEAR, tag->year());
+ ftag->setValue(FileTag::TRACK, tag->track());
+ }
+
+ if (fileRef.audioProperties())
+ ftag->setValue(FileTag::LENGTH, fileRef.audioProperties()->length());
+
+ return ftag;
}
void DecoderFLACFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/lib/qmmp/Input/flac/flac.pro b/lib/qmmp/Input/flac/flac.pro
index ec81ffd10..618123e36 100644
--- a/lib/qmmp/Input/flac/flac.pro
+++ b/lib/qmmp/Input/flac/flac.pro
@@ -4,14 +4,12 @@
# ???? - ??????????:
FORMS += detailsdialog.ui
-HEADERS += tag.h \
- decoderflacfactory.h \
+HEADERS += decoderflacfactory.h \
decoder_flac.h \
- detailsdialog.h
+ detailsdialog.h
SOURCES += decoder_flac.cpp \
decoderflacfactory.cpp \
- detailsdialog.cpp \
- tag.cpp
+ detailsdialog.cpp
DESTDIR = ../
QMAKE_CLEAN += ../libflac.so
INCLUDEPATH += ../../../
diff --git a/lib/qmmp/Input/flac/tag.cpp b/lib/qmmp/Input/flac/tag.cpp
deleted file mode 100644
index fd3530c0c..000000000
--- a/lib/qmmp/Input/flac/tag.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "tag.h"
-
-Tag::Tag(const QString &source)
- : FileTag()
-{
- m_length = 0;
- m_year = 0;
- m_track = 0;
- m_empty = TRUE;
- TagLib::FileRef fileRef(source.toLocal8Bit ());
-
- m_tag = fileRef.tag();
- if(m_tag && !m_tag->isEmpty())
- {
- m_album = QString::fromUtf8(m_tag->album().toCString(TRUE)).trimmed();
- m_artist = QString::fromUtf8(m_tag->artist().toCString(TRUE)).trimmed();
- m_comment = QString::fromUtf8(m_tag->comment().toCString(TRUE)).trimmed();
- m_genre = QString::fromUtf8(m_tag->genre().toCString(TRUE)).trimmed();
- m_title = QString::fromUtf8(m_tag->title().toCString(TRUE)).trimmed();
- m_year = 0;
- m_track = 0;
- m_empty = FALSE;
- }
- else
- m_tag = 0;
- if(fileRef.audioProperties())
- m_length = fileRef.audioProperties()->length();
-}
-
-
-Tag::~Tag()
-{}
-
-
-bool Tag::isEmpty()
-{
- return m_empty;
-}
-
-QString Tag::album()
-{
- return m_album;
-}
-
-QString Tag::artist()
-{
- return m_artist;
-}
-
-QString Tag::comment()
-{
- return m_comment;
-}
-
-QString Tag::genre()
-{
- return m_genre;
-}
-
-QString Tag::title()
-{
- return m_title;
-}
-
-uint Tag::length()
-{
- return m_length;
-}
-
-uint Tag::track()
-{
- return m_track;
-}
-
-uint Tag::year()
-{
- return m_year;
-}
diff --git a/lib/qmmp/Input/flac/tag.h b/lib/qmmp/Input/flac/tag.h
deleted file mode 100644
index 514f64d2a..000000000
--- a/lib/qmmp/Input/flac/tag.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifndef TAG_H
-#define TAG_H
-
-#include <taglib/tag.h>
-#include <taglib/fileref.h>
-
-#include <filetag.h>
-
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class Tag : public FileTag
-{
-public:
- Tag(const QString &source);
-
- ~Tag();
-
- virtual QString album();
- virtual QString artist();
- virtual QString comment();
- virtual QString genre();
- virtual QString title();
- virtual uint length();
- virtual uint track();
- virtual uint year();
- virtual bool isEmpty();
-
-private:
- TagLib::Tag *m_tag;
- QString m_album;
- QString m_artist;
- QString m_comment;
- QString m_genre;
- QString m_title;
- uint m_length;
- uint m_year;
- uint m_track;
- bool m_empty;
-};
-
-#endif
diff --git a/lib/qmmp/Input/mad/decodermadfactory.cpp b/lib/qmmp/Input/mad/decodermadfactory.cpp
index c503850fb..f86f6972b 100644
--- a/lib/qmmp/Input/mad/decodermadfactory.cpp
+++ b/lib/qmmp/Input/mad/decodermadfactory.cpp
@@ -12,7 +12,6 @@
#include "detailsdialog.h"
#include "settingsdialog.h"
#include "decoder_mad.h"
-#include "id3tag.h"
#include "decodermadfactory.h"
// DecoderMADFactory
@@ -38,9 +37,9 @@ bool DecoderMADFactory::canDecode(QIODevice *input) const
mad_stream_buffer (&stream, (unsigned char *) buf, sizeof(buf));
stream.error = MAD_ERROR_NONE;
- while((dec_res = mad_header_decode(&header, &stream)) == -1
+ while ((dec_res = mad_header_decode(&header, &stream)) == -1
&& MAD_RECOVERABLE(stream.error))
- ;
+ ;
return dec_res != -1 ? TRUE: FALSE;
}
return FALSE;
@@ -65,8 +64,95 @@ Decoder *DecoderMADFactory::create(QObject *parent, QIODevice *input, Output *ou
FileTag *DecoderMADFactory::createTag(const QString &source)
{
- FileTag *tag = new ID3Tag(source);
- return tag;
+ FileTag *ftag = new FileTag();
+ TagLib::Tag *tag = 0;
+ TagLib::MPEG::File fileRef(source.toLocal8Bit ());
+
+ QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
+ settings.beginGroup("MAD");
+ QTextCodec *codec_v1 =
+ QTextCodec::codecForName(settings.value("ID3v1_encoding","UTF-8" )
+ .toByteArray ());
+ QTextCodec *codec_v2 =
+ QTextCodec::codecForName(settings.value("ID3v2_encoding","UTF-8" )
+ .toByteArray ());
+ if (!codec_v1)
+ codec_v1 = QTextCodec::codecForName ("UTF-8");
+ if (!codec_v2)
+ codec_v2 = QTextCodec::codecForName ("UTF-8");
+
+ QTextCodec *codec = 0;
+
+ int ver = settings.value("ID3_version", 2).toInt();
+ if (ver == 1 && settings.value("ID3v1_enable", TRUE).toBool() &&
+ fileRef.ID3v1Tag())
+ {
+ tag = fileRef.ID3v1Tag();
+ codec = codec_v1;
+ if (tag->isEmpty())
+ {
+ tag = 0;
+ if (settings.value("ID3v2_enable", TRUE).toBool() &&
+ fileRef.ID3v2Tag())
+ {
+ if (!fileRef.ID3v2Tag()->isEmpty())
+ {
+ tag = fileRef.ID3v2Tag();
+ codec = codec_v2;
+ }
+ }
+ }
+ }
+ else
+ ver = 2;
+ if (ver == 2 && settings.value("ID3v2_enable", TRUE).toBool() &&
+ fileRef.ID3v2Tag())
+ {
+ tag = fileRef.ID3v2Tag();
+ codec = codec_v2;
+ if (tag->isEmpty())
+ {
+ tag = 0;
+ if (settings.value("ID3v1_enable", TRUE).toBool() &&
+ fileRef.ID3v1Tag())
+ {
+ if (!fileRef.ID3v1Tag()->isEmpty())
+ {
+ tag = fileRef.ID3v1Tag();
+ codec = codec_v1;
+ }
+ }
+ }
+ }
+ settings.endGroup();
+
+ if (tag && codec)
+ {
+ bool utf = codec->name ().contains("UTF");
+ TagLib::String album = tag->album();
+ TagLib::String artist = tag->artist();
+ TagLib::String comment = tag->comment();
+ TagLib::String genre = tag->genre();
+ TagLib::String title = tag->title();
+
+ ftag->setValue(FileTag::ALBUM,
+ codec->toUnicode(album.toCString(utf)).trimmed());
+ ftag->setValue(FileTag::ARTIST,
+ codec->toUnicode(artist.toCString(utf)).trimmed());
+ ftag->setValue(FileTag::COMMENT,
+ codec->toUnicode(comment.toCString(utf)).trimmed());
+ ftag->setValue(FileTag::GENRE,
+ codec->toUnicode(genre.toCString(utf)).trimmed());
+ ftag->setValue(FileTag::TITLE,
+ codec->toUnicode(title.toCString(utf)).trimmed());
+ ftag->setValue(FileTag::YEAR,
+ tag->year());
+ ftag->setValue(FileTag::TRACK,
+ tag->track());
+ }
+ if (fileRef.audioProperties())
+ ftag->setValue(FileTag::LENGTH,fileRef.audioProperties()->length());
+ return ftag;
}
void DecoderMADFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/lib/qmmp/Input/mad/id3tag.cpp b/lib/qmmp/Input/mad/id3tag.cpp
deleted file mode 100644
index 35086f8a8..000000000
--- a/lib/qmmp/Input/mad/id3tag.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-
-#include <QString>
-#include <QTextCodec>
-#include <QSettings>
-#include <QDir>
-/*#include <filetag.h>
-#include <taglib/tag.h>
-#include <taglib/fileref.h>
-#include <taglib/id3v1tag.h>
-#include <taglib/id3v2tag.h>
-#include <taglib/tfile.h>
-#include <taglib/mpegfile.h>*/
-
-#include "id3tag.h"
-
-ID3Tag::ID3Tag(const QString &source): FileTag(), m_tag(0)
-{
- m_length = 0;
- m_year = 0;
- m_track = 0;
- m_empty = TRUE;
- TagLib::MPEG::File fileRef(source.toLocal8Bit ());
-
- QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
- settings.beginGroup("MAD");
- QTextCodec *codec_v1 =
- QTextCodec::codecForName(settings.value("ID3v1_encoding","UTF-8" )
- .toByteArray ());
- QTextCodec *codec_v2 =
- QTextCodec::codecForName(settings.value("ID3v2_encoding","UTF-8" )
- .toByteArray ());
- if(!codec_v1)
- codec_v1 = QTextCodec::codecForName ("UTF-8");
- if(!codec_v2)
- codec_v2 = QTextCodec::codecForName ("UTF-8");
-
- QTextCodec *codec = 0;
-
- int ver = settings.value("ID3_version", 2).toInt();
- if (ver == 1 && settings.value("ID3v1_enable", TRUE).toBool() &&
- fileRef.ID3v1Tag())
- {
- m_tag = fileRef.ID3v1Tag();
- codec = codec_v1;
- if(m_tag->isEmpty())
- {
- m_tag = 0;
- if (settings.value("ID3v2_enable", TRUE).toBool() &&
- fileRef.ID3v2Tag())
- {
- if(!fileRef.ID3v2Tag()->isEmpty())
- {
- m_tag = fileRef.ID3v2Tag();
- codec = codec_v2;
- }
- }
- }
- }
- else
- ver = 2;
- if (ver == 2 && settings.value("ID3v2_enable", TRUE).toBool() &&
- fileRef.ID3v2Tag())
- {
- m_tag = fileRef.ID3v2Tag();
- codec = codec_v2;
- if(m_tag->isEmpty())
- {
- m_tag = 0;
- if (settings.value("ID3v1_enable", TRUE).toBool() &&
- fileRef.ID3v1Tag())
- {
- if(!fileRef.ID3v1Tag()->isEmpty())
- {
- m_tag = fileRef.ID3v1Tag();
- codec = codec_v1;
- }
- }
- }
- }
- settings.endGroup();
-
- if (m_tag && codec)
- {
- bool utf = codec->name ().contains("UTF");
- TagLib::String album = m_tag->album();
- TagLib::String artist = m_tag->artist();
- TagLib::String comment = m_tag->comment();
- TagLib::String genre = m_tag->genre();
- TagLib::String title = m_tag->title();
-
- m_album = codec->toUnicode(album.toCString(utf)).trimmed();
- m_artist = codec->toUnicode(artist.toCString(utf)).trimmed();
- m_comment = codec->toUnicode(comment.toCString(utf)).trimmed();
- m_genre = codec->toUnicode(genre.toCString(utf)).trimmed();
- m_title = codec->toUnicode(title.toCString(utf)).trimmed();
- m_year = m_tag->year();
- m_track = m_tag->track();
- m_empty = FALSE;
- }
- if(fileRef.audioProperties())
- m_length = fileRef.audioProperties()->length();
-}
-
-
-ID3Tag::~ID3Tag()
-{}
-
-
-uint ID3Tag::length()
-{
- return m_length;
-}
-
-uint ID3Tag::track()
-{
- return m_track;
-}
-
-uint ID3Tag::year()
-{
- return m_year;
-}
-
-QString ID3Tag::album()
-{
- return m_album;
-}
-
-QString ID3Tag::artist()
-{
- return m_artist;
-}
-
-QString ID3Tag::comment()
-{
- return m_comment;
-}
-
-QString ID3Tag::genre()
-{
- return m_genre;
-}
-
-QString ID3Tag::title()
-{
- return m_title;
-}
-
-bool ID3Tag::isEmpty ()
-{
- return m_empty;
-}
diff --git a/lib/qmmp/Input/mad/id3tag.h b/lib/qmmp/Input/mad/id3tag.h
deleted file mode 100644
index bb0a10d35..000000000
--- a/lib/qmmp/Input/mad/id3tag.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifndef ID3TAG_H
-#define ID3TAG_H
-
-#include <QString>
-#include <filetag.h>
-#include <taglib/tag.h>
-#include <taglib/fileref.h>
-#include <taglib/id3v1tag.h>
-#include <taglib/id3v2tag.h>
-#include <taglib/tfile.h>
-#include <taglib/mpegfile.h>
-
-#include <filetag.h>
-
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class QTextCodec;
-
-class ID3Tag : public FileTag
-{
-public:
- ID3Tag(const QString &source);
-
- ~ID3Tag();
-
- uint length();
- uint track();
- uint year();
- QString album();
- QString artist();
- QString comment();
- QString genre();
- QString title();
- bool isEmpty ();
-
-private:
- TagLib::Tag *m_tag;
- QString m_album;
- QString m_artist;
- QString m_comment;
- QString m_genre;
- QString m_title;
- uint m_length;
- uint m_year;
- uint m_track;
- bool m_empty;
-
-};
-
-#endif
diff --git a/lib/qmmp/Input/mad/mad.pro b/lib/qmmp/Input/mad/mad.pro
index 6b52fed93..f98863515 100644
--- a/lib/qmmp/Input/mad/mad.pro
+++ b/lib/qmmp/Input/mad/mad.pro
@@ -8,13 +8,11 @@ FORMS += detailsdialog.ui \
HEADERS += decodermadfactory.h \
decoder_mad.h \
detailsdialog.h \
- settingsdialog.h \
- id3tag.h
+ settingsdialog.h
SOURCES += decoder_mad.cpp \
decodermadfactory.cpp \
detailsdialog.cpp \
- settingsdialog.cpp \
- id3tag.cpp
+ settingsdialog.cpp
DESTDIR = ../
QMAKE_CLEAN += ../libmad.so
INCLUDEPATH += ../../../
diff --git a/lib/qmmp/Input/mpc/decodermpcfactory.cpp b/lib/qmmp/Input/mpc/decodermpcfactory.cpp
index de4fc5b1f..7e15174e5 100644
--- a/lib/qmmp/Input/mpc/decodermpcfactory.cpp
+++ b/lib/qmmp/Input/mpc/decodermpcfactory.cpp
@@ -4,7 +4,6 @@
#include "detailsdialog.h"
#include "decoder_mpc.h"
-#include "tag.h"
#include "decodermpcfactory.h"
@@ -16,7 +15,7 @@ bool DecoderMPCFactory::supports(const QString &source) const
return (source.right(4).toLower() == ".mpc");
}
-bool DecoderMPCFactory::canDecode(QIODevice *input) const
+bool DecoderMPCFactory::canDecode(QIODevice *) const
{
return FALSE;
}
@@ -41,8 +40,31 @@ Decoder *DecoderMPCFactory::create(QObject *parent, QIODevice *input,
FileTag *DecoderMPCFactory::createTag(const QString &source)
{
- FileTag *tag = new Tag(source);
- return tag;
+ FileTag *ftag = new FileTag();
+
+ TagLib::FileRef fileRef(source.toLocal8Bit ());
+ TagLib::Tag *tag = fileRef.tag();
+
+ if (tag && !tag->isEmpty())
+ {
+ ftag->setValue(FileTag::ALBUM,
+ QString::fromUtf8(tag->album().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::ARTIST,
+ QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::COMMENT,
+ QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::GENRE,
+ QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::TITLE,
+ QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
+ ftag->setValue(FileTag::YEAR, tag->year());
+ ftag->setValue(FileTag::TRACK, tag->track());
+ }
+
+ if (fileRef.audioProperties())
+ ftag->setValue(FileTag::LENGTH, fileRef.audioProperties()->length());
+
+ return ftag;
}
void DecoderMPCFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/lib/qmmp/Input/mpc/mpc.pro b/lib/qmmp/Input/mpc/mpc.pro
index d932740da..4b279bcc7 100644
--- a/lib/qmmp/Input/mpc/mpc.pro
+++ b/lib/qmmp/Input/mpc/mpc.pro
@@ -1,11 +1,9 @@
FORMS += detailsdialog.ui
HEADERS += decodermpcfactory.h \
decoder_mpc.h \
- tag.h \
detailsdialog.h
SOURCES += decoder_mpc.cpp \
decodermpcfactory.cpp \
- tag.cpp \
detailsdialog.cpp
DESTDIR = ../
QMAKE_CLEAN += ../libmpc.so
diff --git a/lib/qmmp/Input/mpc/tag.cpp b/lib/qmmp/Input/mpc/tag.cpp
deleted file mode 100644
index fd3530c0c..000000000
--- a/lib/qmmp/Input/mpc/tag.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "tag.h"
-
-Tag::Tag(const QString &source)
- : FileTag()
-{
- m_length = 0;
- m_year = 0;
- m_track = 0;
- m_empty = TRUE;
- TagLib::FileRef fileRef(source.toLocal8Bit ());
-
- m_tag = fileRef.tag();
- if(m_tag && !m_tag->isEmpty())
- {
- m_album = QString::fromUtf8(m_tag->album().toCString(TRUE)).trimmed();
- m_artist = QString::fromUtf8(m_tag->artist().toCString(TRUE)).trimmed();
- m_comment = QString::fromUtf8(m_tag->comment().toCString(TRUE)).trimmed();
- m_genre = QString::fromUtf8(m_tag->genre().toCString(TRUE)).trimmed();
- m_title = QString::fromUtf8(m_tag->title().toCString(TRUE)).trimmed();
- m_year = 0;
- m_track = 0;
- m_empty = FALSE;
- }
- else
- m_tag = 0;
- if(fileRef.audioProperties())
- m_length = fileRef.audioProperties()->length();
-}
-
-
-Tag::~Tag()
-{}
-
-
-bool Tag::isEmpty()
-{
- return m_empty;
-}
-
-QString Tag::album()
-{
- return m_album;
-}
-
-QString Tag::artist()
-{
- return m_artist;
-}
-
-QString Tag::comment()
-{
- return m_comment;
-}
-
-QString Tag::genre()
-{
- return m_genre;
-}
-
-QString Tag::title()
-{
- return m_title;
-}
-
-uint Tag::length()
-{
- return m_length;
-}
-
-uint Tag::track()
-{
- return m_track;
-}
-
-uint Tag::year()
-{
- return m_year;
-}
diff --git a/lib/qmmp/Input/mpc/tag.h b/lib/qmmp/Input/mpc/tag.h
deleted file mode 100644
index 3404575f4..000000000
--- a/lib/qmmp/Input/mpc/tag.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
- * forkotov02@hotmail.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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#ifndef TAG_H
-#define TAG_H
-
-#include <taglib/tag.h>
-#include <taglib/fileref.h>
-
-#include <filetag.h>
-
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class Tag : public FileTag
-{
-public:
- Tag(const QString &source);
-
- ~Tag();
-
- virtual QString album();
- virtual QString artist();
- virtual QString comment();
- virtual QString genre();
- virtual QString title();
- virtual uint length();
- virtual uint track();
- virtual uint year();
- virtual bool isEmpty();
-
-private:
- TagLib::Tag *m_tag;
- QString m_album;
- QString m_artist;
- QString m_comment;
- QString m_genre;
- QString m_title;
- uint m_length;
- uint m_year;
- uint m_track;
- bool m_empty;
-};
-
-#endif
diff --git a/lib/qmmp/Input/vorbis/decoder_vorbis.cpp b/lib/qmmp/Input/vorbis/decoder_vorbis.cpp
index 5dfe0b179..c37949085 100644
--- a/lib/qmmp/Input/vorbis/decoder_vorbis.cpp
+++ b/lib/qmmp/Input/vorbis/decoder_vorbis.cpp
@@ -265,7 +265,6 @@ void DecoderVorbis::updateTags()
vorbis_comment *comments;
FileTag tag;
- //TODO add all tags
comments = ov_comment (&oggfile, -1);
for (i = 0; i < comments->comments; i++)
{
diff --git a/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp b/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
index 53f173631..d09154d61 100644
--- a/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
+++ b/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
@@ -62,8 +62,8 @@ FileTag *DecoderVorbisFactory::createTag(const QString &source)
QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
ftag->setValue(FileTag::TITLE,
QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
- //year - ?;
- //track - ?;
+ ftag->setValue(FileTag::YEAR, tag->year());
+ ftag->setValue(FileTag::TRACK, tag->track());
}
if (fileRef.audioProperties())