diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp index d51a487c..876fac4d 100644 --- a/taglib/mp4/mp4item.cpp +++ b/taglib/mp4/mp4item.cpp @@ -43,6 +43,9 @@ public: bool m_bool; int m_int; IntPair m_intPair; + uchar m_byte; + uint m_uint; + long long m_longlong; }; StringList m_stringList; MP4::CoverArtList m_coverArtList; @@ -89,6 +92,24 @@ MP4::Item::Item(int value) d->m_int = value; } +MP4::Item::Item(uchar value) +{ + d = new ItemPrivate; + d->m_byte = value; +} + +MP4::Item::Item(uint value) +{ + d = new ItemPrivate; + d->m_uint = value; +} + +MP4::Item::Item(long long value) +{ + d = new ItemPrivate; + d->m_longlong = value; +} + MP4::Item::Item(int value1, int value2) { d = new ItemPrivate; @@ -120,6 +141,24 @@ MP4::Item::toInt() const return d->m_int; } +uchar +MP4::Item::toByte() const +{ + return d->m_byte; +} + +TagLib::uint +MP4::Item::toUInt() const +{ + return d->m_uint; +} + +long long +MP4::Item::toLongLong() const +{ + return d->m_longlong; +} + MP4::Item::IntPair MP4::Item::toIntPair() const { diff --git a/taglib/mp4/mp4item.h b/taglib/mp4/mp4item.h index 3158b4dd..243a0998 100644 --- a/taglib/mp4/mp4item.h +++ b/taglib/mp4/mp4item.h @@ -47,12 +47,18 @@ namespace TagLib { ~Item(); Item(int value); + Item(uchar value); + Item(uint value); + Item(long long value); Item(bool value); Item(int first, int second); Item(const StringList &value); Item(const CoverArtList &value); int toInt() const; + uchar toByte() const; + uint toUInt() const; + long long toLongLong() const; bool toBool() const; IntPair toIntPair() const; StringList toStringList() const; diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 4e2d0211..8d2283ab 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -71,12 +71,23 @@ MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms) else if(atom->name == "trkn" || atom->name == "disk") { parseIntPair(atom, file); } - else if(atom->name == "cpil" || atom->name == "pgap" || atom->name == "pcst") { + else if(atom->name == "cpil" || atom->name == "pgap" || atom->name == "pcst" || + atom->name == "hdvd") { parseBool(atom, file); } else if(atom->name == "tmpo") { parseInt(atom, file); } + else if(atom->name == "tvsn" || atom->name == "tves" || atom->name == "cnID" || + atom->name == "sfID" || atom->name == "atID" || atom->name == "geID") { + parseUInt(atom, file); + } + else if(atom->name == "plID") { + parseLongLong(atom, file); + } + else if(atom->name == "stik" || atom->name == "rtng" || atom->name == "akID") { + parseByte(atom, file); + } else if(atom->name == "gnre") { parseGnre(atom, file); } @@ -140,6 +151,33 @@ MP4::Tag::parseInt(MP4::Atom *atom, TagLib::File *file) } } +void +MP4::Tag::parseUInt(MP4::Atom *atom, TagLib::File *file) +{ + ByteVectorList data = parseData(atom, file); + if(data.size()) { + d->items.insert(atom->name, data[0].toUInt()); + } +} + +void +MP4::Tag::parseLongLong(MP4::Atom *atom, TagLib::File *file) +{ + ByteVectorList data = parseData(atom, file); + if(data.size()) { + d->items.insert(atom->name, data[0].toLongLong()); + } +} + +void +MP4::Tag::parseByte(MP4::Atom *atom, TagLib::File *file) +{ + ByteVectorList data = parseData(atom, file); + if(data.size()) { + d->items.insert(atom->name, (uchar)data[0].at(0)); + } +} + void MP4::Tag::parseGnre(MP4::Atom *atom, TagLib::File *file) { @@ -265,6 +303,30 @@ MP4::Tag::renderInt(const ByteVector &name, MP4::Item &item) return renderData(name, 0x15, data); } +ByteVector +MP4::Tag::renderUInt(const ByteVector &name, MP4::Item &item) +{ + ByteVectorList data; + data.append(ByteVector::fromUInt(item.toUInt())); + return renderData(name, 0x15, data); +} + +ByteVector +MP4::Tag::renderLongLong(const ByteVector &name, MP4::Item &item) +{ + ByteVectorList data; + data.append(ByteVector::fromLongLong(item.toLongLong())); + return renderData(name, 0x15, data); +} + +ByteVector +MP4::Tag::renderByte(const ByteVector &name, MP4::Item &item) +{ + ByteVectorList data; + data.append(ByteVector(1, item.toByte())); + return renderData(name, 0x15, data); +} + ByteVector MP4::Tag::renderIntPair(const ByteVector &name, MP4::Item &item) { @@ -342,12 +404,22 @@ MP4::Tag::save() else if(name == "disk") { data.append(renderIntPairNoTrailing(name.data(String::Latin1), i->second)); } - else if(name == "cpil" || name == "pgap" || name == "pcst") { + else if(name == "cpil" || name == "pgap" || name == "pcst" || name == "hdvd") { data.append(renderBool(name.data(String::Latin1), i->second)); } else if(name == "tmpo") { data.append(renderInt(name.data(String::Latin1), i->second)); } + else if(name == "tvsn" || name == "tves" || name == "cnID" || + name == "sfID" || name == "atID" || name == "geID") { + data.append(renderUInt(name.data(String::Latin1), i->second)); + } + else if(name == "plID") { + data.append(renderLongLong(name.data(String::Latin1), i->second)); + } + else if(name == "stik" || name == "rtng" || name == "akID") { + data.append(renderByte(name.data(String::Latin1), i->second)); + } else if(name == "covr") { data.append(renderCovr(name.data(String::Latin1), i->second)); } diff --git a/taglib/mp4/mp4tag.h b/taglib/mp4/mp4tag.h index 2c8b2df8..433edf8a 100644 --- a/taglib/mp4/mp4tag.h +++ b/taglib/mp4/mp4tag.h @@ -72,6 +72,9 @@ namespace TagLib { void parseText(Atom *atom, TagLib::File *file, int expectedFlags = 1); void parseFreeForm(Atom *atom, TagLib::File *file); void parseInt(Atom *atom, TagLib::File *file); + void parseByte(Atom *atom, TagLib::File *file); + void parseUInt(Atom *atom, TagLib::File *file); + void parseLongLong(Atom *atom, TagLib::File *file); void parseGnre(Atom *atom, TagLib::File *file); void parseIntPair(Atom *atom, TagLib::File *file); void parseBool(Atom *atom, TagLib::File *file); @@ -84,6 +87,9 @@ namespace TagLib { TagLib::ByteVector renderFreeForm(const String &name, Item &item); TagLib::ByteVector renderBool(const ByteVector &name, Item &item); TagLib::ByteVector renderInt(const ByteVector &name, Item &item); + TagLib::ByteVector renderByte(const ByteVector &name, Item &item); + TagLib::ByteVector renderUInt(const ByteVector &name, Item &item); + TagLib::ByteVector renderLongLong(const ByteVector &name, Item &item); TagLib::ByteVector renderIntPair(const ByteVector &name, Item &item); TagLib::ByteVector renderIntPairNoTrailing(const ByteVector &name, Item &item); TagLib::ByteVector renderCovr(const ByteVector &name, Item &item);