This file is indexed.

/usr/include/gpac/internal/isomedia_dev.h is in libgpac-dev 0.5.0+svn5324~dfsg1-1+b3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
/*
 *			GPAC - Multimedia Framework C SDK
 *
 *			Authors: Jean Le Feuvre
 *			Copyright (c) Telecom ParisTech 2000-2012
 *					All rights reserved
 *
 *  This file is part of GPAC / ISO Media File Format sub-project
 *
 *  GPAC is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  GPAC is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef _GF_ISOMEDIA_DEV_H_
#define _GF_ISOMEDIA_DEV_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <gpac/isomedia.h>

#ifndef GPAC_DISABLE_ISOM


/*the default size is 64, cause we need to handle large boxes...

the other_boxes container is by default NOT created. When parsing a box and adding
a sub-box with gf_isom_box_add_default, the list is created.
This list is destroyed befaore calling the final box destructor
This list is automatically taken into account during size() and write() functions
*/
#define GF_ISOM_BOX			\
	u32 type;			\
	u64 size;			\
	GF_List *other_boxes;	\
 
#define GF_ISOM_FULL_BOX		\
	GF_ISOM_BOX			\
	u8 version;			\
	u32 flags;			\
 
#define GF_ISOM_UUID_BOX	\
	GF_ISOM_BOX			\
	u8 uuid[16];		\
	u32 internal_4cc;		\
 
typedef struct
{
	GF_ISOM_BOX
} GF_Box;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_FullBox;

typedef struct
{
	GF_ISOM_UUID_BOX
} GF_UUIDBox;


#define ISOM_DECL_BOX_ALLOC(__TYPE, __4cc)	__TYPE *tmp; \
	GF_SAFEALLOC(tmp, __TYPE);	\
	if (tmp==NULL) return NULL;	\
	tmp->type = __4cc;


/*constructor*/
GF_Box *gf_isom_box_new(u32 boxType);

GF_Err gf_isom_box_write(GF_Box *ptr, GF_BitStream *bs);
GF_Err gf_isom_box_read(GF_Box *ptr, GF_BitStream *bs);
void gf_isom_box_del(GF_Box *ptr);
GF_Err gf_isom_box_size(GF_Box *ptr);

GF_Err gf_isom_clone_box(GF_Box *src, GF_Box **dst);

GF_Err gf_isom_parse_box(GF_Box **outBox, GF_BitStream *bs);
GF_Err gf_isom_read_box_list(GF_Box *s, GF_BitStream *bs, GF_Err (*add_box)(GF_Box *par, GF_Box *b));
GF_Err gf_isom_read_box_list_ex(GF_Box *parent, GF_BitStream *bs, GF_Err (*add_box)(GF_Box *par, GF_Box *b), u32 parent_type);
GF_Err gf_isom_box_add_default(GF_Box *a, GF_Box *subbox);

#define gf_isom_full_box_init(__pre)

//void gf_isom_full_box_init(GF_Box *ptr);

GF_Err gf_isom_box_get_size(GF_Box *ptr);
GF_Err gf_isom_full_box_get_size(GF_Box *ptr);
GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs);
GF_Err gf_isom_full_box_read(GF_Box *ptr, GF_BitStream *bs);
GF_Err gf_isom_full_box_write(GF_Box *s, GF_BitStream *bs);
void gf_isom_box_array_del(GF_List *other_boxes);
GF_Err gf_isom_box_array_write(GF_Box *parent, GF_List *list, GF_BitStream *bs);
GF_Err gf_isom_box_array_size(GF_Box *parent, GF_List *list);

