Tag Parser 12.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
flacmetadata.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_FLACMETADATAHEADER_H
2#define TAG_PARSER_FLACMETADATAHEADER_H
3
4#include "../global.h"
5
6#include <cstdint>
7#include <iostream>
8
9namespace TagParser {
10
11class TagValue;
12
17
18constexpr bool operator==(std::uint8_t lhs, FlacMetaDataBlockType type)
19{
20 return lhs == static_cast<std::uint8_t>(type);
21}
22
23constexpr bool operator!=(std::uint8_t lhs, FlacMetaDataBlockType type)
24{
25 return lhs != static_cast<std::uint8_t>(type);
26}
27
28class TAG_PARSER_EXPORT FlacMetaDataBlockHeader {
29public:
30 constexpr FlacMetaDataBlockHeader();
31
32 void parseHeader(std::string_view buffer);
33 void makeHeader(std::ostream &outputStream);
34
35 constexpr std::uint8_t isLast() const;
36 void setLast(std::uint8_t last);
37 constexpr std::uint8_t type() const;
38 void setType(FlacMetaDataBlockType type);
39 constexpr std::uint32_t dataSize() const;
40 void setDataSize(std::uint32_t dataSize);
41
42private:
43 std::uint8_t m_last;
44 std::uint8_t m_type;
45 std::uint32_t m_dataSize;
46};
47
52 : m_last(0)
53 , m_type(0)
54 , m_dataSize(0)
55{
56}
57
62constexpr std::uint8_t FlacMetaDataBlockHeader::isLast() const
63{
64 return m_last;
65}
66
70inline void FlacMetaDataBlockHeader::setLast(std::uint8_t last)
71{
72 m_last = last;
73}
74
79constexpr std::uint8_t FlacMetaDataBlockHeader::type() const
80{
81 return m_type;
82}
83
88{
89 m_type = static_cast<std::uint8_t>(type);
90}
91
95constexpr std::uint32_t FlacMetaDataBlockHeader::dataSize() const
96{
97 return m_dataSize;
98}
99
104inline void FlacMetaDataBlockHeader::setDataSize(std::uint32_t dataSize)
105{
106 m_dataSize = dataSize;
107}
108
110public:
111 constexpr FlacMetaDataBlockStreamInfo();
112
113 void parse(std::string_view buffer);
114
115 constexpr std::uint16_t minBlockSize() const;
116 constexpr std::uint16_t maxBlockSize() const;
117 constexpr std::uint32_t minFrameSize() const;
118 constexpr std::uint32_t maxFrameSize() const;
119 constexpr std::uint32_t samplingFrequency() const;
120 constexpr std::uint8_t channelCount() const;
121 constexpr std::uint8_t bitsPerSample() const;
122 constexpr std::uint64_t totalSampleCount() const;
123 constexpr const char *md5Sum() const;
124
125private:
126 std::uint16_t m_minBlockSize;
127 std::uint16_t m_maxBlockSize;
128 std::uint32_t m_minFrameSize;
129 std::uint32_t m_maxFrameSize;
130 std::uint32_t m_samplingFrequency;
131 std::uint8_t m_channelCount;
132 std::uint8_t m_bitsPerSample;
133 std::uint64_t m_totalSampleCount;
134 char m_md5Sum[16];
135};
136
141 : m_minBlockSize(0)
142 , m_maxBlockSize(0)
143 , m_minFrameSize(0)
144 , m_maxFrameSize(0)
145 , m_samplingFrequency(0)
146 , m_channelCount(0)
147 , m_bitsPerSample(0)
148 , m_totalSampleCount(0)
149 , m_md5Sum{ 0 }
150{
151}
152
156constexpr std::uint16_t FlacMetaDataBlockStreamInfo::minBlockSize() const
157{
158 return m_minBlockSize;
159}
160
166constexpr std::uint16_t FlacMetaDataBlockStreamInfo::maxBlockSize() const
167{
168 return m_maxBlockSize;
169}
170
176constexpr std::uint32_t FlacMetaDataBlockStreamInfo::minFrameSize() const
177{
178 return m_minFrameSize;
179}
180
186constexpr std::uint32_t FlacMetaDataBlockStreamInfo::maxFrameSize() const
187{
188 return m_maxFrameSize;
189}
190
198{
199 return m_samplingFrequency;
200}
201
207constexpr std::uint8_t FlacMetaDataBlockStreamInfo::channelCount() const
208{
209 return m_channelCount;
210}
211
219constexpr std::uint8_t FlacMetaDataBlockStreamInfo::bitsPerSample() const
220{
221 return m_bitsPerSample;
222}
223
233{
234 return m_totalSampleCount;
235}
236
243constexpr const char *FlacMetaDataBlockStreamInfo::md5Sum() const
244{
245 return m_md5Sum;
246}
247
249public:
251
252 void parse(std::istream &inputStream, std::uint32_t maxSize);
253 std::uint32_t requiredSize() const;
254 void make(std::ostream &outputStream);
255
256 std::uint32_t pictureType() const;
257 void setPictureType(std::uint32_t pictureType);
258 TagValue &value();
259
260private:
261 std::uint32_t m_pictureType;
262 TagValue &m_value;
263};
264
273 : m_pictureType(0)
274 , m_value(tagValue)
275{
276}
277
281inline std::uint32_t FlacMetaDataBlockPicture::pictureType() const
282{
283 return m_pictureType;
284}
285
289inline void FlacMetaDataBlockPicture::setPictureType(std::uint32_t pictureType)
290{
291 m_pictureType = pictureType;
292}
293
298{
299 return m_value;
300}
301
302} // namespace TagParser
303
304#endif // TAG_PARSER_FLACMETADATAHEADER_H
constexpr std::uint32_t dataSize() const
Returns the length in bytes of the meta data (excluding the size of the header itself).
void setType(FlacMetaDataBlockType type)
Sets the block type.
constexpr std::uint8_t type() const
Returns the block type.
void setLast(std::uint8_t last)
Sets whether this is the last metadata block before the audio blocks.
constexpr std::uint8_t isLast() const
Returns whether this is the last metadata block before the audio blocks.
void setDataSize(std::uint32_t dataSize)
Sets the length in bytes of the meta data (excluding the size of the header itself).
constexpr FlacMetaDataBlockHeader()
Constructs a new FLAC "METADATA_BLOCK_HEADER".
The FlacMetaDataBlockPicture class is a FLAC "METADATA_BLOCK_PICTURE" parser and maker.
void setPictureType(std::uint32_t pictureType)
Sets the picture type according to the ID3v2 APIC frame.
FlacMetaDataBlockPicture(TagValue &tagValue)
Constructs a new FLAC "METADATA_BLOCK_PICTURE".
std::uint32_t pictureType() const
Returns the picture type according to the ID3v2 APIC frame.
TagValue & value()
Returns the tag value the picture is read from/stored to.
The FlacMetaDataBlockStreamInfo class is a FLAC "METADATA_BLOCK_STREAMINFO" parser.
constexpr std::uint64_t totalSampleCount() const
Returns the total samples in stream.
constexpr const char * md5Sum() const
Returns the MD5 signature of the unencoded audio data.
constexpr std::uint32_t samplingFrequency() const
Returns the sampling frequency in Hz.
constexpr std::uint16_t maxBlockSize() const
Returns the maximum block size (in samples) used in the stream.
constexpr std::uint32_t maxFrameSize() const
The maximum frame size (in bytes) used in the stream.
constexpr std::uint32_t minFrameSize() const
Returns the minimum frame size (in bytes) used in the stream.
constexpr FlacMetaDataBlockStreamInfo()
Constructs a new FLAC "METADATA_BLOCK_STREAMINFO".
constexpr std::uint8_t bitsPerSample() const
Returns the bits per sample.
constexpr std::uint16_t minBlockSize() const
Returns the minimum block size (in samples) used in the stream.
constexpr std::uint8_t channelCount() const
Returns the number of channels.
The TagValue class wraps values of different types.
#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
FlacMetaDataBlockType
The FlacMetaDataBlockType enum specifies the type of FlacMetaDataBlockHeader.
constexpr bool operator!=(std::uint8_t lhs, FlacMetaDataBlockType type)
constexpr bool operator==(std::uint8_t lhs, FlacMetaDataBlockType type)