return new UnknownFrame(data, header);
}
+void FrameFactory::rebuildAggregateFrames(Tag *tag) const
+{
+ if(tag->header()->majorVersion() < 4 &&
+ tag->frameList("TDRC").size() == 1 &&
+ tag->frameList("TDAT").size() == 1)
+ {
+ TextIdentificationFrame *trdc =
+ static_cast<TextIdentificationFrame *>(tag->frameList("TDRC").front());
+ UnknownFrame *tdat =
+ static_cast<UnknownFrame *>(tag->frameList("TDAT").front());
+
+ if(trdc->fieldList().size() == 1 &&
+ trdc->fieldList().front().size() == 4 &&
+ tdat->data().size() >= 5)
+ {
+ String date(tdat->data().mid(1), String::Type(tdat->data()[0]));
+ if(date.length() == 4)
+ trdc->setText(trdc->toString() + '-' + date.substr(2, 2) + '-' + date.substr(0, 2));
+ }
+ }
+}
+
String::Type FrameFactory::defaultTextEncoding() const
{
return d->defaultEncoding;
// BIC: make virtual
Frame *createFrame(const ByteVector &data, Header *tagHeader) const;
+ /*!
+ * After a tag has been read, this tries to rebuild some of them
+ * information, most notably the recording date, from frames that
+ * have been deprecated and can't be upgraded directly.
+ */
+ // BIC: Make virtual
+ void rebuildAggregateFrames(Tag *tag) const;
+
/*!
* Returns the default text encoding for text frames. If setTextEncoding()
* has not been explicitly called this will only be used for new text
}
d->paddingSize = frameDataLength - frameDataPosition;
- return;
+ break;
}
Frame *frame = d->factory->createFrame(data.mid(frameDataPosition),
frameDataPosition += frame->size() + Frame::headerSize(d->header.majorVersion());
addFrame(frame);
}
+
+ d->factory->rebuildAggregateFrames(this);
}
void ID3v2::Tag::setTextFrame(const ByteVector &id, const String &value)
tf = static_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TDRC").front());
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), tf->fieldList().size());
- CPPUNIT_ASSERT_EQUAL(String("2012"), tf->fieldList().front());
+ CPPUNIT_ASSERT_EQUAL(String("2012-04-17"), tf->fieldList().front());
tf = dynamic_cast<ID3v2::TextIdentificationFrame *>(bar.ID3v2Tag()->frameList("TIPL").front());
CPPUNIT_ASSERT(tf);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(8), tf->fieldList().size());