enum
{
	GF_ISOM_BOX_TYPE_CO64	= GF_4CC( 'c', 'o', '6', '4' ),
	GF_ISOM_BOX_TYPE_STCO	= GF_4CC( 's', 't', 'c', 'o' ),
	GF_ISOM_BOX_TYPE_CRHD	= GF_4CC( 'c', 'r', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_CTTS	= GF_4CC( 'c', 't', 't', 's' ),
	GF_ISOM_BOX_TYPE_CPRT	= GF_4CC( 'c', 'p', 'r', 't' ),
	GF_ISOM_BOX_TYPE_CHPL	= GF_4CC( 'c', 'h', 'p', 'l' ),
	GF_ISOM_BOX_TYPE_URL	= GF_4CC( 'u', 'r', 'l', ' ' ),
	GF_ISOM_BOX_TYPE_URN	= GF_4CC( 'u', 'r', 'n', ' ' ),
	GF_ISOM_BOX_TYPE_DINF	= GF_4CC( 'd', 'i', 'n', 'f' ),
	GF_ISOM_BOX_TYPE_DREF	= GF_4CC( 'd', 'r', 'e', 'f' ),
	GF_ISOM_BOX_TYPE_STDP	= GF_4CC( 's', 't', 'd', 'p' ),
	GF_ISOM_BOX_TYPE_EDTS	= GF_4CC( 'e', 'd', 't', 's' ),
	GF_ISOM_BOX_TYPE_ELST	= GF_4CC( 'e', 'l', 's', 't' ),
	GF_ISOM_BOX_TYPE_UUID	= GF_4CC( 'u', 'u', 'i', 'd' ),
	GF_ISOM_BOX_TYPE_FREE	= GF_4CC( 'f', 'r', 'e', 'e' ),
	GF_ISOM_BOX_TYPE_HDLR	= GF_4CC( 'h', 'd', 'l', 'r' ),
	GF_ISOM_BOX_TYPE_GMHD	= GF_4CC( 'g', 'm', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_HMHD	= GF_4CC( 'h', 'm', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_HINT	= GF_4CC( 'h', 'i', 'n', 't' ),
	GF_ISOM_BOX_TYPE_MDIA	= GF_4CC( 'm', 'd', 'i', 'a' ),
	GF_ISOM_BOX_TYPE_MDAT	= GF_4CC( 'm', 'd', 'a', 't' ),
	GF_ISOM_BOX_TYPE_MDHD	= GF_4CC( 'm', 'd', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_MINF	= GF_4CC( 'm', 'i', 'n', 'f' ),
	GF_ISOM_BOX_TYPE_MOOV	= GF_4CC( 'm', 'o', 'o', 'v' ),
	GF_ISOM_BOX_TYPE_MVHD	= GF_4CC( 'm', 'v', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_STSD	= GF_4CC( 's', 't', 's', 'd' ),
	GF_ISOM_BOX_TYPE_STSZ	= GF_4CC( 's', 't', 's', 'z' ),
	GF_ISOM_BOX_TYPE_STZ2	= GF_4CC( 's', 't', 'z', '2' ),
	GF_ISOM_BOX_TYPE_STBL	= GF_4CC( 's', 't', 'b', 'l' ),
	GF_ISOM_BOX_TYPE_STSC	= GF_4CC( 's', 't', 's', 'c' ),
	GF_ISOM_BOX_TYPE_STSH	= GF_4CC( 's', 't', 's', 'h' ),
	GF_ISOM_BOX_TYPE_SKIP	= GF_4CC( 's', 'k', 'i', 'p' ),
	GF_ISOM_BOX_TYPE_SMHD	= GF_4CC( 's', 'm', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_STSS	= GF_4CC( 's', 't', 's', 's' ),
	GF_ISOM_BOX_TYPE_STTS	= GF_4CC( 's', 't', 't', 's' ),
	GF_ISOM_BOX_TYPE_TRAK	= GF_4CC( 't', 'r', 'a', 'k' ),
	GF_ISOM_BOX_TYPE_TKHD	= GF_4CC( 't', 'k', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_TREF	= GF_4CC( 't', 'r', 'e', 'f' ),
	GF_ISOM_BOX_TYPE_UDTA	= GF_4CC( 'u', 'd', 't', 'a' ),
	GF_ISOM_BOX_TYPE_VMHD	= GF_4CC( 'v', 'm', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_FTYP	= GF_4CC( 'f', 't', 'y', 'p' ),
	GF_ISOM_BOX_TYPE_PADB	= GF_4CC( 'p', 'a', 'd', 'b' ),
	GF_ISOM_BOX_TYPE_PDIN	= GF_4CC( 'p', 'd', 'i', 'n' ),
	GF_ISOM_BOX_TYPE_SDTP	= GF_4CC( 's', 'd', 't', 'p' ),
	GF_ISOM_BOX_TYPE_CSLG	= GF_4CC( 'c', 's', 'l', 'g' ),

	GF_ISOM_BOX_TYPE_SBGP	= GF_4CC( 's', 'b', 'g', 'p' ),
	GF_ISOM_BOX_TYPE_SGPD	= GF_4CC( 's', 'g', 'p', 'd' ),
	GF_ISOM_BOX_TYPE_SAIZ	= GF_4CC( 's', 'a', 'i', 'z' ),
	GF_ISOM_BOX_TYPE_SAIO	= GF_4CC( 's', 'a', 'i', 'o' ),
	GF_ISOM_BOX_TYPE_MFRA	= GF_4CC( 'm', 'f', 'r', 'a' ),

	GF_ISOM_BOX_TYPE_PSSH	= GF_4CC( 'p', 's', 's', 'h' ),
	GF_ISOM_BOX_TYPE_TENC	= GF_4CC( 't', 'e', 'n', 'c' ),

	/*Adobe's protection boxes*/
	GF_ISOM_BOX_TYPE_ADKM	= GF_4CC( 'a', 'd', 'k', 'm' ),
	GF_ISOM_BOX_TYPE_AHDR	= GF_4CC( 'a', 'h', 'd', 'r' ),
	GF_ISOM_BOX_TYPE_ADAF	= GF_4CC( 'a', 'd', 'a', 'f' ),
	GF_ISOM_BOX_TYPE_APRM	= GF_4CC( 'a', 'p', 'r', 'm' ),
	GF_ISOM_BOX_TYPE_AEIB	= GF_4CC( 'a', 'e', 'i', 'b' ),
	GF_ISOM_BOX_TYPE_AKEY	= GF_4CC( 'a', 'k', 'e', 'y' ),
	GF_ISOM_BOX_TYPE_FLXS	= GF_4CC( 'f', 'l', 'x', 's' ),

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	/*Movie Fragments*/
	GF_ISOM_BOX_TYPE_MVEX	= GF_4CC( 'm', 'v', 'e', 'x' ),
	GF_ISOM_BOX_TYPE_MEHD	= GF_4CC( 'm', 'e', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_TREX	= GF_4CC( 't', 'r', 'e', 'x' ),
	GF_ISOM_BOX_TYPE_MOOF	= GF_4CC( 'm', 'o', 'o', 'f' ),
	GF_ISOM_BOX_TYPE_MFHD	= GF_4CC( 'm', 'f', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_TRAF	= GF_4CC( 't', 'r', 'a', 'f' ),
	GF_ISOM_BOX_TYPE_TFHD	= GF_4CC( 't', 'f', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_TRUN	= GF_4CC( 't', 'r', 'u', 'n' ),
#endif

	/*MP4 extensions*/
	GF_ISOM_BOX_TYPE_DPND	= GF_4CC( 'd', 'p', 'n', 'd' ),
	GF_ISOM_BOX_TYPE_IODS	= GF_4CC( 'i', 'o', 'd', 's' ),
	GF_ISOM_BOX_TYPE_ESDS	= GF_4CC( 'e', 's', 'd', 's' ),
	GF_ISOM_BOX_TYPE_MPOD	= GF_4CC( 'm', 'p', 'o', 'd' ),
	GF_ISOM_BOX_TYPE_SYNC	= GF_4CC( 's', 'y', 'n', 'c' ),
	GF_ISOM_BOX_TYPE_IPIR	= GF_4CC( 'i', 'p', 'i', 'r' ),
	GF_ISOM_BOX_TYPE_SDHD	= GF_4CC( 's', 'd', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_ODHD	= GF_4CC( 'o', 'd', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_NMHD	= GF_4CC( 'n', 'm', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_STHD	= GF_4CC( 's', 't', 'h', 'd' ),
	GF_ISOM_BOX_TYPE_MP4S	= GF_4CC( 'm', 'p', '4', 's' ),
	GF_ISOM_BOX_TYPE_MP4A	= GF_4CC( 'm', 'p', '4', 'a' ),
	GF_ISOM_BOX_TYPE_MP4V	= GF_4CC( 'm', 'p', '4', 'v' ),


	/*AVC / H264 extension*/
	GF_ISOM_BOX_TYPE_AVCC	= GF_4CC( 'a', 'v', 'c', 'C' ),
	GF_ISOM_BOX_TYPE_BTRT	= GF_4CC( 'b', 't', 'r', 't' ),
	GF_ISOM_BOX_TYPE_M4DS	= GF_4CC( 'm', '4', 'd', 's' ),
	GF_ISOM_BOX_TYPE_PASP	= GF_4CC( 'p', 'a', 's', 'p' ),
	GF_ISOM_BOX_TYPE_AVC1	= GF_4CC( 'a', 'v', 'c', '1' ),
	GF_ISOM_BOX_TYPE_AVC2	= GF_4CC( 'a', 'v', 'c', '2' ),
	GF_ISOM_BOX_TYPE_AVC3	= GF_4CC( 'a', 'v', 'c', '3' ),
	GF_ISOM_BOX_TYPE_AVC4	= GF_4CC( 'a', 'v', 'c', '4' ),
	GF_ISOM_BOX_TYPE_SVCC	= GF_4CC( 's', 'v', 'c', 'C' ),
	GF_ISOM_BOX_TYPE_SVC1	= GF_4CC( 's', 'v', 'c', '1' ),
	GF_ISOM_BOX_TYPE_HVCC	= GF_4CC( 'h', 'v', 'c', 'C' ),
	GF_ISOM_BOX_TYPE_HVC1	= GF_4CC( 'h', 'v', 'c', '1' ),
	GF_ISOM_BOX_TYPE_HEV1	= GF_4CC( 'h', 'e', 'v', '1' ),
	GF_ISOM_BOX_TYPE_HVT1	= GF_4CC( 'h', 'v', 't', '1' ),

	GF_ISOM_BOX_TYPE_HVC2	= GF_4CC( 'h', 'v', 'c', '2' ),
	GF_ISOM_BOX_TYPE_HEV2	= GF_4CC( 'h', 'e', 'v', '2' ),
	GF_ISOM_BOX_TYPE_SHCC	= GF_4CC( 's', 'h', 'c', 'C' ),
	GF_ISOM_BOX_TYPE_SHC1	= GF_4CC( 's', 'h', 'c', '1' ),
	GF_ISOM_BOX_TYPE_SHV1	= GF_4CC( 's', 'h', 'v', '1' ),

	/*LASeR extension*/
	GF_ISOM_BOX_TYPE_LSRC	= GF_4CC( 'l', 's', 'r', 'C' ),
	GF_ISOM_BOX_TYPE_LSR1	= GF_4CC( 'l', 's', 'r', '1' ),

	/*3GPP extensions*/
	GF_ISOM_BOX_TYPE_DAMR	= GF_4CC( 'd', 'a', 'm', 'r' ),
	GF_ISOM_BOX_TYPE_D263	= GF_4CC( 'd', '2', '6', '3' ),
	GF_ISOM_BOX_TYPE_DEVC	= GF_4CC( 'd', 'e', 'v', 'c' ),
	GF_ISOM_BOX_TYPE_DQCP	= GF_4CC( 'd', 'q', 'c', 'p' ),
	GF_ISOM_BOX_TYPE_DSMV	= GF_4CC( 'd', 's', 'm', 'v' ),
	GF_ISOM_BOX_TYPE_TSEL	= GF_4CC( 't', 's', 'e', 'l' ),

	/* 3GPP Adaptive Streaming extensions */
	GF_ISOM_BOX_TYPE_STYP	= GF_4CC( 's', 't', 'y', 'p' ),
	GF_ISOM_BOX_TYPE_TFDT	= GF_4CC( 't', 'f', 'd', 't' ),
	GF_ISOM_BOX_TYPE_SIDX	= GF_4CC( 's', 'i', 'd', 'x' ),
	GF_ISOM_BOX_TYPE_PCRB	= GF_4CC( 'p', 'c', 'r', 'b' ),

	/*3GPP text / MPEG-4 StreamingText*/
	GF_ISOM_BOX_TYPE_FTAB	= GF_4CC( 'f', 't', 'a', 'b' ),
	GF_ISOM_BOX_TYPE_TX3G	= GF_4CC( 't', 'x', '3', 'g' ),
	GF_ISOM_BOX_TYPE_STYL	= GF_4CC( 's', 't', 'y', 'l' ),
	GF_ISOM_BOX_TYPE_HLIT	= GF_4CC( 'h', 'l', 'i', 't' ),
	GF_ISOM_BOX_TYPE_HCLR	= GF_4CC( 'h', 'c', 'l', 'r' ),
	GF_ISOM_BOX_TYPE_KROK	= GF_4CC( 'k', 'r', 'o', 'k' ),
	GF_ISOM_BOX_TYPE_DLAY	= GF_4CC( 'd', 'l', 'a', 'y' ),
	GF_ISOM_BOX_TYPE_HREF	= GF_4CC( 'h', 'r', 'e', 'f' ),
	GF_ISOM_BOX_TYPE_TBOX	= GF_4CC( 't', 'b', 'o', 'x' ),
	GF_ISOM_BOX_TYPE_BLNK	= GF_4CC( 'b', 'l', 'n', 'k' ),
	GF_ISOM_BOX_TYPE_TWRP	= GF_4CC( 't', 'w', 'r', 'p' ),

	/* ISO Base Media File Format Extensions for MPEG-21 */
	GF_ISOM_BOX_TYPE_META	= GF_4CC( 'm', 'e', 't', 'a' ),
	GF_ISOM_BOX_TYPE_XML	= GF_4CC( 'x', 'm', 'l', ' ' ),
	GF_ISOM_BOX_TYPE_BXML	= GF_4CC( 'b', 'x', 'm', 'l' ),
	GF_ISOM_BOX_TYPE_ILOC	= GF_4CC( 'i', 'l', 'o', 'c' ),
	GF_ISOM_BOX_TYPE_PITM	= GF_4CC( 'p', 'i', 't', 'm' ),
	GF_ISOM_BOX_TYPE_IPRO	= GF_4CC( 'i', 'p', 'r', 'o' ),
	GF_ISOM_BOX_TYPE_INFE	= GF_4CC( 'i', 'n', 'f', 'e' ),
	GF_ISOM_BOX_TYPE_IINF	= GF_4CC( 'i', 'i', 'n', 'f' ),
	GF_ISOM_BOX_TYPE_ENCA	= GF_4CC( 'e', 'n', 'c', 'a' ),
	GF_ISOM_BOX_TYPE_ENCV	= GF_4CC( 'e', 'n', 'c', 'v' ),
	GF_ISOM_BOX_TYPE_ENCT	= GF_4CC( 'e', 'n', 'c', 't' ),
	GF_ISOM_BOX_TYPE_ENCS	= GF_4CC( 'e', 'n', 'c', 's' ),
	GF_ISOM_BOX_TYPE_SINF	= GF_4CC( 's', 'i', 'n', 'f' ),
	GF_ISOM_BOX_TYPE_FRMA	= GF_4CC( 'f', 'r', 'm', 'a' ),
	GF_ISOM_BOX_TYPE_SCHM	= GF_4CC( 's', 'c', 'h', 'm' ),
	GF_ISOM_BOX_TYPE_SCHI	= GF_4CC( 's', 'c', 'h', 'i' ),

	GF_ISOM_BOX_TYPE_METX	= GF_4CC( 'm', 'e', 't', 'x' ),
	GF_ISOM_BOX_TYPE_METT	= GF_4CC( 'm', 'e', 't', 't' ),

	/* ISMA 1.0 Encryption and Authentication V 1.0 */
	GF_ISOM_BOX_TYPE_IKMS	= GF_4CC( 'i', 'K', 'M', 'S' ),
	GF_ISOM_BOX_TYPE_ISFM	= GF_4CC( 'i', 'S', 'F', 'M' ),

	/* Hinting boxes */
	GF_ISOM_BOX_TYPE_RTP_STSD	= GF_4CC( 'r', 't', 'p', ' ' ),
	GF_ISOM_BOX_TYPE_HNTI	= GF_4CC( 'h', 'n', 't', 'i' ),
	GF_ISOM_BOX_TYPE_RTP	= GF_4CC( 'r', 't', 'p', ' ' ),
	GF_ISOM_BOX_TYPE_SDP	= GF_4CC( 's', 'd', 'p', ' ' ),
	GF_ISOM_BOX_TYPE_HINF	= GF_4CC( 'h', 'i', 'n', 'f' ),
	GF_ISOM_BOX_TYPE_NAME	= GF_4CC( 'n', 'a', 'm', 'e' ),
	GF_ISOM_BOX_TYPE_TRPY	= GF_4CC( 't', 'r', 'p', 'y' ),
	GF_ISOM_BOX_TYPE_NUMP	= GF_4CC( 'n', 'u', 'm', 'p' ),
	GF_ISOM_BOX_TYPE_TOTL	= GF_4CC( 't', 'o', 't', 'l' ),
	GF_ISOM_BOX_TYPE_NPCK	= GF_4CC( 'n', 'p', 'c', 'k' ),
	GF_ISOM_BOX_TYPE_TPYL	= GF_4CC( 't', 'p', 'y', 'l' ),
	GF_ISOM_BOX_TYPE_TPAY	= GF_4CC( 't', 'p', 'a', 'y' ),
	GF_ISOM_BOX_TYPE_MAXR	= GF_4CC( 'm', 'a', 'x', 'r' ),
	GF_ISOM_BOX_TYPE_DMED	= GF_4CC( 'd', 'm', 'e', 'd' ),
	GF_ISOM_BOX_TYPE_DIMM	= GF_4CC( 'd', 'i', 'm', 'm' ),
	GF_ISOM_BOX_TYPE_DREP	= GF_4CC( 'd', 'r', 'e', 'p' ),
	GF_ISOM_BOX_TYPE_TMIN	= GF_4CC( 't', 'm', 'i', 'n' ),
	GF_ISOM_BOX_TYPE_TMAX	= GF_4CC( 't', 'm', 'a', 'x' ),
	GF_ISOM_BOX_TYPE_PMAX	= GF_4CC( 'p', 'm', 'a', 'x' ),
	GF_ISOM_BOX_TYPE_DMAX	= GF_4CC( 'd', 'm', 'a', 'x' ),
	GF_ISOM_BOX_TYPE_PAYT	= GF_4CC( 'p', 'a', 'y', 't' ),
	GF_ISOM_BOX_TYPE_RELY	= GF_4CC( 'r', 'e', 'l', 'y' ),
	GF_ISOM_BOX_TYPE_TIMS	= GF_4CC( 't', 'i', 'm', 's' ),
	GF_ISOM_BOX_TYPE_TSRO	= GF_4CC( 't', 's', 'r', 'o' ),
	GF_ISOM_BOX_TYPE_SNRO	= GF_4CC( 's', 'n', 'r', 'o' ),
	GF_ISOM_BOX_TYPE_RTPO	= GF_4CC( 'r', 't', 'p', 'o' ),

	/*internal type for track references*/
	GF_ISOM_BOX_TYPE_REFT	= GF_4CC( 'R', 'E', 'F', 'T' ),

#ifndef GPAC_DISABLE_ISOM_ADOBE
	/* Adobe extensions */
	GF_ISOM_BOX_TYPE_ABST	= GF_4CC( 'a', 'b', 's', 't' ),
	GF_ISOM_BOX_TYPE_AFRA	= GF_4CC( 'a', 'f', 'r', 'a' ),
	GF_ISOM_BOX_TYPE_ASRT	= GF_4CC( 'a', 's', 'r', 't' ),
	GF_ISOM_BOX_TYPE_AFRT	= GF_4CC( 'a', 'f', 'r', 't' ),
#endif

	/* Apple extensions */

	GF_ISOM_BOX_TYPE_ILST	= GF_4CC( 'i', 'l', 's', 't' ),
	GF_ISOM_BOX_TYPE_0xA9NAM	= GF_4CC( 0xA9, 'n', 'a', 'm' ),
	GF_ISOM_BOX_TYPE_0xA9CMT	= GF_4CC( 0xA9, 'c', 'm', 't' ),
	GF_ISOM_BOX_TYPE_0xA9DAY	= GF_4CC( 0xA9, 'd', 'a', 'y' ),
	GF_ISOM_BOX_TYPE_0xA9ART	= GF_4CC( 0xA9, 'A', 'R', 'T' ),
	GF_ISOM_BOX_TYPE_0xA9TRK	= GF_4CC( 0xA9, 't', 'r', 'k' ),
	GF_ISOM_BOX_TYPE_0xA9ALB	= GF_4CC( 0xA9, 'a', 'l', 'b' ),
	GF_ISOM_BOX_TYPE_0xA9COM	= GF_4CC( 0xA9, 'c', 'o', 'm' ),
	GF_ISOM_BOX_TYPE_0xA9WRT	= GF_4CC( 0xA9, 'w', 'r', 't' ),
	GF_ISOM_BOX_TYPE_0xA9TOO	= GF_4CC( 0xA9, 't', 'o', 'o' ),
	GF_ISOM_BOX_TYPE_0xA9CPY	= GF_4CC( 0xA9, 'c', 'p', 'y' ),
	GF_ISOM_BOX_TYPE_0xA9DES	= GF_4CC( 0xA9, 'd', 'e', 's' ),
	GF_ISOM_BOX_TYPE_0xA9GEN	= GF_4CC( 0xA9, 'g', 'e', 'n' ),
	GF_ISOM_BOX_TYPE_0xA9GRP	= GF_4CC( 0xA9, 'g', 'r', 'p' ),
	GF_ISOM_BOX_TYPE_0xA9ENC	= GF_4CC( 0xA9, 'e', 'n', 'c' ),
	GF_ISOM_BOX_TYPE_aART		= GF_4CC( 'a', 'A', 'R', 'T' ),
	GF_ISOM_BOX_TYPE_PGAP = GF_4CC( 'p', 'g', 'a', 'p' ),
	GF_ISOM_BOX_TYPE_GNRE	= GF_4CC( 'g', 'n', 'r', 'e' ),
	GF_ISOM_BOX_TYPE_DISK	= GF_4CC( 'd', 'i', 's', 'k' ),
	GF_ISOM_BOX_TYPE_TRKN	= GF_4CC( 't', 'r', 'k', 'n' ),
	GF_ISOM_BOX_TYPE_TMPO	= GF_4CC( 't', 'm', 'p', 'o' ),
	GF_ISOM_BOX_TYPE_CPIL	= GF_4CC( 'c', 'p', 'i', 'l' ),
	GF_ISOM_BOX_TYPE_COVR	= GF_4CC( 'c', 'o', 'v', 'r' ),
	GF_ISOM_BOX_TYPE_iTunesSpecificInfo	= GF_4CC( '-', '-', '-', '-' ),
	GF_ISOM_BOX_TYPE_DATA	= GF_4CC( 'd', 'a', 't', 'a' ),

	GF_ISOM_HANDLER_TYPE_MDIR	= GF_4CC( 'm', 'd', 'i', 'r' ),
	GF_ISOM_BOX_TYPE_CHAP	= GF_4CC( 'c', 'h', 'a', 'p' ),
	GF_ISOM_BOX_TYPE_TEXT	= GF_4CC( 't', 'e', 'x', 't' ),

	/*OMA (P)DCF boxes*/
	GF_ISOM_BOX_TYPE_OHDR	= GF_4CC( 'o', 'h', 'd', 'r' ),
	GF_ISOM_BOX_TYPE_GRPI	= GF_4CC( 'g', 'r', 'p', 'i' ),
	GF_ISOM_BOX_TYPE_MDRI	= GF_4CC( 'm', 'd', 'r', 'i' ),
	GF_ISOM_BOX_TYPE_ODTT	= GF_4CC( 'o', 'd', 't', 't' ),
	GF_ISOM_BOX_TYPE_ODRB	= GF_4CC( 'o', 'd', 'r', 'b' ),
	GF_ISOM_BOX_TYPE_ODKM	= GF_4CC( 'o', 'd', 'k', 'm' ),
	GF_ISOM_BOX_TYPE_ODAF	= GF_4CC( 'o', 'd', 'a', 'f' ),

	/*3GPP DIMS */
	GF_ISOM_BOX_TYPE_DIMS	= GF_4CC( 'd', 'i', 'm', 's' ),
	GF_ISOM_BOX_TYPE_DIMC	= GF_4CC( 'd', 'i', 'm', 'C' ),
	GF_ISOM_BOX_TYPE_DIST	= GF_4CC( 'd', 'i', 'S', 'T' ),


	GF_ISOM_BOX_TYPE_AC3	= GF_4CC( 'a', 'c', '-', '3' ),
	GF_ISOM_BOX_TYPE_DAC3	= GF_4CC( 'd', 'a', 'c', '3' ),
	GF_ISOM_BOX_TYPE_EC3	= GF_4CC( 'e', 'c', '-', '3' ),
	GF_ISOM_BOX_TYPE_DEC3	= GF_4CC( 'd', 'e', 'c', '3' ),

	GF_ISOM_BOX_TYPE_SUBS	= GF_4CC( 's', 'u', 'b', 's' ),

	GF_ISOM_BOX_TYPE_RVCC	= GF_4CC( 'r', 'v', 'c', 'c' ),

	GF_ISOM_BOX_TYPE_VTTC	= GF_4CC( 'v', 't', 't', 'C' ),
	GF_ISOM_BOX_TYPE_VTCU	= GF_4CC( 'v', 't', 't', 'c' ),
	GF_ISOM_BOX_TYPE_VTTE	= GF_4CC( 'v', 't', 't', 'e' ),
	GF_ISOM_BOX_TYPE_CTIM	= GF_4CC( 'c', 't', 'i', 'm' ),
	GF_ISOM_BOX_TYPE_IDEN	= GF_4CC( 'i', 'd', 'e', 'n' ),
	GF_ISOM_BOX_TYPE_STTG	= GF_4CC( 's', 't', 't', 'g' ),
	GF_ISOM_BOX_TYPE_PAYL	= GF_4CC( 'p', 'a', 'y', 'l' ),
	GF_ISOM_BOX_TYPE_WVTT	= GF_4CC( 'w', 'v', 't', 't' ),

	GF_ISOM_BOX_TYPE_STPP	= GF_4CC( 's', 't', 'p', 'p' ),
	GF_ISOM_BOX_TYPE_SBTT	= GF_4CC( 's', 'b', 't', 't' ),

	GF_ISOM_BOX_TYPE_STSE	= GF_4CC( 's', 't', 's', 'e' ),
	GF_ISOM_BOX_TYPE_STTC	= GF_4CC( 's', 't', 't', 'C' ),

	GF_ISOM_BOX_TYPE_PRFT   = GF_4CC( 'p', 'r', 'f', 't' ),

	/*ALL INTERNAL BOXES - NEVER WRITTEN TO FILE!!*/

	/*generic handlers*/
	GF_ISOM_BOX_TYPE_GNRM	= GF_4CC( 'g', 'n', 'r', 'm' ),
	GF_ISOM_BOX_TYPE_GNRV	= GF_4CC( 'g', 'n', 'r', 'v' ),
	GF_ISOM_BOX_TYPE_GNRA	= GF_4CC( 'g', 'n', 'r', 'a' ),
	/*storage of AU fragments (for MPEG-4 visual resync marker (video packets), located in stbl.*/
	GF_ISOM_BOX_TYPE_STSF	=  GF_4CC( 'S', 'T', 'S', 'F' ),
	/*base constructor of all hint formats (currently only RTP uses it)*/
	GF_ISOM_BOX_TYPE_GHNT	= GF_4CC( 'g', 'h', 'n', 't' ),
	/*for compatibility with old files hinted for DSS - needs special parsing*/
	GF_ISOM_BOX_TYPE_VOID	= GF_4CC( 'V', 'O', 'I', 'D' ),

	/*MS Smooth - these are actually UUID boxes*/
	GF_ISOM_BOX_UUID_PSSH	= GF_4CC( 'P', 'S', 'S', 'H' ),
	GF_ISOM_BOX_UUID_TENC	= GF_4CC( 'T', 'E', 'N', 'C' ),
	GF_ISOM_BOX_UUID_TFRF	= GF_4CC( 'T', 'F', 'R', 'F' ),
	GF_ISOM_BOX_UUID_TFXD	= GF_4CC( 'T', 'F', 'X', 'D' ),
};


typedef struct
{
	GF_ISOM_BOX
	/*note: the data is NEVER loaded to the mdat in this lib*/
	u64 dataSize;
	char *data;
} GF_MediaDataBox;

typedef struct
{
	GF_ISOM_BOX
	char *data;
	u32 dataSize;
} GF_UnknownBox;

typedef struct
{
	GF_ISOM_UUID_BOX
	char *data;
	u32 dataSize;
} GF_UnknownUUIDBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u64 creationTime;
	u64 modificationTime;
	u32 timeScale;
	u64 duration;
	u32 nextTrackID;
	u32 preferredRate;
	u16 preferredVolume;
	char reserved[10];
	u32 matrixA;
	u32 matrixB;
	u32 matrixU;
	u32 matrixC;
	u32 matrixD;
	u32 matrixV;
	u32 matrixW;
	u32 matrixX;
	u32 matrixY;
	u32 previewTime;
	u32 previewDuration;
	u32 posterTime;
	u32 selectionTime;
	u32 selectionDuration;
	u32 currentTime;
} GF_MovieHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_Descriptor *descriptor;
} GF_ObjectDescriptorBox;

/*used for entry list*/
typedef struct
{
	u64 segmentDuration;
	s64 mediaTime;
	u32 mediaRate;
} GF_EdtsEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *entryList;
} GF_EditListBox;

typedef struct
{
	GF_ISOM_BOX
	GF_EditListBox *editList;
} GF_EditBox;


/*used to classify boxes in the UserData GF_Box*/
typedef struct
{
	u32 boxType;
	u8 uuid[16];
	GF_List *other_boxes;
} GF_UserDataMap;

typedef struct
{
	GF_ISOM_BOX
	GF_List *recordList;
} GF_UserDataBox;

typedef struct
{
	GF_ISOM_BOX
	GF_MovieHeaderBox *mvhd;
	GF_ObjectDescriptorBox *iods;
	GF_UserDataBox *udta;
#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	struct __tag_mvex_box *mvex;
#endif
	/*meta box if any*/
	struct __tag_meta_box *meta;
	/*track boxes*/
	GF_List *trackList;

	GF_ISOFile *mov;

} GF_MovieBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u64 creationTime;
	u64 modificationTime;
	u32 trackID;
	u32 reserved1;
	u64 duration;
	u32 reserved2[2];
	u16 layer;
	u16 alternate_group;
	u16 volume;
	u16 reserved3;
	u32 matrix[9];
	u32 width, height;
} GF_TrackHeaderBox;

typedef struct
{
	GF_ISOM_BOX
} GF_TrackReferenceBox;



typedef struct
{
	GF_ISOM_BOX
	GF_UserDataBox *udta;
	GF_TrackHeaderBox *Header;
	struct __tag_media_box *Media;
	GF_EditBox *editBox;
	GF_TrackReferenceBox *References;
	/*meta box if any*/
	struct __tag_meta_box *meta;

	GF_MovieBox *moov;
	/*private for media padding*/
	u32 padding_bytes;
	/*private for editing*/
	char *name;
	/*private for editing*/
	Bool is_unpacked;
	/*private for checking dependency*/
	u32 originalFile;
	u32 originalID;

	/*private for SVC/MVC extractors resolution*/
	s32 extractor_mode;
	Bool has_base_layer;

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	u64 dts_at_seg_start;
	u32 sample_count_at_seg_start;
	Bool first_traf_merged;
	Bool present_in_scalable_segment;
#endif
} GF_TrackBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u64 creationTime;
	u64 modificationTime;
	u32 timeScale;
	u64 duration;
	char packedLanguage[4];
	u16 reserved;
} GF_MediaHeaderBox;


typedef struct
{
	GF_ISOM_FULL_BOX
	u32 reserved1;
	u32 handlerType;
	u8 reserved2[12];
	char *nameUTF8;
} GF_HandlerBox;

typedef struct __tag_media_box
{
	GF_ISOM_BOX
	GF_TrackBox *mediaTrack;
	GF_MediaHeaderBox *mediaHeader;
	GF_HandlerBox *handler;
	struct __tag_media_info_box *information;
	u64 BytesMissing;
} GF_MediaBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u64 reserved;
} GF_VideoMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 reserved;
} GF_SoundMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	/*this is used for us INTERNALLY*/
	u32 subType;
	u32 maxPDUSize;
	u32 avgPDUSize;
	u32 maxBitrate;
	u32 avgBitrate;
	u32 slidingAverageBitrate;
} GF_HintMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_MPEGMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_SubtitleMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_ODMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_OCRMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_SceneMediaHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_DataReferenceBox;

typedef struct
{
	GF_ISOM_BOX
	GF_DataReferenceBox *dref;
} GF_DataInformationBox;

#define GF_ISOM_DATAENTRY_FIELDS	\
	char *location;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_ISOM_DATAENTRY_FIELDS
} GF_DataEntryBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_ISOM_DATAENTRY_FIELDS
} GF_DataEntryURLBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_ISOM_DATAENTRY_FIELDS
	char *nameURN;
} GF_DataEntryURNBox;

typedef struct
{
	u32 sampleCount;
	u32 sampleDelta;
} GF_SttsEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_SttsEntry *entries;
	u32 nb_entries, alloc_size;

#ifndef GPAC_DISABLE_ISOM_WRITE
	/*cache for WRITE*/
	u32 w_currentSampleNum;
	u64 w_LastDTS;
#endif
	/*cache for READ*/
	u32 r_FirstSampleInEntry;
	u32 r_currentEntryIndex;
	u64 r_CurrentDTS;
} GF_TimeToSampleBox;


/*TO CHECK - it could be reasonnable to only use 16bits for both count and offset*/
typedef struct
{
	u32 sampleCount;
	s32 decodingOffset;
} GF_DttsEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_DttsEntry *entries;
	u32 nb_entries, alloc_size;

#ifndef GPAC_DISABLE_ISOM_WRITE
	u32 w_LastSampleNumber;
	/*force one sample per entry*/
	Bool unpack_mode;
#endif
	/*Cache for read*/
	u32 r_currentEntryIndex;
	u32 r_FirstSampleInEntry;
} GF_CompositionOffsetBox;


typedef struct
{
	u32 SampleNumber;
	u32 fragmentCount;
	u16 *fragmentSizes;
} GF_StsfEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *entryList;
#ifndef GPAC_DISABLE_ISOM_WRITE
	/*Cache for write*/
	GF_StsfEntry *w_currentEntry;
	u32 w_currentEntryIndex;
#endif
	/*Cache for read*/
	u32 r_currentEntryIndex;
	GF_StsfEntry *r_currentEntry;
} GF_SampleFragmentBox;


#define GF_ISOM_SAMPLE_ENTRY_FIELDS		\
	GF_ISOM_UUID_BOX					\
	u16 dataReferenceIndex;				\
	char reserved[ 6 ];					\
	GF_List *protections;

