Mercurial > audlegacy
annotate Plugins/Input/aac/src/mp4_utils.c @ 416:cb00a4b01302 trunk
[svn] Convert to produce_audio usage.
| author | chainsaw |
|---|---|
| date | Tue, 10 Jan 2006 16:50:39 -0800 |
| parents | e1630c75175b |
| children | e88b60d2fdf0 |
| rev | line source |
|---|---|
| 61 | 1 /* |
| 2 ** some function for MP4 file based on libmp4v2 from mpeg4ip project | |
| 3 */ | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
4 #include <gtk/gtk.h> |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
5 #include "mp4.h" |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
6 #include "faad.h" |
| 61 | 7 |
| 8 const char *mp4AudioNames[]= | |
| 9 { | |
| 10 "MPEG-1 Audio Layers 1,2 or 3", | |
| 11 "MPEG-2 low biterate (MPEG-1 extension) - MP3", | |
| 12 "MPEG-2 AAC Main Profile", | |
| 13 "MPEG-2 AAC Low Complexity profile", | |
| 14 "MPEG-2 AAC SSR profile", | |
| 15 "MPEG-4 audio (MPEG-4 AAC)", | |
| 16 0 | |
| 17 }; | |
| 18 | |
| 19 const u_int8_t mp4AudioTypes[] = | |
| 20 { | |
| 21 MP4_MPEG1_AUDIO_TYPE, // 0x6B | |
| 22 MP4_MPEG2_AUDIO_TYPE, // 0x69 | |
| 23 MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66 | |
| 24 MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67 | |
| 25 MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68 | |
| 26 MP4_MPEG4_AUDIO_TYPE, // 0x40 | |
| 27 0 | |
| 28 }; | |
| 29 | |
| 30 /* MPEG-4 Audio types from 14496-3 Table 1.5.1 (from mp4.h)*/ | |
| 31 const char *mpeg4AudioNames[]= | |
| 32 { | |
| 33 "!!!!MPEG-4 Audio track Invalid !!!!!!!", | |
| 34 "MPEG-4 AAC Main profile", | |
| 35 "MPEG-4 AAC Low Complexity profile", | |
| 36 "MPEG-4 AAC SSR profile", | |
| 37 "MPEG-4 AAC Long Term Prediction profile", | |
| 38 "MPEG-4 AAC Scalable", | |
| 39 "MPEG-4 CELP", | |
| 40 "MPEG-4 HVXC", | |
| 41 "MPEG-4 Text To Speech", | |
| 42 "MPEG-4 Main Synthetic profile", | |
| 43 "MPEG-4 Wavetable Synthesis profile", | |
| 44 "MPEG-4 MIDI Profile", | |
| 45 "MPEG-4 Algorithmic Synthesis and Audio FX profile" | |
| 46 }; | |
| 47 | |
| 48 int getAACTrack(MP4FileHandle file) | |
| 49 { | |
| 50 int numTracks = MP4GetNumberOfTracks(file, NULL, 0); | |
| 51 int i=0; | |
| 52 | |
| 53 for(i=0;i<numTracks;i++){ | |
| 54 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
| 55 const char *trackType = MP4GetTrackType(file, trackID); | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
56 |
| 61 | 57 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track ! |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
58 u_int8_t audiotype = MP4GetTrackAudioMpeg4Type(file, trackID); |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
59 if(audiotype !=0) |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
60 return(trackID); |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
61 else |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
62 return(-1); |
| 61 | 63 } |
| 64 } | |
| 65 return(-1); | |
| 66 } | |
| 67 | |
| 68 int getAudioTrack(MP4FileHandle file) | |
| 69 { | |
| 70 int numTracks = MP4GetNumberOfTracks(file, NULL,0); | |
| 71 int i=0; | |
| 72 | |
| 73 for(i=0;i<numTracks;i++){ | |
| 74 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
| 75 const char *trackType = MP4GetTrackType(file, trackID); | |
| 76 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){ | |
| 77 return(trackID); | |
| 78 } | |
| 79 } | |
| 80 return(-1); | |
| 81 } | |
| 82 | |
| 83 int getVideoTrack(MP4FileHandle file) | |
| 84 { | |
| 85 int numTracks = MP4GetNumberOfTracks(file, NULL, 0); | |
| 86 int i=0; | |
| 87 | |
| 88 for(i=0;i<numTracks; i++){ | |
| 89 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
| 90 const char *trackType = MP4GetTrackType(file, trackID); | |
| 91 if(!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)){ | |
| 92 return (trackID); | |
| 93 } | |
| 94 } | |
| 95 return(-1); | |
| 96 } | |
| 97 | |
| 98 void getMP4info(char* file) | |
| 99 { | |
| 100 MP4FileHandle mp4file; | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
101 //MP4Duration trackDuration; |
| 61 | 102 int numTracks; |
| 103 int i=0; | |
| 339 | 104 char *value; |
| 61 | 105 |
| 106 if(!(mp4file = MP4Read(file,0))) | |
| 107 return; | |
| 108 //MP4Dump(mp4file, 0, 0); | |
| 109 numTracks = MP4GetNumberOfTracks(mp4file, NULL, 0); | |
| 110 g_print("there are %d track(s)\n", numTracks); | |
| 339 | 111 |
| 112 MP4GetMetadataName(mp4file, &value); | |
| 113 g_print(" name : %s\n", value); | |
| 114 | |
| 115 MP4GetMetadataArtist(mp4file, &value); | |
| 116 g_print(" artist : %s\n", value); | |
| 117 | |
| 61 | 118 for(i=0;i<numTracks;i++){ |
| 119 MP4TrackId trackID = MP4FindTrackId(mp4file, i, NULL, 0); | |
| 120 const char *trackType = MP4GetTrackType(mp4file, trackID); | |
| 121 printf("Track %d, %s", trackID, trackType); | |
| 122 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track ! | |
| 123 int j=0; | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
124 u_int8_t audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID); |
| 61 | 125 while(mp4AudioTypes[j]){ // what kind of audio is ? |
| 126 if(mp4AudioTypes[j] == audiotype){ | |
| 127 if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){ | |
| 128 audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID); | |
| 129 g_print(" %s", mpeg4AudioNames[audiotype]); | |
| 130 } | |
| 131 else{ | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
132 g_print(" %s", mp4AudioNames[j]); |
| 61 | 133 } |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
134 g_print(" duration : %d", |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
135 (int)MP4ConvertFromTrackDuration(mp4file, trackID, |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
136 MP4GetTrackDuration(mp4file, |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
137 trackID), |
|
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
138 MP4_MSECS_TIME_SCALE)); |
| 61 | 139 } |
| 140 j++; | |
| 141 } | |
| 142 } | |
|
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
143 g_print("\n"); |
| 61 | 144 } |
| 145 MP4Close(mp4file); | |
| 146 } |
