Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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 const std::vector<std::unique_ptr<MatroskaEditionEntry>> &editionEntires() const;
35 MatroskaChapter *chapter(std::size_t index) override;
36 std::size_t chapterCount() const override;
37 MatroskaAttachment *createAttachment() override;
38 MatroskaAttachment *attachment(std::size_t index) override;
39 std::size_t attachmentCount() const override;
40 ElementPosition determineElementPosition(std::uint64_t elementId, Diagnostics &diag) const;
41 ElementPosition determineTagPosition(Diagnostics &diag) const override;
42 ElementPosition determineIndexPosition(Diagnostics &diag) const override;
43
44 virtual bool supportsTitle() const override;
45 virtual std::size_t segmentCount() const override;
46
47 void reset() override;
48
49protected:
50 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
51 void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override;
52 void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override;
53 void internalParseChapters(Diagnostics &diag, AbortableProgressFeedback &progress) override;
54 void internalParseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress) override;
55 void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
56
57private:
58 void parseSegmentInfo(Diagnostics &diag);
59 void readTrackStatisticsFromTags(Diagnostics &diag);
60
61 std::uint64_t m_maxIdLength;
62 std::uint64_t m_maxSizeLength;
63
64 std::vector<EbmlElement *> m_tracksElements;
65 std::vector<EbmlElement *> m_segmentInfoElements;
66 std::vector<EbmlElement *> m_tagsElements;
67 std::vector<EbmlElement *> m_chaptersElements;
68 std::vector<EbmlElement *> m_attachmentsElements;
69 std::vector<std::unique_ptr<MatroskaSeekInfo>> m_seekInfos;
70 std::vector<std::unique_ptr<MatroskaEditionEntry>> m_editionEntries;
71 std::vector<std::unique_ptr<MatroskaAttachment>> m_attachments;
72 std::size_t m_segmentCount;
73};
74
78inline std::uint64_t MatroskaContainer::maxIdLength() const
79{
80 return m_maxIdLength;
81}
82
86inline std::uint64_t MatroskaContainer::maxSizeLength() const
87{
88 return m_maxSizeLength;
89}
90
94inline const std::vector<std::unique_ptr<MatroskaSeekInfo>> &MatroskaContainer::seekInfos() const
95{
96 return m_seekInfos;
97}
98
102inline const std::vector<std::unique_ptr<MatroskaEditionEntry>> &MatroskaContainer::editionEntires() const
103{
104 return m_editionEntries;
105}
106
108{
109 return m_attachments.at(index).get();
110}
111
112inline std::size_t MatroskaContainer::attachmentCount() const
113{
114 return m_attachments.size();
115}
116
118{
119 return true;
120}
121
122inline std::size_t MatroskaContainer::segmentCount() const
123{
124 return m_segmentInfoElements.size();
125}
126
127} // namespace TagParser
128
129#endif // MATROSKACONTAINER_H
Implementation of TagParser::AbstractAttachment for the Matroska container.
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.
virtual bool supportsTitle() const override
Returns whether the title property is supported.
std::uint64_t maxIdLength() const
Returns the maximal ID length in bytes.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
ElementPosition
Definition settings.h:13