Tag Parser  9.1.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"
5 #include "./matroskaattachment.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 
17 namespace TagParser {
18 
19 class MatroskaSeekInfo;
20 class MatroskaEditionEntry;
21 
22 class MediaFileInfo;
23 
24 class TAG_PARSER_EXPORT MatroskaContainer : public GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement> {
25 public:
26  MatroskaContainer(MediaFileInfo &stream, std::uint64_t startOffset);
27  ~MatroskaContainer() override;
28 
29  void validateIndex(Diagnostics &diag);
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 
51 protected:
52  void internalParseHeader(Diagnostics &diag) override;
53  void internalParseTags(Diagnostics &diag) override;
54  void internalParseTracks(Diagnostics &diag) override;
55  void internalParseChapters(Diagnostics &diag) override;
56  void internalParseAttachments(Diagnostics &diag) override;
57  void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
58 
59 private:
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 
81 inline std::uint64_t MatroskaContainer::maxIdLength() const
82 {
83  return m_maxIdLength;
84 }
85 
89 inline std::uint64_t MatroskaContainer::maxSizeLength() const
90 {
91  return m_maxSizeLength;
92 }
93 
97 inline const std::vector<std::unique_ptr<MatroskaSeekInfo>> &MatroskaContainer::seekInfos() const
98 {
99  return m_seekInfos;
100 }
101 
116 {
117  return m_maxFullParseSize;
118 }
119 
124 inline void MatroskaContainer::setMaxFullParseSize(std::uint64_t maxFullParseSize)
125 {
126  m_maxFullParseSize = maxFullParseSize;
127 }
128 
132 inline 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 
142 inline std::size_t MatroskaContainer::attachmentCount() const
143 {
144  return m_attachments.size();
145 }
146 
148 {
149  return true;
150 }
151 
152 inline std::size_t MatroskaContainer::segmentCount() const
153 {
154  return m_segmentInfoElements.size();
155 }
156 
157 } // namespace TagParser
158 
159 #endif // MATROSKACONTAINER_H
matroskaattachment.h
TagParser::MatroskaContainer::setMaxFullParseSize
void setMaxFullParseSize(std::uint64_t maxFullParseSize)
Sets the maximal file size for a "full parse" in byte.
Definition: matroskacontainer.h:124
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks....
Definition: progressfeedback.h:186
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::MatroskaChapter
The MatroskaChapter class provides an implementation of AbstractAttachment for Matroska files.
Definition: matroskachapter.h:12
TagParser::MatroskaContainer::editionEntires
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires() const
Returns the edition entries.
Definition: matroskacontainer.h:132
matroskatag.h
TagParser::MatroskaAttachment
Implementation of TagParser::AbstractAttachment for the Matroska container.
Definition: matroskaattachment.h:44
TagParser::MatroskaContainer::seekInfos
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & seekInfos() const
Returns seek information read from "SeekHead"-elements when parsing segment info.
Definition: matroskacontainer.h:97
matroskatrack.h
TagParser::MatroskaContainer::segmentCount
virtual std::size_t segmentCount() const override
Returns the number of segments.
Definition: matroskacontainer.h:152
TagParser::GenericContainer
The GenericContainer class helps parsing header, track, tag and chapter information of a file.
Definition: genericcontainer.h:22
TagParser::MatroskaContainer::maxSizeLength
std::uint64_t maxSizeLength() const
Returns the maximal size length in bytes.
Definition: matroskacontainer.h:89
TagParser::MatroskaContainer::maxFullParseSize
static std::uint64_t maxFullParseSize()
Returns the maximal file size for a "full parse" in byte.
Definition: matroskacontainer.h:115
TagParser::MatroskaContainer::attachment
MatroskaAttachment * attachment(std::size_t index) override
Returns the attachment with the specified index.
Definition: matroskacontainer.h:137
TagParser::MatroskaContainer::maxIdLength
std::uint64_t maxIdLength() const
Returns the maximal ID length in bytes.
Definition: matroskacontainer.h:81
matroskachapter.h
TagParser::ElementPosition
ElementPosition
Definition: settings.h:13
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
ebmlelement.h
TagParser::MatroskaContainer
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
Definition: matroskacontainer.h:24
TagParser::MediaFileInfo
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition: mediafileinfo.h:45
TagParser::MatroskaContainer::attachmentCount
std::size_t attachmentCount() const override
Returns the number of attachments the container holds.
Definition: matroskacontainer.h:142
TagParser::MatroskaContainer::supportsTitle
virtual bool supportsTitle() const override
Returns whether the title property is supported.
Definition: matroskacontainer.h:147