Allow checking tag position
Only implemented for MP4 so far
This commit is contained in:
parent
f6d0f3a003
commit
6717062ca2
|
@ -159,8 +159,8 @@ set(META_APP_AUTHOR "Martchus")
|
|||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags")
|
||||
set(META_VERSION_MAJOR 6)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
set(META_VERSION_MINOR 1)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities)
|
||||
set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)
|
||||
set(META_PRIVATE_COMPILE_DEFINITIONS LEGACY_API)
|
||||
|
|
|
@ -315,6 +315,16 @@ bool AbstractContainer::removeTag(Tag *)
|
|||
void AbstractContainer::removeAllTags()
|
||||
{}
|
||||
|
||||
/*!
|
||||
* \brief Determines the position of the tags inside the file.
|
||||
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
|
||||
* be determined; otherwise returns ElementPosition::Keep.
|
||||
*/
|
||||
ElementPosition AbstractContainer::determineTagPosition() const
|
||||
{
|
||||
return ElementPosition::Keep;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the track with the specified \a index.
|
||||
*
|
||||
|
|
|
@ -13,10 +13,8 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace IoUtilities {
|
||||
|
||||
class BinaryReader;
|
||||
class BinaryWriter;
|
||||
|
||||
}
|
||||
|
||||
namespace Media {
|
||||
|
@ -26,6 +24,13 @@ class AbstractTrack;
|
|||
class AbstractChapter;
|
||||
class AbstractAttachment;
|
||||
|
||||
enum class ElementPosition
|
||||
{
|
||||
BeforeData, /**< the element is positioned before the actual data */
|
||||
AfterData, /**< the element is positioned after the actual data */
|
||||
Keep /**< the element is placed where it was before */
|
||||
};
|
||||
|
||||
class TAG_PARSER_EXPORT AbstractContainer : public StatusProvider
|
||||
{
|
||||
public:
|
||||
|
@ -55,6 +60,7 @@ public:
|
|||
virtual std::size_t tagCount() const;
|
||||
virtual bool removeTag(Tag *tag);
|
||||
virtual void removeAllTags();
|
||||
virtual ElementPosition determineTagPosition() const;
|
||||
|
||||
virtual AbstractTrack *track(std::size_t index);
|
||||
virtual std::size_t trackCount() const;
|
||||
|
|
|
@ -332,6 +332,11 @@ generateRandomId:
|
|||
return attachment.get();
|
||||
}
|
||||
|
||||
ElementPosition MatroskaContainer::determineTagPosition() const
|
||||
{
|
||||
return ElementPosition::Keep; // TODO
|
||||
}
|
||||
|
||||
void MatroskaContainer::internalParseHeader()
|
||||
{
|
||||
static const string context("parsing header of Matroska container");
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
MatroskaAttachment *createAttachment();
|
||||
MatroskaAttachment *attachment(std::size_t index);
|
||||
std::size_t attachmentCount() const;
|
||||
ElementPosition determineTagPosition() const;
|
||||
|
||||
virtual bool supportsTitle() const;
|
||||
virtual std::size_t segmentCount() const;
|
||||
|
|
|
@ -37,13 +37,6 @@ enum class TagUsage
|
|||
Never /**< tags of the type are never used; a possibly existing tag of the type is removed */
|
||||
};
|
||||
|
||||
enum class ElementPosition
|
||||
{
|
||||
BeforeData, /**< the element is positioned before the actual data */
|
||||
AfterData, /**< the element is positioned after the actual data */
|
||||
Keep /**< the element is placed at its previous position */
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief The ParsingStatus enum specifies whether a certain part of the file (tracks, tags, ...) has
|
||||
* been parsed yet and if what the parsing result is.
|
||||
|
|
|
@ -45,6 +45,18 @@ void Mp4Container::reset()
|
|||
m_fragmented = false;
|
||||
}
|
||||
|
||||
ElementPosition Mp4Container::determineTagPosition() const
|
||||
{
|
||||
if(m_firstElement) {
|
||||
Mp4Atom *mediaDataAtom = m_firstElement->siblingById(Mp4AtomIds::MediaData);
|
||||
Mp4Atom *userDataAtom = m_firstElement->subelementByPath({Mp4AtomIds::Movie, Mp4AtomIds::UserData});
|
||||
if(mediaDataAtom && userDataAtom) {
|
||||
return userDataAtom->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
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
bool supportsTrackModifications() const;
|
||||
bool isFragmented() const;
|
||||
void reset();
|
||||
ElementPosition determineTagPosition() const;
|
||||
|
||||
protected:
|
||||
void internalParseHeader();
|
||||
|
|
Loading…
Reference in New Issue