Commit a86437b7 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

Support patched TagLib which does not remove known iTunes atoms in M4A files.

parent a7886fa4
......@@ -163,6 +163,15 @@ if(WITH_TAGLIB)
endif (NOT HAVE_TAGLIB)
endif (WIN32)
endif(WITH_TAGLIB)
if (TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TAGLIB_LIBRARIES})
set(_CMAKE_REQUIRED_DEFINITIONS_TMP ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${TAGLIB_CFLAGS})
CHECK_CXX_SOURCE_COMPILES("#include <mp4file.h>\nint main() {\n TagLib::MP4::Item item;\n item.toUInt();\n return 0;\n}\n" HAVE_TAGLIB_MP4_UINTTYPES)
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_TMP})
endif (TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
### Check for mp4v2
set(MP4V2_LIBRARIES)
......
......@@ -199,6 +199,239 @@ diff -ru id3lib-3.8.3.orig/include/id3/globals.h id3lib-3.8.3/include/id3/global
# define LINKOPTION_USE_DYNAMIC 3 //if your project links id3lib dynamic
EOF
test -f taglib-mp4-uinttypes.patch ||
cat >taglib-mp4-uinttypes.patch <<"EOF"
diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp
index 7dcf594..7d95079 100644
--- a/taglib/mp4/mp4item.cpp
+++ b/taglib/mp4/mp4item.cpp
@@ -45,6 +45,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;
@@ -91,6 +94,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;
@@ -122,6 +143,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 3158b4d..243a099 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 d7933db..a2f5d1f 100644
--- a/taglib/mp4/mp4tag.cpp
+++ b/taglib/mp4/mp4tag.cpp
@@ -68,12 +68,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);
}
@@ -138,6 +149,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)
{
ByteVectorList data = parseData(atom, file);
@@ -263,6 +301,30 @@ MP4::Tag::renderInt(const ByteVector &name, MP4::Item &item)
}
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)
{
ByteVectorList data;
@@ -339,12 +401,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 3e6d667..d0ff728 100644
--- a/taglib/mp4/mp4tag.h
+++ b/taglib/mp4/mp4tag.h
@@ -71,6 +71,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);
@@ -83,6 +86,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);
EOF
cd ..
......@@ -266,6 +499,7 @@ tar xzf source/taglib_1.7.orig.tar.gz
cd taglib-1.7/
tar xzf ../source/taglib_1.7-1.debian.tar.gz
for f in $(cat debian/patches/series); do patch -p1 <debian/patches/$f; done
patch -p1 <../source/taglib-mp4-uinttypes.patch
cd ..
fi
......
......@@ -10,6 +10,7 @@
/* Define if you have TagLib installed */
#cmakedefine HAVE_TAGLIB 1
#cmakedefine HAVE_TAGLIB_MP4_UINTTYPES 1
/* Define if you have mp4v2 installed */
#cmakedefine HAVE_MP4V2 1
......
......@@ -2958,7 +2958,10 @@ enum Mp4ValueType {
MVT_String,
MVT_Bool,
MVT_Int,
MVT_IntPair
MVT_IntPair,
MVT_Byte,
MVT_UInt,
MVT_LongLong
};
/** MP4 name, frame type and value type. */
......@@ -2992,8 +2995,8 @@ static const Mp4NameTypeValue mp4NameTypeValues[] = {
{ "tvsh", Frame::FT_Other, MVT_String },
{ "tvnn", Frame::FT_Other, MVT_String },
{ "tven", Frame::FT_Other, MVT_String },
{ "tvsn", Frame::FT_Other, MVT_ByteArray },
{ "tves", Frame::FT_Other, MVT_ByteArray },
{ "tvsn", Frame::FT_Other, MVT_UInt },
{ "tves", Frame::FT_Other, MVT_UInt },
{ "desc", Frame::FT_Other, MVT_String },
{ "ldes", Frame::FT_Other, MVT_String },
{ "sonm", Frame::FT_Other, MVT_String },
......@@ -3007,16 +3010,16 @@ static const Mp4NameTypeValue mp4NameTypeValues[] = {
{ "pcst", Frame::FT_Other, MVT_Bool },
{ "keyw", Frame::FT_Other, MVT_String },
{ "catg", Frame::FT_Other, MVT_String },
{ "hdvd", Frame::FT_Other, MVT_ByteArray },
{ "stik", Frame::FT_Other, MVT_ByteArray },
{ "rtng", Frame::FT_Other, MVT_ByteArray },
{ "hdvd", Frame::FT_Other, MVT_Bool },
{ "stik", Frame::FT_Other, MVT_Byte },
{ "rtng", Frame::FT_Other, MVT_Byte },
{ "apID", Frame::FT_Other, MVT_String },
{ "akID", Frame::FT_Other, MVT_ByteArray },
{ "sfID", Frame::FT_Other, MVT_ByteArray },
{ "cnID", Frame::FT_Other, MVT_ByteArray },
{ "atID", Frame::FT_Other, MVT_ByteArray },
{ "plID", Frame::FT_Other, MVT_ByteArray },
{ "geID", Frame::FT_Other, MVT_ByteArray },
{ "akID", Frame::FT_Other, MVT_Byte },
{ "sfID", Frame::FT_Other, MVT_UInt },
{ "cnID", Frame::FT_Other, MVT_UInt },
{ "atID", Frame::FT_Other, MVT_UInt },
{ "plID", Frame::FT_Other, MVT_LongLong },
{ "geID", Frame::FT_Other, MVT_UInt },
#if TAGLIB_VERSION >= 0x010602
{ "covr", Frame::FT_Picture, MVT_CoverArt },
#else
......@@ -3217,6 +3220,14 @@ static TagLib::MP4::Item getMp4ItemForFrame(const Frame& frame, TagLib::String&
coverArtList.append(coverArt);
return TagLib::MP4::Item(coverArtList);
}
#endif
#ifdef HAVE_TAGLIB_MP4_UINTTYPES
case MVT_Byte:
return TagLib::MP4::Item(static_cast<uchar>(frame.getValue().toInt()));
case MVT_UInt:
return TagLib::MP4::Item(frame.getValue().toUInt());
case MVT_LongLong:
return TagLib::MP4::Item(frame.getValue().toLongLong());
#endif
case MVT_ByteArray:
default:
......@@ -4408,6 +4419,17 @@ void TagLibFile::getAllFramesV2(FrameCollection& frames)
}
break;
}
#endif
#ifdef HAVE_TAGLIB_MP4_UINTTYPES
case MVT_Byte:
value.setNum((*it).second.toByte());
break;
case MVT_UInt:
value.setNum((*it).second.toUInt());
break;
case MVT_LongLong:
value.setNum((*it).second.toLongLong());
break;
#endif
case MVT_ByteArray:
default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment