frameSize(0),
version(4),
tagAlterPreservation(false),
- frameAlterPreservation(false),
+ fileAlterPreservation(false),
readOnly(false),
groupingIdentity(false),
compression(false),
// flags
bool tagAlterPreservation;
- bool frameAlterPreservation;
+ bool fileAlterPreservation;
bool readOnly;
bool groupingIdentity;
bool compression;
case 1:
case 2:
{
-
// ID3v2.2
if(data.size() < 3) {
break;
}
case 3:
+ {
+ // ID3v2.3
+
+ if(data.size() < 4) {
+ debug("You must at least specify a frame ID.");
+ return;
+ }
+
+ // Set the frame ID -- the first four bytes
+
+ d->frameID = data.mid(0, 4);
+
+ // If the full header information was not passed in, do not continue to the
+ // steps to parse the frame size and flags.
+
+ if(data.size() < 10) {
+ d->frameSize = 0;
+ return;
+ }
+
+ // Set the size -- the frame size is the four bytes starting at byte four in
+ // the frame header (structure 4)
+
+ d->frameSize = data.mid(4, 4).toUInt();
+
+ { // read the first byte of flags
+ std::bitset<8> flags(data[8]);
+ d->tagAlterPreservation = flags[7]; // (structure 3.3.1.a)
+ d->fileAlterPreservation = flags[6]; // (structure 3.3.1.b)
+ d->readOnly = flags[5]; // (structure 3.3.1.c)
+ }
+
+ { // read the second byte of flags
+ std::bitset<8> flags(data[9]);
+ d->compression = flags[7]; // (structure 3.3.1.i)
+ d->encryption = flags[6]; // (structure 3.3.1.j)
+ d->groupingIdentity = flags[5]; // (structure 3.3.1.k)
+ }
+ break;
+ }
case 4:
default:
{
- // ID3v2.3 / ID3v2.4
+ // ID3v2.4
if(data.size() < 4) {
debug("You must at least specify a frame ID.");
// Set the size -- the frame size is the four bytes starting at byte four in
// the frame header (structure 4)
- if(version >= 4)
- d->frameSize = SynchData::toUInt(data.mid(4, 4));
- else
- d->frameSize = data.mid(4, 4).toUInt();
+ d->frameSize = SynchData::toUInt(data.mid(4, 4));
{ // read the first byte of flags
std::bitset<8> flags(data[8]);
- d->tagAlterPreservation = flags[6]; // (structure 4.1.1.a)
- d->frameAlterPreservation = flags[5]; // (structure 4.1.1.b)
- d->readOnly = flags[4]; // (structure 4.1.1.c)
+ d->tagAlterPreservation = flags[6]; // (structure 4.1.1.a)
+ d->fileAlterPreservation = flags[5]; // (structure 4.1.1.b)
+ d->readOnly = flags[4]; // (structure 4.1.1.c)
}
{ // read the second byte of flags
return d->tagAlterPreservation;
}
-bool Frame::Header::frameAlterPreservation() const
+bool Frame::Header::fileAlterPreservation() const
{
- return d->frameAlterPreservation;
+ return d->fileAlterPreservation;
}
bool Frame::Header::readOnly() const
return v;
}
+
+bool Frame::Header::frameAlterPreservation() const // deprecated
+{
+ return fileAlterPreservation();
+}
bool tagAlterPreservation() const;
/*!
- * Returns true if the flag for frame alter preservation is set.
+ * Returns true if the flag for file alter preservation is set.
*
* \note This flag is currently ignored internally in TagLib.
*/
- bool frameAlterPreservation() const;
+ bool fileAlterPreservation() const;
/*!
* Returns true if the frame is meant to be read only.
*/
ByteVector render() const;
+ /*!
+ * @deprecated
+ */
+ bool frameAlterPreservation() const;
+
private:
Header(const Header &);
Header &operator=(const Header &);
{
Frame::Header *header = new Frame::Header(data, version);
+ // TagLib doesn't mess with encrypted or compressed frames, so just treat them
+ // as unknown frames.
+
+ if(header->compression()) {
+ debug("Compressed frames are currently not supported.");
+ return new UnknownFrame(data, header);
+ }
+ if(header->encryption()) {
+ debug("Entrypted frames are currently not supported.");
+ return new UnknownFrame(data, header);
+ }
+
TagLib::ByteVector frameID = header->frameID();
// A quick sanity check -- make sure that the frameID is 4 uppercase Latin1