Tag Parser  10.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
mediaformat.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_MEDIAFORMAT_H
2 #define TAG_PARSER_MEDIAFORMAT_H
3 
4 #include "./global.h"
5 
6 #include <string_view>
7 #include <utility>
8 
9 namespace TagParser {
10 
14 enum class MediaType : unsigned int {
15  Unknown,
16  Audio,
17  Video,
18  Text,
19  Buttons,
20  Control,
21  Hint,
22  Meta,
23 };
24 
25 TAG_PARSER_EXPORT std::string_view mediaTypeName(MediaType mediaType);
26 
30 enum class GeneralMediaFormat : unsigned int {
31  Unknown,
32  Aac,
33  Ac3,
34  Ac4,
35  AdpcmAcm,
36  AfxStream,
37  Alac,
38  Als,
39  Amr,
40  Avc,
41  Av1,
42  Bitmap,
43  Daala,
44  Dirac,
45  DolbyMlp,
46  Dts,
47  DtsHd,
48  DvbSub,
49  EAc3,
50  Evrc,
51  Flac,
53  Gif,
54  Gpp2Cmf,
55  Hevc,
56  ImaadpcmAcm,
59  Jpeg,
63  MonkeysAudio,
64  Mpc,
65  Mpeg1Audio,
66  Mpeg1Video,
67  Mpeg2Audio,
68  Mpeg2Video,
70  Mpeg4Video,
71  OggKate,
72  Opus,
73  Pcm,
74  Png,
75  ProRes,
76  Qcelp,
79  RealAudio,
80  RealVideo,
81  Sa0c,
82  Smv,
83  Speex,
86  Systems,
87  TextSubtitle,
88  Theora,
89  Tiff,
90  TimedText,
91  Tta,
93  Vc1,
94  VobBtn,
95  VobSub,
96  Vorbis,
97  Vp8,
98  Vp9,
99  WavPack,
102 };
103 
109 namespace SubFormats {
110 
111 enum : unsigned char { None };
112 
113 enum Mpeg1AudioLayer : unsigned char { Mpeg1Layer1 = 1, Mpeg1Layer2, Mpeg1Layer3 };
114 
115 enum AacProfile : unsigned char {
128 };
129 
130 enum Mpeg2VideoProfile : unsigned char {
137 };
138 
139 enum Mpeg4VideoProfile : unsigned char {
199 };
200 
201 enum AvcProfile : unsigned char {
216 };
217 
218 enum DtsSpecifier : unsigned char {
223 };
224 
225 enum PcmVersion : unsigned char { PcmIntBe = 1, PcmIntLe, PcmFloatIeee };
226 
227 enum TextSubtitle : unsigned char {
233 };
234 
235 enum ImageSubtitle : unsigned char { ImgSubBmp = 1 };
236 
237 } // namespace SubFormats
238 
242 namespace ExtensionFormats {
244 }
245 
247 public:
248  constexpr MediaFormat(GeneralMediaFormat general = GeneralMediaFormat::Unknown, unsigned char sub = 0, unsigned char extension = 0);
249 
250  std::string_view name() const;
251  std::string_view abbreviation() const;
252  std::string_view shortAbbreviation() const;
253  std::string_view extensionName() const;
254  constexpr operator bool() const;
255  constexpr MediaFormat &operator+=(const MediaFormat &other);
256  constexpr bool operator==(GeneralMediaFormat general) const;
257  constexpr bool operator!=(GeneralMediaFormat general) const;
258 
260  unsigned char sub;
261  unsigned char extension;
262 };
263 
267 constexpr MediaFormat::MediaFormat(GeneralMediaFormat general, unsigned char sub, unsigned char extension)
268  : general(general)
269  , sub(sub)
270  , extension(extension)
271 {
272 }
273 
278 {
279  if (other) {
280  general = other.general;
281  if (other.sub) {
282  sub = other.sub;
283  }
284  if (other.extension) {
285  extension = other.extension;
286  }
287  }
288  return *this;
289 }
290 
294 constexpr bool MediaFormat::operator==(GeneralMediaFormat general) const
295 {
296  return this->general == general;
297 }
298 
302 constexpr bool MediaFormat::operator!=(GeneralMediaFormat general) const
303 {
304  return this->general != general;
305 }
306 
310 constexpr MediaFormat::operator bool() const
311 {
312  return general != GeneralMediaFormat::Unknown;
313 }
314 
315 } // namespace TagParser
316 
317 #endif // TAG_PARSER_MEDIAFORMAT_H
The MediaFormat class specifies the format of media data.
Definition: mediaformat.h:246
constexpr bool operator==(GeneralMediaFormat general) const
Returns whether the media format is the specified general media format.
Definition: mediaformat.h:294
unsigned char extension
Definition: mediaformat.h:261
GeneralMediaFormat general
Definition: mediaformat.h:259
constexpr MediaFormat & operator+=(const MediaFormat &other)
"Adds" information from another instance to the object.
Definition: mediaformat.h:277
constexpr MediaFormat(GeneralMediaFormat general=GeneralMediaFormat::Unknown, unsigned char sub=0, unsigned char extension=0)
Constructs a new media format.
Definition: mediaformat.h:267
constexpr bool operator!=(GeneralMediaFormat general) const
Returns whether the media format is not the specified general media format.
Definition: mediaformat.h:302
#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
constexpr bool operator!=(std::uint8_t lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:23
constexpr bool operator==(std::uint8_t lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:18
@ MonkeysAudio
Definition: signature.cpp:52
MediaType
The MediaType enum specifies the type of media data (audio, video, text, ...).
Definition: mediaformat.h:14
GeneralMediaFormat
The GeneralMediaFormat enum specifies the general format of media data (PCM, MPEG-4,...
Definition: mediaformat.h:30
TAG_PARSER_EXPORT std::string_view mediaTypeName(MediaType mediaType)
Returns the string representation for the specified mediaType.