Tag Parser  7.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
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 <c++utilities/conversion/types.h>
7 
8 #include <iostream>
9 
10 namespace TagParser {
11 
12 class TagValue;
13 
18 
19 constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
20 {
21  return lhs == static_cast<byte>(type);
22 }
23 
24 constexpr bool operator!=(byte lhs, FlacMetaDataBlockType type)
25 {
26  return lhs != static_cast<byte>(type);
27 }
28 
30 public:
32 
33  void parseHeader(const char *buffer);
34  void makeHeader(std::ostream &outputStream);
35 
36  byte isLast() const;
37  void setLast(byte last);
38  byte type() const;
39  void setType(FlacMetaDataBlockType type);
40  uint32 dataSize() const;
41  void setDataSize(uint32 dataSize);
42 
43 private:
44  byte m_last;
45  byte m_type;
46  uint32 m_dataSize;
47 };
48 
53  : m_last(0)
54  , m_type(0)
55  , m_dataSize(0)
56 {
57 }
58 
64 {
65  return m_last;
66 }
67 
71 inline void FlacMetaDataBlockHeader::setLast(byte last)
72 {
73  m_last = last;
74 }
75 
80 inline byte FlacMetaDataBlockHeader::type() const
81 {
82  return m_type;
83 }
84 
89 {
90  m_type = static_cast<byte>(type);
91 }
92 
96 inline uint32 FlacMetaDataBlockHeader::dataSize() const
97 {
98  return m_dataSize;
99 }
100 
105 inline void FlacMetaDataBlockHeader::setDataSize(uint32 dataSize)
106 {
107  m_dataSize = dataSize;
108 }
109 
111 public:
113 
114  void parse(const char *buffer);
115 
116  uint16 minBlockSize() const;
117  uint16 maxBlockSize() const;
118  uint32 minFrameSize() const;
119  uint32 maxFrameSize() const;
120  uint32 samplingFrequency() const;
121  byte channelCount() const;
122  byte bitsPerSample() const;
123  uint64 totalSampleCount() const;
124  const char *md5Sum() const;
125 
126 private:
127  uint16 m_minBlockSize;
128  uint16 m_maxBlockSize;
129  uint32 m_minFrameSize;
130  uint32 m_maxFrameSize;
131  uint32 m_samplingFrequency;
132  byte m_channelCount;
133  byte m_bitsPerSample;
134  uint64 m_totalSampleCount;
135  char m_md5Sum[16];
136 };
137 
142  : m_minBlockSize(0)
143  , m_maxBlockSize(0)
144  , m_minFrameSize(0)
145  , m_maxFrameSize(0)
146  , m_samplingFrequency(0)
147  , m_channelCount(0)
148  , m_bitsPerSample(0)
149  , m_totalSampleCount(0)
150  , m_md5Sum{ 0 }
151 {
152 }
153 
158 {
159  return m_minBlockSize;
160 }
161 
168 {
169  return m_maxBlockSize;
170 }
171 
178 {
179  return m_minFrameSize;
180 }
181 
188 {
189  return m_maxFrameSize;
190 }
191 
199 {
200  return m_samplingFrequency;
201 }
202 
209 {
210  return m_channelCount;
211 }
212 
221 {
222  return m_bitsPerSample;
223 }
224 
234 {
235  return m_totalSampleCount;
236 }
237 
244 inline const char *FlacMetaDataBlockStreamInfo::md5Sum() const
245 {
246  return m_md5Sum;
247 }
248 
250 public:
252 
253  void parse(std::istream &inputStream, uint32 maxSize);
254  uint32 requiredSize() const;
255  void make(std::ostream &outputStream);
256 
257  uint32 pictureType() const;
258  void setPictureType(uint32 pictureType);
259  TagValue &value();
260 
261 private:
262  uint32 m_pictureType;
263  TagValue &m_value;
264 };
265 
274  : m_pictureType(0)
275  , m_value(tagValue)
276 {
277 }
278 
283 {
284  return m_pictureType;
285 }
286 
290 inline void FlacMetaDataBlockPicture::setPictureType(uint32 pictureType)
291 {
292  m_pictureType = pictureType;
293 }
294 
299 {
300  return m_value;
301 }
302 
303 } // namespace TagParser
304 
305 #endif // TAG_PARSER_FLACMETADATAHEADER_H
TAG_PARSER_EXPORT byte channelCount(byte config)
Returns the channel count for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:445
uint16 minBlockSize() const
Returns the minimum block size (in samples) used in the stream.
Definition: flacmetadata.h:157
FlacMetaDataBlockHeader()
Constructs a new FLAC "METADATA_BLOCK_HEADER".
Definition: flacmetadata.h:52
byte isLast() const
Returns whether this is the last metadata block before the audio blocks.
Definition: flacmetadata.h:63
uint32 minFrameSize() const
Returns the minimum frame size (in bytes) used in the stream.
Definition: flacmetadata.h:177
uint32 samplingFrequency() const
Returns the sampling frequency in Hz.
Definition: flacmetadata.h:198
constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:19
FlacMetaDataBlockPicture(TagValue &tagValue)
Constructs a new FLAC "METADATA_BLOCK_PICTURE".
Definition: flacmetadata.h:273
void setDataSize(uint32 dataSize)
Sets the length in bytes of the meta data (excluding the size of the header itself).
Definition: flacmetadata.h:105
uint64 totalSampleCount() const
Returns the total samples in stream.
Definition: flacmetadata.h:233
void setPictureType(uint32 pictureType)
Sets the picture type according to the ID3v2 APIC frame.
Definition: flacmetadata.h:290
byte channelCount() const
Returns the number of channels.
Definition: flacmetadata.h:208
constexpr bool operator!=(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:24
uint16 maxBlockSize() const
Returns the maximum block size (in samples) used in the stream.
Definition: flacmetadata.h:167
uint32 dataSize() const
Returns the length in bytes of the meta data (excluding the size of the header itself).
Definition: flacmetadata.h:96
const char * md5Sum() const
Returns the MD5 signature of the unencoded audio data.
Definition: flacmetadata.h:244
byte bitsPerSample() const
Returns the bits per sample.
Definition: flacmetadata.h:220
void setType(FlacMetaDataBlockType type)
Sets the block type.
Definition: flacmetadata.h:88
uint32 pictureType() const
Returns the picture type according to the ID3v2 APIC frame.
Definition: flacmetadata.h:282
TagValue & value()
Returns the tag value the picture is read from/stored to.
Definition: flacmetadata.h:298
void setLast(byte last)
Sets whether this is the last metadata block before the audio blocks.
Definition: flacmetadata.h:71
uint32 maxFrameSize() const
The maximum frame size (in bytes) used in the stream.
Definition: flacmetadata.h:187
byte type() const
Returns the block type.
Definition: flacmetadata.h:80
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
FlacMetaDataBlockStreamInfo()
Constructs a new FLAC "METADATA_BLOCK_STREAMINFO".
Definition: flacmetadata.h:141
FlacMetaDataBlockType
The FlacMetaDataBlockType enum specifies the type of FlacMetaDataBlockHeader.
Definition: flacmetadata.h:17