setData(data);
}
-ChapterFrame::ChapterFrame(const ByteVector &eID, const int &sT, const int &eT, const int &sO, const int &eO) :
+ChapterFrame::ChapterFrame(const ByteVector &eID, const uint &sT, const uint &eT, const uint &sO, const uint &eO) :
ID3v2::Frame("CHAP")
{
d = new ChapterFramePrivate;
d->startTime = sT;
d->endTime = eT;
d->startOffset = sO;
- d->endOffset = e0;
+ d->endOffset = eO;
}
ChapterFrame::~ChapterFrame()
return String::null;
}
-PropertyMap UniqueFileIdentifierFrame::asProperties() const
+PropertyMap ChapterFrame::asProperties() const
{
PropertyMap map;
ByteVector data;
data.append(d->elementID);
- data.append(ByteVector.fromUInt(d->startTime, true));
- data.append(ByteVector.fromUInt(d->endTime, true));
- data.append(ByteVector.fromUInt(d->startOffset, true));
- data.append(ByteVector.fromUInt(d->endOffset, true));
+ data.append(ByteVector::fromUInt(d->startTime, true));
+ data.append(ByteVector::fromUInt(d->endTime, true));
+ data.append(ByteVector::fromUInt(d->startOffset, true));
+ data.append(ByteVector::fromUInt(d->endOffset, true));
return data;
}
#define TAGLIB_CHAPTERFRAME
#include "id3v2frame.h"
+#include "taglib_export.h"
namespace TagLib {
* Returns zero based byte offset (count of bytes from the beginning
* of the audio file) of chapter's start.
*
+ * \note If returned value is 0xFFFFFFFF, start time should be used instead.
* \see setStartOffset()
*/
uint startOffset() const;
* Returns zero based byte offset (count of bytes from the beginning
* of the audio file) of chapter's end.
*
+ * \note If returned value is 0xFFFFFFFF, end time should be used instead.
* \see setEndOffset()
*/
uint endOffset() const;
*
* \see endOffset()
*/
- void endOffset(const uint &eO);
+ void setEndOffset(const uint &eO);
virtual String toString() const;
int pos = 0;
d->elementID = readStringField(data, String::Latin1, &pos).data(String::Latin1);
d->elementID.append(char(0));
- d->isTopLevel = (data.at(pos++) & 2) > 0;
+ d->isTopLevel = (data.at(pos) & 2) > 0;
d->isOrdered = (data.at(pos++) & 1) > 0;
uint entryCount = data.at(pos++);
- for(int i = 0; i < entryCount; i++)
+ for(uint i = 0; i < entryCount; i++)
{
ByteVector childElementID = readStringField(data, String::Latin1, &pos).data(String::Latin1);
childElementID.append(char(0));
flags += 1;
data.append(flags);
data.append((char)(entryCount()));
- ConstIterator it = d->childElements.begin();
+ ByteVectorList::ConstIterator it = d->childElements.begin();
while(it != d->childElements.end()) {
data.append(*it);
data.append(char(0));
#include <urllinkframe.h>
#include <ownershipframe.h>
#include <unknownframe.h>
+#include <chapterframe.h>
+#include <tableofcontentsframe.h>
#include <tdebug.h>
#include <tpropertymap.h>
#include <cppunit/extensions/HelperMacros.h>
CPPUNIT_TEST(testPropertyInterface2);
CPPUNIT_TEST(testDeleteFrame);
CPPUNIT_TEST(testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2);
+ CPPUNIT_TEST(testChapters);
+ CPPUNIT_TEST(testTableOfContents);
CPPUNIT_TEST_SUITE_END();
public:
CPPUNIT_ASSERT(!f.ID3v2Tag()->frameListMap().contains("TPE1"));
}
+ void testChaptersParsing()
+ {
+ ID3v2::ChapterFrame f(
+ ByteVector("CHAP" // Frame ID
+ "\x00\x00\x00\x12" // Frame size
+ "\x00\x00" // Frame flags
+ "\x43\x00" // Element ID
+ "\x00\x00\x00\x03" // Start time
+ "\x00\x00\x00\x05" // End time
+ "\x00\x00\x00\x02" // Start offset
+ "\x00\x00\x00\x03", 28)); // End offset
+ CPPUNIT_ASSERT_EQUAL(ByteVector("\x43\x00", 2),
+ f.elementID());
+ CPPUNIT_ASSERT((uint)0x03 == f.startTime());
+ CPPUNIT_ASSERT((uint)0x05 == f.endTime());
+ CPPUNIT_ASSERT((uint)0x02 == f.startOffset());
+ CPPUNIT_ASSERT((uint)0x03 == f.endOffset());
+ }
+
+ void testChapters()
+ {
+ ID3v2::ChapterFrame f(
+ ByteVector("CHAP" // Frame ID
+ "\x00\x00\x00\x12" // Frame size
+ "\x00\x00" // Frame flags
+ "\x43\x00" // Element ID
+ "\x00\x00\x00\x03" // Start time
+ "\x00\x00\x00\x05" // End time
+ "\x00\x00\x00\x02" // Start offset
+ "\x00\x00\x00\x03", 28)); // End offset
+ CPPUNIT_ASSERT_EQUAL(ByteVector("\x43\x00", 2),
+ f.elementID());
+ CPPUNIT_ASSERT((uint)0x03 == f.startTime());
+ CPPUNIT_ASSERT((uint)0x05 == f.endTime());
+ CPPUNIT_ASSERT((uint)0x02 == f.startOffset());
+ CPPUNIT_ASSERT((uint)0x03 == f.endOffset());
+ }
+
+ void testTableOfContents()
+ {
+ ID3v2::TableOfContentsFrame f(
+ ByteVector("CTOC" // Frame ID
+ "\x00\x00\x00\x08" // Frame size
+ "\x00\x00" // Frame flags
+ "\x54\x00" // Element ID
+ "\x01" // CTOC flags
+ "\x02" // Entry count
+ "\x43\x00" // First entry
+ "\x44\x00", 18)); // Second entry
+ CPPUNIT_ASSERT_EQUAL(ByteVector("\x54\x00", 2),
+ f.elementID());
+ CPPUNIT_ASSERT(!f.isTopLevel());
+ CPPUNIT_ASSERT(f.isOrdered());
+ CPPUNIT_ASSERT((uint)0x02 == f.entryCount());
+ CPPUNIT_ASSERT_EQUAL(ByteVector("\x43\x00", 2),
+ f.childElements()[0]);
+ CPPUNIT_ASSERT_EQUAL(ByteVector("\x44\x00", 2),
+ f.childElements()[1]);
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);