Tag Parser: matroska/matroskaid.cpp Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
matroskaid.cpp
Go to the documentation of this file.
1#include "./matroskaid.h"
2#include "./ebmlid.h"
3
4namespace TagParser {
5
9namespace MatroskaIds {
10}
11
15namespace MatroskaTrackType {
16}
17
22std::string_view matroskaIdName(std::uint32_t matroskaId)
23{
24 using namespace EbmlIds;
25 using namespace MatroskaIds;
26
27 switch (matroskaId) {
28 // top-level IDs
29 case Header:
30 return "header";
31 case Version:
32 return "version";
33 case ReadVersion:
34 return "read version";
35 case MaxIdLength:
36 return "max id length";
37 case MaxSizeLength:
38 return "max size length";
39 case DocType:
40 return "document type";
41 case DocTypeVersion:
42 return "document version";
43 case DocTypeReadVersion:
44 return "document read version";
45 case Void:
46 return "void";
47 case Crc32:
48 return "CRC-32";
49 case Segment:
50 return "segment";
51 case SegmentInfo:
52 return "segment info";
53 case Tracks:
54 return "tracks";
55 case Cues:
56 return "cues";
57 case Tags:
58 return "tags";
59 case SeekHead:
60 return "seek head";
61 case Cluster:
62 return "cluster";
63 case Attachments:
64 return "attachments";
65 case Chapters:
66 return "chapters";
67
68 // IDs in the SeekHead master
69 case Seek:
70 return "seek";
71
72 // IDs in the Seek master
73 case SeekID:
74 return "seek id";
75 case SeekPosition:
76 return "seek position";
77
78 // IDs in the SegmentInfo master
79 case TimeCodeScale:
80 return "time scale code";
81 case Duration:
82 return "duration";
83 case WrittingApp:
84 return "writing application";
85 case MuxingApp:
86 return "muxing application";
87 case DateUTC:
88 return "date UTC";
89 case SegmentUID:
90 return "unique segment ID";
91 case SegmentFileName:
92 return "segment file name";
93 case PrevUID:
94 return "previous unique id";
95 case PrevFileName:
96 return "previous file name";
97 case NexUID:
98 return "next unique ID";
99 case NextFileName:
100 return "next file name";
101 case Title:
102 return "title";
103 case SegmentFamily:
104 return "segment family";
105 case ChapterTranslate:
106 return "chapter translate";
107
108 // IDs in ChapterTranslate master
109 case ChapterTranslateEditionUID:
110 return "chapter translate edition UID";
111 case ChapterTranslateCodec:
112 return "chapter translate codec";
113 case ChapterTranslateID:
114 return "chapter translate ID";
115
116 // IDs in the Tracks master
117 case TrackEntry:
118 return "track entry";
119
120 // IDs in the TrackEntry master
121 case TrackNumber:
122 return "track number";
123 case TrackUID:
124 return "unique track id";
125 case TrackEntryIds::TrackType:
126 return "track type";
127 case TrackAudio:
128 return "audio track";
129 case TrackVideo:
130 return "video track";
131 case ContentEncodings:
132 return "content encodings";
133 case CodecID:
134 return "codec id";
135 case CodecPrivate:
136 return "codec private";
137 case CodecName:
138 return "codec name";
139 case TrackName:
140 return "track name";
141 case TrackLanguage:
142 return "track language";
143 case TrackLanguageIETF:
144 return "track language IETF";
145 case TrackFlagEnabled:
146 return "track enabled";
147 case TrackFlagDefault:
148 return "default track";
149 case TrackFlagForced:
150 return "forced track";
151 case TrackFlagLacing:
152 return "track lacing";
153 case MinCache:
154 return "track minimum cache";
155 case MaxCache:
156 return "track maximum cache";
157 case DefaultDuration:
158 return "track default duration";
159 case TrackTimeCodeScale:
160 return "track time code scale";
161 case MaxBlockAdditionId:
162 return "max block addition ID";
163 case AttachmentLink:
164 return "track attachment link";
165 case TrackOverlay:
166 return "track overlay";
167 case TrackTranslate:
168 return "track translate";
169 case TrackOffset:
170 return "track offset";
171 case CodecSettings:
172 return "codec settings";
173 case CodecInfoUrl:
174 return "codec info url";
175 case CodecDownloadUrl:
176 return "codec download url";
177 case CodecDecodeAll:
178 return "codec decode all";
179
180 // IDs in the TrackTranslate master
181 case TrackTranslateEditionUID:
182 return "track translate edition UID";
183 case TrackTranslateCodec:
184 return "track translate codec";
185 case TrackTranslateTrackID:
186 return "track translate ID";
187
188 // IDs in the TrackVideo master
189 case FrameRate:
190 return "video frame rate";
191 case DisplayWidth:
192 return "video display width";
193 case DisplayHeight:
194 return "video display height";
195 case TrackVideoIds::DisplayUnit:
196 return "video display unit";
197 case PixelWidth:
198 return "video pixel width";
199 case PixelHeight:
200 return "video pixel height";
201 case PixelCropBottom:
202 return "video pixel crop bottom";
203 case PixelCropTop:
204 return "video pixel crop top";
205 case PixelCropLeft:
206 return "video pixel crop left";
207 case PixelCropRight:
208 return "video pixel crop right";
209 case FlagInterlaced:
210 return "video flag interlaced";
211 case TrackVideoIds::StereoMode:
212 return "video stereo mode";
213 case TrackVideoIds::AspectRatioType:
214 return "video aspect ratio type";
215 case ColorSpace:
216 return "video color space";
217 case GammaValue:
218 return "video gamma value";
219
220 // IDs in the TrackAudio master
221 case SamplingFrequency:
222 return "audio sampling frequence";
223 case BitDepth:
224 return "audio bit depth";
225 case Channels:
226 return "audio channels";
227 case ChannelsPositions:
228 return "audio channel positions";
229 case OutputSamplingFrequency:
230 return "audio output sample frequence";
231
232 // IDs in the TrackOperation master
233 case TrackCombinePlanes:
234 return "track combine planes";
235 case TrackJoinBlocks:
236 return "track join blocks";
237
238 // IDs in the TrackCombinePlanes master
239 case TrackPlane:
240 return "track plane";
241
242 // IDs in the TrackPlane master
243 case TrackPlaneUID:
244 return "track plane UID";
245 case TrackPlaneType:
246 return "track plane type";
247
248 // IDs in the TrackJoinBlocks master
249 case TrackJoinUID:
250 return "track join UID";
251
252 // IDs in the ContentEncoding master
253 case ContentEncodingOrder:
254 return "content encoding order";
255 case ContentEncodingScope:
256 return "content encoding scope";
257 case ContentEncodingType:
258 return "content encoding type";
259 case ContentCompression:
260 return "content encoding compression";
261 case ContentEncryption:
262 return "content encoding encryption";
263
264 // IDs in the ContentEncryption master
265 case ContentEncAlgo:
266 return "content encryption algorithmus";
267 case ContentEncKeyID:
268 return "content encryption key ID";
269 case ContentSignature:
270 return "content encryption signature";
271 case ContentSigKeyID:
272 return "content encryption signature key ID";
273 case ContentSigAlgo:
274 return "content encryption signature algorithmus";
275 case ContentSigHashAlgo:
276 return "content encryption signature hash algorithmus";
277
278 // IDs in the Tags master
279 case TagsIds::Tag:
280 return "tag";
281
282 // IDs in the Tag master
283 case SimpleTag:
284 return "simple tag";
285 case Targets:
286 return "targets";
287
288 // IDs in the SimpleTag master
289 case TagName:
290 return "tag name";
291 case TagString:
292 return "tag string";
293 case TagLanguage:
294 return "tag language";
295 case TagLanguageIETF:
296 return "tag language IETF";
297 case TagDefault:
298 return "tag default";
299 case TagBinary:
300 return "tag binary";
301
302 // IDs in the Targets master
303 case TargetTypeValue:
304 return "target type value";
305 case TargetType:
306 return "target type";
307 case TagTrackUID:
308 return "tag track UID";
309 case TagEditionUID:
310 return "tag edition UID";
311 case TagChapterUID:
312 return "tag chapter UID";
313 case TagAttachmentUID:
314 return "tag attachment UID";
315
316 // IDs in the Cues master
317 case CuePoint:
318 return "cue point";
319
320 // IDs in the CuePoint master
321 case CueTime:
322 return "cue time";
323 case CueTrackPositions:
324 return "cue track positions";
325
326 // IDs in the CueTrackPositions master
327 case CueTrack:
328 return "cue track";
329 case CueClusterPosition:
330 return "cue cluster position";
331 case CueRelativePosition:
332 return "cue relative position";
333 case CueDuration:
334 return "cue duration";
335 case CueBlockNumber:
336 return "cue block number";
337 case CueCodecState:
338 return "cue codec state";
339 case CueReference:
340 return "cue reference";
341
342 // IDs in the CueReference master
343 case CueRefTime:
344 return "cue reference time";
345 case CueRefCluster:
346 return "cue reference cluster";
347 case CueRefNumber:
348 return "cue reference number";
349 case CueRefCodecState:
350 return "cue reference codec state";
351
352 // IDs in the Attachments master
353 case AttachedFile:
354 return "attached file";
355
356 // IDs in the AttachedFile master
357 case FileDescription:
358 return "file description";
359 case FileName:
360 return "file name";
361 case FileMimeType:
362 return "file mime type";
363 case FileData:
364 return "file data";
365 case FileUID:
366 return "file UID";
367 case FileReferral:
368 return "file referral";
369 case FileUsedStartTime:
370 return "file used start time";
371 case FileUsedEndTime:
372 return "file used end time";
373
374 // IDs in the Chapters master
375 case EditionEntry:
376 return "edition entry";
377
378 // IDs in the EditionEntry master
379 case EditionUID:
380 return "edition UID";
381 case EditionFlagHidden:
382 return "edition flag hidden";
383 case EditionFlagDefault:
384 return "edition flag default";
385 case EditionFlagOrdered:
386 return "edition flag ordered";
387 case ChapterAtom:
388 return "chapter atom";
389
390 // IDs in the ChapterAtom master
391 case ChapterUID:
392 return "chapter UID";
393 case ChapterStringUID:
394 return "chapter string UID";
395 case ChapterTimeStart:
396 return "chapter time start";
397 case ChapterTimeEnd:
398 return "chapter time end";
399 case ChapterFlagHidden:
400 return "chapter flag hidden";
401 case ChapterFlagEnabled:
402 return "chapter flag enabled";
403 case ChapterSegmentUID:
404 return "chapter segment UID";
405 case ChapterSegmentEditionUID:
406 return "chapter segment edition UID";
407 case ChapterPhysicalEquiv:
408 return "chapter physical equiv";
409 case ChapterTrack:
410 return "chapter track";
411 case ChapterDisplay:
412 return "chapter display";
413 case ChapProcess:
414 return "chapter process";
415
416 // IDs in the ChaptgerTrack master
417 case ChapterTrackNumber:
418 return "chapter track number";
419
420 // IDs in the ChapterDisplay master
421 case ChapString:
422 return "chap string";
423 case ChapLanguage:
424 return "chap language";
425 case ChapLanguageIETF:
426 return "chap language IETF";
427 case ChapCountry:
428 return "chap country";
429
430 // IDs in the ChapProcess master
431 case ChapProcessCodecID:
432 return "chap process ID";
433 case ChapProcessPrivate:
434 return "chap process private";
435 case ChapProcessCommand:
436 return "chap process command";
437
438 // IDs in the ChapProcessCommand master
439 case ChapProcessTime:
440 return "chap process time";
441 case ChapProcessData:
442 return "chap process data";
443
444 // IDs in the Cluster master
445 case Timecode:
446 return "timecode";
447 case SilentTracks:
448 return "silent tracks";
449 case Position:
450 return "position";
451 case PrevSize:
452 return "previous size";
453 case SimpleBlock:
454 return "simple block";
455 case BlockGroup:
456 return "block group";
457 case EncryptedBlock:
458 return "encrypted block";
459
460 // IDs in the SilentTracks master
461 case SilentTrackNumber:
462 return "silent track number";
463
464 // IDs in the BlockGroup master
465 case Block:
466 return "block";
467 case BlockVirtual:
468 return "block virtual";
469 case BlockAdditions:
470 return "block additions";
471 case BlockDuration:
472 return "block duration";
473 case ReferencePriority:
474 return "reference priority";
475 case ReferenceBlock:
476 return "reference block";
477 case ReferenceVirtual:
478 return "reference virtual";
479 case CodecState:
480 return "codec state";
481 case DiscardPadding:
482 return "discard padding";
483 case Slices:
484 return "slices";
485 case ReferenceFrame:
486 return "reference frame";
487
488 // IDs in the BlockAdditions master
489 case BlockMore:
490 return "block more";
491
492 // IDs in the BlockMore master
493 case BlockAddID:
494 return "block add ID";
495 case BlockAdditional:
496 return "block additional";
497
498 // IDs in the Slices master
499 case TimeSlice:
500 return "time slice";
501
502 // IDs in the TimeSlice master
503 case LaceNumber:
504 return "lace number";
505 case FrameNumber:
506 return "frame number";
507 case BlockAdditionID:
508 return "block addition ID";
509 case Delay:
510 return "delay";
511 case SliceDuration:
512 return "slice duration";
513
514 // IDs in the ReferenceFrame master
515 case ReferenceOffset:
516 return "reference offset";
517 case ReferenceTimeCode:
518 return "reference time code";
519
520 default:
521 return std::string_view();
522 }
523}
524
529 MatroskaElementLevel matroskaIdLevel(std::uint32_t matroskaId)
530{
531 using namespace EbmlIds;
532 using namespace MatroskaIds;
533 switch (matroskaId) {
534 case Header:
535 case Segment:
536 return MatroskaElementLevel::TopLevel;
537 case SeekHead:
538 case SegmentInfo:
539 case Cluster:
540 case Tracks:
541 case Cues:
542 case Attachments:
543 case Chapters:
544 case Tags:
545 return MatroskaElementLevel::Level1;
546 case Seek:
547 case SegmentUID:
548 case SegmentFileName:
549 case PrevUID:
550 case PrevFileName:
551 case NexUID:
552 case NextFileName:
553 case SegmentFamily:
554 case ChapterTranslate:
555 case TimeCodeScale:
556 case Duration:
557 case DateUTC:
558 case Title:
559 case MuxingApp:
560 case WrittingApp:
561 case Timecode:
562 case SilentTracks:
563 case Position:
564 case PrevSize:
565 case SimpleBlock:
566 case BlockGroup:
567 case EncryptedBlock:
568 case TrackEntry:
569 case CuePoint:
570 case AttachedFile:
571 case EditionEntry:
572 case TagsIds::Tag:
573 return MatroskaElementLevel::Level2;
574 case SeekID:
575 case SeekPosition:
576 case ChapterTranslateEditionUID:
577 case ChapterTranslateCodec:
578 case ChapterTranslateID:
579 case SilentTrackNumber:
580 case BlockVirtual:
581 case BlockAdditions:
582 case BlockDuration:
583 case ReferencePriority:
584 case ReferenceBlock:
585 case ReferenceVirtual:
586 case CodecState:
587 case DiscardPadding:
588 case Slices:
589 case TrackNumber:
590 case TrackUID:
591 case TrackEntryIds::TrackType:
592 case TrackFlagEnabled:
593 case TrackFlagDefault:
594 case TrackFlagForced:
595 case TrackFlagLacing:
596 case MinCache:
597 case MaxCache:
598 case DefaultDuration:
599 case DefaultDecodedFieldDuration:
600 case TrackTimeCodeScale:
601 case TrackOffset:
602 case MaxBlockAdditionId:
603 case TrackName:
604 case TrackLanguage:
605 case TrackLanguageIETF:
606 case CodecID:
607 case CodecPrivate:
608 case CodecName:
609 case AttachmentLink:
610 case CodecSettings:
611 case CodecInfoUrl:
612 case CodecDownloadUrl:
613 case CodecDecodeAll:
614 case TrackOverlay:
615 case CodecDelay:
616 case SeekPreRoll:
617 case TrackTranslate:
618 case TrackVideo:
619 case TrackAudio:
620 case ContentEncodings:
621 case CueTime:
622 case CueTrackPositions:
623 case FileDescription:
624 case FileName:
625 case FileMimeType:
626 case FileData:
627 case FileUID:
628 case FileReferral:
629 case FileUsedStartTime:
630 case FileUsedEndTime:
631 case EditionUID:
632 case EditionFlagHidden:
633 case EditionFlagDefault:
634 case EditionFlagOrdered:
635 case Targets:
636 return MatroskaElementLevel::Level3;
637 case BlockMore:
638 case TimeSlice:
639 case ContentEncoding:
640 case CueTrack:
641 case CueClusterPosition:
642 case CueRelativePosition:
643 case CueDuration:
644 case CueBlockNumber:
645 case CueCodecState:
646 case CueReference:
647 case TargetTypeValue:
648 case TargetType:
649 case TagTrackUID:
650 case TagEditionUID:
651 case TagChapterUID:
652 case TagAttachmentUID:
653 return MatroskaElementLevel::Level4;
654 case BlockAddID:
655 case BlockAdditional:
656 case LaceNumber:
657 case FrameNumber:
658 case BlockAdditionID:
659 case Delay:
660 case SliceDuration:
661 case ReferenceFrame:
662 case ReferenceOffset:
663 case ReferenceTimeCode:
664 case CueRefTime:
665 case CueRefCluster:
666 case CueRefNumber:
667 case CueRefCodecState:
668 return MatroskaElementLevel::Level5;
669 case Void:
670 case Crc32:
671 return MatroskaElementLevel::Global;
672 default:
673 return MatroskaElementLevel::Unknown;
674 }
675}
676
677} // namespace TagParser
ebmlid.h
matroskaid.h
TagParser::EbmlIds
Encapsulates all EBML ID values.
Definition ebmlid.h:9
TagParser::MatroskaIds
Encapsulates the most common Matroska element IDs.
Definition matroskaid.h:11
TagParser::MatroskaTrackType
Encapsulates the most common Matroska track IDs.
Definition matroskaid.h:409
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::matroskaIdLevel
TAG_PARSER_EXPORT MatroskaElementLevel matroskaIdLevel(std::uint32_t matroskaId)
Returns the level at which elements with the specified matroskaId are supposed to occur in a Matroska...
Definition matroskaid.cpp:529
TagParser::KnownField::Title
@ Title
Definition tag.h:39
TagParser::MatroskaElementLevel
MatroskaElementLevel
Definition matroskaid.h:414
TagParser::MatroskaElementLevel::Level2
@ Level2
Definition matroskaid.h:417
TagParser::MatroskaElementLevel::Global
@ Global
Definition matroskaid.h:422
TagParser::MatroskaElementLevel::Level1
@ Level1
Definition matroskaid.h:416
TagParser::MatroskaElementLevel::Level3
@ Level3
Definition matroskaid.h:418
TagParser::MatroskaElementLevel::Level5
@ Level5
Definition matroskaid.h:420
TagParser::MatroskaElementLevel::Level4
@ Level4
Definition matroskaid.h:419
TagParser::MatroskaElementLevel::Unknown
@ Unknown
Definition matroskaid.h:423
TagParser::MatroskaElementLevel::TopLevel
@ TopLevel
Definition matroskaid.h:415
TagParser::matroskaIdName
TAG_PARSER_EXPORT std::string_view matroskaIdName(std::uint32_t matroskaId)
Returns a string for the specified matroskaId if known; otherwise returns an empty string.
Definition matroskaid.cpp:22