Tag Parser  7.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
mp4ids.cpp
Go to the documentation of this file.
1 #include "./mp4ids.h"
2 
3 #include "../mediaformat.h"
4 
5 namespace TagParser {
6 
10 namespace Mp4AtomIds {
11 }
12 
16 namespace Mp4TagAtomIds {
17 }
18 
22 namespace Mp4TagExtendedMeanIds {
23 const char *iTunes = "com.apple.iTunes";
24 }
25 
29 namespace Mp4TagExtendedNameIds {
30 const char *cdec = "cdec";
31 const char *label = "LABEL";
32 } // namespace Mp4TagExtendedNameIds
33 
37 namespace Mp4MediaTypeIds {
38 }
39 
44 namespace FourccIds {
45 
47 {
48  switch (fourccId) {
49  case Mpeg:
51  case Mpeg2Imx30:
52  case Mpeg2Imx50:
54  case Mpeg4Video:
56  case Mpeg4TimedText:
58  case Hevc1:
59  case Hevc2:
61  case Avc1:
62  case Avc2:
63  case Avc3:
64  case Avc4:
65  case H264Decoder1:
66  case H264Decoder2:
67  case H264Decoder3:
68  case H264Decoder4:
69  case H264Decoder5:
70  case H264Decoder6:
72  case Divx4Decoder1:
73  case Divx4Decoder2:
74  case H263Quicktime:
75  case H2633GPP:
76  case XvidDecoder1:
77  case XvidDecoder2:
78  case XvidDecoder3:
79  case XvidDecoder4:
80  case XvidDecoder5:
81  case Divx5Decoder:
83  case Divx3Decoder1:
84  case Divx3Decoder2:
85  case Divx3Decoder3:
86  case Divx3Decoder4:
87  case Divx3Decoder5:
88  case Divx3Decoder6:
89  case Divx3Decoder7:
90  case Divx3Decoder8:
91  case Divx3Decoder9:
92  case Divx3Decoder10:
93  case Divx3Decoder11:
94  case Divx3Decoder12:
95  case Divx3Decoder13:
96  case Divx3Decoder14:
97  case Divx3Decoder15:
99  case Tiff:
101  case AppleTextAtsuiCodec:
103  case Raw:
105  case Jpeg:
107  case Gif:
109  case Png:
111  case AdpcmAcm:
113  case ImaadpcmAcm:
115  case Mp3CbrOnly:
116  case Mp3:
118  case Mpeg4Audio:
120  case Alac:
122  case Ac3:
124  case EAc3:
126  case DolbyMpl:
128  case Ac4:
130  case Rv20:
131  case Rv30:
132  case Rv40:
134  case Int24:
135  case Int32:
137  case Int16Be:
139  case Int16Le:
141  case FloatingPoint32Bit:
142  case FloatingPoint64Bit:
144  case Amr:
145  case AmrNarrowband:
147  case Dts:
148  case DtsH:
150  case DtsE:
152  case WindowsMediaAudio:
153  case WindowsMediaAudio7:
157  case MsMpeg4V1Decoder1:
158  case MsMpeg4V1Decoder2:
159  case MsMpeg4V1Decoder3:
160  case MsMpeg4V1Decoder4:
161  case MsMpeg4V1Decoder5:
162  case MsMpeg4V1Decoder6:
164  case MsMpeg4V2Decoder1:
165  case MsMpeg4V2Decoder2:
166  case MsMpeg4V2Decoder3:
167  case MsMpeg4V2Decoder4:
169  case MsMpeg4V3Decoder1:
170  case MsMpeg4V3Decoder2:
172  case WavPack:
176  case WindowsMediaVideoV2:
177  case WindowsMediaVideoV8:
179  // TODO: map more FOURCCs
180  default:
182  }
183 }
184 
185 } // namespace FourccIds
186 
191 namespace Mp4FormatExtensionIds {
192 }
193 
197 namespace Mpeg4ElementaryStreamObjectIds {
198 
202 MediaFormat streamObjectTypeFormat(byte streamObjectTypeId)
203 {
204  switch (streamObjectTypeId) {
205  case SystemsIso144961:
207  case SystemsIso144961v2:
209  case InteractionStream:
211  case AfxStream:
213  case FontDataStream:
217  case StreamingTextStream:
219  case Mpeg4Visual:
221  case Avc:
223  case ParameterSetsForAvc:
225  case Als:
227  case Sa0c:
229  case Aac:
243  case Mpeg2AacMainProfile:
249  case Mpeg2Audio:
251  case Mpeg1Video:
253  case Mpeg1Audio:
255  case Jpeg:
257  case Png:
259  case Evrc:
260  case PrivateEvrc:
262  case Smv:
264  case Gpp2Cmf:
266  case Vc1:
268  case Dirac:
270  case Ac3:
271  case PrivateAc3:
273  case EAc3:
275  case Dts:
276  case PrivateDts:
278  case DtsHdHighResolution:
280  case DtsHdMasterAudio:
282  case DtsHdExpress:
284  case PrivateOgg:
285  case PrivateOgg2:
287  case PrivateQcelp:
289  default:
290  return MediaFormat();
291  }
292 }
293 
294 } // namespace Mpeg4ElementaryStreamObjectIds
295 
299 namespace Mpeg4DescriptorIds {
300 }
301 
305 namespace Mpeg4ElementaryStreamTypeIds {
306 
310 const char *streamTypeName(byte streamTypeId)
311 {
312  switch (streamTypeId) {
313  case ObjectDescriptor:
314  return "object descriptor";
315  case ClockReference:
316  return "clock reference";
317  case SceneDescriptor:
318  return "scene descriptor";
319  case Visual:
320  return "visual";
321  case Audio:
322  return "audio";
323  case Mpeg7:
324  return "MPEG-7";
325  case Ipmps:
326  return "IMPS";
327  case ObjectContentInfo:
328  return "object content info";
329  case MpegJava:
330  return "MPEG Java";
331  case Interaction:
332  return "interaction";
333  case Ipmp:
334  return "IPMP";
335  case FontData:
336  return "font data";
337  case StreamingText:
338  return "streaming text";
339  default:
340  return "";
341  }
342 }
343 
344 } // namespace Mpeg4ElementaryStreamTypeIds
345 
350 namespace Mpeg4AudioObjectIds {
351 
352 TAG_PARSER_EXPORT MediaFormat idToMediaFormat(byte mpeg4AudioObjectId, bool sbrPresent, bool psPresent)
353 {
354  MediaFormat fmt;
355  switch (mpeg4AudioObjectId) {
356  case AacMain:
358  break;
359  case AacLc:
361  break;
362  case AacSsr:
364  break;
365  case AacLtp:
367  break;
368  case Sbr:
370  break;
371  case AacScalable:
373  break;
374  case ErAacLc:
376  break;
377  case ErAacLtp:
379  break;
380  case ErAacLd:
382  break;
383  case Ps:
385  break;
386  case Layer1:
388  break;
389  case Layer2:
391  break;
392  case Layer3:
394  break;
395  default:;
396  }
397  if (sbrPresent) {
399  }
400  if (psPresent) {
402  }
403  return fmt;
404 }
405 
406 } // namespace Mpeg4AudioObjectIds
407 
408 uint32 mpeg4SamplingFrequencyTable[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
409 
413 namespace Mpeg4ChannelConfigs {
414 
418 const char *channelConfigString(byte config)
419 {
420  switch (config) {
421  case AotSpecificConfig:
422  return "defined in AOT Specific Config";
423  case FrontCenter:
424  return "1 channel: front-center";
425  case FrontLeftFrontRight:
426  return "2 channels: front-left, front-right";
428  return "3 channels: front-center, front-left, front-right";
430  return "4 channels: front-center, front-left, front-right, back-center";
432  return "5 channels: front-center, front-left, front-right, back-left, back-right";
434  return "6 channels: front-center, front-left, front-right, back-left, back-right, LFE-channel";
436  return "8 channels: front-center, front-left, front-right, side-left, side-right, back-left, back-right, LFE-channel";
437  default:
438  return nullptr;
439  }
440 }
441 
445 byte channelCount(byte config)
446 {
447  switch (config) {
448  case FrontCenter:
449  return 1;
450  case FrontLeftFrontRight:
451  return 2;
453  return 3;
455  return 4;
457  return 5;
459  return 6;
461  return 8;
462  default:
463  return 0;
464  }
465 }
466 
467 } // namespace Mpeg4ChannelConfigs
468 
472 namespace Mpeg4VideoCodes {
473 }
474 
478 namespace Mpeg2VideoCodes {
479 }
480 
481 } // namespace TagParser
TAG_PARSER_EXPORT byte channelCount(byte config)
Returns the channel count for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:445
TAG_PARSER_EXPORT MediaFormat idToMediaFormat(byte mpeg4AudioObjectId, bool sbrPresent=false, bool psPresent=false)
Definition: mp4ids.cpp:352
TAG_PARSER_EXPORT const char * streamTypeName(byte streamTypeId)
Returns the name of the stream type denoted by the specified MPEG-4 stream type ID.
Definition: mp4ids.cpp:310
TAG_PARSER_EXPORT const char * channelConfigString(byte config)
Returns the string representation for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:418
TAG_PARSER_EXPORT MediaFormat fourccToMediaFormat(uint32 fourccId)
Definition: mp4ids.cpp:46
TAG_PARSER_EXPORT MediaFormat streamObjectTypeFormat(byte streamObjectTypeId)
Returns the Media::MediaFormat denoted by the specified MPEG-4 stream ID.
Definition: mp4ids.cpp:202
unsigned char extension
Definition: mediaformat.h:258
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
uint32 mpeg4SamplingFrequencyTable[13]
Definition: mp4ids.cpp:408