/*base sample entry box (never used but for typecasting)*/
typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
} GF_SampleEntryBox;

void gf_isom_sample_entry_init(GF_SampleEntryBox *ptr);
void gf_isom_sample_entry_predestroy(GF_SampleEntryBox *ptr);

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	/*box type as specified in the file (not this box's type!!)*/
	u32 EntryType;

	char *data;
	u32 data_size;
} GF_GenericSampleEntryBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_ESD *desc;
} GF_ESDBox;

typedef struct
{
	GF_ISOM_BOX
	u32 bufferSizeDB;
	u32 maxBitrate;
	u32 avgBitrate;
} GF_MPEG4BitRateBox;

typedef struct
{
	GF_ISOM_BOX
	GF_List *descriptors;
} GF_MPEG4ExtensionDescriptorsBox;

/*for most MPEG4 media */
typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	GF_ESDBox *esd;
	/*used for hinting when extracting the OD stream...*/
	GF_SLConfig *slc;
} GF_MPEGSampleEntryBox;

typedef struct
{
	GF_ISOM_BOX
	char *hdr;
	u32 hdr_size;
} GF_LASERConfigurationBox;


typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS

	GF_LASERConfigurationBox *lsr_config;
	GF_MPEG4BitRateBox *bitrate;
	GF_MPEG4ExtensionDescriptorsBox *descr;

	/*used for hinting when extracting the OD stream...*/
	GF_SLConfig *slc;
} GF_LASeRSampleEntryBox;

/*rewrites avcC based on the given esd - this destroys the esd*/
GF_Err LSR_UpdateESD(GF_LASeRSampleEntryBox *lsr, GF_ESD *esd);

typedef struct
{
	GF_ISOM_BOX
	u32 hSpacing;
	u32 vSpacing;
} GF_PixelAspectRatioBox;

typedef struct
{
	GF_ISOM_BOX
	u16 predefined_rvc_config;
	u32 rvc_meta_idx;
} GF_RVCConfigurationBox;

#define GF_ISOM_VISUAL_SAMPLE_ENTRY		\
	GF_ISOM_SAMPLE_ENTRY_FIELDS			\
	u16 version;						\
	u16 revision;						\
	u32 vendor;							\
	u32 temporal_quality;				\
	u32 spatial_quality;				\
	u16 Width, Height;					\
	u32 horiz_res, vert_res;			\
	u32 entry_data_size;				\
	u16 frames_per_sample;				\
	char compressor_name[33];			\
	u16 bit_depth;						\
	s16 color_table_index;				\
	GF_PixelAspectRatioBox *pasp;		\
	GF_RVCConfigurationBox *rvcc;		\
 
typedef struct
{
	GF_ISOM_VISUAL_SAMPLE_ENTRY
} GF_VisualSampleEntryBox;

void gf_isom_video_sample_entry_init(GF_VisualSampleEntryBox *ent);
GF_Err gf_isom_video_sample_entry_read(GF_VisualSampleEntryBox *ptr, GF_BitStream *bs);
#ifndef GPAC_DISABLE_ISOM_WRITE
void gf_isom_video_sample_entry_write(GF_VisualSampleEntryBox *ent, GF_BitStream *bs);
void gf_isom_video_sample_entry_size(GF_VisualSampleEntryBox *ent);
#endif

void gf_isom_sample_entry_predestroy(GF_SampleEntryBox *ptr);

typedef struct
{
	GF_ISOM_BOX
	GF_AVCConfig *config;
} GF_AVCConfigurationBox;

typedef struct
{
	GF_ISOM_BOX
	GF_HEVCConfig *config;
} GF_HEVCConfigurationBox;

typedef struct
{
	GF_ISOM_VISUAL_SAMPLE_ENTRY
	GF_ESDBox *esd;
	/*used for Publishing*/
	GF_SLConfig *slc;

	/*avc extensions - we merged with regular 'mp4v' box to handle isma E&A signaling of AVC*/
	GF_AVCConfigurationBox *avc_config;
	GF_AVCConfigurationBox *svc_config;
	/*hevc extension*/
	GF_HEVCConfigurationBox *hevc_config;
	GF_HEVCConfigurationBox *shvc_config;

	GF_MPEG4BitRateBox *bitrate;
	/*ext descriptors*/
	GF_MPEG4ExtensionDescriptorsBox *descr;
	/*internally emulated esd*/
	GF_ESD *emul_esd;
	/*iPod's hack*/
	GF_UnknownUUIDBox *ipod_ext;

} GF_MPEGVisualSampleEntryBox;

Bool gf_isom_is_nalu_based_entry(GF_MediaBox *mdia, GF_SampleEntryBox *_entry);
GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 sampleNumber, GF_MPEGVisualSampleEntryBox *entry);

/*this is the default visual sdst (to handle unknown media)*/
typedef struct
{
	GF_ISOM_VISUAL_SAMPLE_ENTRY
	/*box type as specified in the file (not this box's type!!)*/
	u32 EntryType;
	/*opaque description data (ESDS in MP4, SMI in SVQ3, ...)*/
	char *data;
	u32 data_size;
} GF_GenericVisualSampleEntryBox;


#define GF_ISOM_AUDIO_SAMPLE_ENTRY	\
	GF_ISOM_SAMPLE_ENTRY_FIELDS		\
	u16 version;					\
	u16 revision;					\
	u32 vendor;						\
	u16 channel_count;				\
	u16 bitspersample;				\
	u16 compression_id;				\
	u16 packet_size;				\
	u16 samplerate_hi;				\
	u16 samplerate_lo;				\
	u8 extensions[36];				\
 

typedef struct
{
	GF_ISOM_AUDIO_SAMPLE_ENTRY
} GF_AudioSampleEntryBox;

void gf_isom_audio_sample_entry_init(GF_AudioSampleEntryBox *ptr);
GF_Err gf_isom_audio_sample_entry_read(GF_AudioSampleEntryBox *ptr, GF_BitStream *bs);
#ifndef GPAC_DISABLE_ISOM_WRITE
void gf_isom_audio_sample_entry_write(GF_AudioSampleEntryBox *ptr, GF_BitStream *bs);
void gf_isom_audio_sample_entry_size(GF_AudioSampleEntryBox *ptr);
#endif


typedef struct
{
	GF_ISOM_AUDIO_SAMPLE_ENTRY
	GF_ESDBox *esd;
	GF_SLConfig *slc;
} GF_MPEGAudioSampleEntryBox;

typedef struct
{
	GF_ISOM_BOX
	GF_3GPConfig cfg;
} GF_3GPPConfigBox;

typedef struct
{
	GF_ISOM_AUDIO_SAMPLE_ENTRY
	GF_3GPPConfigBox *info;
} GF_3GPPAudioSampleEntryBox;

typedef struct
{
	GF_ISOM_VISUAL_SAMPLE_ENTRY
	GF_3GPPConfigBox *info;
} GF_3GPPVisualSampleEntryBox;

/*this is the default visual sdst (to handle unknown media)*/
typedef struct
{
	GF_ISOM_AUDIO_SAMPLE_ENTRY
	/*box type as specified in the file (not this box's type!!)*/
	u32 EntryType;
	/*opaque description data (ESDS in MP4, ...)*/
	char *data;
	u32 data_size;
} GF_GenericAudioSampleEntryBox;

typedef struct
{
	GF_ISOM_BOX
	GF_AC3Config cfg;
} GF_AC3ConfigBox;

typedef struct
{
	GF_ISOM_AUDIO_SAMPLE_ENTRY
	Bool is_ec3;
	GF_AC3ConfigBox *info;
} GF_AC3SampleEntryBox;


typedef struct
{
	GF_ISOM_FULL_BOX
	u8 profile;
	u8 level;
	u8 pathComponents;
	Bool fullRequestHost;
	Bool streamType;
	u8 containsRedundant;
	char *textEncoding;
	char *contentEncoding;
} GF_DIMSSceneConfigBox;

typedef struct
{
	GF_ISOM_BOX
	char *content_script_types;
} GF_DIMSScriptTypesBox;

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	GF_DIMSSceneConfigBox *config;
	GF_MPEG4BitRateBox *bitrate;
	GF_DIMSScriptTypesBox *scripts;
} GF_DIMSSampleEntryBox;


/*base sample entry box (never used but for typecasting)*/
typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	char *content_encoding;	//optional
	char *mime_type_or_namespace;	//not optional
	char *xml_schema_loc;	// optional
	GF_MPEG4BitRateBox *bitrate; // optional
} GF_MetaDataSampleEntryBox;

typedef struct
{
	GF_ISOM_FULL_BOX
} GF_SampleDescriptionBox;


typedef struct
{
	GF_ISOM_FULL_BOX
	/*if this is the compact version, sample size is actually fieldSize*/
	u32 sampleSize;
	u32 sampleCount;
	u32 alloc_size;
	u32 *sizes;
} GF_SampleSizeBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 nb_entries;
	u32 alloc_size;
	u32 *offsets;
} GF_ChunkOffsetBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 nb_entries;
	u32 alloc_size;
	u64 *offsets;
} GF_ChunkLargeOffsetBox;

typedef struct
{
	u32 firstChunk;
	u32 nextChunk;
	u32 samplesPerChunk;
	u32 sampleDescriptionIndex;
	u8 isEdited;
} GF_StscEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_StscEntry *entries;
	u32 alloc_size, nb_entries;

	/*0-based cache for READ. In WRITE mode, we always have 1 sample per chunk so no need for a cache*/
	u32 currentIndex;
	/*first sample number in this chunk*/
	u32 firstSampleInCurrentChunk;
	u32 currentChunk;
	u32 ghostNumber;
} GF_SampleToChunkBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 alloc_size, nb_entries;
	u32 *sampleNumbers;
	/*cache for READ mode (in write we realloc no matter what)*/
	u32 r_LastSyncSample;
	/*0-based index in the array*/
	u32 r_LastSampleIndex;
} GF_SyncSampleBox;

typedef struct
{
	u32 shadowedSampleNumber;
	s32 syncSampleNumber;
} GF_StshEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *entries;
	/*Cache for read mode*/
	u32 r_LastEntryIndex;
	u32 r_LastFoundSample;
} GF_ShadowSyncBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 nb_entries;
	u16 *priorities;
} GF_DegradationPriorityBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 SampleCount;
	u8 *padbits;
} GF_PaddingBitsBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 sampleCount;
	/*each dep type is packed on 1 byte*/
	u8 *sample_info;
} GF_SampleDependencyTypeBox;


typedef struct
{
	u32 subsample_size;
	u8 subsample_priority;
	u8 discardable;
	u32 reserved;
} GF_SubSampleEntry;

typedef struct
{
	u32 sample_delta;
	GF_List *SubSamples;
} GF_SubSampleInfoEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *Samples;
} GF_SubSampleInformationBox;

u32 gf_isom_sample_get_subsample_entry(GF_ISOFile *movie, u32 track, u32 sampleNumber, GF_SubSampleInfoEntry **sub_sample);
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err gf_isom_add_subsample_info(GF_SubSampleInformationBox *sub_samples, u32 sampleNumber, u32 subSampleSize, u8 priority, u32 reserved, Bool discardable);
#endif

/* Use to relate the composition and decoding timeline when signed composition is used*/
typedef struct
{
	GF_ISOM_FULL_BOX

	s32 compositionToDTSShift;
	s32 leastDecodeToDisplayDelta;
	s32 greatestDecodeToDisplayDelta;
	s32 compositionStartTime;
	s32 compositionEndTime;
} GF_CompositionToDecodeBox;

typedef struct
{
	GF_ISOM_FULL_BOX

	u32 aux_info_type;
	u32 aux_info_type_parameter;

	u8 default_sample_info_size;
	u32 sample_count;
	u8 *sample_info_size;
} GF_SampleAuxiliaryInfoSizeBox;

typedef struct
{
	GF_ISOM_FULL_BOX

	u32 aux_info_type;
	u32 aux_info_type_parameter;

	u8 default_sample_info_size;
	u32 entry_count;  //1 or stco / trun count
	u32 *offsets;
	u64 *offsets_large;

	u64 offset_first_offset_field;
} GF_SampleAuxiliaryInfoOffsetBox;


typedef struct
{
	GF_ISOM_BOX
	GF_TimeToSampleBox *TimeToSample;
	GF_CompositionOffsetBox *CompositionOffset;
	GF_CompositionToDecodeBox *CompositionToDecode;
	GF_SyncSampleBox *SyncSample;
	GF_SampleDescriptionBox *SampleDescription;
	GF_SampleSizeBox *SampleSize;
	GF_SampleToChunkBox *SampleToChunk;
	/*untyped, to handle 32 bits and 64 bits chunkOffsets*/
	GF_Box *ChunkOffset;
	GF_ShadowSyncBox *ShadowSync;
	GF_DegradationPriorityBox *DegradationPriority;
	GF_PaddingBitsBox *PaddingBits;
	GF_SampleDependencyTypeBox *SampleDep;
	GF_SampleFragmentBox *Fragments;

	GF_SubSampleInformationBox *SubSamples;

	GF_Box *piff_psec;
	GF_Box *senc;

	GF_List *sampleGroups;
	GF_List *sampleGroupsDescription;

	GF_List *sai_sizes;
	GF_List *sai_offsets;

	u32 MaxSamplePerChunk;
	u16 groupID;
	u16 trackPriority;
	u32 currentEntryIndex;

	Bool no_sync_found;
} GF_SampleTableBox;

typedef struct __tag_media_info_box
{
	GF_ISOM_BOX
	GF_DataInformationBox *dataInformation;
	GF_SampleTableBox *sampleTable;
	GF_Box *InfoHeader;
	struct __tag_data_map *scalableDataHandler;
	struct __tag_data_map *dataHandler;
	u32 dataEntryIndex;
} GF_MediaInformationBox;


typedef struct
{
	GF_ISOM_BOX
	char *data;
	u32 dataSize;
} GF_FreeSpaceBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	char packedLanguageCode[4];
	char *notice;
} GF_CopyrightBox;


typedef struct
{
	char *name;
	u64 start_time;
} GF_ChapterEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *list;
} GF_ChapterListBox;

typedef struct
{
	GF_ISOM_BOX
	u32 reference_type;
	u32 trackIDCount;
	u32 *trackIDs;
} GF_TrackReferenceTypeBox;

typedef struct
{
	GF_ISOM_BOX
	u32 majorBrand;
	u32 minorVersion;
	u32 altCount;
	u32 *altBrand;
} GF_FileTypeBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 *rates;
	u32 *times;
	u32 count;
} GF_ProgressiveDownloadBox;


/*
	3GPP streaming text boxes
*/

typedef struct
{
	GF_ISOM_BOX
	u32 entry_count;
	GF_FontRecord *fonts;
} GF_FontTableBox;

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS				\
	u32 displayFlags;
	s8 horizontal_justification;
	s8 vertical_justification;
	/*ARGB*/
	u32 back_color;
	GF_BoxRecord default_box;
	GF_StyleRecord	default_style;
	GF_FontTableBox *font_table;
} GF_Tx3gSampleEntryBox;

/*Apple specific*/
typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS				\
	u32 displayFlags;
	u32 textJustification;
	char background_color[6], foreground_color[6];
	GF_BoxRecord default_box;
	u16 fontNumber;
	u16 fontFace;
	char reserved1[8];
	u8 reserved2;
	u16 reserved3;
	char *textName; /*font name*/
} GF_TextSampleEntryBox;

typedef struct
{
	GF_ISOM_BOX
	u32 entry_count;
	GF_StyleRecord *styles;
} GF_TextStyleBox;

typedef struct
{
	GF_ISOM_BOX
	u16 startcharoffset;
	u16 endcharoffset;
} GF_TextHighlightBox;

typedef struct
{
	GF_ISOM_BOX
	/*ARGB*/
	u32 hil_color;
} GF_TextHighlightColorBox;

typedef struct
{
	u32 highlight_endtime;
	u16 start_charoffset;
	u16 end_charoffset;
} KaraokeRecord;

typedef struct
{
	GF_ISOM_BOX
	u32 highlight_starttime;
	u16 nb_entries;
	KaraokeRecord *records;
} GF_TextKaraokeBox;

typedef struct
{
	GF_ISOM_BOX
	u32 scroll_delay;
} GF_TextScrollDelayBox;

typedef struct
{
	GF_ISOM_BOX
	u16 startcharoffset;
	u16 endcharoffset;
	char *URL;
	char *URL_hint;
} GF_TextHyperTextBox;

typedef struct
{
	GF_ISOM_BOX
	GF_BoxRecord box;
} GF_TextBoxBox;

typedef struct
{
	GF_ISOM_BOX
	u16 startcharoffset;
	u16 endcharoffset;
} GF_TextBlinkBox;

typedef struct
{
	GF_ISOM_BOX
	u8 wrap_flag;
} GF_TextWrapBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 switchGroup;
	u32 *attributeList;
	u32 attributeListCount;
} GF_TrackSelectionBox;

/*
	MPEG-21 extensions
*/
typedef struct
{
	GF_ISOM_FULL_BOX
	u32 xml_length;
	char *xml;
} GF_XMLBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 data_length;
	char *data;
} GF_BinaryXMLBox;

typedef struct
{
	u64 extent_offset;
	u64 extent_length;
#ifndef GPAC_DISABLE_ISOM_WRITE
	/*for storage only*/
	u64 original_extent_offset;
#endif
} GF_ItemExtentEntry;

typedef struct
{
	u16 item_ID;
	u16 data_reference_index;
	u64 base_offset;
#ifndef GPAC_DISABLE_ISOM_WRITE
	/*for storage only*/
	u64 original_base_offset;
#endif
	GF_List *extent_entries;
} GF_ItemLocationEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	u8 offset_size;
	u8 length_size;
	u8 base_offset_size;
	GF_List *location_entries;
} GF_ItemLocationBox;

typedef	struct
{
	GF_ISOM_FULL_BOX
	u16 item_ID;
} GF_PrimaryItemBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *protection_information;
} GF_ItemProtectionBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u16 item_ID;
	u16 item_protection_index;
	/*zero-terminated strings*/
	char *item_name;
	char *content_type;
	char *content_encoding;
	// needed to actually read the resource file, but not written in the MP21 file.
	char *full_path;
	// if not 0, full_path is actually the data to write.
	u32 data_len;
} GF_ItemInfoEntryBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *item_infos;
} GF_ItemInfoBox;

typedef struct
{
	GF_ISOM_BOX
	u32 data_format;
} GF_OriginalFormatBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 scheme_type;
	u32 scheme_version;
	char *URI;
} GF_SchemeTypeBox;

/*ISMACryp specific*/
typedef struct
{
	GF_ISOM_FULL_BOX
	/*zero-terminated string*/
	char *URI;
} GF_ISMAKMSBox;

/*ISMACryp specific*/
typedef struct __isma_format_box
{
	GF_ISOM_FULL_BOX
	u8 selective_encryption;
	u8 key_indicator_length;
	u8 IV_length;
} GF_ISMASampleFormatBox;

typedef struct
{
	GF_ISOM_BOX
	GF_ISMAKMSBox *ikms;
	GF_ISMASampleFormatBox *isfm;
	struct __oma_kms_box *okms;
	struct __cenc_tenc_box *tenc;
	struct __piff_tenc_box *piff_tenc;
	struct __adobe_drm_key_management_system_box *adkm;
} GF_SchemeInformationBox;

typedef struct __tag_protect_box
{
	GF_ISOM_BOX
	GF_OriginalFormatBox *original_format;
	GF_SchemeTypeBox *scheme_type;
	GF_SchemeInformationBox *info;
} GF_ProtectionInfoBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_List *descriptors;
} GF_IPMPInfoBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	GF_IPMP_ToolList *ipmp_tools;
	GF_List *descriptors;
} GF_IPMPControlBox;


