Allow checking index position

Only implemented for MP4 so far
This commit is contained in:
Martchus 2016-11-16 19:31:09 +01:00
parent 6717062ca2
commit a8dce14514
6 changed files with 32 additions and 2 deletions

View File

@ -171,6 +171,16 @@ bool AbstractContainer::supportsTrackModifications() const
return false;
}
/*!
* \brief Determines the position of the index.
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
* be determined; otherwise returns ElementPosition::Keep.
*/
ElementPosition AbstractContainer::determineIndexPosition() const
{
return ElementPosition::Keep;
}
/*!
* \brief Internally called to parse the header.
*

View File

@ -67,6 +67,7 @@ public:
virtual bool removeTrack(AbstractTrack *track);
virtual void removeAllTracks();
virtual bool supportsTrackModifications() const;
virtual ElementPosition determineIndexPosition() const;
virtual AbstractChapter *chapter(std::size_t index);
virtual std::size_t chapterCount() const;

View File

@ -337,6 +337,11 @@ ElementPosition MatroskaContainer::determineTagPosition() const
return ElementPosition::Keep; // TODO
}
ElementPosition MatroskaContainer::determineIndexPosition() const
{
return ElementPosition::Keep; // TODO
}
void MatroskaContainer::internalParseHeader()
{
static const string context("parsing header of Matroska container");

View File

@ -42,6 +42,7 @@ public:
MatroskaAttachment *attachment(std::size_t index);
std::size_t attachmentCount() const;
ElementPosition determineTagPosition() const;
ElementPosition determineIndexPosition() const;
virtual bool supportsTitle() const;
virtual std::size_t segmentCount() const;

View File

@ -48,8 +48,8 @@ void Mp4Container::reset()
ElementPosition Mp4Container::determineTagPosition() const
{
if(m_firstElement) {
Mp4Atom *mediaDataAtom = m_firstElement->siblingById(Mp4AtomIds::MediaData);
Mp4Atom *userDataAtom = m_firstElement->subelementByPath({Mp4AtomIds::Movie, Mp4AtomIds::UserData});
const Mp4Atom *mediaDataAtom = m_firstElement->siblingById(Mp4AtomIds::MediaData);
const Mp4Atom *userDataAtom = m_firstElement->subelementByPath({Mp4AtomIds::Movie, Mp4AtomIds::UserData});
if(mediaDataAtom && userDataAtom) {
return userDataAtom->startOffset() < mediaDataAtom->startOffset() ? ElementPosition::BeforeData : ElementPosition::AfterData;
}
@ -57,6 +57,18 @@ ElementPosition Mp4Container::determineTagPosition() const
return ElementPosition::Keep;
}
ElementPosition Mp4Container::determineIndexPosition() const
{
if(m_firstElement) {
const Mp4Atom *mediaDataAtom = m_firstElement->siblingById(Mp4AtomIds::MediaData);
const Mp4Atom *movieAtom = m_firstElement->siblingById(Mp4AtomIds::Movie);
if(mediaDataAtom && movieAtom) {
return movieAtom->startOffset() < mediaDataAtom->startOffset() ? ElementPosition::BeforeData : ElementPosition::AfterData;
}
}
return ElementPosition::Keep;
}
void Mp4Container::internalParseHeader()
{
//const string context("parsing header of MP4 container"); will be used when generating notifications

View File

@ -26,6 +26,7 @@ public:
bool isFragmented() const;
void reset();
ElementPosition determineTagPosition() const;
ElementPosition determineIndexPosition() const;
protected:
void internalParseHeader();