2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_MATROSKACONTAINER_H
|
|
|
|
#define TAG_PARSER_MATROSKACONTAINER_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "./ebmlelement.h"
|
2018-03-07 01:17:50 +01:00
|
|
|
#include "./matroskaattachment.h"
|
|
|
|
#include "./matroskachapter.h"
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "./matroskatag.h"
|
|
|
|
#include "./matroskatrack.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../genericcontainer.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
#include <c++utilities/conversion/types.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
class MatroskaSeekInfo;
|
|
|
|
class MatroskaEditionEntry;
|
|
|
|
|
|
|
|
class MediaFileInfo;
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT MatroskaContainer : public GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement> {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
|
|
|
MatroskaContainer(MediaFileInfo &stream, uint64 startOffset);
|
2018-03-05 17:49:29 +01:00
|
|
|
~MatroskaContainer() override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
void validateIndex(Diagnostics &diag);
|
2015-04-22 19:22:01 +02:00
|
|
|
uint64 maxIdLength() const;
|
|
|
|
uint64 maxSizeLength() const;
|
2018-03-07 01:17:50 +01:00
|
|
|
const std::vector<std::unique_ptr<MatroskaSeekInfo>> &seekInfos() const;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
static uint64 maxFullParseSize();
|
|
|
|
void setMaxFullParseSize(uint64 maxFullParseSize);
|
2018-03-07 01:17:50 +01:00
|
|
|
const std::vector<std::unique_ptr<MatroskaEditionEntry>> &editionEntires() const;
|
2018-03-05 17:49:29 +01:00
|
|
|
MatroskaChapter *chapter(std::size_t index) override;
|
|
|
|
std::size_t chapterCount() const override;
|
|
|
|
MatroskaAttachment *createAttachment() override;
|
|
|
|
MatroskaAttachment *attachment(std::size_t index) override;
|
|
|
|
std::size_t attachmentCount() const override;
|
|
|
|
ElementPosition determineElementPosition(uint64 elementId, Diagnostics &diag) const;
|
|
|
|
ElementPosition determineTagPosition(Diagnostics &diag) const override;
|
|
|
|
ElementPosition determineIndexPosition(Diagnostics &diag) const override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
virtual bool supportsTitle() const override;
|
|
|
|
virtual std::size_t segmentCount() const override;
|
2015-12-27 19:51:57 +01:00
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
void reset() override;
|
2015-10-06 22:39:18 +02:00
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
protected:
|
2018-03-05 17:49:29 +01:00
|
|
|
void internalParseHeader(Diagnostics &diag) override;
|
|
|
|
void internalParseTags(Diagnostics &diag) override;
|
|
|
|
void internalParseTracks(Diagnostics &diag) override;
|
|
|
|
void internalParseChapters(Diagnostics &diag) override;
|
|
|
|
void internalParseAttachments(Diagnostics &diag) override;
|
|
|
|
void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
private:
|
2018-03-05 17:49:29 +01:00
|
|
|
void parseSegmentInfo(Diagnostics &diag);
|
|
|
|
void readTrackStatisticsFromTags(Diagnostics &diag);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
uint64 m_maxIdLength;
|
|
|
|
uint64 m_maxSizeLength;
|
|
|
|
|
|
|
|
std::vector<EbmlElement *> m_tracksElements;
|
|
|
|
std::vector<EbmlElement *> m_segmentInfoElements;
|
|
|
|
std::vector<EbmlElement *> m_tagsElements;
|
|
|
|
std::vector<EbmlElement *> m_chaptersElements;
|
|
|
|
std::vector<EbmlElement *> m_attachmentsElements;
|
2018-03-07 01:17:50 +01:00
|
|
|
std::vector<std::unique_ptr<MatroskaSeekInfo>> m_seekInfos;
|
|
|
|
std::vector<std::unique_ptr<MatroskaEditionEntry>> m_editionEntries;
|
|
|
|
std::vector<std::unique_ptr<MatroskaAttachment>> m_attachments;
|
2015-12-27 19:51:57 +01:00
|
|
|
std::size_t m_segmentCount;
|
2015-04-22 19:22:01 +02:00
|
|
|
static uint64 m_maxFullParseSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the maximal ID length in bytes.
|
|
|
|
*/
|
|
|
|
inline uint64 MatroskaContainer::maxIdLength() const
|
|
|
|
{
|
|
|
|
return m_maxIdLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the maximal size length in bytes.
|
|
|
|
*/
|
|
|
|
inline uint64 MatroskaContainer::maxSizeLength() const
|
|
|
|
{
|
|
|
|
return m_maxSizeLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2015-11-26 14:40:35 +01:00
|
|
|
* \brief Returns seek information read from "SeekHead"-elements when parsing segment info.
|
2015-04-22 19:22:01 +02:00
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline const std::vector<std::unique_ptr<MatroskaSeekInfo>> &MatroskaContainer::seekInfos() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_seekInfos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the maximal file size for a "full parse" in byte.
|
|
|
|
*
|
|
|
|
* The "Tags" element (which holds the tag information) is commonly at the end of a Matroska file. Hence the
|
|
|
|
* parser needs to walk through the entire file to find the tag information if no "SeekHead" element is present
|
|
|
|
* which might causes long loading times. To avoid this a maximal file size for a "full parse" can be specified.
|
|
|
|
* The disadvantage is that the parser relies on the presence of a SeekHead element on larger files to retrieve
|
|
|
|
* tag information.
|
|
|
|
*
|
|
|
|
* The default value is 50 MiB.
|
|
|
|
*
|
|
|
|
* \sa setMaxFullParseSize()
|
|
|
|
*/
|
|
|
|
inline uint64 MatroskaContainer::maxFullParseSize()
|
|
|
|
{
|
|
|
|
return m_maxFullParseSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the maximal file size for a "full parse" in byte.
|
|
|
|
* \sa maxFullParseSize()
|
|
|
|
*/
|
|
|
|
inline void MatroskaContainer::setMaxFullParseSize(uint64 maxFullParseSize)
|
|
|
|
{
|
|
|
|
m_maxFullParseSize = maxFullParseSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the edition entries.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline const std::vector<std::unique_ptr<MatroskaEditionEntry>> &MatroskaContainer::editionEntires() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_editionEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline MatroskaAttachment *MatroskaContainer::attachment(std::size_t index)
|
|
|
|
{
|
|
|
|
return m_attachments.at(index).get();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::size_t MatroskaContainer::attachmentCount() const
|
|
|
|
{
|
|
|
|
return m_attachments.size();
|
|
|
|
}
|
|
|
|
|
2015-12-27 19:51:57 +01:00
|
|
|
inline bool MatroskaContainer::supportsTitle() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::size_t MatroskaContainer::segmentCount() const
|
|
|
|
{
|
|
|
|
return m_segmentInfoElements.size();
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
#endif // MATROSKACONTAINER_H
|