typedef struct __tag_meta_box
{
	GF_ISOM_FULL_BOX
	GF_HandlerBox *handler;
	GF_PrimaryItemBox *primary_resource;
	GF_DataInformationBox *file_locations;
	GF_ItemLocationBox *item_locations;
	GF_ItemProtectionBox *protections;
	GF_ItemInfoBox *item_infos;
	GF_IPMPControlBox *IPMP_control;
} GF_MetaBox;




#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS

/*V2 boxes - Movie Fragments*/

typedef struct
{
	GF_ISOM_FULL_BOX
	u64 fragment_duration;
} GF_MovieExtendsHeaderBox;


typedef struct __tag_mvex_box
{
	GF_ISOM_BOX
	GF_List *TrackExList;
	GF_MovieExtendsHeaderBox *mehd;
	GF_ISOFile *mov;
} GF_MovieExtendsBox;

/*the TrackExtends contains default values for the track fragments*/
typedef struct
{
	GF_ISOM_FULL_BOX
	u32 trackID;
	u32 def_sample_desc_index;
	u32 def_sample_duration;
	u32 def_sample_size;
	u32 def_sample_flags;
	GF_TrackBox *track;
} GF_TrackExtendsBox;

/*indicates the seq num of this fragment*/
typedef struct
{
	GF_ISOM_FULL_BOX
	u32 sequence_number;
} GF_MovieFragmentHeaderBox;

/*MovieFragment is a container IN THE FILE, contains 1 fragment*/
typedef struct
{
	GF_ISOM_BOX
	GF_MovieFragmentHeaderBox *mfhd;
	GF_List *TrackList;
	GF_ISOFile *mov;
	/*offset in the file of moof or mdat (whichever comes first) for this fragment*/
	u64 fragment_offset;
	u32 mdat_size;
	char *mdat;

	//temp storage of prft box
	u32 reference_track_ID;
	u64 ntp, timestamp;
} GF_MovieFragmentBox;


/*FLAGS for TRAF*/
enum
{
	GF_ISOM_TRAF_BASE_OFFSET	=	0x01,
	GF_ISOM_TRAF_SAMPLE_DESC	=	0x02,
	GF_ISOM_TRAF_SAMPLE_DUR	=	0x08,
	GF_ISOM_TRAF_SAMPLE_SIZE	=	0x10,
	GF_ISOM_TRAF_SAMPLE_FLAGS	=	0x20,
	GF_ISOM_TRAF_DUR_EMPTY	=	0x10000,
	GF_ISOM_MOOF_BASE_OFFSET	=	0x20000,
};

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 trackID;
	/* all the following are optional fields */
	u64 base_data_offset;
	u32 sample_desc_index;
	u32 def_sample_duration;
	u32 def_sample_size;
	u32 def_sample_flags;
	u32 EmptyDuration;
	u8 IFrameSwitching;
} GF_TrackFragmentHeaderBox;


typedef struct
{
	GF_ISOM_FULL_BOX
	u64 baseMediaDecodeTime;
} GF_TFBaseMediaDecodeTimeBox;

typedef struct
{
	GF_ISOM_BOX
	GF_TrackFragmentHeaderBox *tfhd;
	GF_List *TrackRuns;
	/*keep a pointer to default flags*/
	GF_TrackExtendsBox *trex;
	GF_SampleDependencyTypeBox *sdtp;
	GF_SubSampleInformationBox *subs;

	GF_List *sampleGroups;
	GF_List *sampleGroupsDescription;

	GF_List *sai_sizes;
	GF_List *sai_offsets;

	struct __piff_sample_enc_box *piff_sample_encryption;
	struct __sample_encryption_box *sample_encryption;

	/*when data caching is on*/
	u32 DataCache;
	GF_TFBaseMediaDecodeTimeBox *tfdt;

	u64 moof_start_in_bs;
} GF_TrackFragmentBox;

/*FLAGS for TRUN : specify what is written in the SampleTable of TRUN*/
enum
{
	GF_ISOM_TRUN_DATA_OFFSET	= 0x01,
	GF_ISOM_TRUN_FIRST_FLAG		= 0x04,
	GF_ISOM_TRUN_DURATION		= 0x100,
	GF_ISOM_TRUN_SIZE			= 0x200,
	GF_ISOM_TRUN_FLAGS			= 0x400,
	GF_ISOM_TRUN_CTS_OFFSET		= 0x800
};

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 sample_count;
	/*the following are optional fields */
	s32 data_offset;
	u32 first_sample_flags;
	/*can be empty*/
	GF_List *entries;

	/*in write mode with data caching*/
	GF_BitStream *cache;
} GF_TrackFragmentRunBox;

typedef struct
{
	u32 Duration;
	u32 size;
	u32 flags;
	u32 CTS_Offset;
} GF_TrunEntry;

typedef struct
{
	GF_ISOM_BOX
	u32 majorBrand;
	u32 minorVersion;
	u32 altCount;
	u32 *altBrand;
} GF_SegmentTypeBox;

#endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/


/*RTP Hint Track Sample Entry*/
typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	u16 HintTrackVersion;
	u16 LastCompatibleVersion;
	u32 MaxPacketSize;
	GF_List *HintDataTable;
	/*this is where we store the current RTP sample in read/write mode*/
	struct __tag_hint_sample *hint_sample;
	/*current hint sample in read mode, 1-based (0 is reset)*/
	u32 cur_sample;
	u32 pck_sn, ts_offset, ssrc;
	GF_TrackReferenceTypeBox *hint_ref;
} GF_HintSampleEntryBox;


typedef struct
{
	GF_ISOM_BOX
	u32 subType;
	char *sdpText;
} GF_RTPBox;

typedef struct
{
	GF_ISOM_BOX
	char *sdpText;
} GF_SDPBox;

typedef struct
{
	GF_ISOM_BOX
	s32 timeOffset;
} GF_RTPOBox;

typedef struct
{
	GF_ISOM_BOX
	GF_List *hints;
	/*contains GF_SDPBox if in track, GF_RTPBox if in movie*/
	GF_Box *SDP;
} GF_HintTrackInfoBox;

typedef struct
{
	GF_ISOM_BOX
	u8 reserved;
	u8 prefered;
	u8 required;
} GF_RelyHintBox;

/***********************************************************
			data entry tables for RTP
***********************************************************/
typedef struct
{
	GF_ISOM_BOX
	u32 timeScale;
} GF_TSHintEntryBox;

typedef struct
{
	GF_ISOM_BOX
	u32 TimeOffset;
} GF_TimeOffHintEntryBox;

typedef struct
{
	GF_ISOM_BOX
	u32 SeqOffset;
} GF_SeqOffHintEntryBox;



/***********************************************************
			hint track information boxes for RTP
***********************************************************/

/*Total number of bytes that will be sent, including 12-byte RTP headers, but not including any network headers*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbBytes;
} GF_TRPYBox;

/*32-bits version of trpy used in Darwin*/
typedef struct
{
	GF_ISOM_BOX
	u32 nbBytes;
} GF_TOTLBox;

/*Total number of network packets that will be sent*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbPackets;
} GF_NUMPBox;

/*32-bits version of nump used in Darwin*/
typedef struct
{
	GF_ISOM_BOX
	u32 nbPackets;
} GF_NPCKBox;


/*Total number of bytes that will be sent, not including 12-byte RTP headers*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbBytes;
} GF_NTYLBox;

/*32-bits version of tpyl used in Darwin*/
typedef struct
{
	GF_ISOM_BOX
	u32 nbBytes;
} GF_TPAYBox;

/*Maximum data rate in bits per second.*/
typedef struct
{
	GF_ISOM_BOX
	u32 granularity;
	u32 maxDataRate;
} GF_MAXRBox;


/*Total number of bytes from the media track to be sent*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbBytes;
} GF_DMEDBox;

/*Number of bytes of immediate data to be sent*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbBytes;
} GF_DIMMBox;


/*Number of bytes of repeated data to be sent*/
typedef struct
{
	GF_ISOM_BOX
	u64 nbBytes;
} GF_DREPBox;

/*Smallest relative transmission time, in milliseconds. signed integer for smoothing*/
typedef struct
{
	GF_ISOM_BOX
	s32 minTime;
} GF_TMINBox;

/*Largest relative transmission time, in milliseconds.*/
typedef struct
{
	GF_ISOM_BOX
	s32 maxTime;
} GF_TMAXBox;

/*Largest packet, in bytes, including 12-byte RTP header*/
typedef struct
{
	GF_ISOM_BOX
	u32 maxSize;
} GF_PMAXBox;

/*Longest packet duration, in milliseconds*/
typedef struct
{
	GF_ISOM_BOX
	u32 maxDur;
} GF_DMAXBox;

/*32-bit payload type number, followed by rtpmap payload string */
typedef struct
{
	GF_ISOM_BOX
	u32 payloadCode;
	char *payloadString;
} GF_PAYTBox;


typedef struct
{
	GF_ISOM_BOX
	char *string;
} GF_NameBox;

typedef struct
{
	GF_ISOM_BOX
} GF_HintInfoBox;

/*Apple extension*/

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 reserved;
	char *data;
	u32 dataSize;
} GF_DataBox;

typedef struct
{
	GF_ISOM_BOX
	GF_DataBox *data;
} GF_ListItemBox;

typedef struct
{
	GF_ISOM_BOX
} GF_ItemListBox;

/*OMA (P)DCF extensions*/
typedef struct
{
	GF_ISOM_FULL_BOX
	u8 EncryptionMethod;
	u8 PaddingScheme;
	u64 PlaintextLength;
	char *ContentID;
	char *RightsIssuerURL;
	char *TextualHeaders;
	u32 TextualHeadersLen;
} GF_OMADRMCommonHeaderBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u8 GKEncryptionMethod;
	char *GroupID;
	u16 GKLength;
	char *GroupKey;
} GF_OMADRMGroupIDBox;

typedef struct
{
	GF_ISOM_BOX
} GF_OMADRMMutableInformationBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	char TransactionID[16];
} GF_OMADRMTransactionTrackingBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	char *oma_ro;
	u32 oma_ro_size;
} GF_OMADRMRightsObjectBox;

/*identical*/
typedef struct __isma_format_box GF_OMADRMAUFormatBox;

typedef struct __oma_kms_box
{
	GF_ISOM_FULL_BOX
	GF_OMADRMCommonHeaderBox *hdr;
	GF_OMADRMAUFormatBox *fmt;
} GF_OMADRMKMSBox;


typedef struct
{
	Bool reference_type;
	u32 reference_size;
	u32 subsegment_duration;
	Bool starts_with_SAP;
	u32 SAP_type;
	u32 SAP_delta_time;
} GF_SIDXReference;

typedef struct __sidx_box
{
	GF_ISOM_FULL_BOX

	u32 reference_ID;
	u32 timescale;
	u64 earliest_presentation_time;
	u64 first_offset;
	u32 nb_refs;
	GF_SIDXReference *refs;
} GF_SegmentIndexBox;

typedef struct __pcrInfo_box
{
	GF_ISOM_BOX
	u32	subsegment_count;
	u64 *pcr_values;
} GF_PcrInfoBox;

#ifndef GPAC_DISABLE_ISOM_ADOBE

/*Adobe specific boxes*/
typedef struct
{
	u64 time;
	u64 offset;
} GF_AfraEntry;

typedef struct
{
	u64 time;
	u32 segment;
	u32 fragment;
	u64 afra_offset;
	u64 offset_from_afra;
} GF_GlobalAfraEntry;

typedef struct __adobe_frag_random_access_box
{
	GF_ISOM_FULL_BOX
	Bool long_ids;
	Bool long_offsets;
	Bool global_entries;
	u8 reserved;
	u32 time_scale;
	u32 entry_count;
	GF_List *local_access_entries;
	u32 global_entry_count;
	GF_List *global_access_entries;
} GF_AdobeFragRandomAccessBox;

typedef struct __adobe_bootstrap_info_box
{
	GF_ISOM_FULL_BOX
	u32 bootstrapinfo_version;
	u8 profile;
	Bool live;
	Bool update;
	u8 reserved;
	u32 time_scale;
	u64 current_media_time;
	u64 smpte_time_code_offset;
	char *movie_identifier;
	u8 server_entry_count;
	GF_List *server_entry_table;
	u8 quality_entry_count;
	GF_List *quality_entry_table;
	char *drm_data;
	char *meta_data;
	u8 segment_run_table_count;
	GF_List *segment_run_table_entries;
	u8 fragment_run_table_count;
	GF_List *fragment_run_table_entries;
} GF_AdobeBootstrapInfoBox;

typedef struct
{
	u32 first_segment;
	u32 fragment_per_segment;
} GF_AdobeSegmentRunEntry;

typedef struct __adobe_segment_run_table_box
{
	GF_ISOM_FULL_BOX
	u8 quality_entry_count;
	GF_List *quality_segment_url_modifiers;
	u32 segment_run_entry_count;
	GF_List *segment_run_entry_table;
} GF_AdobeSegmentRunTableBox;

typedef struct
{
	u32 first_fragment;
	u64 first_fragment_timestamp;
	u32 fragment_duration;
	u8 discontinuity_indicator;
} GF_AdobeFragmentRunEntry;

typedef struct __adobe_fragment_run_table_box
{
	GF_ISOM_FULL_BOX
	u32 timescale;
	u8 quality_entry_count;
	GF_List *quality_segment_url_modifiers;
	u32 fragment_run_entry_count;
	GF_List *fragment_run_entry_table;
} GF_AdobeFragmentRunTableBox;

#endif /*GPAC_DISABLE_ISOM_ADOBE*/


/***********************************************************
			Sample Groups
***********************************************************/
typedef struct
{
	u32 sample_count;
	u32 group_description_index;
} GF_SampleGroupEntry;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 grouping_type;
	u32 grouping_type_parameter;

	u32 entry_count;
	GF_SampleGroupEntry *sample_entries;

} GF_SampleGroupBox;

typedef struct
{
	GF_ISOM_FULL_BOX
	u32 grouping_type;
	u32 default_length;

	u32 default_description_index;
	GF_List *group_descriptions;
} GF_SampleGroupDescriptionBox;

/*default entry */
typedef struct
{
	u32 length;
	u8 *data;
} GF_DefaultSampleGroupDescriptionEntry;

/*VisualRandomAccessEntry - 'rap ' type*/
typedef struct
{
	u8 num_leading_samples_known;
	u8 num_leading_samples;
} GF_VisualRandomAccessEntry;

/*RollRecoveryEntry - 'roll' type*/
typedef struct
{
	s16 roll_distance;
} GF_RollRecoveryEntry;



/*
		CENC stuff
*/

/*CENCSampleEncryptionGroupEntry - 'seig' type*/
typedef struct
{
	u32 IsEncrypted;
	u8 IV_size;
	bin128 KID;
} GF_CENCSampleEncryptionGroupEntry;

typedef struct
{
	GF_ISOM_FULL_BOX

	bin128 SystemID;
	u32 KID_count;
	bin128 *KIDs;
	u32 private_data_size;
	u8 *private_data;
} GF_ProtectionSystemHeaderBox;

typedef struct __cenc_tenc_box
{
	GF_ISOM_FULL_BOX

	u32 IsEncrypted;
	u8 IV_size;
	bin128 KID;
} GF_TrackEncryptionBox;

typedef struct __piff_tenc_box
{
	GF_ISOM_UUID_BOX
	u8 version;
	u32 flags;

	u32 AlgorithmID;
	u8 IV_size;
	bin128 KID;
} GF_PIFFTrackEncryptionBox;

typedef struct
{
	GF_ISOM_UUID_BOX
	u8 version;
	u32 flags;

	bin128 SystemID;
	u32 private_data_size;
	u8 *private_data;
} GF_PIFFProtectionSystemHeaderBox;


typedef struct __piff_sample_enc_box
{
	GF_ISOM_UUID_BOX
	u8 version;
	u32 flags;

	GF_List *samp_aux_info;
	u64 bs_offset;

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	/*pointer to container traf*/
	GF_TrackFragmentBox *traf;
#endif
	/*pointer to associated saio*/
	GF_SampleAuxiliaryInfoSizeBox *cenc_saiz;
	GF_SampleAuxiliaryInfoOffsetBox *cenc_saio;

	//do NOT change order below this point or insert anything, since we cast GF_PIFFSampleEncryptionBox into GF_SampleEncryptionBox


	u32 AlgorithmID;
	u8 IV_size;
	bin128 KID;

} GF_PIFFSampleEncryptionBox;

typedef struct __sample_encryption_box
{
	GF_ISOM_UUID_BOX
	u8 version;
	u32 flags;

	GF_List *samp_aux_info;
	u64 bs_offset;

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	/*pointer to container traf*/
	GF_TrackFragmentBox *traf;
#endif
	/*pointer to associated saio*/
	GF_SampleAuxiliaryInfoSizeBox *cenc_saiz;
	GF_SampleAuxiliaryInfoOffsetBox *cenc_saio;

} GF_SampleEncryptionBox;

GF_PIFFSampleEncryptionBox *gf_isom_create_piff_psec_box(u8 version, u32 flags, u32 AlgorithmID, u8 IV_size, bin128 KID);
GF_SampleEncryptionBox * gf_isom_create_samp_enc_box(u8 version, u32 flags);

void gf_isom_cenc_get_default_info_ex(GF_TrackBox *trak, u32 sampleDescriptionIndex, u32 *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID);
GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u32 sample_number, u32 *IsEncrypted, u8 *IV_size, bin128 *KID);

GF_Err senc_Parse(GF_BitStream *bs, GF_TrackBox *trak, GF_TrackFragmentBox *traf, GF_SampleEncryptionBox *ptr);

/*
	Boxes for Adobe's protection scheme
*/
typedef struct __adobe_enc_info_box
{
	GF_ISOM_FULL_BOX
	char *enc_algo; /*spec: The encryption algorithm shall be 'AES-CBC'*/
	u8 key_length;
} GF_AdobeEncryptionInfoBox;

typedef struct __adobe_flash_access_params_box
{
	GF_ISOM_BOX
	char *metadata; /*base-64 encoded metadata used by the DRM client to retrieve decrypted key*/
} GF_AdobeFlashAccessParamsBox;

typedef struct __adobe_key_info_box
{
	GF_ISOM_FULL_BOX
	GF_AdobeFlashAccessParamsBox * params; /*spec: APSParamsBox will no longer be produced by conformaing applications*/
} GF_AdobeKeyInfoBox;

typedef struct __adobe_std_enc_params_box
{
	GF_ISOM_FULL_BOX
	GF_AdobeEncryptionInfoBox *enc_info;
	GF_AdobeKeyInfoBox *key_info;
} GF_AdobeStdEncryptionParamsBox;

typedef struct __adobe_drm_header_box
{
	GF_ISOM_FULL_BOX
	GF_AdobeStdEncryptionParamsBox *std_enc_params;
	//AdobeSignatureBox *signature; /*AdobeSignatureBox is not described*/
} GF_AdobeDRMHeaderBox;


typedef struct __adobe_drm_au_format_box
{
	GF_ISOM_FULL_BOX
	u8 selective_enc;
	u8 IV_length;
} GF_AdobeDRMAUFormatBox;

typedef struct __adobe_drm_key_management_system_box
{
	GF_ISOM_FULL_BOX
	GF_AdobeDRMHeaderBox *header;
	GF_AdobeDRMAUFormatBox *au_format;
} GF_AdobeDRMKeyManagementSystemBox;


