Tag Parser: matroska/matroskacontainer.h Source File

Tag Parser 12.5.2 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"
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
17namespace TagParser {
18
19class MatroskaSeekInfo;
20class MatroskaEditionEntry;
21
22class MediaFileInfo;
23
24 class 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
78 inline std::uint64_t MatroskaContainer::maxIdLength() const
79{
80 return m_maxIdLength;
81}
82
86 inline std::uint64_t MatroskaContainer::maxSizeLength() const
87{
88 return m_maxSizeLength;
89}
90
94 inline const std::vector<std::unique_ptr<MatroskaSeekInfo>> &MatroskaContainer::seekInfos() const
95{
96 return m_seekInfos;
97}
98
102 inline const std::vector<std::unique_ptr<MatroskaEditionEntry>> &MatroskaContainer::editionEntires() const
103{
104 return m_editionEntries;
105}
106
107 inline MatroskaAttachment *MatroskaContainer::attachment(std::size_t index)
108{
109 return m_attachments.at(index).get();
110}
111
112 inline std::size_t MatroskaContainer::attachmentCount() const
113{
114 return m_attachments.size();
115}
116
117 inline bool MatroskaContainer::supportsTitle() const
118{
119 return true;
120}
121
122 inline std::size_t MatroskaContainer::segmentCount() const
123{
124 return m_segmentInfoElements.size();
125}
126
127} // namespace TagParser
128
129#endif // MATROSKACONTAINER_H
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::AbstractContainer::stream
std::iostream & stream()
Returns the related stream.
Definition abstractcontainer.h:136
TagParser::AbstractContainer::startOffset
std::uint64_t startOffset() const
Returns the start offset in the related stream.
Definition abstractcontainer.h:154
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >::GenericContainer
GenericContainer(MediaFileInfo &fileInfo, std::uint64_t startOffset)
Definition genericcontainer.h:71
TagParser::MatroskaAttachment
Implementation of TagParser::AbstractAttachment for the Matroska container.
Definition matroskaattachment.h:44
TagParser::MatroskaChapter
The MatroskaChapter class provides an implementation of AbstractAttachment for Matroska files.
Definition matroskachapter.h:12
TagParser::MatroskaContainer::internalParseChapters
void internalParseChapters(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the chapters.
Definition matroskacontainer.cpp:742
TagParser::MatroskaContainer::internalParseHeader
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the header.
Definition matroskacontainer.cpp:401
TagParser::MatroskaContainer::segmentCount
virtual std::size_t segmentCount() const override
Returns the number of segments.
Definition matroskacontainer.h:122
TagParser::MatroskaContainer::chapterCount
std::size_t chapterCount() const override
Returns the number of chapters the container holds.
Definition matroskacontainer.cpp:327
TagParser::MatroskaContainer::internalParseTracks
void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tracks.
Definition matroskacontainer.cpp:706
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:94
TagParser::MatroskaContainer::determineTagPosition
ElementPosition determineTagPosition(Diagnostics &diag) const override
Determines the position of the tags inside the file.
Definition matroskacontainer.cpp:391
TagParser::MatroskaContainer::attachmentCount
std::size_t attachmentCount() const override
Returns the number of attachments the container holds.
Definition matroskacontainer.h:112
TagParser::MatroskaContainer::createAttachment
MatroskaAttachment * createAttachment() override
Creates and returns a new attachment.
Definition matroskacontainer.cpp:336
TagParser::MatroskaContainer::reset
void reset() override
Discards all parsing results.
Definition matroskacontainer.cpp:58
TagParser::MatroskaContainer::editionEntires
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires() const
Returns the edition entries.
Definition matroskacontainer.h:102
TagParser::MatroskaContainer::MatroskaContainer
MatroskaContainer(MediaFileInfo &stream, std::uint64_t startOffset)
Constructs a new container for the specified fileInfo at the specified startOffset.
Definition matroskacontainer.cpp:41
TagParser::MatroskaContainer::maxSizeLength
std::uint64_t maxSizeLength() const
Returns the maximal size length in bytes.
Definition matroskacontainer.h:86
TagParser::MatroskaContainer::attachment
MatroskaAttachment * attachment(std::size_t index) override
Returns the attachment with the specified index.
Definition matroskacontainer.h:107
TagParser::MatroskaContainer::internalMakeFile
void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to make the file.
Definition matroskacontainer.cpp:861
TagParser::MatroskaContainer::supportsTitle
virtual bool supportsTitle() const override
Returns whether the title property is supported.
Definition matroskacontainer.h:117
TagParser::MatroskaContainer::chapter
MatroskaChapter * chapter(std::size_t index) override
Returns the chapter with the specified index.
Definition matroskacontainer.cpp:314
TagParser::MatroskaContainer::determineIndexPosition
ElementPosition determineIndexPosition(Diagnostics &diag) const override
Determines the position of the index.
Definition matroskacontainer.cpp:396
TagParser::MatroskaContainer::internalParseAttachments
void internalParseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the attachments.
Definition matroskacontainer.cpp:776
TagParser::MatroskaContainer::maxIdLength
std::uint64_t maxIdLength() const
Returns the maximal ID length in bytes.
Definition matroskacontainer.h:78
TagParser::MatroskaContainer::determineElementPosition
ElementPosition determineElementPosition(std::uint64_t elementId, Diagnostics &diag) const
Determines the position of the element with the specified elementId.
Definition matroskacontainer.cpp:365
TagParser::MatroskaContainer::validateIndex
void validateIndex(Diagnostics &diag, AbortableProgressFeedback &progress)
Validates the file index (cue entries).
Definition matroskacontainer.cpp:83
TagParser::MatroskaContainer::internalParseTags
void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tags.
Definition matroskacontainer.cpp:665
TagParser::MatroskaEditionEntry
The MatroskaEditionEntry class provides a parser for edition entries in Matroska files.
Definition matroskaeditionentry.h:10
TagParser::MatroskaSeekInfo
The MatroskaSeekInfo class helps parsing and making "SeekHead"-elements.
Definition matroskaseekinfo.h:12
TagParser::MediaFileInfo
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition mediafileinfo.h:83
ebmlelement.h
genericcontainer.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
matroskaattachment.h
matroskachapter.h
matroskatag.h
matroskatrack.h
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::ElementPosition
ElementPosition
Definition settings.h:13