Tag Parser 12.5.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
9
10#include "../genericcontainer.h"
11
12#include <tuple>
13#include <unordered_map>
14
16namespace CppUtilities {
17template <std::size_t bufferSize> class CopyHelper;
18}
20
21namespace TagParser {
22
23class MediaFileInfo;
24class OggContainer;
25
30 constexpr OggParameter();
31 void set(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat streamFormat = GeneralMediaFormat::Vorbis);
32
33 std::size_t firstPageIndex;
34 std::size_t firstSegmentIndex;
35 std::size_t lastPageIndex;
36 std::size_t lastSegmentIndex;
39 bool removed;
40};
41
56
61inline void OggParameter::set(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat streamFormat)
62{
63 firstPageIndex = lastPageIndex = pageIndex;
64 firstSegmentIndex = lastSegmentIndex = segmentIndex;
65 this->lastMetaDataBlock = lastMetaDataBlock;
66 this->streamFormat = streamFormat;
67}
68
70 friend class OggContainer;
71
72public:
74
76 static constexpr std::string_view tagName = "Ogg Vorbis comment";
77 TagType type() const override;
78 std::string_view typeName() const override;
79 bool supportsTarget() const override;
80
82 const OggParameter &oggParams() const;
83
84private:
85 OggParameter m_oggParams;
86};
87
94
99
108{
109 return true;
110}
111
119{
120 return m_oggParams;
121}
122
130{
131 return m_oggParams;
132}
133
134class TAG_PARSER_EXPORT OggContainer final : public GenericContainer<MediaFileInfo, OggVorbisComment, OggStream, OggPage> {
135 friend class OggStream;
136
137public:
139 ~OggContainer() override;
140
141 bool isChecksumValidationEnabled() const;
142 void setChecksumValidationEnabled(bool enabled);
143 void reset() override;
144
145 OggVorbisComment *createTag(const TagTarget &target) override;
146 OggVorbisComment *tag(std::size_t index) override;
147 std::size_t tagCount() const override;
148 bool removeTag(Tag *tag) override;
149 void removeAllTags() override;
150
151protected:
152 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
153 void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override;
154 void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override;
155 void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override;
156
157private:
158 void announceComment(
159 std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat mediaFormat = GeneralMediaFormat::Vorbis);
160 void makeVorbisCommentSegment(std::stringstream &buffer, CppUtilities::CopyHelper<65307> &copyHelper, std::vector<std::uint32_t> &newSegmentSizes,
161 VorbisComment *comment, OggParameter *params, Diagnostics &diag);
162
163 std::unordered_map<std::uint32_t, std::vector<std::unique_ptr<OggStream>>::size_type> m_streamsBySerialNo;
164
165 OggIterator m_iterator;
166 bool m_validateChecksums;
167};
168
178{
179 return m_validateChecksums;
180}
181
187{
188 m_validateChecksums = enabled;
189}
190
191} // namespace TagParser
192
193#endif // TAG_PARSER_OGGCONTAINER_H
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
The Diagnostics class is a container for DiagMessage.
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Implementation of TagParser::AbstractContainer for Ogg files.
void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tags.
void setChecksumValidationEnabled(bool enabled)
Sets whether checksum validation is enabled.
OggVorbisComment * tag(std::size_t index) override
Returns the tag with the specified index.
std::size_t tagCount() const override
Returns the number of tags attached to the container.
bool isChecksumValidationEnabled() const
Returns whether checksum validation is enabled.
void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the tracks.
OggContainer(MediaFileInfo &fileInfo, std::uint64_t startOffset)
Constructs a new container for the specified stream at the specified startOffset.
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to parse the header.
void removeAllTags() override
Actually just flags all tags as removed and clears all assigned fields.
OggVorbisComment * createTag(const TagTarget &target) override
Creates a new tag.
void reset() override
Discards all parsing results.
void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress) override
Internally called to make the file.
bool removeTag(Tag *tag) override
Actually just flags the specified tag as removed and clears all assigned fields.
The OggIterator class helps iterating through all segments of an Ogg bitstream.
Definition oggiterator.h:11
Specialization of TagParser::VorbisComment for Vorbis comments inside an Ogg stream.
OggParameter & oggParams()
Returns the Ogg parameter for the comment.
static constexpr std::string_view tagName
TagType type() const override
Returns the type of the tag as TagParser::TagType.
bool supportsTarget() const override
Returns true; the target is used to specify the stream.
static constexpr TagType tagType
OggVorbisComment()
Constructs a new Ogg Vorbis comment.
std::string_view typeName() const override
Returns the type name of the tag as C-style string.
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:179
Implementation of TagParser::Tag for Vorbis comments.
VorbisComment()
Constructs a new Vorbis comment.
#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
TagType
Specifies the tag type.
Definition tagtype.h:11
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.
GeneralMediaFormat streamFormat
std::size_t lastSegmentIndex
constexpr OggParameter()
Creates new parameters.
std::size_t firstSegmentIndex
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...