typedef struct
{
	GF_ISOM_FULL_BOX
	u32 refTrackID;
	u64 ntp, timestamp;
} GF_ProducerReferenceTimeBox;


/*
		Data Map (media storage) stuff
*/

/*regular file IO*/
#define GF_ISOM_DATA_FILE			0x01
/*File Maping object, read-only mode on complete files (no download)*/
#define GF_ISOM_DATA_FILE_MAPPING		0x02
/*External file object. Needs implementation*/
#define GF_ISOM_DATA_FILE_EXTERN		0x03

/*Data Map modes*/
enum
{
	/*read mode*/
	GF_ISOM_DATA_MAP_READ = 1,
	/*write mode*/
	GF_ISOM_DATA_MAP_WRITE = 2,
	/*the following modes are just ways of signaling extended functionalities
	edit mode, to make sure the file is here, set to GF_ISOM_DATA_MAP_READ afterwards*/
	GF_ISOM_DATA_MAP_EDIT = 3,
	/*read-only access to the movie file: we create a file mapping object
	mode is set to GF_ISOM_DATA_MAP_READ afterwards*/
	GF_ISOM_DATA_MAP_READ_ONLY = 4,
	/*write-only access at the end of the movie - only used for movie fragments concatenation*/
	GF_ISOM_DATA_MAP_CAT = 5,
};

/*this is the DataHandler structure each data handler has its own bitstream*/
#define GF_ISOM_BASE_DATA_HANDLER	\
	u8	type;		\
	u64	curPos;		\
	u8	mode;		\
	GF_BitStream *bs;\
	char *szName;

typedef struct __tag_data_map
{
	GF_ISOM_BASE_DATA_HANDLER
} GF_DataMap;

typedef struct
{
	GF_ISOM_BASE_DATA_HANDLER
	FILE *stream;
	Bool is_stdout;
	Bool last_acces_was_read;
#ifndef GPAC_DISABLE_ISOM_WRITE
	char *temp_file;
#endif
} GF_FileDataMap;

/*file mapping handler. used if supported, only on read mode for complete files  (not in file download)*/
typedef struct
{
	GF_ISOM_BASE_DATA_HANDLER
	char *name;
	u64 file_size;
	char *byte_map;
	u64 byte_pos;
} GF_FileMappingDataMap;

GF_Err gf_isom_datamap_new(const char *location, const char *parentPath, u8 mode, GF_DataMap **outDataMap);
void gf_isom_datamap_del(GF_DataMap *ptr);
GF_Err gf_isom_datamap_open(GF_MediaBox *minf, u32 dataRefIndex, u8 Edit);
void gf_isom_datamap_close(GF_MediaInformationBox *minf);
u32 gf_isom_datamap_get_data(GF_DataMap *map, char *buffer, u32 bufferLength, u64 Offset);

/*File-based data map*/
GF_DataMap *gf_isom_fdm_new(const char *sPath, u8 mode);
void gf_isom_fdm_del(GF_FileDataMap *ptr);
u32 gf_isom_fdm_get_data(GF_FileDataMap *ptr, char *buffer, u32 bufferLength, u64 fileOffset);

#ifndef GPAC_DISABLE_ISOM_WRITE
GF_DataMap *gf_isom_fdm_new_temp(const char *sTempPath);
#endif

/*file-mapping, read only*/
GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode);
void gf_isom_fmo_del(GF_FileMappingDataMap *ptr);
u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, char *buffer, u32 bufferLength, u64 fileOffset);

#ifndef GPAC_DISABLE_ISOM_WRITE
u64 gf_isom_datamap_get_offset(GF_DataMap *map);
GF_Err gf_isom_datamap_add_data(GF_DataMap *ptr, char *data, u32 dataSize);
#endif

void gf_isom_datamap_flush(GF_DataMap *map);

/*
		Movie stuff
*/


/*time def for MP4/QT/MJ2K files*/
#define GF_ISOM_MAC_TIME_OFFSET 2082844800

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
#define GF_ISOM_FORMAT_FRAG_FLAGS(pad, sync, deg) ( ( (pad) << 17) | ( ( !(sync) ) << 16) | (deg) );
#define GF_ISOM_GET_FRAG_PAD(flag) ( (flag) >> 17) & 0x7
#define GF_ISOM_GET_FRAG_SYNC(flag) ( ! ( ( (flag) >> 16) & 0x1))
#define GF_ISOM_GET_FRAG_DEG(flag)	(flag) & 0x7FFF

#define GF_ISOM_GET_FRAG_LEAD(flag) ( (flag) >> 26) & 0x3
#define GF_ISOM_GET_FRAG_DEPENDS(flag) ( (flag) >> 24) & 0x3
#define GF_ISOM_GET_FRAG_DEPENDED(flag) ( (flag) >> 22) & 0x3
#define GF_ISOM_GET_FRAG_REDUNDANT(flag) ( (flag) >> 20) & 0x3

#define GF_ISOM_GET_FRAG_DEPEND_FLAGS(lead, depends, depended, redundant) ( (lead<<26) | (depends<<24) | (depended<<22) | (redundant<<20) )
#define GF_ISOM_RESET_FRAG_DEPEND_FLAGS(flags) flags = flags & 0xFFFFF

GF_TrackExtendsBox *GetTrex(GF_MovieBox *moov, u32 TrackID);
#endif

enum
{
	GF_ISOM_FRAG_WRITE_READY	=	0x01,
	GF_ISOM_FRAG_READ_DEBUG		=	0x02,
};

/*this is our movie object*/
struct __tag_isom {
	/*the last fatal error*/
	GF_Err LastError;
	/*the original filename*/
	char *fileName;
	/*the original file in read/edit, and also used in fragments mode
	once the first moov has been written
	Nota: this API doesn't allow fragments BEFORE the MOOV in order
	to make easily parsable files (note there could be some data (mdat) before
	the moov*/
	GF_DataMap *movieFileMap;

#ifndef GPAC_DISABLE_ISOM_WRITE
	/*the final file name*/
	char *finalName;
	/*the file where we store edited samples (for READ_WRITE and WRITE mode only)*/
	GF_DataMap *editFileMap;
	/*the interleaving time for dummy mode (in movie TimeScale)*/
	u32 interleavingTime;
#endif

	u8 openMode;
	u8 storageMode;
	/*if true 3GPP text streams are read as MPEG-4 StreamingText*/
	u8 convert_streaming_text;
	u8 is_jp2;

	Bool keep_utc;
	/*main boxes for fast access*/
	/*moov*/
	GF_MovieBox *moov;
	/*our MDAT box (one and only one when we store the file)*/
	GF_MediaDataBox *mdat;
	/*file brand (since v2, NULL means mp4 v1)*/
	GF_FileTypeBox *brand;
	/*progressive download info*/
	GF_ProgressiveDownloadBox *pdin;
	/*meta box if any*/
	GF_MetaBox *meta;

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
	u32 FragmentsFlags, NextMoofNumber;
	/*active fragment*/
	GF_MovieFragmentBox *moof;
	/*in WRITE mode, this is the current MDAT where data is written*/
	/*in READ mode this is the last valid file position before a gf_isom_box_read failed*/
	u64 current_top_box_start;
	u64 segment_start;

	GF_List *moof_list;
	Bool use_segments, moof_first, append_segment, styp_written;

	/*used when building single-indexed self initializing media segments*/
	GF_SegmentIndexBox *root_sidx;
	u64 root_sidx_offset;
	u32 root_sidx_index;

	Bool is_index_segment;

	GF_BitStream *segment_bs;
	/* 0: no moof found yet, 1: 1 moof found, 2: next moof found */
	Bool single_moof_mode;
	u32 single_moof_state;
#endif
	GF_ProducerReferenceTimeBox *last_producer_ref_time;

	/*this contains ALL the root boxes excepts fragments*/
	GF_List *TopBoxes;

	/*default track for sync of MPEG4 streams - this is the first accessed stream without OCR info - only set in READ mode*/
	s32 es_id_default_sync;

};

/*time function*/
u64 gf_isom_get_mp4time();
/*set the last error of the file. if file is NULL, set the static error (used for IO errors*/
void gf_isom_set_last_error(GF_ISOFile *the_file, GF_Err error);
GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progressive_mode);
GF_ISOFile *gf_isom_new_movie();
/*Movie and Track access functions*/
GF_TrackBox *gf_isom_get_track_from_file(GF_ISOFile *the_file, u32 trackNumber);
GF_TrackBox *gf_isom_get_track(GF_MovieBox *moov, u32 trackNumber);
GF_TrackBox *gf_isom_get_track_from_id(GF_MovieBox *moov, u32 trackID);
GF_TrackBox *gf_isom_get_track_from_original_id(GF_MovieBox *moov, u32 originalID, u32 originalFile);
u32 gf_isom_get_tracknum_from_id(GF_MovieBox *moov, u32 trackID);
/*open a movie*/
GF_ISOFile *gf_isom_open_file(const char *fileName, u32 OpenMode, const char *tmp_dir);
/*close and delete a movie*/
void gf_isom_delete_movie(GF_ISOFile *mov);
/*StreamDescription reconstruction Functions*/
GF_Err GetESD(GF_MovieBox *moov, u32 trackID, u32 StreamDescIndex, GF_ESD **outESD);
GF_Err GetESDForTime(GF_MovieBox *moov, u32 trackID, u64 CTS, GF_ESD **outESD);
GF_Err Media_GetSampleDesc(GF_MediaBox *mdia, u32 SampleDescIndex, GF_SampleEntryBox **out_entry, u32 *dataRefIndex);
GF_Err Media_GetSampleDescIndex(GF_MediaBox *mdia, u64 DTS, u32 *sampleDescIndex);
/*get esd for given sample desc -
	@true_desc_only: if true doesn't emulate desc and returns native ESD,
				otherwise emulates if needed/possible (TimedText) and return a hard copy of the desc
*/
GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **esd, Bool true_desc_only);
Bool Track_IsMPEG4Stream(u32 HandlerType);
Bool IsMP4Description(u32 entryType);
/*Find a reference of a given type*/
GF_Err Track_FindRef(GF_TrackBox *trak, u32 ReferenceType, GF_TrackReferenceTypeBox **dpnd);
/*Time and sample*/
GF_Err GetMediaTime(GF_TrackBox *trak, Bool force_non_empty, u64 movieTime, u64 *MediaTime, s64 *SegmentStartTime, s64 *MediaOffset, u8 *useEdit, u64 *next_edit_start_plus_one);
GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, u32 *sampleDescriptionIndex, Bool no_data, u64 *out_offset);
GF_Err Media_CheckDataEntry(GF_MediaBox *mdia, u32 dataEntryIndex);
GF_Err Media_FindSyncSample(GF_SampleTableBox *stbl, u32 searchFromTime, u32 *sampleNumber, u8 mode);
GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample);
GF_Err Media_FindDataRef(GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex);
Bool Media_IsSelfContained(GF_MediaBox *mdia, u32 StreamDescIndex);


GF_TrackBox *GetTrackbyID(GF_MovieBox *moov, u32 TrackID);

/*check the TimeToSample for the given time and return the Sample number
if the entry is not found, return the closest sampleNumber in prevSampleNumber and 0 in sampleNumber
if the DTS required is after all DTSs in the list, set prevSampleNumber and SampleNumber to 0
useCTS specifies that we're looking for a composition time
*/
GF_Err findEntryForTime(GF_SampleTableBox *stbl, u64 DTS, u8 useCTS, u32 *sampleNumber, u32 *prevSampleNumber);
/*Reading of the sample tables*/
GF_Err stbl_GetSampleSize(GF_SampleSizeBox *stsz, u32 SampleNumber, u32 *Size);
GF_Err stbl_GetSampleCTS(GF_CompositionOffsetBox *ctts, u32 SampleNumber, s32 *CTSoffset);
GF_Err stbl_GetSampleDTS(GF_TimeToSampleBox *stts, u32 SampleNumber, u64 *DTS);
GF_Err stbl_GetSampleDTS_and_Duration(GF_TimeToSampleBox *stts, u32 SampleNumber, u64 *DTS, u32 *duration);

/*find a RAP or set the prev / next RAPs if vars are passed*/
GF_Err stbl_GetSampleRAP(GF_SyncSampleBox *stss, u32 SampleNumber, u8 *IsRAP, u32 *prevRAP, u32 *nextRAP);
/*same as above but only look for open-gop RAPs and GDR (roll)*/
GF_Err stbl_SearchSAPs(GF_SampleTableBox *stbl, u32 SampleNumber, u8 *IsRAP, u32 *prevRAP, u32 *nextRAP);
GF_Err stbl_GetSampleInfos(GF_SampleTableBox *stbl, u32 sampleNumber, u64 *offset, u32 *chunkNumber, u32 *descIndex, u8 *isEdited);
GF_Err stbl_GetSampleShadow(GF_ShadowSyncBox *stsh, u32 *sampleNumber, u32 *syncNum);
GF_Err stbl_GetPaddingBits(GF_PaddingBitsBox *padb, u32 SampleNumber, u8 *PadBits);
u32 stbl_GetSampleFragmentCount(GF_SampleFragmentBox *stsf, u32 sampleNumber);
u32 stbl_GetSampleFragmentSize(GF_SampleFragmentBox *stsf, u32 sampleNumber, u32 FragmentIndex);
GF_Err stbl_GetSampleDepType(GF_SampleDependencyTypeBox *stbl, u32 SampleNumber, u32 *dependsOn, u32 *dependedOn, u32 *redundant);


/*unpack sample2chunk and chunk offset so that we have 1 sample per chunk (edition mode only)*/
GF_Err stbl_UnpackOffsets(GF_SampleTableBox *stbl);
GF_Err SetTrackDuration(GF_TrackBox *trak);
GF_Err Media_SetDuration(GF_TrackBox *trak);

/*rewrites 3GP samples desc as MPEG-4 ESD*/
GF_Err gf_isom_get_ttxt_esd(GF_MediaBox *mdia, GF_ESD **out_esd);
/*inserts TTU header - only used when conversion to StreamingText is on*/
GF_Err gf_isom_rewrite_text_sample(GF_ISOSample *samp, u32 sampleDescriptionIndex, u32 sample_dur);

GF_UserDataMap *udta_getEntry(GF_UserDataBox *ptr, u32 box_type, bin128 *uuid);

#ifndef GPAC_DISABLE_ISOM_WRITE

GF_Err FlushCaptureMode(GF_ISOFile *movie);
GF_Err CanAccessMovie(GF_ISOFile *movie, u32 Mode);
GF_ISOFile *gf_isom_create_movie(const char *fileName, u32 OpenMode, const char *tmp_dir);
void gf_isom_insert_moov(GF_ISOFile *file);

GF_Err WriteToFile(GF_ISOFile *movie);
GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, u32 DataReferenceIndex, GF_ESD *esd, u32 *outStreamIndex);
u8 RequestTrack(GF_MovieBox *moov, u32 TrackID);
/*Track-Media setup*/
GF_Err NewMedia(GF_MediaBox **mdia, u32 MediaType, u32 TimeScale);
GF_Err Media_ParseODFrame(GF_MediaBox *mdia, GF_ISOSample *sample, GF_ISOSample **od_samp);
GF_Err Media_AddSample(GF_MediaBox *mdia, u64 data_offset, GF_ISOSample *sample, u32 StreamDescIndex, u32 syncShadowNumber);
GF_Err Media_CreateDataRef(GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex);
/*update a media sample. ONLY in edit mode*/
GF_Err Media_UpdateSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample *sample, Bool data_only);
GF_Err Media_UpdateSampleReference(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample *sample, u64 data_offset);
/*addition in the sample tables*/
GF_Err stbl_AddDTS(GF_SampleTableBox *stbl, u64 DTS, u32 *sampleNumber, u32 LastAUDefDuration);
GF_Err stbl_AddCTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 CTSoffset);
GF_Err stbl_AddSize(GF_SampleSizeBox *stsz, u32 sampleNumber, u32 size);
GF_Err stbl_AddRAP(GF_SyncSampleBox *stss, u32 sampleNumber);
GF_Err stbl_AddShadow(GF_ShadowSyncBox *stsh, u32 sampleNumber, u32 shadowNumber);
GF_Err stbl_AddChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u32 StreamDescIndex, u64 offset);
/*NB - no add for padding, this is done only through SetPaddingBits*/

GF_Err stbl_AddSampleFragment(GF_SampleTableBox *stbl, u32 sampleNumber, u16 size);

/*update of the sample table
all these functions are called in edit and we always have 1 sample per chunk*/
GF_Err stbl_SetChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u64 offset);
GF_Err stbl_SetSampleCTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 offset);
GF_Err stbl_SetSampleSize(GF_SampleSizeBox *stsz, u32 SampleNumber, u32 size);
GF_Err stbl_SetSampleRAP(GF_SyncSampleBox *stss, u32 SampleNumber, u8 isRAP);
GF_Err stbl_SetSyncShadow(GF_ShadowSyncBox *stsh, u32 sampleNumber, u32 syncSample);
GF_Err stbl_SetPaddingBits(GF_SampleTableBox *stbl, u32 SampleNumber, u8 bits);
/*for adding fragmented samples*/
GF_Err stbl_SampleSizeAppend(GF_SampleSizeBox *stsz, u32 data_size);
/*writing of the final chunk info in edit mode*/
GF_Err stbl_SetChunkAndOffset(GF_SampleTableBox *stbl, u32 sampleNumber, u32 StreamDescIndex, GF_SampleToChunkBox *the_stsc, GF_Box **the_stco, u64 data_offset, u8 forceNewChunk);
/*EDIT LIST functions*/
GF_EdtsEntry *CreateEditEntry(u64 EditDuration, u64 MediaTime, u8 EditMode);

GF_Err stbl_SetRedundant(GF_SampleTableBox *stbl, u32 sampleNumber);
GF_Err stbl_AddRedundant(GF_SampleTableBox *stbl, u32 sampleNumber);

/*REMOVE functions*/
GF_Err stbl_RemoveDTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 LastAUDefDuration);
GF_Err stbl_RemoveCTS(GF_SampleTableBox *stbl, u32 sampleNumber);
GF_Err stbl_RemoveSize(GF_SampleSizeBox *stsz, u32 sampleNumber);
GF_Err stbl_RemoveChunk(GF_SampleTableBox *stbl, u32 sampleNumber);
GF_Err stbl_RemoveRAP(GF_SampleTableBox *stbl, u32 sampleNumber);
GF_Err stbl_RemoveShadow(GF_ShadowSyncBox *stsh, u32 sampleNumber);
GF_Err stbl_RemovePaddingBits(GF_SampleTableBox *stbl, u32 SampleNumber);
GF_Err stbl_RemoveSampleFragments(GF_SampleTableBox *stbl, u32 sampleNumber);
GF_Err stbl_RemoveRedundant(GF_SampleTableBox *stbl, u32 SampleNumber);

GF_Err gf_isom_copy_sample_group_entry_to_traf(GF_TrackFragmentBox *traf, GF_SampleTableBox *stbl, u32 grouping_type, u32 sampleGroupDescriptionIndex, Bool sgpd_in_traf);

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
GF_Err gf_isom_close_fragments(GF_ISOFile *movie);
#endif

#endif /*GPAC_DISABLE_ISOM_WRITE*/


GF_Err GetNextMediaTime(GF_TrackBox *trak, u64 movieTime, u64 *OutMovieTime);
GF_Err GetPrevMediaTime(GF_TrackBox *trak, u64 movieTime, u64 *OutMovieTime);

Bool IsHintTrack(GF_TrackBox *trak);
Bool CheckHintFormat(GF_TrackBox *trak, u32 HintType);
u32 GetHintFormat(GF_TrackBox *trak);


