Tag Parser  6.4.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 MEDIA_FLACMETADATAHEADER_H
2 #define MEDIA_FLACMETADATAHEADER_H
3 
4 #include "../global.h"
5 
6 #include <c++utilities/conversion/types.h>
7 
8 #include <iostream>
9 
10 namespace Media {
11 
12 class TagValue;
13 
17 enum class FlacMetaDataBlockType : byte
18 {
19  StreamInfo = 0,
20  Padding,
22  SeekTable,
24  CuseSheet,
25  Picture
26 };
27 
28 constexpr bool operator ==(byte lhs, FlacMetaDataBlockType type)
29 {
30  return lhs == static_cast<byte>(type);
31 }
32 
33 constexpr bool operator !=(byte lhs, FlacMetaDataBlockType type)
34 {
35  return lhs != static_cast<byte>(type);
36 }
37 
39 {
40 public:
42 
43  void parseHeader(const char *buffer);
44  void makeHeader(std::ostream &outputStream);
45 
46  byte isLast() const;
47  void setLast(byte last);
48  byte type() const;
49  void setType(FlacMetaDataBlockType type);
50  uint32 dataSize() const;
51  void setDataSize(uint32 dataSize);
52 
53 private:
54  byte m_last;
55  byte m_type;
56  uint32 m_dataSize;
57 };
58 
63  m_last(0),
64  m_type(0),
65  m_dataSize(0)
66 {}
67 
73 {
74  return m_last;
75 }
76 
80 inline void FlacMetaDataBlockHeader::setLast(byte last)
81 {
82  m_last = last;
83 }
84 
89 inline byte FlacMetaDataBlockHeader::type() const
90 {
91  return m_type;
92 }
93 
98 {
99  m_type = static_cast<byte>(type);
100 }
101 
106 {
107  return m_dataSize;
108 }
109 
115 {
116  m_dataSize = dataSize;
117 }
118 
120 {
121 public:
123 
124  void parse(const char *buffer);
125 
126  uint16 minBlockSize() const;
127  uint16 maxBlockSize() const;
128  uint32 minFrameSize() const;
129  uint32 maxFrameSize() const;
130  uint32 samplingFrequency() const;
131  byte channelCount() const;
132  byte bitsPerSample() const;
133  uint64 totalSampleCount() const;
134  const char *md5Sum() const;
135 
136 private:
137  uint16 m_minBlockSize;
138  uint16 m_maxBlockSize;
139  uint32 m_minFrameSize;
140  uint32 m_maxFrameSize;
141  uint32 m_samplingFrequency;
142  byte m_channelCount;
143  byte m_bitsPerSample;
144  uint64 m_totalSampleCount;
145  char m_md5Sum[16];
146 };
147 
152  m_minBlockSize(0),
153  m_maxBlockSize(0),
154  m_minFrameSize(0),
155  m_maxFrameSize(0),
156  m_samplingFrequency(0),
157  m_channelCount(0),
158  m_bitsPerSample(0),
159  m_totalSampleCount(0),
160  m_md5Sum{0}
161 {}
162 
167 {
168  return m_minBlockSize;
169 }
170 
177 {
178  return m_maxBlockSize;
179 }
180 
187 {
188  return m_minFrameSize;
189 }
190 
197 {
198  return m_maxFrameSize;
199 }
200 
208 {
209  return m_samplingFrequency;
210 }
211 
218 {
219  return m_channelCount;
220 }
221 
230 {
231  return m_bitsPerSample;
232 }
233 
243 {
244  return m_totalSampleCount;
245 }
246 
253 inline const char *FlacMetaDataBlockStreamInfo::md5Sum() const
254 {
255  return m_md5Sum;
256 }
257 
259 {
260 public:
262 
263  void parse(std::istream &inputStream, uint32 maxSize);
264  uint32 requiredSize() const;
265  void make(std::ostream &outputStream);
266 
267  uint32 pictureType() const;
268  void setPictureType(uint32 pictureType);
269  TagValue &value();
270 
271 private:
272  uint32 m_pictureType;
273  TagValue &m_value;
274 };
275 
284  m_pictureType(0),
285  m_value(tagValue)
286 {}
287 
292 {
293  return m_pictureType;
294 }
295 
300 {
301  m_pictureType = pictureType;
302 }
303 
308 {
309  return m_value;
310 }
311 
312 }
313 
314 #endif // MEDIA_FLACMETADATAHEADER_H
The TagValue class wraps values of different types.
Definition: tagvalue.h:64
const char * md5Sum() const
Returns the MD5 signature of the unencoded audio data.
Definition: flacmetadata.h:253
void setPictureType(uint32 pictureType)
Sets the picture type according to the ID3v2 APIC frame.
Definition: flacmetadata.h:299
FlacMetaDataBlockType
The FlacMetaDataBlockType enum specifies the type of FlacMetaDataBlockHeader.
Definition: flacmetadata.h:17
byte type() const
Returns the block type.
Definition: flacmetadata.h:89
byte isLast() const
Returns whether this is the last metadata block before the audio blocks.
Definition: flacmetadata.h:72
uint32 maxFrameSize() const
The maximum frame size (in bytes) used in the stream.
Definition: flacmetadata.h:196
FlacMetaDataBlockStreamInfo()
Constructs a new FLAC "METADATA_BLOCK_STREAMINFO".
Definition: flacmetadata.h:151
The FlacMetaDataBlockHeader class is a FLAC "METADATA_BLOCK_HEADER" parser and maker.
Definition: flacmetadata.h:38
FlacMetaDataBlockHeader()
Constructs a new FLAC "METADATA_BLOCK_HEADER".
Definition: flacmetadata.h:62
uint16 minBlockSize() const
Returns the minimum block size (in samples) used in the stream.
Definition: flacmetadata.h:166
void parse(const char *buffer)
Parses the FLAC "METADATA_BLOCK_STREAMINFO" which is read using the specified iterator.
TagValue & value()
Returns the tag value the picture is read from/stored to.
Definition: flacmetadata.h:307
uint32 minFrameSize() const
Returns the minimum frame size (in bytes) used in the stream.
Definition: flacmetadata.h:186
constexpr bool operator!=(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:33
The FlacMetaDataBlockStreamInfo class is a FLAC "METADATA_BLOCK_STREAMINFO" parser.
Definition: flacmetadata.h:119
uint16 maxBlockSize() const
Returns the maximum block size (in samples) used in the stream.
Definition: flacmetadata.h:176
byte bitsPerSample() const
Returns the bits per sample.
Definition: flacmetadata.h:229
FlacMetaDataBlockPicture(TagValue &tagValue)
Constructs a new FLAC "METADATA_BLOCK_PICTURE".
Definition: flacmetadata.h:283
uint64 totalSampleCount() const
Returns the total samples in stream.
Definition: flacmetadata.h:242
TAG_PARSER_EXPORT byte channelCount(byte config)
Returns the channel count for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:342
uint32 pictureType() const
Returns the picture type according to the ID3v2 APIC frame.
Definition: flacmetadata.h:291
constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:28
byte channelCount() const
Returns the number of channels.
Definition: flacmetadata.h:217
void setLast(byte last)
Sets whether this is the last metadata block before the audio blocks.
Definition: flacmetadata.h:80
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
uint32 dataSize() const
Returns the length in bytes of the meta data (excluding the size of the header itself).
Definition: flacmetadata.h:105
uint32 samplingFrequency() const
Returns the sampling frequency in Hz.
Definition: flacmetadata.h:207
The FlacMetaDataBlockPicture class is a FLAC "METADATA_BLOCK_PICTURE" parser and maker.
Definition: flacmetadata.h:258
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
void setType(FlacMetaDataBlockType type)
Sets the block type.
Definition: flacmetadata.h:97
void setDataSize(uint32 dataSize)
Sets the length in bytes of the meta data (excluding the size of the header itself).
Definition: flacmetadata.h:114