Tag Parser 11.2.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
oggcontainer.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_OGGCONTAINER_H
2#define TAG_PARSER_OGGCONTAINER_H
3
4#include "./oggiterator.h"
5#include "./oggpage.h"
6#include "./oggstream.h"
7
8#include "../vorbis/vorbiscomment.h"
9
10#include "../genericcontainer.h"
11
12#include <tuple>
13#include <unordered_map>
14
15namespace CppUtilities {
16template <std::size_t bufferSize> class CopyHelper;
17}
18
19namespace TagParser {
20
21class MediaFileInfo;
22class OggContainer;
23
28 constexpr OggParameter();
29 void set(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat streamFormat = GeneralMediaFormat::Vorbis);
30
31 std::size_t firstPageIndex;
32 std::size_t firstSegmentIndex;
33 std::size_t lastPageIndex;
34 std::size_t lastSegmentIndex;
37 bool removed;
38};
39
45 : firstPageIndex(0)
46 , firstSegmentIndex(0)
47 , lastPageIndex(0)
48 , lastSegmentIndex(0)
49 , streamFormat(GeneralMediaFormat::Vorbis)
50 , lastMetaDataBlock(false)
51 , removed(false)
52{
53}
54
59inline void OggParameter::set(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat streamFormat)
60{
61 firstPageIndex = lastPageIndex = pageIndex;
62 firstSegmentIndex = lastSegmentIndex = segmentIndex;
63 this->lastMetaDataBlock = lastMetaDataBlock;
64 this->streamFormat = streamFormat;
65}
66
68 friend class OggContainer;
69
70public:
72
73 static constexpr TagType tagType = TagType::OggVorbisComment;
74 static constexpr std::string_view tagName = "OGG Vorbis comment";
75 TagType type() const override;
76 std::string_view typeName() const override;
77 bool supportsTarget() const override;
78
79 OggParameter &oggParams();
80 const OggParameter &oggParams() const;
81
82private:
83 OggParameter m_oggParams;
84};
85
90{
91}
92
94{
96}
97
106{
107 return true;
108}
109
117{
118 return m_oggParams;
119}
120
128{
129 return m_oggParams;
130}
131
132class TAG_PARSER_EXPORT OggContainer final : public GenericContainer<MediaFileInfo, OggVorbisComment, OggStream, OggPage> {
133 friend class OggStream;
134
135public:
136 OggContainer(MediaFileInfo &fileInfo, std::uint64_t startOffset);
137 ~OggContainer() override;
138
139 bool isChecksumValidationEnabled() const;
140 void setChecksumValidationEnabled(bool enabled);
141 void reset() override;
142
143 OggVorbisComment *createTag(const TagTarget &target) override;
144 OggVorbisComment *tag(std::size_t index) override;
145 std::size_t tagCount() const override;
146 bool removeTag(Tag *tag) override;
147 void removeAllTags() override;
148
149protected:
150 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
151 void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override;
152 void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override;
153 void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
154
155private:
156 void announceComment(
157 std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat mediaFormat = GeneralMediaFormat::Vorbis);
158 void makeVorbisCommentSegment(std::stringstream &buffer, CppUtilities::CopyHelper<65307> &copyHelper, std::vector<std::uint32_t> &newSegmentSizes,
160
161 std::unordered_map<std::uint32_t, std::vector<std::unique_ptr<OggStream>>::size_type> m_streamsBySerialNo;
162
163 OggIterator m_iterator;
164 bool m_validateChecksums;
165};
166
176{
177 return m_validateChecksums;
178}
179
185{
186 m_validateChecksums = enabled;
187}
188
189} // namespace TagParser
190
191#endif // TAG_PARSER_OGGCONTAINER_H
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
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.
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition: mediafileinfo.h:76
Implementation of TagParser::AbstractContainer for OGG files.
Definition: oggcontainer.h:132
void setChecksumValidationEnabled(bool enabled)
Sets whether checksum validation is enabled.
Definition: oggcontainer.h:184
bool isChecksumValidationEnabled() const
Returns whether checksum validation is enabled.
Definition: oggcontainer.h:175
The OggIterator class helps iterating through all segments of an OGG bitstream.
Definition: oggiterator.h:11
Implementation of TagParser::AbstractTrack for OGG streams.
Definition: oggstream.h:13
Specialization of TagParser::VorbisComment for Vorbis comments inside an OGG stream.
Definition: oggcontainer.h:67
OggParameter & oggParams()
Returns the OGG parameter for the comment.
Definition: oggcontainer.h:116
TagType type() const override
Returns the type of the tag as TagParser::TagType.
Definition: oggcontainer.h:93
bool supportsTarget() const override
Returns true; the target is used to specify the stream.
Definition: oggcontainer.h:105
OggVorbisComment()
Constructs a new OGG Vorbis comment.
Definition: oggcontainer.h:89
The TagTarget class specifies the target of a tag.
Definition: tagtarget.h:20
The Tag class is used to store, read and write tag information.
Definition: tag.h:177
Implementation of TagParser::Tag for Vorbis comments.
Definition: vorbiscomment.h:25
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
constexpr TAG_PARSER_EXPORT std::string_view comment()
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagType
Specifies the tag type.
Definition: tag.h:20
GeneralMediaFormat
The GeneralMediaFormat enum specifies the general format of media data (PCM, MPEG-4,...
Definition: mediaformat.h:30
The OggParameter struct holds the OGG parameter for a VorbisComment.
Definition: oggcontainer.h:27
GeneralMediaFormat streamFormat
Definition: oggcontainer.h:35
std::size_t lastPageIndex
Definition: oggcontainer.h:33
std::size_t lastSegmentIndex
Definition: oggcontainer.h:34
constexpr OggParameter()
Creates new parameters.
Definition: oggcontainer.h:44
std::size_t firstSegmentIndex
Definition: oggcontainer.h:32
void set(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat streamFormat=GeneralMediaFormat::Vorbis)
Sets the firstPageIndex/lastPageIndex, the firstSegmentIndex/lastSegmentIndex, whether the associated...
Definition: oggcontainer.h:59
std::size_t firstPageIndex
Definition: oggcontainer.h:31