/*locate a box by its type or UUID*/
GF_ItemListBox *gf_ismo_locate_box(GF_List *list, u32 boxType, bin128 UUID);

GF_Err moov_AddBox(GF_Box *ptr, GF_Box *a);
GF_Err tref_AddBox(GF_Box *ptr, GF_Box *a);
GF_Err trak_AddBox(GF_Box *ptr, GF_Box *a);
GF_Err mvex_AddBox(GF_Box *ptr, GF_Box *a);
GF_Err stsd_AddBox(GF_SampleDescriptionBox *ptr, GF_Box *a);
GF_Err hnti_AddBox(GF_HintTrackInfoBox *hnti, GF_Box *a);
GF_Err udta_AddBox(GF_UserDataBox *ptr, GF_Box *a);
GF_Err edts_AddBox(GF_Box *s, GF_Box *a);
GF_Err stdp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stbl_AddBox(GF_SampleTableBox *ptr, GF_Box *a);
GF_Err sdtp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dinf_AddBox(GF_Box *s, GF_Box *a);
GF_Err minf_AddBox(GF_Box *s, GF_Box *a);
GF_Err mdia_AddBox(GF_Box *s, GF_Box *a);
GF_Err traf_AddBox(GF_Box *s, GF_Box *a);

/*rewrites avcC based on the given esd - this destroys the esd*/
GF_Err AVC_HEVC_UpdateESD(GF_MPEGVisualSampleEntryBox *avc, GF_ESD *esd);
void AVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *mdia);
void AVC_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *avc);
void HEVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *mdia);
void HEVC_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *avc);

GF_Err reftype_AddRefTrack(GF_TrackReferenceTypeBox *ref, u32 trackID, u16 *outRefIndex);

GF_XMLBox *gf_isom_get_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, Bool *is_binary);
void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, GF_TrackFragmentBox  *traf, u32 len);
void gf_isom_cenc_merge_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, u32 offset, u32 len);
Bool gf_isom_cenc_has_saiz_saio(GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf);

void gf_isom_parse_trif_info(const char *data, u32 size, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h);

#ifndef GPAC_DISABLE_ISOM_HINTING

/*
		Hinting stuff
*/

/*the HintType for each protocol*/
enum
{
	GF_ISMO_HINT_RTP	= 1,
	/*not supported yet*/
	GF_ISMO_MPEG2_TS	= 2
};

/*****************************************************
		RTP Data Entries
*****************************************************/

#define GF_ISMO_BASE_DTE_ENTRY	\
	u8 source;

typedef struct
{
	GF_ISMO_BASE_DTE_ENTRY
} GF_GenericDTE;

typedef struct
{
	GF_ISMO_BASE_DTE_ENTRY
} GF_EmptyDTE;

typedef struct
{
	GF_ISMO_BASE_DTE_ENTRY
	u8 dataLength;
	char data[14];
} GF_ImmediateDTE;

typedef struct
{
	GF_ISMO_BASE_DTE_ENTRY
	s8 trackRefIndex;
	u32 sampleNumber;
	u16 dataLength;
	u32 byteOffset;
	u16 bytesPerComp;
	u16 samplesPerComp;
} GF_SampleDTE;

typedef struct
{
	GF_ISMO_BASE_DTE_ENTRY
	s8 trackRefIndex;
	u32 streamDescIndex;
	u16 dataLength;
	u32 byteOffset;
	u32 reserved;
} GF_StreamDescDTE;

GF_GenericDTE *NewDTE(u8 type);
void DelDTE(GF_GenericDTE *dte);
GF_Err ReadDTE(GF_GenericDTE *dte, GF_BitStream *bs);
GF_Err WriteDTE(GF_GenericDTE *dte, GF_BitStream *bs);
GF_Err OffsetDTE(GF_GenericDTE *dte, u32 offset, u32 HintSampleNumber);

/*****************************************************
		RTP Sample
*****************************************************/

/*data cache when reading*/
typedef struct __tag_hint_data_cache
{
	GF_ISOSample *samp;
	GF_TrackBox *trak;
	u32 sample_num;
} GF_HintDataCache;


typedef struct __tag_hint_sample
{
	/*used internally for future protocol support (write only)*/
	u8 HintType;
	/*QT packets*/
	u16 reserved;
	GF_List *packetTable;
	char *AdditionalData;
	u32 dataLength;
	/*used internally for hinting*/
	u64 TransmissionTime;
	/*for read only, used to store samples fetched while building packets*/
	GF_List *sample_cache;
} GF_HintSample;

GF_HintSample *gf_isom_hint_sample_new(u32 ProtocolType);
void gf_isom_hint_sample_del(GF_HintSample *ptr);
GF_Err gf_isom_hint_sample_read(GF_HintSample *ptr, GF_BitStream *bs, u32 sampleSize);
GF_Err gf_isom_hint_sample_write(GF_HintSample *ptr, GF_BitStream *bs);
u32 gf_isom_hint_sample_size(GF_HintSample *ptr);


/*****************************************************
		Hint Packets (generic packet for future protocol support)
*****************************************************/
#define GF_ISOM_BASE_PACKET			\
	s32 relativeTransTime;


typedef struct
{
	GF_ISOM_BASE_PACKET
} GF_HintPacket;

GF_HintPacket *gf_isom_hint_pck_new(u8 HintType);
void gf_isom_hint_pck_del(u8 HintType, GF_HintPacket *ptr);
GF_Err gf_isom_hint_pck_read(u8 HintType, GF_HintPacket *ptr, GF_BitStream *bs);
GF_Err gf_isom_hint_pck_write(u8 HintType, GF_HintPacket *ptr, GF_BitStream *bs);
u32 gf_isom_hint_pck_size(u8 HintType, GF_HintPacket *ptr);
GF_Err gf_isom_hint_pck_offset(u8 HintType, GF_HintPacket *ptr, u32 offset, u32 HintSampleNumber);
GF_Err gf_isom_hint_pck_add_dte(u8 HintType, GF_HintPacket *ptr, GF_GenericDTE *dte, u8 AtBegin);
/*get the size of the packet AS RECONSTRUCTED BY THE SERVER (without CSRC)*/
u32 gf_isom_hint_pck_length(u8 HintType, GF_HintPacket *ptr);

/*the RTP packet*/
typedef struct
{
	GF_ISOM_BASE_PACKET

	/*RTP Header*/
	u8 P_bit;
	u8 X_bit;
	u8 M_bit;
	/*on 7 bits */
	u8 payloadType;
	u16 SequenceNumber;
	/*Hinting flags*/
	u8 B_bit;
	u8 R_bit;
	/*ExtraInfos TLVs - not really used */
	GF_List *TLV;
	/*DataTable - contains the DTEs...*/
	GF_List *DataTable;
} GF_RTPPacket;

GF_RTPPacket *gf_isom_hint_rtp_new();
void gf_isom_hint_rtp_del(GF_RTPPacket *ptr);
GF_Err gf_isom_hint_rtp_read(GF_RTPPacket *ptr, GF_BitStream *bs);
GF_Err gf_isom_hint_rtp_write(GF_RTPPacket *ptr, GF_BitStream *bs);
u32 gf_isom_hint_rtp_size(GF_RTPPacket *ptr);
GF_Err gf_isom_hint_rtp_offset(GF_RTPPacket *ptr, u32 offset, u32 HintSampleNumber);
u32 gf_isom_hint_rtp_length(GF_RTPPacket *ptr);


#endif


struct _3gpp_text_sample
{
	char *text;
	u32 len;

	GF_TextStyleBox *styles;
	/*at most one of these*/
	GF_TextHighlightColorBox *highlight_color;
	GF_TextScrollDelayBox *scroll_delay;
	GF_TextBoxBox *box;
	GF_TextWrapBox *wrap;

	GF_List *others;
	GF_TextKaraokeBox *cur_karaoke;
};

GF_TextSample *gf_isom_parse_texte_sample(GF_BitStream *bs);
GF_TextSample *gf_isom_parse_texte_sample_from_data(char *data, u32 dataLength);

struct _generic_subtitle_sample
{
	char *text;
	u32 len;
};
GF_GenericSubtitleSample *gf_isom_parse_generic_subtitle_sample(GF_BitStream *bs);
GF_GenericSubtitleSample *gf_isom_parse_generic_subtitle_sample_from_data(char *data, u32 dataLength);


/*do not throw fatal errors if boxes are duplicated, just warn and remove extra ones*/
#define ERROR_ON_DUPLICATED_BOX(__abox, __parent) {	\
		char __ptype[5];\
		strcpy(__ptype, gf_4cc_to_str(__parent->type) );\
		GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] extra box %s found in %s, deleting\n", gf_4cc_to_str(__abox->type), __ptype)); \
		gf_isom_box_del(a);\
		return GF_OK;\
	}

/*
	these are exported just in case, there should never be needed outside the lib
*/

GF_Box *reftype_New();
GF_Box *free_New();
GF_Box *mdat_New();
GF_Box *moov_New();
GF_Box *mvhd_New();
GF_Box *mdhd_New();
GF_Box *vmhd_New();
GF_Box *smhd_New();
GF_Box *hmhd_New();
GF_Box *nmhd_New();
GF_Box *stbl_New();
GF_Box *dinf_New();
GF_Box *url_New();
GF_Box *urn_New();
GF_Box *cprt_New();
GF_Box *chpl_New();
GF_Box *hdlr_New();
GF_Box *iods_New();
GF_Box *trak_New();
GF_Box *mp4s_New();
GF_Box *mp4a_New();
GF_Box *edts_New();
GF_Box *udta_New();
GF_Box *dref_New();
GF_Box *stsd_New();
GF_Box *stts_New();
GF_Box *ctts_New();
GF_Box *stsh_New();
GF_Box *elst_New();
GF_Box *stsc_New();
GF_Box *stsz_New();
GF_Box *stco_New();
GF_Box *stss_New();
GF_Box *stdp_New();
GF_Box *sdtp_New();
GF_Box *co64_New();
GF_Box *esds_New();
GF_Box *minf_New();
GF_Box *tkhd_New();
GF_Box *tref_New();
GF_Box *mdia_New();
GF_Box *defa_New();
GF_Box *uuid_New();
GF_Box *void_New();
GF_Box *stsf_New();
GF_Box *gnrm_New();
GF_Box *gnrv_New();
GF_Box *gnra_New();
GF_Box *pdin_New();

void reftype_del(GF_Box *);
void free_del(GF_Box *);
void mdat_del(GF_Box *);
void moov_del(GF_Box *);
void mvhd_del(GF_Box *);
void mdhd_del(GF_Box *);
void vmhd_del(GF_Box *);
void smhd_del(GF_Box *);
void hmhd_del(GF_Box *);
void nmhd_del(GF_Box *);
void stbl_del(GF_Box *);
void dinf_del(GF_Box *);
void url_del(GF_Box *);
void urn_del(GF_Box *);
void chpl_del(GF_Box *);
void cprt_del(GF_Box *);
void hdlr_del(GF_Box *);
void iods_del(GF_Box *);
void trak_del(GF_Box *);
void mp4s_del(GF_Box *);
void mp4v_del(GF_Box *);
void mp4a_del(GF_Box *);
void edts_del(GF_Box *);
void udta_del(GF_Box *);
void dref_del(GF_Box *);
void stsd_del(GF_Box *);
void stts_del(GF_Box *);
void ctts_del(GF_Box *);
void stsh_del(GF_Box *);
void elst_del(GF_Box *);
void stsc_del(GF_Box *);
void stsz_del(GF_Box *);
void stco_del(GF_Box *);
void stss_del(GF_Box *);
void stdp_del(GF_Box *);
void sdtp_del(GF_Box *);
void co64_del(GF_Box *);
void esds_del(GF_Box *);
void minf_del(GF_Box *);
void tkhd_del(GF_Box *);
void tref_del(GF_Box *);
void mdia_del(GF_Box *);
void defa_del(GF_Box *);
void uuid_del(GF_Box *);
void void_del(GF_Box *);
void stsf_del(GF_Box *);
void gnrm_del(GF_Box *);
void gnrv_del(GF_Box *);
void gnra_del(GF_Box *);
void pdin_del(GF_Box *);

GF_Err reftype_Write(GF_Box *s, GF_BitStream *bs);
GF_Err free_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mdat_Write(GF_Box *s, GF_BitStream *bs);
GF_Err moov_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mvhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mdhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err vmhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err smhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hmhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err nmhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stbl_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dinf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err url_Write(GF_Box *s, GF_BitStream *bs);
GF_Err urn_Write(GF_Box *s, GF_BitStream *bs);
GF_Err chpl_Write(GF_Box *s, GF_BitStream *bs);
GF_Err cprt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hdlr_Write(GF_Box *s, GF_BitStream *bs);
GF_Err iods_Write(GF_Box *s, GF_BitStream *bs);
GF_Err trak_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mp4s_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mp4v_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mp4a_Write(GF_Box *s, GF_BitStream *bs);
GF_Err edts_Write(GF_Box *s, GF_BitStream *bs);
GF_Err udta_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dref_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stsd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stts_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ctts_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stsh_Write(GF_Box *s, GF_BitStream *bs);
GF_Err elst_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stsc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stsz_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stco_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stss_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stdp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sdtp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err co64_Write(GF_Box *s, GF_BitStream *bs);
GF_Err esds_Write(GF_Box *s, GF_BitStream *bs);
GF_Err minf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tkhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tref_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mdia_Write(GF_Box *s, GF_BitStream *bs);
GF_Err defa_Write(GF_Box *s, GF_BitStream *bs);
GF_Err uuid_Write(GF_Box *s, GF_BitStream *bs);
GF_Err void_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stsf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gnrm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gnrv_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gnra_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pdin_Write(GF_Box *s, GF_BitStream *bs);

GF_Err reftype_Size(GF_Box *);
GF_Err free_Size(GF_Box *);
GF_Err mdat_Size(GF_Box *);
GF_Err moov_Size(GF_Box *);
GF_Err mvhd_Size(GF_Box *);
GF_Err mdhd_Size(GF_Box *);
GF_Err vmhd_Size(GF_Box *);
GF_Err smhd_Size(GF_Box *);
GF_Err hmhd_Size(GF_Box *);
GF_Err nmhd_Size(GF_Box *);
GF_Err stbl_Size(GF_Box *);
GF_Err dinf_Size(GF_Box *);
GF_Err url_Size(GF_Box *);
GF_Err urn_Size(GF_Box *);
GF_Err chpl_Size(GF_Box *);
GF_Err cprt_Size(GF_Box *);
GF_Err hdlr_Size(GF_Box *);
GF_Err iods_Size(GF_Box *);
GF_Err trak_Size(GF_Box *);
GF_Err mp4s_Size(GF_Box *);
GF_Err mp4v_Size(GF_Box *);
GF_Err mp4a_Size(GF_Box *);
GF_Err edts_Size(GF_Box *);
GF_Err udta_Size(GF_Box *);
GF_Err dref_Size(GF_Box *);
GF_Err stsd_Size(GF_Box *);
GF_Err stts_Size(GF_Box *);
GF_Err ctts_Size(GF_Box *);
GF_Err stsh_Size(GF_Box *);
GF_Err elst_Size(GF_Box *);
GF_Err stsc_Size(GF_Box *);
GF_Err stsz_Size(GF_Box *);
GF_Err stco_Size(GF_Box *);
GF_Err stss_Size(GF_Box *);
GF_Err stdp_Size(GF_Box *);
GF_Err sdtp_Size(GF_Box *);
GF_Err co64_Size(GF_Box *);
GF_Err esds_Size(GF_Box *);
GF_Err minf_Size(GF_Box *);
GF_Err tkhd_Size(GF_Box *);
GF_Err tref_Size(GF_Box *);
GF_Err mdia_Size(GF_Box *);
GF_Err defa_Size(GF_Box *);
GF_Err uuid_Size(GF_Box *);
GF_Err void_Size(GF_Box *);
GF_Err stsf_Size(GF_Box *);
GF_Err gnrm_Size(GF_Box *);
GF_Err gnrv_Size(GF_Box *);
GF_Err gnra_Size(GF_Box *);
GF_Err pdin_Size(GF_Box *);

GF_Err reftype_Read(GF_Box *s, GF_BitStream *bs);
GF_Err free_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mdat_Read(GF_Box *s, GF_BitStream *bs);
GF_Err moov_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mvhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mdhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err vmhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err smhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hmhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err nmhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stbl_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dinf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err url_Read(GF_Box *s, GF_BitStream *bs);
GF_Err urn_Read(GF_Box *s, GF_BitStream *bs);
GF_Err chpl_Read(GF_Box *s, GF_BitStream *bs);
GF_Err cprt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hdlr_Read(GF_Box *s, GF_BitStream *bs);
GF_Err iods_Read(GF_Box *s, GF_BitStream *bs);
GF_Err trak_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mp4s_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mp4v_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mp4a_Read(GF_Box *s, GF_BitStream *bs);
GF_Err edts_Read(GF_Box *s, GF_BitStream *bs);
GF_Err udta_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dref_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stsd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stts_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ctts_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stsh_Read(GF_Box *s, GF_BitStream *bs);
GF_Err elst_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stsc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stsz_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stco_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stss_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stdp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sdtp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err co64_Read(GF_Box *s, GF_BitStream *bs);
GF_Err esds_Read(GF_Box *s, GF_BitStream *bs);
GF_Err minf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tkhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tref_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mdia_Read(GF_Box *s, GF_BitStream *bs);
GF_Err defa_Read(GF_Box *s, GF_BitStream *bs);
GF_Err uuid_Read(GF_Box *s, GF_BitStream *bs);
GF_Err void_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stsf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pdin_Read(GF_Box *s, GF_BitStream *bs);

#ifndef GPAC_DISABLE_ISOM_HINTING

GF_Box *hinf_New();
GF_Box *trpy_New();
GF_Box *totl_New();
GF_Box *nump_New();
GF_Box *npck_New();
GF_Box *tpyl_New();
GF_Box *tpay_New();
GF_Box *maxr_New();
GF_Box *dmed_New();
GF_Box *dimm_New();
GF_Box *drep_New();
GF_Box *tmin_New();
GF_Box *tmax_New();
GF_Box *pmax_New();
GF_Box *dmax_New();
GF_Box *payt_New();
GF_Box *name_New();
GF_Box *rely_New();
GF_Box *snro_New();
GF_Box *tims_New();
GF_Box *tsro_New();
GF_Box *ghnt_New();
GF_Box *hnti_New();
GF_Box *sdp_New();
GF_Box *rtpo_New();

void hinf_del(GF_Box *s);
void trpy_del(GF_Box *s);
void totl_del(GF_Box *s);
void nump_del(GF_Box *s);
void npck_del(GF_Box *s);
void tpyl_del(GF_Box *s);
void tpay_del(GF_Box *s);
void maxr_del(GF_Box *s);
void dmed_del(GF_Box *s);
void dimm_del(GF_Box *s);
void drep_del(GF_Box *s);
void tmin_del(GF_Box *s);
void tmax_del(GF_Box *s);
void pmax_del(GF_Box *s);
void dmax_del(GF_Box *s);
void payt_del(GF_Box *s);
void name_del(GF_Box *s);
void rely_del(GF_Box *s);
void snro_del(GF_Box *s);
void tims_del(GF_Box *s);
void tsro_del(GF_Box *s);
void ghnt_del(GF_Box *s);
void hnti_del(GF_Box *a);
void sdp_del(GF_Box *a);
void rtpo_del(GF_Box *s);

