1 /* 2 * GPAC - Multimedia Framework C SDK 3 * 4 * Authors: Jean Le Feuvre 5 * Copyright (c) Telecom ParisTech 2000-2012 6 * All rights reserved 7 * 8 * This file is part of GPAC / ISO Media File Format sub-project 9 * 10 * GPAC is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation; either version 2, or (at your option) 13 * any later version. 14 * 15 * GPAC is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; see the file COPYING. If not, write to 22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 * 24 */ 25 26 #ifndef _GF_ISOMEDIA_DEV_H_ 27 #define _GF_ISOMEDIA_DEV_H_ 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <gpac/isomedia.h> 34 35 36 enum 37 { 38 //internal code type for unknown boxes 39 GF_ISOM_BOX_TYPE_UNKNOWN = GF_4CC( 'U', 'N', 'K', 'N' ), 40 41 GF_ISOM_BOX_TYPE_CO64 = GF_4CC( 'c', 'o', '6', '4' ), 42 GF_ISOM_BOX_TYPE_STCO = GF_4CC( 's', 't', 'c', 'o' ), 43 GF_ISOM_BOX_TYPE_CTTS = GF_4CC( 'c', 't', 't', 's' ), 44 GF_ISOM_BOX_TYPE_CPRT = GF_4CC( 'c', 'p', 'r', 't' ), 45 GF_ISOM_BOX_TYPE_KIND = GF_4CC( 'k', 'i', 'n', 'd' ), 46 GF_ISOM_BOX_TYPE_CHPL = GF_4CC( 'c', 'h', 'p', 'l' ), 47 GF_ISOM_BOX_TYPE_URL = GF_4CC( 'u', 'r', 'l', ' ' ), 48 GF_ISOM_BOX_TYPE_URN = GF_4CC( 'u', 'r', 'n', ' ' ), 49 GF_ISOM_BOX_TYPE_DINF = GF_4CC( 'd', 'i', 'n', 'f' ), 50 GF_ISOM_BOX_TYPE_DREF = GF_4CC( 'd', 'r', 'e', 'f' ), 51 GF_ISOM_BOX_TYPE_STDP = GF_4CC( 's', 't', 'd', 'p' ), 52 GF_ISOM_BOX_TYPE_EDTS = GF_4CC( 'e', 'd', 't', 's' ), 53 GF_ISOM_BOX_TYPE_ELST = GF_4CC( 'e', 'l', 's', 't' ), 54 GF_ISOM_BOX_TYPE_UUID = GF_4CC( 'u', 'u', 'i', 'd' ), 55 GF_ISOM_BOX_TYPE_FREE = GF_4CC( 'f', 'r', 'e', 'e' ), 56 GF_ISOM_BOX_TYPE_HDLR = GF_4CC( 'h', 'd', 'l', 'r' ), 57 GF_ISOM_BOX_TYPE_GMHD = GF_4CC( 'g', 'm', 'h', 'd' ), 58 GF_ISOM_BOX_TYPE_HMHD = GF_4CC( 'h', 'm', 'h', 'd' ), 59 GF_ISOM_BOX_TYPE_HINT = GF_4CC( 'h', 'i', 'n', 't' ), 60 GF_ISOM_BOX_TYPE_MDIA = GF_4CC( 'm', 'd', 'i', 'a' ), 61 GF_ISOM_BOX_TYPE_ELNG = GF_4CC( 'e', 'l', 'n', 'g' ), 62 GF_ISOM_BOX_TYPE_MDAT = GF_4CC( 'm', 'd', 'a', 't' ), 63 GF_ISOM_BOX_TYPE_IDAT = GF_4CC( 'i', 'd', 'a', 't' ), 64 GF_ISOM_BOX_TYPE_MDHD = GF_4CC( 'm', 'd', 'h', 'd' ), 65 GF_ISOM_BOX_TYPE_MINF = GF_4CC( 'm', 'i', 'n', 'f' ), 66 GF_ISOM_BOX_TYPE_MOOV = GF_4CC( 'm', 'o', 'o', 'v' ), 67 GF_ISOM_BOX_TYPE_MVHD = GF_4CC( 'm', 'v', 'h', 'd' ), 68 GF_ISOM_BOX_TYPE_STSD = GF_4CC( 's', 't', 's', 'd' ), 69 GF_ISOM_BOX_TYPE_STSZ = GF_4CC( 's', 't', 's', 'z' ), 70 GF_ISOM_BOX_TYPE_STZ2 = GF_4CC( 's', 't', 'z', '2' ), 71 GF_ISOM_BOX_TYPE_STBL = GF_4CC( 's', 't', 'b', 'l' ), 72 GF_ISOM_BOX_TYPE_STSC = GF_4CC( 's', 't', 's', 'c' ), 73 GF_ISOM_BOX_TYPE_STSH = GF_4CC( 's', 't', 's', 'h' ), 74 GF_ISOM_BOX_TYPE_SKIP = GF_4CC( 's', 'k', 'i', 'p' ), 75 GF_ISOM_BOX_TYPE_SMHD = GF_4CC( 's', 'm', 'h', 'd' ), 76 GF_ISOM_BOX_TYPE_STSS = GF_4CC( 's', 't', 's', 's' ), 77 GF_ISOM_BOX_TYPE_STTS = GF_4CC( 's', 't', 't', 's' ), 78 GF_ISOM_BOX_TYPE_TRAK = GF_4CC( 't', 'r', 'a', 'k' ), 79 GF_ISOM_BOX_TYPE_TKHD = GF_4CC( 't', 'k', 'h', 'd' ), 80 GF_ISOM_BOX_TYPE_TREF = GF_4CC( 't', 'r', 'e', 'f' ), 81 GF_ISOM_BOX_TYPE_STRK = GF_4CC( 's', 't', 'r', 'k' ), 82 GF_ISOM_BOX_TYPE_STRI = GF_4CC( 's', 't', 'r', 'i' ), 83 GF_ISOM_BOX_TYPE_STRD = GF_4CC( 's', 't', 'r', 'd' ), 84 GF_ISOM_BOX_TYPE_STSG = GF_4CC( 's', 't', 's', 'g' ), 85 86 GF_ISOM_BOX_TYPE_UDTA = GF_4CC( 'u', 'd', 't', 'a' ), 87 GF_ISOM_BOX_TYPE_VMHD = GF_4CC( 'v', 'm', 'h', 'd' ), 88 GF_ISOM_BOX_TYPE_FTYP = GF_4CC( 'f', 't', 'y', 'p' ), 89 GF_ISOM_BOX_TYPE_PADB = GF_4CC( 'p', 'a', 'd', 'b' ), 90 GF_ISOM_BOX_TYPE_PDIN = GF_4CC( 'p', 'd', 'i', 'n' ), 91 GF_ISOM_BOX_TYPE_SDTP = GF_4CC( 's', 'd', 't', 'p' ), 92 GF_ISOM_BOX_TYPE_CSLG = GF_4CC( 'c', 's', 'l', 'g' ), 93 94 GF_ISOM_BOX_TYPE_SBGP = GF_4CC( 's', 'b', 'g', 'p' ), 95 GF_ISOM_BOX_TYPE_SGPD = GF_4CC( 's', 'g', 'p', 'd' ), 96 GF_ISOM_BOX_TYPE_SAIZ = GF_4CC( 's', 'a', 'i', 'z' ), 97 GF_ISOM_BOX_TYPE_SAIO = GF_4CC( 's', 'a', 'i', 'o' ), 98 GF_ISOM_BOX_TYPE_MFRA = GF_4CC( 'm', 'f', 'r', 'a' ), 99 GF_ISOM_BOX_TYPE_MFRO = GF_4CC( 'm', 'f', 'r', 'o' ), 100 GF_ISOM_BOX_TYPE_TFRA = GF_4CC( 't', 'f', 'r', 'a' ), 101 102 GF_ISOM_BOX_TYPE_TENC = GF_4CC( 't', 'e', 'n', 'c' ), 103 104 //track group 105 GF_ISOM_BOX_TYPE_TRGR = GF_4CC( 't', 'r', 'g', 'r' ), 106 //track group types 107 GF_ISOM_BOX_TYPE_TRGT = GF_4CC( 't', 'r', 'g', 't' ), 108 GF_ISOM_BOX_TYPE_MSRC = GF_4CC( 'm', 's', 'r', 'c' ), 109 GF_ISOM_BOX_TYPE_CSTG = GF_4CC( 'c', 's', 't', 'g' ), 110 GF_ISOM_BOX_TYPE_STER = GF_4CC( 's', 't', 'e', 'r' ), 111 112 /*Adobe's protection boxes*/ 113 GF_ISOM_BOX_TYPE_ADKM = GF_4CC( 'a', 'd', 'k', 'm' ), 114 GF_ISOM_BOX_TYPE_AHDR = GF_4CC( 'a', 'h', 'd', 'r' ), 115 GF_ISOM_BOX_TYPE_ADAF = GF_4CC( 'a', 'd', 'a', 'f' ), 116 GF_ISOM_BOX_TYPE_APRM = GF_4CC( 'a', 'p', 'r', 'm' ), 117 GF_ISOM_BOX_TYPE_AEIB = GF_4CC( 'a', 'e', 'i', 'b' ), 118 GF_ISOM_BOX_TYPE_AKEY = GF_4CC( 'a', 'k', 'e', 'y' ), 119 GF_ISOM_BOX_TYPE_FLXS = GF_4CC( 'f', 'l', 'x', 's' ), 120 121 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 122 /*Movie Fragments*/ 123 GF_ISOM_BOX_TYPE_MVEX = GF_4CC( 'm', 'v', 'e', 'x' ), 124 GF_ISOM_BOX_TYPE_MEHD = GF_4CC( 'm', 'e', 'h', 'd' ), 125 GF_ISOM_BOX_TYPE_TREX = GF_4CC( 't', 'r', 'e', 'x' ), 126 GF_ISOM_BOX_TYPE_TREP = GF_4CC( 't', 'r', 'e', 'p' ), 127 GF_ISOM_BOX_TYPE_MOOF = GF_4CC( 'm', 'o', 'o', 'f' ), 128 GF_ISOM_BOX_TYPE_MFHD = GF_4CC( 'm', 'f', 'h', 'd' ), 129 GF_ISOM_BOX_TYPE_TRAF = GF_4CC( 't', 'r', 'a', 'f' ), 130 GF_ISOM_BOX_TYPE_TFHD = GF_4CC( 't', 'f', 'h', 'd' ), 131 GF_ISOM_BOX_TYPE_TRUN = GF_4CC( 't', 'r', 'u', 'n' ), 132 #ifdef GF_ENABLE_CTRN 133 GF_ISOM_BOX_TYPE_CTRN = GF_4CC( 'c', 't', 'r', 'n' ), 134 #endif 135 136 #endif 137 138 139 /*MP4 extensions*/ 140 GF_ISOM_BOX_TYPE_DPND = GF_4CC( 'd', 'p', 'n', 'd' ), 141 GF_ISOM_BOX_TYPE_IODS = GF_4CC( 'i', 'o', 'd', 's' ), 142 GF_ISOM_BOX_TYPE_ESDS = GF_4CC( 'e', 's', 'd', 's' ), 143 GF_ISOM_BOX_TYPE_MPOD = GF_4CC( 'm', 'p', 'o', 'd' ), 144 GF_ISOM_BOX_TYPE_SYNC = GF_4CC( 's', 'y', 'n', 'c' ), 145 GF_ISOM_BOX_TYPE_IPIR = GF_4CC( 'i', 'p', 'i', 'r' ), 146 147 GF_ISOM_BOX_TYPE_NMHD = GF_4CC( 'n', 'm', 'h', 'd' ), 148 GF_ISOM_BOX_TYPE_STHD = GF_4CC( 's', 't', 'h', 'd' ), 149 /*reseved 150 GF_ISOM_BOX_TYPE_SDHD = GF_4CC( 's', 'd', 'h', 'd' ), 151 GF_ISOM_BOX_TYPE_ODHD = GF_4CC( 'o', 'd', 'h', 'd' ), 152 GF_ISOM_BOX_TYPE_CRHD = GF_4CC( 'c', 'r', 'h', 'd' ), 153 */ 154 GF_ISOM_BOX_TYPE_MP4S = GF_4CC( 'm', 'p', '4', 's' ), 155 GF_ISOM_BOX_TYPE_MP4A = GF_4CC( 'm', 'p', '4', 'a' ), 156 GF_ISOM_BOX_TYPE_MP4V = GF_4CC( 'm', 'p', '4', 'v' ), 157 158 159 /*AVC / H264 extension*/ 160 GF_ISOM_BOX_TYPE_AVCC = GF_4CC( 'a', 'v', 'c', 'C' ), 161 GF_ISOM_BOX_TYPE_BTRT = GF_4CC( 'b', 't', 'r', 't' ), 162 GF_ISOM_BOX_TYPE_M4DS = GF_4CC( 'm', '4', 'd', 's' ), 163 GF_ISOM_BOX_TYPE_PASP = GF_4CC( 'p', 'a', 's', 'p' ), 164 GF_ISOM_BOX_TYPE_CLAP = GF_4CC( 'c', 'l', 'a', 'p' ), 165 GF_ISOM_BOX_TYPE_AVC1 = GF_4CC( 'a', 'v', 'c', '1' ), 166 GF_ISOM_BOX_TYPE_AVC2 = GF_4CC( 'a', 'v', 'c', '2' ), 167 GF_ISOM_BOX_TYPE_AVC3 = GF_4CC( 'a', 'v', 'c', '3' ), 168 GF_ISOM_BOX_TYPE_AVC4 = GF_4CC( 'a', 'v', 'c', '4' ), 169 GF_ISOM_BOX_TYPE_SVCC = GF_4CC( 's', 'v', 'c', 'C' ), 170 GF_ISOM_BOX_TYPE_SVC1 = GF_4CC( 's', 'v', 'c', '1' ), 171 GF_ISOM_BOX_TYPE_SVC2 = GF_4CC( 's', 'v', 'c', '2' ), 172 GF_ISOM_BOX_TYPE_MVCC = GF_4CC( 'm', 'v', 'c', 'C' ), 173 GF_ISOM_BOX_TYPE_MVC1 = GF_4CC( 'm', 'v', 'c', '1' ), 174 GF_ISOM_BOX_TYPE_MVC2 = GF_4CC( 'm', 'v', 'c', '2' ), 175 GF_ISOM_BOX_TYPE_MHC1 = GF_4CC( 'm', 'h', 'c', '1' ), 176 GF_ISOM_BOX_TYPE_MHV1 = GF_4CC( 'm', 'h', 'v', '1' ), 177 178 GF_ISOM_BOX_TYPE_HVCC = GF_4CC( 'h', 'v', 'c', 'C' ), 179 GF_ISOM_BOX_TYPE_HVC1 = GF_4CC( 'h', 'v', 'c', '1' ), 180 GF_ISOM_BOX_TYPE_HEV1 = GF_4CC( 'h', 'e', 'v', '1' ), 181 GF_ISOM_BOX_TYPE_HVT1 = GF_4CC( 'h', 'v', 't', '1' ), 182 GF_ISOM_BOX_TYPE_MVCI = GF_4CC( 'm', 'v', 'c', 'i' ), 183 GF_ISOM_BOX_TYPE_MVCG = GF_4CC( 'm', 'v', 'c', 'g' ), 184 GF_ISOM_BOX_TYPE_VWID = GF_4CC( 'v', 'w', 'i', 'd' ), 185 186 GF_ISOM_BOX_TYPE_HVC2 = GF_4CC( 'h', 'v', 'c', '2' ), 187 GF_ISOM_BOX_TYPE_HEV2 = GF_4CC( 'h', 'e', 'v', '2' ), 188 GF_ISOM_BOX_TYPE_LHV1 = GF_4CC( 'l', 'h', 'v', '1' ), 189 GF_ISOM_BOX_TYPE_LHE1 = GF_4CC( 'l', 'h', 'e', '1' ), 190 GF_ISOM_BOX_TYPE_LHT1 = GF_4CC( 'l', 'h', 't', '1' ), 191 192 GF_ISOM_BOX_TYPE_LHVC = GF_4CC( 'l', 'h', 'v', 'C' ), 193 194 GF_ISOM_BOX_TYPE_AV1C = GF_4CC('a', 'v', '1', 'C'), 195 GF_ISOM_BOX_TYPE_AV01 = GF_4CC('a', 'v', '0', '1'), 196 197 /*WebM*/ 198 GF_ISOM_BOX_TYPE_VPCC = GF_4CC('v', 'p', 'c', 'C'), 199 GF_ISOM_BOX_TYPE_VP08 = GF_4CC('v', 'p', '0', '8'), 200 GF_ISOM_BOX_TYPE_VP09 = GF_4CC('v', 'p', '0', '9'), 201 GF_ISOM_BOX_TYPE_SMDM = GF_4CC('S', 'm', 'D', 'm'), 202 GF_ISOM_BOX_TYPE_COLL = GF_4CC('C', 'o', 'L', 'L'), 203 204 /*Opus*/ 205 GF_ISOM_BOX_TYPE_OPUS = GF_4CC('O', 'p', 'u', 's'), 206 GF_ISOM_BOX_TYPE_DOPS = GF_4CC('d', 'O', 'p', 's'), 207 208 /*LASeR extension*/ 209 GF_ISOM_BOX_TYPE_LSRC = GF_4CC( 'l', 's', 'r', 'C' ), 210 GF_ISOM_BOX_TYPE_LSR1 = GF_4CC( 'l', 's', 'r', '1' ), 211 212 /*3GPP extensions*/ 213 GF_ISOM_BOX_TYPE_DAMR = GF_4CC( 'd', 'a', 'm', 'r' ), 214 GF_ISOM_BOX_TYPE_D263 = GF_4CC( 'd', '2', '6', '3' ), 215 GF_ISOM_BOX_TYPE_DEVC = GF_4CC( 'd', 'e', 'v', 'c' ), 216 GF_ISOM_BOX_TYPE_DQCP = GF_4CC( 'd', 'q', 'c', 'p' ), 217 GF_ISOM_BOX_TYPE_DSMV = GF_4CC( 'd', 's', 'm', 'v' ), 218 GF_ISOM_BOX_TYPE_TSEL = GF_4CC( 't', 's', 'e', 'l' ), 219 220 /* 3GPP Adaptive Streaming extensions */ 221 GF_ISOM_BOX_TYPE_STYP = GF_4CC( 's', 't', 'y', 'p' ), 222 GF_ISOM_BOX_TYPE_TFDT = GF_4CC( 't', 'f', 'd', 't' ), 223 GF_ISOM_BOX_TYPE_SIDX = GF_4CC( 's', 'i', 'd', 'x' ), 224 GF_ISOM_BOX_TYPE_SSIX = GF_4CC( 's', 's', 'i', 'x' ), 225 GF_ISOM_BOX_TYPE_LEVA = GF_4CC( 'l', 'e', 'v', 'a' ), 226 GF_ISOM_BOX_TYPE_PCRB = GF_4CC( 'p', 'c', 'r', 'b' ), 227 GF_ISOM_BOX_TYPE_EMSG = GF_4CC( 'e', 'm', 's', 'g' ), 228 229 /*3GPP text / MPEG-4 StreamingText*/ 230 GF_ISOM_BOX_TYPE_FTAB = GF_4CC( 'f', 't', 'a', 'b' ), 231 GF_ISOM_BOX_TYPE_TX3G = GF_4CC( 't', 'x', '3', 'g' ), 232 GF_ISOM_BOX_TYPE_STYL = GF_4CC( 's', 't', 'y', 'l' ), 233 GF_ISOM_BOX_TYPE_HLIT = GF_4CC( 'h', 'l', 'i', 't' ), 234 GF_ISOM_BOX_TYPE_HCLR = GF_4CC( 'h', 'c', 'l', 'r' ), 235 GF_ISOM_BOX_TYPE_KROK = GF_4CC( 'k', 'r', 'o', 'k' ), 236 GF_ISOM_BOX_TYPE_DLAY = GF_4CC( 'd', 'l', 'a', 'y' ), 237 GF_ISOM_BOX_TYPE_HREF = GF_4CC( 'h', 'r', 'e', 'f' ), 238 GF_ISOM_BOX_TYPE_TBOX = GF_4CC( 't', 'b', 'o', 'x' ), 239 GF_ISOM_BOX_TYPE_BLNK = GF_4CC( 'b', 'l', 'n', 'k' ), 240 GF_ISOM_BOX_TYPE_TWRP = GF_4CC( 't', 'w', 'r', 'p' ), 241 242 /* ISO Base Media File Format Extensions for MPEG-21 */ 243 GF_ISOM_BOX_TYPE_META = GF_4CC( 'm', 'e', 't', 'a' ), 244 GF_ISOM_BOX_TYPE_XML = GF_4CC( 'x', 'm', 'l', ' ' ), 245 GF_ISOM_BOX_TYPE_BXML = GF_4CC( 'b', 'x', 'm', 'l' ), 246 GF_ISOM_BOX_TYPE_ILOC = GF_4CC( 'i', 'l', 'o', 'c' ), 247 GF_ISOM_BOX_TYPE_PITM = GF_4CC( 'p', 'i', 't', 'm' ), 248 GF_ISOM_BOX_TYPE_IPRO = GF_4CC( 'i', 'p', 'r', 'o' ), 249 GF_ISOM_BOX_TYPE_INFE = GF_4CC( 'i', 'n', 'f', 'e' ), 250 GF_ISOM_BOX_TYPE_IINF = GF_4CC( 'i', 'i', 'n', 'f' ), 251 GF_ISOM_BOX_TYPE_IREF = GF_4CC( 'i', 'r', 'e', 'f' ), 252 GF_ISOM_BOX_TYPE_ENCA = GF_4CC( 'e', 'n', 'c', 'a' ), 253 GF_ISOM_BOX_TYPE_ENCV = GF_4CC( 'e', 'n', 'c', 'v' ), 254 GF_ISOM_BOX_TYPE_RESV = GF_4CC( 'r', 'e', 's', 'v' ), 255 GF_ISOM_BOX_TYPE_ENCT = GF_4CC( 'e', 'n', 'c', 't' ), 256 GF_ISOM_BOX_TYPE_ENCS = GF_4CC( 'e', 'n', 'c', 's' ), 257 GF_ISOM_BOX_TYPE_ENCF = GF_4CC( 'e', 'n', 'c', 'f' ), 258 GF_ISOM_BOX_TYPE_ENCM = GF_4CC( 'e', 'n', 'c', 'm' ), 259 GF_ISOM_BOX_TYPE_SINF = GF_4CC( 's', 'i', 'n', 'f' ), 260 GF_ISOM_BOX_TYPE_RINF = GF_4CC( 'r', 'i', 'n', 'f' ), 261 GF_ISOM_BOX_TYPE_FRMA = GF_4CC( 'f', 'r', 'm', 'a' ), 262 GF_ISOM_BOX_TYPE_SCHM = GF_4CC( 's', 'c', 'h', 'm' ), 263 GF_ISOM_BOX_TYPE_SCHI = GF_4CC( 's', 'c', 'h', 'i' ), 264 265 GF_ISOM_BOX_TYPE_STVI = GF_4CC( 's', 't', 'v', 'i' ), 266 267 268 GF_ISOM_BOX_TYPE_METX = GF_4CC( 'm', 'e', 't', 'x' ), 269 GF_ISOM_BOX_TYPE_METT = GF_4CC( 'm', 'e', 't', 't' ), 270 271 /* ISMA 1.0 Encryption and Authentication V 1.0 */ 272 GF_ISOM_BOX_TYPE_IKMS = GF_4CC( 'i', 'K', 'M', 'S' ), 273 GF_ISOM_BOX_TYPE_ISFM = GF_4CC( 'i', 'S', 'F', 'M' ), 274 GF_ISOM_BOX_TYPE_ISLT = GF_4CC( 'i', 'S', 'L', 'T' ), 275 276 /* Hinting boxes */ 277 GF_ISOM_BOX_TYPE_RTP_STSD = GF_4CC( 'r', 't', 'p', ' ' ), 278 GF_ISOM_BOX_TYPE_SRTP_STSD = GF_4CC( 's', 'r', 't', 'p' ), 279 GF_ISOM_BOX_TYPE_FDP_STSD = GF_4CC( 'f', 'd', 'p', ' ' ), 280 GF_ISOM_BOX_TYPE_RRTP_STSD = GF_4CC( 'r', 'r', 't', 'p' ), 281 GF_ISOM_BOX_TYPE_RTCP_STSD = GF_4CC( 'r', 't', 'c', 'p' ), 282 GF_ISOM_BOX_TYPE_HNTI = GF_4CC( 'h', 'n', 't', 'i' ), 283 GF_ISOM_BOX_TYPE_RTP = GF_4CC( 'r', 't', 'p', ' ' ), 284 GF_ISOM_BOX_TYPE_SDP = GF_4CC( 's', 'd', 'p', ' ' ), 285 GF_ISOM_BOX_TYPE_HINF = GF_4CC( 'h', 'i', 'n', 'f' ), 286 GF_ISOM_BOX_TYPE_NAME = GF_4CC( 'n', 'a', 'm', 'e' ), 287 GF_ISOM_BOX_TYPE_TRPY = GF_4CC( 't', 'r', 'p', 'y' ), 288 GF_ISOM_BOX_TYPE_NUMP = GF_4CC( 'n', 'u', 'm', 'p' ), 289 GF_ISOM_BOX_TYPE_TOTL = GF_4CC( 't', 'o', 't', 'l' ), 290 GF_ISOM_BOX_TYPE_NPCK = GF_4CC( 'n', 'p', 'c', 'k' ), 291 GF_ISOM_BOX_TYPE_TPYL = GF_4CC( 't', 'p', 'y', 'l' ), 292 GF_ISOM_BOX_TYPE_TPAY = GF_4CC( 't', 'p', 'a', 'y' ), 293 GF_ISOM_BOX_TYPE_MAXR = GF_4CC( 'm', 'a', 'x', 'r' ), 294 GF_ISOM_BOX_TYPE_DMED = GF_4CC( 'd', 'm', 'e', 'd' ), 295 GF_ISOM_BOX_TYPE_DIMM = GF_4CC( 'd', 'i', 'm', 'm' ), 296 GF_ISOM_BOX_TYPE_DREP = GF_4CC( 'd', 'r', 'e', 'p' ), 297 GF_ISOM_BOX_TYPE_TMIN = GF_4CC( 't', 'm', 'i', 'n' ), 298 GF_ISOM_BOX_TYPE_TMAX = GF_4CC( 't', 'm', 'a', 'x' ), 299 GF_ISOM_BOX_TYPE_PMAX = GF_4CC( 'p', 'm', 'a', 'x' ), 300 GF_ISOM_BOX_TYPE_DMAX = GF_4CC( 'd', 'm', 'a', 'x' ), 301 GF_ISOM_BOX_TYPE_PAYT = GF_4CC( 'p', 'a', 'y', 't' ), 302 GF_ISOM_BOX_TYPE_RELY = GF_4CC( 'r', 'e', 'l', 'y' ), 303 GF_ISOM_BOX_TYPE_TIMS = GF_4CC( 't', 'i', 'm', 's' ), 304 GF_ISOM_BOX_TYPE_TSRO = GF_4CC( 't', 's', 'r', 'o' ), 305 GF_ISOM_BOX_TYPE_SNRO = GF_4CC( 's', 'n', 'r', 'o' ), 306 GF_ISOM_BOX_TYPE_RTPO = GF_4CC( 'r', 't', 'p', 'o' ), 307 GF_ISOM_BOX_TYPE_TSSY = GF_4CC( 't', 's', 's', 'y' ), 308 GF_ISOM_BOX_TYPE_RSSR = GF_4CC( 'r', 's', 's', 'r' ), 309 GF_ISOM_BOX_TYPE_SRPP = GF_4CC( 's', 'r', 'p', 'p' ), 310 311 //FEC boxes 312 GF_ISOM_BOX_TYPE_FIIN = GF_4CC( 'f', 'i', 'i', 'n' ), 313 GF_ISOM_BOX_TYPE_PAEN = GF_4CC( 'p', 'a', 'e', 'n' ), 314 GF_ISOM_BOX_TYPE_FPAR = GF_4CC( 'f', 'p', 'a', 'r' ), 315 GF_ISOM_BOX_TYPE_FECR = GF_4CC( 'f', 'e', 'c', 'r' ), 316 GF_ISOM_BOX_TYPE_SEGR = GF_4CC( 's', 'e', 'g', 'r' ), 317 GF_ISOM_BOX_TYPE_GITN = GF_4CC( 'g', 'i', 't', 'n' ), 318 GF_ISOM_BOX_TYPE_FIRE = GF_4CC( 'f', 'i', 'r', 'e' ), 319 GF_ISOM_BOX_TYPE_FDSA = GF_4CC( 'f', 'd', 's', 'a' ), 320 GF_ISOM_BOX_TYPE_FDPA = GF_4CC( 'f', 'd', 'p', 'a' ), 321 GF_ISOM_BOX_TYPE_EXTR = GF_4CC( 'e', 'x', 't', 'r' ), 322 323 /*internal type for track and item references*/ 324 GF_ISOM_BOX_TYPE_REFT = GF_4CC( 'R', 'E', 'F', 'T' ), 325 GF_ISOM_BOX_TYPE_REFI = GF_4CC( 'R', 'E', 'F', 'I'), 326 GF_ISOM_BOX_TYPE_GRPT = GF_4CC( 'G', 'R', 'P', 'T'), 327 328 #ifndef GPAC_DISABLE_ISOM_ADOBE 329 /* Adobe extensions */ 330 GF_ISOM_BOX_TYPE_ABST = GF_4CC( 'a', 'b', 's', 't' ), 331 GF_ISOM_BOX_TYPE_AFRA = GF_4CC( 'a', 'f', 'r', 'a' ), 332 GF_ISOM_BOX_TYPE_ASRT = GF_4CC( 'a', 's', 'r', 't' ), 333 GF_ISOM_BOX_TYPE_AFRT = GF_4CC( 'a', 'f', 'r', 't' ), 334 #endif 335 336 /* Apple extensions */ 337 338 GF_ISOM_BOX_TYPE_ILST = GF_4CC( 'i', 'l', 's', 't' ), 339 GF_ISOM_BOX_TYPE_0xA9NAM = GF_4CC( 0xA9, 'n', 'a', 'm' ), 340 GF_ISOM_BOX_TYPE_0xA9CMT = GF_4CC( 0xA9, 'c', 'm', 't' ), 341 GF_ISOM_BOX_TYPE_0xA9DAY = GF_4CC( 0xA9, 'd', 'a', 'y' ), 342 GF_ISOM_BOX_TYPE_0xA9ART = GF_4CC( 0xA9, 'A', 'R', 'T' ), 343 GF_ISOM_BOX_TYPE_0xA9TRK = GF_4CC( 0xA9, 't', 'r', 'k' ), 344 GF_ISOM_BOX_TYPE_0xA9ALB = GF_4CC( 0xA9, 'a', 'l', 'b' ), 345 GF_ISOM_BOX_TYPE_0xA9COM = GF_4CC( 0xA9, 'c', 'o', 'm' ), 346 GF_ISOM_BOX_TYPE_0xA9WRT = GF_4CC( 0xA9, 'w', 'r', 't' ), 347 GF_ISOM_BOX_TYPE_0xA9TOO = GF_4CC( 0xA9, 't', 'o', 'o' ), 348 GF_ISOM_BOX_TYPE_0xA9CPY = GF_4CC( 0xA9, 'c', 'p', 'y' ), 349 GF_ISOM_BOX_TYPE_0xA9DES = GF_4CC( 0xA9, 'd', 'e', 's' ), 350 GF_ISOM_BOX_TYPE_0xA9GEN = GF_4CC( 0xA9, 'g', 'e', 'n' ), 351 GF_ISOM_BOX_TYPE_0xA9GRP = GF_4CC( 0xA9, 'g', 'r', 'p' ), 352 GF_ISOM_BOX_TYPE_0xA9ENC = GF_4CC( 0xA9, 'e', 'n', 'c' ), 353 GF_ISOM_BOX_TYPE_aART = GF_4CC( 'a', 'A', 'R', 'T' ), 354 GF_ISOM_BOX_TYPE_PGAP = GF_4CC( 'p', 'g', 'a', 'p' ), 355 GF_ISOM_BOX_TYPE_GNRE = GF_4CC( 'g', 'n', 'r', 'e' ), 356 GF_ISOM_BOX_TYPE_DISK = GF_4CC( 'd', 'i', 's', 'k' ), 357 GF_ISOM_BOX_TYPE_TRKN = GF_4CC( 't', 'r', 'k', 'n' ), 358 GF_ISOM_BOX_TYPE_TMPO = GF_4CC( 't', 'm', 'p', 'o' ), 359 GF_ISOM_BOX_TYPE_CPIL = GF_4CC( 'c', 'p', 'i', 'l' ), 360 GF_ISOM_BOX_TYPE_COVR = GF_4CC( 'c', 'o', 'v', 'r' ), 361 GF_ISOM_BOX_TYPE_iTunesSpecificInfo = GF_4CC( '-', '-', '-', '-' ), 362 GF_ISOM_BOX_TYPE_DATA = GF_4CC( 'd', 'a', 't', 'a' ), 363 364 GF_ISOM_HANDLER_TYPE_MDIR = GF_4CC( 'm', 'd', 'i', 'r' ), 365 GF_ISOM_BOX_TYPE_CHAP = GF_4CC( 'c', 'h', 'a', 'p' ), 366 GF_ISOM_BOX_TYPE_TEXT = GF_4CC( 't', 'e', 'x', 't' ), 367 368 /*OMA (P)DCF boxes*/ 369 GF_ISOM_BOX_TYPE_OHDR = GF_4CC( 'o', 'h', 'd', 'r' ), 370 GF_ISOM_BOX_TYPE_GRPI = GF_4CC( 'g', 'r', 'p', 'i' ), 371 GF_ISOM_BOX_TYPE_MDRI = GF_4CC( 'm', 'd', 'r', 'i' ), 372 GF_ISOM_BOX_TYPE_ODTT = GF_4CC( 'o', 'd', 't', 't' ), 373 GF_ISOM_BOX_TYPE_ODRB = GF_4CC( 'o', 'd', 'r', 'b' ), 374 GF_ISOM_BOX_TYPE_ODKM = GF_4CC( 'o', 'd', 'k', 'm' ), 375 GF_ISOM_BOX_TYPE_ODAF = GF_4CC( 'o', 'd', 'a', 'f' ), 376 377 /*3GPP DIMS */ 378 GF_ISOM_BOX_TYPE_DIMS = GF_4CC( 'd', 'i', 'm', 's' ), 379 GF_ISOM_BOX_TYPE_DIMC = GF_4CC( 'd', 'i', 'm', 'C' ), 380 GF_ISOM_BOX_TYPE_DIST = GF_4CC( 'd', 'i', 'S', 'T' ), 381 382 383 GF_ISOM_BOX_TYPE_AC3 = GF_4CC( 'a', 'c', '-', '3' ), 384 GF_ISOM_BOX_TYPE_DAC3 = GF_4CC( 'd', 'a', 'c', '3' ), 385 GF_ISOM_BOX_TYPE_EC3 = GF_4CC( 'e', 'c', '-', '3' ), 386 GF_ISOM_BOX_TYPE_DEC3 = GF_4CC( 'd', 'e', 'c', '3' ), 387 GF_ISOM_BOX_TYPE_DVCC = GF_4CC( 'd', 'v', 'c', 'C' ), 388 GF_ISOM_BOX_TYPE_DVHE = GF_4CC( 'd', 'v', 'h', 'e' ), 389 390 GF_ISOM_BOX_TYPE_SUBS = GF_4CC( 's', 'u', 'b', 's' ), 391 392 GF_ISOM_BOX_TYPE_RVCC = GF_4CC( 'r', 'v', 'c', 'c' ), 393 394 GF_ISOM_BOX_TYPE_VTTC_CONFIG = GF_4CC( 'v', 't', 't', 'C' ), 395 GF_ISOM_BOX_TYPE_VTCC_CUE = GF_4CC( 'v', 't', 't', 'c' ), 396 GF_ISOM_BOX_TYPE_VTTE = GF_4CC( 'v', 't', 't', 'e' ), 397 GF_ISOM_BOX_TYPE_VTTA = GF_4CC( 'v', 't', 't', 'a' ), 398 GF_ISOM_BOX_TYPE_CTIM = GF_4CC( 'c', 't', 'i', 'm' ), 399 GF_ISOM_BOX_TYPE_IDEN = GF_4CC( 'i', 'd', 'e', 'n' ), 400 GF_ISOM_BOX_TYPE_STTG = GF_4CC( 's', 't', 't', 'g' ), 401 GF_ISOM_BOX_TYPE_PAYL = GF_4CC( 'p', 'a', 'y', 'l' ), 402 GF_ISOM_BOX_TYPE_WVTT = GF_4CC( 'w', 'v', 't', 't' ), 403 404 GF_ISOM_BOX_TYPE_STPP = GF_4CC( 's', 't', 'p', 'p' ), 405 GF_ISOM_BOX_TYPE_SBTT = GF_4CC( 's', 'b', 't', 't' ), 406 407 GF_ISOM_BOX_TYPE_STXT = GF_4CC( 's', 't', 'x', 't' ), 408 GF_ISOM_BOX_TYPE_TXTC = GF_4CC( 't', 'x', 't', 'C' ), 409 410 GF_ISOM_BOX_TYPE_PRFT = GF_4CC( 'p', 'r', 'f', 't' ), 411 412 /* Image File Format Boxes */ 413 GF_ISOM_BOX_TYPE_ISPE = GF_4CC( 'i', 's', 'p', 'e' ), 414 GF_ISOM_BOX_TYPE_COLR = GF_4CC( 'c', 'o', 'l', 'r' ), 415 GF_ISOM_BOX_TYPE_PIXI = GF_4CC( 'p', 'i', 'x', 'i' ), 416 GF_ISOM_BOX_TYPE_RLOC = GF_4CC( 'r', 'l', 'o', 'c' ), 417 GF_ISOM_BOX_TYPE_IROT = GF_4CC( 'i', 'r', 'o', 't' ), 418 GF_ISOM_BOX_TYPE_IPCO = GF_4CC( 'i', 'p', 'c', 'o' ), 419 GF_ISOM_BOX_TYPE_IPRP = GF_4CC( 'i', 'p', 'r', 'p' ), 420 GF_ISOM_BOX_TYPE_IPMA = GF_4CC( 'i', 'p', 'm', 'a' ), 421 GF_ISOM_BOX_TYPE_GRPL = GF_4CC( 'g', 'r', 'p', 'l'), 422 GF_ISOM_BOX_TYPE_CCST = GF_4CC( 'c', 'c', 's', 't' ), 423 GF_ISOM_BOX_TYPE_AUXC = GF_4CC( 'a', 'u', 'x', 'C' ), 424 GF_ISOM_BOX_TYPE_AUXI = GF_4CC( 'a', 'u', 'x', 'i' ), 425 GF_ISOM_BOX_TYPE_OINF = GF_4CC( 'o', 'i', 'n', 'f' ), 426 GF_ISOM_BOX_TYPE_TOLS = GF_4CC( 't', 'o', 'l', 's' ), 427 428 /* MIAF Boxes */ 429 GF_ISOM_BOX_TYPE_CLLI = GF_4CC('c', 'l', 'l', 'i'), 430 GF_ISOM_BOX_TYPE_MDCV = GF_4CC('m', 'd', 'c', 'v'), 431 432 GF_ISOM_BOX_TYPE_ALTR = GF_4CC( 'a', 'l', 't', 'r' ), 433 434 /*ALL INTERNAL BOXES - NEVER WRITTEN TO FILE!!*/ 435 436 /*generic handlers*/ 437 GF_ISOM_BOX_TYPE_GNRM = GF_4CC( 'G', 'N', 'R', 'M' ), 438 GF_ISOM_BOX_TYPE_GNRV = GF_4CC( 'G', 'N', 'R', 'V' ), 439 GF_ISOM_BOX_TYPE_GNRA = GF_4CC( 'G', 'N', 'R', 'A' ), 440 /*base constructor of all hint formats (currently only RTP uses it)*/ 441 GF_ISOM_BOX_TYPE_GHNT = GF_4CC( 'g', 'h', 'n', 't' ), 442 /*for compatibility with old files hinted for DSS - needs special parsing*/ 443 GF_ISOM_BOX_TYPE_VOID = GF_4CC( 'V', 'O', 'I', 'D' ), 444 445 /*MS Smooth - these are actually UUID boxes*/ 446 GF_ISOM_BOX_UUID_PSSH = GF_4CC( 'P', 'S', 'S', 'H' ), 447 GF_ISOM_BOX_UUID_MSSM = GF_4CC( 'M', 'S', 'S', 'M' ), /*Stream Manifest box*/ 448 GF_ISOM_BOX_UUID_TENC = GF_4CC( 'T', 'E', 'N', 'C' ), 449 GF_ISOM_BOX_UUID_TFRF = GF_4CC( 'T', 'F', 'R', 'F' ), 450 GF_ISOM_BOX_UUID_TFXD = GF_4CC( 'T', 'F', 'X', 'D' ), 451 452 GF_ISOM_BOX_TYPE_MP3 = GF_4CC( '.', 'm', 'p', '3' ), 453 454 GF_ISOM_BOX_TYPE_TRIK = GF_4CC( 't', 'r', 'i', 'k' ), 455 GF_ISOM_BOX_TYPE_BLOC = GF_4CC( 'b', 'l', 'o', 'c' ), 456 GF_ISOM_BOX_TYPE_AINF = GF_4CC( 'a', 'i', 'n', 'f' ), 457 458 /*JPEG2000*/ 459 GF_ISOM_BOX_TYPE_MJP2 = GF_4CC('m','j','p','2'), 460 GF_ISOM_BOX_TYPE_IHDR = GF_4CC('i','h','d','r'), 461 GF_ISOM_BOX_TYPE_JP = GF_4CC('j','P',' ',' '), 462 GF_ISOM_BOX_TYPE_JP2H = GF_4CC('j','p','2','h'), 463 GF_ISOM_BOX_TYPE_JP2K = GF_4CC('j','p','2','k'), 464 465 GF_ISOM_BOX_TYPE_JPEG = GF_4CC('j','p','e','g'), 466 GF_ISOM_BOX_TYPE_PNG = GF_4CC('p','n','g',' '), 467 468 /* apple QT box */ 469 GF_QT_BOX_TYPE_ALIS = GF_4CC('a','l','i','s'), 470 GF_QT_BOX_TYPE_LOAD = GF_4CC('l','o','a','d'), 471 GF_QT_BOX_TYPE_WIDE = GF_4CC('w','i','d','e'), 472 GF_QT_BOX_TYPE_GMIN = GF_4CC( 'g', 'm', 'i', 'n' ), 473 GF_QT_BOX_TYPE_TAPT = GF_4CC( 't', 'a', 'p', 't' ), 474 GF_QT_BOX_TYPE_CLEF = GF_4CC( 'c', 'l', 'e', 'f' ), 475 GF_QT_BOX_TYPE_PROF = GF_4CC( 'p', 'r', 'o', 'f' ), 476 GF_QT_BOX_TYPE_ENOF = GF_4CC( 'e', 'n', 'o', 'f' ), 477 GF_QT_BOX_TYPE_WAVE = GF_4CC('w','a','v','e'), 478 GF_QT_BOX_TYPE_CHAN = GF_4CC('c','h','a','n'), 479 GF_QT_BOX_TYPE_TERMINATOR = 0, 480 GF_QT_BOX_TYPE_ENDA = GF_4CC('e','n','d','a'), 481 GF_QT_BOX_TYPE_FRMA = GF_4CC('f','r','m','a'), 482 GF_QT_BOX_TYPE_TMCD = GF_4CC('t','m','c','d'), 483 GF_QT_BOX_TYPE_NAME = GF_4CC('n','a','m','e'), 484 GF_QT_BOX_TYPE_TCMI = GF_4CC('t','c','m','i'), 485 GF_QT_BOX_TYPE_FIEL = GF_4CC('f','i','e','l'), 486 GF_QT_BOX_TYPE_GAMA = GF_4CC('g','a','m','a'), 487 GF_QT_BOX_TYPE_CHRM = GF_4CC('c','h','r','m'), 488 489 /* from drm_sample.c */ 490 GF_ISOM_BOX_TYPE_264B = GF_4CC('2','6','4','b'), 491 GF_ISOM_BOX_TYPE_265B = GF_4CC('2','6','5','b'), 492 493 /*MPEG-H 3D audio*/ 494 GF_ISOM_BOX_TYPE_MHA1 = GF_4CC('m','h','a','1'), 495 GF_ISOM_BOX_TYPE_MHA2 = GF_4CC('m','h','a','2'), 496 GF_ISOM_BOX_TYPE_MHM1 = GF_4CC('m','h','m','1'), 497 GF_ISOM_BOX_TYPE_MHM2 = GF_4CC('m','h','m','2'), 498 GF_ISOM_BOX_TYPE_MHAC = GF_4CC('m','h','a','C'), 499 500 GF_ISOM_BOX_TYPE_IPCM = GF_4CC('i','p','c','m'), 501 GF_ISOM_BOX_TYPE_FPCM = GF_4CC('f','p','c','m'), 502 GF_ISOM_BOX_TYPE_PCMC = GF_4CC('p','c','m','C'), 503 504 GF_ISOM_BOX_TYPE_CHNL = GF_4CC('c','h','n','l'), 505 506 GF_ISOM_BOX_TYPE_AUXV = GF_4CC('A','U','X','V'), 507 508 GF_ISOM_BOX_TYPE_FLAC = GF_4CC( 'f', 'L', 'a', 'C' ), 509 GF_ISOM_BOX_TYPE_DFLA = GF_4CC( 'd', 'f', 'L', 'a' ), 510 511 //internal only 512 GF_QT_SUBTYPE_RAW_AUD = GF_4CC('Q','T','R','A'), 513 GF_QT_SUBTYPE_RAW_VID = GF_4CC('Q','T','R','V'), 514 515 516 }; 517 518 enum 519 { 520 GF_ISOM_SAMPLE_ENTRY_UNKN = 0, 521 GF_ISOM_SAMPLE_ENTRY_VIDEO = GF_4CC('v','i','d','e'), 522 GF_ISOM_SAMPLE_ENTRY_AUDIO = GF_4CC('a','u','d','i'), 523 GF_ISOM_SAMPLE_ENTRY_MP4S = GF_4CC('m','p','4','s') 524 525 }; 526 527 528 /* bitstream cookies used by isobmff lib*/ 529 #define GF_ISOM_BS_COOKIE_NO_LOGS 1 530 #define GF_ISOM_BS_COOKIE_VISUAL_TRACK (1<<1) 531 #define GF_ISOM_BS_COOKIE_QT_CONV (1<<2) 532 #define GF_ISOM_BS_COOKIE_CLONE_TRACK (1<<3) 533 534 535 #ifndef GPAC_DISABLE_ISOM 536 537 538 #if defined(GPAC_DISABLE_ISOM_FRAGMENTS) && !defined(GPAC_DISABLE_ISOM_ADOBE) 539 #define GPAC_DISABLE_ISOM_ADOBE 540 #endif 541 542 //internal flags (up to 16) 543 //if flag is set, position checking of child boxes is ignored 544 #define GF_ISOM_ORDER_FREEZE 1 545 546 /*the default size is 64, cause we need to handle large boxes... 547 548 the child_boxes container is by default NOT created. When parsing a box and sub-boxes are detected, the list is created. 549 This list is destroyed before calling the final box destructor 550 This list is automatically taken into account during size() and write() functions, and 551 gf_isom_box_write shall not be called in XXXX_box_write on any box registered with the child list 552 553 the full box version field is moved in the base box since we also need some internal flags, as u16 to 554 also be used for audio and video sample entries version field 555 */ 556 #define GF_ISOM_BOX \ 557 u32 type; \ 558 u64 size; \ 559 const struct box_registry_entry *registry;\ 560 GF_List *child_boxes; \ 561 u16 internal_flags; \ 562 u16 version; \ 563 564 #define GF_ISOM_FULL_BOX \ 565 GF_ISOM_BOX \ 566 u32 flags; \ 567 568 #define GF_ISOM_UUID_BOX \ 569 GF_ISOM_BOX \ 570 u8 uuid[16]; \ 571 u32 internal_4cc; \ 572 573 typedef struct 574 { 575 GF_ISOM_BOX 576 } GF_Box; 577 578 typedef struct 579 { 580 GF_ISOM_FULL_BOX 581 } GF_FullBox; 582 583 typedef struct 584 { 585 GF_ISOM_UUID_BOX 586 } GF_UUIDBox; 587 588 589 #define ISOM_DECL_BOX_ALLOC(__TYPE, __4cc) __TYPE *tmp; \ 590 GF_SAFEALLOC(tmp, __TYPE); \ 591 if (tmp==NULL) return NULL; \ 592 tmp->type = __4cc; 593 594 #define ISOM_DECREASE_SIZE(__ptr, bytes) if (__ptr->size < (bytes) ) {\ 595 GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[isom] not enough bytes in box %s: %d left, reading %d (file %s, line %d)\n", gf_4cc_to_str(__ptr->type), (u32) __ptr->size, (bytes), __FILE__, __LINE__ )); \ 596 return GF_ISOM_INVALID_FILE; \ 597 }\ 598 __ptr->size -= bytes; \ 599 600 /*constructor*/ 601 GF_Box *gf_isom_box_new(u32 boxType); 602 //some boxes may have different syntax based on container. Use this constructor for this case 603 GF_Box *gf_isom_box_new_ex(u32 boxType, u32 parentType, Bool skip_logs, Bool is_root_box); 604 605 GF_Err gf_isom_box_write(GF_Box *ptr, GF_BitStream *bs); 606 GF_Err gf_isom_box_read(GF_Box *ptr, GF_BitStream *bs); 607 void gf_isom_box_del(GF_Box *ptr); 608 GF_Err gf_isom_box_size(GF_Box *ptr); 609 610 GF_Err gf_isom_clone_box(GF_Box *src, GF_Box **dst); 611 612 GF_Err gf_isom_box_parse(GF_Box **outBox, GF_BitStream *bs); 613 GF_Err gf_isom_box_array_read(GF_Box *s, GF_BitStream *bs, GF_Err (*check_child_box)(GF_Box *par, GF_Box *b)); 614 GF_Err gf_isom_box_array_read_ex(GF_Box *parent, GF_BitStream *bs, GF_Err (*check_child_box)(GF_Box *par, GF_Box *b), u32 parent_type); 615 616 GF_Err gf_isom_box_parse_ex(GF_Box **outBox, GF_BitStream *bs, u32 parent_type, Bool is_root_box); 617 618 //writes box header - shall be called at the beginning of each xxxx_Write function 619 //this function is not factorized in order to let box serializer modify box type before writing 620 GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs); 621 622 //writes box header then version+flags 623 GF_Err gf_isom_full_box_write(GF_Box *s, GF_BitStream *bs); 624 625 void gf_isom_box_array_del(GF_List *child_boxes); 626 GF_Err gf_isom_box_array_write(GF_Box *parent, GF_List *list, GF_BitStream *bs); 627 GF_Err gf_isom_box_array_size(GF_Box *parent, GF_List *list); 628 629 void gf_isom_check_position(GF_Box *s, GF_Box *child, u32 *pos); 630 void gf_isom_check_position_list(GF_Box *s, GF_List *childlist, u32 *pos); 631 632 Bool gf_box_valid_in_parent(GF_Box *a, const char *parent_4cc); 633 634 void gf_isom_box_array_del_parent(GF_List **child_boxes, GF_List *boxlist); 635 void gf_isom_box_array_reset_parent(GF_List **child_boxes, GF_List *boxlist); 636 637 void gf_isom_box_freeze_order(GF_Box *box); 638 639 640 typedef struct 641 { 642 GF_ISOM_BOX 643 /*note: the data is NEVER loaded to the mdat in this lib*/ 644 u64 dataSize; 645 /* store the file offset when parsing to access the raw data */ 646 u64 bsOffset; 647 u8 *data; 648 } GF_MediaDataBox; 649 650 typedef struct 651 { 652 u64 time; 653 u64 moof_offset; 654 u32 traf_number; 655 u32 trun_number; 656 u32 sample_number; 657 } GF_RandomAccessEntry; 658 659 typedef struct 660 { 661 GF_ISOM_FULL_BOX 662 GF_ISOTrackID track_id; 663 u8 traf_bits; 664 u8 trun_bits; 665 u8 sample_bits; 666 u32 nb_entries; 667 GF_RandomAccessEntry *entries; 668 } GF_TrackFragmentRandomAccessBox; 669 670 typedef struct 671 { 672 GF_ISOM_FULL_BOX 673 u32 container_size; 674 } GF_MovieFragmentRandomAccessOffsetBox; 675 676 typedef struct 677 { 678 GF_ISOM_BOX 679 GF_List* tfra_list; 680 GF_MovieFragmentRandomAccessOffsetBox *mfro; 681 } GF_MovieFragmentRandomAccessBox; 682 683 typedef struct 684 { 685 GF_ISOM_BOX 686 u8 *data; 687 u32 dataSize; 688 u32 original_4cc; 689 } GF_UnknownBox; 690 691 typedef struct 692 { 693 GF_ISOM_UUID_BOX 694 u8 *data; 695 u32 dataSize; 696 } GF_UnknownUUIDBox; 697 698 u32 gf_isom_solve_uuid_box(u8 *UUID); 699 700 typedef struct 701 { 702 GF_ISOM_FULL_BOX 703 u64 creationTime; 704 u64 modificationTime; 705 u32 timeScale; 706 u64 duration; 707 u64 original_duration; 708 GF_ISOTrackID nextTrackID; 709 u32 preferredRate; 710 u16 preferredVolume; 711 char reserved[10]; 712 u32 matrixA; 713 u32 matrixB; 714 u32 matrixU; 715 u32 matrixC; 716 u32 matrixD; 717 u32 matrixV; 718 u32 matrixW; 719 u32 matrixX; 720 u32 matrixY; 721 u32 previewTime; 722 u32 previewDuration; 723 u32 posterTime; 724 u32 selectionTime; 725 u32 selectionDuration; 726 u32 currentTime; 727 } GF_MovieHeaderBox; 728 729 typedef struct 730 { 731 GF_ISOM_FULL_BOX 732 GF_Descriptor *descriptor; 733 } GF_ObjectDescriptorBox; 734 735 /*used for entry list*/ 736 typedef struct 737 { 738 u64 segmentDuration; 739 s64 mediaTime; 740 u32 mediaRate; 741 Bool was_empty_dur; 742 } GF_EdtsEntry; 743 744 typedef struct 745 { 746 GF_ISOM_FULL_BOX 747 GF_List *entryList; 748 } GF_EditListBox; 749 750 typedef struct 751 { 752 GF_ISOM_BOX 753 GF_EditListBox *editList; 754 } GF_EditBox; 755 756 757 /*used to classify boxes in the UserData GF_Box*/ 758 typedef struct 759 { 760 u32 boxType; 761 u8 uuid[16]; 762 GF_List *boxes; 763 } GF_UserDataMap; 764 765 typedef struct 766 { 767 GF_ISOM_BOX 768 GF_List *recordList; 769 } GF_UserDataBox; 770 771 typedef struct 772 { 773 GF_ISOM_BOX 774 GF_MovieHeaderBox *mvhd; 775 GF_ObjectDescriptorBox *iods; 776 GF_UserDataBox *udta; 777 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 778 struct __tag_mvex_box *mvex; 779 #endif 780 /*meta box if any*/ 781 struct __tag_meta_box *meta; 782 /*track boxes*/ 783 GF_List *trackList; 784 785 GF_ISOFile *mov; 786 787 Bool mvex_after_traks; 788 //for compressed mov, stores the difference between compressed and uncompressed payload 789 s32 compressed_diff; 790 //for compressed mov, indicates the file offset of the moov box start 791 u64 file_offset; 792 793 } GF_MovieBox; 794 795 typedef struct 796 { 797 GF_ISOM_FULL_BOX 798 u64 creationTime; 799 u64 modificationTime; 800 GF_ISOTrackID trackID; 801 u32 reserved1; 802 u64 duration; 803 u32 reserved2[2]; 804 u16 layer; 805 u16 alternate_group; 806 u16 volume; 807 u16 reserved3; 808 s32 matrix[9]; 809 u32 width, height; 810 u64 initial_duration; 811 } GF_TrackHeaderBox; 812 813 typedef struct 814 { 815 GF_ISOM_BOX 816 } GF_TrackReferenceBox; 817 818 819 typedef struct { 820 GF_ISOM_BOX 821 GF_List *groups; 822 } GF_TrackGroupBox; 823 824 typedef struct { 825 GF_ISOM_FULL_BOX 826 u32 group_type; 827 u32 track_group_id; 828 } GF_TrackGroupTypeBox; 829 830 typedef struct 831 { 832 GF_ISOM_BOX 833 GF_UserDataBox *udta; 834 GF_TrackHeaderBox *Header; 835 struct __tag_media_box *Media; 836 GF_EditBox *editBox; 837 GF_TrackReferenceBox *References; 838 /*meta box if any*/ 839 struct __tag_meta_box *meta; 840 GF_TrackGroupBox *groups; 841 842 GF_Box *Aperture; 843 844 GF_MovieBox *moov; 845 /*private for media padding*/ 846 u32 padding_bytes; 847 /*private for editing*/ 848 Bool is_unpacked; 849 /*private for checking dependency*/ 850 u32 originalFile; 851 u32 originalID; 852 853 //not sure about piff (not supposed to be stored in moov), but senc is in track according to CENC 854 struct __sample_encryption_box *sample_encryption; 855 856 /*private for SVC/MVC extractors resolution*/ 857 GF_ISONaluExtractMode extractor_mode; 858 Bool has_base_layer; 859 u32 pack_num_samples; 860 861 u64 magic; 862 u32 index; 863 864 #ifndef GPAC_DISABLE_ISOM_WRITE 865 u64 first_dts_chunk; 866 u32 nb_samples_in_cache; 867 u32 chunk_stsd_idx; 868 u32 chunk_cache_size; 869 GF_BitStream *chunk_cache; 870 #endif 871 872 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 873 u64 dts_at_seg_start; 874 u32 sample_count_at_seg_start; 875 Bool first_traf_merged; 876 Bool present_in_scalable_segment; 877 u32 current_traf_stsd_idx; 878 #endif 879 } GF_TrackBox; 880 881 typedef struct 882 { 883 GF_ISOM_FULL_BOX 884 u64 creationTime; 885 u64 modificationTime; 886 u32 timeScale; 887 u64 duration, original_duration; 888 char packedLanguage[4]; 889 u16 reserved; 890 } GF_MediaHeaderBox; 891 892 893 typedef struct 894 { 895 GF_ISOM_FULL_BOX 896 u32 reserved1; 897 u32 handlerType; 898 u8 reserved2[12]; 899 char *nameUTF8; 900 Bool store_counted_string; 901 } GF_HandlerBox; 902 903 typedef struct __tag_media_box 904 { 905 GF_ISOM_BOX 906 GF_TrackBox *mediaTrack; 907 GF_MediaHeaderBox *mediaHeader; 908 GF_HandlerBox *handler; 909 struct __tag_media_info_box *information; 910 u64 BytesMissing; 911 912 //all the following are only used for NALU-based tracks 913 //NALU reader 914 GF_BitStream *nalu_parser; 915 916 GF_BitStream *nalu_out_bs; 917 GF_BitStream *nalu_ps_bs; 918 u8 *in_sample_buffer; 919 u32 in_sample_buffer_alloc; 920 u8 *tmp_nal_copy_buffer; 921 u32 tmp_nal_copy_buffer_alloc; 922 923 GF_ISOSample *extracted_samp; 924 GF_BitStream *extracted_bs; 925 926 } GF_MediaBox; 927 928 typedef struct 929 { 930 GF_ISOM_FULL_BOX 931 char *extended_language; 932 } GF_ExtendedLanguageBox; 933 934 typedef struct 935 { 936 GF_ISOM_FULL_BOX 937 u64 reserved; 938 } GF_VideoMediaHeaderBox; 939 940 typedef struct 941 { 942 GF_ISOM_FULL_BOX 943 944 u16 graphics_mode; 945 u16 op_color_red; 946 u16 op_color_green; 947 u16 op_color_blue; 948 u16 balance; 949 u16 reserved; 950 } GF_GenericMediaHeaderInfoBox; 951 952 typedef struct 953 { 954 GF_ISOM_FULL_BOX 955 u16 balance; 956 u16 reserved; 957 } GF_SoundMediaHeaderBox; 958 959 typedef struct 960 { 961 GF_ISOM_FULL_BOX 962 /*this is used for us INTERNALLY*/ 963 u32 subType; 964 u32 maxPDUSize; 965 u32 avgPDUSize; 966 u32 maxBitrate; 967 u32 avgBitrate; 968 u32 slidingAverageBitrate; 969 } GF_HintMediaHeaderBox; 970 971 typedef struct 972 { 973 GF_ISOM_FULL_BOX 974 } GF_MPEGMediaHeaderBox; 975 976 typedef struct 977 { 978 GF_ISOM_FULL_BOX 979 } GF_SubtitleMediaHeaderBox; 980 981 typedef struct 982 { 983 GF_ISOM_FULL_BOX 984 } GF_ODMediaHeaderBox; 985 986 typedef struct 987 { 988 GF_ISOM_FULL_BOX 989 } GF_OCRMediaHeaderBox; 990 991 typedef struct 992 { 993 GF_ISOM_FULL_BOX 994 } GF_SceneMediaHeaderBox; 995 996 997 typedef struct 998 { 999 GF_ISOM_FULL_BOX 1000 1001 u32 width; 1002 u32 height; 1003 } GF_ApertureBox; 1004 1005 typedef struct 1006 { 1007 GF_ISOM_FULL_BOX 1008 } GF_DataReferenceBox; 1009 1010 typedef struct 1011 { 1012 GF_ISOM_BOX 1013 GF_DataReferenceBox *dref; 1014 } GF_DataInformationBox; 1015 1016 #define GF_ISOM_DATAENTRY_FIELDS \ 1017 char *location; 1018 1019 typedef struct 1020 { 1021 GF_ISOM_FULL_BOX 1022 GF_ISOM_DATAENTRY_FIELDS 1023 } GF_DataEntryBox; 1024 1025 typedef struct 1026 { 1027 GF_ISOM_FULL_BOX 1028 GF_ISOM_DATAENTRY_FIELDS 1029 } GF_DataEntryURLBox; 1030 1031 typedef struct 1032 { 1033 GF_ISOM_FULL_BOX 1034 GF_ISOM_DATAENTRY_FIELDS 1035 } GF_DataEntryAliasBox; 1036 1037 typedef struct 1038 { 1039 GF_ISOM_FULL_BOX 1040 GF_ISOM_DATAENTRY_FIELDS 1041 char *nameURN; 1042 } GF_DataEntryURNBox; 1043 1044 typedef struct 1045 { 1046 u32 sampleCount; 1047 u32 sampleDelta; 1048 } GF_SttsEntry; 1049 1050 typedef struct 1051 { 1052 GF_ISOM_FULL_BOX 1053 GF_SttsEntry *entries; 1054 u32 nb_entries, alloc_size; 1055 1056 #ifndef GPAC_DISABLE_ISOM_WRITE 1057 /*cache for WRITE*/ 1058 u32 w_currentSampleNum; 1059 u64 w_LastDTS; 1060 #endif 1061 /*cache for READ*/ 1062 u32 r_FirstSampleInEntry; 1063 u32 r_currentEntryIndex; 1064 u64 r_CurrentDTS; 1065 1066 //stats for read 1067 u32 max_ts_delta; 1068 } GF_TimeToSampleBox; 1069 1070 1071 /*TO CHECK - it could be reasonnable to only use 16bits for both count and offset*/ 1072 typedef struct 1073 { 1074 u32 sampleCount; 1075 s32 decodingOffset; 1076 } GF_DttsEntry; 1077 1078 typedef struct 1079 { 1080 GF_ISOM_FULL_BOX 1081 GF_DttsEntry *entries; 1082 u32 nb_entries, alloc_size; 1083 1084 #ifndef GPAC_DISABLE_ISOM_WRITE 1085 u32 w_LastSampleNumber; 1086 /*force one sample per entry*/ 1087 Bool unpack_mode; 1088 #endif 1089 /*Cache for read*/ 1090 u32 r_currentEntryIndex; 1091 u32 r_FirstSampleInEntry; 1092 1093 //stats for read 1094 s32 max_ts_delta; 1095 } GF_CompositionOffsetBox; 1096 1097 1098 #define GF_ISOM_SAMPLE_ENTRY_FIELDS \ 1099 GF_ISOM_UUID_BOX \ 1100 u16 dataReferenceIndex; \ 1101 char reserved[ 6 ]; \ 1102 u32 internal_type; \ 1103 1104 /*base sample entry box - used by some generic media sample descriptions of QT*/ 1105 typedef struct 1106 { 1107 GF_ISOM_SAMPLE_ENTRY_FIELDS 1108 } GF_SampleEntryBox; 1109 1110 void gf_isom_sample_entry_init(GF_SampleEntryBox *ptr); 1111 void gf_isom_sample_entry_predestroy(GF_SampleEntryBox *ptr); 1112 GF_Err gf_isom_base_sample_entry_read(GF_SampleEntryBox *ptr, GF_BitStream *bs); 1113 1114 typedef struct 1115 { 1116 GF_ISOM_SAMPLE_ENTRY_FIELDS 1117 /*box type as specified in the file (not this box's type!!)*/ 1118 u32 EntryType; 1119 1120 u8 *data; 1121 u32 data_size; 1122 } GF_GenericSampleEntryBox; 1123 1124 typedef struct 1125 { 1126 GF_ISOM_SAMPLE_ENTRY_FIELDS 1127 1128 u32 flags; 1129 u32 timescale; 1130 u32 frame_duration; 1131 u8 frames_per_counter_tick; 1132 } GF_TimeCodeSampleEntryBox; 1133 1134 typedef struct 1135 { 1136 GF_ISOM_FULL_BOX 1137 1138 u16 text_font; 1139 u16 text_face; 1140 u16 text_size; 1141 u16 text_color_red, text_color_green, text_color_blue; 1142 u16 back_color_red, back_color_green, back_color_blue; 1143 char *font; 1144 } GF_TimeCodeMediaInformationBox; 1145 1146 typedef struct 1147 { 1148 GF_ISOM_BOX 1149 1150 u8 field_count; 1151 u8 field_order; 1152 } GF_FieldInfoBox; 1153 1154 typedef struct 1155 { 1156 GF_ISOM_BOX 1157 u32 gama; 1158 } GF_GamaInfoBox; 1159 1160 typedef struct 1161 { 1162 GF_ISOM_BOX 1163 u16 chroma; 1164 } GF_ChromaInfoBox; 1165 1166 typedef struct 1167 { 1168 u32 label; 1169 u32 flags; 1170 Float coordinates[3]; 1171 } GF_AudioChannelDescription; 1172 1173 typedef struct 1174 { 1175 GF_ISOM_FULL_BOX 1176 1177 u32 layout_tag; 1178 u32 bitmap; 1179 u32 num_audio_description; 1180 GF_AudioChannelDescription *audio_descs; 1181 u8 *ext_data; 1182 u32 ext_data_size; 1183 } GF_ChannelLayoutInfoBox; 1184 1185 1186 typedef struct 1187 { 1188 GF_ISOM_BOX 1189 1190 u32 preload_start_time; 1191 u32 preload_duration; 1192 u32 preload_flags; 1193 u32 default_hints; 1194 } GF_TrackLoadBox; 1195 1196 1197 typedef struct 1198 { 1199 GF_ISOM_FULL_BOX 1200 1201 GF_AudioChannelLayout layout; 1202 } GF_ChannelLayoutBox; 1203 1204 typedef struct 1205 { 1206 GF_ISOM_FULL_BOX 1207 GF_ESD *desc; 1208 } GF_ESDBox; 1209 1210 typedef struct 1211 { 1212 GF_ISOM_BOX 1213 u32 bufferSizeDB; 1214 u32 maxBitrate; 1215 u32 avgBitrate; 1216 } GF_BitRateBox; 1217 1218 GF_BitRateBox *gf_isom_sample_entry_get_bitrate(GF_SampleEntryBox *ent, Bool create); 1219 1220 typedef struct 1221 { 1222 GF_ISOM_BOX 1223 GF_List *descriptors; 1224 } GF_MPEG4ExtensionDescriptorsBox; 1225 1226 /*for most MPEG4 media */ 1227 typedef struct 1228 { 1229 GF_ISOM_SAMPLE_ENTRY_FIELDS 1230 GF_ESDBox *esd; 1231 /*used for hinting when extracting the OD stream...*/ 1232 GF_SLConfig *slc; 1233 } GF_MPEGSampleEntryBox; 1234 1235 typedef struct 1236 { 1237 GF_ISOM_BOX 1238 u8 *hdr; 1239 u32 hdr_size; 1240 } GF_LASERConfigurationBox; 1241 1242 1243 typedef struct 1244 { 1245 GF_ISOM_SAMPLE_ENTRY_FIELDS 1246 1247 GF_LASERConfigurationBox *lsr_config; 1248 GF_MPEG4ExtensionDescriptorsBox *descr; 1249 1250 /*used for hinting when extracting the OD stream...*/ 1251 GF_SLConfig *slc; 1252 } GF_LASeRSampleEntryBox; 1253 1254 /*rewrites avcC based on the given esd - this destroys the esd*/ 1255 GF_Err LSR_UpdateESD(GF_LASeRSampleEntryBox *lsr, GF_ESD *esd); 1256 1257 typedef struct 1258 { 1259 GF_ISOM_BOX 1260 u32 hSpacing; 1261 u32 vSpacing; 1262 } GF_PixelAspectRatioBox; 1263 1264 typedef struct 1265 { 1266 GF_ISOM_BOX 1267 u32 cleanApertureWidthN; 1268 u32 cleanApertureWidthD; 1269 u32 cleanApertureHeightN; 1270 u32 cleanApertureHeightD; 1271 u32 horizOffN; 1272 u32 horizOffD; 1273 u32 vertOffN; 1274 u32 vertOffD; 1275 } GF_CleanApertureBox; 1276 1277 1278 typedef struct __ContentLightLevel { 1279 GF_ISOM_BOX 1280 GF_ContentLightLevelInfo clli; 1281 } GF_ContentLightLevelBox; 1282 1283 typedef struct ___MasteringDisplayColourVolume { 1284 GF_ISOM_BOX 1285 GF_MasteringDisplayColourVolumeInfo mdcv; 1286 } GF_MasteringDisplayColourVolumeBox; 1287 1288 typedef struct 1289 { 1290 GF_ISOM_FULL_BOX 1291 Bool all_ref_pics_intra; 1292 Bool intra_pred_used; 1293 u32 max_ref_per_pic; 1294 u32 reserved; 1295 } GF_CodingConstraintsBox; 1296 1297 typedef struct 1298 { 1299 GF_ISOM_FULL_BOX 1300 char *aux_track_type; 1301 } GF_AuxiliaryTypeInfoBox; 1302 1303 typedef struct 1304 { 1305 GF_ISOM_BOX 1306 u16 predefined_rvc_config; 1307 u32 rvc_meta_idx; 1308 } GF_RVCConfigurationBox; 1309 1310 1311 typedef struct { 1312 GF_ISOM_BOX 1313 Bool is_jp2; 1314 1315 u32 colour_type; 1316 u16 colour_primaries; 1317 u16 transfer_characteristics; 1318 u16 matrix_coefficients; 1319 Bool full_range_flag; 1320 u8 *opaque; 1321 u32 opaque_size; 1322 1323 u8 method, precedence, approx; 1324 } GF_ColourInformationBox; 1325 1326 1327 //do NOT extend this structure with boxes, children boxes shall go into the other_box field of the parent 1328 #define GF_ISOM_VISUAL_SAMPLE_ENTRY \ 1329 GF_ISOM_SAMPLE_ENTRY_FIELDS \ 1330 u16 revision; \ 1331 u32 vendor; \ 1332 u32 temporal_quality; \ 1333 u32 spatial_quality; \ 1334 u16 Width, Height; \ 1335 u32 horiz_res, vert_res; \ 1336 u32 entry_data_size; \ 1337 u16 frames_per_sample; \ 1338 char compressor_name[33]; \ 1339 u16 bit_depth; \ 1340 s16 color_table_index; \ 1341 struct __tag_protect_box *rinf; \ 1342 1343 typedef struct 1344 { 1345 GF_ISOM_VISUAL_SAMPLE_ENTRY 1346 } GF_VisualSampleEntryBox; 1347 1348 void gf_isom_video_sample_entry_init(GF_VisualSampleEntryBox *ent); 1349 GF_Err gf_isom_video_sample_entry_read(GF_VisualSampleEntryBox *ptr, GF_BitStream *bs); 1350 #ifndef GPAC_DISABLE_ISOM_WRITE 1351 void gf_isom_video_sample_entry_write(GF_VisualSampleEntryBox *ent, GF_BitStream *bs); 1352 void gf_isom_video_sample_entry_size(GF_VisualSampleEntryBox *ent); 1353 #endif 1354 1355 void gf_isom_sample_entry_predestroy(GF_SampleEntryBox *ptr); 1356 1357 1358 GF_Box *gf_isom_box_find_child(GF_List *parent_child_list, u32 code); 1359 void gf_isom_box_del_parent(GF_List **parent_child_list, GF_Box*b); 1360 GF_Box *gf_isom_box_new_parent(GF_List **parent_child_list, u32 code); 1361 Bool gf_isom_box_check_unique(GF_List *children, GF_Box *a); 1362 1363 typedef struct 1364 { 1365 GF_ISOM_BOX 1366 GF_AVCConfig *config; 1367 } GF_AVCConfigurationBox; 1368 1369 typedef struct 1370 { 1371 GF_ISOM_BOX 1372 GF_HEVCConfig *config; 1373 } GF_HEVCConfigurationBox; 1374 1375 typedef struct 1376 { 1377 GF_ISOM_BOX 1378 GF_AV1Config *config; 1379 } GF_AV1ConfigurationBox; 1380 1381 typedef struct 1382 { 1383 GF_ISOM_FULL_BOX 1384 GF_VPConfig *config; 1385 } GF_VPConfigurationBox; 1386 1387 typedef struct 1388 { 1389 GF_ISOM_FULL_BOX 1390 u16 primaryRChromaticity_x; 1391 u16 primaryRChromaticity_y; 1392 u16 primaryGChromaticity_x; 1393 u16 primaryGChromaticity_y; 1394 u16 primaryBChromaticity_x; 1395 u16 primaryBChromaticity_y; 1396 u16 whitePointChromaticity_x; 1397 u16 whitePointChromaticity_y; 1398 u32 luminanceMax; 1399 u32 luminanceMin; 1400 } GF_SMPTE2086MasteringDisplayMetadataBox; 1401 1402 typedef struct { 1403 GF_ISOM_FULL_BOX 1404 u16 maxCLL; 1405 u16 maxFALL; 1406 } GF_VPContentLightLevelBox; 1407 1408 typedef struct { 1409 GF_ISOM_BOX 1410 GF_DOVIDecoderConfigurationRecord DOVIConfig; 1411 } GF_DOVIConfigurationBox; 1412 1413 /*typedef struct { //extends Box('hvcE') 1414 GF_ISOM_BOX 1415 GF_HEVCConfig HEVCConfig; 1416 } GF_DolbyVisionELHEVCConfigurationBox;*/ 1417 1418 typedef struct { //extends HEVCSampleEntry('dvhe') 1419 GF_DOVIConfigurationBox config; 1420 //TODO: GF_DolbyVisionELHEVCConfigurationBox ELConfig; // optional 1421 } GF_DolbyVisionHEVCSampleEntry; 1422 1423 typedef struct 1424 { 1425 GF_ISOM_BOX 1426 GF_3GPConfig cfg; 1427 } GF_3GPPConfigBox; 1428 1429 typedef struct 1430 { 1431 GF_ISOM_BOX 1432 1433 u32 width, height; 1434 u16 nb_comp; 1435 u8 bpc, Comp, UnkC, IPR; 1436 } GF_J2KImageHeaderBox; 1437 1438 typedef struct 1439 { 1440 GF_ISOM_BOX 1441 GF_J2KImageHeaderBox *ihdr; 1442 GF_ColourInformationBox *colr; 1443 } GF_J2KHeaderBox; 1444 1445 typedef struct 1446 { 1447 GF_ISOM_VISUAL_SAMPLE_ENTRY 1448 GF_ESDBox *esd; 1449 /*used for Publishing*/ 1450 GF_SLConfig *slc; 1451 1452 /*avc extensions - we merged with regular 'mp4v' box to handle isma E&A signaling of AVC*/ 1453 GF_AVCConfigurationBox *avc_config; 1454 GF_AVCConfigurationBox *svc_config; 1455 GF_AVCConfigurationBox *mvc_config; 1456 /*hevc extension*/ 1457 GF_HEVCConfigurationBox *hevc_config; 1458 GF_HEVCConfigurationBox *lhvc_config; 1459 /*av1 extension*/ 1460 GF_AV1ConfigurationBox *av1_config; 1461 /*vp8-9 extension*/ 1462 GF_VPConfigurationBox *vp_config; 1463 /*jp2k extension*/ 1464 GF_J2KHeaderBox *jp2h; 1465 /*dolbyvision extension*/ 1466 GF_DOVIConfigurationBox *dovi_config; 1467 1468 /*internally emulated esd*/ 1469 GF_ESD *emul_esd; 1470 1471 //3GPP 1472 GF_3GPPConfigBox *cfg_3gpp; 1473 1474 /*iPod's hack*/ 1475 GF_UnknownUUIDBox *ipod_ext; 1476 1477 } GF_MPEGVisualSampleEntryBox; 1478 1479 static const u8 GF_ISOM_IPOD_EXT[][16] = { { 0x6B, 0x68, 0x40, 0xF2, 0x5F, 0x24, 0x4F, 0xC5, 0xBA, 0x39, 0xA5, 0x1B, 0xCF, 0x03, 0x23, 0xF3} }; 1480 1481 Bool gf_isom_is_nalu_based_entry(GF_MediaBox *mdia, GF_SampleEntryBox *_entry); 1482 GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 sampleNumber, GF_MPEGVisualSampleEntryBox *entry); 1483 1484 /*this is the default visual sdst (to handle unknown media)*/ 1485 typedef struct 1486 { 1487 GF_ISOM_VISUAL_SAMPLE_ENTRY 1488 /*box type as specified in the file (not this box's type!!)*/ 1489 u32 EntryType; 1490 /*opaque description data (ESDS in MP4, SMI in SVQ3, ...)*/ 1491 u8 *data; 1492 u32 data_size; 1493 } GF_GenericVisualSampleEntryBox; 1494 1495 enum 1496 { 1497 GF_ISOM_AUDIO_QTFF_NONE = 0, 1498 //sample entry is QTFF and data in extensions() is NOT valid (conversion done by libisomedia) 1499 GF_ISOM_AUDIO_QTFF_ON_NOEXT, 1500 //sample entry is QTFF and data in extensions() is valid (import from QT) 1501 GF_ISOM_AUDIO_QTFF_ON_EXT_VALID, 1502 GF_ISOM_AUDIO_QTFF_CONVERT_FLAG = 1<<16 1503 }; 1504 1505 #define GF_ISOM_AUDIO_SAMPLE_ENTRY \ 1506 GF_ISOM_SAMPLE_ENTRY_FIELDS \ 1507 u16 revision; \ 1508 u32 vendor; \ 1509 u16 channel_count; \ 1510 u16 bitspersample; \ 1511 u16 compression_id; \ 1512 u16 packet_size; \ 1513 u32 qtff_mode; \ 1514 u16 samplerate_hi; \ 1515 u16 samplerate_lo; \ 1516 u8 extensions[36]; \ 1517 1518 1519 typedef struct 1520 { 1521 GF_ISOM_AUDIO_SAMPLE_ENTRY 1522 } GF_AudioSampleEntryBox; 1523 1524 void gf_isom_audio_sample_entry_init(GF_AudioSampleEntryBox *ptr); 1525 GF_Err gf_isom_audio_sample_entry_read(GF_AudioSampleEntryBox *ptr, GF_BitStream *bs); 1526 #ifndef GPAC_DISABLE_ISOM_WRITE 1527 void gf_isom_audio_sample_entry_write(GF_AudioSampleEntryBox *ptr, GF_BitStream *bs); 1528 void gf_isom_audio_sample_entry_size(GF_AudioSampleEntryBox *ptr); 1529 #endif 1530 1531 typedef struct 1532 { 1533 GF_ISOM_BOX 1534 GF_AC3Config cfg; 1535 } GF_AC3ConfigBox; 1536 1537 typedef struct 1538 { 1539 GF_ISOM_FULL_BOX 1540 u8 *data; 1541 u32 dataSize; 1542 } GF_FLACConfigBox; 1543 1544 typedef struct 1545 { 1546 GF_ISOM_BOX 1547 1548 /*OpusSpecificBox*/ 1549 /*u8 version; //1, field included in base box structure */ 1550 u8 OutputChannelCount; //same value as the *Output Channel Count* field in the identification header defined in Ogg Opus [3] 1551 u16 PreSkip; //The value of the PreSkip field shall be at least 80 milliseconds' worth of PCM samples even when removing any number of Opus samples which may or may not contain the priming samples. The PreSkip field is not used for discarding the priming samples at the whole playback at all since it is informative only, and that task falls on the Edit List Box. 1552 u32 InputSampleRate; //The InputSampleRate field shall be set to the same value as the *Input Sample Rate* field in the identification header defined in Ogg Opus 1553 s16 OutputGain; //The OutputGain field shall be set to the same value as the *Output Gain* field in the identification header define in Ogg Opus [3]. Note that the value is stored as 8.8 fixed-point. 1554 u8 ChannelMappingFamily; //The ChannelMappingFamily field shall be set to the same value as the *Channel Mapping Family* field in the identification header defined in Ogg Opus [3]. Note that the value 255 may be used for an alternative to map channels by ISO Base Media native mapping. The details are described in 4.5.1. 1555 1556 u8 StreamCount; // The StreamCount field shall be set to the same value as the *Stream Count* field in the identification header defined in Ogg Opus [3]. 1557 u8 CoupledCount; // The CoupledCount field shall be set to the same value as the *Coupled Count* field in the identification header defined in Ogg Opus [3]. 1558 u8 ChannelMapping[255]; // The ChannelMapping field shall be set to the same octet string as *Channel Mapping* field in the identi- fication header defined in Ogg Opus [3]. 1559 1560 /*for internal box use only*/ 1561 // int channels; 1562 } GF_OpusSpecificBox; 1563 1564 GF_Err gf_isom_opus_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_OpusSpecificBox *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex); 1565 1566 typedef struct 1567 { 1568 GF_ISOM_BOX 1569 u8 configuration_version; 1570 u8 mha_pl_indication; 1571 u8 reference_channel_layout; 1572 u16 mha_config_size; 1573 char *mha_config; 1574 } GF_MHAConfigBox; 1575 1576 1577 typedef struct 1578 { 1579 GF_ISOM_FULL_BOX 1580 u8 format_flags; 1581 u8 PCM_sample_size; 1582 } GF_PCMConfigBox; 1583 1584 1585 typedef struct 1586 { 1587 GF_ISOM_AUDIO_SAMPLE_ENTRY 1588 //for MPEG4 audio 1589 GF_ESDBox *esd; 1590 GF_SLConfig *slc; 1591 //for 3GPP audio 1592 GF_3GPPConfigBox *cfg_3gpp; 1593 1594 //for AC3/EC3 audio 1595 GF_AC3ConfigBox *cfg_ac3; 1596 1597 //for Opus 1598 GF_OpusSpecificBox *cfg_opus; 1599 1600 //for MPEG-H audio 1601 GF_MHAConfigBox *cfg_mha; 1602 1603 //for FLAC 1604 GF_FLACConfigBox *cfg_flac; 1605 1606 } GF_MPEGAudioSampleEntryBox; 1607 1608 /*this is the default visual sdst (to handle unknown media)*/ 1609 typedef struct 1610 { 1611 GF_ISOM_AUDIO_SAMPLE_ENTRY 1612 /*box type as specified in the file (not this box's type!!)*/ 1613 u32 EntryType; 1614 /*opaque description data (ESDS in MP4, ...)*/ 1615 u8 *data; 1616 u32 data_size; 1617 } GF_GenericAudioSampleEntryBox; 1618 1619 1620 typedef struct 1621 { 1622 GF_ISOM_FULL_BOX 1623 u8 profile; 1624 u8 level; 1625 u8 pathComponents; 1626 Bool fullRequestHost; 1627 Bool streamType; 1628 u8 containsRedundant; 1629 char *textEncoding; 1630 char *contentEncoding; 1631 } GF_DIMSSceneConfigBox; 1632 1633 typedef struct 1634 { 1635 GF_ISOM_BOX 1636 char *content_script_types; 1637 } GF_DIMSScriptTypesBox; 1638 1639 typedef struct 1640 { 1641 GF_ISOM_SAMPLE_ENTRY_FIELDS 1642 GF_DIMSSceneConfigBox *config; 1643 GF_DIMSScriptTypesBox *scripts; 1644 } GF_DIMSSampleEntryBox; 1645 1646 1647 typedef struct 1648 { 1649 GF_ISOM_FULL_BOX 1650 char *config; 1651 } GF_TextConfigBox; 1652 1653 /*base metadata sample entry box for METT, METX, SBTT, STXT and STPP*/ 1654 typedef struct 1655 { 1656 GF_ISOM_SAMPLE_ENTRY_FIELDS 1657 char *content_encoding; //optional 1658 char *mime_type; //for anything except metx 1659 char *xml_namespace; //for metx and sttp only 1660 char *xml_schema_loc; // for metx and sttp only 1661 GF_TextConfigBox *config; //optional for anything except metx and sttp 1662 } GF_MetaDataSampleEntryBox; 1663 1664 1665 typedef struct 1666 { 1667 u8 entry_type; 1668 union { 1669 u32 trackID; 1670 u32 output_view_id; 1671 u32 start_view_id; 1672 }; 1673 union { 1674 u16 tierID; 1675 u16 view_count; 1676 }; 1677 } MVCIEntry; 1678 1679 typedef struct 1680 { 1681 GF_ISOM_FULL_BOX 1682 u32 multiview_group_id; 1683 u16 num_entries; 1684 MVCIEntry *entries; 1685 } GF_MultiviewGroupBox; 1686 1687 typedef struct 1688 { 1689 u8 dep_comp_idc; 1690 u16 ref_view_id; 1691 } ViewIDRefViewEntry; 1692 1693 typedef struct 1694 { 1695 u16 view_id; 1696 u16 view_order_index; 1697 u8 texture_in_stream; 1698 u8 texture_in_track; 1699 u8 depth_in_stream; 1700 u8 depth_in_track; 1701 u8 base_view_type; 1702 u16 num_ref_views; 1703 ViewIDRefViewEntry *view_refs; 1704 } ViewIDEntry; 1705 1706 typedef struct 1707 { 1708 GF_ISOM_FULL_BOX 1709 u8 min_temporal_id; 1710 u8 max_temporal_id; 1711 u16 num_views; 1712 ViewIDEntry *views; 1713 } GF_ViewIdentifierBox; 1714 1715 1716 typedef struct 1717 { 1718 GF_ISOM_FULL_BOX 1719 } GF_SampleDescriptionBox; 1720 1721 1722 typedef struct 1723 { 1724 GF_ISOM_FULL_BOX 1725 /*if this is the compact version, sample size is actually fieldSize*/ 1726 u32 sampleSize; 1727 u32 sampleCount; 1728 u32 alloc_size; 1729 u32 *sizes; 1730 //stats for read 1731 u32 max_size; 1732 u64 total_size; 1733 u32 total_samples; 1734 } GF_SampleSizeBox; 1735 1736 typedef struct 1737 { 1738 GF_ISOM_FULL_BOX 1739 u32 nb_entries; 1740 u32 alloc_size; 1741 u32 *offsets; 1742 } GF_ChunkOffsetBox; 1743 1744 typedef struct 1745 { 1746 GF_ISOM_FULL_BOX 1747 u32 nb_entries; 1748 u32 alloc_size; 1749 u64 *offsets; 1750 } GF_ChunkLargeOffsetBox; 1751 1752 typedef struct 1753 { 1754 u32 firstChunk; 1755 u32 nextChunk; 1756 u32 samplesPerChunk; 1757 u32 sampleDescriptionIndex; 1758 u8 isEdited; 1759 } GF_StscEntry; 1760 1761 typedef struct 1762 { 1763 GF_ISOM_FULL_BOX 1764 GF_StscEntry *entries; 1765 u32 alloc_size, nb_entries; 1766 1767 /*0-based cache for READ. In WRITE mode, we always have 1 sample per chunk so no need for a cache*/ 1768 u32 currentIndex; 1769 /*first sample number in this chunk*/ 1770 u32 firstSampleInCurrentChunk; 1771 u32 currentChunk; 1772 u32 ghostNumber; 1773 1774 u32 w_lastSampleNumber; 1775 u32 w_lastChunkNumber; 1776 } GF_SampleToChunkBox; 1777 1778 typedef struct 1779 { 1780 GF_ISOM_FULL_BOX 1781 u32 alloc_size, nb_entries; 1782 u32 *sampleNumbers; 1783 /*cache for READ mode (in write we realloc no matter what)*/ 1784 u32 r_LastSyncSample; 1785 /*0-based index in the array*/ 1786 u32 r_LastSampleIndex; 1787 } GF_SyncSampleBox; 1788 1789 typedef struct 1790 { 1791 u32 shadowedSampleNumber; 1792 s32 syncSampleNumber; 1793 } GF_StshEntry; 1794 1795 typedef struct 1796 { 1797 GF_ISOM_FULL_BOX 1798 GF_List *entries; 1799 /*Cache for read mode*/ 1800 u32 r_LastEntryIndex; 1801 u32 r_LastFoundSample; 1802 } GF_ShadowSyncBox; 1803 1804 typedef struct 1805 { 1806 GF_ISOM_FULL_BOX 1807 u32 nb_entries; 1808 u16 *priorities; 1809 } GF_DegradationPriorityBox; 1810 1811 typedef struct 1812 { 1813 GF_ISOM_FULL_BOX 1814 u32 SampleCount; 1815 u8 *padbits; 1816 } GF_PaddingBitsBox; 1817 1818 typedef struct 1819 { 1820 GF_ISOM_FULL_BOX 1821 u32 sampleCount; 1822 /*each dep type is packed on 1 byte*/ 1823 u8 *sample_info; 1824 } GF_SampleDependencyTypeBox; 1825 1826 1827 typedef struct 1828 { 1829 u32 subsample_size; 1830 u8 subsample_priority; 1831 u8 discardable; 1832 u32 reserved; 1833 } GF_SubSampleEntry; 1834 1835 typedef struct 1836 { 1837 u32 sample_delta; 1838 GF_List *SubSamples; 1839 } GF_SubSampleInfoEntry; 1840 1841 typedef struct 1842 { 1843 GF_ISOM_FULL_BOX 1844 GF_List *Samples; 1845 } GF_SubSampleInformationBox; 1846 1847 Bool gf_isom_get_subsample_types(GF_ISOFile *movie, u32 track, u32 subs_index, u32 *flags); 1848 u32 gf_isom_sample_get_subsample_entry(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 entry_index, GF_SubSampleInfoEntry **sub_sample); 1849 #ifndef GPAC_DISABLE_ISOM_WRITE 1850 GF_Err gf_isom_add_subsample_info(GF_SubSampleInformationBox *sub_samples, u32 sampleNumber, u32 subSampleSize, u8 priority, u32 reserved, Bool discardable); 1851 #endif 1852 1853 /* Use to relate the composition and decoding timeline when signed composition is used*/ 1854 typedef struct 1855 { 1856 GF_ISOM_FULL_BOX 1857 1858 s32 compositionToDTSShift; 1859 s32 leastDecodeToDisplayDelta; 1860 s32 greatestDecodeToDisplayDelta; 1861 s32 compositionStartTime; 1862 s32 compositionEndTime; 1863 } GF_CompositionToDecodeBox; 1864 1865 typedef struct 1866 { 1867 GF_ISOM_FULL_BOX 1868 1869 u32 aux_info_type; 1870 u32 aux_info_type_parameter; 1871 1872 u8 default_sample_info_size; 1873 u32 sample_count, sample_alloc; 1874 u8 *sample_info_size; 1875 1876 u32 cached_sample_num; 1877 u32 cached_prev_size; 1878 } GF_SampleAuxiliaryInfoSizeBox; 1879 1880 typedef struct 1881 { 1882 GF_ISOM_FULL_BOX 1883 1884 u32 aux_info_type; 1885 u32 aux_info_type_parameter; 1886 1887 u8 default_sample_info_size; 1888 u32 entry_count; //1 or stco / trun count 1889 u32 entry_alloc; 1890 u64 *offsets; 1891 1892 u64 offset_first_offset_field; 1893 1894 u32 total_size; 1895 u8 *cached_data; 1896 } GF_SampleAuxiliaryInfoOffsetBox; 1897 1898 typedef struct 1899 { 1900 u32 sample_num; 1901 u8 *moof_template; 1902 u32 moof_template_size; 1903 u64 seg_start_plus_one; 1904 u64 sidx_start; 1905 u64 sidx_end; 1906 u64 moof_start; 1907 u64 mdat_end; 1908 } GF_TrafMapEntry; 1909 1910 typedef struct 1911 { 1912 u32 nb_entries, nb_alloc; 1913 GF_TrafMapEntry *frag_starts; 1914 } GF_TrafToSampleMap; 1915 1916 typedef struct 1917 { 1918 GF_ISOM_BOX 1919 GF_TimeToSampleBox *TimeToSample; 1920 GF_CompositionOffsetBox *CompositionOffset; 1921 GF_CompositionToDecodeBox *CompositionToDecode; 1922 GF_SyncSampleBox *SyncSample; 1923 GF_SampleDescriptionBox *SampleDescription; 1924 GF_SampleSizeBox *SampleSize; 1925 GF_SampleToChunkBox *SampleToChunk; 1926 /*untyped, to handle 32 bits and 64 bits chunkOffsets*/ 1927 GF_Box *ChunkOffset; 1928 GF_ShadowSyncBox *ShadowSync; 1929 GF_DegradationPriorityBox *DegradationPriority; 1930 GF_PaddingBitsBox *PaddingBits; 1931 GF_SampleDependencyTypeBox *SampleDep; 1932 1933 GF_TrafToSampleMap *traf_map; 1934 1935 GF_List *sub_samples; 1936 1937 GF_List *sampleGroups; 1938 GF_List *sampleGroupsDescription; 1939 u32 nb_sgpd_in_stbl; 1940 u32 nb_stbl_boxes; 1941 1942 GF_List *sai_sizes; 1943 GF_List *sai_offsets; 1944 1945 u32 MaxSamplePerChunk, MaxChunkSize; 1946 u16 groupID; 1947 u16 trackPriority; 1948 u32 currentEntryIndex; 1949 1950 Bool no_sync_found; 1951 Bool skip_sample_groups; 1952 } GF_SampleTableBox; 1953 1954 GF_Err stbl_AppendTrafMap(GF_SampleTableBox *stbl, Bool is_seg_start, u64 seg_start_offset, u64 frag_start_offset, u8 *moof_template, u32 moof_template_size, u64 sidx_start, u64 sidx_end); 1955 1956 typedef struct __tag_media_info_box 1957 { 1958 GF_ISOM_BOX 1959 GF_DataInformationBox *dataInformation; 1960 GF_SampleTableBox *sampleTable; 1961 GF_Box *InfoHeader; 1962 struct __tag_data_map *scalableDataHandler; 1963 struct __tag_data_map *dataHandler; 1964 u32 dataEntryIndex; 1965 } GF_MediaInformationBox; 1966 1967 GF_Err stbl_SetDependencyType(GF_SampleTableBox *stbl, u32 sampleNumber, u32 isLeading, u32 dependsOn, u32 dependedOn, u32 redundant); 1968 GF_Err stbl_AppendDependencyType(GF_SampleTableBox *stbl, u32 isLeading, u32 dependsOn, u32 dependedOn, u32 redundant); 1969 GF_Err stbl_AddDependencyType(GF_SampleTableBox *stbl, u32 sampleNumber, u32 isLeading, u32 dependsOn, u32 dependedOn, u32 redundant); 1970 1971 typedef struct 1972 { 1973 GF_ISOM_BOX 1974 u8 *data; 1975 u32 dataSize; 1976 u32 original_4cc; 1977 } GF_FreeSpaceBox; 1978 1979 typedef struct 1980 { 1981 GF_ISOM_BOX 1982 } GF_WideBox; /*Apple*/ 1983 1984 typedef struct 1985 { 1986 GF_ISOM_FULL_BOX 1987 char packedLanguageCode[4]; 1988 char *notice; 1989 } GF_CopyrightBox; 1990 1991 typedef struct 1992 { 1993 GF_ISOM_FULL_BOX 1994 char *schemeURI; 1995 char *value; 1996 } GF_KindBox; 1997 1998 1999 typedef struct 2000 { 2001 char *name; 2002 u64 start_time; 2003 } GF_ChapterEntry; 2004 2005 typedef struct 2006 { 2007 GF_ISOM_FULL_BOX 2008 GF_List *list; 2009 } GF_ChapterListBox; 2010 2011 typedef struct 2012 { 2013 GF_ISOM_BOX 2014 u32 reference_type; 2015 u32 trackIDCount; 2016 GF_ISOTrackID *trackIDs; 2017 } GF_TrackReferenceTypeBox; 2018 2019 typedef struct 2020 { 2021 GF_ISOM_FULL_BOX 2022 u32 grouping_type; 2023 u32 group_id; 2024 u32 entity_id_count; 2025 u32 *entity_ids; 2026 } GF_EntityToGroupTypeBox; 2027 2028 typedef struct 2029 { 2030 GF_ISOM_BOX 2031 u32 majorBrand; 2032 u32 minorVersion; 2033 u32 altCount; 2034 u32 *altBrand; 2035 } GF_FileTypeBox; 2036 2037 typedef struct 2038 { 2039 GF_ISOM_FULL_BOX 2040 u32 *rates; 2041 u32 *times; 2042 u32 count; 2043 } GF_ProgressiveDownloadBox; 2044 2045 typedef struct 2046 { 2047 GF_ISOM_FULL_BOX 2048 u32 switch_group; 2049 u32 alternate_group; 2050 GF_ISOTrackID sub_track_id; 2051 u64 attribute_count; 2052 u32 *attribute_list; 2053 } GF_SubTrackInformationBox; 2054 2055 typedef struct 2056 { 2057 GF_ISOM_FULL_BOX 2058 u32 grouping_type; 2059 u16 nb_groups; 2060 u32 *group_description_index; 2061 } GF_SubTrackSampleGroupBox; 2062 2063 typedef struct 2064 { 2065 GF_ISOM_BOX 2066 GF_SubTrackInformationBox *info; 2067 GF_Box *strd; 2068 } GF_SubTrackBox; 2069 2070 /* 2071 3GPP streaming text boxes 2072 */ 2073 2074 typedef struct 2075 { 2076 GF_ISOM_BOX 2077 u32 entry_count; 2078 GF_FontRecord *fonts; 2079 } GF_FontTableBox; 2080 2081 typedef struct 2082 { 2083 GF_ISOM_SAMPLE_ENTRY_FIELDS \ 2084 u32 displayFlags; 2085 s8 horizontal_justification; 2086 s8 vertical_justification; 2087 /*ARGB*/ 2088 u32 back_color; 2089 GF_BoxRecord default_box; 2090 GF_StyleRecord default_style; 2091 GF_FontTableBox *font_table; 2092 } GF_Tx3gSampleEntryBox; 2093 2094 /*Apple specific*/ 2095 typedef struct 2096 { 2097 GF_ISOM_SAMPLE_ENTRY_FIELDS \ 2098 u32 displayFlags; 2099 u32 textJustification; 2100 char background_color[6], foreground_color[6]; 2101 GF_BoxRecord default_box; 2102 u16 fontNumber; 2103 u16 fontFace; 2104 char reserved1[8]; 2105 u8 reserved2; 2106 u16 reserved3; 2107 char *textName; /*font name*/ 2108 } GF_TextSampleEntryBox; 2109 2110 typedef struct 2111 { 2112 GF_ISOM_BOX 2113 u32 entry_count; 2114 GF_StyleRecord *styles; 2115 } GF_TextStyleBox; 2116 2117 typedef struct 2118 { 2119 GF_ISOM_BOX 2120 u16 startcharoffset; 2121 u16 endcharoffset; 2122 } GF_TextHighlightBox; 2123 2124 typedef struct 2125 { 2126 GF_ISOM_BOX 2127 /*ARGB*/ 2128 u32 hil_color; 2129 } GF_TextHighlightColorBox; 2130 2131 typedef struct 2132 { 2133 u32 highlight_endtime; 2134 u16 start_charoffset; 2135 u16 end_charoffset; 2136 } KaraokeRecord; 2137 2138 typedef struct 2139 { 2140 GF_ISOM_BOX 2141 u32 highlight_starttime; 2142 u16 nb_entries; 2143 KaraokeRecord *records; 2144 } GF_TextKaraokeBox; 2145 2146 typedef struct 2147 { 2148 GF_ISOM_BOX 2149 u32 scroll_delay; 2150 } GF_TextScrollDelayBox; 2151 2152 typedef struct 2153 { 2154 GF_ISOM_BOX 2155 u16 startcharoffset; 2156 u16 endcharoffset; 2157 char *URL; 2158 char *URL_hint; 2159 } GF_TextHyperTextBox; 2160 2161 typedef struct 2162 { 2163 GF_ISOM_BOX 2164 GF_BoxRecord box; 2165 } GF_TextBoxBox; 2166 2167 typedef struct 2168 { 2169 GF_ISOM_BOX 2170 u16 startcharoffset; 2171 u16 endcharoffset; 2172 } GF_TextBlinkBox; 2173 2174 typedef struct 2175 { 2176 GF_ISOM_BOX 2177 u8 wrap_flag; 2178 } GF_TextWrapBox; 2179 2180 typedef struct 2181 { 2182 GF_ISOM_FULL_BOX 2183 u32 switchGroup; 2184 u32 *attributeList; 2185 u32 attributeListCount; 2186 } GF_TrackSelectionBox; 2187 2188 /* 2189 MPEG-21 extensions 2190 */ 2191 typedef struct 2192 { 2193 GF_ISOM_FULL_BOX 2194 char *xml; 2195 } GF_XMLBox; 2196 2197 typedef struct 2198 { 2199 GF_ISOM_FULL_BOX 2200 u32 data_length; 2201 u8 *data; 2202 } GF_BinaryXMLBox; 2203 2204 2205 typedef struct 2206 { 2207 u16 item_ID; 2208 u16 construction_method; 2209 u16 data_reference_index; 2210 u64 base_offset; 2211 #ifndef GPAC_DISABLE_ISOM_WRITE 2212 /*for storage only*/ 2213 u64 original_base_offset; 2214 #endif 2215 GF_List *extent_entries; 2216 } GF_ItemLocationEntry; 2217 2218 void iloc_entry_del(GF_ItemLocationEntry *location); 2219 2220 typedef struct 2221 { 2222 GF_ISOM_FULL_BOX 2223 u8 offset_size; 2224 u8 length_size; 2225 u8 base_offset_size; 2226 u8 index_size; 2227 GF_List *location_entries; 2228 } GF_ItemLocationBox; 2229 2230 typedef struct 2231 { 2232 GF_ISOM_FULL_BOX 2233 u16 item_ID; 2234 } GF_PrimaryItemBox; 2235 2236 typedef struct 2237 { 2238 GF_ISOM_FULL_BOX 2239 GF_List *protection_information; 2240 } GF_ItemProtectionBox; 2241 2242 typedef struct 2243 { 2244 GF_ISOM_FULL_BOX 2245 u16 item_ID; 2246 u16 item_protection_index; 2247 u32 item_type; 2248 /*zero-terminated strings*/ 2249 char *item_name; 2250 char *content_type; 2251 char *content_encoding; 2252 // needed to actually read the resource file, but not written in the MP21 file. 2253 char *full_path; 2254 // if not 0, full_path is actually the data to write. 2255 u32 data_len; 2256 } GF_ItemInfoEntryBox; 2257 2258 typedef struct 2259 { 2260 GF_ISOM_FULL_BOX 2261 GF_List *item_infos; 2262 } GF_ItemInfoBox; 2263 2264 typedef struct 2265 { 2266 GF_ISOM_BOX 2267 u32 reference_type; 2268 u32 from_item_id; 2269 u32 reference_count; 2270 u32 *to_item_IDs; 2271 } GF_ItemReferenceTypeBox; 2272 2273 typedef struct 2274 { 2275 GF_ISOM_FULL_BOX 2276 GF_List *references; 2277 } GF_ItemReferenceBox; 2278 2279 typedef struct 2280 { 2281 GF_ISOM_BOX 2282 u32 data_format; 2283 } GF_OriginalFormatBox; 2284 2285 typedef struct 2286 { 2287 GF_ISOM_FULL_BOX 2288 u32 scheme_type; 2289 u32 scheme_version; 2290 char *URI; 2291 } GF_SchemeTypeBox; 2292 2293 /*ISMACryp specific*/ 2294 typedef struct 2295 { 2296 GF_ISOM_FULL_BOX 2297 /*zero-terminated string*/ 2298 char *URI; 2299 } GF_ISMAKMSBox; 2300 2301 /*ISMACryp specific*/ 2302 typedef struct 2303 { 2304 GF_ISOM_BOX 2305 u64 salt; 2306 } GF_ISMACrypSaltBox; 2307 2308 /*ISMACryp specific*/ 2309 typedef struct __isma_format_box 2310 { 2311 GF_ISOM_FULL_BOX 2312 u8 selective_encryption; 2313 u8 key_indicator_length; 2314 u8 IV_length; 2315 } GF_ISMASampleFormatBox; 2316 2317 typedef struct 2318 { 2319 GF_ISOM_BOX 2320 GF_ISMAKMSBox *ikms; 2321 GF_ISMASampleFormatBox *isfm; 2322 GF_ISMACrypSaltBox *islt; 2323 struct __oma_kms_box *odkm; 2324 struct __cenc_tenc_box *tenc; 2325 struct __piff_tenc_box *piff_tenc; 2326 struct __adobe_drm_key_management_system_box *adkm; 2327 } GF_SchemeInformationBox; 2328 2329 typedef struct __tag_protect_box 2330 { 2331 GF_ISOM_BOX 2332 GF_OriginalFormatBox *original_format; 2333 GF_SchemeTypeBox *scheme_type; 2334 GF_SchemeInformationBox *info; 2335 } GF_ProtectionSchemeInfoBox; 2336 typedef struct __tag_protect_box GF_RestrictedSchemeInfoBox; 2337 2338 typedef struct 2339 { 2340 GF_ISOM_FULL_BOX 2341 GF_List *descriptors; 2342 } GF_IPMPInfoBox; 2343 2344 typedef struct 2345 { 2346 GF_ISOM_FULL_BOX 2347 GF_IPMP_ToolList *ipmp_tools; 2348 GF_List *descriptors; 2349 } GF_IPMPControlBox; 2350 2351 typedef struct { 2352 GF_ISOM_BOX 2353 } GF_ItemPropertyContainerBox; 2354 2355 typedef struct { 2356 GF_ISOM_BOX 2357 GF_ItemPropertyContainerBox *property_container; 2358 struct __item_association_box *property_association; 2359 } GF_ItemPropertiesBox; 2360 2361 typedef struct { 2362 GF_ISOM_BOX 2363 } GF_GroupListBox; 2364 2365 typedef struct __tag_meta_box 2366 { 2367 GF_ISOM_FULL_BOX 2368 GF_HandlerBox *handler; 2369 GF_PrimaryItemBox *primary_resource; 2370 GF_DataInformationBox *file_locations; 2371 GF_ItemLocationBox *item_locations; 2372 GF_ItemProtectionBox *protections; 2373 GF_ItemInfoBox *item_infos; 2374 GF_IPMPControlBox *IPMP_control; 2375 GF_ItemPropertiesBox *item_props; 2376 GF_ItemReferenceBox *item_refs; 2377 } GF_MetaBox; 2378 2379 typedef struct 2380 { 2381 GF_ISOM_FULL_BOX 2382 2383 u32 single_view_allowed; 2384 u32 stereo_scheme; 2385 u32 sit_len; 2386 char *stereo_indication_type; 2387 } GF_StereoVideoBox; 2388 2389 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 2390 2391 /*V2 boxes - Movie Fragments*/ 2392 2393 typedef struct 2394 { 2395 GF_ISOM_FULL_BOX 2396 u64 fragment_duration; 2397 } GF_MovieExtendsHeaderBox; 2398 2399 2400 typedef struct __tag_mvex_box 2401 { 2402 GF_ISOM_BOX 2403 GF_List *TrackExList; 2404 GF_List *TrackExPropList; 2405 GF_MovieExtendsHeaderBox *mehd; 2406 GF_ISOFile *mov; 2407 } GF_MovieExtendsBox; 2408 2409 /*the TrackExtends contains default values for the track fragments*/ 2410 typedef struct 2411 { 2412 GF_ISOM_FULL_BOX 2413 GF_ISOTrackID trackID; 2414 u32 def_sample_desc_index; 2415 u32 def_sample_duration; 2416 u32 def_sample_size; 2417 u32 def_sample_flags; 2418 GF_TrackBox *track; 2419 2420 Bool cannot_use_default; 2421 GF_ISOTrackID inherit_from_traf_id; 2422 2423 GF_TrackFragmentRandomAccessBox *tfra; 2424 } GF_TrackExtendsBox; 2425 2426 /*the TrackExtends contains default values for the track fragments*/ 2427 typedef struct 2428 { 2429 GF_ISOM_FULL_BOX 2430 GF_ISOTrackID trackID; 2431 } GF_TrackExtensionPropertiesBox; 2432 2433 /*indicates the seq num of this fragment*/ 2434 typedef struct 2435 { 2436 GF_ISOM_FULL_BOX 2437 u32 sequence_number; 2438 } GF_MovieFragmentHeaderBox; 2439 2440 /*MovieFragment is a container IN THE FILE, contains 1 fragment*/ 2441 typedef struct 2442 { 2443 GF_ISOM_BOX 2444 GF_MovieFragmentHeaderBox *mfhd; 2445 GF_List *TrackList; 2446 GF_List *PSSHs; 2447 GF_ISOFile *mov; 2448 /*offset in the file of moof or mdat (whichever comes first) for this fragment*/ 2449 u64 fragment_offset; 2450 u32 mdat_size; 2451 u8 *mdat; 2452 //when moof box was a compressed moof box, indicates the difference between the uncompressed size and the compressed size 2453 s32 compressed_diff; 2454 2455 //temp storage of prft box 2456 GF_ISOTrackID reference_track_ID; 2457 u64 ntp, timestamp; 2458 } GF_MovieFragmentBox; 2459 2460 2461 /*FLAGS for TRAF*/ 2462 enum 2463 { 2464 GF_ISOM_TRAF_BASE_OFFSET = 0x01, 2465 GF_ISOM_TRAF_SAMPLE_DESC = 0x02, 2466 GF_ISOM_TRAF_SAMPLE_DUR = 0x08, 2467 GF_ISOM_TRAF_SAMPLE_SIZE = 0x10, 2468 GF_ISOM_TRAF_SAMPLE_FLAGS = 0x20, 2469 GF_ISOM_TRAF_DUR_EMPTY = 0x10000, 2470 GF_ISOM_MOOF_BASE_OFFSET = 0x20000, 2471 }; 2472 2473 typedef struct 2474 { 2475 GF_ISOM_FULL_BOX 2476 GF_ISOTrackID trackID; 2477 /* all the following are optional fields */ 2478 u64 base_data_offset; 2479 u32 sample_desc_index; 2480 u32 def_sample_duration; 2481 u32 def_sample_size; 2482 u32 def_sample_flags; 2483 u32 EmptyDuration; 2484 } GF_TrackFragmentHeaderBox; 2485 2486 2487 typedef struct 2488 { 2489 GF_ISOM_FULL_BOX 2490 u64 baseMediaDecodeTime; 2491 } GF_TFBaseMediaDecodeTimeBox; 2492 2493 typedef struct 2494 { 2495 GF_ISOM_BOX 2496 GF_TrackFragmentHeaderBox *tfhd; 2497 GF_List *TrackRuns; 2498 /*keep a pointer to default flags*/ 2499 GF_TrackExtendsBox *trex; 2500 GF_SampleDependencyTypeBox *sdtp; 2501 2502 // GF_SubSampleInformationBox *subs; 2503 GF_List *sub_samples; 2504 2505 GF_List *sampleGroups; 2506 GF_List *sampleGroupsDescription; 2507 2508 GF_List *sai_sizes; 2509 GF_List *sai_offsets; 2510 2511 //can be senc or PIFF psec 2512 struct __sample_encryption_box *sample_encryption; 2513 struct __traf_mss_timeext_box *tfxd; /*similar to PRFT but for Smooth Streaming*/ 2514 2515 /*when data caching is on*/ 2516 u32 DataCache; 2517 GF_TFBaseMediaDecodeTimeBox *tfdt; 2518 2519 u64 moof_start_in_bs; 2520 #ifdef GF_ENABLE_CTRN 2521 Bool use_ctrn; 2522 Bool use_inherit; 2523 #endif 2524 2525 u32 interleave_id; 2526 u8 merge_sample_interleave; 2527 u8 use_sample_interleave; 2528 u8 force_new_trun; 2529 u8 IFrameSwitching; 2530 u8 use_sdtp; 2531 } GF_TrackFragmentBox; 2532 2533 GF_TrackFragmentBox *gf_isom_get_traf(GF_ISOFile *mov, GF_ISOTrackID TrackID); 2534 2535 /*FLAGS for TRUN : specify what is written in the SampleTable of TRUN*/ 2536 enum 2537 { 2538 /*common to both trun and ctrn*/ 2539 GF_ISOM_TRUN_DATA_OFFSET = 0x01, 2540 /*trun flags*/ 2541 GF_ISOM_TRUN_FIRST_FLAG = 0x04, 2542 GF_ISOM_TRUN_DURATION = 0x100, 2543 GF_ISOM_TRUN_SIZE = 0x200, 2544 GF_ISOM_TRUN_FLAGS = 0x400, 2545 GF_ISOM_TRUN_CTS_OFFSET = 0x800, 2546 2547 #ifdef GF_ENABLE_CTRN 2548 /*compact trun flags (not all of them, field indices are stored in trun box)*/ 2549 GF_ISOM_CTRN_FIRST_SAMPLE = 1<<1, //0x00000002 2550 GF_ISOM_CTRN_DATAOFFSET_16 = 1<<2, //0x00000004 2551 GF_ISOM_CTRN_CTSO_MULTIPLIER = 1<<3, //0x00000008 2552 2553 GF_ISOM_CTRN_INHERIT_CTSO = 1<<4, 2554 GF_ISOM_CTRN_INHERIT_FLAGS = 1<<5, 2555 GF_ISOM_CTRN_INHERIT_SIZE = 1<<6, 2556 GF_ISOM_CTRN_INHERIT_DUR = 1<<7 2557 #endif 2558 2559 }; 2560 2561 typedef struct 2562 { 2563 GF_ISOM_FULL_BOX 2564 u32 sample_count; 2565 /*the following are optional fields */ 2566 /* unsigned for version 0 */ 2567 s32 data_offset; 2568 /*can be empty*/ 2569 GF_List *entries; 2570 2571 /*only for trun, ignored for ctrn*/ 2572 u32 first_sample_flags; 2573 2574 /*in write mode with data caching*/ 2575 GF_BitStream *cache; 2576 2577 #ifdef GF_ENABLE_CTRN 2578 /*the remaining is internal for compact trun*/ 2579 /*use compact mode*/ 2580 Bool use_ctrn; 2581 /*we store the ctrn box flags here rather than in flags and swap when writing/dumping. This avoids overwriting the flags 2582 set by the fragment writer*/ 2583 u32 ctrn_flags; 2584 /*set to default sample duration when writing, parsed from box otherwise. If 0, not used*/ 2585 u32 ctso_multiplier; 2586 u8 ctrn_first_dur, ctrn_first_size, ctrn_first_sample_flags, ctrn_first_ctts; 2587 u8 ctrn_dur, ctrn_size, ctrn_sample_flags, ctrn_ctts; 2588 /*use inherit in write mode- in the current version, only size will be set and all other fields inherited*/ 2589 Bool use_inherit; 2590 #endif 2591 2592 u32 interleave_id; 2593 u32 first_sample_idx; 2594 u32 *sample_order; 2595 } GF_TrackFragmentRunBox; 2596 2597 #ifdef GF_ENABLE_CTRN 2598 u32 gf_isom_ctrn_field_size_bits(u32 field_idx); 2599 #endif 2600 2601 typedef struct 2602 { 2603 u32 Duration; 2604 u32 size; 2605 u32 flags; 2606 s32 CTS_Offset; 2607 2608 /*internal*/ 2609 u32 SAP_type; 2610 u64 dts; 2611 u32 nb_pack; 2612 } GF_TrunEntry; 2613 2614 #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/ 2615 2616 2617 /*RTP Hint Track Sample Entry*/ 2618 typedef struct 2619 { 2620 GF_ISOM_SAMPLE_ENTRY_FIELDS 2621 u16 HintTrackVersion; 2622 u16 LastCompatibleVersion; 2623 u32 MaxPacketSize; 2624 // GF_List *HintDataTable; 2625 /*this is where we store the current RTP sample in read/write mode*/ 2626 struct __tag_hint_sample *hint_sample; 2627 /*current hint sample in read mode, 1-based (0 is reset)*/ 2628 u32 cur_sample; 2629 u32 pck_sn, ts_offset, ssrc; 2630 GF_TrackReferenceTypeBox *hint_ref; 2631 2632 //for FEC 2633 u16 partition_entry_ID, FEC_overhead; 2634 } GF_HintSampleEntryBox; 2635 2636 2637 typedef struct 2638 { 2639 GF_ISOM_BOX 2640 u32 subType; 2641 char *sdpText; 2642 } GF_RTPBox; 2643 2644 typedef struct 2645 { 2646 GF_ISOM_BOX 2647 char *sdpText; 2648 } GF_SDPBox; 2649 2650 typedef struct 2651 { 2652 GF_ISOM_BOX 2653 s32 timeOffset; 2654 } GF_RTPOBox; 2655 2656 typedef struct 2657 { 2658 GF_ISOM_BOX 2659 /*contains GF_SDPBox if in track, GF_RTPBox if in movie*/ 2660 GF_Box *SDP; 2661 } GF_HintTrackInfoBox; 2662 2663 typedef struct 2664 { 2665 GF_ISOM_BOX 2666 u8 reserved; 2667 u8 preferred; 2668 u8 required; 2669 } GF_RelyHintBox; 2670 2671 /*********************************************************** 2672 data entry tables for RTP 2673 ***********************************************************/ 2674 typedef struct 2675 { 2676 GF_ISOM_BOX 2677 u32 timeScale; 2678 } GF_TSHintEntryBox; 2679 2680 typedef struct 2681 { 2682 GF_ISOM_BOX 2683 u32 TimeOffset; 2684 } GF_TimeOffHintEntryBox; 2685 2686 typedef struct 2687 { 2688 GF_ISOM_BOX 2689 u32 SeqOffset; 2690 } GF_SeqOffHintEntryBox; 2691 2692 2693 2694 /*********************************************************** 2695 hint track information boxes for RTP 2696 ***********************************************************/ 2697 2698 /*Total number of bytes that will be sent, including 12-byte RTP headers, but not including any network headers*/ 2699 typedef struct 2700 { 2701 GF_ISOM_BOX 2702 u64 nbBytes; 2703 } GF_TRPYBox; 2704 2705 /*32-bits version of trpy used in Darwin*/ 2706 typedef struct 2707 { 2708 GF_ISOM_BOX 2709 u32 nbBytes; 2710 } GF_TOTLBox; 2711 2712 /*Total number of network packets that will be sent*/ 2713 typedef struct 2714 { 2715 GF_ISOM_BOX 2716 u64 nbPackets; 2717 } GF_NUMPBox; 2718 2719 /*32-bits version of nump used in Darwin*/ 2720 typedef struct 2721 { 2722 GF_ISOM_BOX 2723 u32 nbPackets; 2724 } GF_NPCKBox; 2725 2726 2727 /*Total number of bytes that will be sent, not including 12-byte RTP headers*/ 2728 typedef struct 2729 { 2730 GF_ISOM_BOX 2731 u64 nbBytes; 2732 } GF_NTYLBox; 2733 2734 /*32-bits version of tpyl used in Darwin*/ 2735 typedef struct 2736 { 2737 GF_ISOM_BOX 2738 u32 nbBytes; 2739 } GF_TPAYBox; 2740 2741 /*Maximum data rate in bits per second.*/ 2742 typedef struct 2743 { 2744 GF_ISOM_BOX 2745 u32 granularity; 2746 u32 maxDataRate; 2747 } GF_MAXRBox; 2748 2749 2750 /*Total number of bytes from the media track to be sent*/ 2751 typedef struct 2752 { 2753 GF_ISOM_BOX 2754 u64 nbBytes; 2755 } GF_DMEDBox; 2756 2757 /*Number of bytes of immediate data to be sent*/ 2758 typedef struct 2759 { 2760 GF_ISOM_BOX 2761 u64 nbBytes; 2762 } GF_DIMMBox; 2763 2764 2765 /*Number of bytes of repeated data to be sent*/ 2766 typedef struct 2767 { 2768 GF_ISOM_BOX 2769 u64 nbBytes; 2770 } GF_DREPBox; 2771 2772 /*Smallest relative transmission time, in milliseconds. signed integer for smoothing*/ 2773 typedef struct 2774 { 2775 GF_ISOM_BOX 2776 s32 minTime; 2777 } GF_TMINBox; 2778 2779 /*Largest relative transmission time, in milliseconds.*/ 2780 typedef struct 2781 { 2782 GF_ISOM_BOX 2783 s32 maxTime; 2784 } GF_TMAXBox; 2785 2786 /*Largest packet, in bytes, including 12-byte RTP header*/ 2787 typedef struct 2788 { 2789 GF_ISOM_BOX 2790 u32 maxSize; 2791 } GF_PMAXBox; 2792 2793 /*Longest packet duration, in milliseconds*/ 2794 typedef struct 2795 { 2796 GF_ISOM_BOX 2797 u32 maxDur; 2798 } GF_DMAXBox; 2799 2800 /*32-bit payload type number, followed by rtpmap payload string */ 2801 typedef struct 2802 { 2803 GF_ISOM_BOX 2804 u32 payloadCode; 2805 char *payloadString; 2806 } GF_PAYTBox; 2807 2808 2809 typedef struct 2810 { 2811 GF_ISOM_BOX 2812 char *string; 2813 } GF_NameBox; 2814 2815 typedef struct 2816 { 2817 GF_ISOM_BOX 2818 } GF_HintInfoBox; 2819 2820 typedef struct 2821 { 2822 GF_ISOM_BOX 2823 u8 timestamp_sync; 2824 } GF_TimeStampSynchronyBox; 2825 2826 typedef struct 2827 { 2828 GF_ISOM_BOX 2829 u32 ssrc; 2830 } GF_ReceivedSsrcBox; 2831 2832 2833 typedef struct 2834 { 2835 GF_ISOM_FULL_BOX 2836 u32 encryption_algorithm_rtp; 2837 u32 encryption_algorithm_rtcp; 2838 u32 integrity_algorithm_rtp; 2839 u32 integrity_algorithm_rtcp; 2840 2841 GF_SchemeTypeBox *scheme_type; 2842 GF_SchemeInformationBox *info; 2843 } GF_SRTPProcessBox; 2844 2845 /*Apple extension*/ 2846 2847 typedef struct 2848 { 2849 GF_ISOM_FULL_BOX 2850 u32 reserved; 2851 u8 *data; 2852 u32 dataSize; 2853 Bool qt_style; 2854 } GF_DataBox; 2855 2856 typedef struct 2857 { 2858 GF_ISOM_BOX 2859 GF_DataBox *data; 2860 } GF_ListItemBox; 2861 2862 typedef struct 2863 { 2864 GF_ISOM_BOX 2865 } GF_ItemListBox; 2866 2867 /*DECE*/ 2868 typedef struct 2869 { 2870 u8 pic_type; 2871 u8 dependency_level; 2872 } GF_TrickPlayBoxEntry; 2873 2874 typedef struct 2875 { 2876 GF_ISOM_FULL_BOX 2877 u32 entry_count; 2878 GF_TrickPlayBoxEntry *entries; 2879 } GF_TrickPlayBox; 2880 2881 typedef struct 2882 { 2883 GF_ISOM_FULL_BOX 2884 u8 baseLocation[256]; 2885 u8 basePurlLocation[256]; 2886 } GF_BaseLocationBox; 2887 2888 typedef struct 2889 { 2890 GF_ISOM_FULL_BOX 2891 u32 profile_version; 2892 char *APID; 2893 } GF_AssetInformationBox; 2894 2895 /*OMA (P)DCF extensions*/ 2896 typedef struct 2897 { 2898 GF_ISOM_FULL_BOX 2899 u8 EncryptionMethod; 2900 u8 PaddingScheme; 2901 u64 PlaintextLength; 2902 char *ContentID; 2903 char *RightsIssuerURL; 2904 char *TextualHeaders; 2905 u32 TextualHeadersLen; 2906 } GF_OMADRMCommonHeaderBox; 2907 2908 typedef struct 2909 { 2910 GF_ISOM_FULL_BOX 2911 u8 GKEncryptionMethod; 2912 char *GroupID; 2913 u16 GKLength; 2914 char *GroupKey; 2915 } GF_OMADRMGroupIDBox; 2916 2917 typedef struct 2918 { 2919 GF_ISOM_BOX 2920 } GF_OMADRMMutableInformationBox; 2921 2922 typedef struct 2923 { 2924 GF_ISOM_FULL_BOX 2925 char TransactionID[16]; 2926 } GF_OMADRMTransactionTrackingBox; 2927 2928 typedef struct 2929 { 2930 GF_ISOM_FULL_BOX 2931 u8 *oma_ro; 2932 u32 oma_ro_size; 2933 } GF_OMADRMRightsObjectBox; 2934 2935 /*identical*/ 2936 typedef struct __isma_format_box GF_OMADRMAUFormatBox; 2937 2938 typedef struct __oma_kms_box 2939 { 2940 GF_ISOM_FULL_BOX 2941 GF_OMADRMCommonHeaderBox *hdr; 2942 GF_OMADRMAUFormatBox *fmt; 2943 } GF_OMADRMKMSBox; 2944 2945 typedef struct 2946 { 2947 Bool reference_type; 2948 u32 reference_size; 2949 u32 subsegment_duration; 2950 Bool starts_with_SAP; 2951 u32 SAP_type; 2952 u32 SAP_delta_time; 2953 } GF_SIDXReference; 2954 2955 typedef struct __sidx_box 2956 { 2957 GF_ISOM_FULL_BOX 2958 2959 u32 reference_ID; 2960 u32 timescale; 2961 u64 earliest_presentation_time; 2962 u64 first_offset; 2963 u32 nb_refs; 2964 GF_SIDXReference *refs; 2965 //for trace only 2966 s32 compressed_diff; 2967 } GF_SegmentIndexBox; 2968 2969 GF_Err gf_isom_set_fragment_template(GF_ISOFile *movie, u8 *tpl_data, u32 tpl_size, Bool *has_tfdt, GF_SegmentIndexBox **out_sidx); 2970 2971 typedef struct 2972 { 2973 u8 level; 2974 u32 range_size; 2975 } GF_SubsegmentRangeInfo; 2976 2977 typedef struct 2978 { 2979 u32 range_count; 2980 GF_SubsegmentRangeInfo *ranges; 2981 } GF_SubsegmentInfo; 2982 2983 typedef struct __ssix_box 2984 { 2985 GF_ISOM_FULL_BOX 2986 2987 u32 subsegment_count, subsegment_alloc; 2988 GF_SubsegmentInfo *subsegments; 2989 //for trace only 2990 s32 compressed_diff; 2991 } GF_SubsegmentIndexBox; 2992 2993 typedef struct 2994 { 2995 GF_ISOTrackID track_id; 2996 Bool padding_flag; 2997 u8 type; 2998 u32 grouping_type; 2999 u32 grouping_type_parameter; 3000 GF_ISOTrackID sub_track_id; 3001 } GF_LevelAssignment; 3002 3003 typedef struct __leva_box 3004 { 3005 GF_ISOM_FULL_BOX 3006 3007 u32 level_count; 3008 GF_LevelAssignment *levels; 3009 } GF_LevelAssignmentBox; 3010 3011 typedef struct __pcrInfo_box 3012 { 3013 GF_ISOM_BOX 3014 u32 subsegment_count; 3015 u64 *pcr_values; 3016 } GF_PcrInfoBox; 3017 3018 3019 typedef struct 3020 { 3021 GF_ISOM_FULL_BOX 3022 char *scheme_id_uri; 3023 char *value; 3024 u32 timescale; 3025 u64 presentation_time_delta; 3026 u32 event_duration; 3027 u32 event_id; 3028 u8 *message_data; 3029 u32 message_data_size; 3030 } GF_EventMessageBox; 3031 3032 3033 #ifndef GPAC_DISABLE_ISOM_ADOBE 3034 3035 /*Adobe specific boxes*/ 3036 typedef struct 3037 { 3038 u64 time; 3039 u64 offset; 3040 } GF_AfraEntry; 3041 3042 typedef struct 3043 { 3044 u64 time; 3045 u32 segment; 3046 u32 fragment; 3047 u64 afra_offset; 3048 u64 offset_from_afra; 3049 } GF_GlobalAfraEntry; 3050 3051 typedef struct __adobe_frag_random_access_box 3052 { 3053 GF_ISOM_FULL_BOX 3054 Bool long_ids; 3055 Bool long_offsets; 3056 Bool global_entries; 3057 u8 reserved; 3058 u32 time_scale; 3059 u32 entry_count; 3060 GF_List *local_access_entries; 3061 u32 global_entry_count; 3062 GF_List *global_access_entries; 3063 } GF_AdobeFragRandomAccessBox; 3064 3065 typedef struct __adobe_bootstrap_info_box 3066 { 3067 GF_ISOM_FULL_BOX 3068 u32 bootstrapinfo_version; 3069 u8 profile; 3070 Bool live; 3071 Bool update; 3072 u8 reserved; 3073 u32 time_scale; 3074 u64 current_media_time; 3075 u64 smpte_time_code_offset; 3076 char *movie_identifier; 3077 u8 server_entry_count; 3078 GF_List *server_entry_table; 3079 u8 quality_entry_count; 3080 GF_List *quality_entry_table; 3081 char *drm_data; 3082 char *meta_data; 3083 //entries in these two lists are NOT registered with the box child_boxes because of the inbetween 8 bits !! 3084 u8 segment_run_table_count; 3085 GF_List *segment_run_table_entries; 3086 u8 fragment_run_table_count; 3087 GF_List *fragment_run_table_entries; 3088 } GF_AdobeBootstrapInfoBox; 3089 3090 typedef struct 3091 { 3092 u32 first_segment; 3093 u32 fragment_per_segment; 3094 } GF_AdobeSegmentRunEntry; 3095 3096 typedef struct __adobe_segment_run_table_box 3097 { 3098 GF_ISOM_FULL_BOX 3099 u8 quality_entry_count; 3100 GF_List *quality_segment_url_modifiers; 3101 u32 segment_run_entry_count; 3102 GF_List *segment_run_entry_table; 3103 } GF_AdobeSegmentRunTableBox; 3104 3105 typedef struct 3106 { 3107 u32 first_fragment; 3108 u64 first_fragment_timestamp; 3109 u32 fragment_duration; 3110 u8 discontinuity_indicator; 3111 } GF_AdobeFragmentRunEntry; 3112 3113 typedef struct __adobe_fragment_run_table_box 3114 { 3115 GF_ISOM_FULL_BOX 3116 u32 timescale; 3117 u8 quality_entry_count; 3118 GF_List *quality_segment_url_modifiers; 3119 u32 fragment_run_entry_count; 3120 GF_List *fragment_run_entry_table; 3121 } GF_AdobeFragmentRunTableBox; 3122 3123 #endif /*GPAC_DISABLE_ISOM_ADOBE*/ 3124 3125 3126 /*********************************************************** 3127 Sample Groups 3128 ***********************************************************/ 3129 typedef struct 3130 { 3131 u32 sample_count; 3132 u32 group_description_index; 3133 } GF_SampleGroupEntry; 3134 3135 typedef struct 3136 { 3137 GF_ISOM_FULL_BOX 3138 u32 grouping_type; 3139 u32 grouping_type_parameter; 3140 3141 u32 entry_count; 3142 GF_SampleGroupEntry *sample_entries; 3143 3144 } GF_SampleGroupBox; 3145 3146 typedef struct 3147 { 3148 GF_ISOM_FULL_BOX 3149 u32 grouping_type; 3150 u32 default_length; 3151 3152 u32 default_description_index; 3153 GF_List *group_descriptions; 3154 } GF_SampleGroupDescriptionBox; 3155 3156 /*default entry */ 3157 typedef struct 3158 { 3159 u32 length; 3160 u8 *data; 3161 } GF_DefaultSampleGroupDescriptionEntry; 3162 3163 /*VisualRandomAccessEntry - 'rap ' type*/ 3164 typedef struct 3165 { 3166 u8 num_leading_samples_known; 3167 u8 num_leading_samples; 3168 } GF_VisualRandomAccessEntry; 3169 3170 /*RollRecoveryEntry - 'roll' and prol type*/ 3171 typedef struct 3172 { 3173 s16 roll_distance; 3174 } GF_RollRecoveryEntry; 3175 3176 /*TemporalLevelEntry - 'tele' type*/ 3177 typedef struct 3178 { 3179 Bool level_independently_decodable; 3180 } GF_TemporalLevelEntry; 3181 3182 /*SAPEntry - 'sap ' type*/ 3183 typedef struct 3184 { 3185 Bool dependent_flag; 3186 u8 SAP_type; 3187 } GF_SAPEntry; 3188 3189 /*SAPEntry - 'sync' type*/ 3190 typedef struct 3191 { 3192 u8 NALU_type; 3193 } GF_SYNCEntry; 3194 3195 /*Operating Points Information - 'oinf' type*/ 3196 typedef struct 3197 { 3198 u16 scalability_mask; 3199 GF_List* profile_tier_levels; 3200 GF_List* operating_points; 3201 GF_List* dependency_layers; 3202 } GF_OperatingPointsInformation; 3203 3204 GF_OperatingPointsInformation *gf_isom_oinf_new_entry(); 3205 void gf_isom_oinf_del_entry(void *entry); 3206 GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs); 3207 GF_Err gf_isom_oinf_write_entry(void *entry, GF_BitStream *bs); 3208 u32 gf_isom_oinf_size_entry(void *entry); 3209 Bool gf_isom_get_oinf_info(GF_ISOFile *file, u32 trackNumber, GF_OperatingPointsInformation **ptr); 3210 3211 3212 /*Operating Points Information - 'oinf' type*/ 3213 typedef struct 3214 { 3215 u8 layer_id; 3216 u8 min_TemporalId; 3217 u8 max_TemporalId; 3218 u8 sub_layer_presence_flags; 3219 } LHVCLayerInfoItem; 3220 3221 typedef struct 3222 { 3223 GF_List* num_layers_in_track; 3224 } GF_LHVCLayerInformation; 3225 3226 GF_LHVCLayerInformation *gf_isom_linf_new_entry(); 3227 void gf_isom_linf_del_entry(void *entry); 3228 GF_Err gf_isom_linf_read_entry(void *entry, GF_BitStream *bs); 3229 GF_Err gf_isom_linf_write_entry(void *entry, GF_BitStream *bs); 3230 u32 gf_isom_linf_size_entry(void *entry); 3231 Bool gf_isom_get_linf_info(GF_ISOFile *file, u32 trackNumber, GF_LHVCLayerInformation **ptr); 3232 3233 3234 #define MAX_LHEVC_LAYERS 64 3235 3236 typedef struct 3237 { 3238 u8 general_profile_space, general_tier_flag, general_profile_idc, general_level_idc; 3239 u32 general_profile_compatibility_flags; 3240 u64 general_constraint_indicator_flags; 3241 } LHEVC_ProfileTierLevel; 3242 3243 typedef struct 3244 { 3245 u8 ptl_idx; 3246 u8 layer_id; 3247 Bool is_outputlayer, is_alternate_outputlayer; 3248 } LHEVC_LayerInfo; 3249 3250 typedef struct 3251 { 3252 u16 output_layer_set_idx; 3253 u8 max_temporal_id; 3254 u8 layer_count; 3255 LHEVC_LayerInfo layers_info[MAX_LHEVC_LAYERS]; 3256 u16 minPicWidth, minPicHeight, maxPicWidth, maxPicHeight; 3257 u8 maxChromaFormat, maxBitDepth; 3258 Bool frame_rate_info_flag, bit_rate_info_flag; 3259 u16 avgFrameRate; 3260 u8 constantFrameRate; 3261 u32 maxBitRate, avgBitRate; 3262 } LHEVC_OperatingPoint; 3263 3264 3265 typedef struct 3266 { 3267 u8 dependent_layerID; 3268 u8 num_layers_dependent_on; 3269 u8 dependent_on_layerID[MAX_LHEVC_LAYERS]; 3270 u8 dimension_identifier[16]; 3271 } LHEVC_DependentLayer; 3272 3273 3274 3275 /* 3276 CENC stuff 3277 */ 3278 3279 /*CENCSampleEncryptionGroupEntry - 'seig' type*/ 3280 typedef struct 3281 { 3282 u8 crypt_byte_block, skip_byte_block; 3283 u8 IsProtected; 3284 u8 Per_Sample_IV_size; 3285 u8 constant_IV_size; 3286 bin128 KID; 3287 bin128 constant_IV; 3288 } GF_CENCSampleEncryptionGroupEntry; 3289 3290 typedef struct 3291 { 3292 GF_ISOM_FULL_BOX 3293 3294 bin128 SystemID; 3295 u32 KID_count; 3296 bin128 *KIDs; 3297 u32 private_data_size; 3298 u8 *private_data; 3299 } GF_ProtectionSystemHeaderBox; 3300 3301 typedef struct __cenc_tenc_box 3302 { 3303 GF_ISOM_FULL_BOX 3304 3305 u8 crypt_byte_block, skip_byte_block; 3306 u8 isProtected; 3307 u8 Per_Sample_IV_Size; 3308 bin128 KID; 3309 u8 constant_IV_size; 3310 bin128 constant_IV; 3311 } GF_TrackEncryptionBox; 3312 3313 typedef struct __piff_tenc_box 3314 { 3315 GF_ISOM_UUID_BOX 3316 /*u8 version; field in included in base box version */ 3317 u32 flags; 3318 3319 u32 AlgorithmID; 3320 u8 IV_size; 3321 bin128 KID; 3322 } GF_PIFFTrackEncryptionBox; 3323 3324 typedef struct 3325 { 3326 GF_ISOM_UUID_BOX 3327 /*u8 version; field in included in base box version */ 3328 u32 flags; 3329 3330 bin128 SystemID; 3331 u32 private_data_size; 3332 u8 *private_data; 3333 } GF_PIFFProtectionSystemHeaderBox; 3334 3335 3336 typedef struct __sample_encryption_box 3337 { 3338 GF_ISOM_UUID_BOX 3339 /*u8 version; field in included in base box version */ 3340 u32 flags; 3341 3342 Bool is_piff; 3343 3344 GF_List *samp_aux_info; /*GF_CENCSampleAuxInfo*/ 3345 u64 bs_offset; 3346 Bool load_needed; 3347 3348 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 3349 /*pointer to container traf*/ 3350 GF_TrackFragmentBox *traf; 3351 #endif 3352 /*pointer to associated saio*/ 3353 GF_SampleAuxiliaryInfoSizeBox *cenc_saiz; 3354 GF_SampleAuxiliaryInfoOffsetBox *cenc_saio; 3355 3356 3357 u32 AlgorithmID; 3358 u8 IV_size; 3359 bin128 KID; 3360 3361 } GF_SampleEncryptionBox; 3362 3363 typedef struct __traf_mss_timeext_box 3364 { 3365 GF_ISOM_UUID_BOX 3366 /*u8 version; field in included in base box version */ 3367 u32 flags; 3368 3369 u64 absolute_time_in_track_timescale; 3370 u64 fragment_duration_in_track_timescale; 3371 } GF_MSSTimeExtBox; 3372 3373 GF_SampleEncryptionBox *gf_isom_create_piff_psec_box(u8 version, u32 flags, u32 AlgorithmID, u8 IV_size, bin128 KID); 3374 GF_SampleEncryptionBox * gf_isom_create_samp_enc_box(u8 version, u32 flags); 3375 3376 void gf_isom_cenc_get_default_info_ex(GF_TrackBox *trak, u32 sampleDescriptionIndex, u32 *container_type, Bool *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID, u8 *constant_IV_size, bin128 *constant_IV, u8 *crypt_byte_block, u8 *skip_byte_block); 3377 3378 3379 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 3380 GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, GF_TrackFragmentBox *traf, GF_SampleEncryptionBox *senc, u32 sample_number, Bool *IsEncrypted, u8 *IV_size, bin128 *KID, u8 *crypt_byte_block, u8 *skip_byte_block, u8 *constant_IV_size, bin128 *constant_IV); 3381 GF_Err senc_Parse(GF_BitStream *bs, GF_TrackBox *trak, GF_TrackFragmentBox *traf, GF_SampleEncryptionBox *ptr); 3382 #else 3383 GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, void *traf, uGF_SampleEncryptionBox *senc, u32 sample_number, Bool *IsEncrypted, u8 *IV_size, bin128 *KID, 3384 u8 *crypt_byte_block, u8 *skip_byte_block, u8 *constant_IV_size, bin128 *constant_IV); 3385 GF_Err senc_Parse(GF_BitStream *bs, GF_TrackBox *trak, void *traf, GF_SampleEncryptionBox *ptr); 3386 #endif 3387 3388 /* 3389 Boxes for Adobe's protection scheme 3390 */ 3391 typedef struct __adobe_enc_info_box 3392 { 3393 GF_ISOM_FULL_BOX 3394 char *enc_algo; /*spec: The encryption algorithm shall be 'AES-CBC'*/ 3395 u8 key_length; 3396 } GF_AdobeEncryptionInfoBox; 3397 3398 typedef struct __adobe_flash_access_params_box 3399 { 3400 GF_ISOM_BOX 3401 u8 *metadata; /*base-64 encoded metadata used by the DRM client to retrieve decrypted key*/ 3402 } GF_AdobeFlashAccessParamsBox; 3403 3404 typedef struct __adobe_key_info_box 3405 { 3406 GF_ISOM_FULL_BOX 3407 GF_AdobeFlashAccessParamsBox * params; /*spec: APSParamsBox will no longer be produced by conformaing applications*/ 3408 } GF_AdobeKeyInfoBox; 3409 3410 typedef struct __adobe_std_enc_params_box 3411 { 3412 GF_ISOM_FULL_BOX 3413 GF_AdobeEncryptionInfoBox *enc_info; 3414 GF_AdobeKeyInfoBox *key_info; 3415 } GF_AdobeStdEncryptionParamsBox; 3416 3417 typedef struct __adobe_drm_header_box 3418 { 3419 GF_ISOM_FULL_BOX 3420 GF_AdobeStdEncryptionParamsBox *std_enc_params; 3421 //AdobeSignatureBox *signature; /*AdobeSignatureBox is not described*/ 3422 } GF_AdobeDRMHeaderBox; 3423 3424 3425 typedef struct __adobe_drm_au_format_box 3426 { 3427 GF_ISOM_FULL_BOX 3428 u8 selective_enc; 3429 u8 IV_length; 3430 } GF_AdobeDRMAUFormatBox; 3431 3432 typedef struct __adobe_drm_key_management_system_box 3433 { 3434 GF_ISOM_FULL_BOX 3435 GF_AdobeDRMHeaderBox *header; 3436 GF_AdobeDRMAUFormatBox *au_format; 3437 } GF_AdobeDRMKeyManagementSystemBox; 3438 3439 3440 typedef struct 3441 { 3442 GF_ISOM_FULL_BOX 3443 GF_ISOTrackID refTrackID; 3444 u64 ntp, timestamp; 3445 } GF_ProducerReferenceTimeBox; 3446 3447 /* Image File Format Structures */ 3448 typedef struct { 3449 GF_ISOM_FULL_BOX 3450 u32 image_width; 3451 u32 image_height; 3452 } GF_ImageSpatialExtentsPropertyBox; 3453 3454 typedef struct { 3455 GF_ISOM_FULL_BOX 3456 u8 num_channels; 3457 u8 *bits_per_channel; 3458 } GF_PixelInformationPropertyBox; 3459 3460 typedef struct { 3461 GF_ISOM_FULL_BOX 3462 u32 horizontal_offset; 3463 u32 vertical_offset; 3464 } GF_RelativeLocationPropertyBox; 3465 3466 typedef struct { 3467 GF_ISOM_BOX 3468 u8 angle; 3469 } GF_ImageRotationBox; 3470 3471 typedef struct 3472 { 3473 u8 essential; 3474 u32 index; 3475 } GF_ItemPropertyAssociationSlot; 3476 3477 typedef struct { 3478 u32 item_id; 3479 GF_ItemPropertyAssociationSlot *associations; 3480 u32 nb_associations; 3481 } GF_ItemPropertyAssociationEntry; 3482 3483 typedef struct __item_association_box { 3484 GF_ISOM_FULL_BOX 3485 GF_List *entries; 3486 } GF_ItemPropertyAssociationBox; 3487 3488 3489 typedef struct { 3490 GF_ISOM_FULL_BOX 3491 char *aux_urn; 3492 u32 data_size; 3493 u8 *data; 3494 } GF_AuxiliaryTypePropertyBox; 3495 3496 typedef struct { 3497 GF_ISOM_FULL_BOX 3498 3499 GF_OperatingPointsInformation *oinf; 3500 } GF_OINFPropertyBox; 3501 3502 3503 typedef struct { 3504 GF_ISOM_FULL_BOX 3505 3506 u16 target_ols_index; 3507 } GF_TargetOLSPropertyBox; 3508 3509 /*flute hint track boxes*/ 3510 typedef struct 3511 { 3512 u16 block_count; 3513 u32 block_size; 3514 } FilePartitionEntry; 3515 3516 typedef struct 3517 { 3518 GF_ISOM_FULL_BOX 3519 u32 itemID; 3520 u16 packet_payload_size; 3521 u8 FEC_encoding_ID; 3522 u16 FEC_instance_ID; 3523 u16 max_source_block_length; 3524 u16 encoding_symbol_length; 3525 u16 max_number_of_encoding_symbols; 3526 char *scheme_specific_info; 3527 u32 nb_entries; 3528 FilePartitionEntry *entries; 3529 } FilePartitionBox; 3530 3531 typedef struct 3532 { 3533 u32 item_id; 3534 u32 symbol_count; 3535 } FECReservoirEntry; 3536 3537 typedef struct 3538 { 3539 GF_ISOM_FULL_BOX 3540 u32 nb_entries; 3541 FECReservoirEntry *entries; 3542 } FECReservoirBox; 3543 3544 typedef struct 3545 { 3546 u32 nb_groups; 3547 u32 *group_ids; 3548 u32 nb_channels; 3549 u32 *channels; 3550 } SessionGroupEntry; 3551 3552 typedef struct 3553 { 3554 GF_ISOM_BOX 3555 u16 num_session_groups; 3556 SessionGroupEntry *session_groups; 3557 } FDSessionGroupBox; 3558 3559 typedef struct 3560 { 3561 u32 group_id; 3562 char *name; 3563 } GroupIdNameEntry; 3564 3565 typedef struct 3566 { 3567 GF_ISOM_FULL_BOX 3568 u16 nb_entries; 3569 GroupIdNameEntry *entries; 3570 } GroupIdToNameBox; 3571 3572 3573 typedef struct 3574 { 3575 u32 item_id; 3576 u32 symbol_count; 3577 } FileReservoirEntry; 3578 3579 3580 typedef struct 3581 { 3582 GF_ISOM_FULL_BOX 3583 u32 nb_entries; 3584 FileReservoirEntry *entries; 3585 } FileReservoirBox; 3586 3587 typedef struct 3588 { 3589 GF_ISOM_BOX 3590 FilePartitionBox *blocks_and_symbols; 3591 FECReservoirBox *FEC_symbol_locations; 3592 FileReservoirBox *File_symbol_locations; 3593 } FDPartitionEntryBox; 3594 3595 typedef struct 3596 { 3597 GF_ISOM_FULL_BOX 3598 GF_List *partition_entries; 3599 FDSessionGroupBox *session_info; 3600 GroupIdToNameBox *group_id_to_name; 3601 } FDItemInformationBox; 3602 3603 3604 /* 3605 Data Map (media storage) stuff 3606 */ 3607 3608 /*regular file IO*/ 3609 #define GF_ISOM_DATA_FILE 0x01 3610 /*File Mapping object, read-only mode on complete files (no download)*/ 3611 #define GF_ISOM_DATA_FILE_MAPPING 0x02 3612 /*External file object. Needs implementation*/ 3613 #define GF_ISOM_DATA_FILE_EXTERN 0x03 3614 /*regular memory IO*/ 3615 #define GF_ISOM_DATA_MEM 0x04 3616 3617 /*Data Map modes*/ 3618 enum 3619 { 3620 /*read mode*/ 3621 GF_ISOM_DATA_MAP_READ = 1, 3622 /*write mode*/ 3623 GF_ISOM_DATA_MAP_WRITE = 2, 3624 /*the following modes are just ways of signaling extended functionalities 3625 edit mode, to make sure the file is here, set to GF_ISOM_DATA_MAP_READ afterwards*/ 3626 GF_ISOM_DATA_MAP_EDIT = 3, 3627 /*read-only access to the movie file: we create a file mapping object 3628 mode is set to GF_ISOM_DATA_MAP_READ afterwards*/ 3629 GF_ISOM_DATA_MAP_READ_ONLY = 4, 3630 /*write-only access at the end of the movie - only used for movie fragments concatenation*/ 3631 GF_ISOM_DATA_MAP_CAT = 5, 3632 }; 3633 3634 /*this is the DataHandler structure each data handler has its own bitstream*/ 3635 #define GF_ISOM_BASE_DATA_HANDLER \ 3636 u8 type; \ 3637 u64 curPos; \ 3638 u8 mode; \ 3639 GF_BitStream *bs;\ 3640 u64 last_read_offset;\ 3641 char *szName; 3642 3643 typedef struct __tag_data_map 3644 { 3645 GF_ISOM_BASE_DATA_HANDLER 3646 } GF_DataMap; 3647 3648 typedef struct 3649 { 3650 GF_ISOM_BASE_DATA_HANDLER 3651 FILE *stream; 3652 Bool is_stdout; 3653 Bool last_acces_was_read; 3654 #ifndef GPAC_DISABLE_ISOM_WRITE 3655 char *temp_file; 3656 #endif 3657 } GF_FileDataMap; 3658 3659 /*file mapping handler. used if supported, only on read mode for complete files (not in file download)*/ 3660 typedef struct 3661 { 3662 GF_ISOM_BASE_DATA_HANDLER 3663 char *name; 3664 u64 file_size; 3665 u8 *byte_map; 3666 u64 byte_pos; 3667 } GF_FileMappingDataMap; 3668 3669 GF_Err gf_isom_datamap_new(const char *location, const char *parentPath, u8 mode, GF_DataMap **outDataMap); 3670 void gf_isom_datamap_del(GF_DataMap *ptr); 3671 GF_Err gf_isom_datamap_open(GF_MediaBox *minf, u32 dataRefIndex, u8 Edit); 3672 void gf_isom_datamap_close(GF_MediaInformationBox *minf); 3673 u32 gf_isom_datamap_get_data(GF_DataMap *map, u8 *buffer, u32 bufferLength, u64 Offset); 3674 3675 /*File-based data map*/ 3676 GF_DataMap *gf_isom_fdm_new(const char *sPath, u8 mode); 3677 void gf_isom_fdm_del(GF_FileDataMap *ptr); 3678 u32 gf_isom_fdm_get_data(GF_FileDataMap *ptr, u8 *buffer, u32 bufferLength, u64 fileOffset); 3679 3680 #ifndef GPAC_DISABLE_ISOM_WRITE 3681 GF_DataMap *gf_isom_fdm_new_temp(const char *sTempPath); 3682 #endif 3683 3684 /*file-mapping, read only*/ 3685 GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode); 3686 void gf_isom_fmo_del(GF_FileMappingDataMap *ptr); 3687 u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, u8 *buffer, u32 bufferLength, u64 fileOffset); 3688 3689 #ifndef GPAC_DISABLE_ISOM_WRITE 3690 u64 gf_isom_datamap_get_offset(GF_DataMap *map); 3691 GF_Err gf_isom_datamap_add_data(GF_DataMap *ptr, u8 *data, u32 dataSize); 3692 #endif 3693 3694 void gf_isom_datamap_flush(GF_DataMap *map); 3695 3696 /* 3697 Movie stuff 3698 */ 3699 3700 3701 /*time def for MP4/QT/MJ2K files*/ 3702 #define GF_ISOM_MAC_TIME_OFFSET 2082844800 3703 3704 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 3705 #define GF_ISOM_FORMAT_FRAG_FLAGS(pad, sync, deg) ( ( (pad) << 17) | ( ( !(sync) ) << 16) | (deg) ); 3706 #define GF_ISOM_GET_FRAG_PAD(flag) ( (flag) >> 17) & 0x7 3707 #define GF_ISOM_GET_FRAG_SYNC(flag) ( ! ( ( (flag) >> 16) & 0x1)) 3708 #define GF_ISOM_GET_FRAG_DEG(flag) (flag) & 0x7FFF 3709 3710 #define GF_ISOM_GET_FRAG_LEAD(flag) ( (flag) >> 26) & 0x3 3711 #define GF_ISOM_GET_FRAG_DEPENDS(flag) ( (flag) >> 24) & 0x3 3712 #define GF_ISOM_GET_FRAG_DEPENDED(flag) ( (flag) >> 22) & 0x3 3713 #define GF_ISOM_GET_FRAG_REDUNDANT(flag) ( (flag) >> 20) & 0x3 3714 3715 #define GF_ISOM_GET_FRAG_DEPEND_FLAGS(lead, depends, depended, redundant) ( (lead<<26) | (depends<<24) | (depended<<22) | (redundant<<20) ) 3716 #define GF_ISOM_RESET_FRAG_DEPEND_FLAGS(flags) flags = flags & 0xFFFFF 3717 3718 GF_TrackExtendsBox *GetTrex(GF_MovieBox *moov, GF_ISOTrackID TrackID); 3719 #endif 3720 3721 enum 3722 { 3723 GF_ISOM_FRAG_WRITE_READY = 0x01, 3724 GF_ISOM_FRAG_READ_DEBUG = 0x02, 3725 }; 3726 3727 /*this is our movie object*/ 3728 struct __tag_isom { 3729 /*the last fatal error*/ 3730 GF_Err LastError; 3731 /*the original filename*/ 3732 char *fileName; 3733 /*the original file in read/edit, and also used in fragments mode 3734 once the first moov has been written 3735 Nota: this API doesn't allow fragments BEFORE the MOOV in order 3736 to make easily parsable files (note there could be some data (mdat) before 3737 the moov*/ 3738 GF_DataMap *movieFileMap; 3739 3740 #ifndef GPAC_DISABLE_ISOM_WRITE 3741 /*the final file name*/ 3742 char *finalName; 3743 /*the file where we store edited samples (for READ_WRITE and WRITE mode only)*/ 3744 GF_DataMap *editFileMap; 3745 /*the interleaving time for dummy mode (in movie TimeScale)*/ 3746 u32 interleavingTime; 3747 GF_ISOTrackID last_created_track_id; 3748 #endif 3749 3750 GF_ISOOpenMode openMode; 3751 u8 storageMode; 3752 /*if true 3GPP text streams are read as MPEG-4 StreamingText*/ 3753 u8 convert_streaming_text; 3754 u8 is_jp2; 3755 u8 force_co64; 3756 u64 next_flush_chunk_time; 3757 Bool keep_utc; 3758 /*main boxes for fast access*/ 3759 /*moov*/ 3760 GF_MovieBox *moov; 3761 /*our MDAT box (one and only one when we store the file)*/ 3762 GF_MediaDataBox *mdat; 3763 /*file brand (since v2, NULL means mp4 v1)*/ 3764 GF_FileTypeBox *brand; 3765 /*progressive download info*/ 3766 GF_ProgressiveDownloadBox *pdin; 3767 /*meta box if any*/ 3768 GF_MetaBox *meta; 3769 3770 s64 read_byte_offset; 3771 u64 bytes_removed; 3772 3773 Bool disable_odf_translate; 3774 3775 GF_ISOCompressMode compress_mode; 3776 Bool force_compress; 3777 3778 void (*progress_cbk)(void *udta, u64 nb_done, u64 nb_total); 3779 void *progress_cbk_udta; 3780 3781 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 3782 u32 FragmentsFlags, NextMoofNumber; 3783 /*active fragment*/ 3784 GF_MovieFragmentBox *moof; 3785 /*in WRITE mode, this is the current MDAT where data is written*/ 3786 /*in READ mode this is the last valid file position before a gf_isom_box_read failed*/ 3787 u64 current_top_box_start; 3788 u64 segment_start; 3789 3790 GF_List *moof_list; 3791 Bool use_segments, moof_first, append_segment, styp_written, force_moof_base_offset; 3792 3793 /*used when building single-indexed self initializing media segments*/ 3794 GF_SegmentIndexBox *root_sidx; 3795 u64 root_sidx_offset; 3796 u32 root_sidx_index; 3797 Bool dyn_root_sidx; 3798 GF_SubsegmentIndexBox *root_ssix; 3799 3800 Bool is_index_segment; 3801 3802 GF_BitStream *segment_bs; 3803 /* 0: no moof found yet, 1: 1 moof found, 2: next moof found */ 3804 Bool single_moof_mode; 3805 u32 single_moof_state; 3806 3807 Bool sample_groups_in_traf; 3808 3809 /* optional mfra box used in write mode */ 3810 GF_MovieFragmentRandomAccessBox *mfra; 3811 3812 Bool store_traf_map; 3813 Bool signal_frag_bounds; 3814 u64 sidx_start_offset, sidx_end_offset; 3815 u64 styp_start_offset; 3816 u64 mdat_end_offset; 3817 GF_Box *seg_ssix, *seg_styp; 3818 3819 u32 sidx_pts_store_alloc, sidx_pts_store_count; 3820 u64 *sidx_pts_store, *sidx_pts_next_store; 3821 3822 GF_SegmentIndexBox *main_sidx; 3823 u64 main_sidx_end_pos; 3824 3825 #endif 3826 GF_ProducerReferenceTimeBox *last_producer_ref_time; 3827 3828 /*this contains ALL the root boxes excepts fragments*/ 3829 GF_List *TopBoxes; 3830 3831 /*default track for sync of MPEG4 streams - this is the first accessed stream without OCR info - only set in READ mode*/ 3832 s32 es_id_default_sync; 3833 3834 Bool is_smooth; 3835 3836 GF_Err (*on_block_out)(void *usr_data, u8 *block, u32 block_size); 3837 GF_Err (*on_block_patch)(void *usr_data, u8 *block, u32 block_size, u64 block_offset, Bool is_insert); 3838 void *on_block_out_usr_data; 3839 u32 on_block_out_block_size; 3840 3841 //in block disptach mode we don't have the full file, keep the position 3842 u64 fragmented_file_pos; 3843 u8 *block_buffer; 3844 u32 block_buffer_size; 3845 3846 u32 nb_box_init_seg; 3847 }; 3848 3849 /*time function*/ 3850 u64 gf_isom_get_mp4time(); 3851 /*set the last error of the file. if file is NULL, set the static error (used for IO errors*/ 3852 void gf_isom_set_last_error(GF_ISOFile *the_file, GF_Err error); 3853 GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode); 3854 GF_ISOFile *gf_isom_new_movie(); 3855 /*Movie and Track access functions*/ 3856 GF_TrackBox *gf_isom_get_track_from_file(GF_ISOFile *the_file, u32 trackNumber); 3857 GF_TrackBox *gf_isom_get_track(GF_MovieBox *moov, u32 trackNumber); 3858 GF_TrackBox *gf_isom_get_track_from_id(GF_MovieBox *moov, GF_ISOTrackID trackID); 3859 GF_TrackBox *gf_isom_get_track_from_original_id(GF_MovieBox *moov, u32 originalID, u32 originalFile); 3860 u32 gf_isom_get_tracknum_from_id(GF_MovieBox *moov, GF_ISOTrackID trackID); 3861 /*open a movie*/ 3862 GF_ISOFile *gf_isom_open_file(const char *fileName, GF_ISOOpenMode OpenMode, const char *tmp_dir); 3863 /*close and delete a movie*/ 3864 void gf_isom_delete_movie(GF_ISOFile *mov); 3865 3866 /*StreamDescription reconstruction Functions*/ 3867 GF_Err GetESD(GF_MovieBox *moov, GF_ISOTrackID trackID, u32 StreamDescIndex, GF_ESD **outESD); 3868 GF_Err GetESDForTime(GF_MovieBox *moov, GF_ISOTrackID trackID, u64 CTS, GF_ESD **outESD); 3869 GF_Err Media_GetSampleDesc(GF_MediaBox *mdia, u32 SampleDescIndex, GF_SampleEntryBox **out_entry, u32 *dataRefIndex); 3870 GF_Err Media_GetSampleDescIndex(GF_MediaBox *mdia, u64 DTS, u32 *sampleDescIndex); 3871 /*get esd for given sample desc - 3872 @true_desc_only: if true doesn't emulate desc and returns native ESD, 3873 otherwise emulates if needed/possible (TimedText) and return a hard copy of the desc 3874 */ 3875 GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **esd, Bool true_desc_only); 3876 Bool Track_IsMPEG4Stream(u32 HandlerType); 3877 Bool IsMP4Description(u32 entryType); 3878 /*Find a reference of a given type*/ 3879 GF_Err Track_FindRef(GF_TrackBox *trak, u32 ReferenceType, GF_TrackReferenceTypeBox **dpnd); 3880 /*Time and sample*/ 3881 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); 3882 GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, u32 *sampleDescriptionIndex, Bool no_data, u64 *out_offset); 3883 GF_Err Media_CheckDataEntry(GF_MediaBox *mdia, u32 dataEntryIndex); 3884 GF_Err Media_FindSyncSample(GF_SampleTableBox *stbl, u32 searchFromTime, u32 *sampleNumber, u8 mode); 3885 GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample); 3886 GF_Err Media_FindDataRef(GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex); 3887 Bool Media_IsSelfContained(GF_MediaBox *mdia, u32 StreamDescIndex); 3888 3889 typedef enum 3890 { 3891 ISOM_DREF_MIXED = 0, 3892 ISOM_DREF_SELF, 3893 ISOM_DREF_EXT, 3894 } GF_ISOMDataRefAllType; 3895 GF_ISOMDataRefAllType Media_SelfContainedType(GF_MediaBox *mdia); 3896 3897 GF_TrackBox *GetTrackbyID(GF_MovieBox *moov, GF_ISOTrackID TrackID); 3898 3899 /*check the TimeToSample for the given time and return the Sample number 3900 if the entry is not found, return the closest sampleNumber in prevSampleNumber and 0 in sampleNumber 3901 if the DTS required is after all DTSs in the list, set prevSampleNumber and SampleNumber to 0 3902 useCTS specifies that we're looking for a composition time 3903 */ 3904 GF_Err stbl_findEntryForTime(GF_SampleTableBox *stbl, u64 DTS, u8 useCTS, u32 *sampleNumber, u32 *prevSampleNumber); 3905 /*Reading of the sample tables*/ 3906 GF_Err stbl_GetSampleSize(GF_SampleSizeBox *stsz, u32 SampleNumber, u32 *Size); 3907 GF_Err stbl_GetSampleCTS(GF_CompositionOffsetBox *ctts, u32 SampleNumber, s32 *CTSoffset); 3908 GF_Err stbl_GetSampleDTS(GF_TimeToSampleBox *stts, u32 SampleNumber, u64 *DTS); 3909 GF_Err stbl_GetSampleDTS_and_Duration(GF_TimeToSampleBox *stts, u32 SampleNumber, u64 *DTS, u32 *duration); 3910 3911 /*find a RAP or set the prev / next RAPs if vars are passed*/ 3912 GF_Err stbl_GetSampleRAP(GF_SyncSampleBox *stss, u32 SampleNumber, GF_ISOSAPType *IsRAP, u32 *prevRAP, u32 *nextRAP); 3913 /*same as above but only look for open-gop RAPs and GDR (roll)*/ 3914 GF_Err stbl_SearchSAPs(GF_SampleTableBox *stbl, u32 SampleNumber, GF_ISOSAPType *IsRAP, u32 *prevRAP, u32 *nextRAP); 3915 GF_Err stbl_GetSampleInfos(GF_SampleTableBox *stbl, u32 sampleNumber, u64 *offset, u32 *chunkNumber, u32 *descIndex, GF_StscEntry **scsc_entry); 3916 GF_Err stbl_GetSampleShadow(GF_ShadowSyncBox *stsh, u32 *sampleNumber, u32 *syncNum); 3917 GF_Err stbl_GetPaddingBits(GF_PaddingBitsBox *padb, u32 SampleNumber, u8 *PadBits); 3918 GF_Err stbl_GetSampleDepType(GF_SampleDependencyTypeBox *stbl, u32 SampleNumber, u32 *isLeading, u32 *dependsOn, u32 *dependedOn, u32 *redundant); 3919 3920 3921 /*unpack sample2chunk and chunk offset so that we have 1 sample per chunk (edition mode only)*/ 3922 GF_Err stbl_UnpackOffsets(GF_SampleTableBox *stbl); 3923 GF_Err stbl_unpackCTS(GF_SampleTableBox *stbl); 3924 GF_Err SetTrackDuration(GF_TrackBox *trak); 3925 GF_Err Media_SetDuration(GF_TrackBox *trak); 3926 3927 /*rewrites 3GP samples desc as MPEG-4 ESD*/ 3928 GF_Err gf_isom_get_ttxt_esd(GF_MediaBox *mdia, GF_ESD **out_esd); 3929 /*inserts TTU header - only used when conversion to StreamingText is on*/ 3930 GF_Err gf_isom_rewrite_text_sample(GF_ISOSample *samp, u32 sampleDescriptionIndex, u32 sample_dur); 3931 3932 GF_UserDataMap *udta_getEntry(GF_UserDataBox *ptr, u32 box_type, bin128 *uuid); 3933 3934 #ifndef GPAC_DISABLE_ISOM_WRITE 3935 3936 GF_Err FlushCaptureMode(GF_ISOFile *movie); 3937 GF_Err CanAccessMovie(GF_ISOFile *movie, GF_ISOOpenMode Mode); 3938 GF_ISOFile *gf_isom_create_movie(const char *fileName, GF_ISOOpenMode OpenMode, const char *tmp_dir); 3939 GF_Err gf_isom_insert_moov(GF_ISOFile *file); 3940 3941 GF_Err WriteToFile(GF_ISOFile *movie, Bool for_fragments); 3942 GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, u32 DataReferenceIndex, GF_ESD *esd, u32 *outStreamIndex); 3943 u8 RequestTrack(GF_MovieBox *moov, GF_ISOTrackID TrackID); 3944 /*Track-Media setup*/ 3945 GF_Err NewMedia(GF_MediaBox **mdia, u32 MediaType, u32 TimeScale); 3946 GF_Err Media_ParseODFrame(GF_MediaBox *mdia, const GF_ISOSample *sample, GF_ISOSample **od_samp); 3947 GF_Err Media_AddSample(GF_MediaBox *mdia, u64 data_offset, const GF_ISOSample *sample, u32 StreamDescIndex, u32 syncShadowNumber); 3948 GF_Err Media_CreateDataRef(GF_ISOFile *file, GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex); 3949 GF_Err Media_SetDrefURL(GF_DataEntryURLBox *dref_entry, const char *origName, const char *finalName); 3950 3951 /*update a media sample. ONLY in edit mode*/ 3952 GF_Err Media_UpdateSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample *sample, Bool data_only); 3953 GF_Err Media_UpdateSampleReference(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample *sample, u64 data_offset); 3954 /*addition in the sample tables*/ 3955 GF_Err stbl_AddDTS(GF_SampleTableBox *stbl, u64 DTS, u32 *sampleNumber, u32 LastAUDefDuration, u32 nb_pack_samples); 3956 GF_Err stbl_AddCTS(GF_SampleTableBox *stbl, u32 sampleNumber, s32 CTSoffset); 3957 GF_Err stbl_AddSize(GF_SampleSizeBox *stsz, u32 sampleNumber, u32 size, u32 nb_pack_samples); 3958 GF_Err stbl_AddRAP(GF_SyncSampleBox *stss, u32 sampleNumber); 3959 GF_Err stbl_AddShadow(GF_ShadowSyncBox *stsh, u32 sampleNumber, u32 shadowNumber); 3960 GF_Err stbl_AddChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u32 StreamDescIndex, u64 offset, u32 nb_pack_samples); 3961 /*NB - no add for padding, this is done only through SetPaddingBits*/ 3962 3963 GF_Err stbl_AddSampleFragment(GF_SampleTableBox *stbl, u32 sampleNumber, u16 size); 3964 3965 /*update of the sample table 3966 all these functions are called in edit and we always have 1 sample per chunk*/ 3967 GF_Err stbl_SetChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u64 offset); 3968 GF_Err stbl_SetSampleCTS(GF_SampleTableBox *stbl, u32 sampleNumber, s32 offset); 3969 GF_Err stbl_SetSampleSize(GF_SampleSizeBox *stsz, u32 SampleNumber, u32 size); 3970 GF_Err stbl_SetSampleRAP(GF_SyncSampleBox *stss, u32 SampleNumber, u8 isRAP); 3971 GF_Err stbl_SetSyncShadow(GF_ShadowSyncBox *stsh, u32 sampleNumber, u32 syncSample); 3972 GF_Err stbl_SetPaddingBits(GF_SampleTableBox *stbl, u32 SampleNumber, u8 bits); 3973 /*for adding fragmented samples*/ 3974 GF_Err stbl_SampleSizeAppend(GF_SampleSizeBox *stsz, u32 data_size); 3975 /*writing of the final chunk info in edit mode*/ 3976 GF_Err stbl_SetChunkAndOffset(GF_SampleTableBox *stbl, u32 sampleNumber, u32 StreamDescIndex, GF_SampleToChunkBox *the_stsc, GF_Box **the_stco, u64 data_offset, Bool forceNewChunk, u32 nb_samp); 3977 /*EDIT LIST functions*/ 3978 GF_EdtsEntry *CreateEditEntry(u64 EditDuration, u64 MediaTime, u8 EditMode); 3979 3980 GF_Err stbl_SetRedundant(GF_SampleTableBox *stbl, u32 sampleNumber); 3981 GF_Err stbl_AddRedundant(GF_SampleTableBox *stbl, u32 sampleNumber); 3982 3983 /*REMOVE functions*/ 3984 GF_Err stbl_RemoveDTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 LastAUDefDuration); 3985 GF_Err stbl_RemoveCTS(GF_SampleTableBox *stbl, u32 sampleNumber); 3986 GF_Err stbl_RemoveSize(GF_SampleTableBox *stbl, u32 sampleNumber); 3987 GF_Err stbl_RemoveChunk(GF_SampleTableBox *stbl, u32 sampleNumber); 3988 GF_Err stbl_RemoveRAP(GF_SampleTableBox *stbl, u32 sampleNumber); 3989 GF_Err stbl_RemoveShadow(GF_SampleTableBox *stbl, u32 sampleNumber); 3990 GF_Err stbl_RemovePaddingBits(GF_SampleTableBox *stbl, u32 SampleNumber); 3991 GF_Err stbl_RemoveRedundant(GF_SampleTableBox *stbl, u32 SampleNumber); 3992 GF_Err stbl_RemoveSubSample(GF_SampleTableBox *stbl, u32 SampleNumber); 3993 GF_Err stbl_RemoveSampleGroup(GF_SampleTableBox *stbl, u32 SampleNumber); 3994 3995 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 3996 GF_Err gf_isom_close_fragments(GF_ISOFile *movie); 3997 #endif 3998 3999 GF_Err gf_isom_flush_sidx(GF_ISOFile *movie, u32 sidx_max_size, Bool exact_range); 4000 4001 #endif /*GPAC_DISABLE_ISOM_WRITE*/ 4002 4003 Bool gf_isom_is_identical_sgpd(void *ptr1, void *ptr2, u32 grouping_type); 4004 4005 GF_DefaultSampleGroupDescriptionEntry * gf_isom_get_sample_group_info_entry(GF_ISOFile *the_file, GF_TrackBox *trak, u32 grouping_type, u32 sample_description_index, u32 *default_index, GF_SampleGroupDescriptionBox **out_sgdp); 4006 4007 GF_Err GetNextMediaTime(GF_TrackBox *trak, u64 movieTime, u64 *OutMovieTime); 4008 GF_Err GetPrevMediaTime(GF_TrackBox *trak, u64 movieTime, u64 *OutMovieTime); 4009 4010 Bool IsHintTrack(GF_TrackBox *trak); 4011 Bool CheckHintFormat(GF_TrackBox *trak, u32 HintType); 4012 u32 GetHintFormat(GF_TrackBox *trak); 4013 4014 /*locate a box by its type or UUID*/ 4015 GF_ItemListBox *gf_ismo_locate_box(GF_List *list, u32 boxType, bin128 UUID); 4016 4017 GF_Err moov_on_child_box(GF_Box *ptr, GF_Box *a); 4018 GF_Err trak_on_child_box(GF_Box *ptr, GF_Box *a); 4019 GF_Err mvex_on_child_box(GF_Box *ptr, GF_Box *a); 4020 GF_Err stsd_on_child_box(GF_Box *ptr, GF_Box *a); 4021 GF_Err hnti_on_child_box(GF_Box *hnti, GF_Box *a); 4022 GF_Err udta_on_child_box(GF_Box *ptr, GF_Box *a); 4023 GF_Err edts_on_child_box(GF_Box *s, GF_Box *a); 4024 GF_Err stdp_box_read(GF_Box *s, GF_BitStream *bs); 4025 GF_Err stbl_on_child_box(GF_Box *ptr, GF_Box *a); 4026 GF_Err sdtp_box_read(GF_Box *s, GF_BitStream *bs); 4027 GF_Err dinf_on_child_box(GF_Box *s, GF_Box *a); 4028 GF_Err minf_on_child_box(GF_Box *s, GF_Box *a); 4029 GF_Err mdia_on_child_box(GF_Box *s, GF_Box *a); 4030 GF_Err traf_on_child_box(GF_Box *s, GF_Box *a); 4031 4032 /*rewrites avcC based on the given esd - this destroys the esd*/ 4033 GF_Err AVC_HEVC_UpdateESD(GF_MPEGVisualSampleEntryBox *avc, GF_ESD *esd); 4034 void AVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *mdia); 4035 void AVC_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *avc); 4036 void HEVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *hevc, GF_MediaBox *mdia); 4037 void HEVC_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *hevc); 4038 void VP9_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *vp9, GF_MediaBox *mdia); 4039 void VP9_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *vp9); 4040 void AV1_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *av1, GF_MediaBox *mdia); 4041 void AV1_RewriteESDescriptor(GF_MPEGVisualSampleEntryBox *av1); 4042 GF_Err reftype_AddRefTrack(GF_TrackReferenceTypeBox *ref, GF_ISOTrackID trackID, u16 *outRefIndex); 4043 GF_XMLBox *gf_isom_get_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, Bool *is_binary); 4044 Bool gf_isom_cenc_has_saiz_saio_track(GF_SampleTableBox *stbl, u32 scheme_type); 4045 4046 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS 4047 Bool gf_isom_cenc_has_saiz_saio_traf(GF_TrackFragmentBox *traf, u32 scheme_type); 4048 void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf, u32 len, Bool saio_32bits); 4049 #endif 4050 GF_Err gf_isom_cenc_merge_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, u64 offset, u32 len); 4051 4052 void gf_isom_parse_trif_info(const u8 *data, u32 size, u32 *id, u32 *independent, Bool *full_picture, u32 *x, u32 *y, u32 *w, u32 *h); 4053 4054 Bool gf_isom_is_encrypted_entry(u32 entryType); 4055 4056 #ifndef GPAC_DISABLE_ISOM_HINTING 4057 4058 /* 4059 Hinting stuff 4060 */ 4061 4062 /***************************************************** 4063 RTP Data Entries 4064 *****************************************************/ 4065 4066 typedef struct 4067 { 4068 u8 sender_current_time_present; 4069 u8 expected_residual_time_present; 4070 u8 session_close_bit; 4071 u8 object_close_bit; 4072 u16 transport_object_identifier; 4073 } GF_LCTheaderTemplate; 4074 4075 typedef struct 4076 { 4077 u8 header_extension_type; 4078 u8 content[3]; 4079 u32 data_length; 4080 u8 *data; 4081 } GF_LCTheaderExtension; 4082 4083 typedef struct 4084 { 4085 GF_ISOM_BOX 4086 4087 GF_LCTheaderTemplate info; 4088 u16 header_ext_count; 4089 GF_LCTheaderExtension *headers; 4090 4091 GF_List *constructors; 4092 } GF_FDpacketBox; 4093 4094 4095 typedef struct 4096 { 4097 GF_ISOM_BOX 4098 4099 u8 FEC_encoding_ID; 4100 u16 FEC_instance_ID; 4101 u16 source_block_number; 4102 u16 encoding_symbol_ID; 4103 } GF_FECInformationBox; 4104 4105 4106 typedef struct 4107 { 4108 GF_ISOM_BOX 4109 //not registered with child list !! 4110 GF_FECInformationBox *feci; 4111 u32 data_length; 4112 u8 *data; 4113 } GF_ExtraDataBox; 4114 4115 4116 #define GF_ISMO_BASE_DTE_ENTRY \ 4117 u8 source; 4118 4119 typedef struct 4120 { 4121 GF_ISMO_BASE_DTE_ENTRY 4122 } GF_GenericDTE; 4123 4124 typedef struct 4125 { 4126 GF_ISMO_BASE_DTE_ENTRY 4127 } GF_EmptyDTE; 4128 4129 typedef struct 4130 { 4131 GF_ISMO_BASE_DTE_ENTRY 4132 u8 dataLength; 4133 char data[14]; 4134 } GF_ImmediateDTE; 4135 4136 typedef struct 4137 { 4138 GF_ISMO_BASE_DTE_ENTRY 4139 s8 trackRefIndex; 4140 u32 sampleNumber; 4141 u16 dataLength; 4142 u32 byteOffset; 4143 u16 bytesPerComp; 4144 u16 samplesPerComp; 4145 } GF_SampleDTE; 4146 4147 typedef struct 4148 { 4149 GF_ISMO_BASE_DTE_ENTRY 4150 s8 trackRefIndex; 4151 u32 streamDescIndex; 4152 u16 dataLength; 4153 u32 byteOffset; 4154 u32 reserved; 4155 } GF_StreamDescDTE; 4156 4157 GF_GenericDTE *NewDTE(u8 type); 4158 void DelDTE(GF_GenericDTE *dte); 4159 GF_Err ReadDTE(GF_GenericDTE *dte, GF_BitStream *bs); 4160 GF_Err WriteDTE(GF_GenericDTE *dte, GF_BitStream *bs); 4161 GF_Err OffsetDTE(GF_GenericDTE *dte, u32 offset, u32 HintSampleNumber); 4162 4163 /***************************************************** 4164 RTP Sample 4165 *****************************************************/ 4166 4167 /*data cache when reading*/ 4168 typedef struct __tag_hint_data_cache 4169 { 4170 GF_ISOSample *samp; 4171 GF_TrackBox *trak; 4172 u32 sample_num; 4173 } GF_HintDataCache; 4174 4175 typedef struct __tag_hint_sample 4176 { 4177 //for samples deriving from box 4178 GF_ISOM_BOX 4179 4180 /*contains 4cc of hint track sample entry*/ 4181 u32 hint_subtype; 4182 u16 packetCount; 4183 u16 reserved; 4184 GF_List *packetTable; 4185 u8 *AdditionalData; 4186 u32 dataLength; 4187 /*used internally for hinting*/ 4188 u64 TransmissionTime; 4189 /*for read only, used to store samples fetched while building packets*/ 4190 GF_List *sample_cache; 4191 4192 //for dump 4193 GF_ISOTrackID trackID; 4194 u32 sampleNumber; 4195 4196 GF_ExtraDataBox *extra_data; 4197 } GF_HintSample; 4198 4199 GF_HintSample *gf_isom_hint_sample_new(u32 ProtocolType); 4200 void gf_isom_hint_sample_del(GF_HintSample *ptr); 4201 GF_Err gf_isom_hint_sample_read(GF_HintSample *ptr, GF_BitStream *bs, u32 sampleSize); 4202 GF_Err gf_isom_hint_sample_write(GF_HintSample *ptr, GF_BitStream *bs); 4203 u32 gf_isom_hint_sample_size(GF_HintSample *ptr); 4204 4205 4206 /***************************************************** 4207 Hint Packets (generic packet for future protocol support) 4208 *****************************************************/ 4209 #define GF_ISOM_BASE_PACKET \ 4210 u32 hint_subtype, sampleNumber; \ 4211 GF_ISOTrackID trackID;\ 4212 s32 relativeTransTime; 4213 4214 4215 typedef struct 4216 { 4217 GF_ISOM_BASE_PACKET 4218 } GF_HintPacket; 4219 4220 GF_HintPacket *gf_isom_hint_pck_new(u32 HintType); 4221 void gf_isom_hint_pck_del(GF_HintPacket *ptr); 4222 GF_Err gf_isom_hint_pck_read(GF_HintPacket *ptr, GF_BitStream *bs); 4223 GF_Err gf_isom_hint_pck_write(GF_HintPacket *ptr, GF_BitStream *bs); 4224 u32 gf_isom_hint_pck_size(GF_HintPacket *ptr); 4225 GF_Err gf_isom_hint_pck_offset(GF_HintPacket *ptr, u32 offset, u32 HintSampleNumber); 4226 GF_Err gf_isom_hint_pck_add_dte(GF_HintPacket *ptr, GF_GenericDTE *dte, u8 AtBegin); 4227 /*get the size of the packet AS RECONSTRUCTED BY THE SERVER (without CSRC)*/ 4228 u32 gf_isom_hint_pck_length(GF_HintPacket *ptr); 4229 4230 /*the RTP packet*/ 4231 typedef struct 4232 { 4233 GF_ISOM_BASE_PACKET 4234 4235 /*RTP Header*/ 4236 u8 P_bit; 4237 u8 X_bit; 4238 u8 M_bit; 4239 /*on 7 bits */ 4240 u8 payloadType; 4241 u16 SequenceNumber; 4242 /*Hinting flags*/ 4243 u8 B_bit; 4244 u8 R_bit; 4245 /*ExtraInfos TLVs - not really used */ 4246 GF_List *TLV; 4247 /*DataTable - contains the DTEs...*/ 4248 GF_List *DataTable; 4249 } GF_RTPPacket; 4250 4251 GF_RTPPacket *gf_isom_hint_rtp_new(); 4252 void gf_isom_hint_rtp_del(GF_RTPPacket *ptr); 4253 GF_Err gf_isom_hint_rtp_read(GF_RTPPacket *ptr, GF_BitStream *bs); 4254 GF_Err gf_isom_hint_rtp_write(GF_RTPPacket *ptr, GF_BitStream *bs); 4255 u32 gf_isom_hint_rtp_size(GF_RTPPacket *ptr); 4256 GF_Err gf_isom_hint_rtp_offset(GF_RTPPacket *ptr, u32 offset, u32 HintSampleNumber); 4257 u32 gf_isom_hint_rtp_length(GF_RTPPacket *ptr); 4258 4259 4260 /*the RTP packet*/ 4261 typedef struct 4262 { 4263 GF_ISOM_BASE_PACKET 4264 4265 //RTCP report 4266 u8 Version, Padding, Count, PayloadType; 4267 u32 length; 4268 u8 *data; 4269 } GF_RTCPPacket; 4270 4271 GF_RTCPPacket *gf_isom_hint_rtcp_new(); 4272 void gf_isom_hint_rtcp_del(GF_RTCPPacket *ptr); 4273 GF_Err gf_isom_hint_rtcp_read(GF_RTCPPacket *ptr, GF_BitStream *bs); 4274 GF_Err gf_isom_hint_rtcp_write(GF_RTCPPacket *ptr, GF_BitStream *bs); 4275 u32 gf_isom_hint_rtcp_size(GF_RTCPPacket *ptr); 4276 u32 gf_isom_hint_rtcp_length(GF_RTCPPacket *ptr); 4277 4278 4279 #endif 4280 4281 4282 struct _3gpp_text_sample 4283 { 4284 char *text; 4285 u32 len; 4286 4287 GF_TextStyleBox *styles; 4288 /*at most one of these*/ 4289 GF_TextHighlightColorBox *highlight_color; 4290 GF_TextScrollDelayBox *scroll_delay; 4291 GF_TextBoxBox *box; 4292 GF_TextWrapBox *wrap; 4293 4294 GF_List *others; 4295 GF_TextKaraokeBox *cur_karaoke; 4296 }; 4297 4298 GF_TextSample *gf_isom_parse_text_sample(GF_BitStream *bs); 4299 4300 struct _generic_subtitle_sample 4301 { 4302 char *text; 4303 u32 len; 4304 }; 4305 GF_GenericSubtitleSample *gf_isom_parse_generic_subtitle_sample(GF_BitStream *bs); 4306 GF_GenericSubtitleSample *gf_isom_parse_generic_subtitle_sample_from_data(u8 *data, u32 dataLength); 4307 4308 4309 /*do not throw fatal errors if boxes are duplicated, just warn and remove extra ones*/ 4310 #define ERROR_ON_DUPLICATED_BOX(__abox, __parent) { \ 4311 char __ptype[GF_4CC_MSIZE];\ 4312 strcpy(__ptype, gf_4cc_to_str(__parent->type) );\ 4313 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)); \ 4314 gf_isom_box_del_parent(& (__parent->child_boxes), __abox);\ 4315 return GF_OK;\ 4316 } 4317 4318 4319 #ifndef GPAC_DISABLE_VTT 4320 4321 GF_Err gf_isom_update_webvtt_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, const char *config); 4322 GF_ISOSample *gf_isom_webvtt_to_sample(void *samp); 4323 4324 typedef struct 4325 { 4326 GF_ISOM_BOX 4327 char *string; 4328 } GF_StringBox; 4329 4330 typedef struct 4331 { 4332 GF_ISOM_SAMPLE_ENTRY_FIELDS 4333 GF_StringBox *config; 4334 } GF_WebVTTSampleEntryBox; 4335 4336 GF_WebVTTSampleEntryBox *gf_webvtt_isom_get_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex); 4337 4338 #endif /* GPAC_DISABLE_VTT */ 4339 4340 //exported for sgpd comparison in traf merge 4341 void sgpd_write_entry(u32 grouping_type, void *entry, GF_BitStream *bs); 4342 Bool gf_isom_box_equal(GF_Box *a, GF_Box *b); 4343 GF_Box *gf_isom_clone_config_box(GF_Box *box); 4344 4345 GF_Err gf_isom_box_dump(void *ptr, FILE * trace); 4346 GF_Err gf_isom_box_array_dump(GF_List *list, FILE * trace); 4347 4348 void gf_isom_registry_disable(u32 boxCode, Bool disable); 4349 4350 /*Apple extensions*/ 4351 GF_MetaBox *gf_isom_apple_get_meta_extensions(GF_ISOFile *mov); 4352 4353 #ifndef GPAC_DISABLE_ISOM_WRITE 4354 GF_MetaBox *gf_isom_apple_create_meta_extensions(GF_ISOFile *mov); 4355 #endif /*GPAC_DISABLE_ISOM_WRITE*/ 4356 4357 4358 #ifndef GPAC_DISABLE_ISOM_DUMP 4359 GF_Err gf_isom_box_dump_ex(void *ptr, FILE * trace, u32 box_4cc); 4360 GF_Err gf_isom_box_dump_start(GF_Box *a, const char *name, FILE * trace); 4361 void gf_isom_box_dump_done(const char *name, GF_Box *ptr, FILE *trace); 4362 Bool gf_isom_box_is_file_level(GF_Box *s); 4363 #endif 4364 4365 GF_Box *boxstring_new_with_data(u32 type, const char *string, GF_List **parent); 4366 4367 GF_Err gf_isom_read_null_terminated_string(GF_Box *s, GF_BitStream *bs, u64 size, char **out_str); 4368 4369 GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, GF_MovieFragmentBox *moof, u64 moof_offset, s32 compresed_diff, u64 *cumulated_offset, Bool is_first_merge); 4370 4371 4372 #endif //GPAC_DISABLE_ISOM 4373 4374 #ifdef __cplusplus 4375 } 4376 #endif 4377 4378 #endif //_GF_ISOMEDIA_DEV_H_ 4379 4380