Format taglib sources

This commit is contained in:
Jonas Kvinge
2020-06-13 19:02:42 +02:00
parent 72bff7fa35
commit 4ce099294c
224 changed files with 12905 additions and 15623 deletions

View File

@@ -46,16 +46,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{ enum { ApeAPEIndex = 0,
enum { ApeAPEIndex = 0, ApeID3v1Index = 1 }; ApeID3v1Index = 1 };
} }
class APE::File::FilePrivate class APE::File::FilePrivate {
{
public: public:
FilePrivate() : FilePrivate() : APELocation(-1),
APELocation(-1),
APESize(0), APESize(0),
ID3v1Location(-1), ID3v1Location(-1),
ID3v2Header(0), ID3v2Header(0),
@@ -63,8 +61,7 @@ public:
ID3v2Size(0), ID3v2Size(0),
properties(0) {} properties(0) {}
~FilePrivate() ~FilePrivate() {
{
delete ID3v2Header; delete ID3v2Header;
delete properties; delete properties;
} }
@@ -87,8 +84,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool APE::File::isSupported(IOStream*) bool APE::File::isSupported(IOStream *) {
{
// An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede. // An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede.
// FIXME: // FIXME:
@@ -102,57 +98,46 @@ bool APE::File::isSupported(IOStream*)
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
APE::File::~File() APE::File::~File() {
{
delete d; delete d;
} }
Strawberry_TagLib::TagLib::Tag *APE::File::tag() const Strawberry_TagLib::TagLib::Tag *APE::File::tag() const {
{
return &d->tag; return &d->tag;
} }
PropertyMap APE::File::properties() const PropertyMap APE::File::properties() const {
{
return d->tag.properties(); return d->tag.properties();
} }
void APE::File::removeUnsupportedProperties(const StringList &properties) void APE::File::removeUnsupportedProperties(const StringList &properties) {
{
d->tag.removeUnsupportedProperties(properties); d->tag.removeUnsupportedProperties(properties);
} }
PropertyMap APE::File::setProperties(const PropertyMap &properties) PropertyMap APE::File::setProperties(const PropertyMap &properties) {
{
if (ID3v1Tag()) if (ID3v1Tag())
ID3v1Tag()->setProperties(properties); ID3v1Tag()->setProperties(properties);
return APETag(true)->setProperties(properties); return APETag(true)->setProperties(properties);
} }
APE::Properties *APE::File::audioProperties() const APE::Properties *APE::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool APE::File::save() bool APE::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("APE::File::save() -- File is read only."); debug("APE::File::save() -- File is read only.");
return false; return false;
@@ -223,18 +208,15 @@ bool APE::File::save()
return true; return true;
} }
ID3v1::Tag *APE::File::ID3v1Tag(bool create) ID3v1::Tag *APE::File::ID3v1Tag(bool create) {
{
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, create); return d->tag.access<ID3v1::Tag>(ApeID3v1Index, create);
} }
APE::Tag *APE::File::APETag(bool create) APE::Tag *APE::File::APETag(bool create) {
{
return d->tag.access<APE::Tag>(ApeAPEIndex, create); return d->tag.access<APE::Tag>(ApeAPEIndex, create);
} }
void APE::File::strip(int tags) void APE::File::strip(int tags) {
{
if (tags & ID3v1) if (tags & ID3v1)
d->tag.set(ApeID3v1Index, 0); d->tag.set(ApeID3v1Index, 0);
@@ -245,13 +227,11 @@ void APE::File::strip(int tags)
APETag(true); APETag(true);
} }
bool APE::File::hasAPETag() const bool APE::File::hasAPETag() const {
{
return (d->APELocation >= 0); return (d->APELocation >= 0);
} }
bool APE::File::hasID3v1Tag() const bool APE::File::hasID3v1Tag() const {
{
return (d->ID3v1Location >= 0); return (d->ID3v1Location >= 0);
} }
@@ -259,8 +239,7 @@ bool APE::File::hasID3v1Tag() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void APE::File::read(bool readProperties) void APE::File::read(bool readProperties) {
{
// Look for an ID3v2 tag // Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this); d->ID3v2Location = Utils::findID3v2(this);

View File

@@ -43,8 +43,12 @@ namespace TagLib {
class Tag; class Tag;
namespace ID3v1 { class Tag; } namespace ID3v1 {
namespace APE { class Tag; } class Tag;
}
namespace APE {
class Tag;
}
//! An implementation of APE metadata //! An implementation of APE metadata
@@ -66,8 +70,7 @@ namespace TagLib {
* information specific to APE files. * information specific to APE files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* This set of flags is used for various operations and is suitable for * This set of flags is used for various operations and is suitable for
@@ -230,8 +233,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace APE
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -35,11 +35,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace APE; using namespace APE;
class APE::Footer::FooterPrivate class APE::Footer::FooterPrivate {
{
public: public:
FooterPrivate() : FooterPrivate() : version(0),
version(0),
footerPresent(true), footerPresent(true),
headerPresent(false), headerPresent(false),
isHeader(false), isHeader(false),
@@ -61,13 +59,11 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
unsigned int APE::Footer::size() unsigned int APE::Footer::size() {
{
return 32; return 32;
} }
ByteVector APE::Footer::fileIdentifier() ByteVector APE::Footer::fileIdentifier() {
{
return ByteVector("APETAGEX"); return ByteVector("APETAGEX");
} }
@@ -75,87 +71,69 @@ ByteVector APE::Footer::fileIdentifier()
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
APE::Footer::Footer() : APE::Footer::Footer() : d(new FooterPrivate()) {
d(new FooterPrivate())
{
} }
APE::Footer::Footer(const ByteVector &data) : APE::Footer::Footer(const ByteVector &data) : d(new FooterPrivate()) {
d(new FooterPrivate())
{
parse(data); parse(data);
} }
APE::Footer::~Footer() APE::Footer::~Footer() {
{
delete d; delete d;
} }
unsigned int APE::Footer::version() const unsigned int APE::Footer::version() const {
{
return d->version; return d->version;
} }
bool APE::Footer::headerPresent() const bool APE::Footer::headerPresent() const {
{
return d->headerPresent; return d->headerPresent;
} }
bool APE::Footer::footerPresent() const bool APE::Footer::footerPresent() const {
{
return d->footerPresent; return d->footerPresent;
} }
bool APE::Footer::isHeader() const bool APE::Footer::isHeader() const {
{
return d->isHeader; return d->isHeader;
} }
void APE::Footer::setHeaderPresent(bool b) const void APE::Footer::setHeaderPresent(bool b) const {
{
d->headerPresent = b; d->headerPresent = b;
} }
unsigned int APE::Footer::itemCount() const unsigned int APE::Footer::itemCount() const {
{
return d->itemCount; return d->itemCount;
} }
void APE::Footer::setItemCount(unsigned int s) void APE::Footer::setItemCount(unsigned int s) {
{
d->itemCount = s; d->itemCount = s;
} }
unsigned int APE::Footer::tagSize() const unsigned int APE::Footer::tagSize() const {
{
return d->tagSize; return d->tagSize;
} }
unsigned int APE::Footer::completeTagSize() const unsigned int APE::Footer::completeTagSize() const {
{
if (d->headerPresent) if (d->headerPresent)
return d->tagSize + size(); return d->tagSize + size();
else else
return d->tagSize; return d->tagSize;
} }
void APE::Footer::setTagSize(unsigned int s) void APE::Footer::setTagSize(unsigned int s) {
{
d->tagSize = s; d->tagSize = s;
} }
void APE::Footer::setData(const ByteVector &data) void APE::Footer::setData(const ByteVector &data) {
{
parse(data); parse(data);
} }
ByteVector APE::Footer::renderFooter() const ByteVector APE::Footer::renderFooter() const {
{
return render(false); return render(false);
} }
ByteVector APE::Footer::renderHeader() const ByteVector APE::Footer::renderHeader() const {
{
if (!d->headerPresent) if (!d->headerPresent)
return ByteVector(); return ByteVector();
else else
@@ -166,8 +144,7 @@ ByteVector APE::Footer::renderHeader() const
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void APE::Footer::parse(const ByteVector &data) void APE::Footer::parse(const ByteVector &data) {
{
if (data.size() < size()) if (data.size() < size())
return; return;
@@ -192,11 +169,9 @@ void APE::Footer::parse(const ByteVector &data)
d->headerPresent = flags[31]; d->headerPresent = flags[31];
d->footerPresent = !flags[30]; d->footerPresent = !flags[30];
d->isHeader = flags[29]; d->isHeader = flags[29];
} }
ByteVector APE::Footer::render(bool isHeader) const ByteVector APE::Footer::render(bool isHeader) const {
{
ByteVector v; ByteVector v;
// add the file identifier -- "APETAGEX" // add the file identifier -- "APETAGEX"

View File

@@ -43,8 +43,7 @@ namespace TagLib {
* headers specified there. * headers specified there.
*/ */
class TAGLIB_EXPORT Footer class TAGLIB_EXPORT Footer {
{
public: public:
/*! /*!
* Constructs an empty APE footer. * Constructs an empty APE footer.
@@ -168,8 +167,8 @@ namespace TagLib {
FooterPrivate *d; FooterPrivate *d;
}; };
} } // namespace APE
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,11 +31,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace APE; using namespace APE;
class APE::Item::ItemPrivate class APE::Item::ItemPrivate {
{
public: public:
ItemPrivate() : ItemPrivate() : type(Text),
type(Text),
readOnly(false) {} readOnly(false) {}
Item::ItemTypes type; Item::ItemTypes type;
@@ -49,28 +47,20 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
APE::Item::Item() : APE::Item::Item() : d(new ItemPrivate()) {
d(new ItemPrivate())
{
} }
APE::Item::Item(const String &key, const String &value) : APE::Item::Item(const String &key, const String &value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->key = key; d->key = key;
d->text.append(value); d->text.append(value);
} }
APE::Item::Item(const String &key, const StringList &values) : APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->key = key; d->key = key;
d->text = values; d->text = values;
} }
APE::Item::Item(const String &key, const ByteVector &value, bool binary) : APE::Item::Item(const String &key, const ByteVector &value, bool binary) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->key = key; d->key = key;
if (binary) { if (binary) {
d->type = Binary; d->type = Binary;
@@ -81,109 +71,90 @@ APE::Item::Item(const String &key, const ByteVector &value, bool binary) :
} }
} }
APE::Item::Item(const Item &item) : APE::Item::Item(const Item &item) : d(new ItemPrivate(*item.d)) {
d(new ItemPrivate(*item.d))
{
} }
APE::Item::~Item() APE::Item::~Item() {
{
delete d; delete d;
} }
Item &APE::Item::operator=(const Item &item) Item &APE::Item::operator=(const Item &item) {
{
Item(item).swap(*this); Item(item).swap(*this);
return *this; return *this;
} }
void APE::Item::swap(Item &item) void APE::Item::swap(Item &item) {
{
using std::swap; using std::swap;
swap(d, item.d); swap(d, item.d);
} }
void APE::Item::setReadOnly(bool readOnly) void APE::Item::setReadOnly(bool readOnly) {
{
d->readOnly = readOnly; d->readOnly = readOnly;
} }
bool APE::Item::isReadOnly() const bool APE::Item::isReadOnly() const {
{
return d->readOnly; return d->readOnly;
} }
void APE::Item::setType(APE::Item::ItemTypes val) void APE::Item::setType(APE::Item::ItemTypes val) {
{
d->type = val; d->type = val;
} }
APE::Item::ItemTypes APE::Item::type() const APE::Item::ItemTypes APE::Item::type() const {
{
return d->type; return d->type;
} }
String APE::Item::key() const String APE::Item::key() const {
{
return d->key; return d->key;
} }
ByteVector APE::Item::binaryData() const ByteVector APE::Item::binaryData() const {
{
return d->value; return d->value;
} }
void APE::Item::setBinaryData(const ByteVector &value) void APE::Item::setBinaryData(const ByteVector &value) {
{
d->type = Binary; d->type = Binary;
d->value = value; d->value = value;
d->text.clear(); d->text.clear();
} }
ByteVector APE::Item::value() const ByteVector APE::Item::value() const {
{
// This seems incorrect as it won't be actually rendering the value to keep it // This seems incorrect as it won't be actually rendering the value to keep it
// up to date. // up to date.
return d->value; return d->value;
} }
void APE::Item::setKey(const String &key) void APE::Item::setKey(const String &key) {
{
d->key = key; d->key = key;
} }
void APE::Item::setValue(const String &value) void APE::Item::setValue(const String &value) {
{
d->type = Text; d->type = Text;
d->text = value; d->text = value;
d->value.clear(); d->value.clear();
} }
void APE::Item::setValues(const StringList &value) void APE::Item::setValues(const StringList &value) {
{
d->type = Text; d->type = Text;
d->text = value; d->text = value;
d->value.clear(); d->value.clear();
} }
void APE::Item::appendValue(const String &value) void APE::Item::appendValue(const String &value) {
{
d->type = Text; d->type = Text;
d->text.append(value); d->text.append(value);
d->value.clear(); d->value.clear();
} }
void APE::Item::appendValues(const StringList &values) void APE::Item::appendValues(const StringList &values) {
{
d->type = Text; d->type = Text;
d->text.append(values); d->text.append(values);
d->value.clear(); d->value.clear();
} }
int APE::Item::size() const int APE::Item::size() const {
{
int result = 8 + d->key.size() + 1; int result = 8 + d->key.size() + 1;
switch (d->type) { switch (d->type) {
case Text: case Text:
@@ -205,26 +176,22 @@ int APE::Item::size() const
return result; return result;
} }
StringList APE::Item::toStringList() const StringList APE::Item::toStringList() const {
{
return d->text; return d->text;
} }
StringList APE::Item::values() const StringList APE::Item::values() const {
{
return d->text; return d->text;
} }
String APE::Item::toString() const String APE::Item::toString() const {
{
if (d->type == Text && !isEmpty()) if (d->type == Text && !isEmpty())
return d->text.front(); return d->text.front();
else else
return String(); return String();
} }
bool APE::Item::isEmpty() const bool APE::Item::isEmpty() const {
{
switch (d->type) { switch (d->type) {
case Text: case Text:
if (d->text.isEmpty()) if (d->text.isEmpty())
@@ -240,8 +207,7 @@ bool APE::Item::isEmpty() const
} }
} }
void APE::Item::parse(const ByteVector &data) void APE::Item::parse(const ByteVector &data) {
{
// 11 bytes is the minimum size for an APE item // 11 bytes is the minimum size for an APE item
if (data.size() < 11) { if (data.size() < 11) {
@@ -268,8 +234,7 @@ void APE::Item::parse(const ByteVector &data)
d->value = value; d->value = value;
} }
ByteVector APE::Item::render() const ByteVector APE::Item::render() const {
{
ByteVector data; ByteVector data;
unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1); unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1);
ByteVector value; ByteVector value;

View File

@@ -40,8 +40,7 @@ namespace TagLib {
/*! /*!
* This class provides the features of items in the APEv2 standard. * This class provides the features of items in the APEv2 standard.
*/ */
class TAGLIB_EXPORT Item class TAGLIB_EXPORT Item {
{
public: public:
/*! /*!
* Enum of types an Item can have. The value of 3 is reserved. * Enum of types an Item can have. The value of 3 is reserved.
@@ -216,11 +215,9 @@ namespace TagLib {
class ItemPrivate; class ItemPrivate;
ItemPrivate *d; ItemPrivate *d;
}; };
} } // namespace APE
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -38,11 +38,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class APE::Properties::PropertiesPrivate class APE::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : length(0),
length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
channels(0), channels(0),
@@ -63,67 +61,53 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
APE::Properties::Properties(File *, ReadStyle style) : APE::Properties::Properties(File *, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
debug("APE::Properties::Properties() -- This constructor is no longer used."); debug("APE::Properties::Properties() -- This constructor is no longer used.");
} }
APE::Properties::Properties(File *file, long streamLength, ReadStyle style) : APE::Properties::Properties(File *file, long streamLength, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
read(file, streamLength); read(file, streamLength);
} }
APE::Properties::~Properties() APE::Properties::~Properties() {
{
delete d; delete d;
} }
int APE::Properties::length() const int APE::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int APE::Properties::lengthInSeconds() const int APE::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int APE::Properties::lengthInMilliseconds() const int APE::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int APE::Properties::bitrate() const int APE::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int APE::Properties::sampleRate() const int APE::Properties::sampleRate() const {
{
return d->sampleRate; return d->sampleRate;
} }
int APE::Properties::channels() const int APE::Properties::channels() const {
{
return d->channels; return d->channels;
} }
int APE::Properties::version() const int APE::Properties::version() const {
{
return d->version; return d->version;
} }
int APE::Properties::bitsPerSample() const int APE::Properties::bitsPerSample() const {
{
return d->bitsPerSample; return d->bitsPerSample;
} }
unsigned int APE::Properties::sampleFrames() const unsigned int APE::Properties::sampleFrames() const {
{
return d->sampleFrames; return d->sampleFrames;
} }
@@ -131,19 +115,16 @@ unsigned int APE::Properties::sampleFrames() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace namespace {
{ int headerVersion(const ByteVector &header) {
int headerVersion(const ByteVector &header)
{
if (header.size() < 6 || !header.startsWith("MAC ")) if (header.size() < 6 || !header.startsWith("MAC "))
return -1; return -1;
return header.toUShort(4, false); return header.toUShort(4, false);
} }
} } // namespace
void APE::Properties::read(File *file, long streamLength) void APE::Properties::read(File *file, long streamLength) {
{
// First, we assume that the file pointer is set at the first descriptor. // First, we assume that the file pointer is set at the first descriptor.
long offset = file->tell(); long offset = file->tell();
int version = headerVersion(file->readBlock(6)); int version = headerVersion(file->readBlock(6));
@@ -174,8 +155,7 @@ void APE::Properties::read(File *file, long streamLength)
} }
} }
void APE::Properties::analyzeCurrent(File *file) void APE::Properties::analyzeCurrent(File *file) {
{
// Read the descriptor // Read the descriptor
file->seek(2, File::Current); file->seek(2, File::Current);
const ByteVector descriptor = file->readBlock(44); const ByteVector descriptor = file->readBlock(44);
@@ -210,8 +190,7 @@ void APE::Properties::analyzeCurrent(File *file)
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks; d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
} }
void APE::Properties::analyzeOld(File *file) void APE::Properties::analyzeOld(File *file) {
{
const ByteVector header = file->readBlock(26); const ByteVector header = file->readBlock(26);
if (header.size() < 26) { if (header.size() < 26) {
debug("APE::Properties::analyzeOld() -- MAC header is too short."); debug("APE::Properties::analyzeOld() -- MAC header is too short.");

View File

@@ -47,8 +47,7 @@ namespace TagLib {
* API. * API.
*/ */
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
/*! /*!
* Create an instance of APE::Properties with the data read from the * Create an instance of APE::Properties with the data read from the
@@ -138,8 +137,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace APE
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -45,13 +45,12 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace APE; using namespace APE;
namespace namespace {
{
const unsigned int MinKeyLength = 2; const unsigned int MinKeyLength = 2;
const unsigned int MaxKeyLength = 255; const unsigned int MaxKeyLength = 255;
bool isKeyValid(const ByteVector &key) bool isKeyValid(const ByteVector &key) {
{
const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 }; const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 };
// only allow printable ASCII including space (32..126) // only allow printable ASCII including space (32..126)
@@ -70,14 +69,11 @@ namespace
return true; return true;
} }
} } // namespace
class APE::Tag::TagPrivate class APE::Tag::TagPrivate {
{
public: public:
TagPrivate() : TagPrivate() : file(0), footerLocation(0) {}
file(0),
footerLocation(0) {}
File *file; File *file;
long footerLocation; long footerLocation;
@@ -90,124 +86,115 @@ public:
// public methods // public methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
APE::Tag::Tag() : APE::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {}
Strawberry_TagLib::TagLib::Tag(),
d(new TagPrivate()) APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation) : Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {
{
}
APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long footerLocation) :
Strawberry_TagLib::TagLib::Tag(),
d(new TagPrivate())
{
d->file = file; d->file = file;
d->footerLocation = footerLocation; d->footerLocation = footerLocation;
read(); read();
} }
APE::Tag::~Tag() APE::Tag::~Tag() {
{
delete d; delete d;
} }
ByteVector APE::Tag::fileIdentifier() ByteVector APE::Tag::fileIdentifier() {
{
return ByteVector::fromCString("APETAGEX"); return ByteVector::fromCString("APETAGEX");
} }
String APE::Tag::title() const String APE::Tag::title() const {
{
if (d->itemListMap["TITLE"].isEmpty()) if (d->itemListMap["TITLE"].isEmpty())
return String(); return String();
return d->itemListMap["TITLE"].values().toString(); return d->itemListMap["TITLE"].values().toString();
} }
String APE::Tag::artist() const String APE::Tag::artist() const {
{
if (d->itemListMap["ARTIST"].isEmpty()) if (d->itemListMap["ARTIST"].isEmpty())
return String(); return String();
return d->itemListMap["ARTIST"].values().toString(); return d->itemListMap["ARTIST"].values().toString();
} }
String APE::Tag::album() const String APE::Tag::album() const {
{
if (d->itemListMap["ALBUM"].isEmpty()) if (d->itemListMap["ALBUM"].isEmpty())
return String(); return String();
return d->itemListMap["ALBUM"].values().toString(); return d->itemListMap["ALBUM"].values().toString();
} }
String APE::Tag::comment() const String APE::Tag::comment() const {
{
if (d->itemListMap["COMMENT"].isEmpty()) if (d->itemListMap["COMMENT"].isEmpty())
return String(); return String();
return d->itemListMap["COMMENT"].values().toString(); return d->itemListMap["COMMENT"].values().toString();
} }
String APE::Tag::genre() const String APE::Tag::genre() const {
{
if (d->itemListMap["GENRE"].isEmpty()) if (d->itemListMap["GENRE"].isEmpty())
return String(); return String();
return d->itemListMap["GENRE"].values().toString(); return d->itemListMap["GENRE"].values().toString();
} }
unsigned int APE::Tag::year() const unsigned int APE::Tag::year() const {
{
if (d->itemListMap["YEAR"].isEmpty()) if (d->itemListMap["YEAR"].isEmpty())
return 0; return 0;
return d->itemListMap["YEAR"].toString().toInt(); return d->itemListMap["YEAR"].toString().toInt();
} }
unsigned int APE::Tag::track() const unsigned int APE::Tag::track() const {
{
if (d->itemListMap["TRACK"].isEmpty()) if (d->itemListMap["TRACK"].isEmpty())
return 0; return 0;
return d->itemListMap["TRACK"].toString().toInt(); return d->itemListMap["TRACK"].toString().toInt();
} }
void APE::Tag::setTitle(const String &s) void APE::Tag::setTitle(const String &s) {
{
addValue("TITLE", s, true); addValue("TITLE", s, true);
} }
void APE::Tag::setArtist(const String &s) void APE::Tag::setArtist(const String &s) {
{
addValue("ARTIST", s, true); addValue("ARTIST", s, true);
} }
void APE::Tag::setAlbum(const String &s) void APE::Tag::setAlbum(const String &s) {
{
addValue("ALBUM", s, true); addValue("ALBUM", s, true);
} }
void APE::Tag::setComment(const String &s) void APE::Tag::setComment(const String &s) {
{
addValue("COMMENT", s, true); addValue("COMMENT", s, true);
} }
void APE::Tag::setGenre(const String &s) void APE::Tag::setGenre(const String &s) {
{
addValue("GENRE", s, true); addValue("GENRE", s, true);
} }
void APE::Tag::setYear(unsigned int i) void APE::Tag::setYear(unsigned int i) {
{
if (i == 0) if (i == 0)
removeItem("YEAR"); removeItem("YEAR");
else else
addValue("YEAR", String::number(i), true); addValue("YEAR", String::number(i), true);
} }
void APE::Tag::setTrack(unsigned int i) void APE::Tag::setTrack(unsigned int i) {
{
if (i == 0) if (i == 0)
removeItem("TRACK"); removeItem("TRACK");
else else
addValue("TRACK", String::number(i), true); addValue("TRACK", String::number(i), true);
} }
namespace namespace {
{
// conversions of tag keys between what we use in PropertyMap and what's usual // conversions of tag keys between what we use in PropertyMap and what's usual
// for APE tags // for APE tags
// usual, APE // usual, APE
@@ -217,10 +204,9 @@ namespace
{ "DISCNUMBER", "DISC" }, { "DISCNUMBER", "DISC" },
{ "REMIXER", "MIXARTIST" } }; { "REMIXER", "MIXARTIST" } };
const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]); const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]);
} } // namespace
PropertyMap APE::Tag::properties() const PropertyMap APE::Tag::properties() const {
{
PropertyMap properties; PropertyMap properties;
ItemListMap::ConstIterator it = itemListMap().begin(); ItemListMap::ConstIterator it = itemListMap().begin();
for (; it != itemListMap().end(); ++it) { for (; it != itemListMap().end(); ++it) {
@@ -242,15 +228,13 @@ PropertyMap APE::Tag::properties() const
return properties; return properties;
} }
void APE::Tag::removeUnsupportedProperties(const StringList &properties) void APE::Tag::removeUnsupportedProperties(const StringList &properties) {
{
StringList::ConstIterator it = properties.begin(); StringList::ConstIterator it = properties.begin();
for (; it != properties.end(); ++it) for (; it != properties.end(); ++it)
removeItem(*it); removeItem(*it);
} }
PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) {
{
PropertyMap properties(origProps); // make a local copy that can be modified PropertyMap properties(origProps); // make a local copy that can be modified
// see comment in properties() // see comment in properties()
@@ -295,31 +279,26 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps)
return invalid; return invalid;
} }
bool APE::Tag::checkKey(const String &key) bool APE::Tag::checkKey(const String &key) {
{
if (key.size() < MinKeyLength || key.size() > MaxKeyLength) if (key.size() < MinKeyLength || key.size() > MaxKeyLength)
return false; return false;
return isKeyValid(key.data(String::UTF8)); return isKeyValid(key.data(String::UTF8));
} }
APE::Footer *APE::Tag::footer() const APE::Footer *APE::Tag::footer() const {
{
return &d->footer; return &d->footer;
} }
const APE::ItemListMap& APE::Tag::itemListMap() const const APE::ItemListMap &APE::Tag::itemListMap() const {
{
return d->itemListMap; return d->itemListMap;
} }
void APE::Tag::removeItem(const String &key) void APE::Tag::removeItem(const String &key) {
{
d->itemListMap.erase(key.upper()); d->itemListMap.erase(key.upper());
} }
void APE::Tag::addValue(const String &key, const String &value, bool replace) void APE::Tag::addValue(const String &key, const String &value, bool replace) {
{
if (replace) if (replace)
removeItem(key); removeItem(key);
@@ -337,8 +316,7 @@ void APE::Tag::addValue(const String &key, const String &value, bool replace)
setItem(key, Item(key, value)); setItem(key, Item(key, value));
} }
void APE::Tag::setData(const String &key, const ByteVector &value) void APE::Tag::setData(const String &key, const ByteVector &value) {
{
removeItem(key); removeItem(key);
if (value.isEmpty()) if (value.isEmpty())
@@ -347,8 +325,7 @@ void APE::Tag::setData(const String &key, const ByteVector &value)
setItem(key, Item(key, value, true)); setItem(key, Item(key, value, true));
} }
void APE::Tag::setItem(const String &key, const Item &item) void APE::Tag::setItem(const String &key, const Item &item) {
{
if (!checkKey(key)) { if (!checkKey(key)) {
debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key."); debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key.");
return; return;
@@ -357,8 +334,7 @@ void APE::Tag::setItem(const String &key, const Item &item)
d->itemListMap[key.upper()] = item; d->itemListMap[key.upper()] = item;
} }
bool APE::Tag::isEmpty() const bool APE::Tag::isEmpty() const {
{
return d->itemListMap.isEmpty(); return d->itemListMap.isEmpty();
} }
@@ -366,8 +342,7 @@ bool APE::Tag::isEmpty() const
// protected methods // protected methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void APE::Tag::read() void APE::Tag::read() {
{
if (d->file && d->file->isValid()) { if (d->file && d->file->isValid()) {
d->file->seek(d->footerLocation); d->file->seek(d->footerLocation);
@@ -382,8 +357,7 @@ void APE::Tag::read()
} }
} }
ByteVector APE::Tag::render() const ByteVector APE::Tag::render() const {
{
ByteVector data; ByteVector data;
unsigned int itemCount = 0; unsigned int itemCount = 0;
@@ -399,8 +373,7 @@ ByteVector APE::Tag::render() const
return d->footer.renderHeader() + data + d->footer.renderFooter(); return d->footer.renderHeader() + data + d->footer.renderFooter();
} }
void APE::Tag::parse(const ByteVector &data) void APE::Tag::parse(const ByteVector &data) {
{
// 11 bytes is the minimum size for an APE item // 11 bytes is the minimum size for an APE item
if (data.size() < 11) if (data.size() < 11)
@@ -419,10 +392,7 @@ void APE::Tag::parse(const ByteVector &data)
const unsigned int keyLength = nullPos - pos - 8; const unsigned int keyLength = nullPos - pos - 8;
const unsigned int valLegnth = data.toUInt(pos, false); const unsigned int valLegnth = data.toUInt(pos, false);
if(keyLength >= MinKeyLength if (keyLength >= MinKeyLength && keyLength <= MaxKeyLength && isKeyValid(data.mid(pos + 8, keyLength))) {
&& keyLength <= MaxKeyLength
&& isKeyValid(data.mid(pos + 8, keyLength)))
{
APE::Item item; APE::Item item;
item.parse(data.mid(pos)); item.parse(data.mid(pos));

View File

@@ -55,8 +55,7 @@ namespace TagLib {
//! An APE tag implementation //! An APE tag implementation
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
{
public: public:
/*! /*!
* Create an APE tag with default values. * Create an APE tag with default values.
@@ -185,7 +184,6 @@ namespace TagLib {
bool isEmpty() const; bool isEmpty() const;
protected: protected:
/*! /*!
* Reads from the file specified in the constructor. * Reads from the file specified in the constructor.
*/ */
@@ -203,8 +201,8 @@ namespace TagLib {
class TagPrivate; class TagPrivate;
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace APE
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -33,11 +33,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class ASF::Attribute::AttributePrivate : public RefCounter class ASF::Attribute::AttributePrivate : public RefCounter {
{
public: public:
AttributePrivate() : AttributePrivate() : pictureValue(ASF::Picture::fromInvalid()),
pictureValue(ASF::Picture::fromInvalid()),
numericValue(0), numericValue(0),
stream(0), stream(0),
language(0) {} language(0) {}
@@ -54,130 +52,100 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ASF::Attribute::Attribute() : ASF::Attribute::Attribute() : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = UnicodeType; d->type = UnicodeType;
} }
ASF::Attribute::Attribute(const ASF::Attribute &other) : ASF::Attribute::Attribute(const ASF::Attribute &other) : d(other.d) {
d(other.d)
{
d->ref(); d->ref();
} }
ASF::Attribute::Attribute(const String &value) : ASF::Attribute::Attribute(const String &value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = UnicodeType; d->type = UnicodeType;
d->stringValue = value; d->stringValue = value;
} }
ASF::Attribute::Attribute(const ByteVector &value) : ASF::Attribute::Attribute(const ByteVector &value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = BytesType; d->type = BytesType;
d->byteVectorValue = value; d->byteVectorValue = value;
} }
ASF::Attribute::Attribute(const ASF::Picture &value) : ASF::Attribute::Attribute(const ASF::Picture &value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = BytesType; d->type = BytesType;
d->pictureValue = value; d->pictureValue = value;
} }
ASF::Attribute::Attribute(unsigned int value) : ASF::Attribute::Attribute(unsigned int value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = DWordType; d->type = DWordType;
d->numericValue = value; d->numericValue = value;
} }
ASF::Attribute::Attribute(unsigned long long value) : ASF::Attribute::Attribute(unsigned long long value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = QWordType; d->type = QWordType;
d->numericValue = value; d->numericValue = value;
} }
ASF::Attribute::Attribute(unsigned short value) : ASF::Attribute::Attribute(unsigned short value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = WordType; d->type = WordType;
d->numericValue = value; d->numericValue = value;
} }
ASF::Attribute::Attribute(bool value) : ASF::Attribute::Attribute(bool value) : d(new AttributePrivate()) {
d(new AttributePrivate())
{
d->type = BoolType; d->type = BoolType;
d->numericValue = value; d->numericValue = value;
} }
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) {
{
Attribute(other).swap(*this); Attribute(other).swap(*this);
return *this; return *this;
} }
void ASF::Attribute::swap(Attribute &other) void ASF::Attribute::swap(Attribute &other) {
{
using std::swap; using std::swap;
swap(d, other.d); swap(d, other.d);
} }
ASF::Attribute::~Attribute() ASF::Attribute::~Attribute() {
{
if (d->deref()) if (d->deref())
delete d; delete d;
} }
ASF::Attribute::AttributeTypes ASF::Attribute::type() const ASF::Attribute::AttributeTypes ASF::Attribute::type() const {
{
return d->type; return d->type;
} }
String ASF::Attribute::toString() const String ASF::Attribute::toString() const {
{
return d->stringValue; return d->stringValue;
} }
ByteVector ASF::Attribute::toByteVector() const ByteVector ASF::Attribute::toByteVector() const {
{
if (d->pictureValue.isValid()) if (d->pictureValue.isValid())
return d->pictureValue.render(); return d->pictureValue.render();
return d->byteVectorValue; return d->byteVectorValue;
} }
unsigned short ASF::Attribute::toBool() const unsigned short ASF::Attribute::toBool() const {
{
return d->numericValue ? 1 : 0; return d->numericValue ? 1 : 0;
} }
unsigned short ASF::Attribute::toUShort() const unsigned short ASF::Attribute::toUShort() const {
{
return static_cast<unsigned short>(d->numericValue); return static_cast<unsigned short>(d->numericValue);
} }
unsigned int ASF::Attribute::toUInt() const unsigned int ASF::Attribute::toUInt() const {
{
return static_cast<unsigned int>(d->numericValue); return static_cast<unsigned int>(d->numericValue);
} }
unsigned long long ASF::Attribute::toULongLong() const unsigned long long ASF::Attribute::toULongLong() const {
{
return static_cast<unsigned long long>(d->numericValue); return static_cast<unsigned long long>(d->numericValue);
} }
ASF::Picture ASF::Attribute::toPicture() const ASF::Picture ASF::Attribute::toPicture() const {
{
return d->pictureValue; return d->pictureValue;
} }
String ASF::Attribute::parse(ASF::File &f, int kind) String ASF::Attribute::parse(ASF::File &f, int kind) {
{
unsigned int size, nameLength; unsigned int size, nameLength;
String name; String name;
d->pictureValue = Picture::fromInvalid(); d->pictureValue = Picture::fromInvalid();
@@ -248,8 +216,7 @@ String ASF::Attribute::parse(ASF::File &f, int kind)
return name; return name;
} }
int ASF::Attribute::dataSize() const int ASF::Attribute::dataSize() const {
{
switch (d->type) { switch (d->type) {
case WordType: case WordType:
return 2; return 2;
@@ -271,8 +238,7 @@ int ASF::Attribute::dataSize() const
return 0; return 0;
} }
ByteVector ASF::Attribute::render(const String &name, int kind) const ByteVector ASF::Attribute::render(const String &name, int kind) const {
{
ByteVector data; ByteVector data;
switch (d->type) { switch (d->type) {
@@ -332,22 +298,18 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const
return data; return data;
} }
int ASF::Attribute::language() const int ASF::Attribute::language() const {
{
return d->language; return d->language;
} }
void ASF::Attribute::setLanguage(int value) void ASF::Attribute::setLanguage(int value) {
{
d->language = value; d->language = value;
} }
int ASF::Attribute::stream() const int ASF::Attribute::stream() const {
{
return d->stream; return d->stream;
} }
void ASF::Attribute::setStream(int value) void ASF::Attribute::setStream(int value) {
{
d->stream = value; d->stream = value;
} }

View File

@@ -32,19 +32,15 @@
#include "asfpicture.h" #include "asfpicture.h"
namespace Strawberry_TagLib { namespace Strawberry_TagLib {
namespace TagLib namespace TagLib {
{
namespace ASF namespace ASF {
{
class File; class File;
class Picture; class Picture;
class TAGLIB_EXPORT Attribute class TAGLIB_EXPORT Attribute {
{
public: public:
/*! /*!
* Enum of types an Attribute can have. * Enum of types an Attribute can have.
*/ */
@@ -202,9 +198,9 @@ namespace TagLib
class AttributePrivate; class AttributePrivate;
AttributePrivate *d; AttributePrivate *d;
}; };
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -36,8 +36,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class ASF::File::FilePrivate class ASF::File::FilePrivate {
{
public: public:
class BaseObject; class BaseObject;
class UnknownObject; class UnknownObject;
@@ -50,21 +49,18 @@ public:
class MetadataObject; class MetadataObject;
class MetadataLibraryObject; class MetadataLibraryObject;
FilePrivate(): FilePrivate() : headerSize(0),
headerSize(0),
tag(0), tag(0),
properties(0), properties(0),
contentDescriptionObject(0), contentDescriptionObject(0),
extendedContentDescriptionObject(0), extendedContentDescriptionObject(0),
headerExtensionObject(0), headerExtensionObject(0),
metadataObject(0), metadataObject(0),
metadataLibraryObject(0) metadataLibraryObject(0) {
{
objects.setAutoDelete(true); objects.setAutoDelete(true);
} }
~FilePrivate() ~FilePrivate() {
{
delete tag; delete tag;
delete properties; delete properties;
} }
@@ -83,8 +79,7 @@ public:
MetadataLibraryObject *metadataLibraryObject; MetadataLibraryObject *metadataLibraryObject;
}; };
namespace namespace {
{
const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16); const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16); const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16); const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
@@ -97,10 +92,9 @@ namespace
const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16); const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16); const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16); const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
} } // namespace
class ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVector data; ByteVector data;
virtual ~BaseObject() {} virtual ~BaseObject() {}
@@ -109,38 +103,34 @@ public:
virtual ByteVector render(ASF::File *file); virtual ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject {
{
ByteVector myGuid; ByteVector myGuid;
public: public:
explicit UnknownObject(const ByteVector &guid); explicit UnknownObject(const ByteVector &guid);
ByteVector guid() const; ByteVector guid() const;
}; };
class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVector guid() const; ByteVector guid() const;
void parse(ASF::File *file, unsigned int size); void parse(ASF::File *file, unsigned int size);
}; };
class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVector guid() const; ByteVector guid() const;
void parse(ASF::File *file, unsigned int size); void parse(ASF::File *file, unsigned int size);
}; };
class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVector guid() const; ByteVector guid() const;
void parse(ASF::File *file, unsigned int size); void parse(ASF::File *file, unsigned int size);
ByteVector render(ASF::File *file); ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVectorList attributeData; ByteVectorList attributeData;
ByteVector guid() const; ByteVector guid() const;
@@ -148,8 +138,7 @@ public:
ByteVector render(ASF::File *file); ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVectorList attributeData; ByteVectorList attributeData;
ByteVector guid() const; ByteVector guid() const;
@@ -157,8 +146,7 @@ public:
ByteVector render(ASF::File *file); ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVectorList attributeData; ByteVectorList attributeData;
ByteVector guid() const; ByteVector guid() const;
@@ -166,8 +154,7 @@ public:
ByteVector render(ASF::File *file); ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
List<ASF::File::FilePrivate::BaseObject *> objects; List<ASF::File::FilePrivate::BaseObject *> objects;
HeaderExtensionObject(); HeaderExtensionObject();
@@ -176,23 +163,20 @@ public:
ByteVector render(ASF::File *file); ByteVector render(ASF::File *file);
}; };
class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject {
{
public: public:
ByteVector guid() const; ByteVector guid() const;
void parse(ASF::File *file, unsigned int size); void parse(ASF::File *file, unsigned int size);
private: private:
enum CodecType enum CodecType {
{
Video = 0x0001, Video = 0x0001,
Audio = 0x0002, Audio = 0x0002,
Unknown = 0xFFFF Unknown = 0xFFFF
}; };
}; };
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) {
{
data.clear(); data.clear();
if (size > 24 && size <= (unsigned int)(file->length())) if (size > 24 && size <= (unsigned int)(file->length()))
data = file->readBlock(size - 24); data = file->readBlock(size - 24);
@@ -200,27 +184,22 @@ void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int siz
data = ByteVector(); data = ByteVector();
} }
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) {
{
return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data; return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data;
} }
ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) {
{
} }
ByteVector ASF::File::FilePrivate::UnknownObject::guid() const ByteVector ASF::File::FilePrivate::UnknownObject::guid() const {
{
return myGuid; return myGuid;
} }
ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const {
{
return filePropertiesGuid; return filePropertiesGuid;
} }
void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) {
{
BaseObject::parse(file, size); BaseObject::parse(file, size);
if (data.size() < 64) { if (data.size() < 64) {
debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short."); debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short.");
@@ -232,13 +211,11 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsign
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5)); file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
} }
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const {
{
return streamPropertiesGuid; return streamPropertiesGuid;
} }
void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) {
{
BaseObject::parse(file, size); BaseObject::parse(file, size);
if (data.size() < 70) { if (data.size() < 70) {
debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short."); debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short.");
@@ -252,13 +229,11 @@ void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsi
file->d->properties->setBitsPerSample(data.toUShort(68, false)); file->d->properties->setBitsPerSample(data.toUShort(68, false));
} }
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const {
{
return contentDescriptionGuid; return contentDescriptionGuid;
} }
void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
{
const int titleLength = readWORD(file); const int titleLength = readWORD(file);
const int artistLength = readWORD(file); const int artistLength = readWORD(file);
const int copyrightLength = readWORD(file); const int copyrightLength = readWORD(file);
@@ -271,8 +246,7 @@ void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, un
file->d->tag->setRating(readString(file, ratingLength)); file->d->tag->setRating(readString(file, ratingLength));
} }
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) {
{
const ByteVector v1 = renderString(file->d->tag->title()); const ByteVector v1 = renderString(file->d->tag->title());
const ByteVector v2 = renderString(file->d->tag->artist()); const ByteVector v2 = renderString(file->d->tag->artist());
const ByteVector v3 = renderString(file->d->tag->copyright()); const ByteVector v3 = renderString(file->d->tag->copyright());
@@ -292,13 +266,11 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *f
return BaseObject::render(file); return BaseObject::render(file);
} }
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const {
{
return extendedContentDescriptionGuid; return extendedContentDescriptionGuid;
} }
void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
{
int count = readWORD(file); int count = readWORD(file);
while (count--) { while (count--) {
ASF::Attribute attribute; ASF::Attribute attribute;
@@ -307,21 +279,18 @@ void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *
} }
} }
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) {
{
data.clear(); data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(ByteVector::fromShort(attributeData.size(), false));
data.append(attributeData.toByteVector("")); data.append(attributeData.toByteVector(""));
return BaseObject::render(file); return BaseObject::render(file);
} }
ByteVector ASF::File::FilePrivate::MetadataObject::guid() const ByteVector ASF::File::FilePrivate::MetadataObject::guid() const {
{
return metadataGuid; return metadataGuid;
} }
void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) {
{
int count = readWORD(file); int count = readWORD(file);
while (count--) { while (count--) {
ASF::Attribute attribute; ASF::Attribute attribute;
@@ -330,21 +299,18 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int
} }
} }
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) {
{
data.clear(); data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(ByteVector::fromShort(attributeData.size(), false));
data.append(attributeData.toByteVector("")); data.append(attributeData.toByteVector(""));
return BaseObject::render(file); return BaseObject::render(file);
} }
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const {
{
return metadataLibraryGuid; return metadataLibraryGuid;
} }
void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) {
{
int count = readWORD(file); int count = readWORD(file);
while (count--) { while (count--) {
ASF::Attribute attribute; ASF::Attribute attribute;
@@ -353,26 +319,22 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsig
} }
} }
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) {
{
data.clear(); data.clear();
data.append(ByteVector::fromShort(attributeData.size(), false)); data.append(ByteVector::fromShort(attributeData.size(), false));
data.append(attributeData.toByteVector("")); data.append(attributeData.toByteVector(""));
return BaseObject::render(file); return BaseObject::render(file);
} }
ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() {
{
objects.setAutoDelete(true); objects.setAutoDelete(true);
} }
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const {
{
return headerExtensionGuid; return headerExtensionGuid;
} }
void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) {
{
file->seek(18, File::Current); file->seek(18, File::Current);
long long dataSize = readDWORD(file); long long dataSize = readDWORD(file);
long long dataPos = 0; long long dataPos = 0;
@@ -406,8 +368,7 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig
} }
} }
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) {
{
data.clear(); data.clear();
for (List<BaseObject *>::ConstIterator it = objects.begin(); it != objects.end(); ++it) { for (List<BaseObject *>::ConstIterator it = objects.begin(); it != objects.end(); ++it) {
data.append((*it)->render(file)); data.append((*it)->render(file));
@@ -416,13 +377,11 @@ ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file
return BaseObject::render(file); return BaseObject::render(file);
} }
ByteVector ASF::File::FilePrivate::CodecListObject::guid() const ByteVector ASF::File::FilePrivate::CodecListObject::guid() const {
{
return codecListGuid; return codecListGuid;
} }
void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) {
{
BaseObject::parse(file, size); BaseObject::parse(file, size);
if (data.size() <= 20) { if (data.size() <= 20) {
debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short."); debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short.");
@@ -475,8 +434,7 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool ASF::File::isSupported(IOStream *stream) bool ASF::File::isSupported(IOStream *stream) {
{
// An ASF file has to start with the designated GUID. // An ASF file has to start with the designated GUID.
const ByteVector id = Utils::readHeader(stream, 16, false); const ByteVector id = Utils::readHeader(stream, 16, false);
@@ -487,54 +445,43 @@ bool ASF::File::isSupported(IOStream *stream)
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ASF::File::File(FileName file, bool, Properties::ReadStyle) : ASF::File::File(FileName file, bool, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(); read();
} }
ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) : ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(); read();
} }
ASF::File::~File() ASF::File::~File() {
{
delete d; delete d;
} }
ASF::Tag *ASF::File::tag() const ASF::Tag *ASF::File::tag() const {
{
return d->tag; return d->tag;
} }
PropertyMap ASF::File::properties() const PropertyMap ASF::File::properties() const {
{
return d->tag->properties(); return d->tag->properties();
} }
void ASF::File::removeUnsupportedProperties(const StringList &properties) void ASF::File::removeUnsupportedProperties(const StringList &properties) {
{
d->tag->removeUnsupportedProperties(properties); d->tag->removeUnsupportedProperties(properties);
} }
PropertyMap ASF::File::setProperties(const PropertyMap &properties) PropertyMap ASF::File::setProperties(const PropertyMap &properties) {
{
return d->tag->setProperties(properties); return d->tag->setProperties(properties);
} }
ASF::Properties *ASF::File::audioProperties() const ASF::Properties *ASF::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool ASF::File::save() bool ASF::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("ASF::File::save() -- File is read only."); debug("ASF::File::save() -- File is read only.");
return false; return false;
@@ -621,8 +568,7 @@ bool ASF::File::save()
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void ASF::File::read() void ASF::File::read() {
{
if (!isValid()) if (!isValid())
return; return;

View File

@@ -44,10 +44,8 @@ namespace TagLib {
* the abstract TagLib::File API as well as providing some additional * the abstract TagLib::File API as well as providing some additional
* information specific to ASF files. * information specific to ASF files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* Constructs an ASF file from \a file. * Constructs an ASF file from \a file.
* *
@@ -132,9 +130,9 @@ namespace TagLib {
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -34,8 +34,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class ASF::Picture::PicturePrivate : public RefCounter class ASF::Picture::PicturePrivate : public RefCounter {
{
public: public:
bool valid; bool valid;
Type type; Type type;
@@ -48,110 +47,91 @@ public:
// Picture class members // Picture class members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ASF::Picture::Picture() : ASF::Picture::Picture() : d(new PicturePrivate()) {
d(new PicturePrivate())
{
d->valid = true; d->valid = true;
} }
ASF::Picture::Picture(const Picture& other) : ASF::Picture::Picture(const Picture& other) : d(other.d) {
d(other.d)
{
d->ref(); d->ref();
} }
ASF::Picture::~Picture() ASF::Picture::~Picture() {
{
if (d->deref()) if (d->deref())
delete d; delete d;
} }
bool ASF::Picture::isValid() const bool ASF::Picture::isValid() const {
{
return d->valid; return d->valid;
} }
String ASF::Picture::mimeType() const String ASF::Picture::mimeType() const {
{
return d->mimeType; return d->mimeType;
} }
void ASF::Picture::setMimeType(const String &value) void ASF::Picture::setMimeType(const String& value) {
{
d->mimeType = value; d->mimeType = value;
} }
ASF::Picture::Type ASF::Picture::type() const ASF::Picture::Type ASF::Picture::type() const {
{
return d->type; return d->type;
} }
void ASF::Picture::setType(const ASF::Picture::Type& t) void ASF::Picture::setType(const ASF::Picture::Type& t) {
{
d->type = t; d->type = t;
} }
String ASF::Picture::description() const String ASF::Picture::description() const {
{
return d->description; return d->description;
} }
void ASF::Picture::setDescription(const String &desc) void ASF::Picture::setDescription(const String& desc) {
{
d->description = desc; d->description = desc;
} }
ByteVector ASF::Picture::picture() const ByteVector ASF::Picture::picture() const {
{
return d->picture; return d->picture;
} }
void ASF::Picture::setPicture(const ByteVector &p) void ASF::Picture::setPicture(const ByteVector& p) {
{
d->picture = p; d->picture = p;
} }
int ASF::Picture::dataSize() const int ASF::Picture::dataSize() const {
{ return 9 + (d->mimeType.length() + d->description.length()) * 2 +
return
9 + (d->mimeType.length() + d->description.length()) * 2 +
d->picture.size(); d->picture.size();
} }
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) {
{
Picture(other).swap(*this); Picture(other).swap(*this);
return *this; return *this;
} }
void ASF::Picture::swap(Picture &other) void ASF::Picture::swap(Picture& other) {
{
using std::swap; using std::swap;
swap(d, other.d); swap(d, other.d);
} }
ByteVector ASF::Picture::render() const ByteVector ASF::Picture::render() const {
{
if (!isValid()) if (!isValid())
return ByteVector(); return ByteVector();
return return ByteVector((char)d->type) +
ByteVector((char)d->type) +
ByteVector::fromUInt(d->picture.size(), false) + ByteVector::fromUInt(d->picture.size(), false) +
renderString(d->mimeType) + renderString(d->mimeType) +
renderString(d->description) + renderString(d->description) +
d->picture; d->picture;
} }
void ASF::Picture::parse(const ByteVector& bytes) void ASF::Picture::parse(const ByteVector& bytes) {
{
d->valid = false; d->valid = false;
if (bytes.size() < 9) if (bytes.size() < 9)
return; return;
int pos = 0; int pos = 0;
d->type = (Type)bytes[0]; ++pos; d->type = (Type)bytes[0];
const unsigned int dataLen = bytes.toUInt(pos, false); pos+=4; ++pos;
const unsigned int dataLen = bytes.toUInt(pos, false);
pos += 4;
const ByteVector nullStringTerminator(2, 0); const ByteVector nullStringTerminator(2, 0);
@@ -175,8 +155,7 @@ void ASF::Picture::parse(const ByteVector& bytes)
return; return;
} }
ASF::Picture ASF::Picture::fromInvalid() ASF::Picture ASF::Picture::fromInvalid() {
{
Picture ret; Picture ret;
ret.d->valid = false; ret.d->valid = false;
return ret; return ret;

View File

@@ -32,10 +32,8 @@
#include "attachedpictureframe.h" #include "attachedpictureframe.h"
namespace Strawberry_TagLib { namespace Strawberry_TagLib {
namespace TagLib namespace TagLib {
{ namespace ASF {
namespace ASF
{
//! An ASF attached picture interface implementation //! An ASF attached picture interface implementation
@@ -49,7 +47,6 @@ namespace TagLib
*/ */
class TAGLIB_EXPORT Picture { class TAGLIB_EXPORT Picture {
public: public:
/*! /*!
* This describes the function or content of the picture. * This describes the function or content of the picture.
*/ */
@@ -217,8 +214,8 @@ namespace TagLib
class PicturePrivate; class PicturePrivate;
PicturePrivate* d; PicturePrivate* d;
}; };
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif // ASFPICTURE_H #endif // ASFPICTURE_H

View File

@@ -29,11 +29,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class ASF::Properties::PropertiesPrivate class ASF::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : length(0),
length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
channels(0), channels(0),
@@ -56,69 +54,55 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ASF::Properties::Properties() : ASF::Properties::Properties() : AudioProperties(AudioProperties::Average),
AudioProperties(AudioProperties::Average), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
} }
ASF::Properties::~Properties() ASF::Properties::~Properties() {
{
delete d; delete d;
} }
int ASF::Properties::length() const int ASF::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int ASF::Properties::lengthInSeconds() const int ASF::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int ASF::Properties::lengthInMilliseconds() const int ASF::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int ASF::Properties::bitrate() const int ASF::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int ASF::Properties::sampleRate() const int ASF::Properties::sampleRate() const {
{
return d->sampleRate; return d->sampleRate;
} }
int ASF::Properties::channels() const int ASF::Properties::channels() const {
{
return d->channels; return d->channels;
} }
int ASF::Properties::bitsPerSample() const int ASF::Properties::bitsPerSample() const {
{
return d->bitsPerSample; return d->bitsPerSample;
} }
ASF::Properties::Codec ASF::Properties::codec() const ASF::Properties::Codec ASF::Properties::codec() const {
{
return d->codec; return d->codec;
} }
String ASF::Properties::codecName() const String ASF::Properties::codecName() const {
{
return d->codecName; return d->codecName;
} }
String ASF::Properties::codecDescription() const String ASF::Properties::codecDescription() const {
{
return d->codecDescription; return d->codecDescription;
} }
bool ASF::Properties::isEncrypted() const bool ASF::Properties::isEncrypted() const {
{
return d->encrypted; return d->encrypted;
} }
@@ -126,40 +110,32 @@ bool ASF::Properties::isEncrypted() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void ASF::Properties::setLength(int /*length*/) void ASF::Properties::setLength(int /*length*/) {
{
debug("ASF::Properties::setLength() -- This method is deprecated. Do not use."); debug("ASF::Properties::setLength() -- This method is deprecated. Do not use.");
} }
void ASF::Properties::setLengthInMilliseconds(int value) void ASF::Properties::setLengthInMilliseconds(int value) {
{
d->length = value; d->length = value;
} }
void ASF::Properties::setBitrate(int value) void ASF::Properties::setBitrate(int value) {
{
d->bitrate = value; d->bitrate = value;
} }
void ASF::Properties::setSampleRate(int value) void ASF::Properties::setSampleRate(int value) {
{
d->sampleRate = value; d->sampleRate = value;
} }
void ASF::Properties::setChannels(int value) void ASF::Properties::setChannels(int value) {
{
d->channels = value; d->channels = value;
} }
void ASF::Properties::setBitsPerSample(int value) void ASF::Properties::setBitsPerSample(int value) {
{
d->bitsPerSample = value; d->bitsPerSample = value;
} }
void ASF::Properties::setCodec(int value) void ASF::Properties::setCodec(int value) {
{ switch (value) {
switch(value)
{
case 0x0160: case 0x0160:
d->codec = WMA1; d->codec = WMA1;
break; break;
@@ -178,17 +154,14 @@ void ASF::Properties::setCodec(int value)
} }
} }
void ASF::Properties::setCodecName(const String &value) void ASF::Properties::setCodecName(const String &value) {
{
d->codecName = value; d->codecName = value;
} }
void ASF::Properties::setCodecDescription(const String &value) void ASF::Properties::setCodecDescription(const String &value) {
{
d->codecDescription = value; d->codecDescription = value;
} }
void ASF::Properties::setEncrypted(bool value) void ASF::Properties::setEncrypted(bool value) {
{
d->encrypted = value; d->encrypted = value;
} }

View File

@@ -36,15 +36,12 @@ namespace TagLib {
namespace ASF { namespace ASF {
//! An implementation of ASF audio properties //! An implementation of ASF audio properties
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
/*! /*!
* Audio codec types can be used in ASF file. * Audio codec types can be used in ASF file.
*/ */
enum Codec enum Codec {
{
/*! /*!
* Couldn't detect the codec. * Couldn't detect the codec.
*/ */
@@ -180,9 +177,9 @@ namespace TagLib {
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -28,8 +28,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class ASF::Tag::TagPrivate class ASF::Tag::TagPrivate {
{
public: public:
String title; String title;
String artist; String artist;
@@ -39,58 +38,47 @@ public:
AttributeListMap attributeListMap; AttributeListMap attributeListMap;
}; };
ASF::Tag::Tag() : ASF::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(),
Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {
d(new TagPrivate())
{
} }
ASF::Tag::~Tag() ASF::Tag::~Tag() {
{
delete d; delete d;
} }
String ASF::Tag::title() const String ASF::Tag::title() const {
{
return d->title; return d->title;
} }
String ASF::Tag::artist() const String ASF::Tag::artist() const {
{
return d->artist; return d->artist;
} }
String ASF::Tag::album() const String ASF::Tag::album() const {
{
if (d->attributeListMap.contains("WM/AlbumTitle")) if (d->attributeListMap.contains("WM/AlbumTitle"))
return d->attributeListMap["WM/AlbumTitle"][0].toString(); return d->attributeListMap["WM/AlbumTitle"][0].toString();
return String(); return String();
} }
String ASF::Tag::copyright() const String ASF::Tag::copyright() const {
{
return d->copyright; return d->copyright;
} }
String ASF::Tag::comment() const String ASF::Tag::comment() const {
{
return d->comment; return d->comment;
} }
String ASF::Tag::rating() const String ASF::Tag::rating() const {
{
return d->rating; return d->rating;
} }
unsigned int ASF::Tag::year() const unsigned int ASF::Tag::year() const {
{
if (d->attributeListMap.contains("WM/Year")) if (d->attributeListMap.contains("WM/Year"))
return d->attributeListMap["WM/Year"][0].toString().toInt(); return d->attributeListMap["WM/Year"][0].toString().toInt();
return 0; return 0;
} }
unsigned int ASF::Tag::track() const unsigned int ASF::Tag::track() const {
{
if (d->attributeListMap.contains("WM/TrackNumber")) { if (d->attributeListMap.contains("WM/TrackNumber")) {
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0]; const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
if (attr.type() == ASF::Attribute::DWordType) if (attr.type() == ASF::Attribute::DWordType)
@@ -103,97 +91,79 @@ unsigned int ASF::Tag::track() const
return 0; return 0;
} }
String ASF::Tag::genre() const String ASF::Tag::genre() const {
{
if (d->attributeListMap.contains("WM/Genre")) if (d->attributeListMap.contains("WM/Genre"))
return d->attributeListMap["WM/Genre"][0].toString(); return d->attributeListMap["WM/Genre"][0].toString();
return String(); return String();
} }
void ASF::Tag::setTitle(const String &value) void ASF::Tag::setTitle(const String &value) {
{
d->title = value; d->title = value;
} }
void ASF::Tag::setArtist(const String &value) void ASF::Tag::setArtist(const String &value) {
{
d->artist = value; d->artist = value;
} }
void ASF::Tag::setCopyright(const String &value) void ASF::Tag::setCopyright(const String &value) {
{
d->copyright = value; d->copyright = value;
} }
void ASF::Tag::setComment(const String &value) void ASF::Tag::setComment(const String &value) {
{
d->comment = value; d->comment = value;
} }
void ASF::Tag::setRating(const String &value) void ASF::Tag::setRating(const String &value) {
{
d->rating = value; d->rating = value;
} }
void ASF::Tag::setAlbum(const String &value) void ASF::Tag::setAlbum(const String &value) {
{
setAttribute("WM/AlbumTitle", value); setAttribute("WM/AlbumTitle", value);
} }
void ASF::Tag::setGenre(const String &value) void ASF::Tag::setGenre(const String &value) {
{
setAttribute("WM/Genre", value); setAttribute("WM/Genre", value);
} }
void ASF::Tag::setYear(unsigned int value) void ASF::Tag::setYear(unsigned int value) {
{
setAttribute("WM/Year", String::number(value)); setAttribute("WM/Year", String::number(value));
} }
void ASF::Tag::setTrack(unsigned int value) void ASF::Tag::setTrack(unsigned int value) {
{
setAttribute("WM/TrackNumber", String::number(value)); setAttribute("WM/TrackNumber", String::number(value));
} }
ASF::AttributeListMap& ASF::Tag::attributeListMap() ASF::AttributeListMap &ASF::Tag::attributeListMap() {
{
return d->attributeListMap; return d->attributeListMap;
} }
const ASF::AttributeListMap &ASF::Tag::attributeListMap() const const ASF::AttributeListMap &ASF::Tag::attributeListMap() const {
{
return d->attributeListMap; return d->attributeListMap;
} }
bool ASF::Tag::contains(const String &key) const bool ASF::Tag::contains(const String &key) const {
{
return d->attributeListMap.contains(key); return d->attributeListMap.contains(key);
} }
void ASF::Tag::removeItem(const String &key) void ASF::Tag::removeItem(const String &key) {
{
d->attributeListMap.erase(key); d->attributeListMap.erase(key);
} }
ASF::AttributeList ASF::Tag::attribute(const String &name) const ASF::AttributeList ASF::Tag::attribute(const String &name) const {
{
return d->attributeListMap[name]; return d->attributeListMap[name];
} }
void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) {
{
AttributeList value; AttributeList value;
value.append(attribute); value.append(attribute);
d->attributeListMap.insert(name, value); d->attributeListMap.insert(name, value);
} }
void ASF::Tag::setAttribute(const String &name, const AttributeList &values) void ASF::Tag::setAttribute(const String &name, const AttributeList &values) {
{
d->attributeListMap.insert(name, values); d->attributeListMap.insert(name, values);
} }
void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) {
{
if (d->attributeListMap.contains(name)) { if (d->attributeListMap.contains(name)) {
d->attributeListMap[name].append(attribute); d->attributeListMap[name].append(attribute);
} }
@@ -202,16 +172,14 @@ void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
} }
} }
bool ASF::Tag::isEmpty() const bool ASF::Tag::isEmpty() const {
{
return Strawberry_TagLib::TagLib::Tag::isEmpty() && return Strawberry_TagLib::TagLib::Tag::isEmpty() &&
copyright().isEmpty() && copyright().isEmpty() &&
rating().isEmpty() && rating().isEmpty() &&
d->attributeListMap.isEmpty(); d->attributeListMap.isEmpty();
} }
namespace namespace {
{
const char *keyTranslation[][2] = { const char *keyTranslation[][2] = {
{ "WM/AlbumTitle", "ALBUM" }, { "WM/AlbumTitle", "ALBUM" },
{ "WM/AlbumArtist", "ALBUMARTIST" }, { "WM/AlbumArtist", "ALBUMARTIST" },
@@ -255,8 +223,7 @@ namespace
}; };
const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
String translateKey(const String &key) String translateKey(const String &key) {
{
for (size_t i = 0; i < keyTranslationSize; ++i) { for (size_t i = 0; i < keyTranslationSize; ++i) {
if (key == keyTranslation[i][0]) if (key == keyTranslation[i][0])
return keyTranslation[i][1]; return keyTranslation[i][1];
@@ -264,10 +231,9 @@ namespace
return String(); return String();
} }
} } // namespace
PropertyMap ASF::Tag::properties() const PropertyMap ASF::Tag::properties() const {
{
PropertyMap props; PropertyMap props;
if (!d->title.isEmpty()) { if (!d->title.isEmpty()) {
@@ -307,15 +273,13 @@ PropertyMap ASF::Tag::properties() const
return props; return props;
} }
void ASF::Tag::removeUnsupportedProperties(const StringList &props) void ASF::Tag::removeUnsupportedProperties(const StringList &props) {
{
StringList::ConstIterator it = props.begin(); StringList::ConstIterator it = props.begin();
for (; it != props.end(); ++it) for (; it != props.end(); ++it)
d->attributeListMap.erase(*it); d->attributeListMap.erase(*it);
} }
PropertyMap ASF::Tag::setProperties(const PropertyMap &props) PropertyMap ASF::Tag::setProperties(const PropertyMap &props) {
{
static Map<String, String> reverseKeyMap; static Map<String, String> reverseKeyMap;
if (reverseKeyMap.isEmpty()) { if (reverseKeyMap.isEmpty()) {
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]); int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);

View File

@@ -45,7 +45,6 @@ namespace TagLib {
friend class File; friend class File;
public: public:
Tag(); Tag();
virtual ~Tag(); virtual ~Tag();
@@ -202,11 +201,10 @@ namespace TagLib {
PropertyMap setProperties(const PropertyMap &properties); PropertyMap setProperties(const PropertyMap &properties);
private: private:
class TagPrivate; class TagPrivate;
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,15 +31,11 @@
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header #ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
namespace Strawberry_TagLib { namespace Strawberry_TagLib {
namespace TagLib namespace TagLib {
{ namespace ASF {
namespace ASF namespace {
{
namespace
{
inline unsigned short readWORD(File *file, bool *ok = 0) inline unsigned short readWORD(File *file, bool *ok = 0) {
{
const ByteVector v = file->readBlock(2); const ByteVector v = file->readBlock(2);
if (v.size() != 2) { if (v.size() != 2) {
if (ok) *ok = false; if (ok) *ok = false;
@@ -49,8 +45,7 @@ namespace TagLib
return v.toUShort(false); return v.toUShort(false);
} }
inline unsigned int readDWORD(File *file, bool *ok = 0) inline unsigned int readDWORD(File *file, bool *ok = 0) {
{
const ByteVector v = file->readBlock(4); const ByteVector v = file->readBlock(4);
if (v.size() != 4) { if (v.size() != 4) {
if (ok) *ok = false; if (ok) *ok = false;
@@ -60,8 +55,7 @@ namespace TagLib
return v.toUInt(false); return v.toUInt(false);
} }
inline long long readQWORD(File *file, bool *ok = 0) inline long long readQWORD(File *file, bool *ok = 0) {
{
const ByteVector v = file->readBlock(8); const ByteVector v = file->readBlock(8);
if (v.size() != 8) { if (v.size() != 8) {
if (ok) *ok = false; if (ok) *ok = false;
@@ -71,8 +65,7 @@ namespace TagLib
return v.toLongLong(false); return v.toLongLong(false);
} }
inline String readString(File *file, int length) inline String readString(File *file, int length) {
{
ByteVector data = file->readBlock(length); ByteVector data = file->readBlock(length);
unsigned int size = data.size(); unsigned int size = data.size();
while (size >= 2) { while (size >= 2) {
@@ -87,8 +80,7 @@ namespace TagLib
return String(data, String::UTF16LE); return String(data, String::UTF16LE);
} }
inline ByteVector renderString(const String &str, bool includeLength = false) inline ByteVector renderString(const String &str, bool includeLength = false) {
{
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
if (includeLength) { if (includeLength) {
data = ByteVector::fromShort(data.size(), false) + data; data = ByteVector::fromShort(data.size(), false) + data;
@@ -96,10 +88,10 @@ namespace TagLib
return data; return data;
} }
} } // namespace
} } // namespace ASF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -82,27 +82,21 @@ using namespace Strawberry_TagLib::TagLib;
else \ else \
return (default_value); return (default_value);
class AudioProperties::AudioPropertiesPrivate class AudioProperties::AudioPropertiesPrivate {
{
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// public methods // public methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AudioProperties::~AudioProperties() AudioProperties::~AudioProperties() {
{
} }
int AudioProperties::lengthInSeconds() const int AudioProperties::lengthInSeconds() const {
{
VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0) VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0)
} }
int AudioProperties::lengthInMilliseconds() const int AudioProperties::lengthInMilliseconds() const {
{
VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0) VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0)
} }
@@ -110,8 +104,5 @@ int AudioProperties::lengthInMilliseconds() const
// protected methods // protected methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AudioProperties::AudioProperties(ReadStyle) : AudioProperties::AudioProperties(ReadStyle) : d(0) {
d(0)
{
} }

View File

@@ -40,10 +40,8 @@ namespace TagLib {
* interface that is sufficient for most applications. * interface that is sufficient for most applications.
*/ */
class TAGLIB_EXPORT AudioProperties class TAGLIB_EXPORT AudioProperties {
{
public: public:
/*! /*!
* Reading audio properties from a file can sometimes be very time consuming * Reading audio properties from a file can sometimes be very time consuming
* and for the most accurate results can often involve reading the entire * and for the most accurate results can often involve reading the entire
@@ -105,7 +103,6 @@ namespace TagLib {
virtual int channels() const = 0; virtual int channels() const = 0;
protected: protected:
/*! /*!
* Construct an audio properties instance. This is protected as this class * Construct an audio properties instance. This is protected as this class
* should not be instantiated directly, but should be instantiated via its * should not be instantiated directly, but should be instantiated via its
@@ -123,7 +120,7 @@ namespace TagLib {
AudioPropertiesPrivate *d; AudioPropertiesPrivate *d;
}; };
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,108 +30,88 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace DSDIFF::DIIN; using namespace DSDIFF::DIIN;
class DSDIFF::DIIN::Tag::TagPrivate class DSDIFF::DIIN::Tag::TagPrivate {
{
public: public:
TagPrivate() TagPrivate() {
{
} }
String title; String title;
String artist; String artist;
}; };
DSDIFF::DIIN::Tag::Tag() : Strawberry_TagLib::TagLib::Tag() DSDIFF::DIIN::Tag::Tag() : Strawberry_TagLib::TagLib::Tag() {
{
d = new TagPrivate; d = new TagPrivate;
} }
DSDIFF::DIIN::Tag::~Tag() DSDIFF::DIIN::Tag::~Tag() {
{
delete d; delete d;
} }
String DSDIFF::DIIN::Tag::title() const String DSDIFF::DIIN::Tag::title() const {
{
return d->title; return d->title;
} }
String DSDIFF::DIIN::Tag::artist() const String DSDIFF::DIIN::Tag::artist() const {
{
return d->artist; return d->artist;
} }
String DSDIFF::DIIN::Tag::album() const String DSDIFF::DIIN::Tag::album() const {
{
return String(); return String();
} }
String DSDIFF::DIIN::Tag::comment() const String DSDIFF::DIIN::Tag::comment() const {
{
return String(); return String();
} }
String DSDIFF::DIIN::Tag::genre() const String DSDIFF::DIIN::Tag::genre() const {
{
return String(); return String();
} }
unsigned int DSDIFF::DIIN::Tag::year() const unsigned int DSDIFF::DIIN::Tag::year() const {
{
return 0; return 0;
} }
unsigned int DSDIFF::DIIN::Tag::track() const unsigned int DSDIFF::DIIN::Tag::track() const {
{
return 0; return 0;
} }
void DSDIFF::DIIN::Tag::setTitle(const String &title) void DSDIFF::DIIN::Tag::setTitle(const String &title) {
{
if (title.isNull() || title.isEmpty()) if (title.isNull() || title.isEmpty())
d->title = String(); d->title = String();
else else
d->title = title; d->title = title;
} }
void DSDIFF::DIIN::Tag::setArtist(const String &artist) void DSDIFF::DIIN::Tag::setArtist(const String &artist) {
{
if (artist.isNull() || artist.isEmpty()) if (artist.isNull() || artist.isEmpty())
d->artist = String(); d->artist = String();
else else
d->artist = artist; d->artist = artist;
} }
void DSDIFF::DIIN::Tag::setAlbum(const String &) void DSDIFF::DIIN::Tag::setAlbum(const String &) {
{
} }
void DSDIFF::DIIN::Tag::setComment(const String &) void DSDIFF::DIIN::Tag::setComment(const String &) {
{
} }
void DSDIFF::DIIN::Tag::setGenre(const String &) void DSDIFF::DIIN::Tag::setGenre(const String &) {
{
} }
void DSDIFF::DIIN::Tag::setYear(unsigned int) void DSDIFF::DIIN::Tag::setYear(unsigned int) {
{
} }
void DSDIFF::DIIN::Tag::setTrack(unsigned int) void DSDIFF::DIIN::Tag::setTrack(unsigned int) {
{
} }
PropertyMap DSDIFF::DIIN::Tag::properties() const PropertyMap DSDIFF::DIIN::Tag::properties() const {
{
PropertyMap properties; PropertyMap properties;
properties["TITLE"] = d->title; properties["TITLE"] = d->title;
properties["ARTIST"] = d->artist; properties["ARTIST"] = d->artist;
return properties; return properties;
} }
PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) {
{
PropertyMap properties(origProps); PropertyMap properties(origProps);
properties.removeEmpty(); properties.removeEmpty();
StringList oneValueSet; StringList oneValueSet;
@@ -139,13 +119,15 @@ PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps)
if (properties.contains("TITLE")) { if (properties.contains("TITLE")) {
d->title = properties["TITLE"].front(); d->title = properties["TITLE"].front();
oneValueSet.append("TITLE"); oneValueSet.append("TITLE");
} else }
else
d->title = String(); d->title = String();
if (properties.contains("ARTIST")) { if (properties.contains("ARTIST")) {
d->artist = properties["ARTIST"].front(); d->artist = properties["ARTIST"].front();
oneValueSet.append("ARTIST"); oneValueSet.append("ARTIST");
} else }
else
d->artist = String(); d->artist = String();
// for each tag that has been set above, remove the first entry in the corresponding // for each tag that has been set above, remove the first entry in the corresponding
@@ -159,4 +141,3 @@ PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps)
return properties; return properties;
} }

View File

@@ -40,8 +40,7 @@ namespace TagLib {
* *
* Only Title and Artist tags are supported * Only Title and Artist tags are supported
*/ */
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
{
public: public:
Tag(); Tag();
virtual ~Tag(); virtual ~Tag();
@@ -143,10 +142,9 @@ namespace TagLib {
class TagPrivate; class TagPrivate;
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace DIIN
} } // namespace DSDIFF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -37,10 +37,8 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{ struct Chunk64 {
struct Chunk64
{
ByteVector name; ByteVector name;
unsigned long long offset; unsigned long long offset;
unsigned long long size; unsigned long long size;
@@ -49,8 +47,7 @@ namespace
typedef std::vector<Chunk64> ChunkList; typedef std::vector<Chunk64> ChunkList;
int chunkIndex(const ChunkList &chunks, const ByteVector &id) int chunkIndex(const ChunkList &chunks, const ByteVector &id) {
{
for (unsigned long int i = 0; i < chunks.size(); i++) { for (unsigned long int i = 0; i < chunks.size(); i++) {
if (chunks[i].name == id) if (chunks[i].name == id)
return i; return i;
@@ -59,8 +56,7 @@ namespace
return -1; return -1;
} }
bool isValidChunkID(const ByteVector &name) bool isValidChunkID(const ByteVector &name) {
{
if (name.size() != 4) if (name.size() != 4)
return false; return false;
@@ -80,27 +76,23 @@ namespace
PROPChunk = 0, PROPChunk = 0,
DIINChunk = 1 DIINChunk = 1
}; };
} } // namespace
class DSDIFF::File::FilePrivate class DSDIFF::File::FilePrivate {
{
public: public:
FilePrivate() : FilePrivate() : endianness(BigEndian),
endianness(BigEndian),
size(0), size(0),
isID3InPropChunk(false), isID3InPropChunk(false),
duplicateID3V2chunkIndex(-1), duplicateID3V2chunkIndex(-1),
properties(0), properties(0),
id3v2TagChunkID("ID3 "), id3v2TagChunkID("ID3 "),
hasID3v2(false), hasID3v2(false),
hasDiin(false) hasDiin(false) {
{
childChunkIndex[ID3v2Index] = -1; childChunkIndex[ID3v2Index] = -1;
childChunkIndex[DIINIndex] = -1; childChunkIndex[DIINIndex] = -1;
} }
~FilePrivate() ~FilePrivate() {
{
delete properties; delete properties;
} }
@@ -135,8 +127,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool DSDIFF::File::isSupported(IOStream *stream) bool DSDIFF::File::isSupported(IOStream *stream) {
{
// A DSDIFF file has to start with "FRM8????????DSD ". // A DSDIFF file has to start with "FRM8????????DSD ".
const ByteVector id = Utils::readHeader(stream, 16, false); const ByteVector id = Utils::readHeader(stream, 16, false);
@@ -148,8 +139,7 @@ bool DSDIFF::File::isSupported(IOStream *stream)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DSDIFF::File::File(FileName file, bool readProperties, DSDIFF::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file) Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file) {
{
d = new FilePrivate; d = new FilePrivate;
d->endianness = BigEndian; d->endianness = BigEndian;
if (isOpen()) if (isOpen())
@@ -157,54 +147,45 @@ DSDIFF::File::File(FileName file, bool readProperties,
} }
DSDIFF::File::File(IOStream *stream, bool readProperties, DSDIFF::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream) Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream) {
{
d = new FilePrivate; d = new FilePrivate;
d->endianness = BigEndian; d->endianness = BigEndian;
if (isOpen()) if (isOpen())
read(readProperties, propertiesStyle); read(readProperties, propertiesStyle);
} }
DSDIFF::File::~File() DSDIFF::File::~File() {
{
delete d; delete d;
} }
Strawberry_TagLib::TagLib::Tag *DSDIFF::File::tag() const Strawberry_TagLib::TagLib::Tag *DSDIFF::File::tag() const {
{
return &d->tag; return &d->tag;
} }
ID3v2::Tag *DSDIFF::File::ID3v2Tag(bool create) const ID3v2::Tag *DSDIFF::File::ID3v2Tag(bool create) const {
{
return d->tag.access<ID3v2::Tag>(ID3v2Index, create); return d->tag.access<ID3v2::Tag>(ID3v2Index, create);
} }
bool DSDIFF::File::hasID3v2Tag() const bool DSDIFF::File::hasID3v2Tag() const {
{
return d->hasID3v2; return d->hasID3v2;
} }
DSDIFF::DIIN::Tag *DSDIFF::File::DIINTag(bool create) const DSDIFF::DIIN::Tag *DSDIFF::File::DIINTag(bool create) const {
{
return d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, create); return d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, create);
} }
bool DSDIFF::File::hasDIINTag() const bool DSDIFF::File::hasDIINTag() const {
{
return d->hasDiin; return d->hasDiin;
} }
PropertyMap DSDIFF::File::properties() const PropertyMap DSDIFF::File::properties() const {
{
if (d->hasID3v2) if (d->hasID3v2)
return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->properties(); return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->properties();
return PropertyMap(); return PropertyMap();
} }
void DSDIFF::File::removeUnsupportedProperties(const StringList &unsupported) void DSDIFF::File::removeUnsupportedProperties(const StringList &unsupported) {
{
if (d->hasID3v2) if (d->hasID3v2)
d->tag.access<ID3v2::Tag>(ID3v2Index, false)->removeUnsupportedProperties(unsupported); d->tag.access<ID3v2::Tag>(ID3v2Index, false)->removeUnsupportedProperties(unsupported);
@@ -212,23 +193,19 @@ void DSDIFF::File::removeUnsupportedProperties(const StringList &unsupported)
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->removeUnsupportedProperties(unsupported); d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->removeUnsupportedProperties(unsupported);
} }
PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) {
{
return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties); return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
} }
DSDIFF::Properties *DSDIFF::File::audioProperties() const DSDIFF::Properties *DSDIFF::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool DSDIFF::File::save() bool DSDIFF::File::save() {
{
return save(AllTags); return save(AllTags);
} }
bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) {
{
if (readOnly()) { if (readOnly()) {
debug("DSDIFF::File::save() -- File is read only."); debug("DSDIFF::File::save() -- File is read only.");
return false; return false;
@@ -304,8 +281,7 @@ bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version)
return true; return true;
} }
void DSDIFF::File::strip(TagTypes tags) void DSDIFF::File::strip(TagTypes tags) {
{
if (tags & ID3v2) { if (tags & ID3v2) {
removeRootChunk("ID3 "); removeRootChunk("ID3 ");
removeRootChunk("id3 "); removeRootChunk("id3 ");
@@ -326,8 +302,7 @@ void DSDIFF::File::strip(TagTypes tags)
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void DSDIFF::File::removeRootChunk(unsigned int i) void DSDIFF::File::removeRootChunk(unsigned int i) {
{
unsigned long long chunkSize = d->chunks[i].size + d->chunks[i].padding + 12; unsigned long long chunkSize = d->chunks[i].size + d->chunks[i].padding + 12;
d->size -= chunkSize; d->size -= chunkSize;
@@ -338,22 +313,19 @@ void DSDIFF::File::removeRootChunk(unsigned int i)
// Update the internal offsets // Update the internal offsets
for (unsigned long r = i + 1; r < d->chunks.size(); r++) for (unsigned long r = i + 1; r < d->chunks.size(); r++)
d->chunks[r].offset = d->chunks[r - 1].offset + 12 d->chunks[r].offset = d->chunks[r - 1].offset + 12 + d->chunks[r - 1].size + d->chunks[r - 1].padding;
+ d->chunks[r - 1].size + d->chunks[r - 1].padding;
d->chunks.erase(d->chunks.begin() + i); d->chunks.erase(d->chunks.begin() + i);
} }
void DSDIFF::File::removeRootChunk(const ByteVector &id) void DSDIFF::File::removeRootChunk(const ByteVector &id) {
{
int i = chunkIndex(d->chunks, id); int i = chunkIndex(d->chunks, id);
if (i >= 0) if (i >= 0)
removeRootChunk(i); removeRootChunk(i);
} }
void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) {
{
if (data.isEmpty()) { if (data.isEmpty()) {
removeRootChunk(i); removeRootChunk(i);
return; return;
@@ -380,8 +352,7 @@ void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data)
updateRootChunksStructure(i + 1); updateRootChunksStructure(i + 1);
} }
void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &data) void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &data) {
{
if (d->chunks.size() == 0) { if (d->chunks.size() == 0) {
debug("DSDIFF::File::setPropChunkData - No valid chunks found."); debug("DSDIFF::File::setPropChunkData - No valid chunks found.");
return; return;
@@ -418,8 +389,7 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da
d->chunks.push_back(chunk); d->chunks.push_back(chunk);
} }
void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) {
{
ChunkList &childChunks = d->childChunks[childChunkNum]; ChunkList &childChunks = d->childChunks[childChunkNum];
// Update global size // Update global size
@@ -445,23 +415,20 @@ void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum)
childChunks[i + 1].offset = childChunks[i].offset; childChunks[i + 1].offset = childChunks[i].offset;
i++; i++;
for (i++; i < childChunks.size(); i++) for (i++; i < childChunks.size(); i++)
childChunks[i].offset = childChunks[i - 1].offset + 12 childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding;
+ childChunks[i - 1].size + childChunks[i - 1].padding;
} }
// And for root chunks // And for root chunks
for (i = d->childChunkIndex[childChunkNum] + 1; i < d->chunks.size(); i++) for (i = d->childChunkIndex[childChunkNum] + 1; i < d->chunks.size(); i++)
d->chunks[i].offset = d->chunks[i - 1].offset + 12 d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding;
+ d->chunks[i - 1].size + d->chunks[i - 1].padding;
childChunks.erase(childChunks.begin() + i); childChunks.erase(childChunks.begin() + i);
} }
void DSDIFF::File::setChildChunkData(unsigned int i, void DSDIFF::File::setChildChunkData(unsigned int i,
const ByteVector &data, const ByteVector &data,
unsigned int childChunkNum) unsigned int childChunkNum) {
{
ChunkList &childChunks = d->childChunks[childChunkNum]; ChunkList &childChunks = d->childChunks[childChunkNum];
if (data.isEmpty()) { if (data.isEmpty()) {
@@ -497,8 +464,7 @@ void DSDIFF::File::setChildChunkData(unsigned int i,
// Now update the internal offsets // Now update the internal offsets
// For child Chunks // For child Chunks
for (i++; i < childChunks.size(); i++) for (i++; i < childChunks.size(); i++)
childChunks[i].offset = childChunks[i - 1].offset + 12 childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding;
+ childChunks[i - 1].size + childChunks[i - 1].padding;
// And for root chunks // And for root chunks
updateRootChunksStructure(d->childChunkIndex[childChunkNum] + 1); updateRootChunksStructure(d->childChunkIndex[childChunkNum] + 1);
@@ -506,8 +472,7 @@ void DSDIFF::File::setChildChunkData(unsigned int i,
void DSDIFF::File::setChildChunkData(const ByteVector &name, void DSDIFF::File::setChildChunkData(const ByteVector &name,
const ByteVector &data, const ByteVector &data,
unsigned int childChunkNum) unsigned int childChunkNum) {
{
ChunkList &childChunks = d->childChunks[childChunkNum]; ChunkList &childChunks = d->childChunks[childChunkNum];
if (childChunks.size() == 0) { if (childChunks.size() == 0) {
@@ -539,8 +504,7 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name,
// And the child chunk size // And the child chunk size
d->chunks[d->childChunkIndex[childChunkNum]].size += (offset & 1) d->chunks[d->childChunkIndex[childChunkNum]].size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
+ ((data.size() + 1) & ~1) + 12;
insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size, insert(ByteVector::fromLongLong(d->chunks[d->childChunkIndex[childChunkNum]].size,
d->endianness == BigEndian), d->endianness == BigEndian),
d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8); d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
@@ -568,11 +532,9 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name,
childChunks.push_back(chunk); childChunks.push_back(chunk);
} }
void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk) void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk) {
{
for (unsigned int i = startingChunk; i < d->chunks.size(); i++) for (unsigned int i = startingChunk; i < d->chunks.size(); i++)
d->chunks[i].offset = d->chunks[i - 1].offset + 12 d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding;
+ d->chunks[i - 1].size + d->chunks[i - 1].padding;
// Update childchunks structure as well // Update childchunks structure as well
@@ -581,24 +543,20 @@ void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk)
if (childChunksToUpdate.size() > 0) { if (childChunksToUpdate.size() > 0) {
childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[PROPChunk]].offset + 12; childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[PROPChunk]].offset + 12;
for (unsigned int i = 1; i < childChunksToUpdate.size(); i++) for (unsigned int i = 1; i < childChunksToUpdate.size(); i++)
childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
+ childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
} }
} }
if (d->childChunkIndex[DIINChunk] >= static_cast<int>(startingChunk)) { if (d->childChunkIndex[DIINChunk] >= static_cast<int>(startingChunk)) {
ChunkList &childChunksToUpdate = d->childChunks[DIINChunk]; ChunkList &childChunksToUpdate = d->childChunks[DIINChunk];
if (childChunksToUpdate.size() > 0) { if (childChunksToUpdate.size() > 0) {
childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[DIINChunk]].offset + 12; childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[DIINChunk]].offset + 12;
for (unsigned int i = 1; i < childChunksToUpdate.size(); i++) for (unsigned int i = 1; i < childChunksToUpdate.size(); i++)
childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
+ childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
} }
} }
} }
void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) {
{
bool bigEndian = (d->endianness == BigEndian); bool bigEndian = (d->endianness == BigEndian);
d->type = readBlock(4); d->type = readBlock(4);
@@ -619,8 +577,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty
if (static_cast<unsigned long long>(tell()) + chunkSize > if (static_cast<unsigned long long>(tell()) + chunkSize >
static_cast<unsigned long long>(length())) { static_cast<unsigned long long>(length())) {
debug("DSDIFF::File::read() -- Chunk '" + chunkName debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)");
+ "' has invalid size (larger than the file size)");
setValid(false); setValid(false);
break; break;
} }
@@ -679,8 +636,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty
} }
if (static_cast<long long>(tell()) + dstChunkSize > dstChunkEnd) { if (static_cast<long long>(tell()) + dstChunkSize > dstChunkEnd) {
debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid size (larger than the DST chunk)");
+ "' has invalid size (larger than the DST chunk)");
setValid(false); setValid(false);
break; break;
} }
@@ -722,8 +678,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty
} }
if (static_cast<long long>(tell()) + propChunkSize > propChunkEnd) { if (static_cast<long long>(tell()) + propChunkSize > propChunkEnd) {
debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid size (larger than the PROP chunk)");
+ "' has invalid size (larger than the PROP chunk)");
setValid(false); setValid(false);
break; break;
} }
@@ -769,8 +724,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty
} }
if (static_cast<long long>(tell()) + diinChunkSize > diinChunkEnd) { if (static_cast<long long>(tell()) + diinChunkSize > diinChunkEnd) {
debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid size (larger than the DIIN chunk)");
+ "' has invalid size (larger than the DIIN chunk)");
setValid(false); setValid(false);
break; break;
} }
@@ -906,8 +860,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty
void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
unsigned long long offset, unsigned long replace, unsigned long long offset, unsigned long replace,
unsigned int leadingPadding) unsigned int leadingPadding) {
{
ByteVector combined; ByteVector combined;
if (leadingPadding) if (leadingPadding)
combined.append(ByteVector(leadingPadding, '\x00')); combined.append(ByteVector(leadingPadding, '\x00'));
@@ -920,4 +873,3 @@ void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
insert(combined, offset, replace); insert(combined, offset, replace);
} }

View File

@@ -59,10 +59,8 @@ namespace TagLib {
* information specific to DSDIFF files. * information specific to DSDIFF files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* This set of flags is used for various operations and is suitable for * This set of flags is used for various operations and is suitable for
* being OR-ed together. * being OR-ed together.
@@ -218,7 +216,8 @@ namespace TagLib {
static bool isSupported(IOStream *stream); static bool isSupported(IOStream *stream);
protected: protected:
enum Endianness { BigEndian, LittleEndian }; enum Endianness { BigEndian,
LittleEndian };
File(FileName file, Endianness endianness); File(FileName file, Endianness endianness);
File(IOStream *stream, Endianness endianness); File(IOStream *stream, Endianness endianness);
@@ -280,9 +279,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace DSDIFF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,17 +30,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class DSDIFF::Properties::PropertiesPrivate class DSDIFF::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : length(0),
length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
channels(0), channels(0),
sampleWidth(0), sampleWidth(0),
sampleCount(0) sampleCount(0) {
{
} }
int length; int length;
@@ -59,8 +56,7 @@ DSDIFF::Properties::Properties(const unsigned int sampleRate,
const unsigned short channels, const unsigned short channels,
const unsigned long long samplesCount, const unsigned long long samplesCount,
const int bitrate, const int bitrate,
ReadStyle style) : AudioProperties(style) ReadStyle style) : AudioProperties(style) {
{
d = new PropertiesPrivate; d = new PropertiesPrivate;
d->channels = channels; d->channels = channels;
@@ -68,53 +64,41 @@ DSDIFF::Properties::Properties(const unsigned int sampleRate,
d->sampleWidth = 1; d->sampleWidth = 1;
d->sampleRate = sampleRate; d->sampleRate = sampleRate;
d->bitrate = bitrate; d->bitrate = bitrate;
d->length = d->sampleRate > 0 d->length = d->sampleRate > 0 ? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5) : 0;
? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5)
: 0;
} }
DSDIFF::Properties::~Properties() DSDIFF::Properties::~Properties() {
{
delete d; delete d;
} }
int DSDIFF::Properties::length() const int DSDIFF::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int DSDIFF::Properties::lengthInSeconds() const int DSDIFF::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int DSDIFF::Properties::lengthInMilliseconds() const int DSDIFF::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int DSDIFF::Properties::bitrate() const int DSDIFF::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int DSDIFF::Properties::sampleRate() const int DSDIFF::Properties::sampleRate() const {
{
return d->sampleRate; return d->sampleRate;
} }
int DSDIFF::Properties::channels() const int DSDIFF::Properties::channels() const {
{
return d->channels; return d->channels;
} }
int DSDIFF::Properties::bitsPerSample() const int DSDIFF::Properties::bitsPerSample() const {
{
return d->sampleWidth; return d->sampleWidth;
} }
long long DSDIFF::Properties::sampleCount() const long long DSDIFF::Properties::sampleCount() const {
{
return d->sampleCount; return d->sampleCount;
} }

View File

@@ -42,8 +42,7 @@ namespace TagLib {
* API. * API.
*/ */
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
/*! /*!
* Create an instance of DSDIFF::Properties with the data read from the * Create an instance of DSDIFF::Properties with the data read from the
@@ -77,9 +76,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace DSDIFF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -36,19 +36,15 @@ using namespace Strawberry_TagLib::TagLib;
// The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf // The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
class DSF::File::FilePrivate class DSF::File::FilePrivate {
{
public: public:
FilePrivate() : FilePrivate() : fileSize(0),
fileSize(0),
metadataOffset(0), metadataOffset(0),
properties(nullptr), properties(nullptr),
tag(nullptr) tag(nullptr) {
{
} }
~FilePrivate() ~FilePrivate() {
{
delete properties; delete properties;
delete tag; delete tag;
} }
@@ -63,8 +59,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool DSF::File::isSupported(IOStream *stream) bool DSF::File::isSupported(IOStream *stream) {
{
// A DSF file has to start with "DSD " // A DSF file has to start with "DSD "
const ByteVector id = Utils::readHeader(stream, 4, false); const ByteVector id = Utils::readHeader(stream, 4, false);
return id.startsWith("DSD "); return id.startsWith("DSD ");
@@ -75,50 +70,40 @@ bool DSF::File::isSupported(IOStream *stream)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DSF::File::File(FileName file, bool readProperties, DSF::File::File(FileName file, bool readProperties,
Properties::ReadStyle propertiesStyle) : Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties, propertiesStyle); read(readProperties, propertiesStyle);
} }
DSF::File::File(IOStream *stream, bool readProperties, DSF::File::File(IOStream *stream, bool readProperties,
Properties::ReadStyle propertiesStyle) : Properties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties, propertiesStyle); read(readProperties, propertiesStyle);
} }
DSF::File::~File() DSF::File::~File() {
{
delete d; delete d;
} }
ID3v2::Tag *DSF::File::tag() const ID3v2::Tag *DSF::File::tag() const {
{
return d->tag; return d->tag;
} }
PropertyMap DSF::File::properties() const PropertyMap DSF::File::properties() const {
{
return d->tag->properties(); return d->tag->properties();
} }
PropertyMap DSF::File::setProperties(const PropertyMap &properties) PropertyMap DSF::File::setProperties(const PropertyMap &properties) {
{
return d->tag->setProperties(properties); return d->tag->setProperties(properties);
} }
DSF::Properties *DSF::File::audioProperties() const DSF::Properties *DSF::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool DSF::File::save() bool DSF::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("DSF::File::save() -- File is read only."); debug("DSF::File::save() -- File is read only.");
return false; return false;
@@ -180,8 +165,7 @@ bool DSF::File::save()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) void DSF::File::read(bool, Properties::ReadStyle propertiesStyle) {
{
// A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk // A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk
// The file format is not chunked in the sense of a RIFF File, though // The file format is not chunked in the sense of a RIFF File, though
@@ -240,4 +224,3 @@ void DSF::File::read(bool, Properties::ReadStyle propertiesStyle)
else else
d->tag = new ID3v2::Tag(this, d->metadataOffset); d->tag = new ID3v2::Tag(this, d->metadataOffset);
} }

View File

@@ -52,8 +52,7 @@ namespace TagLib {
* information specific to DSF files. * information specific to DSF files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* Constructs an DSF file from \a file. If \a readProperties is true the * Constructs an DSF file from \a file. If \a readProperties is true the
@@ -122,9 +121,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace DSF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,11 +30,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class DSF::Properties::PropertiesPrivate class DSF::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : formatVersion(0),
formatVersion(0),
formatID(0), formatID(0),
channelType(0), channelType(0),
channelNum(0), channelNum(0),
@@ -43,8 +41,7 @@ public:
sampleCount(0), sampleCount(0),
blockSizePerChannel(0), blockSizePerChannel(0),
bitrate(0), bitrate(0),
length(0) length(0) {
{
} }
// Nomenclature is from DSF file format specification // Nomenclature is from DSF file format specification
@@ -66,75 +63,61 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DSF::Properties::Properties(const ByteVector &data, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) DSF::Properties::Properties(const ByteVector &data, ReadStyle style) : Strawberry_TagLib::TagLib::AudioProperties(style) {
{
d = new PropertiesPrivate; d = new PropertiesPrivate;
read(data); read(data);
} }
DSF::Properties::~Properties() DSF::Properties::~Properties() {
{
delete d; delete d;
} }
int DSF::Properties::length() const int DSF::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int DSF::Properties::lengthInSeconds() const int DSF::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int DSF::Properties::lengthInMilliseconds() const int DSF::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int DSF::Properties::bitrate() const int DSF::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int DSF::Properties::sampleRate() const int DSF::Properties::sampleRate() const {
{
return d->samplingFrequency; return d->samplingFrequency;
} }
int DSF::Properties::channels() const int DSF::Properties::channels() const {
{
return d->channelNum; return d->channelNum;
} }
// DSF specific // DSF specific
int DSF::Properties::formatVersion() const int DSF::Properties::formatVersion() const {
{
return d->formatVersion; return d->formatVersion;
} }
int DSF::Properties::formatID() const int DSF::Properties::formatID() const {
{
return d->formatID; return d->formatID;
} }
int DSF::Properties::channelType() const int DSF::Properties::channelType() const {
{
return d->channelType; return d->channelType;
} }
int DSF::Properties::bitsPerSample() const int DSF::Properties::bitsPerSample() const {
{
return d->bitsPerSample; return d->bitsPerSample;
} }
long long DSF::Properties::sampleCount() const long long DSF::Properties::sampleCount() const {
{
return d->sampleCount; return d->sampleCount;
} }
int DSF::Properties::blockSizePerChannel() const int DSF::Properties::blockSizePerChannel() const {
{
return d->blockSizePerChannel; return d->blockSizePerChannel;
} }
@@ -142,8 +125,7 @@ int DSF::Properties::blockSizePerChannel() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void DSF::Properties::read(const ByteVector &data) void DSF::Properties::read(const ByteVector &data) {
{
d->formatVersion = data.toUInt(0U, false); d->formatVersion = data.toUInt(0U, false);
d->formatID = data.toUInt(4U, false); d->formatID = data.toUInt(4U, false);
d->channelType = data.toUInt(8U, false); d->channelType = data.toUInt(8U, false);
@@ -153,9 +135,6 @@ void DSF::Properties::read(const ByteVector &data)
d->sampleCount = data.toLongLong(24U, false); d->sampleCount = data.toLongLong(24U, false);
d->blockSizePerChannel = data.toUInt(32U, false); d->blockSizePerChannel = data.toUInt(32U, false);
d->bitrate d->bitrate = static_cast<unsigned int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
= static_cast<unsigned int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5); d->length = d->samplingFrequency > 0 ? static_cast<unsigned int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
d->length
= d->samplingFrequency > 0 ? static_cast<unsigned int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
} }

View File

@@ -42,8 +42,7 @@ namespace TagLib {
* API. * API.
*/ */
class TAGLIB_EXPORT Properties : public Strawberry_TagLib::TagLib::AudioProperties class TAGLIB_EXPORT Properties : public Strawberry_TagLib::TagLib::AudioProperties {
{
public: public:
/*! /*!
* Create an instance of DSF::AudioProperties with the data read from the * Create an instance of DSF::AudioProperties with the data read from the
@@ -86,9 +85,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace DSF
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -57,16 +57,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{
typedef List<const FileRef::FileTypeResolver *> ResolverList; typedef List<const FileRef::FileTypeResolver *> ResolverList;
ResolverList fileTypeResolvers; ResolverList fileTypeResolvers;
// Detect the file type by user-defined resolvers. // Detect the file type by user-defined resolvers.
File *detectByResolvers(FileName fileName, bool readAudioProperties, File *detectByResolvers(FileName fileName, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
ResolverList::ConstIterator it = fileTypeResolvers.begin(); ResolverList::ConstIterator it = fileTypeResolvers.begin();
for (; it != fileTypeResolvers.end(); ++it) { for (; it != fileTypeResolvers.end(); ++it) {
File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle); File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle);
@@ -80,8 +78,7 @@ namespace
// Detect the file type based on the file extension. // Detect the file type based on the file extension.
File *detectByExtension(IOStream *stream, bool readAudioProperties, File *detectByExtension(IOStream *stream, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
#ifdef _WIN32 #ifdef _WIN32
const String s = stream->name().toString(); const String s = stream->name().toString();
#else #else
@@ -148,8 +145,7 @@ namespace
// Detect the file type based on the actual content of the stream. // Detect the file type based on the actual content of the stream.
File *detectByContent(IOStream *stream, bool readAudioProperties, File *detectByContent(IOStream *stream, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
File *file = 0; File *file = 0;
if (MPEG::File::isSupported(stream)) if (MPEG::File::isSupported(stream))
@@ -202,8 +198,7 @@ namespace
// behavior of FileRef::create(). // behavior of FileRef::create().
File *createInternal(FileName fileName, bool readAudioProperties, File *createInternal(FileName fileName, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
if (file) if (file)
return file; return file;
@@ -272,13 +267,11 @@ namespace
return nullptr; return nullptr;
} }
} } // namespace
class FileRef::FileRefPrivate : public RefCounter class FileRef::FileRefPrivate : public RefCounter {
{
public: public:
FileRefPrivate() : FileRefPrivate() : RefCounter(),
RefCounter(),
file(0), file(0),
stream(0) {} stream(0) {}
@@ -295,44 +288,32 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
FileRef::FileRef() : FileRef::FileRef() : d(new FileRefPrivate()) {
d(new FileRefPrivate())
{
} }
FileRef::FileRef(FileName fileName, bool readAudioProperties, FileRef::FileRef(FileName fileName, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) : AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
d(new FileRefPrivate())
{
parse(fileName, readAudioProperties, audioPropertiesStyle); parse(fileName, readAudioProperties, audioPropertiesStyle);
} }
FileRef::FileRef(IOStream* stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : FileRef::FileRef(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
d(new FileRefPrivate())
{
parse(stream, readAudioProperties, audioPropertiesStyle); parse(stream, readAudioProperties, audioPropertiesStyle);
} }
FileRef::FileRef(File *file) : FileRef::FileRef(File *file) : d(new FileRefPrivate()) {
d(new FileRefPrivate())
{
d->file = file; d->file = file;
} }
FileRef::FileRef(const FileRef &ref) : FileRef::FileRef(const FileRef &ref) : d(ref.d) {
d(ref.d)
{
d->ref(); d->ref();
} }
FileRef::~FileRef() FileRef::~FileRef() {
{
if (d->deref()) if (d->deref())
delete d; delete d;
} }
Tag *FileRef::tag() const Tag *FileRef::tag() const {
{
if (isNull()) { if (isNull()) {
debug("FileRef::tag() - Called without a valid file."); debug("FileRef::tag() - Called without a valid file.");
return nullptr; return nullptr;
@@ -340,8 +321,7 @@ Tag *FileRef::tag() const
return d->file->tag(); return d->file->tag();
} }
AudioProperties *FileRef::audioProperties() const AudioProperties *FileRef::audioProperties() const {
{
if (isNull()) { if (isNull()) {
debug("FileRef::audioProperties() - Called without a valid file."); debug("FileRef::audioProperties() - Called without a valid file.");
return nullptr; return nullptr;
@@ -349,13 +329,11 @@ AudioProperties *FileRef::audioProperties() const
return d->file->audioProperties(); return d->file->audioProperties();
} }
File *FileRef::file() const File *FileRef::file() const {
{
return d->file; return d->file;
} }
bool FileRef::save() bool FileRef::save() {
{
if (isNull()) { if (isNull()) {
debug("FileRef::save() - Called without a valid file."); debug("FileRef::save() - Called without a valid file.");
return false; return false;
@@ -369,8 +347,7 @@ const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::Fil
return resolver; return resolver;
} }
StringList FileRef::defaultFileExtensions() StringList FileRef::defaultFileExtensions() {
{
StringList l; StringList l;
l.append("ogg"); l.append("ogg");
@@ -408,31 +385,26 @@ StringList FileRef::defaultFileExtensions()
return l; return l;
} }
bool FileRef::isNull() const bool FileRef::isNull() const {
{
return (!d->file || !d->file->isValid()); return (!d->file || !d->file->isValid());
} }
FileRef &FileRef::operator=(const FileRef &ref) FileRef &FileRef::operator=(const FileRef &ref) {
{
FileRef(ref).swap(*this); FileRef(ref).swap(*this);
return *this; return *this;
} }
void FileRef::swap(FileRef &ref) void FileRef::swap(FileRef &ref) {
{
using std::swap; using std::swap;
swap(d, ref.d); swap(d, ref.d);
} }
bool FileRef::operator==(const FileRef &ref) const bool FileRef::operator==(const FileRef &ref) const {
{
return (ref.d->file == d->file); return (ref.d->file == d->file);
} }
bool FileRef::operator!=(const FileRef &ref) const bool FileRef::operator!=(const FileRef &ref) const {
{
return (ref.d->file != d->file); return (ref.d->file != d->file);
} }
@@ -447,8 +419,7 @@ File *FileRef::create(FileName fileName, bool readAudioProperties,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void FileRef::parse(FileName fileName, bool readAudioProperties, void FileRef::parse(FileName fileName, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
// Try user-defined resolvers. // Try user-defined resolvers.
d->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); d->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
@@ -475,8 +446,7 @@ void FileRef::parse(FileName fileName, bool readAudioProperties,
} }
void FileRef::parse(IOStream *stream, bool readAudioProperties, void FileRef::parse(IOStream *stream, bool readAudioProperties,
AudioProperties::ReadStyle audioPropertiesStyle) AudioProperties::ReadStyle audioPropertiesStyle) {
{
// User-defined resolvers won't work with a stream. // User-defined resolvers won't work with a stream.
// Try to resolve file types based on the file extension. // Try to resolve file types based on the file extension.

View File

@@ -57,10 +57,8 @@ namespace TagLib {
* \see addFileTypeResolver() * \see addFileTypeResolver()
*/ */
class TAGLIB_EXPORT FileRef class TAGLIB_EXPORT FileRef {
{
public: public:
//! A class for pluggable file type resolution. //! A class for pluggable file type resolution.
/*! /*!
@@ -90,8 +88,7 @@ namespace TagLib {
* to TagLib. * to TagLib.
*/ */
class TAGLIB_EXPORT FileTypeResolver class TAGLIB_EXPORT FileTypeResolver {
{
public: public:
virtual ~FileTypeResolver(); virtual ~FileTypeResolver();
/*! /*!
@@ -283,7 +280,7 @@ namespace TagLib {
FileRefPrivate *d; FileRefPrivate *d;
}; };
} } // namespace TagLib
} // namespace Strawberry_TagLib::TagLib } // namespace Strawberry_TagLib
#endif // TAGLIB_FILEREF_H #endif // TAGLIB_FILEREF_H

View File

@@ -43,38 +43,35 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{
typedef List<FLAC::MetadataBlock *> BlockList; typedef List<FLAC::MetadataBlock *> BlockList;
typedef BlockList::Iterator BlockIterator; typedef BlockList::Iterator BlockIterator;
typedef BlockList::Iterator BlockConstIterator; typedef BlockList::Iterator BlockConstIterator;
enum { FlacXiphIndex = 0, FlacID3v2Index = 1, FlacID3v1Index = 2 }; enum { FlacXiphIndex = 0,
FlacID3v2Index = 1,
FlacID3v1Index = 2 };
const long MinPaddingLength = 4096; const long MinPaddingLength = 4096;
const long MaxPaddingLegnth = 1024 * 1024; const long MaxPaddingLegnth = 1024 * 1024;
const char LastBlockFlag = '\x80'; const char LastBlockFlag = '\x80';
} } // namespace
class FLAC::File::FilePrivate class FLAC::File::FilePrivate {
{
public: public:
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : explicit FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) : ID3v2FrameFactory(frameFactory),
ID3v2FrameFactory(frameFactory),
ID3v2Location(-1), ID3v2Location(-1),
ID3v2OriginalSize(0), ID3v2OriginalSize(0),
ID3v1Location(-1), ID3v1Location(-1),
properties(0), properties(0),
flacStart(0), flacStart(0),
streamStart(0), streamStart(0),
scanned(false) scanned(false) {
{
blocks.setAutoDelete(true); blocks.setAutoDelete(true);
} }
~FilePrivate() ~FilePrivate() {
{
delete properties; delete properties;
} }
@@ -99,8 +96,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool FLAC::File::isSupported(IOStream *stream) bool FLAC::File::isSupported(IOStream *stream) {
{
// A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede. // A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede.
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true); const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
@@ -111,64 +107,51 @@ bool FLAC::File::isSupported(IOStream *stream)
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory, FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory,
bool readProperties, Properties::ReadStyle) : bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(frameFactory)) {
d(new FilePrivate(frameFactory))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
bool readProperties, Properties::ReadStyle) : bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
d(new FilePrivate(frameFactory))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
FLAC::File::~File() FLAC::File::~File() {
{
delete d; delete d;
} }
Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const {
{
return &d->tag; return &d->tag;
} }
PropertyMap FLAC::File::properties() const PropertyMap FLAC::File::properties() const {
{
return d->tag.properties(); return d->tag.properties();
} }
void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) {
{
d->tag.removeUnsupportedProperties(unsupported); d->tag.removeUnsupportedProperties(unsupported);
} }
PropertyMap FLAC::File::setProperties(const PropertyMap &properties) PropertyMap FLAC::File::setProperties(const PropertyMap &properties) {
{
return xiphComment(true)->setProperties(properties); return xiphComment(true)->setProperties(properties);
} }
FLAC::Properties *FLAC::File::audioProperties() const FLAC::Properties *FLAC::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool FLAC::File::save() bool FLAC::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("FLAC::File::save() - Cannot save to a read only file."); debug("FLAC::File::save() - Cannot save to a read only file.");
return false; return false;
@@ -307,40 +290,33 @@ bool FLAC::File::save()
return true; return true;
} }
ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) {
{
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, create); return d->tag.access<ID3v2::Tag>(FlacID3v2Index, create);
} }
ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) {
{
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, create); return d->tag.access<ID3v1::Tag>(FlacID3v1Index, create);
} }
Ogg::XiphComment *FLAC::File::xiphComment(bool create) Ogg::XiphComment *FLAC::File::xiphComment(bool create) {
{
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, create); return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, create);
} }
void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory) {
{
d->ID3v2FrameFactory = factory; d->ID3v2FrameFactory = factory;
} }
ByteVector FLAC::File::streamInfoData() ByteVector FLAC::File::streamInfoData() {
{
debug("FLAC::File::streamInfoData() -- This function is obsolete. Returning an empty ByteVector."); debug("FLAC::File::streamInfoData() -- This function is obsolete. Returning an empty ByteVector.");
return ByteVector(); return ByteVector();
} }
long FLAC::File::streamLength() long FLAC::File::streamLength() {
{
debug("FLAC::File::streamLength() -- This function is obsolete. Returning zero."); debug("FLAC::File::streamLength() -- This function is obsolete. Returning zero.");
return 0; return 0;
} }
List<FLAC::Picture *> FLAC::File::pictureList() List<FLAC::Picture *> FLAC::File::pictureList() {
{
List<Picture *> pictures; List<Picture *> pictures;
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) { for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
Picture *picture = dynamic_cast<Picture *>(*it); Picture *picture = dynamic_cast<Picture *>(*it);
@@ -351,13 +327,11 @@ List<FLAC::Picture *> FLAC::File::pictureList()
return pictures; return pictures;
} }
void FLAC::File::addPicture(Picture *picture) void FLAC::File::addPicture(Picture *picture) {
{
d->blocks.append(picture); d->blocks.append(picture);
} }
void FLAC::File::removePicture(Picture *picture, bool del) void FLAC::File::removePicture(Picture *picture, bool del) {
{
BlockIterator it = d->blocks.find(picture); BlockIterator it = d->blocks.find(picture);
if (it != d->blocks.end()) if (it != d->blocks.end())
d->blocks.erase(it); d->blocks.erase(it);
@@ -366,8 +340,7 @@ void FLAC::File::removePicture(Picture *picture, bool del)
delete picture; delete picture;
} }
void FLAC::File::removePictures() void FLAC::File::removePictures() {
{
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) { for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) {
if (dynamic_cast<Picture *>(*it)) { if (dynamic_cast<Picture *>(*it)) {
delete *it; delete *it;
@@ -379,8 +352,7 @@ void FLAC::File::removePictures()
} }
} }
void FLAC::File::strip(int tags) void FLAC::File::strip(int tags) {
{
if (tags & ID3v1) if (tags & ID3v1)
d->tag.set(FlacID3v1Index, 0); d->tag.set(FlacID3v1Index, 0);
@@ -393,18 +365,15 @@ void FLAC::File::strip(int tags)
} }
} }
bool FLAC::File::hasXiphComment() const bool FLAC::File::hasXiphComment() const {
{
return !d->xiphCommentData.isEmpty(); return !d->xiphCommentData.isEmpty();
} }
bool FLAC::File::hasID3v1Tag() const bool FLAC::File::hasID3v1Tag() const {
{
return (d->ID3v1Location >= 0); return (d->ID3v1Location >= 0);
} }
bool FLAC::File::hasID3v2Tag() const bool FLAC::File::hasID3v2Tag() const {
{
return (d->ID3v2Location >= 0); return (d->ID3v2Location >= 0);
} }
@@ -412,8 +381,7 @@ bool FLAC::File::hasID3v2Tag() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void FLAC::File::read(bool readProperties) void FLAC::File::read(bool readProperties) {
{
// Look for an ID3v2 tag // Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this); d->ID3v2Location = Utils::findID3v2(this);
@@ -459,8 +427,7 @@ void FLAC::File::read(bool readProperties)
} }
} }
void FLAC::File::scan() void FLAC::File::scan() {
{
// Scan the metadata pages // Scan the metadata pages
if (d->scanned) if (d->scanned)
@@ -514,9 +481,7 @@ void FLAC::File::scan()
return; return;
} }
if(blockLength == 0 if (blockLength == 0 && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) {
&& blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable)
{
debug("FLAC::File::scan() -- Zero-sized metadata block found"); debug("FLAC::File::scan() -- Zero-sized metadata block found");
setValid(false); setValid(false);
return; return;

View File

@@ -38,9 +38,16 @@ namespace Strawberry_TagLib {
namespace TagLib { namespace TagLib {
class Tag; class Tag;
namespace ID3v2 { class FrameFactory; class Tag; } namespace ID3v2 {
namespace ID3v1 { class Tag; } class FrameFactory;
namespace Ogg { class XiphComment; } class Tag;
} // namespace ID3v2
namespace ID3v1 {
class Tag;
}
namespace Ogg {
class XiphComment;
}
//! An implementation of FLAC metadata //! An implementation of FLAC metadata
@@ -64,8 +71,7 @@ namespace TagLib {
* information specific to FLAC files. * information specific to FLAC files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* This set of flags is used for various operations and is suitable for * This set of flags is used for various operations and is suitable for
@@ -338,8 +344,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace FLAC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -29,19 +29,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class FLAC::MetadataBlock::MetadataBlockPrivate class FLAC::MetadataBlock::MetadataBlockPrivate {
{
public: public:
MetadataBlockPrivate() {} MetadataBlockPrivate() {}
}; };
FLAC::MetadataBlock::MetadataBlock() FLAC::MetadataBlock::MetadataBlock() {
{
d = 0; d = 0;
} }
FLAC::MetadataBlock::~MetadataBlock() FLAC::MetadataBlock::~MetadataBlock() {
{
} }

View File

@@ -35,8 +35,7 @@ namespace TagLib {
namespace FLAC { namespace FLAC {
class TAGLIB_EXPORT MetadataBlock class TAGLIB_EXPORT MetadataBlock {
{
public: public:
MetadataBlock(); MetadataBlock();
virtual ~MetadataBlock(); virtual ~MetadataBlock();
@@ -69,9 +68,9 @@ namespace TagLib {
MetadataBlockPrivate *d; MetadataBlockPrivate *d;
}; };
} } // namespace FLAC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -29,16 +29,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class FLAC::Picture::PicturePrivate class FLAC::Picture::PicturePrivate {
{
public: public:
PicturePrivate() : PicturePrivate() : type(FLAC::Picture::Other),
type(FLAC::Picture::Other),
width(0), width(0),
height(0), height(0),
colorDepth(0), colorDepth(0),
numColors(0) numColors(0) {
{} }
Type type; Type type;
String mimeType; String mimeType;
@@ -50,29 +48,22 @@ public:
ByteVector data; ByteVector data;
}; };
FLAC::Picture::Picture() : FLAC::Picture::Picture() : d(new PicturePrivate()) {
d(new PicturePrivate())
{
} }
FLAC::Picture::Picture(const ByteVector &data) : FLAC::Picture::Picture(const ByteVector &data) : d(new PicturePrivate()) {
d(new PicturePrivate())
{
parse(data); parse(data);
} }
FLAC::Picture::~Picture() FLAC::Picture::~Picture() {
{
delete d; delete d;
} }
int FLAC::Picture::code() const int FLAC::Picture::code() const {
{
return FLAC::MetadataBlock::Picture; return FLAC::MetadataBlock::Picture;
} }
bool FLAC::Picture::parse(const ByteVector &data) bool FLAC::Picture::parse(const ByteVector &data) {
{
if (data.size() < 32) { if (data.size() < 32) {
debug("A picture block must contain at least 5 bytes."); debug("A picture block must contain at least 5 bytes.");
return false; return false;
@@ -116,8 +107,7 @@ bool FLAC::Picture::parse(const ByteVector &data)
return true; return true;
} }
ByteVector FLAC::Picture::render() const ByteVector FLAC::Picture::render() const {
{
ByteVector result; ByteVector result;
result.append(ByteVector::fromUInt(d->type)); result.append(ByteVector::fromUInt(d->type));
ByteVector mimeTypeData = d->mimeType.data(String::UTF8); ByteVector mimeTypeData = d->mimeType.data(String::UTF8);
@@ -135,83 +125,66 @@ ByteVector FLAC::Picture::render() const
return result; return result;
} }
FLAC::Picture::Type FLAC::Picture::type() const FLAC::Picture::Type FLAC::Picture::type() const {
{
return d->type; return d->type;
} }
void FLAC::Picture::setType(FLAC::Picture::Type type) void FLAC::Picture::setType(FLAC::Picture::Type type) {
{
d->type = type; d->type = type;
} }
String FLAC::Picture::mimeType() const String FLAC::Picture::mimeType() const {
{
return d->mimeType; return d->mimeType;
} }
void FLAC::Picture::setMimeType(const String &mimeType) void FLAC::Picture::setMimeType(const String &mimeType) {
{
d->mimeType = mimeType; d->mimeType = mimeType;
} }
String FLAC::Picture::description() const String FLAC::Picture::description() const {
{
return d->description; return d->description;
} }
void FLAC::Picture::setDescription(const String &description) void FLAC::Picture::setDescription(const String &description) {
{
d->description = description; d->description = description;
} }
int FLAC::Picture::width() const int FLAC::Picture::width() const {
{
return d->width; return d->width;
} }
void FLAC::Picture::setWidth(int width) void FLAC::Picture::setWidth(int width) {
{
d->width = width; d->width = width;
} }
int FLAC::Picture::height() const int FLAC::Picture::height() const {
{
return d->height; return d->height;
} }
void FLAC::Picture::setHeight(int height) void FLAC::Picture::setHeight(int height) {
{
d->height = height; d->height = height;
} }
int FLAC::Picture::colorDepth() const int FLAC::Picture::colorDepth() const {
{
return d->colorDepth; return d->colorDepth;
} }
void FLAC::Picture::setColorDepth(int colorDepth) void FLAC::Picture::setColorDepth(int colorDepth) {
{
d->colorDepth = colorDepth; d->colorDepth = colorDepth;
} }
int FLAC::Picture::numColors() const int FLAC::Picture::numColors() const {
{
return d->numColors; return d->numColors;
} }
void FLAC::Picture::setNumColors(int numColors) void FLAC::Picture::setNumColors(int numColors) {
{
d->numColors = numColors; d->numColors = numColors;
} }
ByteVector FLAC::Picture::data() const ByteVector FLAC::Picture::data() const {
{
return d->data; return d->data;
} }
void FLAC::Picture::setData(const ByteVector &data) void FLAC::Picture::setData(const ByteVector &data) {
{
d->data = data; d->data = data;
} }

View File

@@ -37,10 +37,8 @@ namespace TagLib {
namespace FLAC { namespace FLAC {
class TAGLIB_EXPORT Picture : public MetadataBlock class TAGLIB_EXPORT Picture : public MetadataBlock {
{
public: public:
/*! /*!
* This describes the function or content of the picture. * This describes the function or content of the picture.
*/ */
@@ -202,9 +200,9 @@ namespace TagLib {
typedef List<Picture> PictureList; typedef List<Picture> PictureList;
} } // namespace FLAC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,11 +31,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class FLAC::Properties::PropertiesPrivate class FLAC::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : length(0),
length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
bitsPerSample(0), bitsPerSample(0),
@@ -55,72 +53,57 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) : FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
read(data, streamLength); read(data, streamLength);
} }
FLAC::Properties::Properties(File *, ReadStyle style) : FLAC::Properties::Properties(File *, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
debug("FLAC::Properties::Properties() - This constructor is no longer used."); debug("FLAC::Properties::Properties() - This constructor is no longer used.");
} }
FLAC::Properties::~Properties() FLAC::Properties::~Properties() {
{
delete d; delete d;
} }
int FLAC::Properties::length() const int FLAC::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int FLAC::Properties::lengthInSeconds() const int FLAC::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int FLAC::Properties::lengthInMilliseconds() const int FLAC::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int FLAC::Properties::bitrate() const int FLAC::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int FLAC::Properties::sampleRate() const int FLAC::Properties::sampleRate() const {
{
return d->sampleRate; return d->sampleRate;
} }
int FLAC::Properties::bitsPerSample() const int FLAC::Properties::bitsPerSample() const {
{
return d->bitsPerSample; return d->bitsPerSample;
} }
int FLAC::Properties::sampleWidth() const int FLAC::Properties::sampleWidth() const {
{
return bitsPerSample(); return bitsPerSample();
} }
int FLAC::Properties::channels() const int FLAC::Properties::channels() const {
{
return d->channels; return d->channels;
} }
unsigned long long FLAC::Properties::sampleFrames() const unsigned long long FLAC::Properties::sampleFrames() const {
{
return d->sampleFrames; return d->sampleFrames;
} }
ByteVector FLAC::Properties::signature() const ByteVector FLAC::Properties::signature() const {
{
return d->signature; return d->signature;
} }
@@ -128,8 +111,7 @@ ByteVector FLAC::Properties::signature() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void FLAC::Properties::read(const ByteVector &data, long streamLength) void FLAC::Properties::read(const ByteVector &data, long streamLength) {
{
if (data.size() < 18) { if (data.size() < 18) {
debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes."); debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes.");
return; return;

View File

@@ -43,8 +43,7 @@ namespace TagLib {
* API. * API.
*/ */
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
/*! /*!
* Create an instance of FLAC::Properties with the data read from the * Create an instance of FLAC::Properties with the data read from the
@@ -143,8 +142,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace FLAC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,8 +30,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate {
{
public: public:
UnknownMetadataBlockPrivate() : code(0) {} UnknownMetadataBlockPrivate() : code(0) {}
@@ -39,40 +38,31 @@ public:
ByteVector data; ByteVector data;
}; };
FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : d(new UnknownMetadataBlockPrivate()) {
d(new UnknownMetadataBlockPrivate())
{
d->code = code; d->code = code;
d->data = data; d->data = data;
} }
FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() {
{
delete d; delete d;
} }
int FLAC::UnknownMetadataBlock::code() const int FLAC::UnknownMetadataBlock::code() const {
{
return d->code; return d->code;
} }
void FLAC::UnknownMetadataBlock::setCode(int code) void FLAC::UnknownMetadataBlock::setCode(int code) {
{
d->code = code; d->code = code;
} }
ByteVector FLAC::UnknownMetadataBlock::data() const ByteVector FLAC::UnknownMetadataBlock::data() const {
{
return d->data; return d->data;
} }
void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) {
{
d->data = data; d->data = data;
} }
ByteVector FLAC::UnknownMetadataBlock::render() const ByteVector FLAC::UnknownMetadataBlock::render() const {
{
return d->data; return d->data;
} }

View File

@@ -36,8 +36,7 @@ namespace TagLib {
namespace FLAC { namespace FLAC {
class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock {
{
public: public:
UnknownMetadataBlock(int blockType, const ByteVector &data); UnknownMetadataBlock(int blockType, const ByteVector &data);
~UnknownMetadataBlock(); ~UnknownMetadataBlock();
@@ -75,9 +74,9 @@ namespace TagLib {
UnknownMetadataBlockPrivate *d; UnknownMetadataBlockPrivate *d;
}; };
} } // namespace FLAC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -33,12 +33,10 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace IT; using namespace IT;
class IT::File::FilePrivate class IT::File::FilePrivate {
{
public: public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: tag(), properties(propertiesStyle) : tag(), properties(propertiesStyle) {
{
} }
Mod::Tag tag; Mod::Tag tag;
@@ -46,52 +44,41 @@ public:
}; };
IT::File::File(FileName file, bool readProperties, IT::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file),
Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
d(new FilePrivate(propertiesStyle))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
IT::File::File(IOStream *stream, bool readProperties, IT::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream),
Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
d(new FilePrivate(propertiesStyle))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
IT::File::~File() IT::File::~File() {
{
delete d; delete d;
} }
Mod::Tag *IT::File::tag() const Mod::Tag *IT::File::tag() const {
{
return &d->tag; return &d->tag;
} }
PropertyMap IT::File::properties() const PropertyMap IT::File::properties() const {
{
return d->tag.properties(); return d->tag.properties();
} }
PropertyMap IT::File::setProperties(const PropertyMap &properties) PropertyMap IT::File::setProperties(const PropertyMap &properties) {
{
return d->tag.setProperties(properties); return d->tag.setProperties(properties);
} }
IT::Properties *IT::File::audioProperties() const IT::Properties *IT::File::audioProperties() const {
{
return &d->properties; return &d->properties;
} }
bool IT::File::save() bool IT::File::save() {
{ if (readOnly()) {
if(readOnly())
{
debug("IT::File::save() - Cannot save to a read only file."); debug("IT::File::save() - Cannot save to a read only file.");
return false; return false;
} }
@@ -171,8 +158,7 @@ bool IT::File::save()
if (messageLength == 0) if (messageLength == 0)
messageOffset = fileSize; messageOffset = fileSize;
} }
else else {
{
messageOffset = fileSize; messageOffset = fileSize;
seek(46); seek(46);
writeU16L(special | 0x1); writeU16L(special | 0x1);
@@ -199,8 +185,7 @@ bool IT::File::save()
return true; return true;
} }
void IT::File::read(bool) void IT::File::read(bool) {
{
if (!isOpen()) if (!isOpen())
return; return;

View File

@@ -104,8 +104,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace IT
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -29,11 +29,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace IT; using namespace IT;
class IT::Properties::PropertiesPrivate class IT::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : channels(0),
channels(0),
lengthInPatterns(0), lengthInPatterns(0),
instrumentCount(0), instrumentCount(0),
sampleCount(0), sampleCount(0),
@@ -47,8 +45,7 @@ public:
tempo(0), tempo(0),
bpmSpeed(0), bpmSpeed(0),
panningSeparation(0), panningSeparation(0),
pitchWheelDepth(0) pitchWheelDepth(0) {
{
} }
int channels; int channels;
@@ -68,193 +65,154 @@ public:
unsigned char pitchWheelDepth; unsigned char pitchWheelDepth;
}; };
IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle),
AudioProperties(propertiesStyle), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
} }
IT::Properties::~Properties() IT::Properties::~Properties() {
{
delete d; delete d;
} }
int IT::Properties::length() const int IT::Properties::length() const {
{
return 0; return 0;
} }
int IT::Properties::lengthInSeconds() const int IT::Properties::lengthInSeconds() const {
{
return 0; return 0;
} }
int IT::Properties::lengthInMilliseconds() const int IT::Properties::lengthInMilliseconds() const {
{
return 0; return 0;
} }
int IT::Properties::bitrate() const int IT::Properties::bitrate() const {
{
return 0; return 0;
} }
int IT::Properties::sampleRate() const int IT::Properties::sampleRate() const {
{
return 0; return 0;
} }
int IT::Properties::channels() const int IT::Properties::channels() const {
{
return d->channels; return d->channels;
} }
unsigned short IT::Properties::lengthInPatterns() const unsigned short IT::Properties::lengthInPatterns() const {
{
return d->lengthInPatterns; return d->lengthInPatterns;
} }
bool IT::Properties::stereo() const bool IT::Properties::stereo() const {
{
return d->flags & Stereo; return d->flags & Stereo;
} }
unsigned short IT::Properties::instrumentCount() const unsigned short IT::Properties::instrumentCount() const {
{
return d->instrumentCount; return d->instrumentCount;
} }
unsigned short IT::Properties::sampleCount() const unsigned short IT::Properties::sampleCount() const {
{
return d->sampleCount; return d->sampleCount;
} }
unsigned short IT::Properties::patternCount() const unsigned short IT::Properties::patternCount() const {
{
return d->patternCount; return d->patternCount;
} }
unsigned short IT::Properties::version() const unsigned short IT::Properties::version() const {
{
return d->version; return d->version;
} }
unsigned short IT::Properties::compatibleVersion() const unsigned short IT::Properties::compatibleVersion() const {
{
return d->compatibleVersion; return d->compatibleVersion;
} }
unsigned short IT::Properties::flags() const unsigned short IT::Properties::flags() const {
{
return d->flags; return d->flags;
} }
unsigned short IT::Properties::special() const unsigned short IT::Properties::special() const {
{
return d->special; return d->special;
} }
unsigned char IT::Properties::globalVolume() const unsigned char IT::Properties::globalVolume() const {
{
return d->globalVolume; return d->globalVolume;
} }
unsigned char IT::Properties::mixVolume() const unsigned char IT::Properties::mixVolume() const {
{
return d->mixVolume; return d->mixVolume;
} }
unsigned char IT::Properties::tempo() const unsigned char IT::Properties::tempo() const {
{
return d->tempo; return d->tempo;
} }
unsigned char IT::Properties::bpmSpeed() const unsigned char IT::Properties::bpmSpeed() const {
{
return d->bpmSpeed; return d->bpmSpeed;
} }
unsigned char IT::Properties::panningSeparation() const unsigned char IT::Properties::panningSeparation() const {
{
return d->panningSeparation; return d->panningSeparation;
} }
unsigned char IT::Properties::pitchWheelDepth() const unsigned char IT::Properties::pitchWheelDepth() const {
{
return d->pitchWheelDepth; return d->pitchWheelDepth;
} }
void IT::Properties::setChannels(int channels) void IT::Properties::setChannels(int channels) {
{
d->channels = channels; d->channels = channels;
} }
void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) {
{
d->lengthInPatterns = lengthInPatterns; d->lengthInPatterns = lengthInPatterns;
} }
void IT::Properties::setInstrumentCount(unsigned short instrumentCount) void IT::Properties::setInstrumentCount(unsigned short instrumentCount) {
{
d->instrumentCount = instrumentCount; d->instrumentCount = instrumentCount;
} }
void IT::Properties::setSampleCount(unsigned short sampleCount) void IT::Properties::setSampleCount(unsigned short sampleCount) {
{
d->sampleCount = sampleCount; d->sampleCount = sampleCount;
} }
void IT::Properties::setPatternCount(unsigned short patternCount) void IT::Properties::setPatternCount(unsigned short patternCount) {
{
d->patternCount = patternCount; d->patternCount = patternCount;
} }
void IT::Properties::setFlags(unsigned short flags) void IT::Properties::setFlags(unsigned short flags) {
{
d->flags = flags; d->flags = flags;
} }
void IT::Properties::setSpecial(unsigned short special) void IT::Properties::setSpecial(unsigned short special) {
{
d->special = special; d->special = special;
} }
void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) {
{
d->compatibleVersion = compatibleVersion; d->compatibleVersion = compatibleVersion;
} }
void IT::Properties::setVersion(unsigned short version) void IT::Properties::setVersion(unsigned short version) {
{
d->version = version; d->version = version;
} }
void IT::Properties::setGlobalVolume(unsigned char globalVolume) void IT::Properties::setGlobalVolume(unsigned char globalVolume) {
{
d->globalVolume = globalVolume; d->globalVolume = globalVolume;
} }
void IT::Properties::setMixVolume(unsigned char mixVolume) void IT::Properties::setMixVolume(unsigned char mixVolume) {
{
d->mixVolume = mixVolume; d->mixVolume = mixVolume;
} }
void IT::Properties::setTempo(unsigned char tempo) void IT::Properties::setTempo(unsigned char tempo) {
{
d->tempo = tempo; d->tempo = tempo;
} }
void IT::Properties::setBpmSpeed(unsigned char bpmSpeed) void IT::Properties::setBpmSpeed(unsigned char bpmSpeed) {
{
d->bpmSpeed = bpmSpeed; d->bpmSpeed = bpmSpeed;
} }
void IT::Properties::setPanningSeparation(unsigned char panningSeparation) void IT::Properties::setPanningSeparation(unsigned char panningSeparation) {
{
d->panningSeparation = panningSeparation; d->panningSeparation = panningSeparation;
} }
void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth) void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth) {
{
d->pitchWheelDepth = pitchWheelDepth; d->pitchWheelDepth = pitchWheelDepth;
} }

View File

@@ -34,6 +34,7 @@ namespace TagLib {
namespace IT { namespace IT {
class TAGLIB_EXPORT Properties : public AudioProperties { class TAGLIB_EXPORT Properties : public AudioProperties {
friend class File; friend class File;
public: public:
/*! Flag bits. */ /*! Flag bits. */
enum { enum {
@@ -102,8 +103,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace IT
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -33,12 +33,10 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace Mod; using namespace Mod;
class Mod::File::FilePrivate class Mod::File::FilePrivate {
{
public: public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle)
: properties(propertiesStyle) : properties(propertiesStyle) {
{
} }
Mod::Tag tag; Mod::Tag tag;
@@ -46,50 +44,40 @@ public:
}; };
Mod::File::File(FileName file, bool readProperties, Mod::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file),
Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
d(new FilePrivate(propertiesStyle))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
Mod::File::File(IOStream *stream, bool readProperties, Mod::File::File(IOStream *stream, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream),
Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
d(new FilePrivate(propertiesStyle))
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
Mod::File::~File() Mod::File::~File() {
{
delete d; delete d;
} }
Mod::Tag *Mod::File::tag() const Mod::Tag *Mod::File::tag() const {
{
return &d->tag; return &d->tag;
} }
Mod::Properties *Mod::File::audioProperties() const Mod::Properties *Mod::File::audioProperties() const {
{
return &d->properties; return &d->properties;
} }
PropertyMap Mod::File::properties() const PropertyMap Mod::File::properties() const {
{
return d->tag.properties(); return d->tag.properties();
} }
PropertyMap Mod::File::setProperties(const PropertyMap &properties) PropertyMap Mod::File::setProperties(const PropertyMap &properties) {
{
return d->tag.setProperties(properties); return d->tag.setProperties(properties);
} }
bool Mod::File::save() bool Mod::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("Mod::File::save() - Cannot save to a read only file."); debug("Mod::File::save() - Cannot save to a read only file.");
return false; return false;
@@ -110,8 +98,7 @@ bool Mod::File::save()
return true; return true;
} }
void Mod::File::read(bool) void Mod::File::read(bool) {
{
if (!isOpen()) if (!isOpen())
return; return;

View File

@@ -38,8 +38,7 @@ namespace TagLib {
namespace Mod { namespace Mod {
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
{
public: public:
/*! /*!
* Constructs a Protracker file from \a file. * Constructs a Protracker file from \a file.
@@ -108,9 +107,9 @@ namespace TagLib {
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace Mod
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,28 +30,23 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace Mod; using namespace Mod;
Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {
{
} }
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {
{
} }
void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) void Mod::FileBase::writeString(const String &s, unsigned long size, char padding) {
{
ByteVector data(s.data(String::Latin1)); ByteVector data(s.data(String::Latin1));
data.resize(size, padding); data.resize(size, padding);
writeBlock(data); writeBlock(data);
} }
bool Mod::FileBase::readString(String &s, unsigned long size) bool Mod::FileBase::readString(String &s, unsigned long size) {
{
ByteVector data(readBlock(size)); ByteVector data(readBlock(size));
if (data.size() < size) return false; if (data.size() < size) return false;
int index = data.find((char)0); int index = data.find((char)0);
if(index > -1) if (index > -1) {
{
data.resize(index); data.resize(index);
} }
data.replace('\xff', ' '); data.replace('\xff', ' ');
@@ -60,42 +55,35 @@ bool Mod::FileBase::readString(String &s, unsigned long size)
return true; return true;
} }
void Mod::FileBase::writeByte(unsigned char _byte) void Mod::FileBase::writeByte(unsigned char _byte) {
{
ByteVector data(1, _byte); ByteVector data(1, _byte);
writeBlock(data); writeBlock(data);
} }
void Mod::FileBase::writeU16L(unsigned short number) void Mod::FileBase::writeU16L(unsigned short number) {
{
writeBlock(ByteVector::fromShort(number, false)); writeBlock(ByteVector::fromShort(number, false));
} }
void Mod::FileBase::writeU32L(unsigned long number) void Mod::FileBase::writeU32L(unsigned long number) {
{
writeBlock(ByteVector::fromUInt(number, false)); writeBlock(ByteVector::fromUInt(number, false));
} }
void Mod::FileBase::writeU16B(unsigned short number) void Mod::FileBase::writeU16B(unsigned short number) {
{
writeBlock(ByteVector::fromShort(number, true)); writeBlock(ByteVector::fromShort(number, true));
} }
void Mod::FileBase::writeU32B(unsigned long number) void Mod::FileBase::writeU32B(unsigned long number) {
{
writeBlock(ByteVector::fromUInt(number, true)); writeBlock(ByteVector::fromUInt(number, true));
} }
bool Mod::FileBase::readByte(unsigned char &_byte) bool Mod::FileBase::readByte(unsigned char &_byte) {
{
ByteVector data(readBlock(1)); ByteVector data(readBlock(1));
if (data.size() < 1) return false; if (data.size() < 1) return false;
_byte = data[0]; _byte = data[0];
return true; return true;
} }
bool Mod::FileBase::readU16L(unsigned short &number) bool Mod::FileBase::readU16L(unsigned short &number) {
{
ByteVector data(readBlock(2)); ByteVector data(readBlock(2));
if (data.size() < 2) return false; if (data.size() < 2) return false;
number = data.toUShort(false); number = data.toUShort(false);
@@ -109,8 +97,7 @@ bool Mod::FileBase::readU32L(unsigned long &number) {
return true; return true;
} }
bool Mod::FileBase::readU16B(unsigned short &number) bool Mod::FileBase::readU16B(unsigned short &number) {
{
ByteVector data(readBlock(2)); ByteVector data(readBlock(2));
if (data.size() < 2) return false; if (data.size() < 2) return false;
number = data.toUShort(true); number = data.toUShort(true);

View File

@@ -39,8 +39,7 @@ namespace TagLib {
namespace Mod { namespace Mod {
class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
{
protected: protected:
FileBase(FileName file); FileBase(FileName file);
FileBase(IOStream *stream); FileBase(IOStream *stream);
@@ -60,9 +59,9 @@ namespace TagLib {
bool readU32B(unsigned long &number); bool readU32B(unsigned long &number);
}; };
} } // namespace Mod
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -24,8 +24,7 @@
// some helper-macros only used internally by (s3m|it|xm)file.cpp // some helper-macros only used internally by (s3m|it|xm)file.cpp
#define READ_ASSERT(cond) \ #define READ_ASSERT(cond) \
if(!(cond)) \ if (!(cond)) { \
{ \
setValid(false); \ setValid(false); \
return; \ return; \
} }

View File

@@ -29,14 +29,11 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace Mod; using namespace Mod;
class Mod::Properties::PropertiesPrivate class Mod::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : channels(0),
channels(0),
instrumentCount(0), instrumentCount(0),
lengthInPatterns(0) lengthInPatterns(0) {
{
} }
int channels; int channels;
@@ -44,68 +41,54 @@ public:
unsigned char lengthInPatterns; unsigned char lengthInPatterns;
}; };
Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle),
AudioProperties(propertiesStyle), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
} }
Mod::Properties::~Properties() Mod::Properties::~Properties() {
{
delete d; delete d;
} }
int Mod::Properties::length() const int Mod::Properties::length() const {
{
return 0; return 0;
} }
int Mod::Properties::lengthInSeconds() const int Mod::Properties::lengthInSeconds() const {
{
return 0; return 0;
} }
int Mod::Properties::lengthInMilliseconds() const int Mod::Properties::lengthInMilliseconds() const {
{
return 0; return 0;
} }
int Mod::Properties::bitrate() const int Mod::Properties::bitrate() const {
{
return 0; return 0;
} }
int Mod::Properties::sampleRate() const int Mod::Properties::sampleRate() const {
{
return 0; return 0;
} }
int Mod::Properties::channels() const int Mod::Properties::channels() const {
{
return d->channels; return d->channels;
} }
unsigned int Mod::Properties::instrumentCount() const unsigned int Mod::Properties::instrumentCount() const {
{
return d->instrumentCount; return d->instrumentCount;
} }
unsigned char Mod::Properties::lengthInPatterns() const unsigned char Mod::Properties::lengthInPatterns() const {
{
return d->lengthInPatterns; return d->lengthInPatterns;
} }
void Mod::Properties::setChannels(int channels) void Mod::Properties::setChannels(int channels) {
{
d->channels = channels; d->channels = channels;
} }
void Mod::Properties::setInstrumentCount(unsigned int instrumentCount) void Mod::Properties::setInstrumentCount(unsigned int instrumentCount) {
{
d->instrumentCount = instrumentCount; d->instrumentCount = instrumentCount;
} }
void Mod::Properties::setLengthInPatterns(unsigned char lengthInPatterns) void Mod::Properties::setLengthInPatterns(unsigned char lengthInPatterns) {
{
d->lengthInPatterns = lengthInPatterns; d->lengthInPatterns = lengthInPatterns;
} }

View File

@@ -34,8 +34,7 @@ namespace TagLib {
namespace Mod { namespace Mod {
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
Properties(AudioProperties::ReadStyle propertiesStyle); Properties(AudioProperties::ReadStyle propertiesStyle);
virtual ~Properties(); virtual ~Properties();
@@ -65,9 +64,9 @@ namespace TagLib {
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace Mod
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,11 +31,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace Mod; using namespace Mod;
class Mod::Tag::TagPrivate class Mod::Tag::TagPrivate {
{
public: public:
TagPrivate() TagPrivate() {
{
} }
String title; String title;
@@ -43,94 +41,74 @@ public:
String trackerName; String trackerName;
}; };
Mod::Tag::Tag() : Mod::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(),
Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {
d(new TagPrivate())
{
} }
Mod::Tag::~Tag() Mod::Tag::~Tag() {
{
delete d; delete d;
} }
String Mod::Tag::title() const String Mod::Tag::title() const {
{
return d->title; return d->title;
} }
String Mod::Tag::artist() const String Mod::Tag::artist() const {
{
return String(); return String();
} }
String Mod::Tag::album() const String Mod::Tag::album() const {
{
return String(); return String();
} }
String Mod::Tag::comment() const String Mod::Tag::comment() const {
{
return d->comment; return d->comment;
} }
String Mod::Tag::genre() const String Mod::Tag::genre() const {
{
return String(); return String();
} }
unsigned int Mod::Tag::year() const unsigned int Mod::Tag::year() const {
{
return 0; return 0;
} }
unsigned int Mod::Tag::track() const unsigned int Mod::Tag::track() const {
{
return 0; return 0;
} }
String Mod::Tag::trackerName() const String Mod::Tag::trackerName() const {
{
return d->trackerName; return d->trackerName;
} }
void Mod::Tag::setTitle(const String &title) void Mod::Tag::setTitle(const String &title) {
{
d->title = title; d->title = title;
} }
void Mod::Tag::setArtist(const String &) void Mod::Tag::setArtist(const String &) {
{
} }
void Mod::Tag::setAlbum(const String &) void Mod::Tag::setAlbum(const String &) {
{
} }
void Mod::Tag::setComment(const String &comment) void Mod::Tag::setComment(const String &comment) {
{
d->comment = comment; d->comment = comment;
} }
void Mod::Tag::setGenre(const String &) void Mod::Tag::setGenre(const String &) {
{
} }
void Mod::Tag::setYear(unsigned int) void Mod::Tag::setYear(unsigned int) {
{
} }
void Mod::Tag::setTrack(unsigned int) void Mod::Tag::setTrack(unsigned int) {
{
} }
void Mod::Tag::setTrackerName(const String &trackerName) void Mod::Tag::setTrackerName(const String &trackerName) {
{
d->trackerName = trackerName; d->trackerName = trackerName;
} }
PropertyMap Mod::Tag::properties() const PropertyMap Mod::Tag::properties() const {
{
PropertyMap properties; PropertyMap properties;
properties["TITLE"] = d->title; properties["TITLE"] = d->title;
properties["COMMENT"] = d->comment; properties["COMMENT"] = d->comment;
@@ -139,27 +117,29 @@ PropertyMap Mod::Tag::properties() const
return properties; return properties;
} }
PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) {
{
PropertyMap properties(origProps); PropertyMap properties(origProps);
properties.removeEmpty(); properties.removeEmpty();
StringList oneValueSet; StringList oneValueSet;
if (properties.contains("TITLE")) { if (properties.contains("TITLE")) {
d->title = properties["TITLE"].front(); d->title = properties["TITLE"].front();
oneValueSet.append("TITLE"); oneValueSet.append("TITLE");
} else }
else
d->title.clear(); d->title.clear();
if (properties.contains("COMMENT")) { if (properties.contains("COMMENT")) {
d->comment = properties["COMMENT"].front(); d->comment = properties["COMMENT"].front();
oneValueSet.append("COMMENT"); oneValueSet.append("COMMENT");
} else }
else
d->comment.clear(); d->comment.clear();
if (properties.contains("TRACKERNAME")) { if (properties.contains("TRACKERNAME")) {
d->trackerName = properties["TRACKERNAME"].front(); d->trackerName = properties["TRACKERNAME"].front();
oneValueSet.append("TRACKERNAME"); oneValueSet.append("TRACKERNAME");
} else }
else
d->trackerName.clear(); d->trackerName.clear();
// for each tag that has been set above, remove the first entry in the corresponding // for each tag that has been set above, remove the first entry in the corresponding

View File

@@ -45,8 +45,7 @@ namespace TagLib {
* but it is common practice to abuse instrument/sample/pattern * but it is common practice to abuse instrument/sample/pattern
* names as multiline comments. TagLib does so as well. * names as multiline comments. TagLib does so as well.
*/ */
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
{
public: public:
Tag(); Tag();
virtual ~Tag(); virtual ~Tag();
@@ -188,9 +187,9 @@ namespace TagLib {
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace Mod
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -37,8 +37,7 @@ const char *MP4::Atom::containers[11] = {
"stsd" "stsd"
}; };
MP4::Atom::Atom(File *file) MP4::Atom::Atom(File *file) {
{
children.setAutoDelete(true); children.setAutoDelete(true);
offset = file->tell(); offset = file->tell();
@@ -103,13 +102,11 @@ MP4::Atom::Atom(File *file)
file->seek(offset + length); file->seek(offset + length);
} }
MP4::Atom::~Atom() MP4::Atom::~Atom() {
{
} }
MP4::Atom * MP4::Atom *
MP4::Atom::find(const char *name1, const char *name2, const char *name3, const char *name4) MP4::Atom::find(const char *name1, const char *name2, const char *name3, const char *name4) {
{
if (name1 == 0) { if (name1 == 0) {
return this; return this;
} }
@@ -122,8 +119,7 @@ MP4::Atom::find(const char *name1, const char *name2, const char *name3, const c
} }
MP4::AtomList MP4::AtomList
MP4::Atom::findall(const char *_name, bool recursive) MP4::Atom::findall(const char *_name, bool recursive) {
{
MP4::AtomList result; MP4::AtomList result;
for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) { for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->name == _name) { if ((*it)->name == _name) {
@@ -136,9 +132,7 @@ MP4::Atom::findall(const char *_name, bool recursive)
return result; return result;
} }
bool bool MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const char *name3) {
MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const char *name3)
{
path.append(this); path.append(this);
if (name1 == 0) { if (name1 == 0) {
return true; return true;
@@ -151,8 +145,7 @@ MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const
return false; return false;
} }
MP4::Atoms::Atoms(File *file) MP4::Atoms::Atoms(File *file) {
{
atoms.setAutoDelete(true); atoms.setAutoDelete(true);
file->seek(0, File::End); file->seek(0, File::End);
@@ -166,13 +159,11 @@ MP4::Atoms::Atoms(File *file)
} }
} }
MP4::Atoms::~Atoms() MP4::Atoms::~Atoms() {
{
} }
MP4::Atom * MP4::Atom *
MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) {
{
for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) {
if ((*it)->name == name1) { if ((*it)->name == name1) {
return (*it)->find(name2, name3, name4); return (*it)->find(name2, name3, name4);
@@ -182,8 +173,7 @@ MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const
} }
MP4::AtomList MP4::AtomList
MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) {
{
MP4::AtomList path; MP4::AtomList path;
for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) { for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) {
if ((*it)->name == name1) { if ((*it)->name == name1) {

View File

@@ -41,8 +41,7 @@ namespace TagLib {
class Atom; class Atom;
typedef Strawberry_TagLib::TagLib::List<Atom *> AtomList; typedef Strawberry_TagLib::TagLib::List<Atom *> AtomList;
enum AtomDataType enum AtomDataType {
{
TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed
TypeUTF8 = 1, // without any count or null terminator TypeUTF8 = 1, // without any count or null terminator
TypeUTF16 = 2, // also known as UTF-16BE TypeUTF16 = 2, // also known as UTF-16BE
@@ -75,8 +74,7 @@ namespace TagLib {
typedef Strawberry_TagLib::TagLib::List<AtomData> AtomDataList; typedef Strawberry_TagLib::TagLib::List<AtomData> AtomDataList;
class Atom class Atom {
{
public: public:
Atom(File *file); Atom(File *file);
~Atom(); ~Atom();
@@ -87,14 +85,14 @@ namespace TagLib {
long length; long length;
Strawberry_TagLib::TagLib::ByteVector name; Strawberry_TagLib::TagLib::ByteVector name;
AtomList children; AtomList children;
private: private:
static const int numContainers = 11; static const int numContainers = 11;
static const char *containers[11]; static const char *containers[11];
}; };
//! Root-level atoms //! Root-level atoms
class Atoms class Atoms {
{
public: public:
Atoms(File *file); Atoms(File *file);
~Atoms(); ~Atoms();
@@ -103,10 +101,10 @@ namespace TagLib {
AtomList atoms; AtomList atoms;
}; };
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
# endif # endif

View File

@@ -30,11 +30,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class MP4::CoverArt::CoverArtPrivate : public RefCounter class MP4::CoverArt::CoverArtPrivate : public RefCounter {
{
public: public:
CoverArtPrivate() : CoverArtPrivate() : RefCounter(),
RefCounter(),
format(MP4::CoverArt::JPEG) {} format(MP4::CoverArt::JPEG) {}
Format format; Format format;
@@ -45,49 +43,39 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : d(new CoverArtPrivate()) {
d(new CoverArtPrivate())
{
d->format = format; d->format = format;
d->data = data; d->data = data;
} }
MP4::CoverArt::CoverArt(const CoverArt &item) : MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d) {
d(item.d)
{
d->ref(); d->ref();
} }
MP4::CoverArt & MP4::CoverArt &
MP4::CoverArt::operator=(const CoverArt &item) MP4::CoverArt::operator=(const CoverArt &item) {
{
CoverArt(item).swap(*this); CoverArt(item).swap(*this);
return *this; return *this;
} }
void void MP4::CoverArt::swap(CoverArt &item) {
MP4::CoverArt::swap(CoverArt &item)
{
using std::swap; using std::swap;
swap(d, item.d); swap(d, item.d);
} }
MP4::CoverArt::~CoverArt() MP4::CoverArt::~CoverArt() {
{
if (d->deref()) { if (d->deref()) {
delete d; delete d;
} }
} }
MP4::CoverArt::Format MP4::CoverArt::Format
MP4::CoverArt::format() const MP4::CoverArt::format() const {
{
return d->format; return d->format;
} }
ByteVector ByteVector
MP4::CoverArt::data() const MP4::CoverArt::data() const {
{
return d->data; return d->data;
} }

View File

@@ -36,8 +36,7 @@ namespace TagLib {
namespace MP4 { namespace MP4 {
class TAGLIB_EXPORT CoverArt class TAGLIB_EXPORT CoverArt {
{
public: public:
/*! /*!
* This describes the image type. * This describes the image type.
@@ -78,9 +77,9 @@ namespace TagLib {
typedef List<CoverArt> CoverArtList; typedef List<CoverArt> CoverArtList;
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -34,10 +34,8 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{ bool checkValid(const MP4::AtomList &list) {
bool checkValid(const MP4::AtomList &list)
{
for (MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) { for (MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) {
if ((*it)->length == 0) if ((*it)->length == 0)
@@ -49,18 +47,15 @@ namespace
return true; return true;
} }
} } // namespace
class MP4::File::FilePrivate class MP4::File::FilePrivate {
{
public: public:
FilePrivate() : FilePrivate() : tag(0),
tag(0),
atoms(0), atoms(0),
properties(0) {} properties(0) {}
~FilePrivate() ~FilePrivate() {
{
delete atoms; delete atoms;
delete tag; delete tag;
delete properties; delete properties;
@@ -75,8 +70,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool MP4::File::isSupported(IOStream *stream) bool MP4::File::isSupported(IOStream *stream) {
{
// An MP4 file has to have an "ftyp" box first. // An MP4 file has to have an "ftyp" box first.
const ByteVector id = Utils::readHeader(stream, 8, false); const ByteVector id = Utils::readHeader(stream, 8, false);
@@ -87,57 +81,45 @@ bool MP4::File::isSupported(IOStream *stream)
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
MP4::File::~File() MP4::File::~File() {
{
delete d; delete d;
} }
MP4::Tag * MP4::Tag *
MP4::File::tag() const MP4::File::tag() const {
{
return d->tag; return d->tag;
} }
PropertyMap MP4::File::properties() const PropertyMap MP4::File::properties() const {
{
return d->tag->properties(); return d->tag->properties();
} }
void MP4::File::removeUnsupportedProperties(const StringList &properties) void MP4::File::removeUnsupportedProperties(const StringList &properties) {
{
d->tag->removeUnsupportedProperties(properties); d->tag->removeUnsupportedProperties(properties);
} }
PropertyMap MP4::File::setProperties(const PropertyMap &properties) PropertyMap MP4::File::setProperties(const PropertyMap &properties) {
{
return d->tag->setProperties(properties); return d->tag->setProperties(properties);
} }
MP4::Properties * MP4::Properties *
MP4::File::audioProperties() const MP4::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
void void MP4::File::read(bool readProperties) {
MP4::File::read(bool readProperties)
{
if (!isValid()) if (!isValid())
return; return;
@@ -159,9 +141,7 @@ MP4::File::read(bool readProperties)
} }
} }
bool bool MP4::File::save() {
MP4::File::save()
{
if (readOnly()) { if (readOnly()) {
debug("MP4::File::save() -- File is read only."); debug("MP4::File::save() -- File is read only.");
return false; return false;
@@ -175,8 +155,6 @@ MP4::File::save()
return d->tag->save(); return d->tag->save();
} }
bool bool MP4::File::hasMP4Tag() const {
MP4::File::hasMP4Tag() const
{
return (d->atoms->find("moov", "udta", "meta", "ilst") != 0); return (d->atoms->find("moov", "udta", "meta", "ilst") != 0);
} }

View File

@@ -46,8 +46,7 @@ namespace TagLib {
* the abstract TagLib::File API as well as providing some additional * the abstract TagLib::File API as well as providing some additional
* information specific to MP4 files. * information specific to MP4 files.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* Constructs an MP4 file from \a file. If \a readProperties is true the * Constructs an MP4 file from \a file. If \a readProperties is true the
@@ -137,9 +136,9 @@ namespace TagLib {
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,11 +30,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class MP4::Item::ItemPrivate : public RefCounter class MP4::Item::ItemPrivate : public RefCounter {
{
public: public:
ItemPrivate() : ItemPrivate() : RefCounter(),
RefCounter(),
valid(true), valid(true),
atomDataType(TypeUndefined) {} atomDataType(TypeUndefined) {}
@@ -53,160 +51,119 @@ public:
MP4::CoverArtList m_coverArtList; MP4::CoverArtList m_coverArtList;
}; };
MP4::Item::Item() : MP4::Item::Item() : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->valid = false; d->valid = false;
} }
MP4::Item::Item(const Item &item) : MP4::Item::Item(const Item &item) : d(item.d) {
d(item.d)
{
d->ref(); d->ref();
} }
MP4::Item & MP4::Item &
MP4::Item::operator=(const Item &item) MP4::Item::operator=(const Item &item) {
{
Item(item).swap(*this); Item(item).swap(*this);
return *this; return *this;
} }
void void MP4::Item::swap(Item &item) {
MP4::Item::swap(Item &item)
{
using std::swap; using std::swap;
swap(d, item.d); swap(d, item.d);
} }
MP4::Item::~Item() MP4::Item::~Item() {
{
if (d->deref()) if (d->deref())
delete d; delete d;
} }
MP4::Item::Item(bool value) : MP4::Item::Item(bool value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_bool = value; d->m_bool = value;
} }
MP4::Item::Item(int value) : MP4::Item::Item(int value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_int = value; d->m_int = value;
} }
MP4::Item::Item(unsigned char value) : MP4::Item::Item(unsigned char value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_byte = value; d->m_byte = value;
} }
MP4::Item::Item(unsigned int value) : MP4::Item::Item(unsigned int value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_uint = value; d->m_uint = value;
} }
MP4::Item::Item(long long value) : MP4::Item::Item(long long value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_longlong = value; d->m_longlong = value;
} }
MP4::Item::Item(int value1, int value2) : MP4::Item::Item(int value1, int value2) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_intPair.first = value1; d->m_intPair.first = value1;
d->m_intPair.second = value2; d->m_intPair.second = value2;
} }
MP4::Item::Item(const ByteVectorList &value) : MP4::Item::Item(const ByteVectorList &value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_byteVectorList = value; d->m_byteVectorList = value;
} }
MP4::Item::Item(const StringList &value) : MP4::Item::Item(const StringList &value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_stringList = value; d->m_stringList = value;
} }
MP4::Item::Item(const MP4::CoverArtList &value) : MP4::Item::Item(const MP4::CoverArtList &value) : d(new ItemPrivate()) {
d(new ItemPrivate())
{
d->m_coverArtList = value; d->m_coverArtList = value;
} }
void MP4::Item::setAtomDataType(MP4::AtomDataType type) void MP4::Item::setAtomDataType(MP4::AtomDataType type) {
{
d->atomDataType = type; d->atomDataType = type;
} }
MP4::AtomDataType MP4::Item::atomDataType() const MP4::AtomDataType MP4::Item::atomDataType() const {
{
return d->atomDataType; return d->atomDataType;
} }
bool bool MP4::Item::toBool() const {
MP4::Item::toBool() const
{
return d->m_bool; return d->m_bool;
} }
int int MP4::Item::toInt() const {
MP4::Item::toInt() const
{
return d->m_int; return d->m_int;
} }
unsigned char unsigned char
MP4::Item::toByte() const MP4::Item::toByte() const {
{
return d->m_byte; return d->m_byte;
} }
unsigned int unsigned int
MP4::Item::toUInt() const MP4::Item::toUInt() const {
{
return d->m_uint; return d->m_uint;
} }
long long long long
MP4::Item::toLongLong() const MP4::Item::toLongLong() const {
{
return d->m_longlong; return d->m_longlong;
} }
MP4::Item::IntPair MP4::Item::IntPair
MP4::Item::toIntPair() const MP4::Item::toIntPair() const {
{
return d->m_intPair; return d->m_intPair;
} }
StringList StringList
MP4::Item::toStringList() const MP4::Item::toStringList() const {
{
return d->m_stringList; return d->m_stringList;
} }
ByteVectorList ByteVectorList
MP4::Item::toByteVectorList() const MP4::Item::toByteVectorList() const {
{
return d->m_byteVectorList; return d->m_byteVectorList;
} }
MP4::CoverArtList MP4::CoverArtList
MP4::Item::toCoverArtList() const MP4::Item::toCoverArtList() const {
{
return d->m_coverArtList; return d->m_coverArtList;
} }
bool bool MP4::Item::isValid() const {
MP4::Item::isValid() const
{
return d->valid; return d->valid;
} }

View File

@@ -35,8 +35,7 @@ namespace TagLib {
namespace MP4 { namespace MP4 {
class TAGLIB_EXPORT Item class TAGLIB_EXPORT Item {
{
public: public:
struct IntPair { struct IntPair {
int first, second; int first, second;
@@ -87,9 +86,9 @@ namespace TagLib {
ItemPrivate *d; ItemPrivate *d;
}; };
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,11 +31,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class MP4::Properties::PropertiesPrivate class MP4::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : length(0),
length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
channels(0), channels(0),
@@ -56,69 +54,49 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style) : MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
read(file, atoms); read(file, atoms);
} }
MP4::Properties::~Properties() MP4::Properties::~Properties() {
{
delete d; delete d;
} }
int int MP4::Properties::channels() const {
MP4::Properties::channels() const
{
return d->channels; return d->channels;
} }
int int MP4::Properties::sampleRate() const {
MP4::Properties::sampleRate() const
{
return d->sampleRate; return d->sampleRate;
} }
int int MP4::Properties::length() const {
MP4::Properties::length() const
{
return lengthInSeconds(); return lengthInSeconds();
} }
int int MP4::Properties::lengthInSeconds() const {
MP4::Properties::lengthInSeconds() const
{
return d->length / 1000; return d->length / 1000;
} }
int int MP4::Properties::lengthInMilliseconds() const {
MP4::Properties::lengthInMilliseconds() const
{
return d->length; return d->length;
} }
int int MP4::Properties::bitrate() const {
MP4::Properties::bitrate() const
{
return d->bitrate; return d->bitrate;
} }
int int MP4::Properties::bitsPerSample() const {
MP4::Properties::bitsPerSample() const
{
return d->bitsPerSample; return d->bitsPerSample;
} }
bool bool MP4::Properties::isEncrypted() const {
MP4::Properties::isEncrypted() const
{
return d->encrypted; return d->encrypted;
} }
MP4::Properties::Codec MP4::Properties::Codec
MP4::Properties::codec() const MP4::Properties::codec() const {
{
return d->codec; return d->codec;
} }
@@ -126,9 +104,7 @@ MP4::Properties::codec() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void void MP4::Properties::read(File *file, Atoms *atoms) {
MP4::Properties::read(File *file, Atoms *atoms)
{
MP4::Atom *moov = atoms->find("moov"); MP4::Atom *moov = atoms->find("moov");
if (!moov) { if (!moov) {
debug("MP4: Atom 'moov' not found"); debug("MP4: Atom 'moov' not found");

View File

@@ -38,8 +38,7 @@ namespace TagLib {
class File; class File;
//! An implementation of MP4 audio properties //! An implementation of MP4 audio properties
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
enum Codec { enum Codec {
Unknown = 0, Unknown = 0,
@@ -114,9 +113,9 @@ namespace TagLib {
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -32,11 +32,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class MP4::Tag::TagPrivate class MP4::Tag::TagPrivate {
{
public: public:
TagPrivate() : TagPrivate() : file(0),
file(0),
atoms(0) {} atoms(0) {}
Strawberry_TagLib::TagLib::File *file; Strawberry_TagLib::TagLib::File *file;
@@ -44,14 +42,10 @@ public:
ItemMap items; ItemMap items;
}; };
MP4::Tag::Tag() : MP4::Tag::Tag() : d(new TagPrivate()) {
d(new TagPrivate())
{
} }
MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) : d(new TagPrivate()) {
d(new TagPrivate())
{
d->file = file; d->file = file;
d->atoms = atoms; d->atoms = atoms;
@@ -83,7 +77,8 @@ MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) :
AtomData val = data[0]; AtomData val = data[0];
if (val.type == TypeUTF8) { if (val.type == TypeUTF8) {
addItem(atom->name, StringList(String(val.data, String::UTF8))); addItem(atom->name, StringList(String(val.data, String::UTF8)));
} else { }
else {
addItem(atom->name, (int)(val.data.toShort())); addItem(atom->name, (int)(val.data.toShort()));
} }
} }
@@ -114,14 +109,12 @@ MP4::Tag::Tag(Strawberry_TagLib::TagLib::File *file, MP4::Atoms *atoms) :
} }
} }
MP4::Tag::~Tag() MP4::Tag::~Tag() {
{
delete d; delete d;
} }
MP4::AtomDataList MP4::AtomDataList
MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) {
{
AtomDataList result; AtomDataList result;
ByteVector data = d->file->readBlock(atom->length - 8); ByteVector data = d->file->readBlock(atom->length - 8);
int i = 0; int i = 0;
@@ -162,8 +155,7 @@ MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm)
} }
ByteVectorList ByteVectorList
MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm) MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm) {
{
AtomDataList data = parseData2(atom, expectedFlags, freeForm); AtomDataList data = parseData2(atom, expectedFlags, freeForm);
ByteVectorList result; ByteVectorList result;
for (AtomDataList::ConstIterator it = data.begin(); it != data.end(); ++it) { for (AtomDataList::ConstIterator it = data.begin(); it != data.end(); ++it) {
@@ -172,45 +164,35 @@ MP4::Tag::parseData(const MP4::Atom *atom, int expectedFlags, bool freeForm)
return result; return result;
} }
void void MP4::Tag::parseInt(const MP4::Atom *atom) {
MP4::Tag::parseInt(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
addItem(atom->name, (int)data[0].toShort()); addItem(atom->name, (int)data[0].toShort());
} }
} }
void void MP4::Tag::parseUInt(const MP4::Atom *atom) {
MP4::Tag::parseUInt(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
addItem(atom->name, data[0].toUInt()); addItem(atom->name, data[0].toUInt());
} }
} }
void void MP4::Tag::parseLongLong(const MP4::Atom *atom) {
MP4::Tag::parseLongLong(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
addItem(atom->name, data[0].toLongLong()); addItem(atom->name, data[0].toLongLong());
} }
} }
void void MP4::Tag::parseByte(const MP4::Atom *atom) {
MP4::Tag::parseByte(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
addItem(atom->name, static_cast<unsigned char>(data[0].at(0))); addItem(atom->name, static_cast<unsigned char>(data[0].at(0)));
} }
} }
void void MP4::Tag::parseGnre(const MP4::Atom *atom) {
MP4::Tag::parseGnre(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
int idx = (int)data[0].toShort(); int idx = (int)data[0].toShort();
@@ -220,9 +202,7 @@ MP4::Tag::parseGnre(const MP4::Atom *atom)
} }
} }
void void MP4::Tag::parseIntPair(const MP4::Atom *atom) {
MP4::Tag::parseIntPair(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
const int a = data[0].toShort(2U); const int a = data[0].toShort(2U);
@@ -231,9 +211,7 @@ MP4::Tag::parseIntPair(const MP4::Atom *atom)
} }
} }
void void MP4::Tag::parseBool(const MP4::Atom *atom) {
MP4::Tag::parseBool(const MP4::Atom *atom)
{
ByteVectorList data = parseData(atom); ByteVectorList data = parseData(atom);
if (!data.isEmpty()) { if (!data.isEmpty()) {
bool value = data[0].size() ? data[0][0] != '\0' : false; bool value = data[0].size() ? data[0][0] != '\0' : false;
@@ -241,9 +219,7 @@ MP4::Tag::parseBool(const MP4::Atom *atom)
} }
} }
void void MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) {
MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags)
{
ByteVectorList data = parseData(atom, expectedFlags); ByteVectorList data = parseData(atom, expectedFlags);
if (!data.isEmpty()) { if (!data.isEmpty()) {
StringList value; StringList value;
@@ -254,9 +230,7 @@ MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags)
} }
} }
void void MP4::Tag::parseFreeForm(const MP4::Atom *atom) {
MP4::Tag::parseFreeForm(const MP4::Atom *atom)
{
AtomDataList data = parseData2(atom, -1, true); AtomDataList data = parseData2(atom, -1, true);
if (data.size() > 2) { if (data.size() > 2) {
AtomDataList::ConstIterator itBegin = data.begin(); AtomDataList::ConstIterator itBegin = data.begin();
@@ -295,9 +269,7 @@ MP4::Tag::parseFreeForm(const MP4::Atom *atom)
} }
} }
void void MP4::Tag::parseCovr(const MP4::Atom *atom) {
MP4::Tag::parseCovr(const MP4::Atom *atom)
{
MP4::CoverArtList value; MP4::CoverArtList value;
ByteVector data = d->file->readBlock(atom->length - 8); ByteVector data = d->file->readBlock(atom->length - 8);
unsigned int pos = 0; unsigned int pos = 0;
@@ -305,7 +277,8 @@ MP4::Tag::parseCovr(const MP4::Atom *atom)
const int length = static_cast<int>(data.toUInt(pos)); const int length = static_cast<int>(data.toUInt(pos));
if (length < 12) { if (length < 12) {
debug("MP4: Too short atom"); debug("MP4: Too short atom");
break;; break;
;
} }
const ByteVector name = data.mid(pos + 4, 4); const ByteVector name = data.mid(pos + 4, 4);
@@ -329,8 +302,7 @@ MP4::Tag::parseCovr(const MP4::Atom *atom)
} }
ByteVector ByteVector
MP4::Tag::padIlst(const ByteVector &data, int length) const MP4::Tag::padIlst(const ByteVector &data, int length) const {
{
if (length == -1) { if (length == -1) {
length = ((data.size() + 1023) & ~1023) - data.size(); length = ((data.size() + 1023) & ~1023) - data.size();
} }
@@ -338,14 +310,12 @@ MP4::Tag::padIlst(const ByteVector &data, int length) const
} }
ByteVector ByteVector
MP4::Tag::renderAtom(const ByteVector &name, const ByteVector &data) const MP4::Tag::renderAtom(const ByteVector &name, const ByteVector &data) const {
{
return ByteVector::fromUInt(data.size() + 8) + name + data; return ByteVector::fromUInt(data.size() + 8) + name + data;
} }
ByteVector ByteVector
MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &data) const {
{
ByteVector result; ByteVector result;
for (ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { for (ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) {
result.append(renderAtom("data", ByteVector::fromUInt(flags) + ByteVector(4, '\0') + *it)); result.append(renderAtom("data", ByteVector::fromUInt(flags) + ByteVector(4, '\0') + *it));
@@ -354,48 +324,42 @@ MP4::Tag::renderData(const ByteVector &name, int flags, const ByteVectorList &da
} }
ByteVector ByteVector
MP4::Tag::renderBool(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderBool(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector(1, item.toBool() ? '\1' : '\0')); data.append(ByteVector(1, item.toBool() ? '\1' : '\0'));
return renderData(name, TypeInteger, data); return renderData(name, TypeInteger, data);
} }
ByteVector ByteVector
MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderInt(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector::fromShort(item.toInt())); data.append(ByteVector::fromShort(item.toInt()));
return renderData(name, TypeInteger, data); return renderData(name, TypeInteger, data);
} }
ByteVector ByteVector
MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderUInt(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector::fromUInt(item.toUInt())); data.append(ByteVector::fromUInt(item.toUInt()));
return renderData(name, TypeInteger, data); return renderData(name, TypeInteger, data);
} }
ByteVector ByteVector
MP4::Tag::renderLongLong(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderLongLong(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector::fromLongLong(item.toLongLong())); data.append(ByteVector::fromLongLong(item.toLongLong()));
return renderData(name, TypeInteger, data); return renderData(name, TypeInteger, data);
} }
ByteVector ByteVector
MP4::Tag::renderByte(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderByte(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector(1, item.toByte())); data.append(ByteVector(1, item.toByte()));
return renderData(name, TypeInteger, data); return renderData(name, TypeInteger, data);
} }
ByteVector ByteVector
MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector(2, '\0') + data.append(ByteVector(2, '\0') +
ByteVector::fromShort(item.toIntPair().first) + ByteVector::fromShort(item.toIntPair().first) +
@@ -405,8 +369,7 @@ MP4::Tag::renderIntPair(const ByteVector &name, const MP4::Item &item) const
} }
ByteVector ByteVector
MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item) const {
{
ByteVectorList data; ByteVectorList data;
data.append(ByteVector(2, '\0') + data.append(ByteVector(2, '\0') +
ByteVector::fromShort(item.toIntPair().first) + ByteVector::fromShort(item.toIntPair().first) +
@@ -415,8 +378,7 @@ MP4::Tag::renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item)
} }
ByteVector ByteVector
MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) const MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) const {
{
ByteVectorList data; ByteVectorList data;
StringList value = item.toStringList(); StringList value = item.toStringList();
for (StringList::ConstIterator it = value.begin(); it != value.end(); ++it) { for (StringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
@@ -426,20 +388,17 @@ MP4::Tag::renderText(const ByteVector &name, const MP4::Item &item, int flags) c
} }
ByteVector ByteVector
MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const MP4::Tag::renderCovr(const ByteVector &name, const MP4::Item &item) const {
{
ByteVector data; ByteVector data;
MP4::CoverArtList value = item.toCoverArtList(); MP4::CoverArtList value = item.toCoverArtList();
for (MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) { for (MP4::CoverArtList::ConstIterator it = value.begin(); it != value.end(); ++it) {
data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + data.append(renderAtom("data", ByteVector::fromUInt(it->format()) + ByteVector(4, '\0') + it->data()));
ByteVector(4, '\0') + it->data()));
} }
return renderAtom(name, data); return renderAtom(name, data);
} }
ByteVector ByteVector
MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const {
{
StringList header = StringList::split(name, ":"); StringList header = StringList::split(name, ":");
if (header.size() != 3) { if (header.size() != 3) {
debug("MP4: Invalid free-form item name \"" + name + "\""); debug("MP4: Invalid free-form item name \"" + name + "\"");
@@ -472,9 +431,7 @@ MP4::Tag::renderFreeForm(const String &name, const MP4::Item &item) const
return renderAtom("----", data); return renderAtom("----", data);
} }
bool bool MP4::Tag::save() {
MP4::Tag::save()
{
ByteVector data; ByteVector data;
for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) {
const String name = it->first; const String name = it->first;
@@ -541,9 +498,7 @@ MP4::Tag::save()
return true; return true;
} }
void void MP4::Tag::updateParents(const AtomList &path, long delta, int ignore) {
MP4::Tag::updateParents(const AtomList &path, long delta, int ignore)
{
if (static_cast<int>(path.size()) <= ignore) if (static_cast<int>(path.size()) <= ignore)
return; return;
@@ -569,9 +524,7 @@ MP4::Tag::updateParents(const AtomList &path, long delta, int ignore)
} }
} }
void void MP4::Tag::updateOffsets(long delta, long offset) {
MP4::Tag::updateOffsets(long delta, long offset)
{
MP4::Atom *moov = d->atoms->find("moov"); MP4::Atom *moov = d->atoms->find("moov");
if (moov) { if (moov) {
MP4::AtomList stco = moov->findall("stco", true); MP4::AtomList stco = moov->findall("stco", true);
@@ -640,13 +593,8 @@ MP4::Tag::updateOffsets(long delta, long offset)
} }
} }
void void MP4::Tag::saveNew(ByteVector data) {
MP4::Tag::saveNew(ByteVector data) data = renderAtom("meta", ByteVector(4, '\0') + renderAtom("hdlr", ByteVector(8, '\0') + ByteVector("mdirappl") + ByteVector(9, '\0')) + data + padIlst(data));
{
data = renderAtom("meta", ByteVector(4, '\0') +
renderAtom("hdlr", ByteVector(8, '\0') + ByteVector("mdirappl") +
ByteVector(9, '\0')) +
data + padIlst(data));
AtomList path = d->atoms->path("moov", "udta"); AtomList path = d->atoms->path("moov", "udta");
if (path.size() != 2) { if (path.size() != 2) {
@@ -666,9 +614,7 @@ MP4::Tag::saveNew(ByteVector data)
path.back()->children.prepend(new Atom(d->file)); path.back()->children.prepend(new Atom(d->file));
} }
void void MP4::Tag::saveExisting(ByteVector data, const AtomList &path) {
MP4::Tag::saveExisting(ByteVector data, const AtomList &path)
{
AtomList::ConstIterator it = path.end(); AtomList::ConstIterator it = path.end();
MP4::Atom *ilst = *(--it); MP4::Atom *ilst = *(--it);
@@ -717,94 +663,75 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path)
} }
String String
MP4::Tag::title() const MP4::Tag::title() const {
{
if (d->items.contains("\251nam")) if (d->items.contains("\251nam"))
return d->items["\251nam"].toStringList().toString(", "); return d->items["\251nam"].toStringList().toString(", ");
return String(); return String();
} }
String String
MP4::Tag::artist() const MP4::Tag::artist() const {
{
if (d->items.contains("\251ART")) if (d->items.contains("\251ART"))
return d->items["\251ART"].toStringList().toString(", "); return d->items["\251ART"].toStringList().toString(", ");
return String(); return String();
} }
String String
MP4::Tag::album() const MP4::Tag::album() const {
{
if (d->items.contains("\251alb")) if (d->items.contains("\251alb"))
return d->items["\251alb"].toStringList().toString(", "); return d->items["\251alb"].toStringList().toString(", ");
return String(); return String();
} }
String String
MP4::Tag::comment() const MP4::Tag::comment() const {
{
if (d->items.contains("\251cmt")) if (d->items.contains("\251cmt"))
return d->items["\251cmt"].toStringList().toString(", "); return d->items["\251cmt"].toStringList().toString(", ");
return String(); return String();
} }
String String
MP4::Tag::genre() const MP4::Tag::genre() const {
{
if (d->items.contains("\251gen")) if (d->items.contains("\251gen"))
return d->items["\251gen"].toStringList().toString(", "); return d->items["\251gen"].toStringList().toString(", ");
return String(); return String();
} }
unsigned int unsigned int
MP4::Tag::year() const MP4::Tag::year() const {
{
if (d->items.contains("\251day")) if (d->items.contains("\251day"))
return d->items["\251day"].toStringList().toString().toInt(); return d->items["\251day"].toStringList().toString().toInt();
return 0; return 0;
} }
unsigned int unsigned int
MP4::Tag::track() const MP4::Tag::track() const {
{
if (d->items.contains("trkn")) if (d->items.contains("trkn"))
return d->items["trkn"].toIntPair().first; return d->items["trkn"].toIntPair().first;
return 0; return 0;
} }
void void MP4::Tag::setTitle(const String &value) {
MP4::Tag::setTitle(const String &value)
{
d->items["\251nam"] = StringList(value); d->items["\251nam"] = StringList(value);
} }
void void MP4::Tag::setArtist(const String &value) {
MP4::Tag::setArtist(const String &value)
{
d->items["\251ART"] = StringList(value); d->items["\251ART"] = StringList(value);
} }
void void MP4::Tag::setAlbum(const String &value) {
MP4::Tag::setAlbum(const String &value)
{
d->items["\251alb"] = StringList(value); d->items["\251alb"] = StringList(value);
} }
void void MP4::Tag::setComment(const String &value) {
MP4::Tag::setComment(const String &value)
{
d->items["\251cmt"] = StringList(value); d->items["\251cmt"] = StringList(value);
} }
void void MP4::Tag::setGenre(const String &value) {
MP4::Tag::setGenre(const String &value)
{
d->items["\251gen"] = StringList(value); d->items["\251gen"] = StringList(value);
} }
void void MP4::Tag::setYear(unsigned int value) {
MP4::Tag::setYear(unsigned int value)
{
if (value == 0) { if (value == 0) {
d->items.erase("\251day"); d->items.erase("\251day");
} }
@@ -813,9 +740,7 @@ MP4::Tag::setYear(unsigned int value)
} }
} }
void void MP4::Tag::setTrack(unsigned int value) {
MP4::Tag::setTrack(unsigned int value)
{
if (value == 0) { if (value == 0) {
d->items.erase("trkn"); d->items.erase("trkn");
} }
@@ -824,43 +749,35 @@ MP4::Tag::setTrack(unsigned int value)
} }
} }
bool MP4::Tag::isEmpty() const bool MP4::Tag::isEmpty() const {
{
return d->items.isEmpty(); return d->items.isEmpty();
} }
MP4::ItemMap &MP4::Tag::itemListMap() MP4::ItemMap &MP4::Tag::itemListMap() {
{
return d->items; return d->items;
} }
const MP4::ItemMap &MP4::Tag::itemMap() const const MP4::ItemMap &MP4::Tag::itemMap() const {
{
return d->items; return d->items;
} }
MP4::Item MP4::Tag::item(const String &key) const MP4::Item MP4::Tag::item(const String &key) const {
{
return d->items[key]; return d->items[key];
} }
void MP4::Tag::setItem(const String &key, const Item &value) void MP4::Tag::setItem(const String &key, const Item &value) {
{
d->items[key] = value; d->items[key] = value;
} }
void MP4::Tag::removeItem(const String &key) void MP4::Tag::removeItem(const String &key) {
{
d->items.erase(key); d->items.erase(key);
} }
bool MP4::Tag::contains(const String &key) const bool MP4::Tag::contains(const String &key) const {
{
return d->items.contains(key); return d->items.contains(key);
} }
namespace namespace {
{
const char *keyTranslation[][2] = { const char *keyTranslation[][2] = {
{ "\251nam", "TITLE" }, { "\251nam", "TITLE" },
{ "\251ART", "ARTIST" }, { "\251ART", "ARTIST" },
@@ -917,8 +834,7 @@ namespace
}; };
const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]); const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
String translateKey(const String &key) String translateKey(const String &key) {
{
for (size_t i = 0; i < keyTranslationSize; ++i) { for (size_t i = 0; i < keyTranslationSize; ++i) {
if (key == keyTranslation[i][0]) if (key == keyTranslation[i][0])
return keyTranslation[i][1]; return keyTranslation[i][1];
@@ -926,10 +842,9 @@ namespace
return String(); return String();
} }
} } // namespace
PropertyMap MP4::Tag::properties() const PropertyMap MP4::Tag::properties() const {
{
PropertyMap props; PropertyMap props;
for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) { for (MP4::ItemMap::ConstIterator it = d->items.begin(); it != d->items.end(); ++it) {
const String key = translateKey(it->first); const String key = translateKey(it->first);
@@ -959,14 +874,12 @@ PropertyMap MP4::Tag::properties() const
return props; return props;
} }
void MP4::Tag::removeUnsupportedProperties(const StringList &props) void MP4::Tag::removeUnsupportedProperties(const StringList &props) {
{
for (StringList::ConstIterator it = props.begin(); it != props.end(); ++it) for (StringList::ConstIterator it = props.begin(); it != props.end(); ++it)
d->items.erase(*it); d->items.erase(*it);
} }
PropertyMap MP4::Tag::setProperties(const PropertyMap &props) PropertyMap MP4::Tag::setProperties(const PropertyMap &props) {
{
static Map<String, String> reverseKeyMap; static Map<String, String> reverseKeyMap;
if (reverseKeyMap.isEmpty()) { if (reverseKeyMap.isEmpty()) {
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]); int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
@@ -1017,8 +930,7 @@ PropertyMap MP4::Tag::setProperties(const PropertyMap &props)
return ignoredProps; return ignoredProps;
} }
void MP4::Tag::addItem(const String &name, const Item &value) void MP4::Tag::addItem(const String &name, const Item &value) {
{
if (!d->items.contains(name)) { if (!d->items.contains(name)) {
d->items.insert(name, value); d->items.insert(name, value);
} }

View File

@@ -46,8 +46,7 @@ namespace TagLib {
TAGLIB_DEPRECATED typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemListMap; TAGLIB_DEPRECATED typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemListMap;
typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemMap; typedef Strawberry_TagLib::TagLib::Map<String, Item> ItemMap;
class TAGLIB_EXPORT Tag: public Strawberry_TagLib::TagLib::Tag class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
{
public: public:
Tag(); Tag();
Tag(Strawberry_TagLib::TagLib::File *file, Atoms *atoms); Tag(Strawberry_TagLib::TagLib::File *file, Atoms *atoms);
@@ -151,9 +150,9 @@ namespace TagLib {
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace MP4
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -38,16 +38,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{ enum { MPCAPEIndex = 0,
enum { MPCAPEIndex = 0, MPCID3v1Index = 1 }; MPCID3v1Index = 1 };
} }
class MPC::File::FilePrivate class MPC::File::FilePrivate {
{
public: public:
FilePrivate() : FilePrivate() : APELocation(-1),
APELocation(-1),
APESize(0), APESize(0),
ID3v1Location(-1), ID3v1Location(-1),
ID3v2Header(0), ID3v2Header(0),
@@ -55,8 +53,7 @@ public:
ID3v2Size(0), ID3v2Size(0),
properties(0) {} properties(0) {}
~FilePrivate() ~FilePrivate() {
{
delete ID3v2Header; delete ID3v2Header;
delete properties; delete properties;
} }
@@ -79,8 +76,7 @@ public:
// static members // static members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool MPC::File::isSupported(IOStream *stream) bool MPC::File::isSupported(IOStream *stream) {
{
// A newer MPC file has to start with "MPCK" or "MP+", but older files don't // A newer MPC file has to start with "MPCK" or "MP+", but older files don't
// have keys to do a quick check. // have keys to do a quick check.
@@ -92,57 +88,46 @@ bool MPC::File::isSupported(IOStream *stream)
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(file),
Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
MPC::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : MPC::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream),
Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
d(new FilePrivate())
{
if (isOpen()) if (isOpen())
read(readProperties); read(readProperties);
} }
MPC::File::~File() MPC::File::~File() {
{
delete d; delete d;
} }
Strawberry_TagLib::TagLib::Tag *MPC::File::tag() const Strawberry_TagLib::TagLib::Tag *MPC::File::tag() const {
{
return &d->tag; return &d->tag;
} }
PropertyMap MPC::File::properties() const PropertyMap MPC::File::properties() const {
{
return d->tag.properties(); return d->tag.properties();
} }
void MPC::File::removeUnsupportedProperties(const StringList &properties) void MPC::File::removeUnsupportedProperties(const StringList &properties) {
{
d->tag.removeUnsupportedProperties(properties); d->tag.removeUnsupportedProperties(properties);
} }
PropertyMap MPC::File::setProperties(const PropertyMap &properties) PropertyMap MPC::File::setProperties(const PropertyMap &properties) {
{
if (ID3v1Tag()) if (ID3v1Tag())
ID3v1Tag()->setProperties(properties); ID3v1Tag()->setProperties(properties);
return APETag(true)->setProperties(properties); return APETag(true)->setProperties(properties);
} }
MPC::Properties *MPC::File::audioProperties() const MPC::Properties *MPC::File::audioProperties() const {
{
return d->properties; return d->properties;
} }
bool MPC::File::save() bool MPC::File::save() {
{
if (readOnly()) { if (readOnly()) {
debug("MPC::File::save() -- File is read only."); debug("MPC::File::save() -- File is read only.");
return false; return false;
@@ -228,18 +213,15 @@ bool MPC::File::save()
return true; return true;
} }
ID3v1::Tag *MPC::File::ID3v1Tag(bool create) ID3v1::Tag *MPC::File::ID3v1Tag(bool create) {
{
return d->tag.access<ID3v1::Tag>(MPCID3v1Index, create); return d->tag.access<ID3v1::Tag>(MPCID3v1Index, create);
} }
APE::Tag *MPC::File::APETag(bool create) APE::Tag *MPC::File::APETag(bool create) {
{
return d->tag.access<APE::Tag>(MPCAPEIndex, create); return d->tag.access<APE::Tag>(MPCAPEIndex, create);
} }
void MPC::File::strip(int tags) void MPC::File::strip(int tags) {
{
if (tags & ID3v1) if (tags & ID3v1)
d->tag.set(MPCID3v1Index, 0); d->tag.set(MPCID3v1Index, 0);
@@ -255,18 +237,15 @@ void MPC::File::strip(int tags)
} }
} }
void MPC::File::remove(int tags) void MPC::File::remove(int tags) {
{
strip(tags); strip(tags);
} }
bool MPC::File::hasID3v1Tag() const bool MPC::File::hasID3v1Tag() const {
{
return (d->ID3v1Location >= 0); return (d->ID3v1Location >= 0);
} }
bool MPC::File::hasAPETag() const bool MPC::File::hasAPETag() const {
{
return (d->APELocation >= 0); return (d->APELocation >= 0);
} }
@@ -274,8 +253,7 @@ bool MPC::File::hasAPETag() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void MPC::File::read(bool readProperties) void MPC::File::read(bool readProperties) {
{
// Look for an ID3v2 tag // Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this); d->ID3v2Location = Utils::findID3v2(this);

View File

@@ -39,8 +39,12 @@ namespace TagLib {
class Tag; class Tag;
namespace ID3v1 { class Tag; } namespace ID3v1 {
namespace APE { class Tag; } class Tag;
}
namespace APE {
class Tag;
}
//! An implementation of MPC metadata //! An implementation of MPC metadata
@@ -64,8 +68,7 @@ namespace TagLib {
* The only invalid tag combination supported is an ID3v1 tag after an APE tag. * The only invalid tag combination supported is an ID3v1 tag after an APE tag.
*/ */
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
{
public: public:
/*! /*!
* This set of flags is used for various operations and is suitable for * This set of flags is used for various operations and is suitable for
@@ -233,8 +236,8 @@ namespace TagLib {
class FilePrivate; class FilePrivate;
FilePrivate *d; FilePrivate *d;
}; };
} } // namespace MPC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -33,11 +33,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
class MPC::Properties::PropertiesPrivate class MPC::Properties::PropertiesPrivate {
{
public: public:
PropertiesPrivate() : PropertiesPrivate() : version(0),
version(0),
length(0), length(0),
bitrate(0), bitrate(0),
sampleRate(0), sampleRate(0),
@@ -66,17 +64,13 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
readSV7(data, streamLength); readSV7(data, streamLength);
} }
MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) : MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) : AudioProperties(style),
AudioProperties(style), d(new PropertiesPrivate()) {
d(new PropertiesPrivate())
{
ByteVector magic = file->readBlock(4); ByteVector magic = file->readBlock(4);
if (magic == "MPCK") { if (magic == "MPCK") {
// Musepack version 8 // Musepack version 8
@@ -88,73 +82,59 @@ MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) :
} }
} }
MPC::Properties::~Properties() MPC::Properties::~Properties() {
{
delete d; delete d;
} }
int MPC::Properties::length() const int MPC::Properties::length() const {
{
return lengthInSeconds(); return lengthInSeconds();
} }
int MPC::Properties::lengthInSeconds() const int MPC::Properties::lengthInSeconds() const {
{
return d->length / 1000; return d->length / 1000;
} }
int MPC::Properties::lengthInMilliseconds() const int MPC::Properties::lengthInMilliseconds() const {
{
return d->length; return d->length;
} }
int MPC::Properties::bitrate() const int MPC::Properties::bitrate() const {
{
return d->bitrate; return d->bitrate;
} }
int MPC::Properties::sampleRate() const int MPC::Properties::sampleRate() const {
{
return d->sampleRate; return d->sampleRate;
} }
int MPC::Properties::channels() const int MPC::Properties::channels() const {
{
return d->channels; return d->channels;
} }
int MPC::Properties::mpcVersion() const int MPC::Properties::mpcVersion() const {
{
return d->version; return d->version;
} }
unsigned int MPC::Properties::totalFrames() const unsigned int MPC::Properties::totalFrames() const {
{
return d->totalFrames; return d->totalFrames;
} }
unsigned int MPC::Properties::sampleFrames() const unsigned int MPC::Properties::sampleFrames() const {
{
return d->sampleFrames; return d->sampleFrames;
} }
int MPC::Properties::trackGain() const int MPC::Properties::trackGain() const {
{
return d->trackGain; return d->trackGain;
} }
int MPC::Properties::trackPeak() const int MPC::Properties::trackPeak() const {
{
return d->trackPeak; return d->trackPeak;
} }
int MPC::Properties::albumGain() const int MPC::Properties::albumGain() const {
{
return d->albumGain; return d->albumGain;
} }
int MPC::Properties::albumPeak() const int MPC::Properties::albumPeak() const {
{
return d->albumPeak; return d->albumPeak;
} }
@@ -162,10 +142,8 @@ int MPC::Properties::albumPeak() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace namespace {
{ unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof) {
unsigned long readSize(File *file, unsigned int &sizeLength, bool &eof)
{
sizeLength = 0; sizeLength = 0;
eof = false; eof = false;
@@ -186,8 +164,7 @@ namespace
return size; return size;
} }
unsigned long readSize(const ByteVector &data, unsigned int &pos) unsigned long readSize(const ByteVector &data, unsigned int &pos) {
{
unsigned char tmp; unsigned char tmp;
unsigned long size = 0; unsigned long size = 0;
@@ -201,10 +178,9 @@ namespace
// This array looks weird, but the same as original MusePack code found at: // This array looks weird, but the same as original MusePack code found at:
// https://www.musepack.net/index.php?pg=src // https://www.musepack.net/index.php?pg=src
const unsigned short sftable[8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 }; const unsigned short sftable[8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 };
} } // namespace
void MPC::Properties::readSV8(File *file, long streamLength) void MPC::Properties::readSV8(File *file, long streamLength) {
{
bool readSH = false, readRG = false; bool readSH = false, readRG = false;
while (!readSH && !readRG) { while (!readSH && !readRG) {
@@ -295,8 +271,7 @@ void MPC::Properties::readSV8(File *file, long streamLength)
} }
} }
void MPC::Properties::readSV7(const ByteVector &data, long streamLength) void MPC::Properties::readSV7(const ByteVector &data, long streamLength) {
{
if (data.startsWith("MP+")) { if (data.startsWith("MP+")) {
d->version = data[3] & 15; d->version = data[3] & 15;
if (d->version < 7) if (d->version < 7)

View File

@@ -45,8 +45,7 @@ namespace TagLib {
* API. * API.
*/ */
class TAGLIB_EXPORT Properties : public AudioProperties class TAGLIB_EXPORT Properties : public AudioProperties {
{
public: public:
/*! /*!
* Create an instance of MPC::Properties with the data read from the * Create an instance of MPC::Properties with the data read from the
@@ -153,8 +152,8 @@ namespace TagLib {
class PropertiesPrivate; class PropertiesPrivate;
PropertiesPrivate *d; PropertiesPrivate *d;
}; };
} } // namespace MPC
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -27,8 +27,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
namespace namespace {
{
const wchar_t *genres[] = { const wchar_t *genres[] = {
L"Blues", L"Blues",
L"Classic Rock", L"Classic Rock",
@@ -224,10 +223,9 @@ namespace
L"Psybient" L"Psybient"
}; };
const int genresSize = sizeof(genres) / sizeof(genres[0]); const int genresSize = sizeof(genres) / sizeof(genres[0]);
} } // namespace
StringList ID3v1::genreList() StringList ID3v1::genreList() {
{
StringList l; StringList l;
for (int i = 0; i < genresSize; i++) { for (int i = 0; i < genresSize; i++) {
l.append(genres[i]); l.append(genres[i]);
@@ -236,8 +234,7 @@ StringList ID3v1::genreList()
return l; return l;
} }
ID3v1::GenreMap ID3v1::genreMap() ID3v1::GenreMap ID3v1::genreMap() {
{
GenreMap m; GenreMap m;
for (int i = 0; i < genresSize; i++) { for (int i = 0; i < genresSize; i++) {
m.insert(genres[i], i); m.insert(genres[i], i);
@@ -246,16 +243,14 @@ ID3v1::GenreMap ID3v1::genreMap()
return m; return m;
} }
String ID3v1::genre(int i) String ID3v1::genre(int i) {
{
if (i >= 0 && i < genresSize) if (i >= 0 && i < genresSize)
return String(genres[i]); // always make a copy return String(genres[i]); // always make a copy
else else
return String(); return String();
} }
int ID3v1::genreIndex(const String &name) int ID3v1::genreIndex(const String &name) {
{
for (int i = 0; i < genresSize; ++i) { for (int i = 0; i < genresSize; ++i) {
if (name == genres[i]) if (name == genres[i])
return i; return i;

View File

@@ -61,8 +61,8 @@ namespace TagLib {
* will be returned. * will be returned.
*/ */
int TAGLIB_EXPORT genreIndex(const String &name); int TAGLIB_EXPORT genreIndex(const String &name);
} } // namespace ID3v1
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -32,17 +32,14 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v1; using namespace ID3v1;
namespace namespace {
{
const ID3v1::StringHandler defaultStringHandler; const ID3v1::StringHandler defaultStringHandler;
const ID3v1::StringHandler *stringHandler = &defaultStringHandler; const ID3v1::StringHandler *stringHandler = &defaultStringHandler;
} } // namespace
class ID3v1::Tag::TagPrivate class ID3v1::Tag::TagPrivate {
{
public: public:
TagPrivate() : TagPrivate() : file(0),
file(0),
tagOffset(0), tagOffset(0),
track(0), track(0),
genre(255) {} genre(255) {}
@@ -63,17 +60,14 @@ public:
// StringHandler implementation // StringHandler implementation
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
StringHandler::StringHandler() StringHandler::StringHandler() {
{
} }
String ID3v1::StringHandler::parse(const ByteVector &data) const String ID3v1::StringHandler::parse(const ByteVector &data) const {
{
return String(data, String::Latin1).stripWhiteSpace(); return String(data, String::Latin1).stripWhiteSpace();
} }
ByteVector ID3v1::StringHandler::render(const String &s) const ByteVector ID3v1::StringHandler::render(const String &s) const {
{
if (s.isLatin1()) if (s.isLatin1())
return s.data(String::Latin1); return s.data(String::Latin1);
else else
@@ -84,29 +78,23 @@ ByteVector ID3v1::StringHandler::render(const String &s) const
// public methods // public methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ID3v1::Tag::Tag() : ID3v1::Tag::Tag() : Strawberry_TagLib::TagLib::Tag(),
Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {
d(new TagPrivate())
{
} }
ID3v1::Tag::Tag(File *file, long tagOffset) : ID3v1::Tag::Tag(File *file, long tagOffset) : Strawberry_TagLib::TagLib::Tag(),
Strawberry_TagLib::TagLib::Tag(), d(new TagPrivate()) {
d(new TagPrivate())
{
d->file = file; d->file = file;
d->tagOffset = tagOffset; d->tagOffset = tagOffset;
read(); read();
} }
ID3v1::Tag::~Tag() ID3v1::Tag::~Tag() {
{
delete d; delete d;
} }
ByteVector ID3v1::Tag::render() const ByteVector ID3v1::Tag::render() const {
{
ByteVector data; ByteVector data;
data.append(fileIdentifier()); data.append(fileIdentifier());
@@ -122,93 +110,75 @@ ByteVector ID3v1::Tag::render() const
return data; return data;
} }
ByteVector ID3v1::Tag::fileIdentifier() ByteVector ID3v1::Tag::fileIdentifier() {
{
return ByteVector::fromCString("TAG"); return ByteVector::fromCString("TAG");
} }
String ID3v1::Tag::title() const String ID3v1::Tag::title() const {
{
return d->title; return d->title;
} }
String ID3v1::Tag::artist() const String ID3v1::Tag::artist() const {
{
return d->artist; return d->artist;
} }
String ID3v1::Tag::album() const String ID3v1::Tag::album() const {
{
return d->album; return d->album;
} }
String ID3v1::Tag::comment() const String ID3v1::Tag::comment() const {
{
return d->comment; return d->comment;
} }
String ID3v1::Tag::genre() const String ID3v1::Tag::genre() const {
{
return ID3v1::genre(d->genre); return ID3v1::genre(d->genre);
} }
unsigned int ID3v1::Tag::year() const unsigned int ID3v1::Tag::year() const {
{
return d->year.toInt(); return d->year.toInt();
} }
unsigned int ID3v1::Tag::track() const unsigned int ID3v1::Tag::track() const {
{
return d->track; return d->track;
} }
void ID3v1::Tag::setTitle(const String &s) void ID3v1::Tag::setTitle(const String &s) {
{
d->title = s; d->title = s;
} }
void ID3v1::Tag::setArtist(const String &s) void ID3v1::Tag::setArtist(const String &s) {
{
d->artist = s; d->artist = s;
} }
void ID3v1::Tag::setAlbum(const String &s) void ID3v1::Tag::setAlbum(const String &s) {
{
d->album = s; d->album = s;
} }
void ID3v1::Tag::setComment(const String &s) void ID3v1::Tag::setComment(const String &s) {
{
d->comment = s; d->comment = s;
} }
void ID3v1::Tag::setGenre(const String &s) void ID3v1::Tag::setGenre(const String &s) {
{
d->genre = ID3v1::genreIndex(s); d->genre = ID3v1::genreIndex(s);
} }
void ID3v1::Tag::setYear(unsigned int i) void ID3v1::Tag::setYear(unsigned int i) {
{
d->year = i > 0 ? String::number(i) : String(); d->year = i > 0 ? String::number(i) : String();
} }
void ID3v1::Tag::setTrack(unsigned int i) void ID3v1::Tag::setTrack(unsigned int i) {
{
d->track = i < 256 ? i : 0; d->track = i < 256 ? i : 0;
} }
unsigned int ID3v1::Tag::genreNumber() const unsigned int ID3v1::Tag::genreNumber() const {
{
return d->genre; return d->genre;
} }
void ID3v1::Tag::setGenreNumber(unsigned int i) void ID3v1::Tag::setGenreNumber(unsigned int i) {
{
d->genre = i < 256 ? i : 255; d->genre = i < 256 ? i : 255;
} }
void ID3v1::Tag::setStringHandler(const StringHandler *handler) void ID3v1::Tag::setStringHandler(const StringHandler *handler) {
{
if (handler) if (handler)
stringHandler = handler; stringHandler = handler;
else else
@@ -219,8 +189,7 @@ void ID3v1::Tag::setStringHandler(const StringHandler *handler)
// protected methods // protected methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void ID3v1::Tag::read() void ID3v1::Tag::read() {
{
if (d->file && d->file->isValid()) { if (d->file && d->file->isValid()) {
d->file->seek(d->tagOffset); d->file->seek(d->tagOffset);
// read the tag -- always 128 bytes // read the tag -- always 128 bytes
@@ -234,8 +203,7 @@ void ID3v1::Tag::read()
} }
} }
void ID3v1::Tag::parse(const ByteVector &data) void ID3v1::Tag::parse(const ByteVector &data) {
{
int offset = 3; int offset = 3;
d->title = stringHandler->parse(data.mid(offset, 30)); d->title = stringHandler->parse(data.mid(offset, 30));

View File

@@ -58,8 +58,7 @@ namespace TagLib {
* \see ID3v1::Tag::setStringHandler() * \see ID3v1::Tag::setStringHandler()
*/ */
class TAGLIB_EXPORT StringHandler class TAGLIB_EXPORT StringHandler {
{
TAGLIB_IGNORE_MISSING_DESTRUCTOR TAGLIB_IGNORE_MISSING_DESTRUCTOR
public: public:
// BIC: Add virtual destructor. // BIC: Add virtual destructor.
@@ -103,8 +102,7 @@ namespace TagLib {
* truncation happens automatically when the tag is rendered. * truncation happens automatically when the tag is rendered.
*/ */
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
{
public: public:
/*! /*!
* Create an ID3v1 tag with default values. * Create an ID3v1 tag with default values.
@@ -197,8 +195,8 @@ namespace TagLib {
class TagPrivate; class TagPrivate;
TagPrivate *d; TagPrivate *d;
}; };
} } // namespace ID3v1
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,8 +31,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class AttachedPictureFrame::AttachedPictureFramePrivate class AttachedPictureFrame::AttachedPictureFramePrivate {
{
public: public:
AttachedPictureFramePrivate() : textEncoding(String::Latin1), AttachedPictureFramePrivate() : textEncoding(String::Latin1),
type(AttachedPictureFrame::Other) {} type(AttachedPictureFrame::Other) {}
@@ -48,77 +47,61 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AttachedPictureFrame::AttachedPictureFrame() : AttachedPictureFrame::AttachedPictureFrame() : Frame("APIC"),
Frame("APIC"), d(new AttachedPictureFramePrivate()) {
d(new AttachedPictureFramePrivate())
{
} }
AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data) : AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new AttachedPictureFramePrivate()) {
d(new AttachedPictureFramePrivate())
{
setData(data); setData(data);
} }
AttachedPictureFrame::~AttachedPictureFrame() AttachedPictureFrame::~AttachedPictureFrame() {
{
delete d; delete d;
} }
String AttachedPictureFrame::toString() const String AttachedPictureFrame::toString() const {
{
String s = "[" + d->mimeType + "]"; String s = "[" + d->mimeType + "]";
return d->description.isEmpty() ? s : d->description + " " + s; return d->description.isEmpty() ? s : d->description + " " + s;
} }
String::Type AttachedPictureFrame::textEncoding() const String::Type AttachedPictureFrame::textEncoding() const {
{
return d->textEncoding; return d->textEncoding;
} }
void AttachedPictureFrame::setTextEncoding(String::Type t) void AttachedPictureFrame::setTextEncoding(String::Type t) {
{
d->textEncoding = t; d->textEncoding = t;
} }
String AttachedPictureFrame::mimeType() const String AttachedPictureFrame::mimeType() const {
{
return d->mimeType; return d->mimeType;
} }
void AttachedPictureFrame::setMimeType(const String &m) void AttachedPictureFrame::setMimeType(const String &m) {
{
d->mimeType = m; d->mimeType = m;
} }
AttachedPictureFrame::Type AttachedPictureFrame::type() const AttachedPictureFrame::Type AttachedPictureFrame::type() const {
{
return d->type; return d->type;
} }
void AttachedPictureFrame::setType(Type t) void AttachedPictureFrame::setType(Type t) {
{
d->type = t; d->type = t;
} }
String AttachedPictureFrame::description() const String AttachedPictureFrame::description() const {
{
return d->description; return d->description;
} }
void AttachedPictureFrame::setDescription(const String &desc) void AttachedPictureFrame::setDescription(const String &desc) {
{
d->description = desc; d->description = desc;
} }
ByteVector AttachedPictureFrame::picture() const ByteVector AttachedPictureFrame::picture() const {
{
return d->data; return d->data;
} }
void AttachedPictureFrame::setPicture(const ByteVector &p) void AttachedPictureFrame::setPicture(const ByteVector &p) {
{
d->data = p; d->data = p;
} }
@@ -126,8 +109,7 @@ void AttachedPictureFrame::setPicture(const ByteVector &p)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void AttachedPictureFrame::parseFields(const ByteVector &data) void AttachedPictureFrame::parseFields(const ByteVector &data) {
{
if (data.size() < 5) { if (data.size() < 5) {
debug("A picture frame must contain at least 5 bytes."); debug("A picture frame must contain at least 5 bytes.");
return; return;
@@ -150,8 +132,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data)
d->data = data.mid(pos); d->data = data.mid(pos);
} }
ByteVector AttachedPictureFrame::renderFields() const ByteVector AttachedPictureFrame::renderFields() const {
{
ByteVector data; ByteVector data;
String::Type encoding = checkTextEncoding(d->description, d->textEncoding); String::Type encoding = checkTextEncoding(d->description, d->textEncoding);
@@ -171,10 +152,8 @@ ByteVector AttachedPictureFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new AttachedPictureFramePrivate()) {
d(new AttachedPictureFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }
@@ -182,8 +161,7 @@ AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) :
// support for ID3v2.2 PIC frames // support for ID3v2.2 PIC frames
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void AttachedPictureFrameV22::parseFields(const ByteVector &data) void AttachedPictureFrameV22::parseFields(const ByteVector &data) {
{
if (data.size() < 5) { if (data.size() < 5) {
debug("A picture frame must contain at least 5 bytes."); debug("A picture frame must contain at least 5 bytes.");
return; return;
@@ -198,9 +176,11 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data)
// convert fixed string image type to mime string // convert fixed string image type to mime string
if (fixedString.upper() == "JPG") { if (fixedString.upper() == "JPG") {
d->mimeType = "image/jpeg"; d->mimeType = "image/jpeg";
} else if (fixedString.upper() == "PNG") { }
else if (fixedString.upper() == "PNG") {
d->mimeType = "image/png"; d->mimeType = "image/png";
} else { }
else {
debug("probably unsupported image type"); debug("probably unsupported image type");
d->mimeType = "image/" + fixedString; d->mimeType = "image/" + fixedString;
} }
@@ -211,8 +191,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data)
d->data = data.mid(pos); d->data = data.mid(pos);
} }
AttachedPictureFrameV22::AttachedPictureFrameV22(const ByteVector &data, Header *h) AttachedPictureFrameV22::AttachedPictureFrameV22(const ByteVector &data, Header *h) {
{
// set v2.2 header to make fieldData work correctly // set v2.2 header to make fieldData work correctly
setHeader(h, true); setHeader(h, true);

View File

@@ -44,12 +44,10 @@ namespace TagLib {
* PNG format. * PNG format.
*/ */
class TAGLIB_EXPORT AttachedPictureFrame : public Frame class TAGLIB_EXPORT AttachedPictureFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
/*! /*!
* This describes the function or content of the picture. * This describes the function or content of the picture.
*/ */
@@ -213,20 +211,19 @@ namespace TagLib {
AttachedPictureFrame(const AttachedPictureFrame &); AttachedPictureFrame(const AttachedPictureFrame &);
AttachedPictureFrame &operator=(const AttachedPictureFrame &); AttachedPictureFrame &operator=(const AttachedPictureFrame &);
AttachedPictureFrame(const ByteVector &data, Header *h); AttachedPictureFrame(const ByteVector &data, Header *h);
}; };
//! support for ID3v2.2 PIC frames //! support for ID3v2.2 PIC frames
class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame {
{
protected: protected:
virtual void parseFields(const ByteVector &data); virtual void parseFields(const ByteVector &data);
private: private:
AttachedPictureFrameV22(const ByteVector &data, Header *h); AttachedPictureFrameV22(const ByteVector &data, Header *h);
friend class FrameFactory; friend class FrameFactory;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -33,16 +33,13 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class ChapterFrame::ChapterFramePrivate class ChapterFrame::ChapterFramePrivate {
{
public: public:
ChapterFramePrivate() : ChapterFramePrivate() : tagHeader(0),
tagHeader(0),
startTime(0), startTime(0),
endTime(0), endTime(0),
startOffset(0), startOffset(0),
endOffset(0) endOffset(0) {
{
embeddedFrameList.setAutoDelete(true); embeddedFrameList.setAutoDelete(true);
} }
@@ -60,10 +57,8 @@ public:
// public methods // public methods
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ID3v2::Frame(data),
ID3v2::Frame(data), d(new ChapterFramePrivate()) {
d(new ChapterFramePrivate())
{
d->tagHeader = tagHeader; d->tagHeader = tagHeader;
setData(data); setData(data);
} }
@@ -71,10 +66,8 @@ ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &dat
ChapterFrame::ChapterFrame(const ByteVector &elementID, ChapterFrame::ChapterFrame(const ByteVector &elementID,
unsigned int startTime, unsigned int endTime, unsigned int startTime, unsigned int endTime,
unsigned int startOffset, unsigned int endOffset, unsigned int startOffset, unsigned int endOffset,
const FrameList &embeddedFrames) : const FrameList &embeddedFrames) : ID3v2::Frame("CHAP"),
ID3v2::Frame("CHAP"), d(new ChapterFramePrivate()) {
d(new ChapterFramePrivate())
{
// setElementID has a workaround for a previously silly API where you had to // setElementID has a workaround for a previously silly API where you had to
// specifically include the null byte. // specifically include the null byte.
@@ -86,91 +79,76 @@ ChapterFrame::ChapterFrame(const ByteVector &elementID,
d->endOffset = endOffset; d->endOffset = endOffset;
for (FrameList::ConstIterator it = embeddedFrames.begin(); for (FrameList::ConstIterator it = embeddedFrames.begin();
it != embeddedFrames.end(); ++it) it != embeddedFrames.end();
++it)
addEmbeddedFrame(*it); addEmbeddedFrame(*it);
} }
ChapterFrame::~ChapterFrame() ChapterFrame::~ChapterFrame() {
{
delete d; delete d;
} }
ByteVector ChapterFrame::elementID() const ByteVector ChapterFrame::elementID() const {
{
return d->elementID; return d->elementID;
} }
unsigned int ChapterFrame::startTime() const unsigned int ChapterFrame::startTime() const {
{
return d->startTime; return d->startTime;
} }
unsigned int ChapterFrame::endTime() const unsigned int ChapterFrame::endTime() const {
{
return d->endTime; return d->endTime;
} }
unsigned int ChapterFrame::startOffset() const unsigned int ChapterFrame::startOffset() const {
{
return d->startOffset; return d->startOffset;
} }
unsigned int ChapterFrame::endOffset() const unsigned int ChapterFrame::endOffset() const {
{
return d->endOffset; return d->endOffset;
} }
void ChapterFrame::setElementID(const ByteVector &eID) void ChapterFrame::setElementID(const ByteVector &eID) {
{
d->elementID = eID; d->elementID = eID;
if (d->elementID.endsWith(char(0))) if (d->elementID.endsWith(char(0)))
d->elementID = d->elementID.mid(0, d->elementID.size() - 1); d->elementID = d->elementID.mid(0, d->elementID.size() - 1);
} }
void ChapterFrame::setStartTime(const unsigned int &sT) void ChapterFrame::setStartTime(const unsigned int &sT) {
{
d->startTime = sT; d->startTime = sT;
} }
void ChapterFrame::setEndTime(const unsigned int &eT) void ChapterFrame::setEndTime(const unsigned int &eT) {
{
d->endTime = eT; d->endTime = eT;
} }
void ChapterFrame::setStartOffset(const unsigned int &sO) void ChapterFrame::setStartOffset(const unsigned int &sO) {
{
d->startOffset = sO; d->startOffset = sO;
} }
void ChapterFrame::setEndOffset(const unsigned int &eO) void ChapterFrame::setEndOffset(const unsigned int &eO) {
{
d->endOffset = eO; d->endOffset = eO;
} }
const FrameListMap &ChapterFrame::embeddedFrameListMap() const const FrameListMap &ChapterFrame::embeddedFrameListMap() const {
{
return d->embeddedFrameListMap; return d->embeddedFrameListMap;
} }
const FrameList &ChapterFrame::embeddedFrameList() const const FrameList &ChapterFrame::embeddedFrameList() const {
{
return d->embeddedFrameList; return d->embeddedFrameList;
} }
const FrameList &ChapterFrame::embeddedFrameList(const ByteVector &frameID) const const FrameList &ChapterFrame::embeddedFrameList(const ByteVector &frameID) const {
{
return d->embeddedFrameListMap[frameID]; return d->embeddedFrameListMap[frameID];
} }
void ChapterFrame::addEmbeddedFrame(Frame *frame) void ChapterFrame::addEmbeddedFrame(Frame *frame) {
{
d->embeddedFrameList.append(frame); d->embeddedFrameList.append(frame);
d->embeddedFrameListMap[frame->frameID()].append(frame); d->embeddedFrameListMap[frame->frameID()].append(frame);
} }
void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del) {
{
// remove the frame from the frame list // remove the frame from the frame list
FrameList::Iterator it = d->embeddedFrameList.find(frame); FrameList::Iterator it = d->embeddedFrameList.find(frame);
d->embeddedFrameList.erase(it); d->embeddedFrameList.erase(it);
@@ -184,15 +162,13 @@ void ChapterFrame::removeEmbeddedFrame(Frame *frame, bool del)
delete frame; delete frame;
} }
void ChapterFrame::removeEmbeddedFrames(const ByteVector &id) void ChapterFrame::removeEmbeddedFrames(const ByteVector &id) {
{
FrameList l = d->embeddedFrameListMap[id]; FrameList l = d->embeddedFrameListMap[id];
for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it) for (FrameList::ConstIterator it = l.begin(); it != l.end(); ++it)
removeEmbeddedFrame(*it, true); removeEmbeddedFrame(*it, true);
} }
String ChapterFrame::toString() const String ChapterFrame::toString() const {
{
String s = String(d->elementID) + String s = String(d->elementID) +
": start time: " + String::number(d->startTime) + ": start time: " + String::number(d->startTime) +
", end time: " + String::number(d->endTime); ", end time: " + String::number(d->endTime);
@@ -206,7 +182,8 @@ String ChapterFrame::toString() const
if (!d->embeddedFrameList.isEmpty()) { if (!d->embeddedFrameList.isEmpty()) {
StringList frameIDs; StringList frameIDs;
for (FrameList::ConstIterator it = d->embeddedFrameList.begin(); for (FrameList::ConstIterator it = d->embeddedFrameList.begin();
it != d->embeddedFrameList.end(); ++it) it != d->embeddedFrameList.end();
++it)
frameIDs.append((*it)->frameID()); frameIDs.append((*it)->frameID());
s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]"; s += ", sub-frames: [ " + frameIDs.toString(", ") + " ]";
} }
@@ -214,8 +191,7 @@ String ChapterFrame::toString() const
return s; return s;
} }
PropertyMap ChapterFrame::asProperties() const PropertyMap ChapterFrame::asProperties() const {
{
PropertyMap map; PropertyMap map;
map.unsupportedData().append(frameID() + String("/") + d->elementID); map.unsupportedData().append(frameID() + String("/") + d->elementID);
@@ -229,8 +205,7 @@ ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVec
for (ID3v2::FrameList::ConstIterator it = comments.begin(); for (ID3v2::FrameList::ConstIterator it = comments.begin();
it != comments.end(); it != comments.end();
++it) ++it) {
{
ChapterFrame *frame = dynamic_cast<ChapterFrame *>(*it); ChapterFrame *frame = dynamic_cast<ChapterFrame *>(*it);
if (frame && frame->elementID() == eID) if (frame && frame->elementID() == eID)
return frame; return frame;
@@ -239,8 +214,7 @@ ChapterFrame *ChapterFrame::findByElementID(const ID3v2::Tag *tag, const ByteVec
return nullptr; return nullptr;
} }
void ChapterFrame::parseFields(const ByteVector &data) void ChapterFrame::parseFields(const ByteVector &data) {
{
unsigned int size = data.size(); unsigned int size = data.size();
if (size < 18) { if (size < 18) {
debug("A CHAP frame must contain at least 18 bytes (1 byte element ID " debug("A CHAP frame must contain at least 18 bytes (1 byte element ID "
@@ -283,8 +257,7 @@ void ChapterFrame::parseFields(const ByteVector &data)
} }
} }
ByteVector ChapterFrame::renderFields() const ByteVector ChapterFrame::renderFields() const {
{
ByteVector data; ByteVector data;
data.append(d->elementID); data.append(d->elementID);
@@ -300,10 +273,8 @@ ByteVector ChapterFrame::renderFields() const
return data; return data;
} }
ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new ChapterFramePrivate()) {
d(new ChapterFramePrivate())
{
d->tagHeader = tagHeader; d->tagHeader = tagHeader;
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -42,8 +42,7 @@ namespace TagLib {
//! An implementation of ID3v2 chapter frames //! An implementation of ID3v2 chapter frames
class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -244,8 +243,8 @@ namespace TagLib {
class ChapterFramePrivate; class ChapterFramePrivate;
ChapterFramePrivate *d; ChapterFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -34,8 +34,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class CommentsFrame::CommentsFramePrivate class CommentsFrame::CommentsFramePrivate {
{
public: public:
CommentsFramePrivate() : textEncoding(String::Latin1) {} CommentsFramePrivate() : textEncoding(String::Latin1) {}
String::Type textEncoding; String::Type textEncoding;
@@ -48,72 +47,57 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CommentsFrame::CommentsFrame(String::Type encoding) : CommentsFrame::CommentsFrame(String::Type encoding) : Frame("COMM"),
Frame("COMM"), d(new CommentsFramePrivate()) {
d(new CommentsFramePrivate())
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
CommentsFrame::CommentsFrame(const ByteVector &data) : CommentsFrame::CommentsFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new CommentsFramePrivate()) {
d(new CommentsFramePrivate())
{
setData(data); setData(data);
} }
CommentsFrame::~CommentsFrame() CommentsFrame::~CommentsFrame() {
{
delete d; delete d;
} }
String CommentsFrame::toString() const String CommentsFrame::toString() const {
{
return d->text; return d->text;
} }
ByteVector CommentsFrame::language() const ByteVector CommentsFrame::language() const {
{
return d->language; return d->language;
} }
String CommentsFrame::description() const String CommentsFrame::description() const {
{
return d->description; return d->description;
} }
String CommentsFrame::text() const String CommentsFrame::text() const {
{
return d->text; return d->text;
} }
void CommentsFrame::setLanguage(const ByteVector &languageEncoding) void CommentsFrame::setLanguage(const ByteVector &languageEncoding) {
{
d->language = languageEncoding.mid(0, 3); d->language = languageEncoding.mid(0, 3);
} }
void CommentsFrame::setDescription(const String &s) void CommentsFrame::setDescription(const String &s) {
{
d->description = s; d->description = s;
} }
void CommentsFrame::setText(const String &s) void CommentsFrame::setText(const String &s) {
{
d->text = s; d->text = s;
} }
String::Type CommentsFrame::textEncoding() const String::Type CommentsFrame::textEncoding() const {
{
return d->textEncoding; return d->textEncoding;
} }
void CommentsFrame::setTextEncoding(String::Type encoding) void CommentsFrame::setTextEncoding(String::Type encoding) {
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
PropertyMap CommentsFrame::asProperties() const PropertyMap CommentsFrame::asProperties() const {
{
String key = description().upper(); String key = description().upper();
PropertyMap map; PropertyMap map;
if (key.isEmpty() || key == "COMMENT") if (key.isEmpty() || key == "COMMENT")
@@ -129,8 +113,7 @@ CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const Str
for (ID3v2::FrameList::ConstIterator it = comments.begin(); for (ID3v2::FrameList::ConstIterator it = comments.begin();
it != comments.end(); it != comments.end();
++it) ++it) {
{
CommentsFrame *frame = dynamic_cast<CommentsFrame *>(*it); CommentsFrame *frame = dynamic_cast<CommentsFrame *>(*it);
if (frame && frame->description() == d) if (frame && frame->description() == d)
return frame; return frame;
@@ -143,8 +126,7 @@ CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const Str
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CommentsFrame::parseFields(const ByteVector &data) void CommentsFrame::parseFields(const ByteVector &data) {
{
if (data.size() < 5) { if (data.size() < 5) {
debug("A comment frame must contain at least 5 bytes."); debug("A comment frame must contain at least 5 bytes.");
return; return;
@@ -161,15 +143,15 @@ void CommentsFrame::parseFields(const ByteVector &data)
if (d->textEncoding == String::Latin1) { if (d->textEncoding == String::Latin1) {
d->description = Tag::latin1StringHandler()->parse(l.front()); d->description = Tag::latin1StringHandler()->parse(l.front());
d->text = Tag::latin1StringHandler()->parse(l.back()); d->text = Tag::latin1StringHandler()->parse(l.back());
} else { }
else {
d->description = String(l.front(), d->textEncoding); d->description = String(l.front(), d->textEncoding);
d->text = String(l.back(), d->textEncoding); d->text = String(l.back(), d->textEncoding);
} }
} }
} }
ByteVector CommentsFrame::renderFields() const ByteVector CommentsFrame::renderFields() const {
{
ByteVector v; ByteVector v;
String::Type encoding = d->textEncoding; String::Type encoding = d->textEncoding;
@@ -190,9 +172,7 @@ ByteVector CommentsFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CommentsFrame::CommentsFrame(const ByteVector &data, Header *h) : CommentsFrame::CommentsFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new CommentsFramePrivate()) {
d(new CommentsFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -41,8 +41,7 @@ namespace TagLib {
* a language encoding, a description and a single text field. * a language encoding, a description and a single text field.
*/ */
class TAGLIB_EXPORT CommentsFrame : public Frame class TAGLIB_EXPORT CommentsFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -175,7 +174,7 @@ namespace TagLib {
CommentsFramePrivate *d; CommentsFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -32,11 +32,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class EventTimingCodesFrame::EventTimingCodesFramePrivate class EventTimingCodesFrame::EventTimingCodesFramePrivate {
{
public: public:
EventTimingCodesFramePrivate() : EventTimingCodesFramePrivate() : timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {}
timestampFormat(EventTimingCodesFrame::AbsoluteMilliseconds) {}
EventTimingCodesFrame::TimestampFormat timestampFormat; EventTimingCodesFrame::TimestampFormat timestampFormat;
EventTimingCodesFrame::SynchedEventList synchedEvents; EventTimingCodesFrame::SynchedEventList synchedEvents;
}; };
@@ -45,50 +43,40 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
EventTimingCodesFrame::EventTimingCodesFrame() : EventTimingCodesFrame::EventTimingCodesFrame() : Frame("ETCO"),
Frame("ETCO"), d(new EventTimingCodesFramePrivate()) {
d(new EventTimingCodesFramePrivate())
{
} }
EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data) : EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new EventTimingCodesFramePrivate()) {
d(new EventTimingCodesFramePrivate())
{
setData(data); setData(data);
} }
EventTimingCodesFrame::~EventTimingCodesFrame() EventTimingCodesFrame::~EventTimingCodesFrame() {
{
delete d; delete d;
} }
String EventTimingCodesFrame::toString() const String EventTimingCodesFrame::toString() const {
{
return String(); return String();
} }
EventTimingCodesFrame::TimestampFormat EventTimingCodesFrame::TimestampFormat
EventTimingCodesFrame::timestampFormat() const EventTimingCodesFrame::timestampFormat() const {
{
return d->timestampFormat; return d->timestampFormat;
} }
EventTimingCodesFrame::SynchedEventList EventTimingCodesFrame::SynchedEventList
EventTimingCodesFrame::synchedEvents() const EventTimingCodesFrame::synchedEvents() const {
{
return d->synchedEvents; return d->synchedEvents;
} }
void EventTimingCodesFrame::setTimestampFormat( void EventTimingCodesFrame::setTimestampFormat(
EventTimingCodesFrame::TimestampFormat f) EventTimingCodesFrame::TimestampFormat f) {
{
d->timestampFormat = f; d->timestampFormat = f;
} }
void EventTimingCodesFrame::setSynchedEvents( void EventTimingCodesFrame::setSynchedEvents(
const EventTimingCodesFrame::SynchedEventList &e) const EventTimingCodesFrame::SynchedEventList &e) {
{
d->synchedEvents = e; d->synchedEvents = e;
} }
@@ -96,8 +84,7 @@ void EventTimingCodesFrame::setSynchedEvents(
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void EventTimingCodesFrame::parseFields(const ByteVector &data) void EventTimingCodesFrame::parseFields(const ByteVector &data) {
{
const int end = data.size(); const int end = data.size();
if (end < 1) { if (end < 1) {
debug("An event timing codes frame must contain at least 1 byte."); debug("An event timing codes frame must contain at least 1 byte.");
@@ -116,8 +103,7 @@ void EventTimingCodesFrame::parseFields(const ByteVector &data)
} }
} }
ByteVector EventTimingCodesFrame::renderFields() const ByteVector EventTimingCodesFrame::renderFields() const {
{
ByteVector v; ByteVector v;
v.append(char(d->timestampFormat)); v.append(char(d->timestampFormat));
@@ -136,9 +122,7 @@ ByteVector EventTimingCodesFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data, Header *h) : EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new EventTimingCodesFramePrivate()) {
d(new EventTimingCodesFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -38,12 +38,10 @@ namespace TagLib {
/*! /*!
* An implementation of ID3v2 event timing codes. * An implementation of ID3v2 event timing codes.
*/ */
class TAGLIB_EXPORT EventTimingCodesFrame : public Frame class TAGLIB_EXPORT EventTimingCodesFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
/*! /*!
* Specifies the timestamp format used. * Specifies the timestamp format used.
*/ */
@@ -181,7 +179,7 @@ namespace TagLib {
EventTimingCodesFramePrivate *d; EventTimingCodesFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -34,8 +34,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFramePrivate class GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFramePrivate {
{
public: public:
GeneralEncapsulatedObjectFramePrivate() : textEncoding(String::Latin1) {} GeneralEncapsulatedObjectFramePrivate() : textEncoding(String::Latin1) {}
@@ -50,26 +49,20 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame() : GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame() : Frame("GEOB"),
Frame("GEOB"), d(new GeneralEncapsulatedObjectFramePrivate()) {
d(new GeneralEncapsulatedObjectFramePrivate())
{
} }
GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data) : GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new GeneralEncapsulatedObjectFramePrivate()) {
d(new GeneralEncapsulatedObjectFramePrivate())
{
setData(data); setData(data);
} }
GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() {
{
delete d; delete d;
} }
String GeneralEncapsulatedObjectFrame::toString() const String GeneralEncapsulatedObjectFrame::toString() const {
{
String text = "[" + d->mimeType + "]"; String text = "[" + d->mimeType + "]";
if (!d->fileName.isEmpty()) if (!d->fileName.isEmpty())
@@ -81,53 +74,43 @@ String GeneralEncapsulatedObjectFrame::toString() const
return text; return text;
} }
String::Type GeneralEncapsulatedObjectFrame::textEncoding() const String::Type GeneralEncapsulatedObjectFrame::textEncoding() const {
{
return d->textEncoding; return d->textEncoding;
} }
void GeneralEncapsulatedObjectFrame::setTextEncoding(String::Type encoding) void GeneralEncapsulatedObjectFrame::setTextEncoding(String::Type encoding) {
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
String GeneralEncapsulatedObjectFrame::mimeType() const String GeneralEncapsulatedObjectFrame::mimeType() const {
{
return d->mimeType; return d->mimeType;
} }
void GeneralEncapsulatedObjectFrame::setMimeType(const String &type) void GeneralEncapsulatedObjectFrame::setMimeType(const String &type) {
{
d->mimeType = type; d->mimeType = type;
} }
String GeneralEncapsulatedObjectFrame::fileName() const String GeneralEncapsulatedObjectFrame::fileName() const {
{
return d->fileName; return d->fileName;
} }
void GeneralEncapsulatedObjectFrame::setFileName(const String &name) void GeneralEncapsulatedObjectFrame::setFileName(const String &name) {
{
d->fileName = name; d->fileName = name;
} }
String GeneralEncapsulatedObjectFrame::description() const String GeneralEncapsulatedObjectFrame::description() const {
{
return d->description; return d->description;
} }
void GeneralEncapsulatedObjectFrame::setDescription(const String &desc) void GeneralEncapsulatedObjectFrame::setDescription(const String &desc) {
{
d->description = desc; d->description = desc;
} }
ByteVector GeneralEncapsulatedObjectFrame::object() const ByteVector GeneralEncapsulatedObjectFrame::object() const {
{
return d->data; return d->data;
} }
void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data) void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data) {
{
d->data = data; d->data = data;
} }
@@ -135,8 +118,7 @@ void GeneralEncapsulatedObjectFrame::setObject(const ByteVector &data)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data) {
{
if (data.size() < 4) { if (data.size() < 4) {
debug("An object frame must contain at least 4 bytes."); debug("An object frame must contain at least 4 bytes.");
return; return;
@@ -153,8 +135,7 @@ void GeneralEncapsulatedObjectFrame::parseFields(const ByteVector &data)
d->data = data.mid(pos); d->data = data.mid(pos);
} }
ByteVector GeneralEncapsulatedObjectFrame::renderFields() const ByteVector GeneralEncapsulatedObjectFrame::renderFields() const {
{
StringList sl; StringList sl;
sl.append(d->fileName); sl.append(d->fileName);
sl.append(d->description); sl.append(d->description);
@@ -179,9 +160,7 @@ ByteVector GeneralEncapsulatedObjectFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h) : GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new GeneralEncapsulatedObjectFramePrivate()) {
d(new GeneralEncapsulatedObjectFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -49,12 +49,10 @@ namespace TagLib {
* uniquely identifies the GEOB frame in the tag. * uniquely identifies the GEOB frame in the tag.
*/ */
class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
/*! /*!
* Constructs an empty object frame. The description, file name and text * Constructs an empty object frame. The description, file name and text
* encoding should be set manually. * encoding should be set manually.
@@ -174,8 +172,8 @@ namespace TagLib {
class GeneralEncapsulatedObjectFramePrivate; class GeneralEncapsulatedObjectFramePrivate;
GeneralEncapsulatedObjectFramePrivate *d; GeneralEncapsulatedObjectFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -32,8 +32,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class OwnershipFrame::OwnershipFramePrivate class OwnershipFrame::OwnershipFramePrivate {
{
public: public:
String pricePaid; String pricePaid;
String datePurchased; String datePurchased;
@@ -45,67 +44,53 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
OwnershipFrame::OwnershipFrame(String::Type encoding) : OwnershipFrame::OwnershipFrame(String::Type encoding) : Frame("OWNE"),
Frame("OWNE"), d(new OwnershipFramePrivate()) {
d(new OwnershipFramePrivate())
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
OwnershipFrame::OwnershipFrame(const ByteVector &data) : OwnershipFrame::OwnershipFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new OwnershipFramePrivate()) {
d(new OwnershipFramePrivate())
{
setData(data); setData(data);
} }
OwnershipFrame::~OwnershipFrame() OwnershipFrame::~OwnershipFrame() {
{
delete d; delete d;
} }
String OwnershipFrame::toString() const String OwnershipFrame::toString() const {
{
return "pricePaid=" + d->pricePaid + " datePurchased=" + d->datePurchased + " seller=" + d->seller; return "pricePaid=" + d->pricePaid + " datePurchased=" + d->datePurchased + " seller=" + d->seller;
} }
String OwnershipFrame::pricePaid() const String OwnershipFrame::pricePaid() const {
{
return d->pricePaid; return d->pricePaid;
} }
void OwnershipFrame::setPricePaid(const String &s) void OwnershipFrame::setPricePaid(const String &s) {
{
d->pricePaid = s; d->pricePaid = s;
} }
String OwnershipFrame::datePurchased() const String OwnershipFrame::datePurchased() const {
{
return d->datePurchased; return d->datePurchased;
} }
void OwnershipFrame::setDatePurchased(const String &s) void OwnershipFrame::setDatePurchased(const String &s) {
{
d->datePurchased = s; d->datePurchased = s;
} }
String OwnershipFrame::seller() const String OwnershipFrame::seller() const {
{
return d->seller; return d->seller;
} }
void OwnershipFrame::setSeller(const String &s) void OwnershipFrame::setSeller(const String &s) {
{
d->seller = s; d->seller = s;
} }
String::Type OwnershipFrame::textEncoding() const String::Type OwnershipFrame::textEncoding() const {
{
return d->textEncoding; return d->textEncoding;
} }
void OwnershipFrame::setTextEncoding(String::Type encoding) void OwnershipFrame::setTextEncoding(String::Type encoding) {
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
@@ -113,8 +98,7 @@ void OwnershipFrame::setTextEncoding(String::Type encoding)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void OwnershipFrame::parseFields(const ByteVector &data) void OwnershipFrame::parseFields(const ByteVector &data) {
{
int pos = 0; int pos = 0;
// Get the text encoding // Get the text encoding
@@ -141,8 +125,7 @@ void OwnershipFrame::parseFields(const ByteVector &data)
d->seller = String(data.mid(pos), d->textEncoding); d->seller = String(data.mid(pos), d->textEncoding);
} }
ByteVector OwnershipFrame::renderFields() const ByteVector OwnershipFrame::renderFields() const {
{
StringList sl; StringList sl;
sl.append(d->seller); sl.append(d->seller);
@@ -163,9 +146,7 @@ ByteVector OwnershipFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
OwnershipFrame::OwnershipFrame(const ByteVector &data, Header *h) : OwnershipFrame::OwnershipFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new OwnershipFramePrivate()) {
d(new OwnershipFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -41,8 +41,7 @@ namespace TagLib {
* a price paid, a date purchased (YYYYMMDD) and the name of the seller. * a price paid, a date purchased (YYYYMMDD) and the name of the seller.
*/ */
class TAGLIB_EXPORT OwnershipFrame : public Frame class TAGLIB_EXPORT OwnershipFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -147,7 +146,7 @@ namespace TagLib {
OwnershipFramePrivate *d; OwnershipFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -28,8 +28,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class PodcastFrame::PodcastFramePrivate class PodcastFrame::PodcastFramePrivate {
{
public: public:
ByteVector fieldData; ByteVector fieldData;
}; };
@@ -38,20 +37,16 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PodcastFrame::PodcastFrame() : PodcastFrame::PodcastFrame() : Frame("PCST"),
Frame("PCST"), d(new PodcastFramePrivate()) {
d(new PodcastFramePrivate())
{
d->fieldData = ByteVector(4, '\0'); d->fieldData = ByteVector(4, '\0');
} }
PodcastFrame::~PodcastFrame() PodcastFrame::~PodcastFrame() {
{
delete d; delete d;
} }
String PodcastFrame::toString() const String PodcastFrame::toString() const {
{
return String(); return String();
} }
@@ -59,13 +54,11 @@ String PodcastFrame::toString() const
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void PodcastFrame::parseFields(const ByteVector &data) void PodcastFrame::parseFields(const ByteVector &data) {
{
d->fieldData = data; d->fieldData = data;
} }
ByteVector PodcastFrame::renderFields() const ByteVector PodcastFrame::renderFields() const {
{
return d->fieldData; return d->fieldData;
} }
@@ -73,9 +66,7 @@ ByteVector PodcastFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PodcastFrame::PodcastFrame(const ByteVector &data, Header *h) : PodcastFrame::PodcastFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new PodcastFramePrivate()) {
d(new PodcastFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -38,8 +38,7 @@ namespace TagLib {
/*! /*!
* An implementation of ID3v2 podcast flag, a frame with four zero bytes. * An implementation of ID3v2 podcast flag, a frame with four zero bytes.
*/ */
class TAGLIB_EXPORT PodcastFrame : public Frame class TAGLIB_EXPORT PodcastFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -76,7 +75,7 @@ namespace TagLib {
PodcastFramePrivate *d; PodcastFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -30,8 +30,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class PopularimeterFrame::PopularimeterFramePrivate class PopularimeterFrame::PopularimeterFramePrivate {
{
public: public:
PopularimeterFramePrivate() : rating(0), counter(0) {} PopularimeterFramePrivate() : rating(0), counter(0) {}
String email; String email;
@@ -43,56 +42,44 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PopularimeterFrame::PopularimeterFrame() : PopularimeterFrame::PopularimeterFrame() : Frame("POPM"),
Frame("POPM"), d(new PopularimeterFramePrivate()) {
d(new PopularimeterFramePrivate())
{
} }
PopularimeterFrame::PopularimeterFrame(const ByteVector &data) : PopularimeterFrame::PopularimeterFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new PopularimeterFramePrivate()) {
d(new PopularimeterFramePrivate())
{
setData(data); setData(data);
} }
PopularimeterFrame::~PopularimeterFrame() PopularimeterFrame::~PopularimeterFrame() {
{
delete d; delete d;
} }
String PopularimeterFrame::toString() const String PopularimeterFrame::toString() const {
{
return d->email + " rating=" + String::number(d->rating) + " counter=" + String::number(d->counter); return d->email + " rating=" + String::number(d->rating) + " counter=" + String::number(d->counter);
} }
String PopularimeterFrame::email() const String PopularimeterFrame::email() const {
{
return d->email; return d->email;
} }
void PopularimeterFrame::setEmail(const String &s) void PopularimeterFrame::setEmail(const String &s) {
{
d->email = s; d->email = s;
} }
int PopularimeterFrame::rating() const int PopularimeterFrame::rating() const {
{
return d->rating; return d->rating;
} }
void PopularimeterFrame::setRating(int s) void PopularimeterFrame::setRating(int s) {
{
d->rating = s; d->rating = s;
} }
unsigned int PopularimeterFrame::counter() const unsigned int PopularimeterFrame::counter() const {
{
return d->counter; return d->counter;
} }
void PopularimeterFrame::setCounter(unsigned int s) void PopularimeterFrame::setCounter(unsigned int s) {
{
d->counter = s; d->counter = s;
} }
@@ -100,8 +87,7 @@ void PopularimeterFrame::setCounter(unsigned int s)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void PopularimeterFrame::parseFields(const ByteVector &data) void PopularimeterFrame::parseFields(const ByteVector &data) {
{
int pos = 0, size = int(data.size()); int pos = 0, size = int(data.size());
d->email = readStringField(data, String::Latin1, &pos); d->email = readStringField(data, String::Latin1, &pos);
@@ -116,8 +102,7 @@ void PopularimeterFrame::parseFields(const ByteVector &data)
} }
} }
ByteVector PopularimeterFrame::renderFields() const ByteVector PopularimeterFrame::renderFields() const {
{
ByteVector data; ByteVector data;
data.append(d->email.data(String::Latin1)); data.append(d->email.data(String::Latin1));
@@ -132,9 +117,7 @@ ByteVector PopularimeterFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PopularimeterFrame::PopularimeterFrame(const ByteVector &data, Header *h) : PopularimeterFrame::PopularimeterFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new PopularimeterFramePrivate()) {
d(new PopularimeterFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -41,8 +41,7 @@ namespace TagLib {
* an email, a rating and an optional counter. * an email, a rating and an optional counter.
*/ */
class TAGLIB_EXPORT PopularimeterFrame : public Frame class TAGLIB_EXPORT PopularimeterFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -128,7 +127,7 @@ namespace TagLib {
PopularimeterFramePrivate *d; PopularimeterFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -34,8 +34,7 @@ using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class PrivateFrame::PrivateFramePrivate class PrivateFrame::PrivateFramePrivate {
{
public: public:
ByteVector data; ByteVector data;
String owner; String owner;
@@ -45,46 +44,36 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PrivateFrame::PrivateFrame() : PrivateFrame::PrivateFrame() : Frame("PRIV"),
Frame("PRIV"), d(new PrivateFramePrivate()) {
d(new PrivateFramePrivate())
{
} }
PrivateFrame::PrivateFrame(const ByteVector &data) : PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new PrivateFramePrivate()) {
d(new PrivateFramePrivate())
{
setData(data); setData(data);
} }
PrivateFrame::~PrivateFrame() PrivateFrame::~PrivateFrame() {
{
delete d; delete d;
} }
String PrivateFrame::toString() const String PrivateFrame::toString() const {
{
return d->owner; return d->owner;
} }
String PrivateFrame::owner() const String PrivateFrame::owner() const {
{
return d->owner; return d->owner;
} }
ByteVector PrivateFrame::data() const ByteVector PrivateFrame::data() const {
{
return d->data; return d->data;
} }
void PrivateFrame::setOwner(const String &s) void PrivateFrame::setOwner(const String &s) {
{
d->owner = s; d->owner = s;
} }
void PrivateFrame::setData(const ByteVector & data) void PrivateFrame::setData(const ByteVector &data) {
{
d->data = data; d->data = data;
} }
@@ -92,8 +81,7 @@ void PrivateFrame::setData(const ByteVector & data)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void PrivateFrame::parseFields(const ByteVector &data) void PrivateFrame::parseFields(const ByteVector &data) {
{
if (data.size() < 2) { if (data.size() < 2) {
debug("A private frame must contain at least 2 bytes."); debug("A private frame must contain at least 2 bytes.");
return; return;
@@ -108,8 +96,7 @@ void PrivateFrame::parseFields(const ByteVector &data)
d->data = data.mid(endOfOwner + 1); d->data = data.mid(endOfOwner + 1);
} }
ByteVector PrivateFrame::renderFields() const ByteVector PrivateFrame::renderFields() const {
{
ByteVector v; ByteVector v;
v.append(d->owner.data(String::Latin1)); v.append(d->owner.data(String::Latin1));
@@ -123,9 +110,7 @@ ByteVector PrivateFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new PrivateFramePrivate()) {
d(new PrivateFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -37,8 +37,7 @@ namespace TagLib {
//! An implementation of ID3v2 privateframe //! An implementation of ID3v2 privateframe
class TAGLIB_EXPORT PrivateFrame : public Frame class TAGLIB_EXPORT PrivateFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
@@ -107,7 +106,7 @@ namespace TagLib {
PrivateFramePrivate *d; PrivateFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -31,8 +31,7 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
struct ChannelData struct ChannelData {
{
ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {} ChannelData() : channelType(RelativeVolumeFrame::Other), volumeAdjustment(0) {}
RelativeVolumeFrame::ChannelType channelType; RelativeVolumeFrame::ChannelType channelType;
@@ -40,8 +39,7 @@ struct ChannelData
RelativeVolumeFrame::PeakVolume peakVolume; RelativeVolumeFrame::PeakVolume peakVolume;
}; };
class RelativeVolumeFrame::RelativeVolumeFramePrivate class RelativeVolumeFrame::RelativeVolumeFramePrivate {
{
public: public:
String identification; String identification;
Map<ChannelType, ChannelData> channels; Map<ChannelType, ChannelData> channels;
@@ -51,31 +49,24 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
RelativeVolumeFrame::RelativeVolumeFrame() : RelativeVolumeFrame::RelativeVolumeFrame() : Frame("RVA2"),
Frame("RVA2"), d(new RelativeVolumeFramePrivate()) {
d(new RelativeVolumeFramePrivate())
{
} }
RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data) : RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new RelativeVolumeFramePrivate()) {
d(new RelativeVolumeFramePrivate())
{
setData(data); setData(data);
} }
RelativeVolumeFrame::~RelativeVolumeFrame() RelativeVolumeFrame::~RelativeVolumeFrame() {
{
delete d; delete d;
} }
String RelativeVolumeFrame::toString() const String RelativeVolumeFrame::toString() const {
{
return d->identification; return d->identification;
} }
List<RelativeVolumeFrame::ChannelType> RelativeVolumeFrame::channels() const List<RelativeVolumeFrame::ChannelType> RelativeVolumeFrame::channels() const {
{
List<ChannelType> l; List<ChannelType> l;
Map<ChannelType, ChannelData>::ConstIterator it = d->channels.begin(); Map<ChannelType, ChannelData>::ConstIterator it = d->channels.begin();
@@ -87,85 +78,68 @@ List<RelativeVolumeFrame::ChannelType> RelativeVolumeFrame::channels() const
// deprecated // deprecated
RelativeVolumeFrame::ChannelType RelativeVolumeFrame::channelType() const RelativeVolumeFrame::ChannelType RelativeVolumeFrame::channelType() const {
{
return MasterVolume; return MasterVolume;
} }
// deprecated // deprecated
void RelativeVolumeFrame::setChannelType(ChannelType) void RelativeVolumeFrame::setChannelType(ChannelType) {
{
} }
short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const {
{
return d->channels.contains(type) ? d->channels[type].volumeAdjustment : 0; return d->channels.contains(type) ? d->channels[type].volumeAdjustment : 0;
} }
short RelativeVolumeFrame::volumeAdjustmentIndex() const short RelativeVolumeFrame::volumeAdjustmentIndex() const {
{
return volumeAdjustmentIndex(MasterVolume); return volumeAdjustmentIndex(MasterVolume);
} }
void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) {
{
d->channels[type].volumeAdjustment = index; d->channels[type].volumeAdjustment = index;
} }
void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) {
{
setVolumeAdjustmentIndex(index, MasterVolume); setVolumeAdjustmentIndex(index, MasterVolume);
} }
float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const {
{
return d->channels.contains(type) ? float(d->channels[type].volumeAdjustment) / float(512) : 0; return d->channels.contains(type) ? float(d->channels[type].volumeAdjustment) / float(512) : 0;
} }
float RelativeVolumeFrame::volumeAdjustment() const float RelativeVolumeFrame::volumeAdjustment() const {
{
return volumeAdjustment(MasterVolume); return volumeAdjustment(MasterVolume);
} }
void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) {
{
d->channels[type].volumeAdjustment = short(adjustment * float(512)); d->channels[type].volumeAdjustment = short(adjustment * float(512));
} }
void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) {
{
setVolumeAdjustment(adjustment, MasterVolume); setVolumeAdjustment(adjustment, MasterVolume);
} }
RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const {
{
return d->channels.contains(type) ? d->channels[type].peakVolume : PeakVolume(); return d->channels.contains(type) ? d->channels[type].peakVolume : PeakVolume();
} }
RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const {
{
return peakVolume(MasterVolume); return peakVolume(MasterVolume);
} }
void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) {
{
d->channels[type].peakVolume = peak; d->channels[type].peakVolume = peak;
} }
void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) {
{
setPeakVolume(peak, MasterVolume); setPeakVolume(peak, MasterVolume);
} }
String RelativeVolumeFrame::identification() const String RelativeVolumeFrame::identification() const {
{
return d->identification; return d->identification;
} }
void RelativeVolumeFrame::setIdentification(const String &s) void RelativeVolumeFrame::setIdentification(const String &s) {
{
d->identification = s; d->identification = s;
} }
@@ -173,8 +147,7 @@ void RelativeVolumeFrame::setIdentification(const String &s)
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RelativeVolumeFrame::parseFields(const ByteVector &data) void RelativeVolumeFrame::parseFields(const ByteVector &data) {
{
int pos = 0; int pos = 0;
d->identification = readStringField(data, String::Latin1, &pos); d->identification = readStringField(data, String::Latin1, &pos);
@@ -199,8 +172,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data)
} }
} }
ByteVector RelativeVolumeFrame::renderFields() const ByteVector RelativeVolumeFrame::renderFields() const {
{
ByteVector data; ByteVector data;
data.append(d->identification.data(String::Latin1)); data.append(d->identification.data(String::Latin1));
@@ -225,9 +197,7 @@ ByteVector RelativeVolumeFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data, Header *h) : RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new RelativeVolumeFramePrivate()) {
d(new RelativeVolumeFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -47,12 +47,10 @@ namespace TagLib {
* different channel types. * different channel types.
*/ */
class TAGLIB_EXPORT RelativeVolumeFrame : public Frame class TAGLIB_EXPORT RelativeVolumeFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
/*! /*!
* This indicates the type of volume adjustment that should be applied. * This indicates the type of volume adjustment that should be applied.
*/ */
@@ -83,8 +81,7 @@ namespace TagLib {
* The peak volume is described as a series of bits that is padded to fill * The peak volume is described as a series of bits that is padded to fill
* a block of bytes. These two values should always be updated in tandem. * a block of bytes. These two values should always be updated in tandem.
*/ */
struct PeakVolume struct PeakVolume {
{
/*! /*!
* Constructs an empty peak volume description. * Constructs an empty peak volume description.
*/ */
@@ -270,7 +267,7 @@ namespace TagLib {
RelativeVolumeFramePrivate *d; RelativeVolumeFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

View File

@@ -32,11 +32,9 @@
using namespace Strawberry_TagLib::TagLib; using namespace Strawberry_TagLib::TagLib;
using namespace ID3v2; using namespace ID3v2;
class SynchronizedLyricsFrame::SynchronizedLyricsFramePrivate class SynchronizedLyricsFrame::SynchronizedLyricsFramePrivate {
{
public: public:
SynchronizedLyricsFramePrivate() : SynchronizedLyricsFramePrivate() : textEncoding(String::Latin1),
textEncoding(String::Latin1),
timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds), timestampFormat(SynchronizedLyricsFrame::AbsoluteMilliseconds),
type(SynchronizedLyricsFrame::Lyrics) {} type(SynchronizedLyricsFrame::Lyrics) {}
String::Type textEncoding; String::Type textEncoding;
@@ -51,90 +49,72 @@ public:
// public members // public members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SynchronizedLyricsFrame::SynchronizedLyricsFrame(String::Type encoding) : SynchronizedLyricsFrame::SynchronizedLyricsFrame(String::Type encoding) : Frame("SYLT"),
Frame("SYLT"), d(new SynchronizedLyricsFramePrivate()) {
d(new SynchronizedLyricsFramePrivate())
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data) : SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data) : Frame(data),
Frame(data), d(new SynchronizedLyricsFramePrivate()) {
d(new SynchronizedLyricsFramePrivate())
{
setData(data); setData(data);
} }
SynchronizedLyricsFrame::~SynchronizedLyricsFrame() SynchronizedLyricsFrame::~SynchronizedLyricsFrame() {
{
delete d; delete d;
} }
String SynchronizedLyricsFrame::toString() const String SynchronizedLyricsFrame::toString() const {
{
return d->description; return d->description;
} }
String::Type SynchronizedLyricsFrame::textEncoding() const String::Type SynchronizedLyricsFrame::textEncoding() const {
{
return d->textEncoding; return d->textEncoding;
} }
ByteVector SynchronizedLyricsFrame::language() const ByteVector SynchronizedLyricsFrame::language() const {
{
return d->language; return d->language;
} }
SynchronizedLyricsFrame::TimestampFormat SynchronizedLyricsFrame::TimestampFormat
SynchronizedLyricsFrame::timestampFormat() const SynchronizedLyricsFrame::timestampFormat() const {
{
return d->timestampFormat; return d->timestampFormat;
} }
SynchronizedLyricsFrame::Type SynchronizedLyricsFrame::type() const SynchronizedLyricsFrame::Type SynchronizedLyricsFrame::type() const {
{
return d->type; return d->type;
} }
String SynchronizedLyricsFrame::description() const String SynchronizedLyricsFrame::description() const {
{
return d->description; return d->description;
} }
SynchronizedLyricsFrame::SynchedTextList SynchronizedLyricsFrame::SynchedTextList
SynchronizedLyricsFrame::synchedText() const SynchronizedLyricsFrame::synchedText() const {
{
return d->synchedText; return d->synchedText;
} }
void SynchronizedLyricsFrame::setTextEncoding(String::Type encoding) void SynchronizedLyricsFrame::setTextEncoding(String::Type encoding) {
{
d->textEncoding = encoding; d->textEncoding = encoding;
} }
void SynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) void SynchronizedLyricsFrame::setLanguage(const ByteVector &languageEncoding) {
{
d->language = languageEncoding.mid(0, 3); d->language = languageEncoding.mid(0, 3);
} }
void SynchronizedLyricsFrame::setTimestampFormat(SynchronizedLyricsFrame::TimestampFormat f) void SynchronizedLyricsFrame::setTimestampFormat(SynchronizedLyricsFrame::TimestampFormat f) {
{
d->timestampFormat = f; d->timestampFormat = f;
} }
void SynchronizedLyricsFrame::setType(SynchronizedLyricsFrame::Type t) void SynchronizedLyricsFrame::setType(SynchronizedLyricsFrame::Type t) {
{
d->type = t; d->type = t;
} }
void SynchronizedLyricsFrame::setDescription(const String &s) void SynchronizedLyricsFrame::setDescription(const String &s) {
{
d->description = s; d->description = s;
} }
void SynchronizedLyricsFrame::setSynchedText( void SynchronizedLyricsFrame::setSynchedText(
const SynchronizedLyricsFrame::SynchedTextList &t) const SynchronizedLyricsFrame::SynchedTextList &t) {
{
d->synchedText = t; d->synchedText = t;
} }
@@ -142,8 +122,7 @@ void SynchronizedLyricsFrame::setSynchedText(
// protected members // protected members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void SynchronizedLyricsFrame::parseFields(const ByteVector &data) void SynchronizedLyricsFrame::parseFields(const ByteVector &data) {
{
const int end = data.size(); const int end = data.size();
if (end < 7) { if (end < 7) {
debug("A synchronized lyrics frame must contain at least 7 bytes."); debug("A synchronized lyrics frame must contain at least 7 bytes.");
@@ -173,7 +152,8 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data)
unsigned short bom = data.toUShort(6, true); unsigned short bom = data.toUShort(6, true);
if (bom == 0xfffe) { if (bom == 0xfffe) {
encWithEndianness = String::UTF16LE; encWithEndianness = String::UTF16LE;
} else if(bom == 0xfeff) { }
else if (bom == 0xfeff) {
encWithEndianness = String::UTF16BE; encWithEndianness = String::UTF16BE;
} }
} }
@@ -199,8 +179,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data)
} }
} }
ByteVector SynchronizedLyricsFrame::renderFields() const ByteVector SynchronizedLyricsFrame::renderFields() const {
{
ByteVector v; ByteVector v;
String::Type encoding = d->textEncoding; String::Type encoding = d->textEncoding;
@@ -234,9 +213,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const
// private members // private members
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data, Header *h) : SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data, Header *h) : Frame(h),
Frame(h), d(new SynchronizedLyricsFramePrivate()) {
d(new SynchronizedLyricsFramePrivate())
{
parseFields(fieldData(data)); parseFields(fieldData(data));
} }

View File

@@ -38,12 +38,10 @@ namespace TagLib {
/*! /*!
* An implementation of ID3v2 synchronized lyrics. * An implementation of ID3v2 synchronized lyrics.
*/ */
class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame {
{
friend class FrameFactory; friend class FrameFactory;
public: public:
/*! /*!
* Specifies the timestamp format used. * Specifies the timestamp format used.
*/ */
@@ -227,7 +225,7 @@ namespace TagLib {
SynchronizedLyricsFramePrivate *d; SynchronizedLyricsFramePrivate *d;
}; };
} } // namespace ID3v2
} } // namespace TagLib
} } // namespace Strawberry_TagLib
#endif #endif

Some files were not shown because too many files have changed in this diff Show More