61
|
1 /*
|
|
2 * The contents of this file are subject to the Mozilla Public
|
|
3 * License Version 1.1 (the "License"); you may not use this file
|
|
4 * except in compliance with the License. You may obtain a copy of
|
|
5 * the License at http://www.mozilla.org/MPL/
|
|
6 *
|
|
7 * Software distributed under the License is distributed on an "AS
|
|
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
9 * implied. See the License for the specific language governing
|
|
10 * rights and limitations under the License.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
|
|
15 * Portions created by Cisco Systems Inc. are
|
|
16 * Copyright (C) Cisco Systems Inc. 2001-2002. All Rights Reserved.
|
|
17 *
|
|
18 * Portions created by Ximpo Group Ltd. are
|
|
19 * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
|
|
20 *
|
|
21 * Contributor(s):
|
|
22 * Dave Mackie dmackie@cisco.com
|
|
23 * Bill May wmay@cisco.com
|
|
24 * Alix Marchandise-Franquet alix@cisco.com
|
|
25 * Ximpo Group Ltd. mp4v2@ximpo.com
|
|
26 */
|
|
27
|
|
28 #include "mp4common.h"
|
|
29
|
|
30 static char* PrintAudioInfo(
|
|
31 MP4FileHandle mp4File,
|
|
32 MP4TrackId trackId)
|
|
33 {
|
|
34 static const char* mpeg4AudioNames[] = {
|
|
35 "MPEG-4 AAC main",
|
|
36 "MPEG-4 AAC LC",
|
|
37 "MPEG-4 AAC SSR",
|
|
38 "MPEG-4 AAC LTP",
|
|
39 "MPEG-4 AAC HE",
|
|
40 "MPEG-4 AAC Scalable",
|
|
41 "MPEG-4 TwinVQ",
|
|
42 "MPEG-4 CELP",
|
|
43 "MPEG-4 HVXC",
|
|
44 NULL, NULL,
|
|
45 "MPEG-4 TTSI",
|
|
46 "MPEG-4 Main Synthetic",
|
|
47 "MPEG-4 Wavetable Syn",
|
|
48 "MPEG-4 General MIDI",
|
|
49 "MPEG-4 Algo Syn and Audio FX",
|
|
50 "MPEG-4 ER AAC LC",
|
|
51 NULL,
|
|
52 "MPEG-4 ER AAC LTP",
|
|
53 "MPEG-4 ER AAC Scalable",
|
|
54 "MPEG-4 ER TwinVQ",
|
|
55 "MPEG-4 ER BSAC",
|
|
56 "MPEG-4 ER ACC LD",
|
|
57 "MPEG-4 ER CELP",
|
|
58 "MPEG-4 ER HVXC",
|
|
59 "MPEG-4 ER HILN",
|
|
60 "MPEG-4 ER Parametric",
|
|
61 };
|
|
62
|
|
63 static const u_int8_t mpegAudioTypes[] = {
|
|
64 MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66
|
|
65 MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67
|
|
66 MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68
|
|
67 MP4_MPEG2_AUDIO_TYPE, // 0x69
|
|
68 MP4_MPEG1_AUDIO_TYPE, // 0x6B
|
|
69 // private types
|
|
70 MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE,
|
|
71 MP4_VORBIS_AUDIO_TYPE,
|
|
72 MP4_ALAW_AUDIO_TYPE,
|
|
73 MP4_ULAW_AUDIO_TYPE,
|
|
74 MP4_G723_AUDIO_TYPE,
|
|
75 MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE,
|
|
76 };
|
|
77 static const char* mpegAudioNames[] = {
|
|
78 "MPEG-2 AAC Main",
|
|
79 "MPEG-2 AAC LC",
|
|
80 "MPEG-2 AAC SSR",
|
|
81 "MPEG-2 Audio (13818-3)",
|
|
82 "MPEG-1 Audio (11172-3)",
|
|
83 // private types
|
|
84 "PCM16 (little endian)",
|
|
85 "Vorbis",
|
|
86 "G.711 aLaw",
|
|
87 "G.711 uLaw",
|
|
88 "G.723.1",
|
|
89 "PCM16 (big endian)",
|
|
90 };
|
|
91 u_int8_t numMpegAudioTypes =
|
|
92 sizeof(mpegAudioTypes) / sizeof(u_int8_t);
|
|
93
|
|
94 const char* typeName = "Unknown";
|
|
95 bool foundType = false;
|
|
96 u_int8_t type = 0;
|
|
97 const char *media_data_name;
|
|
98
|
|
99 media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
|
|
100
|
|
101 if (media_data_name == NULL) {
|
|
102 typeName = "Unknown - no media data name";
|
|
103 } else if (strcasecmp(media_data_name, "samr") == 0) {
|
|
104 typeName = "AMR";
|
|
105 foundType = true;
|
|
106 } else if (strcasecmp(media_data_name, "sawb") == 0) {
|
|
107 typeName = "AMR-WB";
|
|
108 foundType = true;
|
|
109 } else if (strcasecmp(media_data_name, "mp4a") == 0) {
|
|
110
|
|
111 type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId);
|
|
112
|
|
113 switch (type) {
|
|
114 case MP4_MPEG4_AUDIO_TYPE: {
|
|
115 u_int8_t* pAacConfig = NULL;
|
|
116 u_int32_t aacConfigLength;
|
|
117
|
|
118 MP4GetTrackESConfiguration(mp4File,
|
|
119 trackId,
|
|
120 &pAacConfig,
|
|
121 &aacConfigLength);
|
|
122
|
|
123 if (pAacConfig != NULL && aacConfigLength >= 2) {
|
|
124 type = (pAacConfig[0] >> 3) & 0x1f;
|
|
125 if (type == 0 || /* type == 5 || */ type == 10 || type == 11 ||
|
|
126 type == 18 || type >= 28) {
|
|
127 typeName = "MPEG-4 Unknown Profile";
|
|
128 } else {
|
|
129 typeName = mpeg4AudioNames[type - 1];
|
|
130 foundType = true;
|
|
131 }
|
|
132 free(pAacConfig);
|
|
133 } else {
|
|
134 typeName = "MPEG-4 (no GAConfig)";
|
|
135 foundType = true;
|
|
136 }
|
|
137 break;
|
|
138 }
|
|
139 // fall through
|
|
140 default:
|
|
141 for (u_int8_t i = 0; i < numMpegAudioTypes; i++) {
|
|
142 if (type == mpegAudioTypes[i]) {
|
|
143 typeName = mpegAudioNames[i];
|
|
144 foundType = true;
|
|
145 break;
|
|
146 }
|
|
147 }
|
|
148 }
|
|
149 } else {
|
|
150 typeName = media_data_name;
|
|
151 foundType = true;
|
|
152 }
|
|
153
|
|
154 u_int32_t timeScale =
|
|
155 MP4GetTrackTimeScale(mp4File, trackId);
|
|
156
|
|
157 MP4Duration trackDuration =
|
|
158 MP4GetTrackDuration(mp4File, trackId);
|
|
159
|
|
160 double msDuration =
|
|
161 (double) (MP4ConvertFromTrackDuration(mp4File, trackId,
|
|
162 trackDuration, MP4_MSECS_TIME_SCALE));
|
|
163
|
|
164 u_int32_t avgBitRate =
|
|
165 MP4GetTrackBitRate(mp4File, trackId);
|
|
166
|
|
167 char *sInfo = (char*)MP4Malloc(256);
|
|
168
|
|
169 // type duration avgBitrate samplingFrequency
|
|
170 if (foundType)
|
|
171 sprintf(sInfo,
|
|
172 "%u\taudio\t%s%s, %.3f secs, %u kbps, %u Hz\n",
|
|
173 trackId,
|
|
174 MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",
|
|
175 typeName,
|
|
176 msDuration / 1000.0,
|
|
177 (avgBitRate + 500) / 1000,
|
|
178 timeScale);
|
|
179 else
|
|
180 sprintf(sInfo,
|
|
181 "%u\taudio\t%s%s(%u), %.3f secs, %u kbps, %u Hz\n",
|
|
182 trackId,
|
|
183 MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",
|
|
184 typeName,
|
|
185 type,
|
|
186 msDuration / 1000.0,
|
|
187 (avgBitRate + 500) / 1000,
|
|
188 timeScale);
|
|
189
|
|
190 return sInfo;
|
|
191 }
|
|
192 static const struct {
|
|
193 uint8_t profile;
|
|
194 const char *name;
|
|
195 } VisualProfileToName[] = {
|
|
196 { MPEG4_SP_L1, "MPEG-4 Simple @ L1"},
|
|
197 { MPEG4_SP_L2, "MPEG-4 Simple @ L2" },
|
|
198 { MPEG4_SP_L3, "MPEG-4 Simple @ L3" },
|
|
199 { MPEG4_SP_L0, "MPEG-4 Simple @ L0" },
|
|
200 { MPEG4_SSP_L1, "MPEG-4 Simple Scalable @ L1"},
|
|
201 { MPEG4_SSP_L2, "MPEG-4 Simple Scalable @ L2" },
|
|
202 { MPEG4_CP_L1, "MPEG-4 Core @ L1"},
|
|
203 { MPEG4_CP_L2, "MPEG-4 Core @ L2"},
|
|
204 { MPEG4_MP_L2, "MPEG-4 Main @ L2"},
|
|
205 { MPEG4_MP_L3, "MPEG-4 Main @ L3"},
|
|
206 { MPEG4_MP_L4, "MPEG-4 Main @ L4"},
|
|
207 { MPEG4_NBP_L2, "MPEG-4 N-bit @ L2"},
|
|
208 { MPEG4_STP_L1, "MPEG-4 Scalable Texture @ L1"},
|
|
209 { MPEG4_SFAP_L1, "MPEG-4 Simple Face Anim @ L1"},
|
|
210 { MPEG4_SFAP_L2, "MPEG-4 Simple Face Anim @ L2"},
|
|
211 { MPEG4_SFBAP_L1, "MPEG-4 Simple FBA @ L1"},
|
|
212 { MPEG4_SFBAP_L2, "MPEG-4 Simple FBA @ L2"},
|
|
213 { MPEG4_BATP_L1, "MPEG-4 Basic Anim Text @ L1"},
|
|
214 { MPEG4_BATP_L2, "MPEG-4 Basic Anim Text @ L2"},
|
|
215 { MPEG4_HP_L1, "MPEG-4 Hybrid @ L1"},
|
|
216 { MPEG4_HP_L2, "MPEG-4 Hybrid @ L2"},
|
|
217 { MPEG4_ARTSP_L1, "MPEG-4 Adv RT Simple @ L1"},
|
|
218 { MPEG4_ARTSP_L2, "MPEG-4 Adv RT Simple @ L2"},
|
|
219 { MPEG4_ARTSP_L3, "MPEG-4 Adv RT Simple @ L3"},
|
|
220 { MPEG4_ARTSP_L4, "MPEG-4 Adv RT Simple @ L4"},
|
|
221 { MPEG4_CSP_L1, "MPEG-4 Core Scalable @ L1"},
|
|
222 { MPEG4_CSP_L2, "MPEG-4 Core Scalable @ L2"},
|
|
223 { MPEG4_CSP_L3, "MPEG-4 Core Scalable @ L3"},
|
|
224 { MPEG4_ACEP_L1, "MPEG-4 Adv Coding Efficieny @ L1"},
|
|
225 { MPEG4_ACEP_L2, "MPEG-4 Adv Coding Efficieny @ L2"},
|
|
226 { MPEG4_ACEP_L3, "MPEG-4 Adv Coding Efficieny @ L3"},
|
|
227 { MPEG4_ACEP_L4, "MPEG-4 Adv Coding Efficieny @ L4"},
|
|
228 { MPEG4_ACP_L1, "MPEG-4 Adv Core Profile @ L1"},
|
|
229 { MPEG4_ACP_L2, "MPEG-4 Adv Core Profile @ L2"},
|
|
230 { MPEG4_AST_L1, "MPEG-4 Adv Scalable Texture @ L1"},
|
|
231 { MPEG4_AST_L2, "MPEG-4 Adv Scalable Texture @ L2"},
|
|
232 { MPEG4_AST_L3, "MPEG-4 Adv Scalable Texture @ L3"},
|
|
233 { MPEG4_S_STUDIO_P_L1, "MPEG-4 Simple Studio @ L1"},
|
|
234 { MPEG4_S_STUDIO_P_L2, "MPEG-4 Simple Studio @ L2"},
|
|
235 { MPEG4_S_STUDIO_P_L3, "MPEG-4 Simple Studio @ L3"},
|
|
236 { MPEG4_S_STUDIO_P_L4, "MPEG-4 Simple Studio @ L4"},
|
|
237 { MPEG4_C_STUDIO_P_L1, "MPEG-4 Core Studio @ L1"},
|
|
238 { MPEG4_C_STUDIO_P_L2, "MPEG-4 Core Studio @ L2"},
|
|
239 { MPEG4_C_STUDIO_P_L3, "MPEG-4 Core Studio @ L3"},
|
|
240 { MPEG4_C_STUDIO_P_L4, "MPEG-4 Core Studio @ L4"},
|
|
241 { MPEG4_ASP_L0, "MPEG-4 Adv Simple@L0"},
|
|
242 { MPEG4_ASP_L1, "MPEG-4 Adv Simple@L1"},
|
|
243 { MPEG4_ASP_L2, "MPEG-4 Adv Simple@L2"},
|
|
244 { MPEG4_ASP_L3, "MPEG-4 Adv Simple@L3"},
|
|
245 { MPEG4_ASP_L4, "MPEG-4 Adv Simple@L4"},
|
|
246 { MPEG4_ASP_L5, "MPEG-4 Adv Simple@L5"},
|
|
247 { MPEG4_ASP_L3B, "MPEG-4 Adv Simple@L3b"},
|
|
248 { MPEG4_FGSP_L0, "MPEG-4 FGS @ L0" },
|
|
249 { MPEG4_FGSP_L1, "MPEG-4 FGS @ L1" },
|
|
250 { MPEG4_FGSP_L2, "MPEG-4 FGS @ L2" },
|
|
251 { MPEG4_FGSP_L3, "MPEG-4 FGS @ L3" },
|
|
252 { MPEG4_FGSP_L4, "MPEG-4 FGS @ L4" },
|
|
253 { MPEG4_FGSP_L5, "MPEG-4 FGS @ L5" }
|
|
254 };
|
|
255
|
|
256 static const char *Mpeg4VisualProfileName (uint8_t visual_profile)
|
|
257 {
|
|
258 size_t size = sizeof(VisualProfileToName) / sizeof(*VisualProfileToName);
|
|
259
|
|
260 for (size_t ix = 0; ix < size; ix++) {
|
|
261 if (visual_profile == VisualProfileToName[ix].profile) {
|
|
262 return (VisualProfileToName[ix].name);
|
|
263 }
|
|
264 }
|
|
265 return (NULL);
|
|
266 }
|
|
267 static char* PrintVideoInfo(
|
|
268 MP4FileHandle mp4File,
|
|
269 MP4TrackId trackId)
|
|
270 {
|
|
271
|
|
272 static const u_int8_t mpegVideoTypes[] = {
|
|
273 MP4_MPEG2_SIMPLE_VIDEO_TYPE, // 0x60
|
|
274 MP4_MPEG2_MAIN_VIDEO_TYPE, // 0x61
|
|
275 MP4_MPEG2_SNR_VIDEO_TYPE, // 0x62
|
|
276 MP4_MPEG2_SPATIAL_VIDEO_TYPE, // 0x63
|
|
277 MP4_MPEG2_HIGH_VIDEO_TYPE, // 0x64
|
|
278 MP4_MPEG2_442_VIDEO_TYPE, // 0x65
|
|
279 MP4_MPEG1_VIDEO_TYPE, // 0x6A
|
|
280 MP4_JPEG_VIDEO_TYPE, // 0x6C
|
|
281 MP4_YUV12_VIDEO_TYPE,
|
|
282 MP4_H263_VIDEO_TYPE,
|
|
283 MP4_H261_VIDEO_TYPE,
|
|
284 };
|
|
285 static const char* mpegVideoNames[] = {
|
|
286 "MPEG-2 Simple",
|
|
287 "MPEG-2 Main",
|
|
288 "MPEG-2 SNR",
|
|
289 "MPEG-2 Spatial",
|
|
290 "MPEG-2 High",
|
|
291 "MPEG-2 4:2:2",
|
|
292 "MPEG-1",
|
|
293 "JPEG",
|
|
294 "YUV12",
|
|
295 "H.263",
|
|
296 "H.261",
|
|
297 };
|
|
298 u_int8_t numMpegVideoTypes =
|
|
299 sizeof(mpegVideoTypes) / sizeof(u_int8_t);
|
|
300 bool foundTypeName = false;
|
|
301 const char* typeName = "Unknown";
|
|
302
|
|
303 const char *media_data_name;
|
|
304 uint8_t type = 0;
|
|
305
|
|
306 media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
|
|
307 char typebuffer[80];
|
|
308 if (media_data_name == NULL) {
|
|
309 typeName = "Unknown - no media data name";
|
|
310 foundTypeName = true;
|
|
311 } else if (strcasecmp(media_data_name, "avc1") == 0) {
|
|
312 // avc
|
|
313 uint8_t profile, level;
|
|
314 char profileb[20], levelb[20];
|
|
315 if (MP4GetTrackH264ProfileLevel(mp4File, trackId, &profile, &level)) {
|
|
316 if (profile == 66) {
|
|
317 strcpy(profileb, "Baseline");
|
|
318 } else if (profile == 77) {
|
|
319 strcpy(profileb, "Main");
|
|
320 } else if (profile == 88) {
|
|
321 strcpy(profileb, "Extended");
|
|
322 } else {
|
|
323 sprintf(profileb, "Unknown Profile %x", profile);
|
|
324 }
|
|
325 switch (level) {
|
|
326 case 10: case 20: case 30: case 40: case 50:
|
|
327 sprintf(levelb, "%u", level / 10);
|
|
328 break;
|
|
329 case 11: case 12: case 13:
|
|
330 case 21: case 22:
|
|
331 case 31: case 32:
|
|
332 case 41: case 42:
|
|
333 case 51:
|
|
334 sprintf(levelb, "%u.%u", level / 10, level % 10);
|
|
335 break;
|
|
336 default:
|
|
337 sprintf(levelb, "unknown level %x", level);
|
|
338 break;
|
|
339 }
|
|
340 sprintf(typebuffer, "H264 %s@%s", profileb, levelb);
|
|
341 typeName = typebuffer;
|
|
342 } else {
|
|
343 typeName = "H.264 - profile/level error";
|
|
344 }
|
|
345 foundTypeName = true;
|
|
346 } else if (strcasecmp(media_data_name, "s263") == 0) {
|
|
347 // 3gp h.263
|
|
348 typeName = "H.263";
|
|
349 foundTypeName = true;
|
|
350 } else if ((strcasecmp(media_data_name, "mp4v") == 0) ||
|
|
351 (strcasecmp(media_data_name, "encv") == 0)) {
|
|
352 // note encv might needs it's own field eventually.
|
|
353 type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId);
|
|
354 if (type == MP4_MPEG4_VIDEO_TYPE) {
|
|
355 type = MP4GetVideoProfileLevel(mp4File);
|
|
356 typeName = Mpeg4VisualProfileName(type);
|
|
357 if (typeName == NULL) {
|
|
358 typeName = "MPEG-4 Unknown Profile";
|
|
359 } else {
|
|
360 foundTypeName = true;
|
|
361 }
|
|
362 } else {
|
|
363 for (u_int8_t i = 0; i < numMpegVideoTypes; i++) {
|
|
364 if (type == mpegVideoTypes[i]) {
|
|
365 typeName = mpegVideoNames[i];
|
|
366 foundTypeName = true;
|
|
367 break;
|
|
368 }
|
|
369 }
|
|
370 }
|
|
371 } else {
|
|
372 typeName = media_data_name;
|
|
373 foundTypeName = true; // we don't have a type value to display
|
|
374 }
|
|
375
|
|
376 MP4Duration trackDuration =
|
|
377 MP4GetTrackDuration(mp4File, trackId);
|
|
378
|
|
379 double msDuration =
|
|
380 (double) (MP4ConvertFromTrackDuration(mp4File, trackId,
|
|
381 trackDuration, MP4_MSECS_TIME_SCALE));
|
|
382
|
|
383 u_int32_t avgBitRate =
|
|
384 MP4GetTrackBitRate(mp4File, trackId);
|
|
385
|
|
386 // Note not all mp4 implementations set width and height correctly
|
|
387 // The real answer can be buried inside the ES configuration info
|
|
388 u_int16_t width = MP4GetTrackVideoWidth(mp4File, trackId);
|
|
389
|
|
390 u_int16_t height = MP4GetTrackVideoHeight(mp4File, trackId);
|
|
391
|
|
392 double fps = MP4GetTrackVideoFrameRate(mp4File, trackId);
|
|
393
|
|
394 char *sInfo = (char*)MP4Malloc(256);
|
|
395
|
|
396 // type duration avgBitrate frameSize frameRate
|
|
397 if (foundTypeName) {
|
|
398 sprintf(sInfo,
|
|
399 "%u\tvideo\t%s%s, %.3f secs, %u kbps, %ux%u @ %f fps\n",
|
|
400 trackId,
|
|
401 MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "encv - " : "",
|
|
402 typeName,
|
|
403 msDuration / 1000.0,
|
|
404 (avgBitRate + 500) / 1000,
|
|
405 width,
|
|
406 height,
|
|
407 fps
|
|
408 );
|
|
409 } else {
|
|
410 sprintf(sInfo,
|
|
411 "%u\tvideo\t%s(%u), %.3f secs, %u kbps, %ux%u @ %f fps\n",
|
|
412 trackId,
|
|
413 typeName,
|
|
414 type,
|
|
415 msDuration / 1000.0,
|
|
416 (avgBitRate + 500) / 1000,
|
|
417 width,
|
|
418 height,
|
|
419 fps
|
|
420 );
|
|
421 }
|
|
422
|
|
423 return sInfo;
|
|
424 }
|
|
425 static char* PrintCntlInfo(
|
|
426 MP4FileHandle mp4File,
|
|
427 MP4TrackId trackId)
|
|
428 {
|
|
429 const char *media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
|
|
430 const char *typeName = "Unknown";
|
|
431
|
|
432 if (media_data_name == NULL) {
|
|
433 typeName = "Unknown - no media data name";
|
|
434 } else if (strcasecmp(media_data_name, "href") == 0) {
|
|
435 typeName = "ISMA Href";
|
|
436 } else {
|
|
437 typeName = media_data_name;
|
|
438 }
|
|
439
|
|
440 MP4Duration trackDuration =
|
|
441 MP4GetTrackDuration(mp4File, trackId);
|
|
442
|
|
443 double msDuration =
|
|
444 (double) (MP4ConvertFromTrackDuration(mp4File, trackId,
|
|
445 trackDuration, MP4_MSECS_TIME_SCALE));
|
|
446 char *sInfo = (char *)MP4Malloc(256);
|
|
447
|
|
448 snprintf(sInfo, 256,
|
|
449 "%u\tcontrol\t%s, %.3f secs\n",
|
|
450 trackId,
|
|
451 typeName,
|
|
452 msDuration / 1000.0);
|
|
453 return sInfo;
|
|
454 }
|
|
455
|
|
456
|
|
457 static char* PrintHintInfo(
|
|
458 MP4FileHandle mp4File,
|
|
459 MP4TrackId trackId)
|
|
460 {
|
|
461 MP4TrackId referenceTrackId =
|
|
462 MP4GetHintTrackReferenceTrackId(mp4File, trackId);
|
|
463
|
|
464 char* payloadName = NULL;
|
|
465 MP4GetHintTrackRtpPayload(mp4File, trackId, &payloadName);
|
|
466
|
|
467 char *sInfo = (char*)MP4Malloc(256);
|
|
468
|
|
469 sprintf(sInfo,
|
|
470 "%u\thint\tPayload %s for track %u\n",
|
|
471 trackId,
|
|
472 payloadName,
|
|
473 referenceTrackId);
|
|
474
|
|
475 free(payloadName);
|
|
476
|
|
477 return sInfo;
|
|
478 }
|
|
479
|
|
480 static char* PrintTrackInfo(
|
|
481 MP4FileHandle mp4File,
|
|
482 MP4TrackId trackId)
|
|
483 {
|
|
484 char* trackInfo = NULL;
|
|
485
|
|
486 const char* trackType =
|
|
487 MP4GetTrackType(mp4File, trackId);
|
|
488
|
|
489 if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)) {
|
|
490 trackInfo = PrintAudioInfo(mp4File, trackId);
|
|
491 } else if (!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) {
|
|
492 trackInfo = PrintVideoInfo(mp4File, trackId);
|
|
493 } else if (!strcmp(trackType, MP4_HINT_TRACK_TYPE)) {
|
|
494 trackInfo = PrintHintInfo(mp4File, trackId);
|
|
495 } else if (strcmp(trackType, MP4_CNTL_TRACK_TYPE) == 0) {
|
|
496 trackInfo = PrintCntlInfo(mp4File, trackId);
|
|
497 } else {
|
|
498 trackInfo = (char*)MP4Malloc(256);
|
|
499 if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) {
|
|
500 sprintf(trackInfo,
|
|
501 "%u\tod\tObject Descriptors\n",
|
|
502 trackId);
|
|
503 } else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) {
|
|
504 sprintf(trackInfo,
|
|
505 "%u\tscene\tBIFS\n",
|
|
506 trackId);
|
|
507 } else {
|
|
508 sprintf(trackInfo,
|
|
509 "%u\t%s\n",
|
|
510 trackId, trackType);
|
|
511 }
|
|
512 }
|
|
513
|
|
514 return trackInfo;
|
|
515 }
|
|
516
|
|
517 extern "C" char* MP4Info(
|
|
518 MP4FileHandle mp4File,
|
|
519 MP4TrackId trackId)
|
|
520 {
|
|
521 char* info = NULL;
|
|
522
|
|
523 if (MP4_IS_VALID_FILE_HANDLE(mp4File)) {
|
|
524 try {
|
|
525 if (trackId == MP4_INVALID_TRACK_ID) {
|
|
526 info = (char*)MP4Calloc(4*1024);
|
|
527
|
|
528 sprintf(info, "Track\tType\tInfo\n");
|
|
529
|
|
530 u_int32_t numTracks = MP4GetNumberOfTracks(mp4File);
|
|
531
|
|
532 for (u_int32_t i = 0; i < numTracks; i++) {
|
|
533 trackId = MP4FindTrackId(mp4File, i);
|
|
534 char* trackInfo = PrintTrackInfo(mp4File, trackId);
|
|
535 strcat(info, trackInfo);
|
|
536 MP4Free(trackInfo);
|
|
537 }
|
|
538 } else {
|
|
539 info = PrintTrackInfo(mp4File, trackId);
|
|
540 }
|
|
541 }
|
|
542 catch (MP4Error* e) {
|
|
543 delete e;
|
|
544 }
|
|
545 }
|
|
546
|
|
547 return info;
|
|
548 }
|
|
549
|
|
550 extern "C" char* MP4FileInfo(
|
|
551 const char* fileName,
|
|
552 MP4TrackId trackId)
|
|
553 {
|
|
554 MP4FileHandle mp4File =
|
|
555 MP4Read(fileName);
|
|
556
|
|
557 if (!mp4File) {
|
|
558 return NULL;
|
|
559 }
|
|
560
|
|
561 char* info = MP4Info(mp4File, trackId);
|
|
562
|
|
563 MP4Close(mp4File);
|
|
564
|
|
565 return info; // caller should free this
|
|
566 }
|
|
567
|