aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukáš Lalinský <lalinsky@gmail.com>2011-04-05 15:16:17 +0200
committerLukáš Lalinský <lalinsky@gmail.com>2011-04-05 15:16:17 +0200
commitaa57db3a391d6a00473e006431b6acb78bfd47b9 (patch)
tree868bb4a922a90eb41be9c145a806522f9302a5ec
parentf9d38129b84bb3f9e3476238cba53d77f2fa26ca (diff)
Convert frames TIPL and TMCL (2.4) to IPLS (2.3)
-rw-r--r--taglib/mpeg/id3v2/id3v2framefactory.cpp2
-rw-r--r--taglib/mpeg/id3v2/id3v2tag.cpp36
-rw-r--r--tests/test_id3v2.cpp17
3 files changed, 50 insertions, 5 deletions
diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp
index 356d60d4..77bd85d5 100644
--- a/taglib/mpeg/id3v2/id3v2framefactory.cpp
+++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp
@@ -153,7 +153,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader)
// Text Identification (frames 4.2)
- if(frameID.startsWith("T")) {
+ if(frameID.startsWith("T") || frameID == "IPLS") {
TextIdentificationFrame *f = frameID != "TXXX"
? new TextIdentificationFrame(data, header)
diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp
index 7286d3c1..8a27a20e 100644
--- a/taglib/mpeg/id3v2/id3v2tag.cpp
+++ b/taglib/mpeg/id3v2/id3v2tag.cpp
@@ -338,11 +338,12 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
{
const char *unsupportedFrames[] = {
"ASPI", "EQU2", "RVA2", "SEEK", "SIGN", "TDRL", "TDTG",
- "TMOO", "TPRO", "TSOA", "TSOT", "TSST", "TSOP", "TIPL",
- "TMCL", 0
+ "TMOO", "TPRO", "TSOA", "TSOT", "TSST", "TSOP", 0
};
ID3v2::TextIdentificationFrame *frameTDOR = 0;
ID3v2::TextIdentificationFrame *frameTDRC = 0;
+ ID3v2::TextIdentificationFrame *frameTIPL = 0;
+ ID3v2::TextIdentificationFrame *frameTMCL = 0;
for(FrameList::Iterator it = d->frameList.begin(); it != d->frameList.end(); it++) {
ID3v2::Frame *frame = *it;
ByteVector frameID = frame->header()->frameID();
@@ -362,6 +363,14 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
frameTDRC = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
frame = 0;
}
+ if(frame && frameID == "TIPL") {
+ frameTIPL = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
+ frame = 0;
+ }
+ if(frame && frameID == "TMCL") {
+ frameTMCL = dynamic_cast<ID3v2::TextIdentificationFrame *>(frame);
+ frame = 0;
+ }
if(frame) {
frames->append(frame);
}
@@ -376,7 +385,6 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
}
}
if(frameTDRC) {
- // FIXME we can do better here, define also TDAT and TIME
String content = frameTDRC->toString();
if(content.size() >= 4) {
ID3v2::TextIdentificationFrame *frameTYER = new ID3v2::TextIdentificationFrame("TYER", String::Latin1);
@@ -397,7 +405,27 @@ void ID3v2::Tag::downgradeFrames(FrameList *frames, FrameList *newFrames) const
}
}
}
- // FIXME migrate TIPL and TMCL to IPLS
+ if(frameTIPL || frameTMCL) {
+ ID3v2::TextIdentificationFrame *frameIPLS = new ID3v2::TextIdentificationFrame("IPLS", String::Latin1);
+ StringList people;
+ if(frameTMCL) {
+ StringList v24People = frameTMCL->fieldList();
+ for(uint i = 0; i + 1 < v24People.size(); i += 2) {
+ people.append(v24People[i]);
+ people.append(v24People[i+1]);
+ }
+ }
+ if(frameTIPL) {
+ StringList v24People = frameTIPL->fieldList();
+ for(uint i = 0; i + 1 < v24People.size(); i += 2) {
+ people.append(v24People[i]);
+ people.append(v24People[i+1]);
+ }
+ }
+ frameIPLS->setText(people);
+ frames->append(frameIPLS);
+ newFrames->append(frameIPLS);
+ }
}
diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp
index d3adc632..440e4f1e 100644
--- a/tests/test_id3v2.cpp
+++ b/tests/test_id3v2.cpp
@@ -488,6 +488,12 @@ public:
tf = new ID3v2::TextIdentificationFrame("TDRC", String::Latin1);
tf->setText("2012-04-17T12:01");
foo.ID3v2Tag()->addFrame(tf);
+ tf = new ID3v2::TextIdentificationFrame("TMCL", String::Latin1);
+ tf->setText(StringList().append("Guitar").append("Artist 1").append("Drums").append("Artist 2"));
+ foo.ID3v2Tag()->addFrame(tf);
+ tf = new ID3v2::TextIdentificationFrame("TIPL", String::Latin1);
+ tf->setText(StringList().append("Producer").append("Artist 3").append("Mastering").append("Artist 4"));
+ foo.ID3v2Tag()->addFrame(tf);
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TDRL", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TDTG", String::Latin1));
foo.ID3v2Tag()->addFrame(new ID3v2::TextIdentificationFrame("TMOO", String::Latin1));
@@ -507,6 +513,17 @@ public:
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size());
CPPUNIT_ASSERT_EQUAL(String("2012"), tf->fieldList().front());
+ tf = dynamic_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("IPLS").front());
+ CPPUNIT_ASSERT(tf);
+ CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), tf->fieldList().size());
+ CPPUNIT_ASSERT_EQUAL(String("Guitar"), tf->fieldList()[0]);
+ CPPUNIT_ASSERT_EQUAL(String("Artist 1"), tf->fieldList()[1]);
+ CPPUNIT_ASSERT_EQUAL(String("Drums"), tf->fieldList()[2]);
+ CPPUNIT_ASSERT_EQUAL(String("Artist 2"), tf->fieldList()[3]);
+ CPPUNIT_ASSERT_EQUAL(String("Producer"), tf->fieldList()[4]);
+ CPPUNIT_ASSERT_EQUAL(String("Artist 3"), tf->fieldList()[5]);
+ CPPUNIT_ASSERT_EQUAL(String("Mastering"), tf->fieldList()[6]);
+ CPPUNIT_ASSERT_EQUAL(String("Artist 4"), tf->fieldList()[7]);
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TDRL"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TDTG"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TMOO"));