summaryrefslogtreecommitdiffstats
path: root/src/metadata/asf
diff options
context:
space:
mode:
Diffstat (limited to 'src/metadata/asf')
-rw-r--r--src/metadata/asf/Makefile.am20
-rw-r--r--src/metadata/asf/asfattribute.cpp304
-rw-r--r--src/metadata/asf/asfattribute.h176
-rw-r--r--src/metadata/asf/asffile.cpp547
-rw-r--r--src/metadata/asf/asffile.h114
-rw-r--r--src/metadata/asf/asfproperties.cpp95
-rw-r--r--src/metadata/asf/asfproperties.h69
-rw-r--r--src/metadata/asf/asftag.cpp202
-rw-r--r--src/metadata/asf/asftag.h181
-rw-r--r--src/metadata/asf/taglib_asffiletyperesolver.cpp47
-rw-r--r--src/metadata/asf/taglib_asffiletyperesolver.h42
11 files changed, 1797 insertions, 0 deletions
diff --git a/src/metadata/asf/Makefile.am b/src/metadata/asf/Makefile.am
new file mode 100644
index 0000000..63fa0e1
--- /dev/null
+++ b/src/metadata/asf/Makefile.am
@@ -0,0 +1,20 @@
+SUBDIRS =
+
+INCLUDES = $(all_includes) $(taglib_includes)
+METASOURCES = AUTO
+libtagasf_la_LDFLAGS = $(all_libraries)
+noinst_LTLIBRARIES = libtagasf.la
+
+libtagasf_la_SOURCES = \
+ asfattribute.cpp \
+ asfproperties.cpp \
+ asftag.cpp \
+ asffile.cpp \
+ taglib_asffiletyperesolver.cpp
+
+noinst_HEADERS = \
+ asfattribute.h \
+ asfproperties.h \
+ asftag.h \
+ asffile.h \
+ taglib_asffiletyperesolver.h
diff --git a/src/metadata/asf/asfattribute.cpp b/src/metadata/asf/asfattribute.cpp
new file mode 100644
index 0000000..bfe81c5
--- /dev/null
+++ b/src/metadata/asf/asfattribute.cpp
@@ -0,0 +1,304 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#include <taglib.h>
+#include "asfattribute.h"
+#include "asffile.h"
+
+using namespace TagLib;
+
+class ASF::Attribute::AttributePrivate : public RefCounter
+{
+public:
+ AttributePrivate()
+ : stream(0),
+ language(0) {}
+ AttributeTypes type;
+ String stringValue;
+ ByteVector byteVectorValue;
+ union {
+ unsigned int intValue;
+ unsigned short shortValue;
+ unsigned long long longLongValue;
+ bool boolValue;
+ };
+ int stream;
+ int language;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+ASF::Attribute::Attribute()
+{
+ d = new AttributePrivate;
+ d->type = UnicodeType;
+}
+
+ASF::Attribute::Attribute(const ASF::Attribute &other)
+ : d(other.d)
+{
+ d->ref();
+}
+
+ASF::Attribute &
+ASF::Attribute::operator=(const ASF::Attribute &other)
+{
+ if(d->deref())
+ delete d;
+ d = other.d;
+ d->ref();
+ return *this;
+}
+
+ASF::Attribute::~Attribute()
+{
+ if(d->deref())
+ delete d;
+}
+
+ASF::Attribute::Attribute(const String &value)
+{
+ d = new AttributePrivate;
+ d->type = UnicodeType;
+ d->stringValue = value;
+}
+
+ASF::Attribute::Attribute(const ByteVector &value)
+{
+ d = new AttributePrivate;
+ d->type = BytesType;
+ d->byteVectorValue = value;
+}
+
+ASF::Attribute::Attribute(unsigned int value)
+{
+ d = new AttributePrivate;
+ d->type = DWordType;
+ d->intValue = value;
+}
+
+ASF::Attribute::Attribute(unsigned long long value)
+{
+ d = new AttributePrivate;
+ d->type = QWordType;
+ d->longLongValue = value;
+}
+
+ASF::Attribute::Attribute(unsigned short value)
+{
+ d = new AttributePrivate;
+ d->type = WordType;
+ d->shortValue = value;
+}
+
+ASF::Attribute::Attribute(bool value)
+{
+ d = new AttributePrivate;
+ d->type = BoolType;
+ d->boolValue = value;
+}
+
+ASF::Attribute::AttributeTypes
+ASF::Attribute::type() const
+{
+ return d->type;
+}
+
+String
+ASF::Attribute::toString() const
+{
+ return d->stringValue;
+}
+
+ByteVector
+ASF::Attribute::toByteVector() const
+{
+ return d->byteVectorValue;
+}
+
+unsigned short
+ASF::Attribute::toBool() const
+{
+ return d->shortValue;
+}
+
+unsigned short
+ASF::Attribute::toUShort() const
+{
+ return d->shortValue;
+}
+
+unsigned int
+ASF::Attribute::toUInt() const
+{
+ return d->intValue;
+}
+
+unsigned long long
+ASF::Attribute::toULongLong() const
+{
+ return d->longLongValue;
+}
+
+String
+ASF::Attribute::parse(ASF::File &f, int kind)
+{
+ int size, nameLength;
+ String name;
+
+ // extended content descriptor
+ if(kind == 0) {
+ nameLength = f.readWORD();
+ name = f.readString(nameLength);
+ d->type = ASF::Attribute::AttributeTypes(f.readWORD());
+ size = f.readWORD();
+ }
+ // metadata & metadata library
+ else {
+ int temp = f.readWORD();
+ // metadata library
+ if(kind == 2) {
+ d->language = temp;
+ }
+ d->stream = f.readWORD();
+ nameLength = f.readWORD();
+ d->type = ASF::Attribute::AttributeTypes(f.readWORD());
+ size = f.readDWORD();
+ name = f.readString(nameLength);
+ }
+
+ switch(d->type) {
+ case WordType:
+ d->shortValue = f.readWORD();
+ break;
+
+ case BoolType:
+ if(kind == 0) {
+ d->boolValue = f.readDWORD() == 1;
+ }
+ else {
+ d->boolValue = f.readWORD() == 1;
+ }
+ break;
+
+ case DWordType:
+ d->intValue = f.readDWORD();
+ break;
+
+ case QWordType:
+ d->longLongValue = f.readQWORD();
+ break;
+
+ case UnicodeType:
+ d->stringValue = f.readString(size);
+ break;
+
+ case BytesType:
+ case GuidType:
+ d->byteVectorValue = f.readBlock(size);
+ break;
+ }
+
+ return name;
+}
+
+ByteVector
+ASF::Attribute::render(const String &name, int kind) const
+{
+ ByteVector data;
+
+ switch (d->type) {
+ case WordType:
+ data.append(ByteVector::fromShort(d->shortValue, false));
+ break;
+
+ case BoolType:
+ if(kind == 0) {
+ data.append(ByteVector::fromUInt(d->boolValue ? 1 : 0, false));
+ }
+ else {
+ data.append(ByteVector::fromShort(d->boolValue ? 1 : 0, false));
+ }
+ break;
+
+ case DWordType:
+ data.append(ByteVector::fromUInt(d->intValue, false));
+ break;
+
+ case QWordType:
+ data.append(ByteVector::fromLongLong(d->longLongValue, false));
+ break;
+
+ case UnicodeType:
+ data.append(File::renderString(d->stringValue));
+ break;
+
+ case BytesType:
+ case GuidType:
+ data.append(d->byteVectorValue);
+ break;
+ }
+
+ if(kind == 0) {
+ data = File::renderString(name, true) +
+ ByteVector::fromShort((int)d->type, false) +
+ ByteVector::fromShort(data.size(), false) +
+ data;
+ }
+ else {
+ ByteVector nameData = File::renderString(name);
+ data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) +
+ ByteVector::fromShort(d->stream, false) +
+ ByteVector::fromShort(nameData.size(), false) +
+ ByteVector::fromShort((int)d->type, false) +
+ ByteVector::fromUInt(data.size(), false) +
+ nameData +
+ data;
+ }
+
+ return data;
+}
+
+int
+ASF::Attribute::language() const
+{
+ return d->language;
+}
+
+void
+ASF::Attribute::setLanguage(int value)
+{
+ d->language = value;
+}
+
+int
+ASF::Attribute::stream() const
+{
+ return d->stream;
+}
+
+void
+ASF::Attribute::setStream(int value)
+{
+ d->stream = value;
+}
diff --git a/src/metadata/asf/asfattribute.h b/src/metadata/asf/asfattribute.h
new file mode 100644
index 0000000..9a8e3c9
--- /dev/null
+++ b/src/metadata/asf/asfattribute.h
@@ -0,0 +1,176 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#ifndef TAGLIB_ASFATTRIBUTE_H
+#define TAGLIB_ASFATTRIBUTE_H
+
+#include <tstring.h>
+#include <tbytevector.h>
+
+namespace TagLib
+{
+
+ namespace ASF
+ {
+
+ class File;
+
+ class Attribute
+ {
+ public:
+
+ /*!
+ * Enum of types an Attribute can have.
+ */
+ enum AttributeTypes {
+ UnicodeType = 0,
+ BytesType = 1,
+ BoolType = 2,
+ DWordType = 3,
+ QWordType = 4,
+ WordType = 5,
+ GuidType = 6
+ };
+
+ /*!
+ * Constructs an empty attribute.
+ */
+ Attribute();
+
+ /*!
+ * Constructs an attribute with \a key and a UnicodeType \a value.
+ */
+ Attribute(const String &value);
+
+ /*!
+ * Constructs an attribute with \a key and a BytesType \a value.
+ */
+ Attribute(const ByteVector &value);
+
+ /*!
+ * Constructs an attribute with \a key and a DWordType \a value.
+ */
+ Attribute(unsigned int value);
+
+ /*!
+ * Constructs an attribute with \a key and a QWordType \a value.
+ */
+ Attribute(unsigned long long value);
+
+ /*!
+ * Constructs an attribute with \a key and a WordType \a value.
+ */
+ Attribute(unsigned short value);
+
+ /*!
+ * Constructs an attribute with \a key and a BoolType \a value.
+ */
+ Attribute(bool value);
+
+ /*!
+ * Construct an attribute as a copy of \a other.
+ */
+ Attribute(const Attribute &item);
+
+ /*!
+ * Copies the contents of \a other into this item.
+ */
+ ASF::Attribute &operator=(const Attribute &other);
+
+ /*!
+ * Destroys the attribute.
+ */
+ virtual ~Attribute();
+
+ /*!
+ * Returns type of the value.
+ */
+ AttributeTypes type() const;
+
+ /*!
+ * Returns the BoolType \a value.
+ */
+ unsigned short toBool() const;
+
+ /*!
+ * Returns the WordType \a value.
+ */
+ unsigned short toUShort() const;
+
+ /*!
+ * Returns the DWordType \a value.
+ */
+ unsigned int toUInt() const;
+
+ /*!
+ * Returns the QWordType \a value.
+ */
+ unsigned long long toULongLong() const;
+
+ /*!
+ * Returns the UnicodeType \a value.
+ */
+ String toString() const;
+
+ /*!
+ * Returns the BytesType \a value.
+ */
+ ByteVector toByteVector() const;
+
+ /*!
+ * Returns the language number, or 0 is no stream number was set.
+ */
+ int language() const;
+
+ /*!
+ * Sets the language number.
+ */
+ void setLanguage(int value);
+
+ /*!
+ * Returns the stream number, or 0 is no stream number was set.
+ */
+ int stream() const;
+
+ /*!
+ * Sets the stream number.
+ */
+ void setStream(int value);
+
+#ifndef DO_NOT_DOCUMENT
+ /* THIS IS PRIVATE, DON'T TOUCH IT! */
+ String parse(ASF::File &file, int kind = 0);
+#endif
+
+ private:
+ friend class File;
+
+ ByteVector render(const String &name, int kind = 0) const;
+
+ class AttributePrivate;
+ AttributePrivate *d;
+ };
+
+ }
+
+}
+
+#endif
diff --git a/src/metadata/asf/asffile.cpp b/src/metadata/asf/asffile.cpp
new file mode 100644
index 0000000..55a12cc
--- /dev/null
+++ b/src/metadata/asf/asffile.cpp
@@ -0,0 +1,547 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#include <tbytevectorlist.h>
+#include <tstring.h>
+#include "asffile.h"
+#include "asftag.h"
+#include "asfproperties.h"
+
+using namespace TagLib;
+
+class ASF::File::FilePrivate
+{
+public:
+ FilePrivate():
+ size(0),
+ tag(0),
+ properties(0),
+ contentDescriptionObject(0),
+ extendedContentDescriptionObject(0),
+ headerExtensionObject(0),
+ metadataObject(0),
+ metadataLibraryObject(0) {}
+ unsigned long long size;
+ ASF::Tag *tag;
+ ASF::Properties *properties;
+ List<ASF::File::BaseObject *> objects;
+ ASF::File::ContentDescriptionObject *contentDescriptionObject;
+ ASF::File::ExtendedContentDescriptionObject *extendedContentDescriptionObject;
+ ASF::File::HeaderExtensionObject *headerExtensionObject;
+ ASF::File::MetadataObject *metadataObject;
+ ASF::File::MetadataLibraryObject *metadataLibraryObject;
+};
+
+static ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
+static ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
+static ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
+static ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
+static ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
+static ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
+static ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
+static ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
+
+class ASF::File::BaseObject
+{
+public:
+ ByteVector data;
+ virtual ~BaseObject() {}
+ virtual ByteVector guid() = 0;
+ virtual void parse(ASF::File *file, unsigned int size);
+ virtual ByteVector render(ASF::File *file);
+};
+
+class ASF::File::UnknownObject : public ASF::File::BaseObject
+{
+ ByteVector myGuid;
+public:
+ UnknownObject(const ByteVector &guid);
+ ByteVector guid();
+};
+
+class ASF::File::FilePropertiesObject : public ASF::File::BaseObject
+{
+public:
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+};
+
+class ASF::File::StreamPropertiesObject : public ASF::File::BaseObject
+{
+public:
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+};
+
+class ASF::File::ContentDescriptionObject : public ASF::File::BaseObject
+{
+public:
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+ ByteVector render(ASF::File *file);
+};
+
+class ASF::File::ExtendedContentDescriptionObject : public ASF::File::BaseObject
+{
+public:
+ ByteVectorList attributeData;
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+ ByteVector render(ASF::File *file);
+};
+
+class ASF::File::MetadataObject : public ASF::File::BaseObject
+{
+public:
+ ByteVectorList attributeData;
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+ ByteVector render(ASF::File *file);
+};
+
+class ASF::File::MetadataLibraryObject : public ASF::File::BaseObject
+{
+public:
+ ByteVectorList attributeData;
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+ ByteVector render(ASF::File *file);
+};
+
+class ASF::File::HeaderExtensionObject : public ASF::File::BaseObject
+{
+public:
+ List<ASF::File::BaseObject *> objects;
+ ByteVector guid();
+ void parse(ASF::File *file, uint size);
+ ByteVector render(ASF::File *file);
+};
+
+void
+ASF::File::BaseObject::parse(ASF::File *file, unsigned int size)
+{
+ data = file->readBlock(size - 24);
+}
+
+ByteVector
+ASF::File::BaseObject::render(ASF::File * /*file*/)
+{
+ return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data;
+}
+
+ASF::File::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid)
+{
+}
+
+ByteVector
+ASF::File::UnknownObject::guid()
+{
+ return myGuid;
+}
+
+ByteVector
+ASF::File::FilePropertiesObject::guid()
+{
+ return filePropertiesGuid;
+}
+
+void
+ASF::File::FilePropertiesObject::parse(ASF::File *file, uint size)
+{
+ BaseObject::parse(file, size);
+ file->d->properties->setLength((int)(data.mid(40, 8).toLongLong(false) / 10000000L - data.mid(56, 8).toLongLong(false) / 1000L));
+}
+
+ByteVector
+ASF::File::StreamPropertiesObject::guid()
+{
+ return streamPropertiesGuid;
+}
+
+void
+ASF::File::StreamPropertiesObject::parse(ASF::File *file, uint size)
+{
+ BaseObject::parse(file, size);
+ file->d->properties->setChannels(data.mid(56, 2).toShort(false));
+ file->d->properties->setSampleRate(data.mid(58, 4).toUInt(false));
+ file->d->properties->setBitrate(data.mid(62, 4).toUInt(false) * 8 / 1000);
+}
+
+ByteVector
+ASF::File::ContentDescriptionObject::guid()
+{
+ return contentDescriptionGuid;
+}
+
+void
+ASF::File::ContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
+{
+ file->d->contentDescriptionObject = this;
+ int titleLength = file->readWORD();
+ int artistLength = file->readWORD();
+ int copyrightLength = file->readWORD();
+ int commentLength = file->readWORD();
+ int ratingLength = file->readWORD();
+ file->d->tag->setTitle(file->readString(titleLength));
+ file->d->tag->setArtist(file->readString(artistLength));
+ file->d->tag->setCopyright(file->readString(copyrightLength));
+ file->d->tag->setComment(file->readString(commentLength));
+ file->d->tag->setRating(file->readString(ratingLength));
+}
+
+ByteVector
+ASF::File::ContentDescriptionObject::render(ASF::File *file)
+{
+ ByteVector v1 = file->renderString(file->d->tag->title());
+ ByteVector v2 = file->renderString(file->d->tag->artist());
+ ByteVector v3 = file->renderString(file->d->tag->copyright());
+ ByteVector v4 = file->renderString(file->d->tag->comment());
+ ByteVector v5 = file->renderString(file->d->tag->rating());
+ data.clear();
+ data.append(ByteVector::fromShort(v1.size(), false));
+ data.append(ByteVector::fromShort(v2.size(), false));
+ data.append(ByteVector::fromShort(v3.size(), false));
+ data.append(ByteVector::fromShort(v4.size(), false));
+ data.append(ByteVector::fromShort(v5.size(), false));
+ data.append(v1);
+ data.append(v2);
+ data.append(v3);
+ data.append(v4);
+ data.append(v5);
+ return BaseObject::render(file);
+}
+
+ByteVector
+ASF::File::ExtendedContentDescriptionObject::guid()
+{
+ return extendedContentDescriptionGuid;
+}
+
+void
+ASF::File::ExtendedContentDescriptionObject::parse(ASF::File *file, uint /*size*/)
+{
+ file->d->extendedContentDescriptionObject = this;
+ int count = file->readWORD();
+ while(count--) {
+ ASF::Attribute attribute;
+ String name = attribute.parse(*file);
+ file->d->tag->addAttribute(name, attribute);
+ }
+}
+
+ByteVector
+ASF::File::ExtendedContentDescriptionObject::render(ASF::File *file)
+{
+ data.clear();
+ data.append(ByteVector::fromShort(attributeData.size(), false));
+ data.append(attributeData.toByteVector(ByteVector::null));
+ return BaseObject::render(file);
+}
+
+ByteVector
+ASF::File::MetadataObject::guid()
+{
+ return metadataGuid;
+}
+
+void
+ASF::File::MetadataObject::parse(ASF::File *file, uint /*size*/)
+{
+ file->d->metadataObject = this;
+ int count = file->readWORD();
+ while(count--) {
+ ASF::Attribute attribute;
+ String name = attribute.parse(*file, 1);
+ file->d->tag->addAttribute(name, attribute);
+ }
+}
+
+ByteVector
+ASF::File::MetadataObject::render(ASF::File *file)
+{
+ data.clear();
+ data.append(ByteVector::fromShort(attributeData.size(), false));
+ data.append(attributeData.toByteVector(ByteVector::null));
+ return BaseObject::render(file);
+}
+
+ByteVector
+ASF::File::MetadataLibraryObject::guid()
+{
+ return metadataLibraryGuid;
+}
+
+void
+ASF::File::MetadataLibraryObject::parse(ASF::File *file, uint /*size*/)
+{
+ file->d->metadataLibraryObject = this;
+ int count = file->readWORD();
+ while(count--) {
+ ASF::Attribute attribute;
+ String name = attribute.parse(*file, 2);
+ file->d->tag->addAttribute(name, attribute);
+ }
+}
+
+ByteVector
+ASF::File::MetadataLibraryObject::render(ASF::File *file)
+{
+ data.clear();
+ data.append(ByteVector::fromShort(attributeData.size(), false));
+ data.append(attributeData.toByteVector(ByteVector::null));
+ return BaseObject::render(file);
+}
+
+ByteVector
+ASF::File::HeaderExtensionObject::guid()
+{
+ return headerExtensionGuid;
+}
+
+void
+ASF::File::HeaderExtensionObject::parse(ASF::File *file, uint /*size*/)
+{
+ file->d->headerExtensionObject = this;
+ file->seek(18, File::Current);
+ long long dataSize = file->readDWORD();
+ long long dataPos = 0;
+ while(dataPos < dataSize) {
+ ByteVector guid = file->readBlock(16);
+ long long size = file->readQWORD();
+ BaseObject *obj;
+ if(guid == metadataGuid) {
+ obj = new MetadataObject();
+ }
+ else if(guid == metadataLibraryGuid) {
+ obj = new MetadataLibraryObject();
+ }
+ else {
+ obj = new UnknownObject(guid);
+ }
+ obj->parse(file, size);
+ objects.append(obj);
+ dataPos += size;
+ }
+}
+
+ByteVector
+ASF::File::HeaderExtensionObject::render(ASF::File *file)
+{
+ data.clear();
+ for(unsigned int i = 0; i < objects.size(); i++) {
+ data.append(objects[i]->render(file));
+ }
+ data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt(data.size(), false) + data;
+ return BaseObject::render(file);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+ASF::File::File(const char *file, bool readProperties, Properties::ReadStyle propertiesStyle)
+ : TagLib::File(file)
+{
+ d = new FilePrivate;
+ read(readProperties, propertiesStyle);
+}
+
+ASF::File::~File()
+{
+ for(unsigned int i = 0; i < d->objects.size(); i++) {
+ delete d->objects[i];
+ }
+ if(d->tag) {
+ delete d->tag;
+ }
+ if(d->properties) {
+ delete d->properties;
+ }
+ delete d;
+}
+
+ASF::Tag *ASF::File::tag() const
+{
+ return d->tag;
+}
+
+ASF::Properties *ASF::File::audioProperties() const
+{
+ return d->properties;
+}
+
+void ASF::File::read(bool /*readProperties*/, Properties::ReadStyle /*propertiesStyle*/)
+{
+ if(!isValid())
+ return;
+
+ ByteVector guid = readBlock(16);
+ if(guid != headerGuid) {
+ return;
+ }
+
+ d->tag = new ASF::Tag();
+ d->properties = new ASF::Properties();
+
+ d->size = readQWORD();
+ int numObjects = readDWORD();
+ seek(2, Current);
+
+ for(int i = 0; i < numObjects; i++) {
+ ByteVector guid = readBlock(16);
+ long size = (long)readQWORD();
+ BaseObject *obj;
+ if(guid == filePropertiesGuid) {
+ obj = new FilePropertiesObject();
+ }
+ else if(guid == streamPropertiesGuid) {
+ obj = new StreamPropertiesObject();
+ }
+ else if(guid == contentDescriptionGuid) {
+ obj = new ContentDescriptionObject();
+ }
+ else if(guid == extendedContentDescriptionGuid) {
+ obj = new ExtendedContentDescriptionObject();
+ }
+ else if(guid == headerExtensionGuid) {
+ obj = new HeaderExtensionObject();
+ }
+ else {
+ obj = new UnknownObject(guid);
+ }
+ obj->parse(this, size);
+ d->objects.append(obj);
+ }
+}
+
+bool ASF::File::save()
+{
+ if(readOnly()) {
+ return false;
+ }
+
+ if(!d->contentDescriptionObject) {
+ d->contentDescriptionObject = new ContentDescriptionObject();
+ d->objects.append(d->contentDescriptionObject);
+ }
+ if(!d->extendedContentDescriptionObject) {
+ d->extendedContentDescriptionObject = new ExtendedContentDescriptionObject();
+ d->objects.append(d->extendedContentDescriptionObject);
+ }
+ if(!d->headerExtensionObject) {
+ d->headerExtensionObject = new HeaderExtensionObject();
+ d->objects.append(d->headerExtensionObject);
+ }
+ if(!d->metadataObject) {
+ d->metadataObject = new MetadataObject();
+ d->headerExtensionObject->objects.append(d->metadataObject);
+ }
+ if(!d->metadataLibraryObject) {
+ d->metadataLibraryObject = new MetadataLibraryObject();
+ d->headerExtensionObject->objects.append(d->metadataLibraryObject);
+ }
+
+ ASF::AttributeListMap::ConstIterator it = d->tag->attributeListMap().begin();
+ for(; it != d->tag->attributeListMap().end(); it++) {
+ const String &name = it->first;
+ const AttributeList &attributes = it->second;
+ bool inExtendedContentDescriptionObject = false;
+ bool inMetadataObject = false;
+ for(unsigned int j = 0; j < attributes.size(); j++) {
+ const Attribute &attribute = attributes[j];
+ if(!inExtendedContentDescriptionObject && attribute.language() == 0 && attribute.stream() == 0) {
+ d->extendedContentDescriptionObject->attributeData.append(attribute.render(name));
+ inExtendedContentDescriptionObject = true;
+ }
+ else if(!inMetadataObject && attribute.language() == 0 && attribute.stream() != 0) {
+ d->metadataObject->attributeData.append(attribute.render(name, 1));
+ inMetadataObject = true;
+ }
+ else {
+ d->metadataLibraryObject->attributeData.append(attribute.render(name, 2));
+ }
+ }
+ }
+
+ ByteVector data;
+ for(unsigned int i = 0; i < d->objects.size(); i++) {
+ data.append(d->objects[i]->render(this));
+ }
+ data = headerGuid + ByteVector::fromLongLong(data.size() + 30, false) + ByteVector::fromUInt(d->objects.size(), false) + ByteVector("\x01\x02", 2) + data;
+ insert(data, 0, d->size);
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// protected members
+////////////////////////////////////////////////////////////////////////////////
+
+int ASF::File::readBYTE()
+{
+ ByteVector v = readBlock(1);
+ return v[0];
+}
+
+int ASF::File::readWORD()
+{
+ ByteVector v = readBlock(2);
+ return v.toShort(false);
+}
+
+unsigned int ASF::File::readDWORD()
+{
+ ByteVector v = readBlock(4);
+ return v.toUInt(false);
+}
+
+long long ASF::File::readQWORD()
+{
+ ByteVector v = readBlock(8);
+ return v.toLongLong(false);
+}
+
+String
+ASF::File::readString(int length)
+{
+ ByteVector data = readBlock(length);
+ unsigned int size = data.size();
+ while (size >= 2) {
+ if(data[size - 1] != '\0' || data[size - 2] != '\0') {
+ break;
+ }
+ size -= 2;
+ }
+ if(size != data.size()) {
+ data.resize(size);
+ }
+ return String(data, String::UTF16LE);
+}
+
+ByteVector
+ASF::File::renderString(const String &str, bool includeLength)
+{
+ ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
+ if(includeLength) {
+ data = ByteVector::fromShort(data.size(), false) + data;
+ }
+ return data;
+}
diff --git a/src/metadata/asf/asffile.h b/src/metadata/asf/asffile.h
new file mode 100644
index 0000000..db97331
--- /dev/null
+++ b/src/metadata/asf/asffile.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#ifndef TAGLIB_ASFFILE_H
+#define TAGLIB_ASFFILE_H
+
+#include <tag.h>
+#include <tfile.h>
+#include "asfproperties.h"
+#include "asftag.h"
+
+namespace TagLib {
+
+ //! An implementation of ASF (WMA) metadata
+ namespace ASF {
+
+ /*!
+ * This implements and provides an interface for ASF files to the
+ * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
+ * the abstract TagLib::File API as well as providing some additional
+ * information specific to ASF files.
+ */
+ class File : public TagLib::File
+ {
+ public:
+
+ /*!
+ * Contructs an ASF file from \a file. If \a readProperties is true the
+ * file's audio properties will also be read using \a propertiesStyle. If
+ * false, \a propertiesStyle is ignored.
+ *
+ * \note In the current implementation, both \a readProperties and
+ * \a propertiesStyle are ignored.
+ */
+ File(const char *file, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average);
+
+ /*!
+ * Destroys this instance of the File.
+ */
+ virtual ~File();
+
+ /*!
+ * Returns a pointer to the ASF tag of the file.
+ *
+ * ASF::Tag implements the tag interface, so this serves as the
+ * reimplementation of TagLib::File::tag().
+ *
+ * \note The Tag <b>is still</b> owned by the ASF::File and should not be
+ * deleted by the user. It will be deleted when the file (object) is
+ * destroyed.
+ */
+ virtual Tag *tag() const;
+
+ /*!
+ * Returns the ASF audio properties for this file.
+ */
+ virtual Properties *audioProperties() const;
+
+ /*!
+ * Save the file.
+ *
+ * This returns true if the save was successful.
+ */
+ virtual bool save();
+
+ private:
+
+ int readBYTE();
+ int readWORD();
+ unsigned int readDWORD();
+ long long readQWORD();
+ static ByteVector renderString(const String &str, bool includeLength = false);
+ String readString(int len);
+ void read(bool readProperties, Properties::ReadStyle propertiesStyle);
+
+ friend class Attribute;
+
+ class BaseObject;
+ class UnknownObject;
+ class FilePropertiesObject;
+ class StreamPropertiesObject;
+ class ContentDescriptionObject;
+ class ExtendedContentDescriptionObject;
+ class HeaderExtensionObject;
+ class MetadataObject;
+ class MetadataLibraryObject;
+
+ class FilePrivate;
+ FilePrivate *d;
+ };
+
+ }
+
+}
+
+#endif
diff --git a/src/metadata/asf/asfproperties.cpp b/src/metadata/asf/asfproperties.cpp
new file mode 100644
index 0000000..ca1d983
--- /dev/null
+++ b/src/metadata/asf/asfproperties.cpp
@@ -0,0 +1,95 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#include <tstring.h>
+#include "asfproperties.h"
+
+using namespace TagLib;
+
+class ASF::Properties::PropertiesPrivate
+{
+public:
+ PropertiesPrivate(): length(0), bitrate(0), sampleRate(0), channels(0) {}
+ int length;
+ int bitrate;
+ int sampleRate;
+ int channels;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+ASF::Properties::Properties() : AudioProperties(AudioProperties::Average)
+{
+ d = new PropertiesPrivate;
+}
+
+ASF::Properties::~Properties()
+{
+ if(d)
+ delete d;
+}
+
+int ASF::Properties::length() const
+{
+ return d->length;
+}
+
+int ASF::Properties::bitrate() const
+{
+ return d->bitrate;
+}
+
+int ASF::Properties::sampleRate() const
+{
+ return d->sampleRate;
+}
+
+int ASF::Properties::channels() const
+{
+ return d->channels;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// private members
+////////////////////////////////////////////////////////////////////////////////
+
+void ASF::Properties::setLength(int length)
+{
+ d->length = length;
+}
+
+void ASF::Properties::setBitrate(int length)
+{
+ d->bitrate = length;
+}
+
+void ASF::Properties::setSampleRate(int length)
+{
+ d->sampleRate = length;
+}
+
+void ASF::Properties::setChannels(int length)
+{
+ d->channels = length;
+}
+
diff --git a/src/metadata/asf/asfproperties.h b/src/metadata/asf/asfproperties.h
new file mode 100644
index 0000000..150db8a
--- /dev/null
+++ b/src/metadata/asf/asfproperties.h
@@ -0,0 +1,69 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#ifndef TAGLIB_ASFPROPERTIES_H
+#define TAGLIB_ASFPROPERTIES_H
+
+#include <audioproperties.h>
+#include <tstring.h>
+
+namespace TagLib {
+
+ namespace ASF {
+
+ //! An implementation of ASF audio properties
+ class Properties : public AudioProperties
+ {
+ public:
+
+ /*!
+ * Create an instance of ASF::Properties.
+ */
+ Properties();
+
+ /*!
+ * Destroys this ASF::Properties instance.
+ */
+ virtual ~Properties();
+
+ // Reimplementations.
+ virtual int length() const;
+ virtual int bitrate() const;
+ virtual int sampleRate() const;
+ virtual int channels() const;
+
+#ifndef DO_NOT_DOCUMENT
+ void setLength(int value);
+ void setBitrate(int value);
+ void setSampleRate(int value);
+ void setChannels(int value);
+#endif
+
+ private:
+ class PropertiesPrivate;
+ PropertiesPrivate *d;
+ };
+
+ }
+
+}
+
+#endif
diff --git a/src/metadata/asf/asftag.cpp b/src/metadata/asf/asftag.cpp
new file mode 100644
index 0000000..300887e
--- /dev/null
+++ b/src/metadata/asf/asftag.cpp
@@ -0,0 +1,202 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#include "asftag.h"
+
+using namespace TagLib;
+
+class ASF::Tag::TagPrivate
+{
+public:
+ String title;
+ String artist;
+ String copyright;
+ String comment;
+ String rating;
+ AttributeListMap attributeListMap;
+};
+
+ASF::Tag::Tag()
+: TagLib::Tag()
+{
+ d = new TagPrivate;
+}
+
+ASF::Tag::~Tag()
+{
+ if(d)
+ delete d;
+}
+
+String
+ASF::Tag::title() const
+{
+ return d->title;
+}
+
+String
+ASF::Tag::artist() const
+{
+ return d->artist;
+}
+
+String
+ASF::Tag::album() const
+{
+ if(d->attributeListMap.contains("WM/AlbumTitle"))
+ return d->attributeListMap["WM/AlbumTitle"][0].toString();
+ return String::null;
+}
+
+String
+ASF::Tag::copyright() const
+{
+ return d->copyright;
+}
+
+String
+ASF::Tag::comment() const
+{
+ return d->comment;
+}
+
+String
+ASF::Tag::rating() const
+{
+ return d->rating;
+}
+
+unsigned int
+ASF::Tag::year() const
+{
+ if(d->attributeListMap.contains("WM/Year"))
+ return d->attributeListMap["WM/Year"][0].toString().toInt();
+ return 0;
+}
+
+unsigned int
+ASF::Tag::track() const
+{
+ if(d->attributeListMap.contains("WM/TrackNumber"))
+ return d->attributeListMap["WM/TrackNumber"][0].toString().toInt();
+ if(d->attributeListMap.contains("WM/Track"))
+ return d->attributeListMap["WM/Track"][0].toUInt();
+ return 0;
+}
+
+String
+ASF::Tag::genre() const
+{
+ if(d->attributeListMap.contains("WM/Genre"))
+ return d->attributeListMap["WM/Genre"][0].toString();
+ return String::null;
+}
+
+void
+ASF::Tag::setTitle(const String &value)
+{
+ d->title = value;
+}
+
+void
+ASF::Tag::setArtist(const String &value)
+{
+ d->artist = value;
+}
+
+void
+ASF::Tag::setCopyright(const String &value)
+{
+ d->copyright = value;
+}
+
+void
+ASF::Tag::setComment(const String &value)
+{
+ d->comment = value;
+}
+
+void
+ASF::Tag::setRating(const String &value)
+{
+ d->rating = value;
+}
+
+void
+ASF::Tag::setAlbum(const String &value)
+{
+ setAttribute("WM/AlbumTitle", value);
+}
+
+void
+ASF::Tag::setGenre(const String &value)
+{
+ setAttribute("WM/Genre", value);
+}
+
+void
+ASF::Tag::setYear(uint value)
+{
+ setAttribute("WM/Year", String::number(value));
+}
+
+void
+ASF::Tag::setTrack(uint value)
+{
+ setAttribute("WM/TrackNumber", String::number(value));
+}
+
+ASF::AttributeListMap&
+ASF::Tag::attributeListMap()
+{
+ return d->attributeListMap;
+}
+
+void ASF::Tag::removeItem(const String &key)
+{
+ AttributeListMap::Iterator it = d->attributeListMap.find(key);
+ if(it != d->attributeListMap.end())
+ d->attributeListMap.erase(it);
+}
+
+void ASF::Tag::setAttribute(const String &name, const Attribute &attribute)
+{
+ AttributeList value;
+ value.append(attribute);
+ d->attributeListMap.insert(name, value);
+}
+
+void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
+{
+ if(d->attributeListMap.contains(name)) {
+ d->attributeListMap[name].append(attribute);
+ }
+ else {
+ setAttribute(name, attribute);
+ }
+}
+
+bool ASF::Tag::isEmpty() const {
+ return TagLib::Tag::isEmpty() &&
+ copyright().isEmpty() &&
+ rating().isEmpty() &&
+ d->attributeListMap.isEmpty();
+}
diff --git a/src/metadata/asf/asftag.h b/src/metadata/asf/asftag.h
new file mode 100644
index 0000000..f282dee
--- /dev/null
+++ b/src/metadata/asf/asftag.h
@@ -0,0 +1,181 @@
+/**************************************************************************
+ copyright : (C) 2005-2007 by Lukáš Lalinský
+ email : lalinsky@gmail.com
+ **************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA *
+ ***************************************************************************/
+
+#ifndef TAGLIB_ASFTAG_H
+#define TAGLIB_ASFTAG_H
+
+#include <tag.h>
+#include <tlist.h>
+#include <tmap.h>
+#include "asfattribute.h"
+
+namespace TagLib {
+
+ namespace ASF {
+
+ typedef List<Attribute> AttributeList;
+ typedef Map<String, AttributeList> AttributeListMap;
+
+ class Tag : public TagLib::Tag {
+
+ friend class File;
+
+ public:
+
+ Tag();
+
+ virtual ~Tag();
+
+ /*!
+ * Returns the track name.
+ */
+ virtual String title() const;
+
+ /*!
+ * Returns the artist name.
+ */
+ virtual String artist() const;
+
+ /*!
+ * Returns the album name; if no album name is present in the tag
+ * String::null will be returned.
+ */
+ virtual String album() const;
+
+ /*!
+ * Returns the track comment.
+ */
+ virtual String comment() const;
+
+ /*!
+ * Returns the genre name; if no genre is present in the tag String::null
+ * will be returned.
+ */
+ virtual String genre() const;
+
+ /*!
+ * Returns the rating.
+ */
+ virtual String rating() const;
+
+ /*!
+ * Returns the genre name; if no genre is present in the tag String::null
+ * will be returned.
+ */
+ virtual String copyright() const;
+
+ /*!
+ * Returns the year; if there is no year set, this will return 0.
+ */
+ virtual uint year() const;
+
+ /*!
+ * Returns the track number; if there is no track number set, this will
+ * return 0.
+ */
+ virtual uint track() const;
+
+ /*!
+ * Sets the title to \a s.
+ */
+ virtual void setTitle(const String &s);
+
+ /*!
+ * Sets the artist to \a s.
+ */
+ virtual void setArtist(const String &s);
+
+ /*!
+ * Sets the album to \a s. If \a s is String::null then this value will be
+ * cleared.
+ */
+ virtual void setAlbum(const String &s);
+
+ /*!
+ * Sets the comment to \a s.
+ */
+ virtual void setComment(const String &s);
+
+ /*!
+ * Sets the rating to \a s.
+ */
+ virtual void setRating(const String &s);
+
+ /*!
+ * Sets the copyright to \a s.
+ */
+ virtual void setCopyright(const String &s);
+
+ /*!
+ * Sets the genre to \a s.
+ */
+ virtual void setGenre(const String &s);
+
+ /*!
+ * Sets the year to \a i. If \a s is 0 then this value will be cleared.
+ */
+ virtual void setYear(uint i);
+
+ /*!
+ * Sets the track to \a i. If \a s is 0 then this value will be cleared.
+ */
+ virtual void setTrack(uint i);
+
+ /*!
+ * Returns true if the tag does not contain any data. This should be
+ * reimplemented in subclasses that provide more than the basic tagging
+ * abilities in this class.
+ */
+ virtual bool isEmpty() const;
+
+ /*!
+ * Returns a reference to the item list map. This is an AttributeListMap of
+ * all of the items in the tag.
+ *
+ * This is the most powerfull structure for accessing the items of the tag.
+ */
+ AttributeListMap &attributeListMap();
+
+ /*!
+ * Removes the \a key attribute from the tag
+ */
+ void removeItem(const String &name);
+
+ /*!
+ * Sets the \a key attribute to the value of \a attribute. If an attribute
+ * with the \a key is already present, it will be replaced.
+ */
+ void setAttribute(const String &name, const Attribute &attribute);
+
+ /*!
+ * Sets the \a key attribute to the value of \a attribute. If an attribute
+ * with the \a key is already present, it will be added to the list.
+ */
+ void addAttribute(const String &name, const Attribute &attribute);
+
+ private:
+
+ class TagPrivate;
+ TagPrivate *d;
+ };
+ }
+}
+#endif
diff --git a/src/metadata/asf/taglib_asffiletyperesolver.cpp b/src/metadata/asf/taglib_asffiletyperesolver.cpp
new file mode 100644
index 0000000..f9ed059
--- /dev/null
+++ b/src/metadata/asf/taglib_asffiletyperesolver.cpp
@@ -0,0 +1,47 @@
+/***************************************************************************
+ copyright : (C) 2005 by Martin Aumueller
+ email : aumuell@reserv.at
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ***************************************************************************/
+
+// (c) 2005 Martin Aumueller <aumuell@reserv.at>
+// See COPYING file for licensing information
+
+#include "taglib_asffiletyperesolver.h"
+#include "asffile.h"
+
+#include <string.h>
+
+TagLib::File *ASFFileTypeResolver::createFile(const char *fileName,
+ bool readProperties,
+ TagLib::AudioProperties::ReadStyle propertiesStyle) const
+{
+ const char *ext = strrchr(fileName, '.');
+ if(ext && (!strcasecmp(ext, ".wma") || !strcasecmp(ext, ".asf")))
+ {
+ TagLib::ASF::File *f = new TagLib::ASF::File(fileName, readProperties, propertiesStyle);
+ if(f->isValid())
+ return f;
+ else
+ {
+ delete f;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/metadata/asf/taglib_asffiletyperesolver.h b/src/metadata/asf/taglib_asffiletyperesolver.h
new file mode 100644
index 0000000..ab524b4
--- /dev/null
+++ b/src/metadata/asf/taglib_asffiletyperesolver.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ copyright : (C) 2005 by Martin Aumueller
+ email : aumuell@reserv.at
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ***************************************************************************/
+
+// (c) 2005 Martin Aumueller <aumuell@reserv.at>
+// See COPYING file for licensing information
+
+#ifndef TAGLIB_ASFFILETYPERESOLVER_H
+#define TAGLIB_ASFFILETYPERESOLVER_H
+
+#include <taglib/tfile.h>
+#include <taglib/fileref.h>
+
+
+class ASFFileTypeResolver : public TagLib::FileRef::FileTypeResolver
+{
+ TagLib::File *createFile(const char *fileName,
+ bool readAudioProperties,
+ TagLib::AudioProperties::ReadStyle audioPropertiesStyle) const;
+
+public:
+ virtual ~ASFFileTypeResolver() {}
+};
+
+#endif