Tag Parser 11.5.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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
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
47 : firstPageIndex(0)
48 , firstSegmentIndex(0)
49 , lastPageIndex(0)
50 , lastSegmentIndex(0)
51 , streamFormat(GeneralMediaFormat::Vorbis)
52 , lastMetaDataBlock(false)
53 , removed(false)
54{
55}
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
75 static constexpr TagType tagType = TagType::OggVorbisComment;
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
81 OggParameter &oggParams();
82 const OggParameter &oggParams() const;
83
84private:
85 OggParameter m_oggParams;
86};
87
92{
93}
94
96{
98}
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:
138 OggContainer(MediaFileInfo &fileInfo, std::uint64_t startOffset);
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.
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:134
void setChecksumValidationEnabled(bool enabled)
Sets whether checksum validation is enabled.
Definition: oggcontainer.h:186
bool isChecksumValidationEnabled() const
Returns whether checksum validation is enabled.
Definition: oggcontainer.h:177
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:69
OggParameter & oggParams()
Returns the OGG parameter for the comment.
Definition: oggcontainer.h:118
TagType type() const override
Returns the type of the tag as TagParser::TagType.
Definition: oggcontainer.h:95
bool supportsTarget() const override
Returns true; the target is used to specify the stream.
Definition: oggcontainer.h:107
OggVorbisComment()
Constructs a new OGG Vorbis comment.
Definition: oggcontainer.h:91
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:163
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.
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.
Definition: oggcontainer.h:29
GeneralMediaFormat streamFormat
Definition: oggcontainer.h:37
std::size_t lastPageIndex
Definition: oggcontainer.h:35
std::size_t lastSegmentIndex
Definition: oggcontainer.h:36
constexpr OggParameter()
Creates new parameters.
Definition: oggcontainer.h:46
std::size_t firstSegmentIndex
Definition: oggcontainer.h:34
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:61
std::size_t firstPageIndex
Definition: oggcontainer.h:33