aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Input/archive/archive.pro6
-rw-r--r--src/plugins/Input/archive/archivetagreader.cpp103
-rw-r--r--src/plugins/Input/archive/archivetagreader.h25
-rw-r--r--src/plugins/Input/archive/decoder_archive.cpp22
-rw-r--r--src/plugins/Input/archive/decoderarchivefactory.cpp4
-rw-r--r--src/plugins/Input/archive/decoderarchivefactory.h2
6 files changed, 144 insertions, 18 deletions
diff --git a/src/plugins/Input/archive/archive.pro b/src/plugins/Input/archive/archive.pro
index 8cd6b7548..6c8c84352 100644
--- a/src/plugins/Input/archive/archive.pro
+++ b/src/plugins/Input/archive/archive.pro
@@ -3,12 +3,14 @@ include(../../plugins.pri)
HEADERS += \
archiveinputdevice.h \
decoderarchivefactory.h \
- decoder_archive.h
+ decoder_archive.h \
+ archivetagreader.h
SOURCES += \
archiveinputdevice.cpp \
decoderarchivefactory.cpp \
- decoder_archive.cpp
+ decoder_archive.cpp \
+ archivetagreader.cpp
TARGET=$$PLUGINS_PREFIX/Input/archive
diff --git a/src/plugins/Input/archive/archivetagreader.cpp b/src/plugins/Input/archive/archivetagreader.cpp
new file mode 100644
index 000000000..e79f4db59
--- /dev/null
+++ b/src/plugins/Input/archive/archivetagreader.cpp
@@ -0,0 +1,103 @@
+#include <taglib/tiostream.h>
+#include <taglib/fileref.h>
+#include "archivetagreader.h"
+
+class IODeviceStream : public TagLib::IOStream
+{
+public:
+ IODeviceStream(QIODevice *input, const QString &fileName)
+ {
+ m_input = input;
+ m_fileName = fileName;
+ }
+
+ virtual ~IODeviceStream() {}
+
+ virtual TagLib::FileName name() const
+ {
+ return QStringToFileName(m_fileName);
+ }
+ virtual TagLib::ByteVector readBlock(unsigned long length)
+ {
+ QByteArray data = m_input->read(length);
+ return TagLib::ByteVector(data.constData(), data.size());
+ }
+ virtual void writeBlock(const TagLib::ByteVector &)
+ {}
+ virtual void insert(const TagLib::ByteVector &, unsigned long, unsigned long)
+ {}
+ virtual void removeBlock(unsigned long, unsigned long)
+ {}
+ virtual bool readOnly() const
+ {
+ return true;
+ }
+ virtual bool isOpen() const
+ {
+ return m_input->isOpen();
+ }
+ virtual void seek(long offset, Position p = Beginning)
+ {
+ switch (p)
+ {
+ case Beginning:
+ m_input->seek(offset);
+ return;
+ case Current:
+ m_input->seek(m_input->pos() + offset);
+ return;
+ case End:
+ m_input->seek(m_input->size() - offset);
+ return;
+ }
+ return;
+ }
+
+
+ virtual void clear()
+ {
+ m_input->reset();
+ TagLib::IOStream::clear();
+ }
+ virtual long tell() const
+ {
+ return m_input->pos();
+ }
+ virtual long length()
+ {
+ return m_input->size();
+ }
+ virtual void truncate(long)
+ {}
+
+private:
+ QString m_fileName;
+ QIODevice *m_input;
+
+};
+
+ArchiveTagReader::ArchiveTagReader(QIODevice *input, const QString &fileName)
+{
+ m_stream = new IODeviceStream(input, fileName);
+}
+
+ArchiveTagReader::~ArchiveTagReader()
+{
+ delete m_stream;
+}
+
+/*const QMap<Qmmp::MetaData, QString> ArchiveTagReader::metaData() const
+{
+ TagLib::FileRef file(m_stream);
+ QMap<Qmmp::MetaData, QString> m;
+
+ m[Qmmp::ALBUM, QString::fromUtf8(tag->album().toCString(true)).trimmed()];
+ m[Qmmp::ARTIST, QString::fromUtf8(tag->artist().toCString(true)).trimmed()];
+ m[Qmmp::COMMENT, QString::fromUtf8(tag->comment().toCString(true)).trimmed()];
+ m[Qmmp::GENRE, QString::fromUtf8(tag->genre().toCString(true)).trimmed()];
+ m[Qmmp::TITLE, QString::fromUtf8(tag->title().toCString(true)).trimmed()];
+ m[Qmmp::YEAR, tag->year());
+ m[Qmmp::TRACK, tag->track());
+
+ return m;
+}*/
diff --git a/src/plugins/Input/archive/archivetagreader.h b/src/plugins/Input/archive/archivetagreader.h
new file mode 100644
index 000000000..918f4383f
--- /dev/null
+++ b/src/plugins/Input/archive/archivetagreader.h
@@ -0,0 +1,25 @@
+#ifndef ARCHIVETAGREADER_H
+#define ARCHIVETAGREADER_H
+
+#include <QIODevice>
+#include <QMap>
+#include <qmmp/qmmp.h>
+
+class IODeviceStream;
+
+class ArchiveTagReader
+{
+public:
+ ArchiveTagReader(QIODevice *input, const QString &fileName);
+
+ ~ArchiveTagReader();
+
+ //const QMap<Qmmp::MetaData, QString> metaData () const;
+
+
+
+private:
+ IODeviceStream *m_stream;
+};
+
+#endif // ARCHIVETAGREADER_H
diff --git a/src/plugins/Input/archive/decoder_archive.cpp b/src/plugins/Input/archive/decoder_archive.cpp
index 89f93cf9a..24e7f15d5 100644
--- a/src/plugins/Input/archive/decoder_archive.cpp
+++ b/src/plugins/Input/archive/decoder_archive.cpp
@@ -40,7 +40,7 @@ bool DecoderArchive::initialize()
if(!QFile::exists(archivePath))
{
- qWarning("DecoderArc: file '%s' not found", qPrintable(archivePath));
+ qWarning("DecoderArchive: file '%s' not found", qPrintable(archivePath));
return false;
}
@@ -63,7 +63,7 @@ bool DecoderArchive::initialize()
if(filtered.isEmpty())
{
- qWarning("DecoderArc: unable to find decoder");
+ qWarning("DecoderArchive: unable to find decoder");
return false;
}
@@ -74,7 +74,7 @@ bool DecoderArchive::initialize()
int r = archive_read_open_filename(m_archive, archivePath.toLocal8Bit().constData(), 10240);
if (r != ARCHIVE_OK)
{
- qWarning("DecoderArc: unable to open file '%s', error code: %d", qPrintable(archivePath), r);
+ qWarning("DecoderArchive: unable to open file '%s', error code: %d", qPrintable(archivePath), r);
return false;
}
@@ -96,7 +96,7 @@ bool DecoderArchive::initialize()
if(!m_input)
{
- qWarning("DecoderArc: unable to find file '%s' inside archive '%s'", qPrintable(filePath),
+ qWarning("DecoderArchive: unable to find file '%s' inside archive '%s'", qPrintable(filePath),
qPrintable(archivePath));
return false;
}
@@ -106,7 +106,7 @@ bool DecoderArchive::initialize()
factory = filtered.first();
else
{
- //several factories, so trying to determine by content
+ //multiple factories, so trying to determine by content
foreach (DecoderFactory *fact, filtered)
{
if(fact->canDecode(m_input))
@@ -119,22 +119,18 @@ bool DecoderArchive::initialize()
if(!factory)
{
- qWarning("DecoderArc: unable to find supported decoder factory");
+ qWarning("DecoderArchive: unable to find decoder factory");
return false;
}
- qDebug("DecoderArc: selected decoder: %s", qPrintable(factory->properties().shortName));
- qDebug("+");
+ qDebug("DecoderArchive: selected decoder: %s", qPrintable(factory->properties().shortName));
m_decoder = factory->create(m_url, m_input);
- qDebug("+1");
if(!m_decoder->initialize())
{
- qWarning("DecoderArc: unable to initialize decoder");
+ qWarning("DecoderArchive: unable to initialize decoder");
return false;
}
- qDebug("+2");
- configure(m_decoder->audioParameters().sampleRate(), m_decoder->audioParameters().channelMap(),
- m_decoder->audioParameters().format());
+ configure(m_decoder->audioParameters());
return true;
}
diff --git a/src/plugins/Input/archive/decoderarchivefactory.cpp b/src/plugins/Input/archive/decoderarchivefactory.cpp
index 9765664a5..f6157503c 100644
--- a/src/plugins/Input/archive/decoderarchivefactory.cpp
+++ b/src/plugins/Input/archive/decoderarchivefactory.cpp
@@ -26,8 +26,8 @@
#include "decoder_archive.h"
#include "decoderarchivefactory.h"
-// DecoderSndFileFactory
-bool DecoderArchiveFactory::canDecode(QIODevice *input) const
+// DecoderArchiveFileFactory
+bool DecoderArchiveFactory::canDecode(QIODevice *) const
{
return false;
}
diff --git a/src/plugins/Input/archive/decoderarchivefactory.h b/src/plugins/Input/archive/decoderarchivefactory.h
index bf4a20829..31d3f8b45 100644
--- a/src/plugins/Input/archive/decoderarchivefactory.h
+++ b/src/plugins/Input/archive/decoderarchivefactory.h
@@ -37,7 +37,7 @@ Q_OBJECT
Q_INTERFACES(DecoderFactory)
public:
- bool canDecode(QIODevice *input) const;
+ bool canDecode(QIODevice *) const;
const DecoderProperties properties() const;
Decoder *create(const QString &url, QIODevice *);
QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData, QStringList *);