From 949a88c6784f34ccc74d7e29e3e0e7a91a005e9c Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 27 Dec 2015 19:51:57 +0100 Subject: [PATCH] improved document title / segment count API --- abstractcontainer.cpp | 17 +++++++++++++++++ abstractcontainer.h | 2 ++ matroska/matroskacontainer.cpp | 6 +++++- matroska/matroskacontainer.h | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/abstractcontainer.cpp b/abstractcontainer.cpp index 0f485b3..931d6b9 100644 --- a/abstractcontainer.cpp +++ b/abstractcontainer.cpp @@ -412,6 +412,23 @@ size_t AbstractContainer::attachmentCount() const { return 0; } + +/*! + * \brief Returns whether the title property is supported. + */ +bool AbstractContainer::supportsTitle() const +{ + return false; +} + +/*! + * \brief Returns the number of segments. + */ +size_t AbstractContainer::segmentCount() const +{ + return 1; +} + /*! * \brief Discards all parsing results. */ diff --git a/abstractcontainer.h b/abstractcontainer.h index cbc7995..e3d0e66 100644 --- a/abstractcontainer.h +++ b/abstractcontainer.h @@ -76,6 +76,8 @@ public: uint64 doctypeReadVersion() const; const std::vector &titles() const; void setTitle(const std::string &title, std::size_t segmentIndex = 0); + virtual bool supportsTitle() const; + virtual std::size_t segmentCount() const; ChronoUtilities::TimeSpan duration() const; ChronoUtilities::DateTime creationTime() const; ChronoUtilities::DateTime modificationTime() const; diff --git a/matroska/matroskacontainer.cpp b/matroska/matroskacontainer.cpp index b5cd01b..6bbff02 100644 --- a/matroska/matroskacontainer.cpp +++ b/matroska/matroskacontainer.cpp @@ -48,7 +48,8 @@ uint64 MatroskaContainer::m_maxFullParseSize = 0x3200000; MatroskaContainer::MatroskaContainer(MediaFileInfo &fileInfo, uint64 startOffset) : GenericContainer(fileInfo, startOffset), m_maxIdLength(4), - m_maxSizeLength(8) + m_maxSizeLength(8), + m_segmentCount(0) { m_version = 1; m_readVersion = 1; @@ -81,6 +82,7 @@ void MatroskaContainer::reset() m_seekInfos.clear(); m_editionEntries.clear(); m_attachments.clear(); + m_segmentCount = 0; } /*! @@ -345,6 +347,7 @@ void MatroskaContainer::internalParseHeader() m_segmentInfoElements.clear(); m_tagsElements.clear(); m_seekInfos.clear(); + m_segmentCount = 0; uint64 currentOffset = 0; vector::size_type seekInfosIndex = 0; // loop through all top level elements @@ -402,6 +405,7 @@ void MatroskaContainer::internalParseHeader() } break; case MatroskaIds::Segment: + ++m_segmentCount; for(EbmlElement *subElement = topLevelElement->firstChild(); subElement; subElement = subElement->nextSibling()) { try { subElement->parse(); diff --git a/matroska/matroskacontainer.h b/matroska/matroskacontainer.h index a0ec28f..e8802f1 100644 --- a/matroska/matroskacontainer.h +++ b/matroska/matroskacontainer.h @@ -42,6 +42,9 @@ public: MatroskaAttachment *attachment(std::size_t index); std::size_t attachmentCount() const; + virtual bool supportsTitle() const; + virtual std::size_t segmentCount() const; + void reset(); protected: @@ -67,6 +70,7 @@ private: std::vector > m_seekInfos; std::vector > m_editionEntries; std::vector > m_attachments; + std::size_t m_segmentCount; static uint64 m_maxFullParseSize; }; @@ -139,6 +143,16 @@ inline std::size_t MatroskaContainer::attachmentCount() const return m_attachments.size(); } +inline bool MatroskaContainer::supportsTitle() const +{ + return true; +} + +inline std::size_t MatroskaContainer::segmentCount() const +{ + return m_segmentInfoElements.size(); +} + } #endif // MATROSKACONTAINER_H