GF_Err hinf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err trpy_Read(GF_Box *s, GF_BitStream *bs);
GF_Err totl_Read(GF_Box *s, GF_BitStream *bs);
GF_Err nump_Read(GF_Box *s, GF_BitStream *bs);
GF_Err npck_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tpyl_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tpay_Read(GF_Box *s, GF_BitStream *bs);
GF_Err maxr_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dmed_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dimm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err drep_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tmin_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tmax_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pmax_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dmax_Read(GF_Box *s, GF_BitStream *bs);
GF_Err payt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err name_Read(GF_Box *s, GF_BitStream *bs);
GF_Err rely_Read(GF_Box *s, GF_BitStream *bs);
GF_Err snro_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tims_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tsro_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ghnt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hnti_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sdp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err rtpo_Read(GF_Box *s, GF_BitStream *bs);

GF_Err hinf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err trpy_Write(GF_Box *s, GF_BitStream *bs);
GF_Err totl_Write(GF_Box *s, GF_BitStream *bs);
GF_Err nump_Write(GF_Box *s, GF_BitStream *bs);
GF_Err npck_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tpyl_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tpay_Write(GF_Box *s, GF_BitStream *bs);
GF_Err maxr_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dmed_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dimm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err drep_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tmin_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tmax_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pmax_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dmax_Write(GF_Box *s, GF_BitStream *bs);
GF_Err payt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err name_Write(GF_Box *s, GF_BitStream *bs);
GF_Err rely_Write(GF_Box *s, GF_BitStream *bs);
GF_Err snro_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tims_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tsro_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ghnt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hnti_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sdp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err rtpo_Write(GF_Box *s, GF_BitStream *bs);

GF_Err hinf_Size(GF_Box *s);
GF_Err trpy_Size(GF_Box *s);
GF_Err totl_Size(GF_Box *s);
GF_Err nump_Size(GF_Box *s);
GF_Err npck_Size(GF_Box *s);
GF_Err tpyl_Size(GF_Box *s);
GF_Err tpay_Size(GF_Box *s);
GF_Err maxr_Size(GF_Box *s);
GF_Err dmed_Size(GF_Box *s);
GF_Err dimm_Size(GF_Box *s);
GF_Err drep_Size(GF_Box *s);
GF_Err tmin_Size(GF_Box *s);
GF_Err tmax_Size(GF_Box *s);
GF_Err pmax_Size(GF_Box *s);
GF_Err dmax_Size(GF_Box *s);
GF_Err payt_Size(GF_Box *s);
GF_Err name_Size(GF_Box *s);
GF_Err rely_Size(GF_Box *s);
GF_Err snro_Size(GF_Box *s);
GF_Err tims_Size(GF_Box *s);
GF_Err tsro_Size(GF_Box *s);
GF_Err ghnt_Size(GF_Box *s);
GF_Err hnti_Size(GF_Box *s);
GF_Err sdp_Size(GF_Box *s);
GF_Err rtpo_Size(GF_Box *s);

#endif


GF_Box *ftyp_New();
void ftyp_del(GF_Box *s);
GF_Err ftyp_Read(GF_Box *s,GF_BitStream *bs);
GF_Err ftyp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ftyp_Size(GF_Box *s);

GF_Box *padb_New();
void padb_del(GF_Box *s);
GF_Err padb_Read(GF_Box *s, GF_BitStream *bs);
GF_Err padb_Write(GF_Box *s, GF_BitStream *bs);
GF_Err padb_Size(GF_Box *s);

GF_Box *gppa_New(u32 type);
GF_Box *gppv_New(u32 type);
GF_Box *gppc_New(u32 type);
void gppa_del(GF_Box *s);
void gppv_del(GF_Box *s);
void gppc_del(GF_Box *s);
GF_Err gppa_Read(GF_Box *s, GF_BitStream *bs);
GF_Err gppv_Read(GF_Box *s, GF_BitStream *bs);
GF_Err gppc_Read(GF_Box *s, GF_BitStream *bs);
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err gppa_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gppv_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gppc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err gppa_Size(GF_Box *s);
GF_Err gppv_Size(GF_Box *s);
GF_Err gppc_Size(GF_Box *s);
#endif


#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
GF_Box *mvex_New();
GF_Box *trex_New();
GF_Box *moof_New();
GF_Box *mfhd_New();
GF_Box *traf_New();
GF_Box *tfhd_New();
GF_Box *trun_New();
GF_Box *styp_New();

void mvex_del(GF_Box *s);
void trex_del(GF_Box *s);
void moof_del(GF_Box *s);
void mfhd_del(GF_Box *s);
void traf_del(GF_Box *s);
void tfhd_del(GF_Box *s);
void trun_del(GF_Box *s);
void styp_del(GF_Box *s);

GF_Err mvex_Read(GF_Box *s, GF_BitStream *bs);
GF_Err trex_Read(GF_Box *s, GF_BitStream *bs);
GF_Err moof_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mfhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err traf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tfhd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err trun_Read(GF_Box *s, GF_BitStream *bs);
GF_Err styp_Read(GF_Box *s, GF_BitStream *bs);

GF_Err mvex_Write(GF_Box *s, GF_BitStream *bs);
GF_Err trex_Write(GF_Box *s, GF_BitStream *bs);
GF_Err moof_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mfhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err traf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tfhd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err trun_Write(GF_Box *s, GF_BitStream *bs);
GF_Err styp_Write(GF_Box *s, GF_BitStream *bs);

GF_Err mvex_Size(GF_Box *s);
GF_Err trex_Size(GF_Box *s);
GF_Err moof_Size(GF_Box *s);
GF_Err mfhd_Size(GF_Box *s);
GF_Err traf_Size(GF_Box *s);
GF_Err tfhd_Size(GF_Box *s);
GF_Err trun_Size(GF_Box *s);
GF_Err styp_Size(GF_Box *s);


GF_Box *mehd_New();
void mehd_del(GF_Box *s);
GF_Err mehd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mehd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mehd_Size(GF_Box *s);

#endif

/*avc ext*/
GF_Box *avcc_New();
void avcc_del(GF_Box *s);
GF_Err avcc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err avcc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err avcc_Size(GF_Box *s);

GF_Box *mp4v_encv_avc_hevc_new(u32 type);

GF_Box *m4ds_New();
void m4ds_del(GF_Box *s);
GF_Err m4ds_Read(GF_Box *s, GF_BitStream *bs);
GF_Err m4ds_Write(GF_Box *s, GF_BitStream *bs);
GF_Err m4ds_Size(GF_Box *s);

GF_Box *btrt_New();
void btrt_del(GF_Box *s);
GF_Err btrt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err btrt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err btrt_Size(GF_Box *s);


/*3GPP streaming text*/
GF_Box *ftab_New();
GF_Box *tx3g_New();
GF_Box *text_New();
GF_Box *styl_New();
GF_Box *hlit_New();
GF_Box *hclr_New();
GF_Box *krok_New();
GF_Box *dlay_New();
GF_Box *href_New();
GF_Box *tbox_New();
GF_Box *blnk_New();
GF_Box *twrp_New();

void ftab_del(GF_Box *s);
void tx3g_del(GF_Box *s);
void text_del(GF_Box *s);
void styl_del(GF_Box *s);
void hlit_del(GF_Box *s);
void hclr_del(GF_Box *s);
void krok_del(GF_Box *s);
void dlay_del(GF_Box *s);
void href_del(GF_Box *s);
void tbox_del(GF_Box *s);
void blnk_del(GF_Box *s);
void twrp_del(GF_Box *s);

GF_Err ftab_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tx3g_Read(GF_Box *s, GF_BitStream *bs);
GF_Err text_Read(GF_Box *s, GF_BitStream *bs);
GF_Err styl_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hlit_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hclr_Read(GF_Box *s, GF_BitStream *bs);
GF_Err krok_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dlay_Read(GF_Box *s, GF_BitStream *bs);
GF_Err href_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tbox_Read(GF_Box *s, GF_BitStream *bs);
GF_Err blnk_Read(GF_Box *s, GF_BitStream *bs);
GF_Err twrp_Read(GF_Box *s, GF_BitStream *bs);

#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err ftab_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tx3g_Write(GF_Box *s, GF_BitStream *bs);
GF_Err text_Write(GF_Box *s, GF_BitStream *bs);
GF_Err styl_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hlit_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hclr_Write(GF_Box *s, GF_BitStream *bs);
GF_Err krok_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dlay_Write(GF_Box *s, GF_BitStream *bs);
GF_Err href_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tbox_Write(GF_Box *s, GF_BitStream *bs);
GF_Err blnk_Write(GF_Box *s, GF_BitStream *bs);
GF_Err twrp_Write(GF_Box *s, GF_BitStream *bs);

GF_Err ftab_Size(GF_Box *s);
GF_Err tx3g_Size(GF_Box *s);
GF_Err text_Size(GF_Box *s);
GF_Err styl_Size(GF_Box *s);
GF_Err hlit_Size(GF_Box *s);
GF_Err hclr_Size(GF_Box *s);
GF_Err krok_Size(GF_Box *s);
GF_Err dlay_Size(GF_Box *s);
GF_Err href_Size(GF_Box *s);
GF_Err tbox_Size(GF_Box *s);
GF_Err blnk_Size(GF_Box *s);
GF_Err twrp_Size(GF_Box *s);
#endif

#ifndef GPAC_DISABLE_VTT
/*WebVTT boxes*/
GF_Box *boxstring_New(u32 type);
GF_Box *vtcu_New();
GF_Box *vtte_New();
GF_Box *wvtt_New();

void boxstring_del(GF_Box *s);
void vtcu_del(GF_Box *s);
void vtte_del(GF_Box *s);
void wvtt_del(GF_Box *s);

GF_Err boxstring_Read(GF_Box *s, GF_BitStream *bs);
GF_Err vtcu_Read(GF_Box *s, GF_BitStream *bs);
GF_Err vtte_Read(GF_Box *s, GF_BitStream *bs);
GF_Err wvtt_Read(GF_Box *s, GF_BitStream *bs);

#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err boxstring_Write(GF_Box *s, GF_BitStream *bs);
GF_Err vtcu_Write(GF_Box *s, GF_BitStream *bs);
GF_Err vtte_Write(GF_Box *s, GF_BitStream *bs);
GF_Err wvtt_Write(GF_Box *s, GF_BitStream *bs);

GF_Err boxstring_Size(GF_Box *s);
GF_Err vtcu_Size(GF_Box *s);
GF_Err vtte_Size(GF_Box *s);
GF_Err wvtt_Size(GF_Box *s);
#endif /* GPAC_DISABLE_ISOM_WRITE */

GF_Err boxstring_dump(GF_Box *a, FILE * trace);
GF_Err vtcu_dump(GF_Box *a, FILE * trace);
GF_Err vtte_dump(GF_Box *a, FILE * trace);
GF_Err wvtt_dump(GF_Box *a, FILE * trace);

GF_Err gf_isom_update_webvtt_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, const char *config);
GF_ISOSample *gf_isom_webvtt_to_sample(void *samp);

typedef struct
{
	GF_ISOM_BOX
	char *string;
} GF_StringBox;

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	GF_StringBox *config;
} GF_WebVTTSampleEntryBox;

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	char *xmlnamespace;			// not optional
	char *schema_location;		// optional
	char *auxiliary_mime_types;	// optional
	GF_MPEG4BitRateBox *bitrate;// not optional
} GF_XMLSubtitleSampleEntryBox;

typedef struct
{
	GF_ISOM_SAMPLE_ENTRY_FIELDS
	char *content_encoding;			//optional
	char *mime_type;				//not optional
	GF_MPEG4BitRateBox *bitrate;	// optional
	GF_StringBox *config;
} GF_SimpleTextSampleEntryBox;

GF_List *gf_webvtt_parse_cues_from_data(const char *data, u32 dataLength, u64 start);

#endif /* GPAC_DISABLE_VTT */

/* MPEG-21 functions */
GF_Box *meta_New();
GF_Box *xml_New();
GF_Box *bxml_New();
GF_Box *iloc_New();
GF_Box *pitm_New();
GF_Box *ipro_New();
GF_Box *infe_New();
GF_Box *iinf_New();
GF_Box *sinf_New();
GF_Box *frma_New();
GF_Box *schm_New();
GF_Box *schi_New();
GF_Box *enca_New();
GF_Box *encs_New();

void meta_del(GF_Box *s);
void xml_del(GF_Box *s);
void bxml_del(GF_Box *s);
void iloc_entry_del(GF_ItemLocationEntry *location);
void iloc_del(GF_Box *s);
void pitm_del(GF_Box *s);
void ipro_del(GF_Box *s);
void infe_del(GF_Box *s);
void iinf_del(GF_Box *s);
void sinf_del(GF_Box *s);
void frma_del(GF_Box *s);
void schm_del(GF_Box *s);
void schi_del(GF_Box *s);

GF_Err meta_Read(GF_Box *s, GF_BitStream *bs);
GF_Err xml_Read(GF_Box *s, GF_BitStream *bs);
GF_Err bxml_Read(GF_Box *s, GF_BitStream *bs);
GF_Err iloc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pitm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ipro_Read(GF_Box *s, GF_BitStream *bs);
GF_Err infe_Read(GF_Box *s, GF_BitStream *bs);
GF_Err iinf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sinf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err frma_Read(GF_Box *s, GF_BitStream *bs);
GF_Err schm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err schi_Read(GF_Box *s, GF_BitStream *bs);

#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err meta_Write(GF_Box *s, GF_BitStream *bs);
GF_Err xml_Write(GF_Box *s, GF_BitStream *bs);
GF_Err bxml_Write(GF_Box *s, GF_BitStream *bs);
GF_Err iloc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pitm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ipro_Write(GF_Box *s, GF_BitStream *bs);
GF_Err infe_Write(GF_Box *s, GF_BitStream *bs);
GF_Err iinf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sinf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err frma_Write(GF_Box *s, GF_BitStream *bs);
GF_Err schm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err schi_Write(GF_Box *s, GF_BitStream *bs);

GF_Err meta_Size(GF_Box *s);
GF_Err xml_Size(GF_Box *s);
GF_Err bxml_Size(GF_Box *s);
GF_Err iloc_Size(GF_Box *s);
GF_Err pitm_Size(GF_Box *s);
GF_Err ipro_Size(GF_Box *s);
GF_Err infe_Size(GF_Box *s);
GF_Err iinf_Size(GF_Box *s);
GF_Err sinf_Size(GF_Box *s);
GF_Err frma_Size(GF_Box *s);
GF_Err schm_Size(GF_Box *s);
GF_Err schi_Size(GF_Box *s);
#endif

/* end of MPEG-21 functions */


/** ISMACryp functions **/
GF_Box *iKMS_New();
GF_Box *iSFM_New();
void iKMS_del(GF_Box *s);
void iSFM_del(GF_Box *s);
GF_Err iKMS_Read(GF_Box *s, GF_BitStream *bs);
GF_Err iSFM_Read(GF_Box *s, GF_BitStream *bs);
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err iKMS_Write(GF_Box *s, GF_BitStream *bs);
GF_Err iSFM_Write(GF_Box *s, GF_BitStream *bs);
GF_Err iKMS_Size(GF_Box *s);
GF_Err iSFM_Size(GF_Box *s);
#endif

#ifndef GPAC_DISABLE_ISOM_ADOBE
/* Adobe extensions */
void abst_del(GF_Box *s);
GF_Err abst_Read(GF_Box *s, GF_BitStream *bs);
GF_Box *abst_New();
void afra_del(GF_Box *s);
GF_Err afra_Read(GF_Box *s, GF_BitStream *bs);
GF_Box *afra_New();
void asrt_del(GF_Box *s);
GF_Err asrt_Read(GF_Box *s, GF_BitStream *bs);
GF_Box *asrt_New();
void afrt_del(GF_Box *s);
GF_Err afrt_Read(GF_Box *s, GF_BitStream *bs);
GF_Box *afrt_New();
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err abst_Write(GF_Box *s, GF_BitStream *bs);
GF_Err abst_Size(GF_Box *s);
GF_Err afra_Write(GF_Box *s, GF_BitStream *bs);
GF_Err afra_Size(GF_Box *s);
GF_Err asrt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err asrt_Size(GF_Box *s);
GF_Err afrt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err afrt_Size(GF_Box *s);
#endif
#endif /*GPAC_DISABLE_ISOM_ADOBE*/

/* Apple extensions */
void ilst_del(GF_Box *s);
void ListItem_del(GF_Box *s);
void data_del(GF_Box *s);
GF_Err ilst_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ListItem_Read(GF_Box *s, GF_BitStream *bs);
GF_Err data_Read(GF_Box *s, GF_BitStream *bs);
GF_Box *ilst_New();
GF_Box *ListItem_New(u32 type);
GF_Box *data_New();
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err ilst_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ListItem_Write(GF_Box *s, GF_BitStream *bs);
GF_Err data_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ilst_Size(GF_Box *s);
GF_Err ListItem_Size(GF_Box *s);
GF_Err data_Size(GF_Box *s);
#endif

GF_Err gf_box_dump(void *ptr, FILE * trace);

GF_Err gb_box_array_dump(GF_List *list, FILE * trace);
GF_Err reftype_dump(GF_Box *a, FILE * trace);
GF_Err free_dump(GF_Box *a, FILE * trace);
GF_Err mdat_dump(GF_Box *a, FILE * trace);
GF_Err moov_dump(GF_Box *a, FILE * trace);
GF_Err mvhd_dump(GF_Box *a, FILE * trace);
GF_Err mdhd_dump(GF_Box *a, FILE * trace);
GF_Err vmhd_dump(GF_Box *a, FILE * trace);
GF_Err smhd_dump(GF_Box *a, FILE * trace);
GF_Err hmhd_dump(GF_Box *a, FILE * trace);
GF_Err nmhd_dump(GF_Box *a, FILE * trace);
GF_Err stbl_dump(GF_Box *a, FILE * trace);
GF_Err dinf_dump(GF_Box *a, FILE * trace);
GF_Err url_dump(GF_Box *a, FILE * trace);
GF_Err urn_dump(GF_Box *a, FILE * trace);
GF_Err cprt_dump(GF_Box *a, FILE * trace);
GF_Err hdlr_dump(GF_Box *a, FILE * trace);
GF_Err iods_dump(GF_Box *a, FILE * trace);
GF_Err trak_dump(GF_Box *a, FILE * trace);
GF_Err mp4s_dump(GF_Box *a, FILE * trace);
GF_Err mp4v_dump(GF_Box *a, FILE * trace);
GF_Err mp4a_dump(GF_Box *a, FILE * trace);
GF_Err edts_dump(GF_Box *a, FILE * trace);
GF_Err udta_dump(GF_Box *a, FILE * trace);
GF_Err dref_dump(GF_Box *a, FILE * trace);
GF_Err stsd_dump(GF_Box *a, FILE * trace);
GF_Err stts_dump(GF_Box *a, FILE * trace);
GF_Err ctts_dump(GF_Box *a, FILE * trace);
GF_Err stsh_dump(GF_Box *a, FILE * trace);
GF_Err elst_dump(GF_Box *a, FILE * trace);
GF_Err stsc_dump(GF_Box *a, FILE * trace);
GF_Err stsz_dump(GF_Box *a, FILE * trace);
GF_Err stco_dump(GF_Box *a, FILE * trace);
GF_Err stss_dump(GF_Box *a, FILE * trace);
GF_Err stdp_dump(GF_Box *a, FILE * trace);
GF_Err sdtp_dump(GF_Box *a, FILE * trace);
GF_Err co64_dump(GF_Box *a, FILE * trace);
GF_Err esds_dump(GF_Box *a, FILE * trace);
GF_Err minf_dump(GF_Box *a, FILE * trace);
GF_Err tkhd_dump(GF_Box *a, FILE * trace);
GF_Err tref_dump(GF_Box *a, FILE * trace);
GF_Err mdia_dump(GF_Box *a, FILE * trace);
GF_Err defa_dump(GF_Box *a, FILE * trace);
GF_Err void_dump(GF_Box *a, FILE * trace);
GF_Err ftyp_dump(GF_Box *a, FILE * trace);
GF_Err padb_dump(GF_Box *a, FILE * trace);
GF_Err stsf_dump(GF_Box *a, FILE * trace);
GF_Err gnrm_dump(GF_Box *a, FILE * trace);
GF_Err gnrv_dump(GF_Box *a, FILE * trace);
GF_Err gnra_dump(GF_Box *a, FILE * trace);
GF_Err gppa_dump(GF_Box *a, FILE * trace);
GF_Err gppv_dump(GF_Box *a, FILE * trace);
GF_Err gppc_dump(GF_Box *a, FILE * trace);
GF_Err chpl_dump(GF_Box *a, FILE * trace);
GF_Err dpin_dump(GF_Box *a, FILE * trace);

