1 /* GStreamer
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) 2009 Tim-Philipp Müller <tim centricular net>
4 * Copyright (C) <2009> STEricsson <benjamin.gaignard@stericsson.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22 #include "qtdemux_debug.h"
23 #include "qtdemux_types.h"
24 #include "qtdemux_dump.h"
25 #include "fourcc.h"
26
27 #include "qtatomparser.h"
28
29 #include <string.h>
30
31 #define GST_CAT_DEFAULT qtdemux_debug
32
33 #define GET_UINT8(data) gst_byte_reader_get_uint8_unchecked(data)
34 #define GET_UINT16(data) gst_byte_reader_get_uint16_be_unchecked(data)
35 #define GET_UINT32(data) gst_byte_reader_get_uint32_be_unchecked(data)
36 #define GET_UINT64(data) gst_byte_reader_get_uint64_be_unchecked(data)
37 #define GET_FP32(data) (gst_byte_reader_get_uint32_be_unchecked(data)/65536.0)
38 #define GET_FP16(data) (gst_byte_reader_get_uint16_be_unchecked(data)/256.0)
39 #define GET_FOURCC(data) qt_atom_parser_get_fourcc_unchecked(data)
40
41 gboolean
qtdemux_dump_mvhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)42 qtdemux_dump_mvhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
43 {
44 guint32 version = 0;
45
46 if (!qt_atom_parser_has_remaining (data, 100))
47 return FALSE;
48
49 version = GET_UINT32 (data);
50 GST_LOG ("%*s version/flags: %08x", depth, "", version);
51
52 version = version >> 24;
53 if (version == 0) {
54 GST_LOG ("%*s creation time: %u", depth, "", GET_UINT32 (data));
55 GST_LOG ("%*s modify time: %u", depth, "", GET_UINT32 (data));
56 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
57 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
58 } else if (version == 1) {
59 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT,
60 depth, "", GET_UINT64 (data));
61 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT,
62 depth, "", GET_UINT64 (data));
63 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
64 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT,
65 depth, "", GET_UINT64 (data));
66 } else
67 return FALSE;
68
69 GST_LOG ("%*s pref. rate: %g", depth, "", GET_FP32 (data));
70 GST_LOG ("%*s pref. volume: %g", depth, "", GET_FP16 (data));
71 gst_byte_reader_skip_unchecked (data, 46);
72 GST_LOG ("%*s preview time: %u", depth, "", GET_UINT32 (data));
73 GST_LOG ("%*s preview dur.: %u", depth, "", GET_UINT32 (data));
74 GST_LOG ("%*s poster time: %u", depth, "", GET_UINT32 (data));
75 GST_LOG ("%*s select time: %u", depth, "", GET_UINT32 (data));
76 GST_LOG ("%*s select dur.: %u", depth, "", GET_UINT32 (data));
77 GST_LOG ("%*s current time: %u", depth, "", GET_UINT32 (data));
78 GST_LOG ("%*s next track ID: %d", depth, "", GET_UINT32 (data));
79 return TRUE;
80 }
81
82 gboolean
qtdemux_dump_tkhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)83 qtdemux_dump_tkhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
84 {
85 guint64 duration, ctime, mtime;
86 guint32 version = 0, track_id = 0, iwidth = 0, iheight = 0;
87 guint16 layer = 0, alt_group = 0, ivol = 0;
88 guint value_size;
89
90 if (!gst_byte_reader_get_uint32_be (data, &version))
91 return FALSE;
92
93 GST_LOG ("%*s version/flags: %08x", depth, "", version);
94
95 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
96
97 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
98 qt_atom_parser_get_offset (data, value_size, &mtime) &&
99 gst_byte_reader_get_uint32_be (data, &track_id) &&
100 gst_byte_reader_skip (data, 4) &&
101 qt_atom_parser_get_offset (data, value_size, &duration) &&
102 gst_byte_reader_skip (data, 4) &&
103 gst_byte_reader_get_uint16_be (data, &layer) &&
104 gst_byte_reader_get_uint16_be (data, &alt_group) &&
105 gst_byte_reader_skip (data, 4) &&
106 gst_byte_reader_get_uint16_be (data, &ivol) &&
107 gst_byte_reader_skip (data, 2 + (9 * 4)) &&
108 gst_byte_reader_get_uint32_be (data, &iwidth) &&
109 gst_byte_reader_get_uint32_be (data, &iheight)) {
110 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
111 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
112 GST_LOG ("%*s track ID: %u", depth, "", track_id);
113 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
114 GST_LOG ("%*s layer: %u", depth, "", layer);
115 GST_LOG ("%*s alt group: %u", depth, "", alt_group);
116 GST_LOG ("%*s volume: %g", depth, "", ivol / 256.0);
117 GST_LOG ("%*s track width: %g", depth, "", iwidth / 65536.0);
118 GST_LOG ("%*s track height: %g", depth, "", iheight / 65536.0);
119 return TRUE;
120 }
121
122 return FALSE;
123 }
124
125 gboolean
qtdemux_dump_elst(GstQTDemux * qtdemux,GstByteReader * data,int depth)126 qtdemux_dump_elst (GstQTDemux * qtdemux, GstByteReader * data, int depth)
127 {
128 guint32 ver_flags = 0, num_entries = 0, i;
129
130 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
131 !gst_byte_reader_get_uint32_be (data, &num_entries))
132 return FALSE;
133
134 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
135 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
136
137 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
138 return FALSE;
139
140 for (i = 0; i < num_entries; i++) {
141 GST_LOG ("%*s track dur: %u", depth, "", GET_UINT32 (data));
142 GST_LOG ("%*s media time: %u", depth, "", GET_UINT32 (data));
143 GST_LOG ("%*s media rate: %g", depth, "", GET_FP32 (data));
144 }
145 return TRUE;
146 }
147
148 gboolean
qtdemux_dump_mdhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)149 qtdemux_dump_mdhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
150 {
151 guint32 version = 0;
152 guint64 duration, ctime, mtime;
153 guint32 time_scale = 0;
154 guint16 language = 0, quality = 0;
155 guint value_size;
156
157 if (!gst_byte_reader_get_uint32_be (data, &version))
158 return FALSE;
159
160 GST_LOG ("%*s version/flags: %08x", depth, "", version);
161
162 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
163
164 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
165 qt_atom_parser_get_offset (data, value_size, &mtime) &&
166 gst_byte_reader_get_uint32_be (data, &time_scale) &&
167 qt_atom_parser_get_offset (data, value_size, &duration) &&
168 gst_byte_reader_get_uint16_be (data, &language) &&
169 gst_byte_reader_get_uint16_be (data, &quality)) {
170 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
171 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
172 GST_LOG ("%*s time scale: 1/%u sec", depth, "", time_scale);
173 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
174 GST_LOG ("%*s language: %u", depth, "", language);
175 GST_LOG ("%*s quality: %u", depth, "", quality);
176 return TRUE;
177 }
178
179 return FALSE;
180 }
181
182 gboolean
qtdemux_dump_hdlr(GstQTDemux * qtdemux,GstByteReader * data,int depth)183 qtdemux_dump_hdlr (GstQTDemux * qtdemux, GstByteReader * data, int depth)
184 {
185 guint32 version, type, subtype, manufacturer;
186 const gchar *name;
187
188 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4))
189 return FALSE;
190
191 version = GET_UINT32 (data);
192 type = GET_FOURCC (data);
193 subtype = GET_FOURCC (data);
194 manufacturer = GET_FOURCC (data);
195
196 GST_LOG ("%*s version/flags: %08x", depth, "", version);
197 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
198 GST_FOURCC_ARGS (type));
199 GST_LOG ("%*s subtype: %" GST_FOURCC_FORMAT, depth, "",
200 GST_FOURCC_ARGS (subtype));
201 GST_LOG ("%*s manufacturer: %" GST_FOURCC_FORMAT, depth, "",
202 GST_FOURCC_ARGS (manufacturer));
203 GST_LOG ("%*s flags: %08x", depth, "", GET_UINT32 (data));
204 GST_LOG ("%*s flags mask: %08x", depth, "", GET_UINT32 (data));
205
206 /* quicktime uses pascal string, mp4 zero-terminated string */
207 if (gst_byte_reader_peek_string (data, &name)) {
208 GST_LOG ("%*s name: %s", depth, "", name);
209 } else {
210 gchar buf[256];
211 guint8 len;
212
213 if (gst_byte_reader_get_uint8 (data, &len)
214 && qt_atom_parser_has_remaining (data, len)) {
215 memcpy (buf, gst_byte_reader_peek_data_unchecked (data), len);
216 buf[len] = '\0';
217 GST_LOG ("%*s name: %s", depth, "", buf);
218 }
219 }
220 return TRUE;
221 }
222
223 gboolean
qtdemux_dump_vmhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)224 qtdemux_dump_vmhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
225 {
226 if (!qt_atom_parser_has_remaining (data, 4 + 4))
227 return FALSE;
228
229 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
230 GST_LOG ("%*s mode/color: %08x", depth, "", GET_UINT32 (data));
231 return TRUE;
232 }
233
234 gboolean
qtdemux_dump_dref(GstQTDemux * qtdemux,GstByteReader * data,int depth)235 qtdemux_dump_dref (GstQTDemux * qtdemux, GstByteReader * data, int depth)
236 {
237 guint32 ver_flags = 0, num_entries = 0, i;
238
239 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
240 !gst_byte_reader_get_uint32_be (data, &num_entries))
241 return FALSE;
242
243 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
244 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
245 for (i = 0; i < num_entries; i++) {
246 guint32 size = 0, fourcc;
247
248 if (!gst_byte_reader_get_uint32_be (data, &size) ||
249 !qt_atom_parser_get_fourcc (data, &fourcc) || size < 8 ||
250 !gst_byte_reader_skip (data, size - 8))
251 return FALSE;
252
253 GST_LOG ("%*s size: %u", depth, "", size);
254 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
255 GST_FOURCC_ARGS (fourcc));
256 }
257 return TRUE;
258 }
259
260 static gboolean
qtdemux_dump_stsd_avc1(GstQTDemux * qtdemux,GstByteReader * data,guint size,int depth)261 qtdemux_dump_stsd_avc1 (GstQTDemux * qtdemux, GstByteReader * data, guint size,
262 int depth)
263 {
264 guint32 fourcc;
265
266 /* Size of avc1 = 78 bytes */
267 if (size < (6 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 2 + 1 + 31 + 2 + 2))
268 return FALSE;
269
270 gst_byte_reader_skip_unchecked (data, 6);
271 GST_LOG_OBJECT (qtdemux, "%*s data reference:%d", depth, "",
272 GET_UINT16 (data));
273 GST_LOG_OBJECT (qtdemux, "%*s version/rev.: %08x", depth, "",
274 GET_UINT32 (data));
275 fourcc = GET_FOURCC (data);
276 GST_LOG_OBJECT (qtdemux, "%*s vendor: %" GST_FOURCC_FORMAT, depth,
277 "", GST_FOURCC_ARGS (fourcc));
278 GST_LOG_OBJECT (qtdemux, "%*s temporal qual: %u", depth, "",
279 GET_UINT32 (data));
280 GST_LOG_OBJECT (qtdemux, "%*s spatial qual: %u", depth, "",
281 GET_UINT32 (data));
282 GST_LOG_OBJECT (qtdemux, "%*s width: %u", depth, "",
283 GET_UINT16 (data));
284 GST_LOG_OBJECT (qtdemux, "%*s height: %u", depth, "",
285 GET_UINT16 (data));
286 GST_LOG_OBJECT (qtdemux, "%*s horiz. resol: %g", depth, "",
287 GET_FP32 (data));
288 GST_LOG_OBJECT (qtdemux, "%*s vert. resol.: %g", depth, "",
289 GET_FP32 (data));
290 GST_LOG_OBJECT (qtdemux, "%*s data size: %u", depth, "",
291 GET_UINT32 (data));
292 GST_LOG_OBJECT (qtdemux, "%*s frame count: %u", depth, "",
293 GET_UINT16 (data));
294 /* something is not right with this, it's supposed to be a string but it's
295 * not apparently, so just skip this for now */
296 gst_byte_reader_skip_unchecked (data, 1 + 31);
297 GST_LOG_OBJECT (qtdemux, "%*s compressor: (skipped)", depth, "");
298 GST_LOG_OBJECT (qtdemux, "%*s depth: %u", depth, "",
299 GET_UINT16 (data));
300 GST_LOG_OBJECT (qtdemux, "%*s color table ID:%u", depth, "",
301 GET_UINT16 (data));
302
303 return TRUE;
304 }
305
306
307 static gboolean
qtdemux_dump_stsd_av01(GstQTDemux * qtdemux,GstByteReader * data,guint size,int depth)308 qtdemux_dump_stsd_av01 (GstQTDemux * qtdemux, GstByteReader * data, guint size,
309 int depth)
310 {
311 guint compressor_len;
312 char compressor_name[32];
313
314 /* Size of av01 = 78 bytes */
315 if (size < (6 + 2 + 4 + 12 + 2 + 2 + 4 + 4 + 4 + 2 + 1 + 31 + 2 + 2))
316 return FALSE;
317
318 gst_byte_reader_skip_unchecked (data, 6);
319 GST_LOG_OBJECT (qtdemux, "%*s data reference:%d", depth, "",
320 GET_UINT16 (data));
321 GST_LOG_OBJECT (qtdemux, "%*s version/rev.: %08x", depth, "",
322 GET_UINT32 (data));
323 gst_byte_reader_skip_unchecked (data, 12); /* pre-defined & reserved */
324 GST_LOG_OBJECT (qtdemux, "%*s width: %u", depth, "",
325 GET_UINT16 (data));
326 GST_LOG_OBJECT (qtdemux, "%*s height: %u", depth, "",
327 GET_UINT16 (data));
328 GST_LOG_OBJECT (qtdemux, "%*s horiz. resol: %g", depth, "",
329 GET_FP32 (data));
330 GST_LOG_OBJECT (qtdemux, "%*s vert. resol.: %g", depth, "",
331 GET_FP32 (data));
332 GST_LOG_OBJECT (qtdemux, "%*s data size: %u", depth, "",
333 GET_UINT32 (data));
334 GST_LOG_OBJECT (qtdemux, "%*s frame count: %u", depth, "",
335 GET_UINT16 (data));
336 /* something is not right with this, it's supposed to be a string but it's
337 * not apparently, so just skip this for now */
338 compressor_len = MAX (GET_UINT8 (data), 31);
339 memcpy (compressor_name, gst_byte_reader_get_data_unchecked (data, 31), 31);
340 compressor_name[compressor_len] = 0;
341 GST_LOG_OBJECT (qtdemux, "%*s compressor: %s", depth, "",
342 compressor_name);
343 GST_LOG_OBJECT (qtdemux, "%*s depth: %u", depth, "",
344 GET_UINT16 (data));
345 GST_LOG_OBJECT (qtdemux, "%*s color table ID:%u", depth, "",
346 GET_UINT16 (data));
347
348 return TRUE;
349 }
350
351 gboolean
qtdemux_dump_stsd(GstQTDemux * qtdemux,GstByteReader * data,int depth)352 qtdemux_dump_stsd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
353 {
354 guint32 ver_flags = 0, num_entries = 0, i;
355
356 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
357 !gst_byte_reader_get_uint32_be (data, &num_entries))
358 return FALSE;
359
360 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
361 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
362
363 for (i = 0; i < num_entries; i++) {
364 GstByteReader sub;
365 guint32 size, remain;
366 guint32 fourcc;
367
368 if (!gst_byte_reader_get_uint32_be (data, &size) ||
369 !qt_atom_parser_get_fourcc (data, &fourcc))
370 return FALSE;
371
372 GST_LOG_OBJECT (qtdemux, "%*s size: %u", depth, "", size);
373 GST_LOG_OBJECT (qtdemux, "%*s type: %" GST_FOURCC_FORMAT, depth,
374 "", GST_FOURCC_ARGS (fourcc));
375
376 remain = gst_byte_reader_get_remaining (data);
377 /* Size includes the 8 bytes we just read: len & fourcc, then 8 bytes
378 * version, flags, entries_count */
379 if (size > remain + 8) {
380 GST_LOG_OBJECT (qtdemux,
381 "Not enough data left for this atom (have %u need %u)", remain, size);
382 return FALSE;
383 }
384
385 qt_atom_parser_peek_sub (data, 0, size, &sub);
386 switch (fourcc) {
387 case FOURCC_avc1:
388 if (!qtdemux_dump_stsd_avc1 (qtdemux, &sub, size, depth + 1))
389 return FALSE;
390 break;
391 case FOURCC_fLaC:
392 /* will be dumped by node_dump_foreach */
393 break;
394 case FOURCC_mp4s:
395 if (!gst_byte_reader_get_uint32_be (&sub, &ver_flags) ||
396 !gst_byte_reader_get_uint32_be (&sub, &num_entries))
397 return FALSE;
398 if (!qtdemux_dump_unknown (qtdemux, &sub, depth + 1))
399 return FALSE;
400 break;
401 case FOURCC_av01:
402 if (!qtdemux_dump_stsd_av01 (qtdemux, &sub, size, depth + 1))
403 return FALSE;
404 break;
405 default:
406 /* Unknown stsd data, dump the bytes */
407 if (!qtdemux_dump_unknown (qtdemux, &sub, depth + 1))
408 return FALSE;
409 break;
410 }
411
412 if (!gst_byte_reader_skip (data, size - (4 + 4)))
413 return FALSE;
414 }
415 return TRUE;
416 }
417
418 gboolean
qtdemux_dump_stts(GstQTDemux * qtdemux,GstByteReader * data,int depth)419 qtdemux_dump_stts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
420 {
421 guint32 ver_flags = 0, num_entries = 0, i;
422
423 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
424 !gst_byte_reader_get_uint32_be (data, &num_entries))
425 return FALSE;
426
427 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
428 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
429
430 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
431 return FALSE;
432
433 for (i = 0; i < num_entries; i++) {
434 GST_LOG ("%*s count: %u", depth, "", GET_UINT32 (data));
435 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
436 }
437 return TRUE;
438 }
439
440 gboolean
qtdemux_dump_stps(GstQTDemux * qtdemux,GstByteReader * data,int depth)441 qtdemux_dump_stps (GstQTDemux * qtdemux, GstByteReader * data, int depth)
442 {
443 guint32 ver_flags = 0, num_entries = 0, i;
444
445 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
446 !gst_byte_reader_get_uint32_be (data, &num_entries))
447 return FALSE;
448
449 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
450 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
451
452 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
453 return FALSE;
454
455 for (i = 0; i < num_entries; i++) {
456 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
457 }
458 return TRUE;
459 }
460
461 gboolean
qtdemux_dump_stss(GstQTDemux * qtdemux,GstByteReader * data,int depth)462 qtdemux_dump_stss (GstQTDemux * qtdemux, GstByteReader * data, int depth)
463 {
464 guint32 ver_flags = 0, num_entries = 0, i;
465
466 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
467 !gst_byte_reader_get_uint32_be (data, &num_entries))
468 return FALSE;
469
470 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
471 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
472
473 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
474 return FALSE;
475
476 for (i = 0; i < num_entries; i++) {
477 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
478 }
479 return TRUE;
480 }
481
482 gboolean
qtdemux_dump_stsc(GstQTDemux * qtdemux,GstByteReader * data,int depth)483 qtdemux_dump_stsc (GstQTDemux * qtdemux, GstByteReader * data, int depth)
484 {
485 guint32 ver_flags = 0, num_entries = 0, i;
486
487 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
488 !gst_byte_reader_get_uint32_be (data, &num_entries))
489 return FALSE;
490
491 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
492 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
493
494 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
495 return FALSE;
496
497 for (i = 0; i < num_entries; i++) {
498 GST_LOG ("%*s first chunk: %u", depth, "", GET_UINT32 (data));
499 GST_LOG ("%*s sample per ch: %u", depth, "", GET_UINT32 (data));
500 GST_LOG ("%*s sample desc id:%08x", depth, "", GET_UINT32 (data));
501 }
502 return TRUE;
503 }
504
505 gboolean
qtdemux_dump_stsz(GstQTDemux * qtdemux,GstByteReader * data,int depth)506 qtdemux_dump_stsz (GstQTDemux * qtdemux, GstByteReader * data, int depth)
507 {
508 guint32 ver_flags = 0, sample_size = 0, num_entries = 0, i;
509
510 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
511 !gst_byte_reader_get_uint32_be (data, &sample_size))
512 return FALSE;
513
514 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
515 GST_LOG ("%*s sample size: %d", depth, "", sample_size);
516
517 if (sample_size == 0) {
518 if (!gst_byte_reader_get_uint32_be (data, &num_entries))
519 return FALSE;
520
521 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
522 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
523 return FALSE;
524 for (i = 0; i < num_entries; i++) {
525 GST_TRACE ("%*s sample size: %u", depth, "", GET_UINT32 (data));
526 }
527 }
528 return TRUE;
529 }
530
531 gboolean
qtdemux_dump_stco(GstQTDemux * qtdemux,GstByteReader * data,int depth)532 qtdemux_dump_stco (GstQTDemux * qtdemux, GstByteReader * data, int depth)
533 {
534 guint32 ver_flags = 0, num_entries = 0, i;
535
536 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
537 !gst_byte_reader_get_uint32_be (data, &num_entries))
538 return FALSE;
539
540 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
541 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
542
543 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
544 return FALSE;
545
546 for (i = 0; i < num_entries; i++) {
547 GST_LOG ("%*s chunk offset: %u", depth, "", GET_UINT32 (data));
548 }
549 return TRUE;
550 }
551
552 gboolean
qtdemux_dump_ctts(GstQTDemux * qtdemux,GstByteReader * data,int depth)553 qtdemux_dump_ctts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
554 {
555 guint32 ver_flags = 0, num_entries = 0, i, count;
556 gint32 offset;
557
558
559 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
560 !gst_byte_reader_get_uint32_be (data, &num_entries))
561 return FALSE;
562
563 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
564 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
565
566 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
567 return FALSE;
568
569 for (i = 0; i < num_entries; i++) {
570 count = GET_UINT32 (data);
571 offset = GET_UINT32 (data);
572 GST_LOG ("%*s sample count :%8d offset: %8d", depth, "", count, offset);
573 }
574 return TRUE;
575 }
576
577 gboolean
qtdemux_dump_cslg(GstQTDemux * qtdemux,GstByteReader * data,int depth)578 qtdemux_dump_cslg (GstQTDemux * qtdemux, GstByteReader * data, int depth)
579 {
580 guint32 ver_flags = 0;
581
582 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
583 return FALSE;
584
585 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
586
587 if (ver_flags >> 24 == 0) {
588 gint32 shift = 0, least_offset = 0, start_time = 0, end_time = 0;
589 if (!gst_byte_reader_get_int32_be (data, &shift) ||
590 !gst_byte_reader_get_int32_be (data, &least_offset) ||
591 !gst_byte_reader_get_int32_be (data, &start_time) ||
592 !gst_byte_reader_get_int32_be (data, &end_time))
593 return FALSE;
594 GST_LOG ("%*s shift: %d", depth, "", shift);
595 GST_LOG ("%*s least offset: %d", depth, "", least_offset);
596 GST_LOG ("%*s start time: %d", depth, "", start_time);
597 GST_LOG ("%*s end time: %d", depth, "", end_time);
598 } else {
599 gint64 shift = 0, least_offset = 0, start_time = 0, end_time = 0;
600 if (!gst_byte_reader_get_int64_be (data, &shift) ||
601 !gst_byte_reader_get_int64_be (data, &least_offset) ||
602 !gst_byte_reader_get_int64_be (data, &start_time) ||
603 !gst_byte_reader_get_int64_be (data, &end_time))
604 return FALSE;
605
606 GST_LOG ("%*s shift: %" G_GINT64_FORMAT, depth, "", shift);
607 GST_LOG ("%*s least offset: %" G_GINT64_FORMAT, depth, "", least_offset);
608 GST_LOG ("%*s start time: %" G_GINT64_FORMAT, depth, "", start_time);
609 GST_LOG ("%*s end time: %" G_GINT64_FORMAT, depth, "", end_time);
610 }
611
612 return TRUE;
613 }
614
615 gboolean
qtdemux_dump_co64(GstQTDemux * qtdemux,GstByteReader * data,int depth)616 qtdemux_dump_co64 (GstQTDemux * qtdemux, GstByteReader * data, int depth)
617 {
618 guint32 ver_flags = 0, num_entries = 0, i;
619
620 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
621 !gst_byte_reader_get_uint32_be (data, &num_entries))
622 return FALSE;
623
624 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
625 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
626
627 if (!qt_atom_parser_has_chunks (data, num_entries, 8))
628 return FALSE;
629
630 for (i = 0; i < num_entries; i++) {
631 GST_LOG ("%*s chunk offset: %" G_GUINT64_FORMAT, depth, "",
632 GET_UINT64 (data));
633 }
634 return TRUE;
635 }
636
637 gboolean
qtdemux_dump_dcom(GstQTDemux * qtdemux,GstByteReader * data,int depth)638 qtdemux_dump_dcom (GstQTDemux * qtdemux, GstByteReader * data, int depth)
639 {
640 if (!qt_atom_parser_has_remaining (data, 4))
641 return FALSE;
642
643 GST_LOG ("%*s compression type: %" GST_FOURCC_FORMAT, depth, "",
644 GST_FOURCC_ARGS (GET_FOURCC (data)));
645 return TRUE;
646 }
647
648 gboolean
qtdemux_dump_cmvd(GstQTDemux * qtdemux,GstByteReader * data,int depth)649 qtdemux_dump_cmvd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
650 {
651 if (!qt_atom_parser_has_remaining (data, 4))
652 return FALSE;
653
654 GST_LOG ("%*s length: %d", depth, "", GET_UINT32 (data));
655 return TRUE;
656 }
657
658 gboolean
qtdemux_dump_mfro(GstQTDemux * qtdemux,GstByteReader * data,int depth)659 qtdemux_dump_mfro (GstQTDemux * qtdemux, GstByteReader * data, int depth)
660 {
661 if (!qt_atom_parser_has_remaining (data, 4))
662 return FALSE;
663
664 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
665 GST_LOG ("%*s size: %d", depth, "", GET_UINT32 (data));
666 return TRUE;
667 }
668
669 gboolean
qtdemux_dump_mfhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)670 qtdemux_dump_mfhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
671 {
672 if (!qt_atom_parser_has_remaining (data, 4))
673 return FALSE;
674
675 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
676 GST_LOG ("%*s sequence_number: %d", depth, "", GET_UINT32 (data));
677 return TRUE;
678 }
679
680 gboolean
qtdemux_dump_tfra(GstQTDemux * qtdemux,GstByteReader * data,int depth)681 qtdemux_dump_tfra (GstQTDemux * qtdemux, GstByteReader * data, int depth)
682 {
683 guint64 time = 0, moof_offset = 0;
684 guint32 len = 0, num_entries = 0, ver_flags = 0, track_id = 0, i;
685 guint value_size, traf_size, trun_size, sample_size;
686
687 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
688 return FALSE;
689
690 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
691
692 if (!gst_byte_reader_get_uint32_be (data, &track_id) ||
693 !gst_byte_reader_get_uint32_be (data, &len) ||
694 !gst_byte_reader_get_uint32_be (data, &num_entries))
695 return FALSE;
696
697 GST_LOG ("%*s track ID: %u", depth, "", track_id);
698 GST_LOG ("%*s length: 0x%x", depth, "", len);
699 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
700
701 value_size = ((ver_flags >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
702 sample_size = (len & 3) + 1;
703 trun_size = ((len & 12) >> 2) + 1;
704 traf_size = ((len & 48) >> 4) + 1;
705
706 if (!qt_atom_parser_has_chunks (data, num_entries,
707 value_size + value_size + traf_size + trun_size + sample_size))
708 return FALSE;
709
710 for (i = 0; i < num_entries; i++) {
711 qt_atom_parser_get_offset (data, value_size, &time);
712 qt_atom_parser_get_offset (data, value_size, &moof_offset);
713 GST_LOG ("%*s time: %" G_GUINT64_FORMAT, depth, "", time);
714 GST_LOG ("%*s moof_offset: %" G_GUINT64_FORMAT,
715 depth, "", moof_offset);
716 GST_LOG ("%*s traf_number: %u", depth, "",
717 qt_atom_parser_get_uint_with_size_unchecked (data, traf_size));
718 GST_LOG ("%*s trun_number: %u", depth, "",
719 qt_atom_parser_get_uint_with_size_unchecked (data, trun_size));
720 GST_LOG ("%*s sample_number: %u", depth, "",
721 qt_atom_parser_get_uint_with_size_unchecked (data, sample_size));
722 }
723
724 return TRUE;
725 }
726
727 gboolean
qtdemux_dump_tfhd(GstQTDemux * qtdemux,GstByteReader * data,int depth)728 qtdemux_dump_tfhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
729 {
730 guint32 flags = 0, n = 0, track_id = 0;
731 guint64 base_data_offset = 0;
732
733 if (!gst_byte_reader_skip (data, 1) ||
734 !gst_byte_reader_get_uint24_be (data, &flags))
735 return FALSE;
736 GST_LOG ("%*s flags: %08x", depth, "", flags);
737
738 if (!gst_byte_reader_get_uint32_be (data, &track_id))
739 return FALSE;
740 GST_LOG ("%*s track_id: %u", depth, "", track_id);
741
742 if (flags & TF_BASE_DATA_OFFSET) {
743 if (!gst_byte_reader_get_uint64_be (data, &base_data_offset))
744 return FALSE;
745 GST_LOG ("%*s base-data-offset: %" G_GUINT64_FORMAT,
746 depth, "", base_data_offset);
747 }
748
749 if (flags & TF_SAMPLE_DESCRIPTION_INDEX) {
750 if (!gst_byte_reader_get_uint32_be (data, &n))
751 return FALSE;
752 GST_LOG ("%*s sample-description-index: %u", depth, "", n);
753 }
754
755 if (flags & TF_DEFAULT_SAMPLE_DURATION) {
756 if (!gst_byte_reader_get_uint32_be (data, &n))
757 return FALSE;
758 GST_LOG ("%*s default-sample-duration: %u", depth, "", n);
759 }
760
761 if (flags & TF_DEFAULT_SAMPLE_SIZE) {
762 if (!gst_byte_reader_get_uint32_be (data, &n))
763 return FALSE;
764 GST_LOG ("%*s default-sample-size: %u", depth, "", n);
765 }
766
767 if (flags & TF_DEFAULT_SAMPLE_FLAGS) {
768 if (!gst_byte_reader_get_uint32_be (data, &n))
769 return FALSE;
770 GST_LOG ("%*s default-sample-flags: %u", depth, "", n);
771 }
772
773 GST_LOG ("%*s duration-is-empty: %s", depth, "",
774 flags & TF_DURATION_IS_EMPTY ? "yes" : "no");
775
776 return TRUE;
777 }
778
779 gboolean
qtdemux_dump_trun(GstQTDemux * qtdemux,GstByteReader * data,int depth)780 qtdemux_dump_trun (GstQTDemux * qtdemux, GstByteReader * data, int depth)
781 {
782 guint32 flags = 0, samples_count = 0, data_offset = 0, first_sample_flags = 0;
783 guint32 sample_duration = 0, sample_size = 0, sample_flags =
784 0, composition_time_offsets = 0;
785 int i = 0;
786
787 if (!gst_byte_reader_skip (data, 1) ||
788 !gst_byte_reader_get_uint24_be (data, &flags))
789 return FALSE;
790
791 GST_LOG ("%*s flags: %08x", depth, "", flags);
792
793 if (!gst_byte_reader_get_uint32_be (data, &samples_count))
794 return FALSE;
795 GST_LOG ("%*s samples_count: %u", depth, "", samples_count);
796
797 if (flags & TR_DATA_OFFSET) {
798 if (!gst_byte_reader_get_uint32_be (data, &data_offset))
799 return FALSE;
800 GST_LOG ("%*s data-offset: %u", depth, "", data_offset);
801 }
802
803 if (flags & TR_FIRST_SAMPLE_FLAGS) {
804 if (!gst_byte_reader_get_uint32_be (data, &first_sample_flags))
805 return FALSE;
806 GST_LOG ("%*s first-sample-flags: %u", depth, "", first_sample_flags);
807 }
808
809 for (i = 0; i < samples_count; i++) {
810 if (flags & TR_SAMPLE_DURATION) {
811 if (!gst_byte_reader_get_uint32_be (data, &sample_duration))
812 return FALSE;
813 GST_TRACE ("%*s sample-duration: %u", depth, "", sample_duration);
814 }
815
816 if (flags & TR_SAMPLE_SIZE) {
817 if (!gst_byte_reader_get_uint32_be (data, &sample_size))
818 return FALSE;
819 GST_TRACE ("%*s sample-size: %u", depth, "", sample_size);
820 }
821
822 if (flags & TR_SAMPLE_FLAGS) {
823 if (!gst_byte_reader_get_uint32_be (data, &sample_flags))
824 return FALSE;
825 GST_TRACE ("%*s sample-flags: %u", depth, "", sample_flags);
826 }
827
828 if (flags & TR_COMPOSITION_TIME_OFFSETS) {
829 if (!gst_byte_reader_get_uint32_be (data, &composition_time_offsets))
830 return FALSE;
831 GST_TRACE ("%*s composition_time_offsets: %d", depth, "",
832 composition_time_offsets);
833 }
834 }
835
836 return TRUE;
837 }
838
839 gboolean
qtdemux_dump_trex(GstQTDemux * qtdemux,GstByteReader * data,int depth)840 qtdemux_dump_trex (GstQTDemux * qtdemux, GstByteReader * data, int depth)
841 {
842 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4))
843 return FALSE;
844
845 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
846 GST_LOG ("%*s track ID: %08x", depth, "", GET_UINT32 (data));
847 GST_LOG ("%*s default sample desc. index: %08x", depth, "",
848 GET_UINT32 (data));
849 GST_LOG ("%*s default sample duration: %08x", depth, "",
850 GET_UINT32 (data));
851 GST_LOG ("%*s default sample size: %08x", depth, "",
852 GET_UINT32 (data));
853 GST_LOG ("%*s default sample flags: %08x", depth, "",
854 GET_UINT32 (data));
855
856 return TRUE;
857 }
858
859 gboolean
qtdemux_dump_mehd(GstQTDemux * qtdemux,GstByteReader * data,int depth)860 qtdemux_dump_mehd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
861 {
862 guint32 version = 0;
863 guint64 fragment_duration;
864 guint value_size;
865
866 if (!gst_byte_reader_get_uint32_be (data, &version))
867 return FALSE;
868
869 GST_LOG ("%*s version/flags: %08x", depth, "", version);
870
871 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
872 if (qt_atom_parser_get_offset (data, value_size, &fragment_duration)) {
873 GST_LOG ("%*s fragment duration: %" G_GUINT64_FORMAT,
874 depth, "", fragment_duration);
875 return TRUE;
876 }
877
878 return FALSE;
879 }
880
881 gboolean
qtdemux_dump_tfdt(GstQTDemux * qtdemux,GstByteReader * data,int depth)882 qtdemux_dump_tfdt (GstQTDemux * qtdemux, GstByteReader * data, int depth)
883 {
884 guint32 version = 0;
885 guint64 decode_time;
886 guint value_size;
887
888 if (!gst_byte_reader_get_uint32_be (data, &version))
889 return FALSE;
890
891 GST_LOG ("%*s version/flags: %08x", depth, "", version);
892
893 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
894 if (qt_atom_parser_get_offset (data, value_size, &decode_time)) {
895 GST_LOG ("%*s Track fragment decode time: %" G_GUINT64_FORMAT,
896 depth, "", decode_time);
897 return TRUE;
898 }
899
900 return FALSE;
901 }
902
903 gboolean
qtdemux_dump_sdtp(GstQTDemux * qtdemux,GstByteReader * data,int depth)904 qtdemux_dump_sdtp (GstQTDemux * qtdemux, GstByteReader * data, int depth)
905 {
906 guint32 version;
907 guint8 val;
908 guint i = 1;
909
910 version = GET_UINT32 (data);
911 GST_LOG ("%*s version/flags: %08x", depth, "", version);
912
913 /* the sample_count is specified in the stsz or stz2 box.
914 * the information for a sample is stored in a single byte,
915 * so we read until there are no remaining bytes */
916 while (qt_atom_parser_has_remaining (data, 1)) {
917 val = GET_UINT8 (data);
918 GST_LOG ("%*s sample number: %d", depth, "", i);
919 GST_LOG ("%*s sample_depends_on: %d", depth, "",
920 ((guint16) (val)) & 0x3);
921 GST_LOG ("%*s sample_is_depended_on: %d", depth, "",
922 ((guint16) (val >> 2)) & 0x3);
923 GST_LOG ("%*s sample_has_redundancy: %d", depth, "",
924 ((guint16) (val >> 4)) & 0x3);
925 GST_LOG ("%*s early display: %d", depth, "",
926 ((guint16) (val >> 6)) & 0x1);
927 ++i;
928 }
929 return TRUE;
930 }
931
932 gboolean
qtdemux_dump_svmi(GstQTDemux * qtdemux,GstByteReader * data,int depth)933 qtdemux_dump_svmi (GstQTDemux * qtdemux, GstByteReader * data, int depth)
934 {
935 guint32 version;
936 guint stereo_mono_change_count;
937 guint i;
938
939 version = GET_UINT32 (data);
940 GST_LOG ("%*s version/flags: %08x", depth, "", version);
941
942 if (!version) {
943 /* stereoscopic visual type information */
944 GST_LOG ("%*s stereo_composition_type: %d", depth, "",
945 GET_UINT8 (data));
946 GST_LOG ("%*s is_left_first: %d", depth, "",
947 ((guint8) GET_UINT8 (data)) & 0x01);
948
949 /* stereo_mono_change information */
950 stereo_mono_change_count = GET_UINT32 (data);
951 GST_LOG ("%*s stereo_mono_change_count: %d", depth, "",
952 stereo_mono_change_count);
953 for (i = 1; i <= stereo_mono_change_count; i++) {
954 GST_LOG ("%*s sample_count: %d", depth, "", GET_UINT32 (data));
955 GST_LOG ("%*s stereo_flag: %d", depth, "",
956 ((guint8) GET_UINT8 (data)) & 0x01);
957 }
958 }
959 return TRUE;
960 }
961
962 gboolean
qtdemux_dump_dfLa(GstQTDemux * qtdemux,GstByteReader * data,int depth)963 qtdemux_dump_dfLa (GstQTDemux * qtdemux, GstByteReader * data, int depth)
964 {
965 const gchar *block_types[] = {
966 "STREAMINFO", "PADDING", "APPLICATION", "SEEKTABLE", "VORBIS_COMMENT",
967 "CUESHEET", "PICTURE", "UNKNOWN", "INVALID"
968 };
969
970 guint32 ver_flags, block_header, block_size;
971 gint8 block_type;
972 gboolean isLast = FALSE;
973
974 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
975 return FALSE;
976
977 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
978
979 do {
980 if (!gst_byte_reader_get_uint32_be (data, &block_header))
981 break;
982
983 isLast = (block_header >> 31) & 1;
984 block_type = (block_header >> 24) & 0x7F;
985 block_size = block_header & 0xFFFFFF;
986
987 if (block_type == 127)
988 block_type = 8;
989 else if (block_type > 6)
990 block_type = 7;
991
992 GST_LOG ("%*s block_type: %s", depth, "", block_types[block_type]);
993 GST_LOG ("%*s last-block-flag: %s", depth, "", isLast ? "true" : "false");
994 GST_LOG ("%*s length: %d", depth, "", block_size);
995
996 if (!gst_byte_reader_skip (data, block_size))
997 break;
998 } while (!isLast);
999
1000 return TRUE;
1001 }
1002
1003 gboolean
qtdemux_dump_fLaC(GstQTDemux * qtdemux,GstByteReader * data,int depth)1004 qtdemux_dump_fLaC (GstQTDemux * qtdemux, GstByteReader * data, int depth)
1005 {
1006 guint16 data_ref_id, n_channels, sample_size;
1007 guint32 sample_rate;
1008
1009 if (!gst_byte_reader_skip (data, 6) ||
1010 !gst_byte_reader_get_uint16_be (data, &data_ref_id) ||
1011 !gst_byte_reader_skip (data, 8) ||
1012 !gst_byte_reader_get_uint16_be (data, &n_channels) ||
1013 !gst_byte_reader_get_uint16_be (data, &sample_size) ||
1014 !gst_byte_reader_skip (data, 4) ||
1015 !gst_byte_reader_get_uint32_be (data, &sample_rate))
1016 return FALSE;
1017
1018 GST_LOG ("%*s data reference: %d", depth, "", data_ref_id);
1019 GST_LOG ("%*s channel count: %d", depth, "", n_channels);
1020 GST_LOG ("%*s sample size: %d", depth, "", sample_size);
1021 GST_LOG ("%*s sample rate: %d", depth, "", (sample_rate >> 16));
1022
1023 return TRUE;
1024 }
1025
1026 gboolean
qtdemux_dump_gmin(GstQTDemux * qtdemux,GstByteReader * data,int depth)1027 qtdemux_dump_gmin (GstQTDemux * qtdemux, GstByteReader * data, int depth)
1028 {
1029 guint32 ver_flags;
1030 guint16 graphics_mode, opc_r, opc_g, opc_b, balance;
1031
1032 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
1033 return FALSE;
1034
1035 GST_LOG ("%*s version/flags : %08x", depth, "", ver_flags);
1036 if (!gst_byte_reader_get_uint16_be (data, &graphics_mode) ||
1037 !gst_byte_reader_get_uint16_be (data, &opc_r) ||
1038 !gst_byte_reader_get_uint16_be (data, &opc_g) ||
1039 !gst_byte_reader_get_uint16_be (data, &opc_b) ||
1040 !gst_byte_reader_get_uint16_be (data, &balance))
1041 return FALSE;
1042
1043 GST_LOG ("%*s graphics mode : 0x%x", depth, "", graphics_mode);
1044 GST_LOG ("%*s opcolor : r:0x%x g:0x%x b:0x%x", depth, "", opc_r, opc_g,
1045 opc_b);
1046 GST_LOG ("%*s balance : %d", depth, "", balance);
1047
1048 return TRUE;
1049 }
1050
1051 gboolean
qtdemux_dump_unknown(GstQTDemux * qtdemux,GstByteReader * data,int depth)1052 qtdemux_dump_unknown (GstQTDemux * qtdemux, GstByteReader * data, int depth)
1053 {
1054 int len;
1055
1056 len = gst_byte_reader_get_remaining (data);
1057 GST_LOG ("%*s length: %d", depth, "", len);
1058
1059 GST_MEMDUMP_OBJECT (qtdemux, "unknown atom data",
1060 gst_byte_reader_peek_data_unchecked (data), len);
1061 return TRUE;
1062 }
1063
1064 static gboolean
qtdemux_node_dump_foreach(GNode * node,gpointer qtdemux)1065 qtdemux_node_dump_foreach (GNode * node, gpointer qtdemux)
1066 {
1067 GstByteReader parser;
1068 guint8 *buffer = (guint8 *) node->data; /* FIXME: move to byte reader */
1069 guint32 node_length;
1070 guint32 fourcc;
1071 const QtNodeType *type;
1072 int depth;
1073
1074 node_length = GST_READ_UINT32_BE (buffer);
1075 fourcc = GST_READ_UINT32_LE (buffer + 4);
1076
1077 g_warn_if_fail (node_length >= 8);
1078
1079 gst_byte_reader_init (&parser, buffer + 8, node_length - 8);
1080
1081 type = qtdemux_type_get (fourcc);
1082
1083 depth = (g_node_depth (node) - 1) * 2;
1084 GST_LOG ("%*s'%" GST_FOURCC_FORMAT "', [%d], %s",
1085 depth, "", GST_FOURCC_ARGS (fourcc), node_length, type->name);
1086
1087 if (type->dump) {
1088 gboolean ret;
1089
1090 ret = type->dump (GST_QTDEMUX_CAST (qtdemux), &parser, depth);
1091
1092 if (!ret) {
1093 GST_WARNING ("%*s not enough data parsing atom %" GST_FOURCC_FORMAT,
1094 depth, "", GST_FOURCC_ARGS (fourcc));
1095 }
1096 }
1097
1098 return FALSE;
1099 }
1100
1101 gboolean
qtdemux_node_dump(GstQTDemux * qtdemux,GNode * node)1102 qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node)
1103 {
1104 #ifndef GST_DISABLE_GST_DEBUG
1105 /* Only traverse/dump if we know it will be outputted in the end */
1106 if (qtdemux_debug->threshold < GST_LEVEL_LOG)
1107 return TRUE;
1108
1109 g_node_traverse (node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
1110 qtdemux_node_dump_foreach, qtdemux);
1111 #endif
1112 return TRUE;
1113 }
1114