Tag Parser 12.4.0
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
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
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:
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.
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...
Implementation of TagParser::AbstractContainer for Ogg files.
void setChecksumValidationEnabled(bool enabled)
Sets whether checksum validation is enabled.
bool isChecksumValidationEnabled() const
Returns whether checksum validation is enabled.
The OggIterator class helps iterating through all segments of an Ogg bitstream.
Implementation of TagParser::AbstractTrack for Ogg streams.
Specialization of TagParser::VorbisComment for Vorbis comments inside an Ogg stream.
OggParameter & oggParams()
Returns the Ogg parameter for the comment.
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.
OggVorbisComment()
Constructs a new Ogg Vorbis comment.
The TagTarget class specifies the target of a tag.
The Tag class is used to store, read and write tag information.
Implementation of TagParser::Tag for Vorbis comments.
#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...