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