mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Added basic members of ChapterFrame and TableOfContentsFrame classes.
Fixed minor bugs in ChapterFrame and TableOfContentsFrame headers.
This commit is contained in:
parent
0864634ea6
commit
3a1040d55b
@ -28,60 +28,96 @@
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2tag.h"
|
||||
#include "uniquefileidentifierframe.h"
|
||||
#include "chapterframe.h"
|
||||
|
||||
using namespace TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
class UniqueFileIdentifierFrame::UniqueFileIdentifierFramePrivate
|
||||
class ChapterFrame::ChapterFramePrivate
|
||||
{
|
||||
public:
|
||||
String owner;
|
||||
ByteVector identifier;
|
||||
ByteVector elementID;
|
||||
uint startTime;
|
||||
uint endTime;
|
||||
uint startOffset;
|
||||
uint endOffset;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data) :
|
||||
ChapterFrame::ChapterFrame(const ByteVector &data) :
|
||||
ID3v2::Frame(data)
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d = new ChapterFramePrivate;
|
||||
setData(data);
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const String &owner, const ByteVector &id) :
|
||||
ID3v2::Frame("UFID")
|
||||
ChapterFrame::ChapterFrame(const ByteVector &eID, const int &sT, const int &eT, const int &sO, const int &eO) :
|
||||
ID3v2::Frame("CHAP")
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d->owner = owner;
|
||||
d->identifier = id;
|
||||
d = new ChapterFramePrivate;
|
||||
d->elementID = eID;
|
||||
d->startTime = sT;
|
||||
d->endTime = eT;
|
||||
d->startOffset = sO;
|
||||
d->endOffset = e0;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame()
|
||||
ChapterFrame::~ChapterFrame()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
String UniqueFileIdentifierFrame::owner() const
|
||||
ByteVector ChapterFrame::elementID() const
|
||||
{
|
||||
return d->owner;
|
||||
return d->elementID;
|
||||
}
|
||||
|
||||
ByteVector UniqueFileIdentifierFrame::identifier() const
|
||||
uint ChapterFrame::startTime() const
|
||||
{
|
||||
return d->identifier;
|
||||
return d->startTime;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::setOwner(const String &s)
|
||||
uint ChapterFrame::endTime() const
|
||||
{
|
||||
d->owner = s;
|
||||
return d->endTime;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::setIdentifier(const ByteVector &v)
|
||||
uint ChapterFrame::startOffset() const
|
||||
{
|
||||
d->identifier = v;
|
||||
return d->startOffset;
|
||||
}
|
||||
|
||||
uint ChapterFrame::endOffset() const
|
||||
{
|
||||
return d->endOffset;
|
||||
}
|
||||
|
||||
void ChapterFrame::setElementID(const ByteVector &eID)
|
||||
{
|
||||
d->elementID = eID;
|
||||
}
|
||||
|
||||
void ChapterFrame::setStartTime(const uint &sT)
|
||||
{
|
||||
d->startTime = sT;
|
||||
}
|
||||
|
||||
void ChapterFrame::setEndTime(const uint &eT)
|
||||
{
|
||||
d->endTime = eT;
|
||||
}
|
||||
|
||||
void ChapterFrame::setStartOffset(const uint &sO)
|
||||
{
|
||||
d->startOffset = sO;
|
||||
}
|
||||
|
||||
void ChapterFrame::setEndOffset(const uint &eO)
|
||||
{
|
||||
d->endOffset = eO;
|
||||
}
|
||||
|
||||
String UniqueFileIdentifierFrame::toString() const
|
||||
@ -89,8 +125,9 @@ String UniqueFileIdentifierFrame::toString() const
|
||||
return String::null;
|
||||
}
|
||||
|
||||
PropertyMap UniqueFileIdentifierFrame::asProperties() const
|
||||
PropertyMap ChapterFrame::asProperties() const
|
||||
{
|
||||
//DODELAT
|
||||
PropertyMap map;
|
||||
if(d->owner == "http://musicbrainz.org") {
|
||||
map.insert("MUSICBRAINZ_TRACKID", String(d->identifier));
|
||||
@ -101,24 +138,25 @@ PropertyMap UniqueFileIdentifierFrame::asProperties() const
|
||||
return map;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame *UniqueFileIdentifierFrame::findByOwner(const ID3v2::Tag *tag, const String &o) // static
|
||||
ChapterFrame *ChapterFrame::findByElementID(const Tag *tag, const ByteVector &eID) // static
|
||||
{
|
||||
ID3v2::FrameList comments = tag->frameList("UFID");
|
||||
ID3v2::FrameList comments = tag->frameList("CHAP");
|
||||
|
||||
for(ID3v2::FrameList::ConstIterator it = comments.begin();
|
||||
it != comments.end();
|
||||
++it)
|
||||
{
|
||||
UniqueFileIdentifierFrame *frame = dynamic_cast<UniqueFileIdentifierFrame *>(*it);
|
||||
if(frame && frame->owner() == o)
|
||||
ChapterFrame *frame = dynamic_cast<ChapterFrame *>(*it);
|
||||
if(frame && frame->elementID() == eID)
|
||||
return frame;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::parseFields(const ByteVector &data)
|
||||
void ChapterFrame::parseFields(const ByteVector &data)
|
||||
{
|
||||
//DODELAT
|
||||
if(data.size() < 1) {
|
||||
debug("An UFID frame must contain at least 1 byte.");
|
||||
return;
|
||||
@ -129,8 +167,9 @@ void UniqueFileIdentifierFrame::parseFields(const ByteVector &data)
|
||||
d->identifier = data.mid(pos);
|
||||
}
|
||||
|
||||
ByteVector UniqueFileIdentifierFrame::renderFields() const
|
||||
ByteVector ChapterFrame::renderFields() const
|
||||
{
|
||||
//DODELAT
|
||||
ByteVector data;
|
||||
|
||||
data.append(d->owner.data(String::Latin1));
|
||||
@ -140,9 +179,9 @@ ByteVector UniqueFileIdentifierFrame::renderFields() const
|
||||
return data;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data, Header *h) :
|
||||
ChapterFrame::ChapterFrame(const ByteVector &data, Header *h) :
|
||||
Frame(h)
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d = new ChapterFramePrivate;
|
||||
parseFields(fieldData(data));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace TagLib {
|
||||
* start time \a sT, end time \a eT, start offset \a sO
|
||||
* and end offset \a eO.
|
||||
*/
|
||||
ChapterFrame(const ByteVector &eID, const int &sT, const int &eT, const int &sO, const int &eO);
|
||||
ChapterFrame(const ByteVector &eID, const uint &sT, const uint &eT, const uint &sO, const uint &eO);
|
||||
|
||||
/*!
|
||||
* Destroys the frame.
|
||||
@ -143,7 +143,8 @@ namespace TagLib {
|
||||
|
||||
/*!
|
||||
* CHAP frames each have a unique element ID. This searches for a CHAP
|
||||
* frame with the element ID \a eID and returns a pointer to it.
|
||||
* frame with the element ID \a eID and returns a pointer to it. This
|
||||
* can be used to link CTOC and CHAP frames together.
|
||||
*
|
||||
* \see elementID()
|
||||
*/
|
||||
|
@ -28,69 +28,97 @@
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2tag.h"
|
||||
#include "uniquefileidentifierframe.h"
|
||||
#include "tableofcontentsframe.h"
|
||||
|
||||
using namespace TagLib;
|
||||
using namespace ID3v2;
|
||||
|
||||
class UniqueFileIdentifierFrame::UniqueFileIdentifierFramePrivate
|
||||
class TableOfContentsFrame::TableOfContentsFramePrivate
|
||||
{
|
||||
public:
|
||||
String owner;
|
||||
ByteVector identifier;
|
||||
ByteVector elementID;
|
||||
bool isTopLevel;
|
||||
bool isOrdered;
|
||||
ByteVectorList childElements;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data) :
|
||||
TableOfContentsFrame::TableOfContentsFrame(const ByteVector &data) :
|
||||
ID3v2::Frame(data)
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d = new TableOfContentsFramePrivate;
|
||||
setData(data);
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const String &owner, const ByteVector &id) :
|
||||
ID3v2::Frame("UFID")
|
||||
TableOfContentsFrame::TableOfContentsFrame(const ByteVector &eID, const ByteVectorList &ch) :
|
||||
ID3v2::Frame("CTOC")
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d->owner = owner;
|
||||
d->identifier = id;
|
||||
d = new TableOfContentsFramePrivate;
|
||||
d->elementID = eID;
|
||||
d->childElements = ch;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame()
|
||||
TableOfContentsFrame::~TableOfContentsFrame()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
String UniqueFileIdentifierFrame::owner() const
|
||||
ByteVector TableOfContentsFrame::elementID() const
|
||||
{
|
||||
return d->owner;
|
||||
return d->elementID;
|
||||
}
|
||||
|
||||
ByteVector UniqueFileIdentifierFrame::identifier() const
|
||||
bool TableOfContentsFrame::isTopLevel() const
|
||||
{
|
||||
return d->identifier;
|
||||
return d->isTopLevel;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::setOwner(const String &s)
|
||||
bool TableOfContentsFrame::isOrdered() const
|
||||
{
|
||||
d->owner = s;
|
||||
return d->isOrdered;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::setIdentifier(const ByteVector &v)
|
||||
unsigned char TableOfContentsFrame::entryCount() const
|
||||
{
|
||||
d->identifier = v;
|
||||
return (unsigned char)(d->childElements.size());
|
||||
}
|
||||
|
||||
String UniqueFileIdentifierFrame::toString() const
|
||||
ByteVectorList TableOfContentsFrame::childElements const
|
||||
{
|
||||
return d->childElements;
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::setElementID(const ByteVector &eID)
|
||||
{
|
||||
d->elementID = eID;
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::setIsTopLevel(const bool &t)
|
||||
{
|
||||
d->isTopLevel = t;
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::setIsOrdered(const bool &o)
|
||||
{
|
||||
d->isOrdered = o;
|
||||
}
|
||||
|
||||
void TableOfContentsFrame::setChildElements(const ByteVectorList &l)
|
||||
{
|
||||
d->childElements = l;
|
||||
}
|
||||
|
||||
String TableOfContentsFrame::toString() const
|
||||
{
|
||||
return String::null;
|
||||
}
|
||||
|
||||
PropertyMap UniqueFileIdentifierFrame::asProperties() const
|
||||
PropertyMap TableOfContentsFrame::asProperties() const
|
||||
{
|
||||
//DODELAT
|
||||
PropertyMap map;
|
||||
if(d->owner == "http://musicbrainz.org") {
|
||||
map.insert("MUSICBRAINZ_TRACKID", String(d->identifier));
|
||||
@ -101,24 +129,25 @@ PropertyMap UniqueFileIdentifierFrame::asProperties() const
|
||||
return map;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame *UniqueFileIdentifierFrame::findByOwner(const ID3v2::Tag *tag, const String &o) // static
|
||||
TableOfContentsFrame *TableOfContentsFrame::findByElementID(const ID3v2::Tag *tag, const ByteVector &eID) // static
|
||||
{
|
||||
ID3v2::FrameList comments = tag->frameList("UFID");
|
||||
ID3v2::FrameList comments = tag->frameList("CTOC");
|
||||
|
||||
for(ID3v2::FrameList::ConstIterator it = comments.begin();
|
||||
it != comments.end();
|
||||
++it)
|
||||
{
|
||||
UniqueFileIdentifierFrame *frame = dynamic_cast<UniqueFileIdentifierFrame *>(*it);
|
||||
if(frame && frame->owner() == o)
|
||||
TableOfContentsFrame *frame = dynamic_cast<TableOfContentsFrame *>(*it);
|
||||
if(frame && frame->elementID() == eID)
|
||||
return frame;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UniqueFileIdentifierFrame::parseFields(const ByteVector &data)
|
||||
void TableOfContentsFrame::parseFields(const ByteVector &data)
|
||||
{
|
||||
//DODELAT
|
||||
if(data.size() < 1) {
|
||||
debug("An UFID frame must contain at least 1 byte.");
|
||||
return;
|
||||
@ -129,8 +158,9 @@ void UniqueFileIdentifierFrame::parseFields(const ByteVector &data)
|
||||
d->identifier = data.mid(pos);
|
||||
}
|
||||
|
||||
ByteVector UniqueFileIdentifierFrame::renderFields() const
|
||||
ByteVector TableOfContentsFrame::renderFields() const
|
||||
{
|
||||
//DODELAT
|
||||
ByteVector data;
|
||||
|
||||
data.append(d->owner.data(String::Latin1));
|
||||
@ -140,9 +170,9 @@ ByteVector UniqueFileIdentifierFrame::renderFields() const
|
||||
return data;
|
||||
}
|
||||
|
||||
UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data, Header *h) :
|
||||
TableOfContentsFrame::TableOfContentsFrame(const ByteVector &data, Header *h) :
|
||||
Frame(h)
|
||||
{
|
||||
d = new UniqueFileIdentifierFramePrivate;
|
||||
d = new TableOfContentsFramePrivate;
|
||||
parseFields(fieldData(data));
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ namespace TagLib {
|
||||
* Creates a table of contents frame with the element ID \a eID and
|
||||
* the child elements \a ch.
|
||||
*/
|
||||
UniqueFileIdentifierFrame(const ByteVector &eID, const List<ByteVector> &ch);
|
||||
TableOfContentsFrame(const ByteVector &eID, const ByteVectorList &ch);
|
||||
|
||||
/*!
|
||||
* Destroys the frame.
|
||||
*/
|
||||
~UniqueFileIdentifierFrame();
|
||||
~TableOfContentsFrame();
|
||||
|
||||
/*!
|
||||
* Returns the elementID of the frame. Element ID
|
||||
@ -88,7 +88,7 @@ namespace TagLib {
|
||||
* Returns count of child elements of the frame. It allways
|
||||
* corresponds to size of child elements list.
|
||||
*
|
||||
* \note Return type should be uint8_t.
|
||||
* \note Return type should be uint8_t, not unsigned char.
|
||||
* \see childElements()
|
||||
*/
|
||||
unsigned char entryCount() const;
|
||||
@ -98,7 +98,7 @@ namespace TagLib {
|
||||
*
|
||||
* \see setChildElements()
|
||||
*/
|
||||
List<ByteVector> childElements() const;
|
||||
ByteVectorList childElements() const;
|
||||
|
||||
/*!
|
||||
* Sets the elementID of the frame to \a eID.
|
||||
@ -129,7 +129,7 @@ namespace TagLib {
|
||||
*
|
||||
* \see childElements()
|
||||
*/
|
||||
void setChildElements(const List<ByteVector> &l);
|
||||
void setChildElements(const ByteVectorList &l);
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
@ -137,11 +137,12 @@ namespace TagLib {
|
||||
|
||||
/*!
|
||||
* CTOC frames each have a unique element ID. This searches for a CTOC
|
||||
* frame with the element ID \a eID and returns a pointer to it.
|
||||
* frame with the element ID \a eID and returns a pointer to it. This
|
||||
* can be used to link together parent and child CTOC frames.
|
||||
*
|
||||
* \see elementID()
|
||||
*/
|
||||
static UniqueFileIdentifierFrame *findByElementID(const Tag *tag, const ByteVector &eID);
|
||||
static TableOfContentsFrame *findByElementID(const Tag *tag, const ByteVector &eID);
|
||||
|
||||
protected:
|
||||
virtual void parseFields(const ByteVector &data);
|
||||
|
Loading…
Reference in New Issue
Block a user