Tag Parser 12.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
mp4ids.cpp
Go to the documentation of this file.
1#include "./mp4ids.h"
2
4#include "../mediaformat.h"
5
6#include <map>
7
8namespace TagParser {
9
13namespace Mp4AtomIds {
14}
15
21namespace Mp4TagAtomIds {
22}
23
27namespace Mp4TagExtendedMeanIds {
28std::string_view iTunes = "com.apple.iTunes";
29}
30
34namespace Mp4TagExtendedNameIds {
35std::string_view cdec = "cdec";
36std::string_view label = "LABEL";
37} // namespace Mp4TagExtendedNameIds
38
42namespace Mp4MediaTypeIds {
43}
44
49namespace FourccIds {
50
51MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
52{
53 switch (fourccId) {
54 case Mpeg:
56 case Mpeg2Imx30:
57 case Mpeg2Imx50:
59 case Mpeg4Video:
61 case Mpeg4TimedText:
63 case Hevc1:
64 case Hevc2:
66 case Vvc1:
68 case Avc1:
69 case Avc2:
70 case Avc3:
71 case Avc4:
72 case H264Decoder1:
73 case H264Decoder2:
74 case H264Decoder3:
75 case H264Decoder4:
76 case H264Decoder5:
77 case H264Decoder6:
79 case Av1_IVF:
80 case Av1_ISOBMFF:
82 case Divx4Decoder1:
83 case Divx4Decoder2:
84 case H263Quicktime:
85 case H2633GPP:
86 case XvidDecoder1:
87 case XvidDecoder2:
88 case XvidDecoder3:
89 case XvidDecoder4:
90 case XvidDecoder5:
91 case Divx5Decoder:
93 case Divx3Decoder1:
94 case Divx3Decoder2:
95 case Divx3Decoder3:
96 case Divx3Decoder4:
97 case Divx3Decoder5:
98 case Divx3Decoder6:
99 case Divx3Decoder7:
100 case Divx3Decoder8:
101 case Divx3Decoder9:
102 case Divx3Decoder10:
103 case Divx3Decoder11:
104 case Divx3Decoder12:
105 case Divx3Decoder13:
106 case Divx3Decoder14:
107 case Divx3Decoder15:
109 case Tiff:
113 case Raw:
115 case Jpeg:
117 case Gif:
119 case Png:
121 case AdpcmAcm:
123 case ImaadpcmAcm:
125 case Mp3CbrOnly:
126 case Mp3:
128 case Mpeg4Audio:
130 case Alac:
132 case Ac3:
134 case EAc3:
136 case DolbyMpl:
138 case Ac4:
140 case Rv20:
141 case Rv30:
142 case Rv40:
144 case Int24:
145 case Int32:
147 case Int16Be:
149 case Int16Le:
154 case Amr:
155 case AmrNarrowband:
157 case Dts:
158 case DtsH:
160 case DtsE:
182 case Vp8:
184 case Vp9:
185 case Vp9_2:
187 case WavPack:
194 case Flac:
196 case Opus:
198 // TODO: map more FOURCCs
199 default:
201 }
202}
203
204} // namespace FourccIds
205
210namespace Mp4FormatExtensionIds {
211}
212
216namespace Mpeg4ElementaryStreamObjectIds {
217
221MediaFormat streamObjectTypeFormat(std::uint8_t streamObjectTypeId)
222{
223 switch (streamObjectTypeId) {
224 case SystemsIso144961:
230 case AfxStream:
232 case FontDataStream:
238 case Mpeg4Visual:
240 case Avc:
244 case Als:
246 case Sa0c:
248 case Aac:
268 case Mpeg2Audio:
270 case Mpeg1Video:
272 case Mpeg1Audio:
274 case Jpeg:
276 case Png:
278 case Evrc:
279 case PrivateEvrc:
281 case Smv:
283 case Gpp2Cmf:
285 case Vc1:
287 case Dirac:
289 case Ac3:
290 case PrivateAc3:
292 case EAc3:
294 case Dts:
295 case PrivateDts:
299 case DtsHdMasterAudio:
301 case DtsHdExpress:
303 case PrivateOgg:
304 case PrivateOgg2:
306 case PrivateVobSub:
308 case PrivateQcelp:
310 default:
311 return MediaFormat();
312 }
313}
314
315} // namespace Mpeg4ElementaryStreamObjectIds
316
320namespace Mpeg4DescriptorIds {
321}
322
326namespace Mpeg4ElementaryStreamTypeIds {
327
331std::string_view streamTypeName(std::uint8_t streamTypeId)
332{
333 switch (streamTypeId) {
334 case ObjectDescriptor:
335 return "object descriptor";
336 case ClockReference:
337 return "clock reference";
338 case SceneDescriptor:
339 return "scene descriptor";
340 case Visual:
341 return "visual";
342 case Audio:
343 return "audio";
344 case Mpeg7:
345 return "MPEG-7";
346 case Ipmps:
347 return "IMPS";
349 return "object content info";
350 case MpegJava:
351 return "MPEG Java";
352 case Interaction:
353 return "interaction";
354 case Ipmp:
355 return "IPMP";
356 case FontData:
357 return "font data";
358 case StreamingText:
359 return "streaming text";
360 default:
361 return "";
362 }
363}
364
365} // namespace Mpeg4ElementaryStreamTypeIds
366
371namespace Mpeg4AudioObjectIds {
372
373TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent, bool psPresent)
374{
375 MediaFormat fmt;
376 switch (mpeg4AudioObjectId) {
377 case AacMain:
379 break;
380 case AacLc:
382 break;
383 case AacSsr:
385 break;
386 case AacLtp:
388 break;
389 case Sbr:
391 break;
392 case AacScalable:
394 break;
395 case ErAacLc:
397 break;
398 case ErAacLtp:
400 break;
401 case ErAacLd:
403 break;
404 case Ps:
406 break;
407 case Layer1:
409 break;
410 case Layer2:
412 break;
413 case Layer3:
415 break;
416 default:;
417 }
418 if (sbrPresent) {
420 }
421 if (psPresent) {
423 }
424 return fmt;
425}
426
427} // namespace Mpeg4AudioObjectIds
428
429std::uint32_t mpeg4SamplingFrequencyTable[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
430
434namespace Mpeg4ChannelConfigs {
435
439std::string_view channelConfigString(std::uint8_t config)
440{
441 switch (config) {
443 return "defined in AOT Specific Config";
444 case FrontCenter:
445 return "1 channel: front-center";
447 return "2 channels: front-left, front-right";
449 return "3 channels: front-center, front-left, front-right";
451 return "4 channels: front-center, front-left, front-right, back-center";
453 return "5 channels: front-center, front-left, front-right, back-left, back-right";
455 return "6 channels: front-center, front-left, front-right, back-left, back-right, LFE-channel";
457 return "8 channels: front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel";
458 default:
459 return std::string_view();
460 }
461}
462
466std::uint8_t channelCount(std::uint8_t config)
467{
468 switch (config) {
469 case FrontCenter:
470 return 1;
472 return 2;
474 return 3;
476 return 4;
478 return 5;
480 return 6;
482 return 8;
483 default:
484 return 0;
485 }
486}
487
488} // namespace Mpeg4ChannelConfigs
489
493namespace Mpeg4VideoCodes {
494}
495
499namespace Mpeg2VideoCodes {
500}
501
502std::string_view mp4TagMediaTypeName(Mp4TagMediaTypeId tagMediaTypeId)
503{
504 switch (static_cast<Mp4TagMediaType>(tagMediaTypeId)) {
506 return "Movie";
508 return "Music";
510 return "Audiobook";
512 return "Whacked Bookmark";
514 return "Music Video";
516 return "Short Film";
518 return "TV Show";
520 return "Booklet";
522 return "Ringtone";
524 return "Podcast";
525 default:
526 return std::string_view();
527 }
528}
529
530std::optional<Mp4TagMediaType> mp4TagMediaTypeId(std::string_view tagMediaTypeName)
531{
532 static const auto m = std::map<std::string_view, Mp4TagMediaType, CaseInsensitiveStringComparer>{
533 { "Movie", Mp4TagMediaType::Movie },
534 { "Music", Mp4TagMediaType::Music },
535 { "Audiobook", Mp4TagMediaType::Audiobook },
536 { "WhackedBookmark", Mp4TagMediaType::WhackedBookmark },
537 { "Whacked Bookmark", Mp4TagMediaType::WhackedBookmark },
538 { "MusicVideo", Mp4TagMediaType::MusicVideo },
539 { "Music Video", Mp4TagMediaType::MusicVideo },
540 { "ShortFilm", Mp4TagMediaType::Movie2 },
541 { "Short Film", Mp4TagMediaType::Movie2 },
542 { "TvShow", Mp4TagMediaType::TvShow },
543 { "TV Show", Mp4TagMediaType::TvShow },
544 { "Booklet", Mp4TagMediaType::Booklet },
545 { "Ringtone", Mp4TagMediaType::Ringtone },
546 { "Podcast", Mp4TagMediaType::Podcast },
547 };
548 const auto i = m.find(tagMediaTypeName);
549 return i != m.cend() ? std::make_optional(i->second) : std::nullopt;
550}
551
552std::string_view mp4TagContentRatingName(Mp4TagContentRatingId tagContentRatingId)
553{
554 switch (static_cast<Mp4TagContentRating>(tagContentRatingId)) {
556 return "None";
558 return "Clean";
559 default:
560 return "Explicit";
561 }
562}
563
564std::optional<Mp4TagContentRating> mp4TagContentRatingId(std::string_view tagContentRatingName)
565{
566 static const auto m = std::map<std::string_view, Mp4TagContentRating, CaseInsensitiveStringComparer>{
567 { "None", Mp4TagContentRating::None },
568 { "Clean", Mp4TagContentRating::Clean },
569 { "Explicit", Mp4TagContentRating::Explicit },
570 };
571 const auto i = m.find(tagContentRatingName);
572 return i != m.cend() ? std::make_optional(i->second) : std::nullopt;
573}
574
575std::string_view mp4TagAccountTypeName(Mp4TagAccountTypeId tagContentRatingId)
576{
577 switch (static_cast<AccountType>(tagContentRatingId)) {
579 return "iTunes";
580 case AccountType::Aol:
581 return "AOL";
583 return "Undefined";
584 default:
585 return std::string_view();
586 }
587}
588
589std::optional<AccountType> mp4TagAccountTypeId(std::string_view tagAccountTypeName)
590{
591 static const auto m = std::map<std::string_view, AccountType, CaseInsensitiveStringComparer>{
592 { "iTunes", AccountType::Itunes },
593 { "AOL", AccountType::Aol },
594 { "Undefined", AccountType::Undefined },
595 };
596 const auto i = m.find(tagAccountTypeName);
597 return i != m.cend() ? std::make_optional(i->second) : std::nullopt;
598}
599
600} // namespace TagParser
The MediaFormat class specifies the format of media data.
unsigned char extension
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
@ WindowsMediaAudio9Professional
Definition mp4ids.h:410
TAG_PARSER_EXPORT MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
Definition mp4ids.cpp:51
TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent=false, bool psPresent=false)
Definition mp4ids.cpp:373
TAG_PARSER_EXPORT std::string_view channelConfigString(std::uint8_t config)
Returns the string representation for the specified MPEG-4 channel config.
Definition mp4ids.cpp:439
@ FrontCenterFrontLeftFrontRightBackLeftBackRightLFEChannel
Definition mp4ids.h:639
@ FrontCenterFrontLeftFrontRightSideLeftSideRightBackLeftBackRightLFEChannel
Definition mp4ids.h:640
TAG_PARSER_EXPORT std::uint8_t channelCount(std::uint8_t config)
Returns the channel count for the specified MPEG-4 channel config.
Definition mp4ids.cpp:466
TAG_PARSER_EXPORT MediaFormat streamObjectTypeFormat(std::uint8_t streamObjectTypeId)
Returns the TagParser::MediaFormat denoted by the specified MPEG-4 stream ID.
Definition mp4ids.cpp:221
TAG_PARSER_EXPORT std::string_view streamTypeName(std::uint8_t streamTypeId)
Returns the name of the stream type denoted by the specified MPEG-4 stream type ID.
Definition mp4ids.cpp:331
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TAG_PARSER_EXPORT std::string_view mp4TagMediaTypeName(Mp4TagMediaTypeId tagMediaTypeId)
Definition mp4ids.cpp:502
Mp4TagMediaType
Specifies the tag type.
Definition mp4ids.h:682
std::uint8_t Mp4TagAccountTypeId
Definition mp4ids.h:712
TAG_PARSER_EXPORT std::string_view mp4TagAccountTypeName(Mp4TagAccountTypeId tagContentRatingId)
Definition mp4ids.cpp:575
TAG_PARSER_EXPORT std::string_view mp4TagContentRatingName(Mp4TagContentRatingId tagContentRatingId)
Definition mp4ids.cpp:552
std::uint8_t Mp4TagContentRatingId
Definition mp4ids.h:698
std::uint8_t Mp4TagMediaTypeId
Definition mp4ids.h:676
AccountType
Specifies the account type.
Definition mp4ids.h:718
Mp4TagContentRating
Specifies the tag content rating.
Definition mp4ids.h:703
std::uint32_t mpeg4SamplingFrequencyTable[13]
Definition mp4ids.cpp:429
TAG_PARSER_EXPORT std::optional< AccountType > mp4TagAccountTypeId(std::string_view tagContentRatingName)
Definition mp4ids.cpp:589
TAG_PARSER_EXPORT std::optional< Mp4TagContentRating > mp4TagContentRatingId(std::string_view tagContentRatingName)
Definition mp4ids.cpp:564
TAG_PARSER_EXPORT std::optional< Mp4TagMediaType > mp4TagMediaTypeId(std::string_view tagMediaTypeName)
Definition mp4ids.cpp:530