diff --git a/CMakeLists.txt b/CMakeLists.txt index 19c9d76..8c903b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/abstractcontainer.cpp b/abstractcontainer.cpp index a5c824f..6a19856 100644 --- a/abstractcontainer.cpp +++ b/abstractcontainer.cpp @@ -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. * diff --git a/abstractcontainer.h b/abstractcontainer.h index 1b0f3f6..2f1be11 100644 --- a/abstractcontainer.h +++ b/abstractcontainer.h @@ -13,10 +13,8 @@ #include 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; diff --git a/matroska/matroskacontainer.cpp b/matroska/matroskacontainer.cpp index 4e068d1..f646e1d 100644 --- a/matroska/matroskacontainer.cpp +++ b/matroska/matroskacontainer.cpp @@ -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"); diff --git a/matroska/matroskacontainer.h b/matroska/matroskacontainer.h index f0a4d22..11e1985 100644 --- a/matroska/matroskacontainer.h +++ b/matroska/matroskacontainer.h @@ -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; diff --git a/mediafileinfo.h b/mediafileinfo.h index da21ca3..8b5583a 100644 --- a/mediafileinfo.h +++ b/mediafileinfo.h @@ -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. diff --git a/mp4/mp4container.cpp b/mp4/mp4container.cpp index b1716a4..80317ed 100644 --- a/mp4/mp4container.cpp +++ b/mp4/mp4container.cpp @@ -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 diff --git a/mp4/mp4container.h b/mp4/mp4container.h index 5d05253..9240faf 100644 --- a/mp4/mp4container.h +++ b/mp4/mp4container.h @@ -25,6 +25,7 @@ public: bool supportsTrackModifications() const; bool isFragmented() const; void reset(); + ElementPosition determineTagPosition() const; protected: void internalParseHeader();