Tag Parser 11.2.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
matroskacontainer.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_MATROSKACONTAINER_H
2#define TAG_PARSER_MATROSKACONTAINER_H
3
4#include "./ebmlelement.h"
6#include "./matroskachapter.h"
7#include "./matroskatag.h"
8#include "./matroskatrack.h"
9
10#include "../genericcontainer.h"
11
12#include <cstdint>
13#include <memory>
14#include <string>
15#include <vector>
16
17namespace TagParser {
18
19class MatroskaSeekInfo;
20class MatroskaEditionEntry;
21
22class MediaFileInfo;
23
24class TAG_PARSER_EXPORT MatroskaContainer final : public GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement> {
25public:
26 MatroskaContainer(MediaFileInfo &stream, std::uint64_t startOffset);
27 ~MatroskaContainer() override;
28
29 void validateIndex(Diagnostics &diag, AbortableProgressFeedback &progress);
30 std::uint64_t maxIdLength() const;
31 std::uint64_t maxSizeLength() const;
32 const std::vector<std::unique_ptr<MatroskaSeekInfo>> &seekInfos() const;
33
34 static std::uint64_t maxFullParseSize();
35 void setMaxFullParseSize(std::uint64_t maxFullParseSize);
36 const std::vector<std::unique_ptr<MatroskaEditionEntry>> &editionEntires() const;
37 MatroskaChapter *chapter(std::size_t index) override;
38 std::size_t chapterCount() const override;
39 MatroskaAttachment *createAttachment() override;
40 MatroskaAttachment *attachment(std::size_t index) override;
41 std::size_t attachmentCount() const override;
42 ElementPosition determineElementPosition(std::uint64_t elementId, Diagnostics &diag) const;
43 ElementPosition determineTagPosition(Diagnostics &diag) const override;
44 ElementPosition determineIndexPosition(Diagnostics &diag) const override;
45
46 virtual bool supportsTitle() const override;
47 virtual std::size_t segmentCount() const override;
48
49 void reset() override;
50
51protected:
52 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
53 void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override;
54 void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override;
55 void internalParseChapters(Diagnostics &diag, AbortableProgressFeedback &progress) override;
56 void internalParseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress) override;
57 void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
58
59private:
60 void parseSegmentInfo(Diagnostics &diag);
61 void readTrackStatisticsFromTags(Diagnostics &diag);
62
63 std::uint64_t m_maxIdLength;
64 std::uint64_t m_maxSizeLength;
65
66 std::vector<EbmlElement *> m_tracksElements;
67 std::vector<EbmlElement *> m_segmentInfoElements;
68 std::vector<EbmlElement *> m_tagsElements;
69 std::vector<EbmlElement *> m_chaptersElements;
70 std::vector<EbmlElement *> m_attachmentsElements;
71 std::vector<std::unique_ptr<MatroskaSeekInfo>> m_seekInfos;
72 std::vector<std::unique_ptr<MatroskaEditionEntry>> m_editionEntries;
73 std::vector<std::unique_ptr<MatroskaAttachment>> m_attachments;
74 std::size_t m_segmentCount;
75 static std::uint64_t m_maxFullParseSize;
76};
77
81inline std::uint64_t MatroskaContainer::maxIdLength() const
82{
83 return m_maxIdLength;
84}
85
89inline std::uint64_t MatroskaContainer::maxSizeLength() const
90{
91 return m_maxSizeLength;
92}
93
97inline const std::vector<std::unique_ptr<MatroskaSeekInfo>> &MatroskaContainer::seekInfos() const
98{
99 return m_seekInfos;
100}
101
116{
117 return m_maxFullParseSize;
118}
119
124inline void MatroskaContainer::setMaxFullParseSize(std::uint64_t maxFullParseSize)
125{
126 m_maxFullParseSize = maxFullParseSize;
127}
128
132inline const std::vector<std::unique_ptr<MatroskaEditionEntry>> &MatroskaContainer::editionEntires() const
133{
134 return m_editionEntries;
135}
136
138{
139 return m_attachments.at(index).get();
140}
141
142inline std::size_t MatroskaContainer::attachmentCount() const
143{
144 return m_attachments.size();
145}
146
148{
149 return true;
150}
151
152inline std::size_t MatroskaContainer::segmentCount() const
153{
154 return m_segmentInfoElements.size();
155}
156
157} // namespace TagParser
158
159#endif // MATROSKACONTAINER_H
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
The GenericContainer class helps parsing header, track, tag and chapter information of a file.
Implementation of TagParser::AbstractAttachment for the Matroska container.
The MatroskaChapter class provides an implementation of AbstractAttachment for Matroska files.
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
virtual std::size_t segmentCount() const override
Returns the number of segments.
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & seekInfos() const
Returns seek information read from "SeekHead"-elements when parsing segment info.
std::size_t attachmentCount() const override
Returns the number of attachments the container holds.
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires() const
Returns the edition entries.
std::uint64_t maxSizeLength() const
Returns the maximal size length in bytes.
MatroskaAttachment * attachment(std::size_t index) override
Returns the attachment with the specified index.
void setMaxFullParseSize(std::uint64_t maxFullParseSize)
Sets the maximal file size for a "full parse" in byte.
virtual bool supportsTitle() const override
Returns whether the title property is supported.
std::uint64_t maxIdLength() const
Returns the maximal ID length in bytes.
static std::uint64_t maxFullParseSize()
Returns the maximal file size for a "full parse" in byte.
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition: mediafileinfo.h:76
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
ElementPosition
Definition: settings.h:13