1 /*
2 * GPAC - Multimedia Framework C SDK
3 *
4 * Authors: Jean Le Feuvre
5 * Copyright (c) Telecom ParisTech 2000-2019
6 * All rights reserved
7 *
8 * This file is part of GPAC / ISO Media File Format sub-project
9 *
10 * GPAC is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * GPAC is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25
26 #include <gpac/internal/isomedia_dev.h>
27
28 #ifndef GPAC_DISABLE_ISOM
29
30 //Add this funct to handle incomplete files...
31 //bytesExpected is 0 most of the time. If the file is incomplete, bytesExpected
32 //is the number of bytes missing to parse the box...
gf_isom_parse_root_box(GF_Box ** outBox,GF_BitStream * bs,u32 * box_type,u64 * bytesExpected,Bool progressive_mode)33 GF_Err gf_isom_parse_root_box(GF_Box **outBox, GF_BitStream *bs, u32 *box_type, u64 *bytesExpected, Bool progressive_mode)
34 {
35 GF_Err ret;
36 u64 start;
37 start = gf_bs_get_position(bs);
38 ret = gf_isom_box_parse_ex(outBox, bs, 0, GF_TRUE);
39 if (ret == GF_ISOM_INCOMPLETE_FILE) {
40 if (!*outBox) {
41 // We could not even read the box size, we at least need 8 bytes
42 *bytesExpected = 8;
43 if (box_type) *box_type = 0;
44 GF_LOG(progressive_mode ? GF_LOG_DEBUG : GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete box - start "LLU"\n", start));
45 }
46 else {
47 u32 type = (*outBox)->type;
48 if (type==GF_ISOM_BOX_TYPE_UNKNOWN)
49 type = ((GF_UnknownBox *) (*outBox))->original_4cc;
50
51 *bytesExpected = (*outBox)->size;
52 if (box_type) *box_type = (*outBox)->type;
53
54 GF_LOG(progressive_mode ? GF_LOG_DEBUG : GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Incomplete box %s - start "LLU" size "LLU"\n", gf_4cc_to_str(type), start, (*outBox)->size));
55 gf_isom_box_del(*outBox);
56 *outBox = NULL;
57 }
58 gf_bs_seek(bs, start);
59 }
60 return ret;
61 }
62
gf_isom_solve_uuid_box(u8 * UUID)63 u32 gf_isom_solve_uuid_box(u8 *UUID)
64 {
65 u32 i;
66 char strUUID[33], strChar[3];
67 strUUID[0] = 0;
68 strUUID[32] = 0;
69 for (i=0; i<16; i++) {
70 snprintf(strChar, 3, "%02X", (unsigned char) UUID[i]);
71 strcat(strUUID, strChar);
72 }
73 if (!strnicmp(strUUID, "8974dbce7be74c5184f97148f9882554", 32))
74 return GF_ISOM_BOX_UUID_TENC;
75 if (!strnicmp(strUUID, "A5D40B30E81411DDBA2F0800200C9A66", 32))
76 return GF_ISOM_BOX_UUID_MSSM;
77 if (!strnicmp(strUUID, "D4807EF2CA3946958E5426CB9E46A79F", 32))
78 return GF_ISOM_BOX_UUID_TFRF;
79 if (!strnicmp(strUUID, "6D1D9B0542D544E680E2141DAFF757B2", 32))
80 return GF_ISOM_BOX_UUID_TFXD;
81 if (!strnicmp(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32))
82 return GF_ISOM_BOX_UUID_PSEC;
83 if (!strnicmp(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32))
84 return GF_ISOM_BOX_UUID_PSSH;
85
86 return 0;
87 }
88
89 static GF_Err gf_isom_full_box_read(GF_Box *ptr, GF_BitStream *bs);
90
gf_isom_box_parse_ex(GF_Box ** outBox,GF_BitStream * bs,u32 parent_type,Bool is_root_box)91 GF_Err gf_isom_box_parse_ex(GF_Box **outBox, GF_BitStream *bs, u32 parent_type, Bool is_root_box)
92 {
93 u32 type, uuid_type, hdr_size, restore_type;
94 u64 size, start, comp_start, payload_start, end;
95 char uuid[16];
96 GF_Err e;
97 GF_BitStream *uncomp_bs = NULL;
98 u8 *uncomp_data = NULL;
99 u32 compressed_size=0;
100 GF_Box *newBox;
101 Bool skip_logs = (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_NO_LOGS ) ? GF_TRUE : GF_FALSE;
102 Bool is_special = GF_TRUE;
103
104 if ((bs == NULL) || (outBox == NULL) ) return GF_BAD_PARAM;
105 *outBox = NULL;
106 if (gf_bs_available(bs) < 8) {
107 return GF_ISOM_INCOMPLETE_FILE;
108 }
109
110 comp_start = start = gf_bs_get_position(bs);
111
112 uuid_type = 0;
113 size = (u64) gf_bs_read_u32(bs);
114 hdr_size = 4;
115 /*fix for some boxes found in some old hinted files*/
116 if ((size >= 2) && (size <= 4)) {
117 size = 4;
118 type = GF_ISOM_BOX_TYPE_VOID;
119 } else {
120 type = gf_bs_read_u32(bs);
121 hdr_size += 4;
122 /*no size means till end of file - EXCEPT FOR some old QuickTime boxes...*/
123 if (type == GF_ISOM_BOX_TYPE_TOTL)
124 size = 12;
125 if (!size) {
126 if (is_root_box) {
127 if (!skip_logs) {
128 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Warning Read Box type %s (0x%08X) size 0 reading till the end of file\n", gf_4cc_to_str(type), type));
129 }
130 size = gf_bs_available(bs) + 8;
131 } else {
132 if (!skip_logs) {
133 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box type %s (0x%08X) at position "LLU" has size 0 but is not at root/file level, skipping\n", gf_4cc_to_str(type), type, start));
134 }
135 return GF_OK;
136 }
137 }
138 if (is_root_box && (size>=8)) {
139 Bool do_uncompress = GF_FALSE;
140 u8 *compb = NULL;
141 u32 osize = 0;
142 if (type==GF_4CC('!', 'm', 'o', 'f')) {
143 do_uncompress = GF_TRUE;
144 type = GF_ISOM_BOX_TYPE_MOOF;
145 }
146 else if (type==GF_4CC('!', 'm', 'o', 'v')) {
147 do_uncompress = GF_TRUE;
148 type = GF_ISOM_BOX_TYPE_MOOV;
149 }
150 else if (type==GF_4CC('!', 's', 'i', 'x')) {
151 do_uncompress = GF_TRUE;
152 type = GF_ISOM_BOX_TYPE_SIDX;
153 }
154 else if (type==GF_4CC('!', 's', 's', 'x')) {
155 do_uncompress = GF_TRUE;
156 type = GF_ISOM_BOX_TYPE_SSIX;
157 }
158
159 if (do_uncompress) {
160 compb = gf_malloc((u32) (size-8));
161
162 compressed_size = (u32) (size - 8);
163 gf_bs_read_data(bs, compb, compressed_size);
164 gf_gz_decompress_payload(compb, compressed_size, &uncomp_data, &osize);
165
166 //keep size as complete box size for tests below
167 size = osize + 8;
168 uncomp_bs = gf_bs_new(uncomp_data, osize, GF_BITSTREAM_READ);
169 bs = uncomp_bs;
170 start = 0;
171 gf_free(compb);
172 }
173 }
174 }
175 /*handle uuid*/
176 memset(uuid, 0, 16);
177 if (type == GF_ISOM_BOX_TYPE_UUID ) {
178 if (gf_bs_available(bs) < 16) {
179 return GF_ISOM_INCOMPLETE_FILE;
180 }
181 gf_bs_read_data(bs, uuid, 16);
182 hdr_size += 16;
183 uuid_type = gf_isom_solve_uuid_box(uuid);
184 }
185
186 //handle large box
187 if (size == 1) {
188 if (gf_bs_available(bs) < 8) {
189 return GF_ISOM_INCOMPLETE_FILE;
190 }
191 size = gf_bs_read_u64(bs);
192 hdr_size += 8;
193 }
194 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Read Box type %s size "LLD" start "LLD"\n", gf_4cc_to_str(type), size, start));
195
196 if ( size < hdr_size ) {
197 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box size "LLD" less than box header size %d\n", size, hdr_size));
198 return GF_ISOM_INVALID_FILE;
199 }
200 restore_type = 0;
201 if ((parent_type==GF_ISOM_BOX_TYPE_STSD) && (type==GF_QT_SUBTYPE_RAW) ) {
202 u64 cookie = gf_bs_get_cookie(bs);
203 restore_type = type;
204 if (cookie & GF_ISOM_BS_COOKIE_VISUAL_TRACK)
205 type = GF_QT_SUBTYPE_RAW_VID;
206 else
207 type = GF_QT_SUBTYPE_RAW_AUD;
208
209 }
210
211 //some special boxes (references and track groups) are handled by a single generic box with an associated ref/group type
212 if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TREF)) {
213 newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFT);
214 if (!newBox) return GF_OUT_OF_MEM;
215 ((GF_TrackReferenceTypeBox*)newBox)->reference_type = type;
216 } else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_IREF)) {
217 newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFI);
218 if (!newBox) return GF_OUT_OF_MEM;
219 ((GF_ItemReferenceTypeBox*)newBox)->reference_type = type;
220 } else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TRGR)) {
221 newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_TRGT);
222 if (!newBox) return GF_OUT_OF_MEM;
223 ((GF_TrackGroupTypeBox*)newBox)->group_type = type;
224 } else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_GRPL)) {
225 newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_GRPT);
226 if (!newBox) return GF_OUT_OF_MEM;
227 ((GF_EntityToGroupTypeBox*)newBox)->grouping_type = type;
228 } else {
229 //OK, create the box based on the type
230 is_special = GF_FALSE;
231 newBox = gf_isom_box_new_ex(uuid_type ? uuid_type : type, parent_type, skip_logs, is_root_box);
232 if (!newBox) return GF_OUT_OF_MEM;
233 }
234
235 //OK, init and read this box
236 if (type==GF_ISOM_BOX_TYPE_UUID && !is_special) {
237 memcpy(((GF_UUIDBox *)newBox)->uuid, uuid, 16);
238 ((GF_UUIDBox *)newBox)->internal_4cc = uuid_type;
239 }
240
241 if (!newBox->type) newBox->type = type;
242 if (restore_type)
243 newBox->type = restore_type;
244
245 payload_start = gf_bs_get_position(bs);
246
247 retry_unknown_box:
248
249 end = gf_bs_available(bs);
250 if (size - hdr_size > end ) {
251 newBox->size = size - hdr_size - end;
252 *outBox = newBox;
253 return GF_ISOM_INCOMPLETE_FILE;
254 }
255
256 newBox->size = size - hdr_size;
257
258 e = gf_isom_full_box_read(newBox, bs);
259 if (!e) e = gf_isom_box_read(newBox, bs);
260 newBox->size = size;
261 end = gf_bs_get_position(bs);
262
263 if (uncomp_bs) {
264 gf_free(uncomp_data);
265 gf_bs_del(uncomp_bs);
266 if (e) {
267 gf_isom_box_del(newBox);
268 *outBox = NULL;
269 return e;
270 }
271 //move size to real bitstream offsets for tests below
272 size -= 8;
273 //remember compressed vs real size info for moof in order to properly recompute data_offset/base_data_offset
274 if (type==GF_ISOM_BOX_TYPE_MOOF) {
275 ((GF_MovieFragmentBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
276 }
277 //remember compressed vs real size info for moov in order to properly recompute chunk offset
278 else if (type==GF_ISOM_BOX_TYPE_MOOV) {
279 ((GF_MovieBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
280 ((GF_MovieBox *)newBox)->file_offset = comp_start;
281 }
282 //remember compressed vs real size info for dump
283 else if (type==GF_ISOM_BOX_TYPE_SIDX) {
284 ((GF_SegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
285 }
286 //remember compressed vs real size info for dump
287 else if (type==GF_ISOM_BOX_TYPE_SSIX) {
288 ((GF_SubsegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
289 }
290 }
291
292
293 if (e && (e != GF_ISOM_INCOMPLETE_FILE)) {
294 gf_isom_box_del(newBox);
295 *outBox = NULL;
296
297 if (parent_type==GF_ISOM_BOX_TYPE_STSD) {
298 newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_UNKNOWN);
299 if (!newBox) return GF_OUT_OF_MEM;
300 ((GF_UnknownBox *)newBox)->original_4cc = type;
301 newBox->size = size;
302 gf_bs_seek(bs, payload_start);
303 goto retry_unknown_box;
304 }
305 if (!skip_logs) {
306 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box \"%s\" (start "LLU") failed (%s) - skipping\n", gf_4cc_to_str(type), start, gf_error_to_string(e)));
307 }
308 //we don't try to reparse known boxes that have been failing (too dangerous)
309 return e;
310 }
311
312 if (end-start > size) {
313 if (!skip_logs) {
314 GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" size "LLU" (start "LLU") invalid (read "LLU")\n", gf_4cc_to_str(type), size, start, (end-start) ));
315 }
316 /*let's still try to load the file since no error was notified*/
317 gf_bs_seek(bs, start+size);
318 } else if (end-start < size) {
319 u32 to_skip = (u32) (size-(end-start));
320 if (!skip_logs) {
321 if ((to_skip!=4) || gf_bs_peek_bits(bs, 32, 0)) {
322 GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" (start "LLU") has %u extra bytes\n", gf_4cc_to_str(type), start, to_skip));
323 }
324 }
325 gf_bs_skip_bytes(bs, to_skip);
326 }
327 *outBox = newBox;
328
329 return e;
330 }
331
332 GF_EXPORT
gf_isom_box_parse(GF_Box ** outBox,GF_BitStream * bs)333 GF_Err gf_isom_box_parse(GF_Box **outBox, GF_BitStream *bs)
334 {
335 return gf_isom_box_parse_ex(outBox, bs, 0, GF_FALSE);
336 }
337
gf_isom_box_array_del(GF_List * boxlist)338 void gf_isom_box_array_del(GF_List *boxlist)
339 {
340 u32 count, i;
341 if (!boxlist) return;
342 count = gf_list_count(boxlist);
343 for (i = 0; i < count; i++) {
344 GF_Box *a = (GF_Box *)gf_list_get(boxlist, i);
345 if (a) gf_isom_box_del(a);
346 }
347 gf_list_del(boxlist);
348 }
349
gf_isom_box_array_reset_parent(GF_List ** child_boxes,GF_List * boxlist)350 void gf_isom_box_array_reset_parent(GF_List **child_boxes, GF_List *boxlist)
351 {
352 u32 count, i;
353 if (!boxlist) return;
354 count = gf_list_count(boxlist);
355 for (i = 0; i < count; i++) {
356 GF_Box *a = (GF_Box *)gf_list_get(boxlist, i);
357 if (a) gf_isom_box_del_parent(child_boxes, a);
358 }
359 gf_list_reset(boxlist);
360 }
gf_isom_box_array_del_parent(GF_List ** child_boxes,GF_List * boxlist)361 void gf_isom_box_array_del_parent(GF_List **child_boxes, GF_List *boxlist)
362 {
363 if (!boxlist) return;
364 gf_isom_box_array_reset_parent(child_boxes, boxlist);
365 gf_list_del(boxlist);
366 }
367
368
gf_isom_box_array_read(GF_Box * parent,GF_BitStream * bs,GF_Err (* check_child_box)(GF_Box * par,GF_Box * b))369 GF_Err gf_isom_box_array_read(GF_Box *parent, GF_BitStream *bs, GF_Err (*check_child_box)(GF_Box *par, GF_Box *b))
370 {
371 return gf_isom_box_array_read_ex(parent, bs, check_child_box, parent->type);
372 }
373
374 #ifndef GPAC_DISABLE_ISOM_WRITE
375
376 GF_EXPORT
gf_isom_box_write_header(GF_Box * ptr,GF_BitStream * bs)377 GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs)
378 {
379 u64 start;
380 if (! bs || !ptr) return GF_BAD_PARAM;
381 if (!ptr->size) return GF_ISOM_INVALID_FILE;
382
383 start = gf_bs_get_position(bs);
384 if (ptr->size > 0xFFFFFFFF) {
385 gf_bs_write_u32(bs, 1);
386 } else {
387 gf_bs_write_u32(bs, (u32) ptr->size);
388 }
389 gf_bs_write_u32(bs, ptr->type);
390 if (ptr->type == GF_ISOM_BOX_TYPE_UUID) {
391 u32 i;
392 Bool conv_uuid = GF_TRUE;
393 GF_UUIDBox *uuidb = (GF_UUIDBox *)ptr;
394 char strUUID[32];
395
396 switch (uuidb->internal_4cc) {
397 case GF_ISOM_BOX_UUID_TENC:
398 memcpy(strUUID, "8974dbce7be74c5184f97148f9882554", 32);
399 break;
400 case GF_ISOM_BOX_UUID_PSEC:
401 memcpy(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32);
402 break;
403 case GF_ISOM_BOX_UUID_MSSM:
404 memcpy(strUUID, "A5D40B30E81411DDBA2F0800200C9A66", 32);
405 break;
406 case GF_ISOM_BOX_UUID_PSSH:
407 memcpy(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32);
408 break;
409 case GF_ISOM_BOX_UUID_TFXD:
410 memcpy(strUUID, "6D1D9B0542D544E680E2141DAFF757B2", 32);
411 break;
412 default:
413 conv_uuid = GF_FALSE;
414 break;
415 }
416
417 if (conv_uuid) {
418 char uuid[16];
419 for (i = 0; i < 16; i++) {
420 char t[3];
421 t[2] = 0;
422 t[0] = strUUID[2*i];
423 t[1] = strUUID[2*i+1];
424 uuid[i] = (u8) strtol(t, NULL, 16);
425 }
426 gf_bs_write_data(bs, uuid, 16);
427 } else {
428 gf_bs_write_data(bs, uuidb->uuid, 16);
429 }
430 }
431 if (ptr->size > 0xFFFFFFFF)
432 gf_bs_write_u64(bs, ptr->size);
433
434 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Written Box type %s size "LLD" start "LLD"\n", gf_4cc_to_str(ptr->type), ptr->size, start));
435
436 return GF_OK;
437 }
438
gf_isom_full_box_write(GF_Box * s,GF_BitStream * bs)439 GF_Err gf_isom_full_box_write(GF_Box *s, GF_BitStream *bs)
440 {
441 GF_Err e;
442 GF_FullBox *ptr = (GF_FullBox *)s;
443 e = gf_isom_box_write_header(s, bs);
444 if (e) return e;
445 gf_bs_write_u8(bs, ptr->version);
446 gf_bs_write_u24(bs, ptr->flags);
447 return GF_OK;
448 }
449
450
gf_isom_box_array_write(GF_Box * parent,GF_List * list,GF_BitStream * bs)451 GF_Err gf_isom_box_array_write(GF_Box *parent, GF_List *list, GF_BitStream *bs)
452 {
453 u32 count, i;
454 GF_Err e;
455 if (!list) return GF_OK;
456 count = gf_list_count(list);
457 for (i = 0; i < count; i++) {
458 GF_Box *a = (GF_Box *)gf_list_get(list, i);
459 if (a) {
460 e = gf_isom_box_write(a, bs);
461 if (e) {
462 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("ISOBMF: Error %s writing box %s\n", gf_error_to_string(e), gf_4cc_to_str(a->type) ));
463 return e;
464 }
465 }
466 }
467 return GF_OK;
468 }
469
470
gf_isom_box_array_size(GF_Box * parent,GF_List * list)471 GF_Err gf_isom_box_array_size(GF_Box *parent, GF_List *list)
472 {
473 GF_Err e;
474 u32 count, i;
475 if (! list) return GF_OK;
476
477 count = gf_list_count(list);
478 for (i = 0; i < count; i++) {
479 GF_Box *a = (GF_Box *)gf_list_get(list, i);
480 if (a) {
481 e = gf_isom_box_size(a);
482 if (e) {
483 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("ISOBMF: Error %s computing box %s size\n", gf_error_to_string(e), gf_4cc_to_str(a->type) ));
484 return e;
485 }
486 parent->size += a->size;
487 }
488 }
489 return GF_OK;
490 }
491
492 #endif /*GPAC_DISABLE_ISOM_WRITE*/
493
494
495
496 GF_Box * unkn_box_new();
497 void unkn_box_del(GF_Box *);
498 GF_Err unkn_box_read(GF_Box *s, GF_BitStream *bs);
499 GF_Err unkn_box_write(GF_Box *s, GF_BitStream *bs);
500 GF_Err unkn_box_size(GF_Box *s);
501 GF_Err unkn_box_dump(GF_Box *a, FILE * trace);
502
503 //definition of boxes new/del/read/write/size. For now still exported since some files other than box_funcs.c call them
504 //this should be fixed by only using gf_isom_box_new
505
506 #define ISOM_BOX_IMPL_DECL(a_name) \
507 GF_Box * a_name##_box_new(); \
508 void a_name##_box_del(GF_Box *); \
509 GF_Err a_name##_box_read(GF_Box *s, GF_BitStream *bs); \
510 GF_Err a_name##_box_write(GF_Box *s, GF_BitStream *bs); \
511 GF_Err a_name##_box_size(GF_Box *s);\
512 GF_Err a_name##_box_dump(GF_Box *a, FILE * trace);
513
514 ISOM_BOX_IMPL_DECL(reftype)
515 ISOM_BOX_IMPL_DECL(ireftype)
516 ISOM_BOX_IMPL_DECL(free)
517 ISOM_BOX_IMPL_DECL(wide)
518 ISOM_BOX_IMPL_DECL(mdat)
519 ISOM_BOX_IMPL_DECL(moov)
520 ISOM_BOX_IMPL_DECL(mvhd)
521 ISOM_BOX_IMPL_DECL(mdhd)
522 ISOM_BOX_IMPL_DECL(vmhd)
523 ISOM_BOX_IMPL_DECL(smhd)
524 ISOM_BOX_IMPL_DECL(hmhd)
525 ISOM_BOX_IMPL_DECL(nmhd)
526 ISOM_BOX_IMPL_DECL(stbl)
527 ISOM_BOX_IMPL_DECL(dinf)
528 ISOM_BOX_IMPL_DECL(url)
529 ISOM_BOX_IMPL_DECL(urn)
530 ISOM_BOX_IMPL_DECL(cprt)
531 ISOM_BOX_IMPL_DECL(kind)
532 ISOM_BOX_IMPL_DECL(chpl)
533 ISOM_BOX_IMPL_DECL(hdlr)
534 ISOM_BOX_IMPL_DECL(iods)
535 ISOM_BOX_IMPL_DECL(trak)
536 ISOM_BOX_IMPL_DECL(mp4s)
537 ISOM_BOX_IMPL_DECL(audio_sample_entry)
538 ISOM_BOX_IMPL_DECL(gen_sample_entry)
539 ISOM_BOX_IMPL_DECL(edts)
540 ISOM_BOX_IMPL_DECL(udta)
541 ISOM_BOX_IMPL_DECL(dref)
542 ISOM_BOX_IMPL_DECL(stsd)
543 ISOM_BOX_IMPL_DECL(stts)
544 ISOM_BOX_IMPL_DECL(ctts)
545 ISOM_BOX_IMPL_DECL(stsh)
546 ISOM_BOX_IMPL_DECL(elst)
547 ISOM_BOX_IMPL_DECL(stsc)
548 ISOM_BOX_IMPL_DECL(stsz)
549 ISOM_BOX_IMPL_DECL(stco)
550 ISOM_BOX_IMPL_DECL(stss)
551 ISOM_BOX_IMPL_DECL(stdp)
552 ISOM_BOX_IMPL_DECL(sdtp)
553 ISOM_BOX_IMPL_DECL(co64)
554 ISOM_BOX_IMPL_DECL(esds)
555 ISOM_BOX_IMPL_DECL(minf)
556 ISOM_BOX_IMPL_DECL(tkhd)
557 ISOM_BOX_IMPL_DECL(tref)
558 ISOM_BOX_IMPL_DECL(mdia)
559 ISOM_BOX_IMPL_DECL(mfra)
560 ISOM_BOX_IMPL_DECL(tfra)
561 ISOM_BOX_IMPL_DECL(mfro)
562 ISOM_BOX_IMPL_DECL(uuid)
563 ISOM_BOX_IMPL_DECL(void)
564 ISOM_BOX_IMPL_DECL(gnrm)
565 ISOM_BOX_IMPL_DECL(gnrv)
566 ISOM_BOX_IMPL_DECL(gnra)
567 ISOM_BOX_IMPL_DECL(pdin)
568 ISOM_BOX_IMPL_DECL(def_parent)
569 ISOM_BOX_IMPL_DECL(def_parent_full)
570
571
572 #ifndef GPAC_DISABLE_ISOM_HINTING
573
574 ISOM_BOX_IMPL_DECL(hinf)
575 ISOM_BOX_IMPL_DECL(trpy)
576 ISOM_BOX_IMPL_DECL(totl)
577 ISOM_BOX_IMPL_DECL(nump)
578 ISOM_BOX_IMPL_DECL(npck)
579 ISOM_BOX_IMPL_DECL(tpyl)
580 ISOM_BOX_IMPL_DECL(tpay)
581 ISOM_BOX_IMPL_DECL(maxr)
582 ISOM_BOX_IMPL_DECL(dmed)
583 ISOM_BOX_IMPL_DECL(dimm)
584 ISOM_BOX_IMPL_DECL(drep)
585 ISOM_BOX_IMPL_DECL(tmin)
586 ISOM_BOX_IMPL_DECL(tmax)
587 ISOM_BOX_IMPL_DECL(pmax)
588 ISOM_BOX_IMPL_DECL(dmax)
589 ISOM_BOX_IMPL_DECL(payt)
590 ISOM_BOX_IMPL_DECL(name)
591 ISOM_BOX_IMPL_DECL(rely)
592 ISOM_BOX_IMPL_DECL(snro)
593 ISOM_BOX_IMPL_DECL(tims)
594 ISOM_BOX_IMPL_DECL(tsro)
595 ISOM_BOX_IMPL_DECL(ghnt)
596 ISOM_BOX_IMPL_DECL(hnti)
597 ISOM_BOX_IMPL_DECL(sdp)
598 ISOM_BOX_IMPL_DECL(rtpo)
599 ISOM_BOX_IMPL_DECL(tssy)
600 ISOM_BOX_IMPL_DECL(rssr)
601 ISOM_BOX_IMPL_DECL(srpp)
602 ISOM_BOX_IMPL_DECL(rtp_hnti)
603
604 #endif
605
606 ISOM_BOX_IMPL_DECL(ftyp)
607 ISOM_BOX_IMPL_DECL(padb)
608 ISOM_BOX_IMPL_DECL(gppc)
609
610
611 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS
612 ISOM_BOX_IMPL_DECL(mvex)
613 ISOM_BOX_IMPL_DECL(trex)
614 ISOM_BOX_IMPL_DECL(moof)
615 ISOM_BOX_IMPL_DECL(mfhd)
616 ISOM_BOX_IMPL_DECL(traf)
617 ISOM_BOX_IMPL_DECL(tfhd)
618 ISOM_BOX_IMPL_DECL(trun)
619 ISOM_BOX_IMPL_DECL(styp)
620 ISOM_BOX_IMPL_DECL(mehd)
621 /*smooth streaming timing*/
622 ISOM_BOX_IMPL_DECL(tfxd)
623
624 #endif
625
626 /*avc ext*/
627 ISOM_BOX_IMPL_DECL(avcc)
628 ISOM_BOX_IMPL_DECL(video_sample_entry)
629 ISOM_BOX_IMPL_DECL(m4ds)
630 ISOM_BOX_IMPL_DECL(btrt)
631 ISOM_BOX_IMPL_DECL(mehd)
632
633 /*3GPP streaming text*/
634 ISOM_BOX_IMPL_DECL(ftab)
635 ISOM_BOX_IMPL_DECL(tx3g)
636 ISOM_BOX_IMPL_DECL(text)
637 ISOM_BOX_IMPL_DECL(styl)
638 ISOM_BOX_IMPL_DECL(hlit)
639 ISOM_BOX_IMPL_DECL(hclr)
640 ISOM_BOX_IMPL_DECL(krok)
641 ISOM_BOX_IMPL_DECL(dlay)
642 ISOM_BOX_IMPL_DECL(href)
643 ISOM_BOX_IMPL_DECL(tbox)
644 ISOM_BOX_IMPL_DECL(blnk)
645 ISOM_BOX_IMPL_DECL(twrp)
646
647
648 #ifndef GPAC_DISABLE_VTT
649
650 /*WebVTT boxes*/
651 ISOM_BOX_IMPL_DECL(boxstring);
652 ISOM_BOX_IMPL_DECL(vtcu)
653 ISOM_BOX_IMPL_DECL(vtte)
654 ISOM_BOX_IMPL_DECL(wvtt)
655
656 #endif //GPAC_DISABLE_VTT
657
658 /* Items functions */
659 ISOM_BOX_IMPL_DECL(meta)
660 ISOM_BOX_IMPL_DECL(xml)
661 ISOM_BOX_IMPL_DECL(bxml)
662 ISOM_BOX_IMPL_DECL(iloc)
663 ISOM_BOX_IMPL_DECL(pitm)
664 ISOM_BOX_IMPL_DECL(ipro)
665 ISOM_BOX_IMPL_DECL(infe)
666 ISOM_BOX_IMPL_DECL(iinf)
667 ISOM_BOX_IMPL_DECL(iref)
668 ISOM_BOX_IMPL_DECL(sinf)
669 ISOM_BOX_IMPL_DECL(frma)
670 ISOM_BOX_IMPL_DECL(schm)
671 ISOM_BOX_IMPL_DECL(schi)
672 ISOM_BOX_IMPL_DECL(enca)
673 ISOM_BOX_IMPL_DECL(encs)
674 ISOM_BOX_IMPL_DECL(encv)
675 ISOM_BOX_IMPL_DECL(resv)
676
677
678 /** ISMACryp functions **/
679 ISOM_BOX_IMPL_DECL(iKMS)
680 ISOM_BOX_IMPL_DECL(iSFM)
681 ISOM_BOX_IMPL_DECL(iSLT)
682
683 #ifndef GPAC_DISABLE_ISOM_ADOBE
684 /* Adobe extensions */
685 ISOM_BOX_IMPL_DECL(abst)
686 ISOM_BOX_IMPL_DECL(afra)
687 ISOM_BOX_IMPL_DECL(asrt)
688 ISOM_BOX_IMPL_DECL(afrt)
689 #endif /*GPAC_DISABLE_ISOM_ADOBE*/
690
691 /* Apple extensions */
692 ISOM_BOX_IMPL_DECL(ilst)
693 ISOM_BOX_IMPL_DECL(ilst_item)
694 ISOM_BOX_IMPL_DECL(databox)
695 ISOM_BOX_IMPL_DECL(gmin)
696 ISOM_BOX_IMPL_DECL(alis)
697 ISOM_BOX_IMPL_DECL(clef)
698
699 /*OMA extensions*/
700 ISOM_BOX_IMPL_DECL(ohdr)
701 ISOM_BOX_IMPL_DECL(grpi)
702 ISOM_BOX_IMPL_DECL(mdri)
703 ISOM_BOX_IMPL_DECL(odtt)
704 ISOM_BOX_IMPL_DECL(odrb)
705 ISOM_BOX_IMPL_DECL(odkm)
706
707
708 ISOM_BOX_IMPL_DECL(pasp)
709 ISOM_BOX_IMPL_DECL(clap)
710 ISOM_BOX_IMPL_DECL(metx)
711 ISOM_BOX_IMPL_DECL(txtc)
712 ISOM_BOX_IMPL_DECL(tsel)
713 ISOM_BOX_IMPL_DECL(dimC)
714 ISOM_BOX_IMPL_DECL(dims)
715 ISOM_BOX_IMPL_DECL(diST)
716 ISOM_BOX_IMPL_DECL(ac3)
717 ISOM_BOX_IMPL_DECL(ec3)
718 ISOM_BOX_IMPL_DECL(dac3)
719 ISOM_BOX_IMPL_DECL(dec3)
720 ISOM_BOX_IMPL_DECL(lsrc)
721 ISOM_BOX_IMPL_DECL(lsr1)
722 ISOM_BOX_IMPL_DECL(mvcg)
723 ISOM_BOX_IMPL_DECL(vwid)
724
725 ISOM_BOX_IMPL_DECL(subs)
726
727 ISOM_BOX_IMPL_DECL(tmcd)
728 ISOM_BOX_IMPL_DECL(tcmi)
729 ISOM_BOX_IMPL_DECL(fiel)
730 ISOM_BOX_IMPL_DECL(gama)
731 ISOM_BOX_IMPL_DECL(chrm)
732 ISOM_BOX_IMPL_DECL(chan)
733
734
735 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS
736 ISOM_BOX_IMPL_DECL(sidx)
737 ISOM_BOX_IMPL_DECL(ssix)
738 ISOM_BOX_IMPL_DECL(leva)
739 ISOM_BOX_IMPL_DECL(pcrb)
740 ISOM_BOX_IMPL_DECL(tfdt)
741 ISOM_BOX_IMPL_DECL(emsg)
742
743 #endif
744
745 ISOM_BOX_IMPL_DECL(rvcc)
746 ISOM_BOX_IMPL_DECL(sbgp)
747 ISOM_BOX_IMPL_DECL(sgpd)
748 ISOM_BOX_IMPL_DECL(saiz)
749 ISOM_BOX_IMPL_DECL(saio)
750
751 ISOM_BOX_IMPL_DECL(pssh)
752
753 ISOM_BOX_IMPL_DECL(tenc)
754 ISOM_BOX_IMPL_DECL(piff_tenc)
755 ISOM_BOX_IMPL_DECL(piff_psec)
756 ISOM_BOX_IMPL_DECL(piff_pssh)
757 ISOM_BOX_IMPL_DECL(senc)
758 ISOM_BOX_IMPL_DECL(cslg)
759 ISOM_BOX_IMPL_DECL(ccst)
760 ISOM_BOX_IMPL_DECL(auxi)
761 ISOM_BOX_IMPL_DECL(hvcc)
762 ISOM_BOX_IMPL_DECL(av1c)
763 ISOM_BOX_IMPL_DECL(dOps)
764 ISOM_BOX_IMPL_DECL(prft)
765
766 //VPx
767 ISOM_BOX_IMPL_DECL(vpcc)
768 ISOM_BOX_IMPL_DECL(SmDm)
769 ISOM_BOX_IMPL_DECL(CoLL)
770
771 ISOM_BOX_IMPL_DECL(trep)
772
773 //FEC
774 ISOM_BOX_IMPL_DECL(fiin)
775 ISOM_BOX_IMPL_DECL(paen)
776 ISOM_BOX_IMPL_DECL(fpar)
777 ISOM_BOX_IMPL_DECL(fecr)
778 ISOM_BOX_IMPL_DECL(segr)
779 ISOM_BOX_IMPL_DECL(gitn)
780 ISOM_BOX_IMPL_DECL(fdsa)
781 ISOM_BOX_IMPL_DECL(fdpa)
782 ISOM_BOX_IMPL_DECL(extr)
783
784
785 /*
786 Adobe's protection boxes
787 */
788 ISOM_BOX_IMPL_DECL(adkm)
789 ISOM_BOX_IMPL_DECL(ahdr)
790 ISOM_BOX_IMPL_DECL(aprm)
791 ISOM_BOX_IMPL_DECL(aeib)
792 ISOM_BOX_IMPL_DECL(akey)
793 ISOM_BOX_IMPL_DECL(flxs)
794 ISOM_BOX_IMPL_DECL(adaf)
795
796 /* Image File Format declarations */
797 ISOM_BOX_IMPL_DECL(ispe)
798 ISOM_BOX_IMPL_DECL(colr)
799 ISOM_BOX_IMPL_DECL(pixi)
800 ISOM_BOX_IMPL_DECL(rloc)
801 ISOM_BOX_IMPL_DECL(irot)
802 ISOM_BOX_IMPL_DECL(ipco)
803 ISOM_BOX_IMPL_DECL(iprp)
804 ISOM_BOX_IMPL_DECL(ipma)
805 ISOM_BOX_IMPL_DECL(trgr)
806 ISOM_BOX_IMPL_DECL(trgt)
807
808 /* MIAF declarations */
809 ISOM_BOX_IMPL_DECL(clli)
810 ISOM_BOX_IMPL_DECL(mdcv)
811
812 ISOM_BOX_IMPL_DECL(grpl)
813
814 ISOM_BOX_IMPL_DECL(strk)
815 ISOM_BOX_IMPL_DECL(stri)
816 ISOM_BOX_IMPL_DECL(stsg)
817 ISOM_BOX_IMPL_DECL(elng)
818 ISOM_BOX_IMPL_DECL(stvi)
819 ISOM_BOX_IMPL_DECL(auxc)
820 ISOM_BOX_IMPL_DECL(oinf)
821 ISOM_BOX_IMPL_DECL(tols)
822
823 ISOM_BOX_IMPL_DECL(trik)
824 ISOM_BOX_IMPL_DECL(bloc)
825 ISOM_BOX_IMPL_DECL(ainf)
826 ISOM_BOX_IMPL_DECL(mhac)
827
828 ISOM_BOX_IMPL_DECL(grptype)
829
830 ISOM_BOX_IMPL_DECL(jp2h)
831 ISOM_BOX_IMPL_DECL(ihdr)
832 ISOM_BOX_IMPL_DECL(load)
833
834 /* Dolby Vision */
835 ISOM_BOX_IMPL_DECL(dvcC)
836 ISOM_BOX_IMPL_DECL(dvhe)
837 ISOM_BOX_IMPL_DECL(dfla)
838
839 ISOM_BOX_IMPL_DECL(pcmC)
840 ISOM_BOX_IMPL_DECL(chnl)
841
842
843
844 #define BOX_DEFINE(__type, b_rad, __par) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 0, 0, __par, "p12", GF_FALSE}
845
846 #define BOX_DEFINE_S(__type, b_rad, __par, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 0, 0, __par, __spec, GF_FALSE }
847
848 #define FBOX_DEFINE(__type, b_rad, __par, __max_v) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 1+__max_v, 0, __par, "p12", GF_FALSE }
849
850 #define FBOX_DEFINE_FLAGS(__type, b_rad, __par, __max_v, flags) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 1+__max_v, flags, __par, "p12", GF_FALSE }
851
852 #define FBOX_DEFINE_FLAGS_S(__type, b_rad, __par, __max_v, flags, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 1+__max_v, flags, __par, __spec, GF_FALSE }
853
854 #define FBOX_DEFINE_S(__type, b_rad, __par, __max_v, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, 0, 1+__max_v, 0, __par, __spec, GF_FALSE }
855
856 #define TREF_DEFINE(__type, b_rad, __par, __4cc, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, __4cc, 0, 0, __par, __spec, GF_FALSE }
857
858 #define TRGT_DEFINE(__type, b_rad, __par, __4cc, max_version, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, __4cc, 1+max_version, 0, __par, __spec, GF_FALSE }
859
860 #define SGPD_DEFINE(__type, b_rad, __par, __4cc, __spec) { __type, b_rad##_box_new, b_rad##_box_del, b_rad##_box_read, b_rad##_box_write, b_rad##_box_size, b_rad##_box_dump, __4cc, 1, 0, __par, __spec, GF_FALSE }
861
862 static struct box_registry_entry {
863 u32 box_4cc;
864 GF_Box * (*new_fn)();
865 void (*del_fn)(GF_Box *a);
866 GF_Err (*read_fn)(GF_Box *s, GF_BitStream *bs);
867 GF_Err (*write_fn)(GF_Box *s, GF_BitStream *bs);
868 GF_Err (*size_fn)(GF_Box *a);
869 GF_Err (*dump_fn)(GF_Box *a, FILE *trace);
870 u32 alt_4cc;//used for sample grouping type and track / item reference types
871 u8 max_version_plus_one;
872 u32 flags;
873 const char *parents_4cc;
874 const char *spec;
875 Bool disabled;
876 } box_registry [] =
877 {
878 //DO NOT MOVE THE FIRST ENTRY
879 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_UNKNOWN, unkn, "unknown", "unknown"),
880 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_UUID, uuid, "unknown", "unknown"),
881
882 //all track reference types
883 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_META, "p12"),
884 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_HINT, "p12"),
885 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_FONT, "p12"),
886 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_HIND, "p12"),
887 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_VDEP, "p12"),
888 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_VPLX, "p12"),
889 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SUBT, "p12"),
890 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_THUMB, "p12"),
891
892 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_OD, "p14"),
893 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_DECODE, "p14"),
894 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_OCR, "p14"),
895 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_IPI, "p14"),
896
897 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_BASE, "p15"),
898 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SCAL, "p15"),
899 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_TBAS, "p15"),
900 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SABT, "p15"),
901 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_OREF, "p15"),
902
903 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_ADDA, "p12"),
904 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_ADRC, "p12"),
905 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_ILOC, "p12"),
906 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_AVCP, "p15"),
907 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SWTO, "p15"),
908 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SWFR, "p15"),
909
910 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_CHAP, "apple"),
911 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_TMCD, "apple"),
912 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_CDEP, "apple"),
913 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SCPT, "apple"),
914 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_SSRC, "apple"),
915 TREF_DEFINE(GF_ISOM_BOX_TYPE_REFT, reftype, "tref", GF_ISOM_REF_LYRA, "apple"),
916
917 //all item reference types
918 TREF_DEFINE( GF_ISOM_BOX_TYPE_REFI, ireftype, "iref", GF_ISOM_REF_TBAS, "p12"),
919 TREF_DEFINE( GF_ISOM_BOX_TYPE_REFI, ireftype, "iref", GF_ISOM_REF_ILOC, "p12"),
920 TREF_DEFINE( GF_ISOM_BOX_TYPE_REFI, ireftype, "iref", GF_ISOM_REF_FDEL, "p12"),
921
922 //all sample group descriptions
923 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_ROLL, "p12"),
924 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_PROL, "p12"),
925 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_RAP, "p12"),
926 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_SEIG, "p15"),
927 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_OINF, "p15"),
928 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_LINF, "p15"),
929 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_TRIF, "p15"),
930 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_NALM, "p15"),
931 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_TELE, "p12"),
932 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_RASH, "p12"),
933 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_ALST, "p12"),
934 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_SAP, "p12"),
935
936 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_AVLL, "p15"),
937 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_AVSS, "p15"),
938 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_DTRT, "p15"),
939 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_MVIF, "p15"),
940 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_SCIF, "p15"),
941 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_SCNM, "p15"),
942 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_STSA, "p15"),
943 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_TSAS, "p15"),
944 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_SYNC, "p15"),
945 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_TSCL, "p15"),
946 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_VIPR, "p15"),
947 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_LBLI, "p15"),
948
949 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_3GAG, "3gpp"),
950 SGPD_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", GF_ISOM_SAMPLE_GROUP_AVCB, "3gpp"),
951
952 //internal boxes
953 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_GNRM, gnrm, "stsd", "unknown"),
954 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_GNRV, gnrv, "stsd", "unknown"),
955 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_GNRA, gnra, "stsd", "unknown"),
956
957 //all track group types
958 TRGT_DEFINE( GF_ISOM_BOX_TYPE_TRGT, trgt, "trgr", GF_ISOM_BOX_TYPE_MSRC, 0, "p12" ),
959 TRGT_DEFINE( GF_ISOM_BOX_TYPE_TRGT, trgt, "trgr", GF_ISOM_BOX_TYPE_STER, 0, "p12" ),
960 TRGT_DEFINE( GF_ISOM_BOX_TYPE_TRGT, trgt, "trgr", GF_ISOM_BOX_TYPE_CSTG, 0, "p15" ),
961
962 //part12 boxes
963 BOX_DEFINE( GF_ISOM_BOX_TYPE_FREE, free, "*"),
964 BOX_DEFINE( GF_ISOM_BOX_TYPE_SKIP, free, "*"),
965 BOX_DEFINE( GF_ISOM_BOX_TYPE_MDAT, mdat, "file"),
966 BOX_DEFINE( GF_ISOM_BOX_TYPE_IDAT, mdat, "meta"),
967 BOX_DEFINE( GF_ISOM_BOX_TYPE_MOOV, moov, "file"),
968 FBOX_DEFINE( GF_ISOM_BOX_TYPE_MVHD, mvhd, "moov", 1),
969 FBOX_DEFINE( GF_ISOM_BOX_TYPE_MDHD, mdhd, "mdia", 1),
970 FBOX_DEFINE( GF_ISOM_BOX_TYPE_VMHD, vmhd, "minf", 0),
971 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SMHD, smhd, "minf", 0),
972 FBOX_DEFINE( GF_ISOM_BOX_TYPE_HMHD, hmhd, "minf", 0),
973 FBOX_DEFINE( GF_ISOM_BOX_TYPE_NMHD, nmhd, "minf", 0),
974 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STHD, nmhd, "minf", 0),
975 BOX_DEFINE( GF_ISOM_BOX_TYPE_STBL, stbl, "minf"),
976 BOX_DEFINE( GF_ISOM_BOX_TYPE_DINF, dinf, "minf meta"),
977 FBOX_DEFINE_FLAGS( GF_ISOM_BOX_TYPE_URL, url, "dref", 0, 1),
978 FBOX_DEFINE_FLAGS( GF_ISOM_BOX_TYPE_URN, urn, "dref", 0, 1),
979 FBOX_DEFINE( GF_ISOM_BOX_TYPE_CPRT, cprt, "udta", 0),
980 FBOX_DEFINE( GF_ISOM_BOX_TYPE_KIND, kind, "udta", 0),
981 FBOX_DEFINE( GF_ISOM_BOX_TYPE_HDLR, hdlr, "mdia meta minf", 0), //minf container is OK in QT ...
982 BOX_DEFINE( GF_ISOM_BOX_TYPE_TRAK, trak, "moov"),
983 BOX_DEFINE( GF_ISOM_BOX_TYPE_EDTS, edts, "trak"),
984 BOX_DEFINE( GF_ISOM_BOX_TYPE_UDTA, udta, "moov trak moof traf"),
985 FBOX_DEFINE( GF_ISOM_BOX_TYPE_DREF, dref, "dinf", 0),
986 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSD, stsd, "stbl", 0),
987 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STTS, stts, "stbl", 0),
988 FBOX_DEFINE( GF_ISOM_BOX_TYPE_CTTS, ctts, "stbl", 1),
989 FBOX_DEFINE( GF_ISOM_BOX_TYPE_CSLG, cslg, "stbl trep", 1),
990 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSH, stsh, "stbl", 0),
991 FBOX_DEFINE( GF_ISOM_BOX_TYPE_ELST, elst, "edts", 1),
992 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSC, stsc, "stbl", 0),
993 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSZ, stsz, "stbl", 0),
994 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STZ2, stsz, "stbl", 0),
995 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STCO, stco, "stbl", 0),
996 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSS, stss, "stbl", 0),
997 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STDP, stdp, "stbl", 0),
998 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SDTP, sdtp, "stbl traf", 0),
999 FBOX_DEFINE( GF_ISOM_BOX_TYPE_CO64, co64, "stbl", 0),
1000 BOX_DEFINE( GF_ISOM_BOX_TYPE_MINF, minf, "mdia"),
1001 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_TKHD, tkhd, "trak", 1, 0x000001 | 0x000002 | 0x000004 | 0x000008),
1002 BOX_DEFINE( GF_ISOM_BOX_TYPE_TREF, tref, "trak"),
1003 BOX_DEFINE( GF_ISOM_BOX_TYPE_MDIA, mdia, "trak"),
1004 BOX_DEFINE( GF_ISOM_BOX_TYPE_MFRA, mfra, "file"),
1005 FBOX_DEFINE( GF_ISOM_BOX_TYPE_MFRO, mfro, "mfra", 0),
1006 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TFRA, tfra, "mfra", 1),
1007 FBOX_DEFINE( GF_ISOM_BOX_TYPE_ELNG, elng, "mdia", 0),
1008 FBOX_DEFINE( GF_ISOM_BOX_TYPE_PDIN, pdin, "file", 0),
1009 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SBGP, sbgp, "stbl traf", 1),
1010 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SGPD, sgpd, "stbl traf", 2),
1011 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_SAIZ, saiz, "stbl traf", 0, 0),
1012 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_SAIZ, saiz, "stbl traf", 0, 1),
1013 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_SAIO, saio, "stbl traf", 1, 0),
1014 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_SAIO, saio, "stbl traf", 1, 1),
1015 FBOX_DEFINE_FLAGS( GF_ISOM_BOX_TYPE_SUBS, subs, "stbl traf", 0, 7), //warning flags are not used as a bit mask but as an enum!!
1016 BOX_DEFINE( GF_ISOM_BOX_TYPE_TRGR, trgr, "trak"),
1017 BOX_DEFINE( GF_ISOM_BOX_TYPE_FTYP, ftyp, "file"),
1018 FBOX_DEFINE( GF_ISOM_BOX_TYPE_PADB, padb, "stbl", 0),
1019 BOX_DEFINE( GF_ISOM_BOX_TYPE_BTRT, btrt, "sample_entry"),
1020 BOX_DEFINE( GF_ISOM_BOX_TYPE_PASP, pasp, "video_sample_entry ipco"),
1021 BOX_DEFINE( GF_ISOM_BOX_TYPE_CLAP, clap, "video_sample_entry ipco"),
1022 FBOX_DEFINE( GF_ISOM_BOX_TYPE_META, meta, "file moov trak moof traf udta", 0), //apple uses meta in moov->udta
1023 FBOX_DEFINE( GF_ISOM_BOX_TYPE_XML, xml, "meta", 0),
1024 FBOX_DEFINE( GF_ISOM_BOX_TYPE_BXML, bxml, "meta", 0),
1025 FBOX_DEFINE( GF_ISOM_BOX_TYPE_ILOC, iloc, "meta", 2),
1026 FBOX_DEFINE( GF_ISOM_BOX_TYPE_PITM, pitm, "meta", 1),
1027 FBOX_DEFINE( GF_ISOM_BOX_TYPE_IPRO, ipro, "meta", 0),
1028 FBOX_DEFINE( GF_ISOM_BOX_TYPE_INFE, infe, "iinf", 3),
1029 FBOX_DEFINE( GF_ISOM_BOX_TYPE_IINF, iinf, "meta", 1),
1030 FBOX_DEFINE( GF_ISOM_BOX_TYPE_IREF, iref, "meta", 1),
1031 BOX_DEFINE( GF_ISOM_BOX_TYPE_SINF, sinf, "ipro sample_entry"),
1032 BOX_DEFINE( GF_ISOM_BOX_TYPE_RINF, sinf, "sample_entry"),
1033 BOX_DEFINE( GF_ISOM_BOX_TYPE_FRMA, frma, "sinf rinf"),
1034 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_SCHM, schm, "sinf rinf", 0, 1),
1035 BOX_DEFINE( GF_ISOM_BOX_TYPE_SCHI, schi, "sinf rinf"),
1036 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCA, audio_sample_entry, "stsd"),
1037 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCV, video_sample_entry, "stsd"),
1038 BOX_DEFINE( GF_ISOM_BOX_TYPE_RESV, video_sample_entry, "stsd"),
1039 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TSEL, tsel, "udta", 0),
1040 BOX_DEFINE( GF_ISOM_BOX_TYPE_STRK, strk, "udta"),
1041 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STRI, stri, "strk", 0),
1042 BOX_DEFINE( GF_ISOM_BOX_TYPE_STRD, def_parent, "strk"),
1043 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STSG, stsg, "strd", 0),
1044
1045 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCS, mp4s, "stsd"),
1046 //THIS HAS TO BE FIXED, not extensible
1047 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCT, mp4s, "stsd"),
1048 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCM, mp4s, "stsd"),
1049 BOX_DEFINE( GF_ISOM_BOX_TYPE_ENCF, mp4s, "stsd"),
1050
1051 BOX_DEFINE( GF_ISOM_BOX_TYPE_METX, metx, "stsd"),
1052 BOX_DEFINE( GF_ISOM_BOX_TYPE_METT, metx, "stsd"),
1053 FBOX_DEFINE( GF_ISOM_BOX_TYPE_STVI, stvi, "schi", 0),
1054
1055
1056 FBOX_DEFINE( GF_ISOM_BOX_TYPE_CHNL, chnl, "audio_sample_entry", 0),
1057
1058 //FEC
1059 FBOX_DEFINE( GF_ISOM_BOX_TYPE_FIIN, fiin, "meta", 0),
1060 BOX_DEFINE( GF_ISOM_BOX_TYPE_PAEN, paen, "fiin"),
1061 FBOX_DEFINE( GF_ISOM_BOX_TYPE_FPAR, fpar, "paen", 1),
1062 FBOX_DEFINE( GF_ISOM_BOX_TYPE_FECR, fecr, "paen", 1),
1063 //fire uses the same box syntax as fecr
1064 FBOX_DEFINE( GF_ISOM_BOX_TYPE_FIRE, fecr, "paen", 1),
1065 BOX_DEFINE( GF_ISOM_BOX_TYPE_SEGR, segr, "fiin"),
1066 FBOX_DEFINE( GF_ISOM_BOX_TYPE_GITN, gitn, "fiin", 0),
1067
1068 #ifndef GPAC_DISABLE_ISOM_HINTING
1069 BOX_DEFINE( GF_ISOM_BOX_TYPE_FDSA, fdsa, "fdp_sample"),
1070 BOX_DEFINE( GF_ISOM_BOX_TYPE_FDPA, fdpa, "fdsa"),
1071 BOX_DEFINE( GF_ISOM_BOX_TYPE_EXTR, extr, "fdsa"),
1072 #endif
1073
1074 //full boxes todo
1075 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_ASSP, assp, 1),
1076 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_MERE, assp, 0),
1077 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_SRAT, srat, 0),
1078 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_CHNL, chnl, 0),
1079 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_DMIX, dmix, 0),
1080 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_TLOU, alou, 0),
1081 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_ALOU, alou, 0),
1082 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_URI, uri, 0),
1083 //FBOX_DEFINE( GF_ISOM_BOX_TYPE_URII, urii, 0),
1084
1085 #ifndef GPAC_DISABLE_ISOM_HINTING
1086 BOX_DEFINE( GF_ISOM_BOX_TYPE_RTP_STSD, ghnt, "stsd"),
1087 BOX_DEFINE( GF_ISOM_BOX_TYPE_SRTP_STSD, ghnt, "stsd"),
1088 BOX_DEFINE( GF_ISOM_BOX_TYPE_FDP_STSD, ghnt, "stsd"),
1089 BOX_DEFINE( GF_ISOM_BOX_TYPE_RRTP_STSD, ghnt, "stsd"),
1090 BOX_DEFINE( GF_ISOM_BOX_TYPE_RTCP_STSD, ghnt, "stsd"),
1091 BOX_DEFINE( GF_ISOM_BOX_TYPE_HNTI, hnti, "udta"),
1092 BOX_DEFINE( GF_ISOM_BOX_TYPE_SDP, sdp, "hnti"),
1093 BOX_DEFINE( GF_ISOM_BOX_TYPE_HINF, hinf, "udta"),
1094 BOX_DEFINE( GF_ISOM_BOX_TYPE_TRPY, trpy, "hinf"),
1095 BOX_DEFINE( GF_ISOM_BOX_TYPE_NUMP, nump, "hinf"),
1096 BOX_DEFINE( GF_ISOM_BOX_TYPE_TPYL, tpyl, "hinf"),
1097 BOX_DEFINE( GF_ISOM_BOX_TYPE_TOTL, totl, "hinf"),
1098 BOX_DEFINE( GF_ISOM_BOX_TYPE_NPCK, npck, "hinf"),
1099 BOX_DEFINE( GF_ISOM_BOX_TYPE_TPAY, tpay, "hinf"),
1100 BOX_DEFINE( GF_ISOM_BOX_TYPE_MAXR, maxr, "hinf"),
1101 BOX_DEFINE( GF_ISOM_BOX_TYPE_DMED, dmed, "hinf"),
1102 BOX_DEFINE( GF_ISOM_BOX_TYPE_DIMM, dimm, "hinf"),
1103 BOX_DEFINE( GF_ISOM_BOX_TYPE_DREP, drep, "hinf"),
1104 BOX_DEFINE( GF_ISOM_BOX_TYPE_TMIN, tmin, "hinf"),
1105 BOX_DEFINE( GF_ISOM_BOX_TYPE_TMAX, tmax, "hinf"),
1106 BOX_DEFINE( GF_ISOM_BOX_TYPE_PMAX, pmax, "hinf"),
1107 BOX_DEFINE( GF_ISOM_BOX_TYPE_DMAX, dmax, "hinf"),
1108 BOX_DEFINE( GF_ISOM_BOX_TYPE_PAYT, payt, "hinf"),
1109 BOX_DEFINE( GF_ISOM_BOX_TYPE_RTP, rtp_hnti, "hnti"),
1110
1111 BOX_DEFINE( GF_ISOM_BOX_TYPE_RTPO, rtpo, "rtp_packet"),
1112
1113 BOX_DEFINE( GF_ISOM_BOX_TYPE_RELY, rely, "rtp srtp"),
1114 BOX_DEFINE( GF_ISOM_BOX_TYPE_TIMS, tims, "rtp srtp rrtp"),
1115 BOX_DEFINE( GF_ISOM_BOX_TYPE_TSRO, tsro, "rtp srtp rrtp"),
1116 BOX_DEFINE( GF_ISOM_BOX_TYPE_SNRO, snro, "rtp srtp"),
1117 BOX_DEFINE( GF_ISOM_BOX_TYPE_NAME, name, "udta"),
1118 BOX_DEFINE( GF_ISOM_BOX_TYPE_TSSY, tssy, "rrtp"),
1119 BOX_DEFINE( GF_ISOM_BOX_TYPE_RSSR, rssr, "rrtp"),
1120 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SRPP, srpp, "srtp", 0),
1121
1122 #endif
1123
1124 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS
1125 BOX_DEFINE( GF_ISOM_BOX_TYPE_MVEX, mvex, "moov"),
1126 FBOX_DEFINE( GF_ISOM_BOX_TYPE_MEHD, mehd, "mvex", 1),
1127 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TREX, trex, "mvex", 0),
1128 FBOX_DEFINE( GF_ISOM_BOX_TYPE_LEVA, leva, "mvex", 0),
1129 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TREP, trep, "mvex", 0),
1130 BOX_DEFINE( GF_ISOM_BOX_TYPE_MOOF, moof, "file"),
1131 FBOX_DEFINE( GF_ISOM_BOX_TYPE_MFHD, mfhd, "moof", 0),
1132 BOX_DEFINE( GF_ISOM_BOX_TYPE_TRAF, traf, "moof"),
1133 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_TFHD, tfhd, "traf", 0, 0x000001|0x000002|0x000008|0x000010|0x000020|0x010000|0x020000),
1134 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_TRUN, trun, "traf", 0, 0x000001|0x000004|0x000100|0x000200|0x000400|0x000800),
1135 #ifdef GF_ENABLE_CTRN
1136 FBOX_DEFINE_FLAGS(GF_ISOM_BOX_TYPE_CTRN, trun, "traf", 0, 0),
1137 #endif
1138 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TFDT, tfdt, "traf", 1),
1139 BOX_DEFINE( GF_ISOM_BOX_TYPE_STYP, ftyp, "file"),
1140 FBOX_DEFINE( GF_ISOM_BOX_TYPE_PRFT, prft, "file", 1),
1141 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SIDX, sidx, "file", 1),
1142 FBOX_DEFINE( GF_ISOM_BOX_TYPE_SSIX, ssix, "file", 0),
1143 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_PCRB, pcrb, "file", "dash"),
1144 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_EMSG, emsg, "file", 1, "dash"),
1145 #endif
1146
1147
1148 //part14 boxes
1149 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_IODS, iods, "moov", 0, "p14"),
1150 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MP4S, mp4s, "stsd", "p14"),
1151 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MP4V, video_sample_entry, "stsd", "p14"),
1152 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MP4A, audio_sample_entry, "stsd", "p14"),
1153 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_M4DS, m4ds, "sample_entry", "p14"),
1154 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ESDS, esds, "mp4a mp4s mp4v encv enca encs resv wave", 0, "p14"),
1155
1156 //part 15 boxes
1157 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AVCC, avcc, "avc1 avc2 avc3 avc4 encv resv ipco", "p15"),
1158 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_SVCC, avcc, "avc1 avc2 avc3 avc4 svc1 svc2 encv resv", "p15"),
1159 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MVCC, avcc, "avc1 avc2 avc3 avc4 mvc1 mvc2 encv resv", "p15"),
1160 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HVCC, hvcc, "hvc1 hev1 hvc2 hev2 encv resv ipco dvhe", "p15"),
1161 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_LHVC, hvcc, "hvc1 hev1 hvc2 hev2 lhv1 lhe1 encv resv ipco", "p15"),
1162 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AVC1, video_sample_entry, "stsd", "p15"),
1163 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AVC2, video_sample_entry, "stsd", "p15"),
1164 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AVC3, video_sample_entry, "stsd", "p15"),
1165 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AVC4, video_sample_entry, "stsd", "p15"),
1166 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_SVC1, video_sample_entry, "stsd", "p15"),
1167 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MVC1, video_sample_entry, "stsd", "p15"),
1168 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HVC1, video_sample_entry, "stsd", "p15"),
1169 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HEV1, video_sample_entry, "stsd", "p15"),
1170 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HVC2, video_sample_entry, "stsd", "p15"),
1171 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HEV2, video_sample_entry, "stsd", "p15"),
1172 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_LHV1, video_sample_entry, "stsd", "p15"),
1173 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_LHE1, video_sample_entry, "stsd", "p15"),
1174 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HVT1, video_sample_entry, "stsd", "p15"),
1175 FBOX_DEFINE_S(GF_ISOM_BOX_TYPE_MVCI, def_parent_full, "minf", 0, "p15"),
1176 FBOX_DEFINE_S(GF_ISOM_BOX_TYPE_MVCG, mvcg, "mvci", 0, "p15"),
1177 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_VWID, vwid, "video_sample_entry", 0, "p15"),
1178
1179 //mpegh 3D audio boxes
1180 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MHA1, audio_sample_entry, "stsd", "mpegh3Daudio"),
1181 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MHA2, audio_sample_entry, "stsd", "mpegh3Daudio"),
1182 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MHM1, audio_sample_entry, "stsd", "mpegh3Daudio"),
1183 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MHM2, audio_sample_entry, "stsd", "mpegh3Daudio"),
1184 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MHAC, mhac, "mha1 mha2 mhm1 mhm2 wave", "mpegh3Daudio"),
1185
1186 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_IPCM, audio_sample_entry, "stsd", "23003_5"),
1187 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_FPCM, audio_sample_entry, "stsd", "23003_5"),
1188 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_PCMC, pcmC, "ipcm fpcm", 0, "23003_5"),
1189
1190 //AV1 in ISOBMFF boxes
1191 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_AV01, video_sample_entry, "stsd", "av1"),
1192 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_AV1C, av1c, "av01 encv resv ipco", "av1"),
1193
1194 // VP8-9 boxes
1195 FBOX_DEFINE_FLAGS_S( GF_ISOM_BOX_TYPE_VPCC, vpcc, "vp08 vp09 encv resv", 1, 0, "vp"),
1196 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VP08, video_sample_entry, "stsd", "vp"),
1197 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VP09, video_sample_entry, "stsd", "vp"),
1198 FBOX_DEFINE_FLAGS_S(GF_ISOM_BOX_TYPE_SMDM, SmDm, "vp08 vp09 encv resv", 1, 0, "vp"),
1199 FBOX_DEFINE_FLAGS_S(GF_ISOM_BOX_TYPE_COLL, CoLL, "vp08 vp09 encv resv", 1, 0, "vp"),
1200
1201 //Opus in ISOBMFF boxes
1202 #ifndef GPAC_DISABLE_OGG
1203 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_OPUS, audio_sample_entry, "stsd", "Opus"),
1204 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_DOPS, dOps, "Opus wave enca", "Opus"),
1205 #endif
1206
1207 //part20 boxes
1208 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_LSR1, lsr1, "stsd", "p20"),
1209 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_LSRC, lsrc, "lsr1", "p20"),
1210
1211 //part30 boxes
1212 #ifndef GPAC_DISABLE_TTXT
1213 BOX_DEFINE( GF_ISOM_BOX_TYPE_STXT, metx, "stsd"),
1214 FBOX_DEFINE( GF_ISOM_BOX_TYPE_TXTC, txtc, "stxt mett sbtt", 0),
1215 #ifndef GPAC_DISABLE_VTT
1216 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_WVTT, wvtt, "stsd", "p30"),
1217 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VTCC_CUE, vtcu, "vtt_sample", "p30"),
1218 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VTTE, vtte, "vtt_sample", "p30"),
1219 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VTTC_CONFIG, boxstring, "wvtt", "p30"),
1220 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_CTIM, boxstring, "vttc", "p30"),
1221 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_IDEN, boxstring, "vttc", "p30"),
1222 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_STTG, boxstring, "vttc", "p30"),
1223 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_PAYL, boxstring, "vttc", "p30"),
1224 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VTTA, boxstring, "vttc", "p30"),
1225 #endif
1226 BOX_DEFINE( GF_ISOM_BOX_TYPE_STPP, metx, "stsd"),
1227 BOX_DEFINE( GF_ISOM_BOX_TYPE_SBTT, metx, "stsd"),
1228 #endif
1229
1230 //Image File Format
1231 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_IPRP, iprp, "meta", "iff"),
1232 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_IPCO, ipco, "iprp", "iff"),
1233 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ISPE, ispe, "ipco", 0, "iff"),
1234 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_COLR, colr, "video_sample_entry ipco encv resv", "iff"),
1235 //defined as a secondary box for now to avoid conflicts with master hashes
1236 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_COLR, colr, "jp2h", "iff"),
1237 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_PIXI, pixi, "ipco", 0, "iff"),
1238 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_RLOC, rloc, "ipco", 0, "iff"),
1239 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_IROT, irot, "ipco", "iff"),
1240 FBOX_DEFINE_FLAGS_S( GF_ISOM_BOX_TYPE_IPMA, ipma, "iprp", 1, 1, "iff"),
1241 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_GRPL, grpl, "meta", "iff"),
1242 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_CCST, ccst, "sample_entry", 0, "iff"),
1243 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AUXI, auxi, "sample_entry", 0, "iff"),
1244 TRGT_DEFINE(GF_ISOM_BOX_TYPE_GRPT, grptype, "grpl", GF_ISOM_BOX_TYPE_ALTR, 0, "iff"),
1245 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AUXC, auxc, "ipco", 0, "iff"),
1246 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_OINF, oinf, "ipco", 0, "iff"),
1247 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_TOLS, tols, "ipco", 0, "iff"),
1248
1249 //MIAF
1250 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_CLLI, clli, "mp4v jpeg avc1 avc2 avc3 avc4 svc1 svc2 hvc1 hev1 hvc2 hev2 lhv1 lhe1 encv resv", "miaf"),
1251 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_MDCV, mdcv, "mp4v jpeg avc1 avc2 avc3 avc4 svc1 svc2 hvc1 hev1 hvc2 hev2 lhv1 lhe1 encv resv", "miaf"),
1252
1253 //other MPEG boxes
1254 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_RVCC, rvcc, "avc1 avc2 avc3 avc4 svc1 svc2 hvc1 hev1 hvc2 hev2 lhv1 lhe1 encv resv", "rvc"),
1255
1256 //3GPP boxes
1257 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_AMR, audio_sample_entry, "stsd", "3gpp"),
1258 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_AMR_WB, audio_sample_entry, "stsd", "3gpp"),
1259 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_QCELP, audio_sample_entry, "stsd", "3gpp"),
1260 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_EVRC, audio_sample_entry, "stsd", "3gpp"),
1261 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_SMV, audio_sample_entry, "stsd", "3gpp"),
1262 BOX_DEFINE_S( GF_ISOM_SUBTYPE_3GP_H263, video_sample_entry, "stsd", "3gpp"),
1263 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DAMR, gppc, "samr sawb enca", "3gpp"),
1264 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DEVC, gppc, "sevc enca", "3gpp"),
1265 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DQCP, gppc, "sqcp enca", "3gpp"),
1266 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DSMV, gppc, "ssmv enca", "3gpp"),
1267 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_D263, gppc, "s263 encv", "3gpp"),
1268 //3gpp timed text
1269 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TX3G, tx3g, "stsd", "3gpp"),
1270 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TEXT, text, "stsd", "apple"),
1271 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_FTAB, ftab, "tx3g text enct", "3gpp"),
1272 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_STYL, styl, "text_sample", "3gpp"),
1273 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HLIT, hlit, "text_sample", "3gpp"),
1274 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HCLR, hclr, "text_sample", "3gpp"),
1275 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_KROK, krok, "text_sample", "3gpp"),
1276 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DLAY, dlay, "text_sample", "3gpp"),
1277 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_HREF, href, "text_sample", "3gpp"),
1278 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TBOX, tbox, "text_sample", "3gpp"),
1279 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_BLNK, blnk, "text_sample", "3gpp"),
1280 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TWRP, twrp, "text_sample", "3gpp"),
1281 //3GPP dims
1282 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DIMS, dims, "stsd", "3gpp"),
1283 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DIMC, dimC, "dims encs", "3gpp"),
1284 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DIST, diST, "stsd", "3gpp"),
1285
1286
1287 //CENC boxes
1288 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_PSSH, pssh, "moov moof", 0, "cenc"),
1289 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_TENC, tenc, "schi", 1, "cenc"),
1290 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_SENC, senc, "trak traf", "cenc"),
1291
1292 // ISMA 1.1 boxes
1293 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_IKMS, iKMS, "schi", 0, "isma"),
1294 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ISFM, iSFM, "schi", 0, "isma"),
1295 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ISLT, iSLT, "schi", 0, "isma"),
1296
1297 //OMA boxes
1298 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ODKM, odkm, "schi", 0, "oma"),
1299 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_OHDR, ohdr, "odkm", 0, "oma"),
1300 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_GRPI, grpi, "ohdr", 0, "oma"),
1301 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MDRI, mdri, "file", "oma"),
1302 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ODTT, odtt, "mdri", 0, "oma"),
1303 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ODRB, odrb, "mdri", 0, "oma"),
1304 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ODAF, iSFM, "schi", 0, "oma"),
1305
1306 //apple boxes
1307 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_MP3, audio_sample_entry, "stsd", "apple"),
1308 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_CHPL, chpl, "udta", 0, "apple"),
1309 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_VOID, void, "", "apple"),
1310 BOX_DEFINE_S(GF_QT_BOX_TYPE_WIDE, wide, "*", "apple"),
1311 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_ILST, ilst, "meta", "apple"),
1312 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_DATA, databox, "ilst *", 0, "apple"),
1313 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9NAM, ilst_item, "ilst data", "apple"),
1314 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9CMT, ilst_item, "ilst data", "apple"),
1315 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9DAY, ilst_item, "ilst data", "apple"),
1316 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9ART, ilst_item, "ilst data", "apple"),
1317 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9TRK, ilst_item, "ilst data", "apple"),
1318 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9ALB, ilst_item, "ilst data", "apple"),
1319 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9COM, ilst_item, "ilst data", "apple"),
1320 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9WRT, ilst_item, "ilst data", "apple"),
1321 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9TOO, ilst_item, "ilst data", "apple"),
1322 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9CPY, ilst_item, "ilst data", "apple"),
1323 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9DES, ilst_item, "ilst data", "apple"),
1324 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9GEN, ilst_item, "ilst data", "apple"),
1325 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9GRP, ilst_item, "ilst data", "apple"),
1326 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_0xA9ENC, ilst_item, "ilst data", "apple"),
1327 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_aART, ilst_item, "ilst data", "apple"),
1328 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_PGAP, ilst_item, "ilst data", "apple"),
1329 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_GNRE, ilst_item, "ilst data", "apple"),
1330 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DISK, ilst_item, "ilst data", "apple"),
1331 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TRKN, ilst_item, "ilst data", "apple"),
1332 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_TMPO, ilst_item, "ilst data", "apple"),
1333 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_CPIL, ilst_item, "ilst data", "apple"),
1334 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_COVR, ilst_item, "ilst data", "apple"),
1335 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_iTunesSpecificInfo, ilst_item, "ilst data", "apple"),
1336 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_GMHD, def_parent, "minf", "apple"),
1337 BOX_DEFINE_S(GF_QT_BOX_TYPE_LOAD, load, "trak", "apple"),
1338 BOX_DEFINE_S(GF_QT_BOX_TYPE_TAPT, def_parent, "trak", "apple"),
1339 FBOX_DEFINE_S( GF_QT_BOX_TYPE_GMIN, gmin, "gmhd", 0, "apple"),
1340 FBOX_DEFINE_FLAGS_S( GF_QT_BOX_TYPE_ALIS, alis, "dref", 0, 1, "apple"),
1341 FBOX_DEFINE_S( GF_QT_BOX_TYPE_CLEF, clef, "tapt", 0, "apple"),
1342 FBOX_DEFINE_S( GF_QT_BOX_TYPE_PROF, clef, "tapt", 0, "apple"),
1343 FBOX_DEFINE_S( GF_QT_BOX_TYPE_ENOF, clef, "tapt", 0, "apple"),
1344 BOX_DEFINE_S( GF_QT_BOX_TYPE_WAVE, def_parent, "audio_sample_entry", "apple"),
1345 FBOX_DEFINE_S( GF_QT_BOX_TYPE_CHAN, chan, "audio_sample_entry", 0, "apple"),
1346 BOX_DEFINE_S( GF_QT_BOX_TYPE_FRMA, frma, "wave", "apple"),
1347 BOX_DEFINE_S( GF_QT_BOX_TYPE_TERMINATOR, unkn, "wave", "apple"),
1348 BOX_DEFINE_S( GF_QT_BOX_TYPE_ENDA, chrm, "wave", "apple"),
1349 BOX_DEFINE_S( GF_QT_BOX_TYPE_TMCD, def_parent, "gmhd", "apple"),
1350 BOX_DEFINE_S( GF_QT_BOX_TYPE_NAME, unkn, "tmcd", "apple"),
1351 FBOX_DEFINE_S( GF_QT_BOX_TYPE_TCMI, tcmi, "tmcd", 0, "apple"),
1352 BOX_DEFINE_S( GF_QT_BOX_TYPE_FIEL, fiel, "video_sample_entry", "apple"),
1353 BOX_DEFINE_S( GF_QT_BOX_TYPE_GAMA, gama, "video_sample_entry", "apple"),
1354 BOX_DEFINE_S( GF_QT_BOX_TYPE_CHRM, chrm, "video_sample_entry", "apple"),
1355 BOX_DEFINE_S( GF_ISOM_SUBTYPE_TEXT, unkn, "gmhd", "apple"),
1356
1357 //QT and prores sample entry types
1358 BOX_DEFINE_S( GF_QT_BOX_TYPE_TMCD, tmcd, "stsd", "apple"),
1359 BOX_DEFINE_S( GF_QT_SUBTYPE_C608, gen_sample_entry, "stsd", "apple"),
1360 BOX_DEFINE_S( GF_QT_SUBTYPE_APCH, video_sample_entry, "stsd", "apple"),
1361 BOX_DEFINE_S( GF_QT_SUBTYPE_APCO, video_sample_entry, "stsd", "apple"),
1362 BOX_DEFINE_S( GF_QT_SUBTYPE_APCS, video_sample_entry, "stsd", "apple"),
1363 BOX_DEFINE_S( GF_QT_SUBTYPE_APCN, video_sample_entry, "stsd", "apple"),
1364 BOX_DEFINE_S( GF_QT_SUBTYPE_AP4X, video_sample_entry, "stsd", "apple"),
1365 BOX_DEFINE_S( GF_QT_SUBTYPE_AP4H, video_sample_entry, "stsd", "apple"),
1366 BOX_DEFINE_S( GF_QT_SUBTYPE_RAW_VID, video_sample_entry, "stsd", "apple"),
1367 BOX_DEFINE_S( GF_QT_SUBTYPE_RAW_AUD, audio_sample_entry, "stsd", "apple"),
1368 BOX_DEFINE_S( GF_QT_SUBTYPE_TWOS, audio_sample_entry, "stsd", "apple"),
1369 BOX_DEFINE_S( GF_QT_SUBTYPE_SOWT, audio_sample_entry, "stsd", "apple"),
1370 BOX_DEFINE_S( GF_QT_SUBTYPE_FL32, audio_sample_entry, "stsd", "apple"),
1371 BOX_DEFINE_S( GF_QT_SUBTYPE_FL64, audio_sample_entry, "stsd", "apple"),
1372 BOX_DEFINE_S( GF_QT_SUBTYPE_IN24, audio_sample_entry, "stsd", "apple"),
1373 BOX_DEFINE_S( GF_QT_SUBTYPE_IN32, audio_sample_entry, "stsd", "apple"),
1374 BOX_DEFINE_S( GF_QT_SUBTYPE_ULAW, audio_sample_entry, "stsd", "apple"),
1375 BOX_DEFINE_S( GF_QT_SUBTYPE_ALAW, audio_sample_entry, "stsd", "apple"),
1376 BOX_DEFINE_S( GF_QT_SUBTYPE_ADPCM, audio_sample_entry, "stsd", "apple"),
1377 BOX_DEFINE_S( GF_QT_SUBTYPE_IMA_ADPCM, audio_sample_entry, "stsd", "apple"),
1378 BOX_DEFINE_S( GF_QT_SUBTYPE_DVCA, audio_sample_entry, "stsd", "apple"),
1379 BOX_DEFINE_S( GF_QT_SUBTYPE_QDMC, audio_sample_entry, "stsd", "apple"),
1380 BOX_DEFINE_S( GF_QT_SUBTYPE_QDMC2, audio_sample_entry, "stsd", "apple"),
1381 BOX_DEFINE_S( GF_QT_SUBTYPE_QCELP, audio_sample_entry, "stsd", "apple"),
1382 BOX_DEFINE_S( GF_QT_SUBTYPE_kMP3, audio_sample_entry, "stsd", "apple"),
1383
1384 //dolby boxes
1385 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_AC3, audio_sample_entry, "stsd", "dolby"),
1386 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_EC3, audio_sample_entry, "stsd", "dolby"),
1387 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_DAC3, dac3, "ac-3 wave", "dolby"),
1388 {GF_ISOM_BOX_TYPE_DEC3, dec3_box_new, dac3_box_del, dac3_box_read, dac3_box_write, dac3_box_size, dac3_box_dump, 0, 0, 0, "ec-3 enca", "dolby" },
1389 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_DVCC, dvcC, "dvhe dvav dva1 dvh1 avc1 avc2 avc3 avc4 hev1 encv resv", "DolbyVision"),
1390 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_DVHE, video_sample_entry, "stsd", "DolbyVision"),
1391
1392 //Adobe boxes
1393 #ifndef GPAC_DISABLE_ISOM_ADOBE
1394 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ABST, abst, "file", 0, "adobe"),
1395 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AFRA, afra, "file", 0, "adobe"),
1396 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ASRT, asrt, "abst", 0, "adobe"),
1397 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AFRT, afrt, "abst", 0, "adobe"),
1398 #endif
1399 /*Adobe's protection boxes*/
1400 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ADKM, adkm, "schi", 0, "adobe"),
1401 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AHDR, ahdr, "adkm", 0, "adobe"),
1402 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_ADAF, adaf, "adkm", 0, "adobe"),
1403 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_APRM, aprm, "ahdr", 0, "adobe"),
1404 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AEIB, aeib, "aprm", 0, "adobe"),
1405 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_AKEY, akey, "aprm", 0, "adobe"),
1406 BOX_DEFINE_S( GF_ISOM_BOX_TYPE_FLXS, flxs, "akey", "adobe"),
1407
1408 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_TRIK, trik, "traf", 0, "dece"),
1409 FBOX_DEFINE_S( GF_ISOM_BOX_TYPE_BLOC, bloc, "file", 0, "dece"),
1410 FBOX_DEFINE_FLAGS_S(GF_ISOM_BOX_TYPE_AINF, ainf, "moov", 0, 0x000001, "dece"),
1411
1412
1413 //internally handled UUID for smooth - the code points are only used during creation and assigned to UUIDBox->internal4CC
1414 //the box type is still "uuid", and the factory is used to read/write/size/dump the code
1415 BOX_DEFINE_S(GF_ISOM_BOX_UUID_TENC, piff_tenc, "schi", "smooth"),
1416 BOX_DEFINE_S(GF_ISOM_BOX_UUID_PSEC, piff_psec, "trak traf", "smooth"),
1417 BOX_DEFINE_S(GF_ISOM_BOX_UUID_PSSH, piff_pssh, "moov moof", "smooth"),
1418 BOX_DEFINE_S(GF_ISOM_BOX_UUID_TFXD, tfxd, "traf", "smooth"),
1419 BOX_DEFINE_S(GF_ISOM_BOX_UUID_MSSM, uuid, "file", "smooth"),
1420 BOX_DEFINE_S(GF_ISOM_BOX_UUID_TFRF, uuid, "traf", "smooth"),
1421
1422
1423 //J2K boxes
1424 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_MJP2, video_sample_entry, "stsd", "j2k"),
1425 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_JP2H, jp2h, "mjp2 encv", "j2k"),
1426 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_IHDR, ihdr, "jp2h", "j2k"),
1427
1428 /* Image tracks */
1429 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_JPEG, video_sample_entry, "stsd", "apple"),
1430 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_JP2K, video_sample_entry, "stsd", "apple"),
1431 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_PNG, video_sample_entry, "stsd", "apple"),
1432
1433
1434 //Opus in ISOBMFF boxes
1435 BOX_DEFINE_S(GF_ISOM_BOX_TYPE_FLAC, audio_sample_entry, "stsd", "Flac"),
1436 FBOX_DEFINE_S(GF_ISOM_BOX_TYPE_DFLA, dfla, "fLaC enca", 0, "Flac"),
1437
1438 };
1439
gf_box_valid_in_parent(GF_Box * a,const char * parent_4cc)1440 Bool gf_box_valid_in_parent(GF_Box *a, const char *parent_4cc)
1441 {
1442 if (!a || !a->registry || !a->registry->parents_4cc) return GF_FALSE;
1443 if (strstr(a->registry->parents_4cc, parent_4cc) != NULL) return GF_TRUE;
1444 return GF_FALSE;
1445 }
1446
1447 GF_EXPORT
gf_isom_get_num_supported_boxes()1448 u32 gf_isom_get_num_supported_boxes()
1449 {
1450 return sizeof(box_registry) / sizeof(struct box_registry_entry);
1451 }
1452
gf_isom_registry_disable(u32 boxCode,Bool disable)1453 void gf_isom_registry_disable(u32 boxCode, Bool disable)
1454 {
1455 u32 i=0, count = gf_isom_get_num_supported_boxes();
1456 for (i=1; i<count; i++) {
1457 if (box_registry[i].box_4cc==boxCode) {
1458 box_registry[i].disabled = disable;
1459 return;
1460 }
1461 }
1462 }
1463
get_box_reg_idx(u32 boxCode,u32 parent_type)1464 static u32 get_box_reg_idx(u32 boxCode, u32 parent_type)
1465 {
1466 u32 i=0, count = gf_isom_get_num_supported_boxes();
1467 const char *parent_name = parent_type ? gf_4cc_to_str(parent_type) : NULL;
1468
1469 for (i=1; i<count; i++) {
1470 if (box_registry[i].box_4cc==boxCode) {
1471 if (!parent_type) return i;
1472 if (strstr(box_registry[i].parents_4cc, parent_name) != NULL) return i;
1473
1474 if (strstr(box_registry[i].parents_4cc, "sample_entry") != NULL) {
1475 u32 j = get_box_reg_idx(parent_type, 0);
1476 if (parent_type==GF_QT_SUBTYPE_RAW)
1477 return i;
1478 if (box_registry[j].parents_4cc && (strstr(box_registry[j].parents_4cc, "stsd") != NULL))
1479 return i;
1480 }
1481 }
1482 }
1483 return 0;
1484 }
1485
gf_isom_box_new_ex(u32 boxType,u32 parentType,Bool skip_logs,Bool is_root_box)1486 GF_Box *gf_isom_box_new_ex(u32 boxType, u32 parentType, Bool skip_logs, Bool is_root_box)
1487 {
1488 GF_Box *a;
1489 s32 idx = get_box_reg_idx(boxType, parentType);
1490 if (idx==0) {
1491 #ifndef GPAC_DISABLE_LOG
1492 if (!skip_logs && (boxType != GF_ISOM_BOX_TYPE_UNKNOWN) && (boxType != GF_ISOM_BOX_TYPE_UUID)) {
1493 switch (parentType) {
1494 case GF_ISOM_BOX_TYPE_ILST:
1495 case GF_ISOM_BOX_TYPE_META:
1496 case GF_ISOM_BOX_TYPE_UDTA:
1497 case GF_ISOM_BOX_TYPE_UNKNOWN:
1498 case GF_ISOM_BOX_TYPE_iTunesSpecificInfo:
1499 break;
1500 default:
1501 if (is_root_box) {
1502 GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[iso file] Unknown top-level box type %s\n", gf_4cc_to_str(boxType)));
1503 } else if (parentType) {
1504 char szName[GF_4CC_MSIZE];
1505 strcpy(szName, gf_4cc_to_str(parentType));
1506 GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[iso file] Unknown box type %s in parent %s\n", gf_4cc_to_str(boxType), szName));
1507 } else {
1508 GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[iso file] Unknown box type %s\n", gf_4cc_to_str(boxType)));
1509 }
1510 break;
1511 }
1512 }
1513 #endif
1514 if (boxType==GF_ISOM_BOX_TYPE_UUID) {
1515 a = uuid_box_new();
1516 if (a) a->registry = &box_registry[1];
1517 } else {
1518 a = unkn_box_new();
1519 if (a) {
1520 ((GF_UnknownBox *)a)->original_4cc = boxType;
1521 a->registry = &box_registry[0];
1522 }
1523 }
1524 return a;
1525 }
1526 a = box_registry[idx].new_fn();
1527
1528 if (a) {
1529 if (a->type!=GF_ISOM_BOX_TYPE_UUID) {
1530 if (a->type==GF_ISOM_BOX_TYPE_UNKNOWN) {
1531 ((GF_UnknownBox *)a)->original_4cc = boxType;
1532 } else {
1533 a->type = boxType;
1534 }
1535 }
1536 a->registry = &box_registry[idx];
1537
1538 if ((a->type==GF_ISOM_BOX_TYPE_COLR) && (parentType==GF_ISOM_BOX_TYPE_JP2H)) {
1539 ((GF_ColourInformationBox *)a)->is_jp2 = GF_TRUE;
1540 }
1541
1542 }
1543 return a;
1544 }
1545
1546 GF_EXPORT
gf_isom_box_new(u32 boxType)1547 GF_Box *gf_isom_box_new(u32 boxType)
1548 {
1549 return gf_isom_box_new_ex(boxType, 0, 0, GF_FALSE);
1550 }
1551
gf_isom_box_array_read_ex(GF_Box * parent,GF_BitStream * bs,GF_Err (* check_child_box)(GF_Box * par,GF_Box * b),u32 parent_type)1552 GF_Err gf_isom_box_array_read_ex(GF_Box *parent, GF_BitStream *bs, GF_Err (*check_child_box)(GF_Box *par, GF_Box *b), u32 parent_type)
1553 {
1554 GF_Err e;
1555 GF_Box *a = NULL;
1556 Bool skip_logs = (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_NO_LOGS ) ? GF_TRUE : GF_FALSE;
1557
1558 //we may have terminators in some QT files (4 bytes set to 0 ...)
1559 while (parent->size>=8) {
1560 e = gf_isom_box_parse_ex(&a, bs, parent_type, GF_FALSE);
1561 if (e) {
1562 if (a) gf_isom_box_del(a);
1563 return e;
1564 }
1565 //sub box parsing aborted with no error
1566 if (!a) return GF_OK;
1567
1568 if (parent->size < a->size) {
1569 if (!skip_logs) {
1570 GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" is larger than container box\n", gf_4cc_to_str(a->type)));
1571 }
1572 parent->size = 0;
1573 } else {
1574 parent->size -= a->size;
1575 }
1576
1577 //check container validity
1578 if (strlen(a->registry->parents_4cc)) {
1579 Bool parent_OK = GF_FALSE;
1580 const char *parent_code = gf_4cc_to_str(parent->type);
1581 if (parent->type == GF_ISOM_BOX_TYPE_UNKNOWN)
1582 parent_code = gf_4cc_to_str( ((GF_UnknownBox*)parent)->original_4cc );
1583 if (strstr(a->registry->parents_4cc, parent_code) != NULL) {
1584 parent_OK = GF_TRUE;
1585 } else if (!strcmp(a->registry->parents_4cc, "*") || strstr(a->registry->parents_4cc, "* ") || strstr(a->registry->parents_4cc, " *")) {
1586 parent_OK = GF_TRUE;
1587 } else {
1588 //parent must be a sample entry
1589 if (strstr(a->registry->parents_4cc, "sample_entry") != NULL) {
1590 //parent is in an stsd
1591 if (strstr(parent->registry->parents_4cc, "stsd") != NULL) {
1592 if (strstr(a->registry->parents_4cc, "video_sample_entry") != NULL) {
1593 if (((GF_SampleEntryBox*)parent)->internal_type==GF_ISOM_SAMPLE_ENTRY_VIDEO) {
1594 parent_OK = GF_TRUE;
1595 }
1596 } else {
1597 parent_OK = GF_TRUE;
1598 }
1599 }
1600 }
1601 //other types are sample formats, eg a 3GPP text sample, RTP hint sample or VTT cue. Not handled at this level
1602 else if (a->type==GF_ISOM_BOX_TYPE_UNKNOWN) parent_OK = GF_TRUE;
1603 else if (a->type==GF_ISOM_BOX_TYPE_UUID) parent_OK = GF_TRUE;
1604 }
1605 if (! parent_OK && !skip_logs) {
1606 GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" is invalid in container %s\n", gf_4cc_to_str(a->type), parent_code));
1607 }
1608 }
1609
1610 //always register boxes
1611 if (!parent->child_boxes) {
1612 parent->child_boxes = gf_list_new();
1613 if (!parent->child_boxes) return GF_OUT_OF_MEM;
1614 }
1615 e = gf_list_add(parent->child_boxes, a);
1616 if (e) return e;
1617
1618 if (check_child_box) {
1619 e = check_child_box(parent, a);
1620 if (e) {
1621 if (e == GF_ISOM_INVALID_MEDIA) return GF_OK;
1622 //if the box is no longer present, consider it destroyed
1623 if (gf_list_find(parent->child_boxes, a) >=0) {
1624 gf_isom_box_del_parent(&parent->child_boxes, a);
1625 }
1626 return e;
1627 }
1628 }
1629 }
1630 return GF_OK;
1631 }
1632
1633 GF_EXPORT
gf_isom_box_del(GF_Box * a)1634 void gf_isom_box_del(GF_Box *a)
1635 {
1636 GF_List *child_boxes;
1637 const struct box_registry_entry *a_box_registry;
1638 if (!a) return;
1639
1640 child_boxes = a->child_boxes;
1641 a->child_boxes = NULL;
1642
1643 a_box_registry = a->registry;
1644 if (!a_box_registry) {
1645 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Delete invalid box type %s without registry\n", gf_4cc_to_str(a->type) ));
1646 } else {
1647 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Delete box type %s\n", gf_4cc_to_str(a->type) ));
1648 a_box_registry->del_fn(a);
1649 }
1650 //delet the other boxes after deleting the box for dumper case where all child boxes are stored in otherbox
1651 if (child_boxes) {
1652 gf_isom_box_array_del(child_boxes);
1653 }
1654 }
1655
1656
gf_isom_box_read(GF_Box * a,GF_BitStream * bs)1657 GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs)
1658 {
1659 if (!a) return GF_BAD_PARAM;
1660 if (!a->registry) {
1661 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read invalid box type %s without registry\n", gf_4cc_to_str(a->type) ));
1662 return GF_ISOM_INVALID_FILE;
1663 }
1664 return a->registry->read_fn(a, bs);
1665 }
1666
1667 #ifndef GPAC_DISABLE_ISOM_WRITE
1668
gf_isom_box_write_listing(GF_Box * a,GF_BitStream * bs)1669 GF_Err gf_isom_box_write_listing(GF_Box *a, GF_BitStream *bs)
1670 {
1671 if (!a) return GF_BAD_PARAM;
1672 if (!a->registry) {
1673 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Write invalid box type %s without registry\n", gf_4cc_to_str(a->type) ));
1674 return GF_ISOM_INVALID_FILE;
1675 }
1676 return a->registry->write_fn(a, bs);
1677 }
1678
1679
gf_isom_check_position(GF_Box * s,GF_Box * child,u32 * pos)1680 void gf_isom_check_position(GF_Box *s, GF_Box *child, u32 *pos)
1681 {
1682 if (!s || !s->child_boxes || !child || !pos) return;
1683 if (s->internal_flags & GF_ISOM_ORDER_FREEZE)
1684 return;
1685
1686 s32 cur_pos = gf_list_find(s->child_boxes, child);
1687
1688 assert (cur_pos >= 0);
1689
1690 if (cur_pos != (s32) *pos) {
1691 gf_list_del_item(s->child_boxes, child);
1692 gf_list_insert(s->child_boxes, child, *pos);
1693 }
1694 (*pos)++;
1695 }
1696
gf_isom_check_position_list(GF_Box * s,GF_List * childlist,u32 * pos)1697 void gf_isom_check_position_list(GF_Box *s, GF_List *childlist, u32 *pos)
1698 {
1699 u32 i, count;
1700 if (!s || (s->internal_flags & GF_ISOM_ORDER_FREEZE))
1701 return;
1702 count = gf_list_count(childlist);
1703 for (i=0; i<count; i++) {
1704 GF_Box *child = gf_list_get(childlist, i);
1705 gf_isom_check_position(s, child, pos);
1706 }
1707 }
1708
1709
1710 GF_EXPORT
gf_isom_box_write(GF_Box * a,GF_BitStream * bs)1711 GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs)
1712 {
1713 GF_Err e;
1714 u64 pos = gf_bs_get_position(bs);
1715 if (!a) return GF_BAD_PARAM;
1716 //box has been disabled, do not write
1717 if (!a->size) return GF_OK;
1718
1719 if (a->registry->disabled) {
1720 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s disabled registry, skip write\n", gf_4cc_to_str(a->type)));
1721 return GF_OK;
1722 }
1723
1724 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s size %d write\n", gf_4cc_to_str(a->type), a->size));
1725 e = gf_isom_box_write_listing(a, bs);
1726 if (e) return e;
1727 if (a->child_boxes) {
1728 e = gf_isom_box_array_write(a, a->child_boxes, bs);
1729 }
1730 pos = gf_bs_get_position(bs) - pos;
1731 if (pos != a->size) {
1732 if ((a->type==GF_ISOM_BOX_TYPE_MDAT) || (a->type==GF_ISOM_BOX_TYPE_IDAT)) {
1733
1734 } else {
1735 GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box %s wrote "LLU" bytes but size is "LLU"\n", gf_4cc_to_str(a->type), pos, a->size ));
1736 }
1737 }
1738 return e;
1739 }
1740
gf_isom_box_size_listing(GF_Box * a)1741 static GF_Err gf_isom_box_size_listing(GF_Box *a)
1742 {
1743 if (!a) return GF_BAD_PARAM;
1744 if (!a->registry) {
1745 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Size invalid box type %s without registry\n", gf_4cc_to_str(a->type) ));
1746 return GF_ISOM_INVALID_FILE;
1747 }
1748 a->size = 8;
1749
1750 if (a->type == GF_ISOM_BOX_TYPE_UUID) {
1751 a->size += 16;
1752 }
1753 //the large size is handled during write, cause at this stage we don't know the size
1754 if (a->registry->max_version_plus_one) {
1755 a->size += 4;
1756 }
1757 return a->registry->size_fn(a);
1758 }
1759
1760 GF_EXPORT
gf_isom_box_size(GF_Box * a)1761 GF_Err gf_isom_box_size(GF_Box *a)
1762 {
1763 GF_Err e;
1764 if (!a) return GF_BAD_PARAM;
1765 if (a->registry->disabled) {
1766 a->size = 0;
1767 return GF_OK;
1768 }
1769 e = gf_isom_box_size_listing(a);
1770 if (e) return e;
1771 //box size set to 0 (not even a header), abort traversal
1772 if (!a->size) return GF_OK;
1773
1774 if (a->child_boxes) {
1775 e = gf_isom_box_array_size(a, a->child_boxes);
1776 if (e) return e;
1777 }
1778 return GF_OK;
1779 }
1780
1781 #endif /*GPAC_DISABLE_ISOM_WRITE*/
1782
gf_isom_full_box_read(GF_Box * ptr,GF_BitStream * bs)1783 static GF_Err gf_isom_full_box_read(GF_Box *ptr, GF_BitStream *bs)
1784 {
1785 if (ptr->registry->max_version_plus_one) {
1786 GF_FullBox *self = (GF_FullBox *) ptr;
1787 ISOM_DECREASE_SIZE(ptr, 4)
1788 self->version = gf_bs_read_u8(bs);
1789 self->flags = gf_bs_read_u24(bs);
1790 }
1791 return GF_OK;
1792 }
1793
1794
1795 GF_EXPORT
gf_isom_dump_supported_box(u32 idx,FILE * trace)1796 GF_Err gf_isom_dump_supported_box(u32 idx, FILE * trace)
1797 {
1798 u32 i;
1799 u32 nb_versions=0;
1800 GF_Err e;
1801
1802 if (box_registry[idx].max_version_plus_one) {
1803 nb_versions = box_registry[idx].max_version_plus_one - 1;
1804 }
1805 for (i = 0; i <= nb_versions; i++) {
1806 GF_Box *a = box_registry[idx].new_fn();
1807 if (!a) return GF_OUT_OF_MEM;
1808
1809 a->registry = &box_registry[idx];
1810
1811 if (box_registry[idx].alt_4cc) {
1812 if (a->type==GF_ISOM_BOX_TYPE_REFT)
1813 ((GF_TrackReferenceTypeBox*)a)->reference_type = box_registry[idx].alt_4cc;
1814 else if (a->type==GF_ISOM_BOX_TYPE_REFI)
1815 ((GF_ItemReferenceTypeBox*)a)->reference_type = box_registry[idx].alt_4cc;
1816 else if (a->type==GF_ISOM_BOX_TYPE_TRGT)
1817 ((GF_TrackGroupTypeBox*)a)->group_type = box_registry[idx].alt_4cc;
1818 else if (a->type==GF_ISOM_BOX_TYPE_SGPD)
1819 ((GF_SampleGroupDescriptionBox*)a)->grouping_type = box_registry[idx].alt_4cc;
1820 else if (a->type==GF_ISOM_BOX_TYPE_GRPT)
1821 ((GF_EntityToGroupTypeBox*)a)->grouping_type = box_registry[idx].alt_4cc;
1822 }
1823 if (box_registry[idx].max_version_plus_one) {
1824 ((GF_FullBox *)a)->version = i;
1825 }
1826 if (box_registry[idx].flags) {
1827 u32 flag_mask=1;
1828 u32 flags = box_registry[idx].flags;
1829 ((GF_FullBox *)a)->flags = 0;
1830 e = gf_isom_box_dump(a, trace);
1831
1832 //we dump all flags individually and this for all version, in order to simplify the XSLT processing
1833 while (!e) {
1834 u32 flag = flags & flag_mask;
1835 flag_mask <<= 1;
1836 if (flag) {
1837 ((GF_FullBox *)a)->flags = flag;
1838 e = gf_isom_box_dump(a, trace);
1839 }
1840 if (flag_mask > flags) break;
1841 if (flag_mask == 0x80000000) break;
1842 }
1843
1844 } else {
1845 e = gf_isom_box_dump(a, trace);
1846 }
1847
1848 gf_isom_box_del(a);
1849 }
1850 return e;
1851 }
1852
1853 GF_EXPORT
gf_isom_get_supported_box_type(u32 idx)1854 u32 gf_isom_get_supported_box_type(u32 idx)
1855 {
1856 return box_registry[idx].box_4cc;
1857 }
1858
1859 #ifndef GPAC_DISABLE_ISOM_DUMP
1860
gf_isom_box_dump_start(GF_Box * a,const char * name,FILE * trace)1861 GF_Err gf_isom_box_dump_start(GF_Box *a, const char *name, FILE * trace)
1862 {
1863 gf_fprintf(trace, "<%s ", name);
1864 if (a->size > 0xFFFFFFFF) {
1865 gf_fprintf(trace, "LargeSize=\""LLU"\" ", a->size);
1866 } else {
1867 gf_fprintf(trace, "Size=\"%u\" ", (u32) a->size);
1868 }
1869 if (a->type==GF_ISOM_BOX_TYPE_UNKNOWN) {
1870 gf_fprintf(trace, "Type=\"%s\" ", gf_4cc_to_str(((GF_UnknownBox*)a)->original_4cc));
1871 } else {
1872 gf_fprintf(trace, "Type=\"%s\" ", gf_4cc_to_str(a->type));
1873 }
1874
1875 if (a->type == GF_ISOM_BOX_TYPE_UUID) {
1876 u32 i;
1877 gf_fprintf(trace, "UUID=\"{");
1878 for (i=0; i<16; i++) {
1879 gf_fprintf(trace, "%02X", (unsigned char) ((GF_UUIDBox*)a)->uuid[i]);
1880 if ((i<15) && (i%4)==3) gf_fprintf(trace, "-");
1881 }
1882 gf_fprintf(trace, "}\" ");
1883 }
1884
1885 if (a->registry->max_version_plus_one) {
1886 gf_fprintf(trace, "Version=\"%d\" Flags=\"%d\" ", ((GF_FullBox*)a)->version,((GF_FullBox*)a)->flags);
1887 }
1888
1889 gf_fprintf(trace, "Specification=\"%s\" ", a->registry->spec);
1890 gf_fprintf(trace, "Container=\"%s\" ", a->registry->parents_4cc);
1891 return GF_OK;
1892 }
1893
gf_isom_box_dump(void * ptr,FILE * trace)1894 GF_Err gf_isom_box_dump(void *ptr, FILE * trace)
1895 {
1896 GF_Box *a = (GF_Box *) ptr;
1897
1898 if (!a) {
1899 gf_fprintf(trace, "<!--ERROR: NULL Box Found-->\n");
1900 return GF_OK;
1901 }
1902 if (!a->registry) {
1903 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[isom] trying to dump box %s not registered\n", gf_4cc_to_str(a->type) ));
1904 return GF_ISOM_INVALID_FILE;
1905 }
1906 a->registry->dump_fn(a, trace);
1907 return GF_OK;
1908 }
1909
gf_isom_box_dump_done(const char * name,GF_Box * ptr,FILE * trace)1910 void gf_isom_box_dump_done(const char *name, GF_Box *ptr, FILE *trace)
1911 {
1912 if (ptr && ptr->child_boxes) {
1913 gf_isom_box_array_dump(ptr->child_boxes, trace);
1914 }
1915 if (name)
1916 gf_fprintf(trace, "</%s>\n", name);
1917 }
1918
gf_isom_box_is_file_level(GF_Box * s)1919 Bool gf_isom_box_is_file_level(GF_Box *s)
1920 {
1921 if (!s || !s->registry) return GF_FALSE;
1922 if (strstr(s->registry->parents_4cc, "file")!= NULL) return GF_TRUE;
1923 if (strstr(s->registry->parents_4cc, "*")!= NULL) return GF_TRUE;
1924 return GF_FALSE;
1925 }
1926 #endif
1927
1928
gf_isom_box_find_child(GF_List * children,u32 code)1929 GF_Box *gf_isom_box_find_child(GF_List *children, u32 code)
1930 {
1931 u32 i, count;
1932 if (!children) return NULL;
1933 count = gf_list_count(children);
1934 for (i=0; i<count; i++) {
1935 GF_Box *c = gf_list_get(children, i);
1936 if (c->type==code) return c;
1937
1938 if (c->type==GF_ISOM_BOX_TYPE_UNKNOWN) {
1939 if (((GF_UnknownBox*)c)->original_4cc==code)
1940 return c;
1941 }
1942 if (c->type==GF_ISOM_BOX_TYPE_UUID) {
1943 if (((GF_UUIDBox*)c)->internal_4cc==code)
1944 return c;
1945 }
1946 }
1947 return NULL;
1948 }
1949
gf_isom_box_check_unique(GF_List * children,GF_Box * a)1950 Bool gf_isom_box_check_unique(GF_List *children, GF_Box *a)
1951 {
1952 u32 i, count;
1953 if (!children) return GF_TRUE;
1954 count = gf_list_count(children);
1955 for (i=0; i<count; i++) {
1956 GF_Box *c = gf_list_get(children, i);
1957 if (c==a) continue;
1958 if (c->type==a->type) return GF_FALSE;
1959 }
1960 return GF_TRUE;
1961 }
1962
gf_isom_box_del_parent(GF_List ** child_boxes,GF_Box * b)1963 void gf_isom_box_del_parent(GF_List **child_boxes, GF_Box*b)
1964 {
1965 if (child_boxes) {
1966 gf_list_del_item(*child_boxes, b);
1967 if (!gf_list_count(*child_boxes)) {
1968 gf_list_del(*child_boxes);
1969 *child_boxes = NULL;
1970 }
1971 }
1972 gf_isom_box_del(b);
1973 }
1974
gf_isom_box_new_parent(GF_List ** parent,u32 code)1975 GF_Box *gf_isom_box_new_parent(GF_List **parent, u32 code)
1976 {
1977 GF_Box *b = gf_isom_box_new(code);
1978 if (!b) return NULL;
1979 if (! (*parent) ) (*parent) = gf_list_new();
1980 gf_list_add(*parent, b);
1981 return b;
1982 }
1983
gf_isom_box_freeze_order(GF_Box * box)1984 void gf_isom_box_freeze_order(GF_Box *box)
1985 {
1986 u32 i=0;
1987 GF_Box *child;
1988 if (!box) return;
1989 box->internal_flags |= GF_ISOM_ORDER_FREEZE;
1990
1991 while ((child = gf_list_enum(box->child_boxes, &i))) {
1992 gf_isom_box_freeze_order(child);
1993 }
1994
1995 }
1996 #endif /*GPAC_DISABLE_ISOM*/
1997