Tag Parser  6.2.2
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 MATROSKACONTAINER_H
2 #define MATROSKACONTAINER_H
3 
4 #include "./ebmlelement.h"
5 #include "./matroskatag.h"
6 #include "./matroskatrack.h"
7 #include "./matroskachapter.h"
8 #include "./matroskaattachment.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 Media {
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 {
27 public:
28  MatroskaContainer(MediaFileInfo &stream, uint64 startOffset);
30 
31  void validateIndex();
32  uint64 maxIdLength() const;
33  uint64 maxSizeLength() const;
34  const std::vector<std::unique_ptr<MatroskaSeekInfo> > &seekInfos() const;
35 
36  static uint64 maxFullParseSize();
37  void setMaxFullParseSize(uint64 maxFullParseSize);
38  const std::vector<std::unique_ptr<MatroskaEditionEntry> > &editionEntires() const;
39  MatroskaChapter *chapter(std::size_t index);
40  std::size_t chapterCount() const;
41  MatroskaAttachment *createAttachment();
42  MatroskaAttachment *attachment(std::size_t index);
43  std::size_t attachmentCount() const;
44  ElementPosition determineElementPosition(uint64 elementId) const;
45  ElementPosition determineTagPosition() const;
46  ElementPosition determineIndexPosition() const;
47 
48  virtual bool supportsTitle() const;
49  virtual std::size_t segmentCount() const;
50 
51  void reset();
52 
53 protected:
54  void internalParseHeader();
55  void internalParseTags();
56  void internalParseTracks();
57  void internalParseChapters();
58  void internalParseAttachments();
59  void internalMakeFile();
60 
61 private:
62  void parseSegmentInfo();
63  void fetchEditionEntryElements();
64 
65  uint64 m_maxIdLength;
66  uint64 m_maxSizeLength;
67 
68  std::vector<EbmlElement *> m_tracksElements;
69  std::vector<EbmlElement *> m_segmentInfoElements;
70  std::vector<EbmlElement *> m_tagsElements;
71  std::vector<EbmlElement *> m_chaptersElements;
72  std::vector<EbmlElement *> m_attachmentsElements;
73  std::vector<std::unique_ptr<MatroskaSeekInfo> > m_seekInfos;
74  std::vector<std::unique_ptr<MatroskaEditionEntry> > m_editionEntries;
75  std::vector<std::unique_ptr<MatroskaAttachment> > m_attachments;
76  std::size_t m_segmentCount;
77  static uint64 m_maxFullParseSize;
78 };
79 
83 inline uint64 MatroskaContainer::maxIdLength() const
84 {
85  return m_maxIdLength;
86 }
87 
91 inline uint64 MatroskaContainer::maxSizeLength() const
92 {
93  return m_maxSizeLength;
94 }
95 
99 inline const std::vector<std::unique_ptr<MatroskaSeekInfo> > &MatroskaContainer::seekInfos() const
100 {
101  return m_seekInfos;
102 }
103 
118 {
119  return m_maxFullParseSize;
120 }
121 
126 inline void MatroskaContainer::setMaxFullParseSize(uint64 maxFullParseSize)
127 {
128  m_maxFullParseSize = maxFullParseSize;
129 }
130 
134 inline const std::vector<std::unique_ptr<MatroskaEditionEntry> > &MatroskaContainer::editionEntires() const
135 {
136  return m_editionEntries;
137 }
138 
140 {
141  return m_attachments.at(index).get();
142 }
143 
144 inline std::size_t MatroskaContainer::attachmentCount() const
145 {
146  return m_attachments.size();
147 }
148 
150 {
151  return true;
152 }
153 
154 inline std::size_t MatroskaContainer::segmentCount() const
155 {
156  return m_segmentInfoElements.size();
157 }
158 
159 }
160 
161 #endif // MATROSKACONTAINER_H
virtual bool supportsTitle() const
Returns whether the title property is supported.
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
void setMaxFullParseSize(uint64 maxFullParseSize)
Sets the maximal file size for a "full parse" in byte.
The GenericContainer class helps parsing header, track, tag and chapter information of a file...
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & seekInfos() const
Returns seek information read from "SeekHead"-elements when parsing segment info. ...
virtual std::size_t segmentCount() const
Returns the number of segments.
std::size_t attachmentCount() const
Returns the number of attachments the container holds.
The MatroskaChapter class provides an implementation of AbstractAttachment for Matroska files...
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition: mediafileinfo.h:52
uint64 maxIdLength() const
Returns the maximal ID length in bytes.
uint64 maxSizeLength() const
Returns the maximal size length in bytes.
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires() const
Returns the edition entries.
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Implementation of Media::AbstractAttachment for the Matroska container.
MatroskaAttachment * attachment(std::size_t index)
Returns the attachment with the specified index.
static uint64 maxFullParseSize()
Returns the maximal file size for a "full parse" in byte.