Tag Parser 12.5.0
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
21
22class MediaFileInfo;
23
24class TAG_PARSER_EXPORT MatroskaContainer final : public GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement> {
25public:
27 ~MatroskaContainer() override;
28
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;
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;
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;
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
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::iostream & stream()
Returns the related stream.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
The Diagnostics class is a container for DiagMessage.
Implementation of TagParser::AbstractAttachment for the Matroska container.
The MatroskaChapter class provides an implementation of AbstractAttachment for Matroska files.
void internalParseChapters(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the chapters.
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the header.
virtual std::size_t segmentCount() const override
Returns the number of segments.
std::size_t chapterCount() const override
Returns the number of chapters the container holds.
void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tracks.
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & seekInfos() const
Returns seek information read from "SeekHead"-elements when parsing segment info.
ElementPosition determineTagPosition(Diagnostics &diag) const override
Determines the position of the tags inside the file.
std::size_t attachmentCount() const override
Returns the number of attachments the container holds.
MatroskaAttachment * createAttachment() override
Creates and returns a new attachment.
void reset() override
Discards all parsing results.
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires() const
Returns the edition entries.
MatroskaContainer(MediaFileInfo &stream, std::uint64_t startOffset)
Constructs a new container for the specified fileInfo at the specified startOffset.
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 internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to make the file.
virtual bool supportsTitle() const override
Returns whether the title property is supported.
MatroskaChapter * chapter(std::size_t index) override
Returns the chapter with the specified index.
ElementPosition determineIndexPosition(Diagnostics &diag) const override
Determines the position of the index.
void internalParseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the attachments.
std::uint64_t maxIdLength() const
Returns the maximal ID length in bytes.
ElementPosition determineElementPosition(std::uint64_t elementId, Diagnostics &diag) const
Determines the position of the element with the specified elementId.
void validateIndex(Diagnostics &diag, AbortableProgressFeedback &progress)
Validates the file index (cue entries).
void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tags.
The MatroskaEditionEntry class provides a parser for edition entries in Matroska files.
The MatroskaSeekInfo class helps parsing and making "SeekHead"-elements.
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
#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