GF_Err hinf_dump(GF_Box *a, FILE * trace);
GF_Err trpy_dump(GF_Box *a, FILE * trace);
GF_Err totl_dump(GF_Box *a, FILE * trace);
GF_Err nump_dump(GF_Box *a, FILE * trace);
GF_Err npck_dump(GF_Box *a, FILE * trace);
GF_Err tpyl_dump(GF_Box *a, FILE * trace);
GF_Err tpay_dump(GF_Box *a, FILE * trace);
GF_Err maxr_dump(GF_Box *a, FILE * trace);
GF_Err dmed_dump(GF_Box *a, FILE * trace);
GF_Err dimm_dump(GF_Box *a, FILE * trace);
GF_Err drep_dump(GF_Box *a, FILE * trace);
GF_Err tmin_dump(GF_Box *a, FILE * trace);
GF_Err tmax_dump(GF_Box *a, FILE * trace);
GF_Err pmax_dump(GF_Box *a, FILE * trace);
GF_Err dmax_dump(GF_Box *a, FILE * trace);
GF_Err payt_dump(GF_Box *a, FILE * trace);
GF_Err name_dump(GF_Box *a, FILE * trace);
GF_Err rely_dump(GF_Box *a, FILE * trace);
GF_Err snro_dump(GF_Box *a, FILE * trace);
GF_Err tims_dump(GF_Box *a, FILE * trace);
GF_Err tsro_dump(GF_Box *a, FILE * trace);
GF_Err ghnt_dump(GF_Box *a, FILE * trace);
GF_Err hnti_dump(GF_Box *a, FILE * trace);
GF_Err sdp_dump(GF_Box *a, FILE * trace);
GF_Err rtpo_dump(GF_Box *a, FILE * trace);



#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
GF_Err mvex_dump(GF_Box *a, FILE * trace);
GF_Err mehd_dump(GF_Box *a, FILE * trace);
GF_Err trex_dump(GF_Box *a, FILE * trace);
GF_Err moof_dump(GF_Box *a, FILE * trace);
GF_Err mfhd_dump(GF_Box *a, FILE * trace);
GF_Err traf_dump(GF_Box *a, FILE * trace);
GF_Err tfhd_dump(GF_Box *a, FILE * trace);
GF_Err trun_dump(GF_Box *a, FILE * trace);
GF_Err styp_dump(GF_Box *a, FILE * trace);
#endif

GF_Err avcc_dump(GF_Box *a, FILE * trace);
GF_Err avc1_dump(GF_Box *a, FILE * trace);
GF_Err m4ds_dump(GF_Box *a, FILE * trace);
GF_Err btrt_dump(GF_Box *a, FILE * trace);

GF_Err ftab_dump(GF_Box *a, FILE * trace);
GF_Err tx3g_dump(GF_Box *a, FILE * trace);
GF_Err text_dump(GF_Box *a, FILE * trace);
GF_Err styl_dump(GF_Box *a, FILE * trace);
GF_Err hlit_dump(GF_Box *a, FILE * trace);
GF_Err hclr_dump(GF_Box *a, FILE * trace);
GF_Err krok_dump(GF_Box *a, FILE * trace);
GF_Err dlay_dump(GF_Box *a, FILE * trace);
GF_Err href_dump(GF_Box *a, FILE * trace);
GF_Err tbox_dump(GF_Box *a, FILE * trace);
GF_Err blnk_dump(GF_Box *a, FILE * trace);
GF_Err twrp_dump(GF_Box *a, FILE * trace);

/* ISMACryp dump */
GF_Err iKMS_dump(GF_Box *a, FILE * trace);
GF_Err iSFM_dump(GF_Box *a, FILE * trace);

/*MPEG-21 extensions dump*/
GF_Err meta_dump(GF_Box *a, FILE * trace);
GF_Err xml_dump(GF_Box *a, FILE * trace);
GF_Err bxml_dump(GF_Box *a, FILE * trace);
GF_Err iloc_dump(GF_Box *a, FILE * trace);
GF_Err pitm_dump(GF_Box *a, FILE * trace);
GF_Err ipro_dump(GF_Box *a, FILE * trace);
GF_Err infe_dump(GF_Box *a, FILE * trace);
GF_Err iinf_dump(GF_Box *a, FILE * trace);
GF_Err sinf_dump(GF_Box *a, FILE * trace);
GF_Err frma_dump(GF_Box *a, FILE * trace);
GF_Err schm_dump(GF_Box *a, FILE * trace);
GF_Err schi_dump(GF_Box *a, FILE * trace);

#ifndef GPAC_DISABLE_ISOM_ADOBE
/*Adobe extensions*/
GF_Err abst_dump(GF_Box *a, FILE * trace);
GF_Err afra_dump(GF_Box *a, FILE * trace);
GF_Err asrt_dump(GF_Box *a, FILE * trace);
GF_Err afrt_dump(GF_Box *a, FILE * trace);
#endif

/*Apple extensions*/
GF_Err ilst_dump(GF_Box *a, FILE * trace);
GF_Err ListItem_dump(GF_Box *a, FILE * trace);
GF_Err data_dump(GF_Box *a, FILE * trace);

GF_Err lsrc_dump(GF_Box *a, FILE * trace);
GF_Err lsr1_dump(GF_Box *a, FILE * trace);

/*Apple extensions*/
GF_MetaBox *gf_isom_apple_get_meta_extensions(GF_ISOFile *mov);

#ifndef GPAC_DISABLE_ISOM_WRITE
GF_MetaBox *gf_isom_apple_create_meta_extensions(GF_ISOFile *mov);
#endif /*GPAC_DISABLE_ISOM_WRITE*/

/*OMA extensions*/
GF_Box *ohdr_New();
void ohdr_del(GF_Box *s);
GF_Err ohdr_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ohdr_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ohdr_Size(GF_Box *s);
GF_Err ohdr_dump(GF_Box *a, FILE * trace);
GF_Box *grpi_New();
void grpi_del(GF_Box *s);
GF_Err grpi_Read(GF_Box *s, GF_BitStream *bs);
GF_Err grpi_Write(GF_Box *s, GF_BitStream *bs);
GF_Err grpi_Size(GF_Box *s);
GF_Err grpi_dump(GF_Box *a, FILE * trace);
GF_Box *mdri_New();
void mdri_del(GF_Box *s);
GF_Err mdri_Read(GF_Box *s, GF_BitStream *bs);
GF_Err mdri_Write(GF_Box *s, GF_BitStream *bs);
GF_Err mdri_Size(GF_Box *s);
GF_Err mdri_dump(GF_Box *a, FILE * trace);
GF_Box *odtt_New();
void odtt_del(GF_Box *s);
GF_Err odtt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err odtt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err odtt_Size(GF_Box *s);
GF_Err odtt_dump(GF_Box *a, FILE * trace);
GF_Box *odrb_New();
void odrb_del(GF_Box *s);
GF_Err odrb_Read(GF_Box *s, GF_BitStream *bs);
GF_Err odrb_Write(GF_Box *s, GF_BitStream *bs);
GF_Err odrb_Size(GF_Box *s);
GF_Err odrb_dump(GF_Box *a, FILE * trace);
GF_Box *odkm_New();
void odkm_del(GF_Box *s);
GF_Err odkm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err odkm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err odkm_Size(GF_Box *s);
GF_Err odkm_dump(GF_Box *a, FILE * trace);


GF_Box *pasp_New();
void pasp_del(GF_Box *s);
GF_Err pasp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pasp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pasp_Size(GF_Box *s);
GF_Err pasp_dump(GF_Box *a, FILE * trace);

GF_Box *metx_New(u32 type);
void metx_del(GF_Box *s);
GF_Err metx_Read(GF_Box *s, GF_BitStream *bs);
GF_Err metx_Write(GF_Box *s, GF_BitStream *bs);
GF_Err metx_Size(GF_Box *s);
GF_Err metx_dump(GF_Box *a, FILE * trace);

GF_Box *stse_New();
void stse_del(GF_Box *s);
GF_Err stse_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stse_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stse_Size(GF_Box *s);
GF_Err stse_dump(GF_Box *a, FILE * trace);

GF_Box *stpp_New();
void stpp_del(GF_Box *s);
GF_Err stpp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err stpp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err stpp_Size(GF_Box *s);
GF_Err stpp_dump(GF_Box *a, FILE * trace);

GF_Box *tsel_New();
void tsel_del(GF_Box *s);
GF_Err tsel_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tsel_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tsel_Size(GF_Box *s);
GF_Err tsel_dump(GF_Box *a, FILE * trace);


GF_Box *dimC_New();
void dimC_del(GF_Box *s);
GF_Err dimC_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dimC_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dimC_Size(GF_Box *s);
GF_Err dimC_dump(GF_Box *a, FILE * trace);

GF_Box *dims_New();
void dims_del(GF_Box *s);
GF_Err dims_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dims_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dims_Size(GF_Box *s);
GF_Err dims_dump(GF_Box *a, FILE * trace);

GF_Box *diST_New();
void diST_del(GF_Box *s);
GF_Err diST_Read(GF_Box *s, GF_BitStream *bs);
GF_Err diST_Write(GF_Box *s, GF_BitStream *bs);
GF_Err diST_Size(GF_Box *s);
GF_Err diST_dump(GF_Box *a, FILE * trace);


GF_Box *ac3_New(u32 boxType);
void ac3_del(GF_Box *s);
GF_Err ac3_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ac3_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ac3_Size(GF_Box *s);
GF_Err ac3_dump(GF_Box *a, FILE * trace);

GF_Box *dac3_New(u32 boxType);
void dac3_del(GF_Box *s);
GF_Err dac3_Read(GF_Box *s, GF_BitStream *bs);
GF_Err dac3_Write(GF_Box *s, GF_BitStream *bs);
GF_Err dac3_Size(GF_Box *s);
GF_Err dac3_dump(GF_Box *a, FILE * trace);

GF_Box *lsrc_New();
void lsrc_del(GF_Box *s);
GF_Err lsrc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err lsrc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err lsrc_Size(GF_Box *s);
GF_Err lsrc_dump(GF_Box *a, FILE * trace);

GF_Box *lsr1_New();
void lsr1_del(GF_Box *s);
GF_Err lsr1_Read(GF_Box *s, GF_BitStream *bs);
GF_Err lsr1_Write(GF_Box *s, GF_BitStream *bs);
GF_Err lsr1_Size(GF_Box *s);
GF_Err lsr1_dump(GF_Box *a, FILE * trace);

GF_Box *sidx_New();
void sidx_del(GF_Box *s);
GF_Err sidx_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sidx_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sidx_Size(GF_Box *s);
GF_Err sidx_dump(GF_Box *a, FILE * trace);

GF_Box *pcrb_New();
void pcrb_del(GF_Box *s);
GF_Err pcrb_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pcrb_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pcrb_Size(GF_Box *s);
GF_Err pcrb_dump(GF_Box *a, FILE * trace);

GF_Box *subs_New();
void subs_del(GF_Box *);
GF_Err subs_Write(GF_Box *s, GF_BitStream *bs);
GF_Err subs_Size(GF_Box *s);
GF_Err subs_Read(GF_Box *s, GF_BitStream *bs);
GF_Err subs_dump(GF_Box *a, FILE * trace);

#ifndef GPAC_DISABLE_ISOM_FRAGMENTS
GF_Box *tfdt_New();
void tfdt_del(GF_Box *);
GF_Err tfdt_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tfdt_Size(GF_Box *s);
GF_Err tfdt_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tfdt_dump(GF_Box *a, FILE * trace);
#endif

GF_Box *rvcc_New();
void rvcc_del(GF_Box *);
GF_Err rvcc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err rvcc_Size(GF_Box *s);
GF_Err rvcc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err rvcc_dump(GF_Box *a, FILE * trace);


GF_Box *sbgp_New();
void sbgp_del(GF_Box *);
GF_Err sbgp_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sbgp_Size(GF_Box *s);
GF_Err sbgp_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sbgp_dump(GF_Box *a, FILE * trace);

GF_Box *sgpd_New();
void sgpd_del(GF_Box *);
GF_Err sgpd_Write(GF_Box *s, GF_BitStream *bs);
GF_Err sgpd_Size(GF_Box *s);
GF_Err sgpd_Read(GF_Box *s, GF_BitStream *bs);
GF_Err sgpd_dump(GF_Box *a, FILE * trace);

GF_Box *saiz_New();
void saiz_del(GF_Box *);
GF_Err saiz_Write(GF_Box *s, GF_BitStream *bs);
GF_Err saiz_Size(GF_Box *s);
GF_Err saiz_Read(GF_Box *s, GF_BitStream *bs);
GF_Err saiz_dump(GF_Box *a, FILE * trace);

GF_Box *saio_New();
void saio_del(GF_Box *);
GF_Err saio_Write(GF_Box *s, GF_BitStream *bs);
GF_Err saio_Size(GF_Box *s);
GF_Err saio_Read(GF_Box *s, GF_BitStream *bs);
GF_Err saio_dump(GF_Box *a, FILE * trace);

GF_Box *pssh_New();
void pssh_del(GF_Box *);
GF_Err pssh_Write(GF_Box *s, GF_BitStream *bs);
GF_Err pssh_Size(GF_Box *s);
GF_Err pssh_Read(GF_Box *s, GF_BitStream *bs);
GF_Err pssh_dump(GF_Box *a, FILE * trace);

GF_Box *tenc_New();
void tenc_del(GF_Box *);
GF_Err tenc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err tenc_Size(GF_Box *s);
GF_Err tenc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err tenc_dump(GF_Box *a, FILE * trace);

GF_Box *piff_tenc_New();
void piff_tenc_del(GF_Box *);
GF_Err piff_tenc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err piff_tenc_Size(GF_Box *s);
GF_Err piff_tenc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err piff_tenc_dump(GF_Box *a, FILE * trace);

GF_Box *piff_psec_New();
void piff_psec_del(GF_Box *);
GF_Err piff_psec_Write(GF_Box *s, GF_BitStream *bs);
GF_Err piff_psec_Size(GF_Box *s);
GF_Err piff_psec_Read(GF_Box *s, GF_BitStream *bs);
GF_Err piff_psec_dump(GF_Box *a, FILE * trace);

GF_Box *piff_pssh_New();
void piff_pssh_del(GF_Box *);
GF_Err piff_pssh_Write(GF_Box *s, GF_BitStream *bs);
GF_Err piff_pssh_Size(GF_Box *s);
GF_Err piff_pssh_Read(GF_Box *s, GF_BitStream *bs);
GF_Err piff_pssh_dump(GF_Box *a, FILE * trace);

GF_Box *senc_New();
void senc_del(GF_Box *);
GF_Err senc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err senc_Size(GF_Box *s);
GF_Err senc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err senc_dump(GF_Box *a, FILE * trace);


GF_Box *cslg_New();
void cslg_del(GF_Box *);
GF_Err cslg_Write(GF_Box *s, GF_BitStream *bs);
GF_Err cslg_Size(GF_Box *s);
GF_Err cslg_Read(GF_Box *s, GF_BitStream *bs);
GF_Err cslg_dump(GF_Box *a, FILE * trace);

GF_Box *hvcc_New();
void hvcc_del(GF_Box *);
GF_Err hvcc_Write(GF_Box *s, GF_BitStream *bs);
GF_Err hvcc_Size(GF_Box *s);
GF_Err hvcc_Read(GF_Box *s, GF_BitStream *bs);
GF_Err hvcc_dump(GF_Box *a, FILE * trace);


void prft_del(GF_Box *s);
GF_Box *prft_New();
GF_Err prft_Read(GF_Box *s,GF_BitStream *bs);
GF_Err prft_dump(GF_Box *a, FILE * trace);

//exported for sgpd comparison in traf merge
void sgpd_write_entry(u32 grouping_type, void *entry, GF_BitStream *bs);

/*
	Adobe's protection boxes
*/

GF_Box *adkm_New();
void adkm_del(GF_Box *s);
GF_Err adkm_AddBox(GF_Box *s, GF_Box *a);
GF_Err adkm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err adkm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err adkm_Size(GF_Box *s);
GF_Err adkm_dump(GF_Box *a, FILE * trace);

GF_Box *ahdr_New();
void ahdr_del(GF_Box *s);
GF_Err ahdr_AddBox(GF_Box *s, GF_Box *a);
GF_Err ahdr_Read(GF_Box *s, GF_BitStream *bs);
GF_Err ahdr_Write(GF_Box *s, GF_BitStream *bs);
GF_Err ahdr_Size(GF_Box *s);
GF_Err ahdr_dump(GF_Box *a, FILE * trace);

GF_Box *aprm_New();
void aprm_del(GF_Box *s);
GF_Err aprm_AddBox(GF_Box *s, GF_Box *a);
GF_Err aprm_Read(GF_Box *s, GF_BitStream *bs);
GF_Err aprm_Write(GF_Box *s, GF_BitStream *bs);
GF_Err aprm_Size(GF_Box *s);
GF_Err aprm_dump(GF_Box *a, FILE * trace);

GF_Box *aeib_New();
void aeib_del(GF_Box *s);
GF_Err aeib_Read(GF_Box *s, GF_BitStream *bs);
GF_Err aeib_Write(GF_Box *s, GF_BitStream *bs);
GF_Err aeib_Size(GF_Box *s);
GF_Err aeib_dump(GF_Box *a, FILE * trace);

GF_Box *akey_New();
void akey_del(GF_Box *s);
GF_Err akey_AddBox(GF_Box *s, GF_Box *a);
GF_Err akey_Read(GF_Box *s, GF_BitStream *bs);
GF_Err akey_Write(GF_Box *s, GF_BitStream *bs);
GF_Err akey_Size(GF_Box *s);
GF_Err akey_dump(GF_Box *a, FILE * trace);

GF_Box *flxs_New();
void flxs_del(GF_Box *s);
GF_Err flxs_Read(GF_Box *s, GF_BitStream *bs);
GF_Err flxs_Write(GF_Box *s, GF_BitStream *bs);
GF_Err flxs_Size(GF_Box *s);
GF_Err flxs_dump(GF_Box *a, FILE * trace);


GF_Box *adaf_New();
void adaf_del(GF_Box *s);
GF_Err adaf_Read(GF_Box *s, GF_BitStream *bs);
GF_Err adaf_Write(GF_Box *s, GF_BitStream *bs);
GF_Err adaf_Size(GF_Box *s);
GF_Err adaf_dump(GF_Box *a, FILE * trace);

#endif /*GPAC_DISABLE_ISOM*/

#ifdef __cplusplus
}
#endif

#endif //_GF_ISOMEDIA_DEV_H_