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 
27 
28 #ifndef _GF_ISOMEDIA_H_
29 #define _GF_ISOMEDIA_H_
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 	/*!
37 	*	\file <gpac/isomedia.h>
38 	*	\brief ISOBMFF parsing and writing library.
39 	*/
40 
41 	/*!
42 	*	\addtogroup iso_grp ISO Base Media File
43 	*	\ingroup isobmf_grp
44 	*	\brief ISOBMF, 3GPP, AVC and HEVC file format utilities.
45 	*
46 	*This section documents the reading and writing of ISOBMF, 3GPP, AVC and HEVC file format  using GPAC.
47 	*	@{
48 	*/
49 
50 #include <gpac/tools.h>
51 
52 
53 	/********************************************************************
54 	FILE FORMAT CONSTANTS
55 	********************************************************************/
56 
57 	/*Modes for file opening
58 	NOTE 1: All the READ function in this API can be used in EDIT/WRITE mode.
59 	However, some unexpected errors or values may happen in that case, depending
60 	on how much modifications you made (timing, track with 0 samples, ...)
61 	On the other hand, none of the EDIT/WRITE functions will work in
62 	READ mode.
63 	NOTE 2: The output structure of a edited file will sometimes be different
64 	from the original file, but the media-data and meta-data will be identical.
65 	The only change happens in the file media-data container(s) during edition
66 	NOTE 3: when editing the file, you MUST set the final name of the modified file
67 	to something different. This API doesn't allow file overwriting.
68 	*/
69 	enum
70 	{
71 		/*Opens file for dumping: same as read-only but keeps all movie fragments info untouched*/
72 		GF_ISOM_OPEN_READ_DUMP = 0,
73 		/*Opens a file in READ ONLY mode*/
74 		GF_ISOM_OPEN_READ,
75 		/*Opens a file in WRITE ONLY mode. Media Data is captured on the fly. In this mode,
76 		the editing functions are disabled.*/
77 		GF_ISOM_OPEN_WRITE,
78 		/*Opens an existing file in EDIT mode*/
79 		GF_ISOM_OPEN_EDIT,
80 		/*Creates a new file in EDIT mode*/
81 		GF_ISOM_WRITE_EDIT,
82 		/*Opens an existing file for fragment concatenation*/
83 		GF_ISOM_OPEN_CAT_FRAGMENTS,
84 	};
85 
86 	/*Movie Options for file writing*/
87 	enum
88 	{
89 		/*FLAT: the MediaData (MPEG4 ESs) is stored at the beginning of the file*/
90 		GF_ISOM_STORE_FLAT = 1,
91 		/*STREAMABLE: the MetaData (File Info) is stored at the beginning of the file
92 		for fast access during download*/
93 		GF_ISOM_STORE_STREAMABLE,
94 		/*INTERLEAVED: Same as STREAMABLE, plus the media data is mixed by chunk  of fixed duration*/
95 		GF_ISOM_STORE_INTERLEAVED,
96 		/*INTERLEAVED +DRIFT: Same as INTERLEAVED, and adds time drift control to avoid creating too long chunks*/
97 		GF_ISOM_STORE_DRIFT_INTERLEAVED,
98 		/*tightly interleaves samples based on their DTS, therefore allowing better placement of samples in the file.
99 		This is used for both http interleaving and Hinting optimizations*/
100 		GF_ISOM_STORE_TIGHT
101 
102 	};
103 
104 	/*Some track may depend on other tracks for several reasons. They reference these tracks
105 	through the following Reference Types*/
106 	enum
107 	{
108 		/*ref type for the OD track dependencies*/
109 		GF_ISOM_REF_OD = GF_4CC('m', 'p', 'o', 'd'),
110 		/*ref type for stream dependencies*/
111 		GF_ISOM_REF_DECODE = GF_4CC('d', 'p', 'n', 'd'),
112 		/*ref type for OCR (Object Clock Reference) dependencies*/
113 		GF_ISOM_REF_OCR = GF_4CC('s', 'y', 'n', 'c'),
114 		/*ref type for IPI (Intellectual Property Information) dependencies*/
115 		GF_ISOM_REF_IPI = GF_4CC('i', 'p', 'i', 'r'),
116 		/*ref type for timed Meta Data tracks*/
117 		GF_ISOM_REF_META = GF_4CC('c', 'd', 's', 'c'),
118 		/*ref type for Hint tracks*/
119 		GF_ISOM_REF_HINT = GF_4CC('h', 'i', 'n', 't'),
120 		/*ref type for QT Chapter tracks*/
121 		GF_ISOM_REF_CHAP = GF_4CC('c', 'h', 'a', 'p'),
122 		/*ref type for the SVC tracks*/
123 		GF_ISOM_REF_BASE = GF_4CC('s', 'b', 'a', 's'),
124 		GF_ISOM_REF_SCAL = GF_4CC('s', 'c', 'a', 'l'),
125 		GF_ISOM_REF_TBAS = GF_4CC('t', 'b', 'a', 's'),
126 		GF_ISOM_REF_SABT = GF_4CC('s', 'a', 'b', 't'),
127 		GF_ISOM_REF_OREF = GF_4CC('o', 'r', 'e', 'f')
128 	};
129 
130 	/*Track Edition flag*/
131 	enum {
132 		/*empty segment in the track (no media for this segment)*/
133 		GF_ISOM_EDIT_EMPTY = 0x00,
134 		/*dwelled segment in the track (one media sample for this segment)*/
135 		GF_ISOM_EDIT_DWELL = 0x01,
136 		/*normal segment in the track*/
137 		GF_ISOM_EDIT_NORMAL = 0x02
138 	};
139 
140 	/*Generic Media Types (YOU HAVE TO USE ONE OF THESE TYPES FOR COMPLIANT ISO MEDIA FILES)*/
141 	enum
142 	{
143 		/*base media types*/
144 		GF_ISOM_MEDIA_VISUAL = GF_4CC('v', 'i', 'd', 'e'),
145 		GF_ISOM_MEDIA_AUDIO = GF_4CC('s', 'o', 'u', 'n'),
146 		GF_ISOM_MEDIA_HINT = GF_4CC('h', 'i', 'n', 't'),
147 		GF_ISOM_MEDIA_META = GF_4CC('m', 'e', 't', 'a'),
148 		GF_ISOM_MEDIA_TEXT = GF_4CC('t', 'e', 'x', 't'),
149 		/*subtitle code point used on ipod - same as text*/
150 		GF_ISOM_MEDIA_SUBT = GF_4CC('s', 'b', 't', 'l'),
151 		GF_ISOM_MEDIA_SUBPIC = GF_4CC('s', 'u', 'b', 'p'),
152 		GF_ISOM_MEDIA_MPEG_SUBT = GF_4CC('s', 'u', 'b', 't'),
153 
154 		/*MPEG-4 media types*/
155 		GF_ISOM_MEDIA_OD = GF_4CC('o', 'd', 's', 'm'),
156 		GF_ISOM_MEDIA_OCR = GF_4CC('c', 'r', 's', 'm'),
157 		GF_ISOM_MEDIA_SCENE = GF_4CC('s', 'd', 's', 'm'),
158 		GF_ISOM_MEDIA_MPEG7 = GF_4CC('m', '7', 's', 'm'),
159 		GF_ISOM_MEDIA_OCI = GF_4CC('o', 'c', 's', 'm'),
160 		GF_ISOM_MEDIA_IPMP = GF_4CC('i', 'p', 's', 'm'),
161 		GF_ISOM_MEDIA_MPEGJ = GF_4CC('m', 'j', 's', 'm'),
162 		/*GPAC-defined, for any track using MPEG-4 systems signaling but with undefined streaml types*/
163 		GF_ISOM_MEDIA_ESM = GF_4CC('g', 'e', 's', 'm'),
164 
165 		/*DIMS media type (same as scene but with a different mediaInfo)*/
166 		GF_ISOM_MEDIA_DIMS = GF_4CC('d', 'i', 'm', 's'),
167 
168 		GF_ISOM_MEDIA_FLASH = GF_4CC('f', 'l', 's', 'h'),
169 
170 		/* CFS: Seen this in an itunes sample */
171 		GF_ISOM_MEDIA_CAPTIONS = GF_4CC('c', 'l', 'c', 'p')
172 	};
173 
174 
175 	/*DRM related code points*/
176 	enum
177 	{
178 		GF_ISOM_BOX_UUID_PSEC = GF_4CC('P', 'S', 'E', 'C'),
179 		GF_ISOM_BOX_TYPE_SENC = GF_4CC('s', 'e', 'n', 'c'),
180 
181 		/* Encryption Scheme Type in the SchemeTypeInfoBox */
182 		GF_ISOM_ISMACRYP_SCHEME = GF_4CC('i', 'A', 'E', 'C'),
183 		/* Encryption Scheme Type in the SchemeTypeInfoBox */
184 		GF_ISOM_OMADRM_SCHEME = GF_4CC('o', 'd', 'k', 'm'),
185 
186 		/* Encryption Scheme Type in the SchemeTypeInfoBox */
187 		GF_ISOM_CENC_SCHEME = GF_4CC('c', 'e', 'n', 'c'),
188 
189 		/* Encryption Scheme Type in the SchemeTypeInfoBox */
190 		GF_ISOM_CBC_SCHEME = GF_4CC('c', 'b', 'c', '1'),
191 
192 		/* Encryption Scheme Type in the SchemeTypeInfoBox */
193 		GF_ISOM_ADOBE_SCHEME = GF_4CC('a', 'd', 'k', 'm'),
194 
195 		/* Pattern Encryption Scheme Type in the SchemeTypeInfoBox */
196 		GF_ISOM_CENS_SCHEME = GF_4CC('c', 'e', 'n', 's'),
197 		GF_ISOM_CBCS_SCHEME = GF_4CC('c', 'b', 'c', 's'),
198 	};
199 
200 
201 	/*specific media sub-types - you shall make sure the media sub type is what you expect*/
202 	enum
203 	{
204 		/*reserved, internal use in the lib. Indicates the track complies to MPEG-4 system
205 		specification, and the usual OD framework tools may be used*/
206 		GF_ISOM_SUBTYPE_MPEG4 = GF_4CC('M', 'P', 'E', 'G'),
207 
208 		/*reserved, internal use in the lib. Indicates the track is of GF_ISOM_SUBTYPE_MPEG4
209 		but it is encrypted.*/
210 		GF_ISOM_SUBTYPE_MPEG4_CRYP = GF_4CC('E', 'N', 'C', 'M'),
211 
212 		/*AVC/H264 media type - not listed as an MPEG-4 type, ALTHOUGH this library automatically remaps
213 		GF_AVCConfig to MPEG-4 ESD*/
214 		GF_ISOM_SUBTYPE_AVC_H264 = GF_4CC('a', 'v', 'c', '1'),
215 		GF_ISOM_SUBTYPE_AVC2_H264 = GF_4CC('a', 'v', 'c', '2'),
216 		GF_ISOM_SUBTYPE_AVC3_H264 = GF_4CC('a', 'v', 'c', '3'),
217 		GF_ISOM_SUBTYPE_AVC4_H264 = GF_4CC('a', 'v', 'c', '4'),
218 		GF_ISOM_SUBTYPE_SVC_H264 = GF_4CC('s', 'v', 'c', '1'),
219 		GF_ISOM_SUBTYPE_HVC1 = GF_4CC('h', 'v', 'c', '1'),
220 		GF_ISOM_SUBTYPE_HEV1 = GF_4CC('h', 'e', 'v', '1'),
221 		GF_ISOM_SUBTYPE_HVC2 = GF_4CC('h', 'v', 'c', '2'),
222 		GF_ISOM_SUBTYPE_HEV2 = GF_4CC('h', 'e', 'v', '2'),
223 		//GF_ISOM_SUBTYPE_SHC1			= GF_4CC( 's', 'h', 'c', '1' ),
224 		//GF_ISOM_SUBTYPE_SHV1			= GF_4CC( 's', 'h', 'v', '1' ),
225 		GF_ISOM_SUBTYPE_LHV1 = GF_4CC('l', 'h', 'v', '1'),
226 		GF_ISOM_SUBTYPE_LHE1 = GF_4CC('l', 'h', 'e', '1'),
227 		GF_ISOM_SUBTYPE_HVT1 = GF_4CC('h', 'v', 't', '1'),
228 
229 		/*3GPP(2) extension subtypes*/
230 		GF_ISOM_SUBTYPE_3GP_H263 = GF_4CC('s', '2', '6', '3'),
231 		GF_ISOM_SUBTYPE_3GP_AMR = GF_4CC('s', 'a', 'm', 'r'),
232 		GF_ISOM_SUBTYPE_3GP_AMR_WB = GF_4CC('s', 'a', 'w', 'b'),
233 		GF_ISOM_SUBTYPE_3GP_EVRC = GF_4CC('s', 'e', 'v', 'c'),
234 		GF_ISOM_SUBTYPE_3GP_QCELP = GF_4CC('s', 'q', 'c', 'p'),
235 		GF_ISOM_SUBTYPE_3GP_SMV = GF_4CC('s', 's', 'm', 'v'),
236 
237 		/*3GPP DIMS*/
238 		GF_ISOM_SUBTYPE_3GP_DIMS = GF_4CC('d', 'i', 'm', 's'),
239 
240 		GF_ISOM_SUBTYPE_AC3 = GF_4CC('a', 'c', '-', '3'),
241 		GF_ISOM_SUBTYPE_MP3 = GF_4CC('.', 'm', 'p', '3'),
242 
243 		GF_ISOM_SUBTYPE_LSR1 = GF_4CC('l', 's', 'r', '1'),
244 		GF_ISOM_SUBTYPE_WVTT = GF_4CC('w', 'v', 't', 't'),
245 		GF_ISOM_SUBTYPE_STXT = GF_4CC('s', 't', 'x', 't'),
246 		GF_ISOM_SUBTYPE_STPP = GF_4CC('s', 't', 'p', 'p'),
247 		GF_ISOM_SUBTYPE_SBTT = GF_4CC('s', 'b', 't', 't'),
248 		GF_ISOM_SUBTYPE_METT = GF_4CC('m', 'e', 't', 't'),
249 		GF_ISOM_SUBTYPE_METX = GF_4CC('m', 'e', 't', 'x'),
250 
251 		/* CAPTIONS */
252 		GF_ISOM_SUBTYPE_C608 = GF_4CC('c', '6', '0', '8'),
253 		GF_ISOM_SUBTYPE_C708 = GF_4CC('c', '7', '0', '8'),
254 
255 		/* xdvb, seems MPEG-2, needed by some US TV stations so I'm doing my best */
256 		GF_ISOM_SUBTYPE_XDVB = GF_4CC('x', 'd', 'v', 'b')
257 	};
258 
259 
260 
261 
262 	/*direction for sample search (including SyncSamples search)
263 	Function using search allways specify the desired time in composition (presentation) time
264 
265 	(Sample N-1)	DesiredTime		(Sample N)
266 
267 	FORWARD: will give the next sample given the desired time (eg, N)
268 	BACKWARD: will give the previous sample given the desired time (eg, N-1)
269 	SYNCFORWARD: will search from the desired point in time for a sync sample if any
270 	If no sync info, behaves as FORWARD
271 	SYNCBACKWARD: will search till the desired point in time for a sync sample if any
272 	If no sync info, behaves as BACKWARD
273 	SYNCSHADOW: use the sync shadow information to retrieve the sample.
274 	If no SyncShadow info, behave as SYNCBACKWARD
275 	*/
276 	enum
277 	{
278 		GF_ISOM_SEARCH_FORWARD = 1,
279 		GF_ISOM_SEARCH_BACKWARD = 2,
280 		GF_ISOM_SEARCH_SYNC_FORWARD = 3,
281 		GF_ISOM_SEARCH_SYNC_BACKWARD = 4,
282 		GF_ISOM_SEARCH_SYNC_SHADOW = 5
283 	};
284 
285 	/*Predefined File Brand codes (MPEG-4 and JPEG2000)*/
286 	enum
287 	{
288 		/*file complying to the generic ISO Media File (base specification ISO/IEC 14496-12)
289 		this is the default brand when creating a new movie*/
290 		GF_ISOM_BRAND_ISOM = GF_4CC('i', 's', 'o', 'm'),
291 		/*file complying to the generic ISO Media File (base specification ISO/IEC 14496-12) + Meta extensions*/
292 		GF_ISOM_BRAND_ISO2 = GF_4CC('i', 's', 'o', '2'),
293 		/*file complying to ISO/IEC 14496-1 2001 edition. A .mp4 file without a brand
294 		is equivalent to a file compatible with this brand*/
295 		GF_ISOM_BRAND_MP41 = GF_4CC('m', 'p', '4', '1'),
296 		/*file complying to ISO/IEC 14496-14 (MP4 spec)*/
297 		GF_ISOM_BRAND_MP42 = GF_4CC('m', 'p', '4', '2'),
298 		/*file complying to ISO/IEC 15444-3 (JPEG2000) without profile restriction*/
299 		GF_ISOM_BRAND_MJP2 = GF_4CC('m', 'j', 'p', '2'),
300 		/*file complying to ISO/IEC 15444-3 (JPEG2000) with simple profile restriction*/
301 		GF_ISOM_BRAND_MJ2S = GF_4CC('m', 'j', '2', 's'),
302 		/*old versions of 3GPP spec (without timed text)*/
303 		GF_ISOM_BRAND_3GP4 = GF_4CC('3', 'g', 'p', '4'),
304 		GF_ISOM_BRAND_3GP5 = GF_4CC('3', 'g', 'p', '5'),
305 		/*final version of 3GPP file spec*/
306 		GF_ISOM_BRAND_3GP6 = GF_4CC('3', 'g', 'p', '6'),
307 		/*generci 3GPP file (several audio tracks, etc..)*/
308 		GF_ISOM_BRAND_3GG6 = GF_4CC('3', 'g', 'g', '6'),
309 		/*3GPP2 file spec*/
310 		GF_ISOM_BRAND_3G2A = GF_4CC('3', 'g', '2', 'a'),
311 		/*AVC file spec*/
312 		GF_ISOM_BRAND_AVC1 = GF_4CC('a', 'v', 'c', '1'),
313 		/* file complying to ISO/IEC 21000-9:2005 (MPEG-21 spec)*/
314 		GF_ISOM_BRAND_MP21 = GF_4CC('m', 'p', '2', '1'),
315 		/*file complying to the generic ISO Media File (base specification ISO/IEC 14496-12) + support for version 1*/
316 		GF_ISOM_BRAND_ISO4 = GF_4CC('i', 's', 'o', '4'),
317 		/* Image File Format */
318 		GF_ISOM_BRAND_MIF1 = GF_4CC('m', 'i', 'f', '1'),
319 		GF_ISOM_BRAND_HEIC = GF_4CC('h', 'e', 'i', 'c'),
320 	};
321 
322 
323 	/*MPEG-4 ProfileAndLevel codes*/
324 	enum
325 	{
326 		GF_ISOM_PL_AUDIO,
327 		GF_ISOM_PL_VISUAL,
328 		GF_ISOM_PL_GRAPHICS,
329 		GF_ISOM_PL_SCENE,
330 		GF_ISOM_PL_OD,
331 		GF_ISOM_PL_MPEGJ,
332 		/*not a profile, just set/unset inlineFlag*/
333 		GF_ISOM_PL_INLINE,
334 	};
335 
336 #ifndef GPAC_DISABLE_ISOM
337 
338 #include <gpac/mpeg4_odf.h>
339 
340 	/*the isomedia file*/
341 	typedef struct __tag_isom GF_ISOFile;
342 
343 	/*Random Access Point flag*/
344 	typedef enum {
345 		RAP_REDUNDANT = -1,
346 		RAP_NO = 0,
347 		RAP = 1,
348 		SAP_TYPE_1 = 1,
349 		SAP_TYPE_2 = 2,
350 		SAP_TYPE_3 = 3,
351 		SAP_TYPE_4 = 4,
352 		SAP_TYPE_5 = 5,
353 		SAP_TYPE_6 = 6
354 	} SAPType;
355 
356 	/*media sample object*/
357 	typedef struct
358 	{
359 		/*data size*/
360 		u32 dataLength;
361 		/*data with padding if requested*/
362 		char *data;
363 		/*decoding time*/
364 		u64 DTS;
365 		/*relative offset for composition if needed*/
366 		s32 CTS_Offset;
367 		SAPType IsRAP;
368 	} GF_ISOSample;
369 
370 
371 	/*creates a new empty sample*/
372 	GF_ISOSample *gf_isom_sample_new();
373 
374 	/*delete a sample. NOTE:the buffer content will be destroyed by default.
375 	if you wish to keep the buffer, set dataLength to 0 in the sample
376 	before deleting it
377 	the pointer is set to NULL after deletion*/
378 	void gf_isom_sample_del(GF_ISOSample **samp);
379 
380 	/********************************************************************
381 	GENERAL API FUNCTIONS
382 	********************************************************************/
383 
384 	/*get the last fatal error that occured in the file
385 	ANY FUNCTION OF THIS API WON'T BE PROCESSED IF THE FILE HAS AN ERROR
386 	Note: some function may return an error while the movie has no error
387 	the last error is a FatalError, and is not always set if a bad
388 	param is specified...*/
389 	GF_Err gf_isom_last_error(GF_ISOFile *the_file);
390 
391 	/*indicates if target file is an IsoMedia file
392 	returns 1 if it is a non-special file, 2 if an init segment, 3 if a media segment,
393 	returns 0 otherwise*/
394 	u32 gf_isom_probe_file(const char *fileName);
395 
396 	/*Opens an isoMedia File.
397 	tmp_dir: for the 2 edit modes only, specifies a location for temp file. If NULL, the library will use the default
398 	OS temporary file management schemes.*/
399 	GF_ISOFile *gf_isom_open(const char *fileName, u32 OpenMode, const char *tmp_dir);
400 
401 	/*close the file, write it if new/edited*/
402 	GF_Err gf_isom_close(GF_ISOFile *the_file);
403 
404 	/*delete the movie without saving it.*/
405 	void gf_isom_delete(GF_ISOFile *the_file);
406 
407 	/*Get the mode of an open file*/
408 	u8 gf_isom_get_mode(GF_ISOFile *the_file);
409 
410 	Bool gf_isom_is_JPEG2000(GF_ISOFile *mov);
411 
412 	u64 gf_isom_get_file_size(GF_ISOFile *the_file);
413 
414 	Bool gf_isom_moov_first(GF_ISOFile *movie);
415 
416 	/*sets write cache size for files when creating them. If size is 0, writing
417 	only relies on the underlying OS fwrite/fgetc
418 	If movie is NULL, assigns the default write cache size for any new movie*/
419 	GF_Err gf_isom_set_output_buffering(GF_ISOFile *movie, u32 size);
420 
421 	/********************************************************************
422 	STREAMING API FUNCTIONS
423 	********************************************************************/
424 	/*open a movie that can be uncomplete in READ_ONLY mode
425 	to use for http streaming & co
426 
427 	NOTE: you must buffer the data to a local file, this mode DOES NOT handle
428 	http/ftp/... streaming
429 
430 	start_range and end_range restricts the media byte range in the URL (used by DASH)
431 	if 0 or end_range<=start_range, the entire URL is used when parsing
432 
433 	BytesMissing is the predicted number of bytes missing for the file to be loaded
434 	Note that if the file is not optimized for streaming, this number is not accurate
435 	If the movie is successfully loaded (the_file non-NULL), BytesMissing is zero
436 	*/
437 	GF_Err gf_isom_open_progressive(const char *fileName, u64 start_range, u64 end_range, GF_ISOFile **the_file, u64 *BytesMissing);
438 
439 	/*If requesting a sample fails with error GF_ISOM_INCOMPLETE_FILE, use this function
440 	to get the number of bytes missing to retrieve the sample*/
441 	u64 gf_isom_get_missing_bytes(GF_ISOFile *the_file, u32 trackNumber);
442 
443 
444 	/*Fragmented movie extensions*/
445 
446 	/*return 0 if movie isn't fragmented, 1 otherwise*/
447 	u32 gf_isom_is_fragmented(GF_ISOFile *the_file);
448 	/*return 0 if track isn't fragmented, 1 otherwise*/
449 	u32 gf_isom_is_track_fragmented(GF_ISOFile *the_file, u32 TrackID);
450 
451 	/*a file being downloaded may be a fragmented file. In this case only partial info
452 	is available once the file is successfully open (gf_isom_open_progressive), and since there is
453 	no information wrt number fragments (which could actually be generated on the fly
454 	at the sender side), you must call this function on regular bases in order to
455 	load newly downloaded fragments. Note this may result in Track/Movie duration changes
456 	and SampleCount change too ...
457 
458 	if new_location is set, the previous bitstream is changed to this new location, otherwise it is refreshed (disk flush)
459 
460 	*/
461 	GF_Err gf_isom_refresh_fragmented(GF_ISOFile *the_file, u64 *MissingBytes, const char *new_location);
462 
463 	/*check if file has movie info, eg has tracks & dynamic media. Some files may just use
464 	the base IsoMedia structure without "moov" container*/
465 	Bool gf_isom_has_movie(GF_ISOFile *file);
466 
467 	/* check if the file has a top styp box and returns the brand and version of the first styp found */
468 	Bool gf_isom_has_segment(GF_ISOFile *file, u32 *brand, u32 *version);
469 	/*get number of movie fragments in the file*/
470 	u32 gf_isom_segment_get_fragment_count(GF_ISOFile *file);
471 	/*get number of track fragments in the indicated movie fragment (1-based index)*/
472 	u32 gf_isom_segment_get_track_fragment_count(GF_ISOFile *file, u32 moof_index);
473 	/*returns the track ID and get the tfdt of the given track fragment (1-based index) in the indicated movie fragment (1-based index)*/
474 	u32 gf_isom_segment_get_track_fragment_decode_time(GF_ISOFile *file, u32 moof_index, u32 traf_index, u64 *decode_time);
475 
476 	/* Indicates that we want to parse only one moof/mdat at a time
477 	in order to proceed to next moof, call gf_isom_reset_data_offset
478 	*/
479 	void gf_isom_set_single_moof_mode(GF_ISOFile *file, Bool mode);
480 	/********************************************************************
481 	READING API FUNCTIONS
482 	********************************************************************/
483 
484 	/*return the number of tracks in the movie, or -1 if error*/
485 	u32 gf_isom_get_track_count(GF_ISOFile *the_file);
486 
487 	/*return the timescale of the movie, 0 if error*/
488 	u32 gf_isom_get_timescale(GF_ISOFile *the_file);
489 
490 	/*return the computed duration of the movie given the media in the sample tables, 0 if error*/
491 	u64 gf_isom_get_duration(GF_ISOFile *the_file);
492 
493 	/*return the duration of the movie as written in the file, regardless of the media data*/
494 	u64 gf_isom_get_original_duration(GF_ISOFile *movie);
495 
496 	/*return the creation info of the movie*/
497 	GF_Err gf_isom_get_creation_time(GF_ISOFile *the_file, u64 *creationTime, u64 *modificationTime);
498 
499 	/*return the trackID of track number n, or 0 if error*/
500 	u32 gf_isom_get_track_id(GF_ISOFile *the_file, u32 trackNumber);
501 
502 	/*return the track number of the track of specified ID, or 0 if error*/
503 	u32 gf_isom_get_track_by_id(GF_ISOFile *the_file, u32 trackID);
504 
505 	/*return the original trackID of the track number n, or 0 if error*/
506 	u32 gf_isom_get_track_original_id(GF_ISOFile *movie, u32 trackNumber);
507 
508 	/*gets the enable flag of a track 0: NO, 1: yes, 2: error*/
509 	u8 gf_isom_is_track_enabled(GF_ISOFile *the_file, u32 trackNumber);
510 
511 	/* determines if the track is encrypted 0: NO, 1: yes, 2: error*/
512 	u8 gf_isom_is_track_encrypted(GF_ISOFile *the_file, u32 trackNumber);
513 
514 	/*get the track duration return 0 if bad param*/
515 	u64 gf_isom_get_track_duration(GF_ISOFile *the_file, u32 trackNumber);
516 
517 	/*return the media type FOUR CHAR code type of the media*/
518 	u32 gf_isom_get_media_type(GF_ISOFile *the_file, u32 trackNumber);
519 
520 	/*return the media type FOUR CHAR code type of the media*/
521 	u32 gf_isom_get_media_subtype(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
522 
523 	/*return the media type FOUR CHAR code type of an MPEG4 media (eg, mp4a, mp4v, enca, encv, etc...)
524 	returns 0 if not MPEG-4 subtype*/
525 	u32 gf_isom_get_mpeg4_subtype(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
526 
527 	/*Get the media (composition) time given the absolute time in the Movie
528 	mediaTime is set to 0 if the media is not playing at that time (empty time segment)*/
529 	GF_Err gf_isom_get_media_time(GF_ISOFile *the_file, u32 trackNumber, u32 movieTime, u64 *MediaTime);
530 
531 	/*Get the number of "streams" stored in the media - a media can have several stream descriptions...*/
532 	u32 gf_isom_get_sample_description_count(GF_ISOFile *the_file, u32 trackNumber);
533 
534 	/*Get the stream description index (eg, the ESD) for a given time IN MEDIA TIMESCALE
535 	return 0 if error or if empty*/
536 	u32 gf_isom_get_sample_description_index(GF_ISOFile *the_file, u32 trackNumber, u64 for_time);
537 
538 	/*returns 1 if samples refering to the given stream description are present in the file
539 	0 otherwise*/
540 	Bool gf_isom_is_self_contained(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
541 
542 	/*get the media duration (without edit) based on sample table return 0 if no samples (URL streams)*/
543 	u64 gf_isom_get_media_duration(GF_ISOFile *the_file, u32 trackNumber);
544 
545 	/*get the media duration (without edit) as indicated in the file (regardless of sample tables)*/
546 	u64 gf_isom_get_media_original_duration(GF_ISOFile *movie, u32 trackNumber);
547 
548 	/*Get the timeScale of the media. */
549 	u32 gf_isom_get_media_timescale(GF_ISOFile *the_file, u32 trackNumber);
550 
551 	/*gets min, average and max maximum chunk durations (each of them s optional) of the track in media timescale*/
552 	GF_Err gf_isom_get_chunks_infos(GF_ISOFile *movie, u32 trackNumber, u32 *dur_min, u32 *dur_avg, u32 *dur_max, u32 *size_min, u32 *size_avg, u32 *size_max);
553 
554 	/*Get the HandlerDescription name. The outName must be:
555 	(outName != NULL && *outName == NULL)
556 	the handler name is the string version of the MediaTypes*/
557 	GF_Err gf_isom_get_handler_name(GF_ISOFile *the_file, u32 trackNumber, const char **outName);
558 
559 	/*Check a DataReference of this track (index >= 1)
560 	A Data Reference allows to construct a file without integrating the media data*/
561 	GF_Err gf_isom_check_data_reference(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
562 
563 	/*get the location of the data. If URL && URN are NULL, the data is in this file
564 	both strings are const: don't free them.*/
565 	GF_Err gf_isom_get_data_reference(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const char **outURL, const char **outURN);
566 
567 	/*Get the number of samples - return 0 if error*/
568 	u32 gf_isom_get_sample_count(GF_ISOFile *the_file, u32 trackNumber);
569 
570 	/*Get constant sample size, or 0 if size not constant*/
571 	u32 gf_isom_get_constant_sample_size(GF_ISOFile *the_file, u32 trackNumber);
572 	/*returns total amount of media bytes in track*/
573 	u64 gf_isom_get_media_data_size(GF_ISOFile *the_file, u32 trackNumber);
574 
575 	/*It may be desired to fetch samples with a bigger allocated buffer than their real size, in case the decoder
576 	reads more data than available. This sets the amount of extra bytes to allocate when reading samples from this track
577 	NOTE: the dataLength of the sample does NOT include padding*/
578 	GF_Err gf_isom_set_sample_padding(GF_ISOFile *the_file, u32 trackNumber, u32 padding_bytes);
579 
580 	/*return a sample given its number, and set the StreamDescIndex of this sample
581 	this index allows to retrieve the stream description if needed (2 media in 1 track)
582 	return NULL if error*/
583 	GF_ISOSample *gf_isom_get_sample(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 *StreamDescriptionIndex);
584 
585 	/*same as gf_isom_get_sample but doesn't fetch media data
586 	@StreamDescriptionIndex (optional): set to stream description index
587 	@data_offset (optional): set to sample start offset in file.
588 
589 	NOTE: when both StreamDescriptionIndex and data_offset are NULL, only DTS, CTS_Offset and RAP indications are
590 	retrieved (faster)
591 	*/
592 	GF_ISOSample *gf_isom_get_sample_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 *StreamDescriptionIndex, u64 *data_offset);
593 
594 	/*retrieves given sample DTS*/
595 	u64 gf_isom_get_sample_dts(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
596 
597 	/*returns sample duration in media timeScale*/
598 	u32 gf_isom_get_sample_duration(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
599 
600 	/*returns sample size in bytes*/
601 	u32 gf_isom_get_sample_size(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
602 
603 	/*returns sync flag of sample*/
604 	u8 gf_isom_get_sample_sync(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
605 
606 	GF_Err gf_isom_get_sample_flags(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 *is_leading, u32 *dependsOn, u32 *dependedOn, u32 *redundant);
607 
608 	/*gets a sample given a desired decoding time IN MEDIA TIME SCALE
609 	and set the StreamDescIndex of this sample
610 	this index allows to retrieve the stream description if needed (2 media in 1 track)
611 	return GF_EOS if the desired time exceeds the media duration
612 	WARNING: the sample may not be sync even though the sync was requested (depends on the media and the editList)
613 	the SampleNum is optional. If non-NULL, will contain the sampleNumber*/
614 	GF_Err gf_isom_get_sample_for_media_time(GF_ISOFile *the_file, u32 trackNumber, u64 desiredTime, u32 *StreamDescriptionIndex, u8 SearchMode, GF_ISOSample **sample, u32 *SampleNum);
615 
616 	/*retrieves given sample DTS*/
617 	u32 gf_isom_get_sample_from_dts(GF_ISOFile *the_file, u32 trackNumber, u64 dts);
618 
619 	/*get the current tfdt of the track - this can be used to adjust sample time queries when edit list are used*/
620 	u64 gf_isom_get_current_tfdt(GF_ISOFile *the_file, u32 trackNumber);
621 
622 	/*Track Edition functions*/
623 
624 	/*return a sample given a desired time in the movie. MovieTime is IN MEDIA TIME SCALE , handles edit list.
625 	and set the StreamDescIndex of this sample
626 	this index allows to retrieve the stream description if needed (2 media in 1 track)
627 	sample must be set to NULL before calling.
628 
629 	result Sample is NULL if an error occured
630 	if no sample is playing, an empty sample is returned with no data and a DTS set to MovieTime when serching in sync modes
631 	if no sample is playing, the closest sample in the edit time-line is returned when serching in regular modes
632 
633 	WARNING: the sample may not be sync even though the sync was requested (depends on the media and the editList)
634 
635 	Note: this function will handle re-timestamping the sample according to the mapping  of the media time-line
636 	on the track time-line. The sample TSs (DTS / CTS offset) are expressed in MEDIA TIME SCALE
637 	(to match the media stream TS resolution as indicated in media header / SLConfig)
638 
639 	sampleNumber is optional and gives the number of the sample in the media
640 	*/
641 	GF_Err gf_isom_get_sample_for_movie_time(GF_ISOFile *the_file, u32 trackNumber, u64 movieTime, u32 *StreamDescriptionIndex, u8 SearchMode, GF_ISOSample **sample, u32 *sampleNumber);
642 
643 	/*return 1 if true edit list, 0 if no edit list or if time-shifting only edit list, in which case mediaOffset is set to the DTS offset value (e.g., your app should add mediaOffset to all sample DTS)*/
644 	Bool gf_isom_get_edit_list_type(GF_ISOFile *the_file, u32 trackNumber, s64 *mediaOffset);
645 
646 	/*get the number of edited segment*/
647 	u32 gf_isom_get_edit_segment_count(GF_ISOFile *the_file, u32 trackNumber);
648 
649 	/*Get the desired segment information*/
650 	GF_Err gf_isom_get_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u32 SegmentIndex, u64 *EditTime, u64 *SegmentDuration, u64 *MediaTime, u8 *EditMode);
651 
652 	/*get the number of languages for the copyright*/
653 	u32 gf_isom_get_copyright_count(GF_ISOFile *the_file);
654 	/*get the copyright and its language code given the index*/
655 	GF_Err gf_isom_get_copyright(GF_ISOFile *the_file, u32 Index, const char **threeCharCodes, const char **notice);
656 	/*get the opaque watermark info if any - returns GF_NOT_SUPPORTED if not present*/
657 	GF_Err gf_isom_get_watermark(GF_ISOFile *the_file, bin128 UUID, u8** data, u32* length);
658 
659 	/*get the number of chapter for movie or track if trackNumber !=0*/
660 	u32 gf_isom_get_chapter_count(GF_ISOFile *the_file, u32 trackNumber);
661 	/*get the given movie or track (trackNumber!=0) chapter time and name - index is 1-based
662 	@chapter_time: retrives start time in milliseconds - may be NULL.
663 	@name: retrieves chapter name - may be NULL - SHALL NOT be destroyed by user
664 	*/
665 	GF_Err gf_isom_get_chapter(GF_ISOFile *the_file, u32 trackNumber, u32 Index, u64 *chapter_time, const char **name);
666 
667 	/*
668 	return 0 if the media has no sync point info (eg, all samples are RAPs)
669 	return 1 if the media has sync points (eg some samples are RAPs)
670 	return 2 if the media has empty sync point info (eg no samples are RAPs). This will likely only happen
671 	in scalable context
672 	*/
673 	u8 gf_isom_has_sync_points(GF_ISOFile *the_file, u32 trackNumber);
674 
675 	/*returns number of sync points*/
676 	u32 gf_isom_get_sync_point_count(GF_ISOFile *the_file, u32 trackNumber);
677 
678 	/*
679 	returns 1 if the track uses unsigned compositionTime offsets (B-frames or similar)
680 	returns 2 if the track uses signed compositionTime offsets (B-frames or similar)
681 	returns 0 if the track does not use compositionTime offsets (CTS == DTS)
682 	*/
683 	u32 gf_isom_has_time_offset(GF_ISOFile *the_file, u32 trackNumber);
684 
685 	/*returns 1 if the track has sync shadow samples*/
686 	Bool gf_isom_has_sync_shadows(GF_ISOFile *the_file, u32 trackNumber);
687 
688 	/*returns 1 if the track has sample dep indications*/
689 	Bool gf_isom_has_sample_dependency(GF_ISOFile *the_file, u32 trackNumber);
690 
691 	/*rough estimation of file size, only works for completely self-contained files and without fragmentation
692 	for the current time*/
693 	u64 gf_isom_estimate_size(GF_ISOFile *the_file);
694 
695 	u32 gf_isom_get_next_alternate_group_id(GF_ISOFile *movie);
696 
697 
698 	/*
699 	MPEG-4 Systems extensions
700 	*/
701 
702 	/*check if files has root OD/IOD or not*/
703 	Bool gf_isom_has_root_od(GF_ISOFile *the_file);
704 
705 	/*return the root Object descriptor of the movie (can be NULL, OD or IOD, you have to check its tag)
706 	YOU HAVE TO DELETE THE DESCRIPTOR
707 	*/
708 	GF_Descriptor *gf_isom_get_root_od(GF_ISOFile *the_file);
709 
710 	/*check the presence of a track in IOD. 0: NO, 1: YES, 2: ERROR*/
711 	u8 gf_isom_is_track_in_root_od(GF_ISOFile *the_file, u32 trackNumber);
712 
713 	/*Get the GF_ESD given the StreamDescriptionIndex - YOU HAVE TO DELETE THE DESCRIPTOR*/
714 	GF_ESD *gf_isom_get_esd(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
715 
716 	/*Get the decoderConfigDescriptor given the StreamDescriptionIndex - YOU HAVE TO DELETE THE DESCRIPTOR*/
717 	GF_DecoderConfig *gf_isom_get_decoder_config(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
718 
719 	/*sets default TrackID (or ES_ID) for clock references. If trackNumber is 0, default sync track ID is reseted
720 	and will be reassigned at next ESD fetch*/
721 	void gf_isom_set_default_sync_track(GF_ISOFile *file, u32 trackNumber);
722 
723 	/*Return the number of track references of a track for a given ReferenceType - return -1 if error*/
724 	s32 gf_isom_get_reference_count(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType);
725 
726 	/*Return the referenced track number for a track and a given ReferenceType and Index
727 	return -1 if error, 0 if the reference is a NULL one, or the trackNumber
728 	*/
729 	GF_Err gf_isom_get_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 referenceIndex, u32 *refTrack);
730 
731 	/*Return the referenced track ID for a track and a given ReferenceType and Index
732 	return -1 if error, 0 if the reference is a NULL one, or the trackNumber
733 	*/
734 	GF_Err gf_isom_get_reference_ID(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 referenceIndex, u32 *refTrackID);
735 
736 	/*Return referenceIndex if the given track has a reference to the given TreckID of a given ReferenceType, 0 otherwise*/
737 	u32 gf_isom_has_track_reference(GF_ISOFile *movie, u32 trackNumber, u32 referenceType, u32 refTrackID);
738 
739 	u8 gf_isom_get_pl_indication(GF_ISOFile *the_file, u8 PL_Code);
740 
741 	/*locates the first ObjectDescriptor using the given track by inspecting any OD tracks*/
742 	u32 gf_isom_find_od_for_track(GF_ISOFile *file, u32 track);
743 
744 	/*returns file name*/
745 	const char *gf_isom_get_filename(GF_ISOFile *the_file);
746 
747 	/*
748 	Update of the Reading API for IsoMedia Version 2
749 	*/
750 
751 	/*retrieves the brand of the file. The brand is introduced in V2 to differenciate
752 	MP4, MJPEG2000 and QT while indicating compatibilities
753 	the brand is one of the above defined code, or any other registered brand
754 
755 	minorVersion is an optional parameter (can be set to NULL) ,
756 	"informative integer for the minor version of the major brand"
757 	AlternateBrandsCount is an optional parameter (can be set to NULL) ,
758 	giving the number of compatible brands.
759 
760 	The function will set brand to 0 if no brand indication is found in the file
761 	*/
762 	GF_Err gf_isom_get_brand_info(GF_ISOFile *the_file, u32 *brand, u32 *minorVersion, u32 *AlternateBrandsCount);
763 
764 	/*gets an alternate brand indication. BrandIndex is 1-based
765 	Note that the Major brand should always be indicated in the alternate brands*/
766 	GF_Err gf_isom_get_alternate_brand(GF_ISOFile *the_file, u32 BrandIndex, u32 *brand);
767 
768 	/*get the number of padding bits at the end of a given sample if any*/
769 	GF_Err gf_isom_get_sample_padding_bits(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u8 *NbBits);
770 	/*indicates whether the track samples use padding bits or not*/
771 	Bool gf_isom_has_padding_bits(GF_ISOFile *the_file, u32 trackNumber);
772 
773 	/*returns width and height of the given visual sample desc - error if not a visual track*/
774 	GF_Err gf_isom_get_visual_info(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 *Width, u32 *Height);
775 
776 	/*returns samplerate (no SBR when applicable), channels and bps of the given audio track - error if not a audio track*/
777 	GF_Err gf_isom_get_audio_info(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 *SampleRate, u32 *Channels, u8 *bitsPerSample);
778 
779 	/*returns track visual info - all coord values are expressed as 16.16 fixed point floats*/
780 	GF_Err gf_isom_get_track_layout_info(GF_ISOFile *the_file, u32 trackNumber, u32 *width, u32 *height, s32 *translation_x, s32 *translation_y, s16 *layer);
781 
782 	/*returns track matrix info - all coord values are expressed as 16.16 fixed point floats*/
783 	GF_Err gf_isom_get_track_matrix(GF_ISOFile *the_file, u32 trackNumber, u32 matrix[9]);
784 
785 	/*returns width and height of the given visual sample desc - error if not a visual track*/
786 	GF_Err gf_isom_get_pixel_aspect_ratio(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 *hSpacing, u32 *vSpacing);
787 
788 	/*gets RVC config of given sample description*/
789 	GF_Err gf_isom_get_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 *rvc_predefined, char **data, u32 *size, const char **mime);
790 
791 	/*
792 	User Data Manipulation (cf write API too)
793 	*/
794 
795 	//returns the number of entries in UDTA of the track if trackNumber is not 0, or of the movie otherwise
796 	u32 gf_isom_get_udta_count(GF_ISOFile *movie, u32 trackNumber);
797 
798 	//returns the type (box 4CC and UUID if any) of the given entry in UDTA of the track if trackNumber is not 0, or of the movie otherwise. udta_idx is 1-based index.
799 	GF_Err gf_isom_get_udta_type(GF_ISOFile *movie, u32 trackNumber, u32 udta_idx, u32 *UserDataType, bin128 *UUID);
800 
801 	/* Gets the number of UserDataItems with the same ID / UUID in the desired track or
802 	in the movie if trackNumber is set to 0*/
803 	u32 gf_isom_get_user_data_count(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID);
804 	/* Gets the UserData for the specified item from the track or the movie if trackNumber is set to 0
805 	data is allocated by the function and is yours to free
806 	you musty pass (userData != NULL && *userData=NULL)
807 
808 	if UserDataIndex is 0, all boxes with type==UserDataType will be serialized (including box header and size) in the buffer
809 	*/
810 	GF_Err gf_isom_get_user_data(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID, u32 UserDataIndex, char **userData, u32 *userDataSize);
811 
812 
813 	/*gets the media language code (3 chars if old files, longer if BCP-47 */
814 	GF_Err gf_isom_get_media_language(GF_ISOFile *the_file, u32 trackNumber, char **lang);
815 
816 	/* gets the i-th track kind (0-based) */
817 	u32 gf_isom_get_track_kind_count(GF_ISOFile *the_file, u32 trackNumber);
818 	GF_Err gf_isom_get_track_kind(GF_ISOFile *the_file, u32 trackNumber, u32 index, char **scheme, char **value);
819 
820 	/*Unknown sample description*/
821 	typedef struct
822 	{
823 		/*codec tag is the containing box's tag, 0 if UUID is used*/
824 		u32 codec_tag;
825 		/*entry UUID if no tag is used*/
826 		bin128 UUID;
827 
828 		u16 version;
829 		u16 revision;
830 		u32 vendor_code;
831 
832 		/*video codecs only*/
833 		u32 temporal_quality;
834 		u32 spatial_quality;
835 		u16 width, height;
836 		u32 h_res, v_res;
837 		u16 depth;
838 		u16 color_table_index;
839 		char compressor_name[33];
840 
841 		/*audio codecs only*/
842 		u32 samplerate;
843 		u16 nb_channels;
844 		u16 bits_per_sample;
845 
846 		/*if present*/
847 		char *extension_buf;
848 		u32 extension_buf_size;
849 	} GF_GenericSampleDescription;
850 
851 	/*returns wrapper for unknown entries - you must delete it yourself*/
852 	GF_GenericSampleDescription *gf_isom_get_generic_sample_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
853 
854 	/*retrieves default values for a track fragment. Each variable is optional and
855 	if set will contain the default value for this track samples*/
856 	GF_Err gf_isom_get_fragment_defaults(GF_ISOFile *the_file, u32 trackNumber,
857 		u32 *defaultDuration, u32 *defaultSize, u32 *defaultDescriptionIndex,
858 		u32 *defaultRandomAccess, u8 *defaultPadding, u16 *defaultDegradationPriority);
859 
860 
861 	/*non standard extensions used for video packets in order to keep AU structure in the file format
862 	(no normative tables for that). Info is NOT written to disk.
863 	*/
864 	/*get number of fragments for a sample */
865 	u32 gf_isom_get_sample_fragment_count(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
866 	/*get sample fragment size*/
867 	u16 gf_isom_get_sample_fragment_size(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 FragmentIndex);
868 
869 	/*returns 1 if file is single AV (max one audio, one video, one text and basic od/bifs)*/
870 	Bool gf_isom_is_single_av(GF_ISOFile *file);
871 
872 	/*guess which std this file refers to. return value:
873 	GF_ISOM_BRAND_ISOM: unrecognized std
874 	GF_ISOM_BRAND_3GP5: 3GP file (max 1 audio, 1 video) without text track
875 	GF_ISOM_BRAND_3GP6: 3GP file (max 1 audio, 1 video) with text track
876 	GF_ISOM_BRAND_3GG6: 3GP file multitrack file
877 	GF_ISOM_BRAND_3G2A: 3GP2 file
878 	GF_ISOM_BRAND_AVC1: AVC file
879 	FCC("ISMA"): ISMA file (may overlap with 3GP)
880 	GF_ISOM_BRAND_MP42: any generic MP4 file (eg with BIFS/OD/MPEG-4 systems stuff)
881 
882 	for files without movie, returns the file meta handler type
883 	*/
884 	u32 gf_isom_guess_specification(GF_ISOFile *file);
885 	/*keeps UTC edit times when storing*/
886 	void gf_isom_keep_utc_times(GF_ISOFile *file, Bool keep_utc);
887 
888 	/*drops all modification/creation times and handler/copyright containing GPAC rev info (used for tests)*/
889 	void gf_isom_no_version_date_info(GF_ISOFile *file, Bool drop_info);
890 
891 
892 	/*gets last UTC/timestamp values indicated for the reference track in the file if any. Returns 0 if no info found*/
893 	Bool gf_isom_get_last_producer_time_box(GF_ISOFile *file, u32 *refTrackID, u64 *ntp, u64 *timestamp, Bool reset_info);
894 
895 #ifndef GPAC_DISABLE_ISOM_WRITE
896 
897 
898 	/********************************************************************
899 	EDITING/WRITING API FUNCTIONS
900 	********************************************************************/
901 
902 	/*set the timescale of the movie*/
903 	GF_Err gf_isom_set_timescale(GF_ISOFile *the_file, u32 timeScale);
904 
905 	/*creates a new Track. If trackID = 0, the trackID is chosen by the API
906 	returns the track number or 0 if error*/
907 	u32 gf_isom_new_track(GF_ISOFile *the_file, u32 trackID, u32 MediaType, u32 TimeScale);
908 
909 	/*removes the desired track - internal cross dependancies will be updated.
910 	WARNING: any OD streams with references to this track through  ODUpdate, ESDUpdate, ESDRemove commands
911 	will be rewritten*/
912 	GF_Err gf_isom_remove_track(GF_ISOFile *the_file, u32 trackNumber);
913 
914 	/*sets the enable flag of a track*/
915 	GF_Err gf_isom_set_track_enabled(GF_ISOFile *the_file, u32 trackNumber, u8 enableTrack);
916 
917 	/*sets creationTime and modificationTime of the movie to the specified date*/
918 	GF_Err gf_isom_set_creation_time(GF_ISOFile *movie, u64 time);
919 	/*sets creationTime and modificationTime of the track to the specified date*/
920 	GF_Err gf_isom_set_track_creation_time(GF_ISOFile *movie, u32 trackNumber, u64 time);
921 
922 	/*changes the trackID - all track references present in the file are updated
923 	returns error if trackID is already in used in the file*/
924 	GF_Err gf_isom_set_track_id(GF_ISOFile *the_file, u32 trackNumber, u32 trackID);
925 
926 	/*force to rewrite all dependencies when trackID changes*/
927 	GF_Err gf_isom_rewrite_track_dependencies(GF_ISOFile *movie, u32 trackNumber);
928 
929 	/*Add samples to a track. Use streamDescriptionIndex to specify the desired stream (if several)*/
930 	GF_Err gf_isom_add_sample(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const GF_ISOSample *sample);
931 
932 	//copies all sample dependency, subSample and sample group information from the given sampleNumber in source file to the last added sample in dest file
933 	GF_Err gf_isom_copy_sample_info(GF_ISOFile *dst, u32 dst_track, GF_ISOFile *src, u32 src_track, u32 sampleNumber);
934 
935 	/*Add sync shadow sample to a track.
936 	- There must be a regular sample with the same DTS.
937 	- Sync Shadow samples MUST be RAP
938 	- Currently, adding sync shadow must be done in order (no sample insertion)
939 	*/
940 	GF_Err gf_isom_add_sample_shadow(GF_ISOFile *the_file, u32 trackNumber, GF_ISOSample *sample);
941 
942 	/*add data to current sample in the track. Use this function for media with
943 	fragmented options such as MPEG-4 video packets. This will update the data size.
944 	CANNOT be used with OD media type*/
945 	GF_Err gf_isom_append_sample_data(GF_ISOFile *the_file, u32 trackNumber, char *data, u32 data_size);
946 
947 	/*sets RAP flag of last sample added to TRUE*/
948 	GF_Err gf_isom_set_sample_rap(GF_ISOFile *movie, u32 trackNumber);
949 
950 	/*Add sample references to a track. The dataOffset is the offset of the data in the referenced file
951 	you MUST have created a StreamDescription with URL or URN specifying your referenced file
952 	Use streamDescriptionIndex to specify the desired stream (if several)*/
953 	GF_Err gf_isom_add_sample_reference(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_ISOSample *sample, u64 dataOffset);
954 
955 	/*set the duration of the last media sample. If not set, the duration of the last sample is the
956 	duration of the previous one if any, or media TimeScale (default value).*/
957 	GF_Err gf_isom_set_last_sample_duration(GF_ISOFile *the_file, u32 trackNumber, u32 duration);
958 
959 	/*sets a track reference*/
960 	GF_Err gf_isom_set_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferencedTrackID);
961 
962 	/*removes a track reference*/
963 	GF_Err gf_isom_remove_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferenceIndex);
964 
965 	/*sets track handler name. name is either NULL (reset), a UTF-8 formatted string or a UTF8 file
966 	resource in the form "file://path/to/file_utf8" */
967 	GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const char *nameUTF8);
968 
969 	/*Update the sample size table - this is needed when using @gf_isom_append_sample_data in case the resulting samples
970 	are of same sizes (typically in 3GP speech tracks)*/
971 	GF_Err gf_isom_refresh_size_info(GF_ISOFile *file, u32 trackNumber);
972 
973 	/*return the duration of the movie, 0 if error*/
974 	GF_Err gf_isom_update_duration(GF_ISOFile *the_file);
975 
976 	/*Update Sample functions*/
977 
978 	/*update a given sample of the media.
979 	@data_only: if set, only the sample data is updated, not other info*/
980 	GF_Err gf_isom_update_sample(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, GF_ISOSample *sample, Bool data_only);
981 
982 	/*update a sample reference in the media. Note that the sample MUST exists,
983 	that sample->data MUST be NULL and sample->dataLength must be NON NULL;*/
984 	GF_Err gf_isom_update_sample_reference(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, GF_ISOSample *sample, u64 data_offset);
985 
986 	/*Remove a given sample*/
987 	GF_Err gf_isom_remove_sample(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
988 
989 	/*changes media time scale - if force_rescale is 1, only the media timescale is changed but media times are not updated */
990 	GF_Err gf_isom_set_media_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 new_timescale, Bool force_rescale);
991 
992 	/*set the save file name of the (edited) movie.
993 	If the movie is edited, the default fileName is avp_#openName)
994 	NOTE: you cannot save an edited file under the same name (overwrite not allowed)
995 	If the movie is created (WRITE mode), the default filename is #openName*/
996 	GF_Err gf_isom_set_final_name(GF_ISOFile *the_file, char *filename);
997 
998 
999 	/*set the storage mode of a file (FLAT, STREAMABLE, INTERLEAVED)*/
1000 	GF_Err gf_isom_set_storage_mode(GF_ISOFile *the_file, u8 storageMode);
1001 	u8 gf_isom_get_storage_mode(GF_ISOFile *the_file);
1002 
1003 	/*set the interleaving time of media data (INTERLEAVED mode only)
1004 	InterleaveTime is in MovieTimeScale*/
1005 	GF_Err gf_isom_set_interleave_time(GF_ISOFile *the_file, u32 InterleaveTime);
1006 	u32 gf_isom_get_interleave_time(GF_ISOFile *the_file);
1007 
1008 	/*forces usage of 64 bit chunk offsets*/
1009 	void gf_isom_force_64bit_chunk_offset(GF_ISOFile *the_file, Bool set_on);
1010 
1011 	/*set the copyright in one language.*/
1012 	GF_Err gf_isom_set_copyright(GF_ISOFile *the_file, const char *threeCharCode, char *notice);
1013 
1014 	/*deletes copyright (1-based indexes)*/
1015 	GF_Err gf_isom_remove_copyright(GF_ISOFile *the_file, u32 index);
1016 
1017 	/*add a kind type to the track */
1018 	GF_Err gf_isom_add_track_kind(GF_ISOFile *movie, u32 trackNumber, const char *schemeURI, const char *value);
1019 	/*removes a kind type to the track, all if NULL params */
1020 	GF_Err gf_isom_remove_track_kind(GF_ISOFile *movie, u32 trackNumber, const char *schemeURI, const char *value);
1021 
1022 	/*changes the handler type of the media*/
1023 	GF_Err gf_isom_set_media_type(GF_ISOFile *movie, u32 trackNumber, u32 new_type);
1024 
1025 	/*changes the type of the sampleDescriptionBox - USE AT YOUR OWN RISK, the file may not be understood afterwards*/
1026 	GF_Err gf_isom_set_media_subtype(GF_ISOFile *movie, u32 trackNumber, u32 sampleDescriptionIndex, u32 new_type);
1027 
1028 	GF_Err gf_isom_set_alternate_group_id(GF_ISOFile *movie, u32 trackNumber, u32 groupId);
1029 
1030 	/*add chapter info:
1031 	if trackNumber is 0, the chapter info is added to the movie, otherwise to the track
1032 	@timestamp: chapter start time in milliseconds. Chapters are added in order to the file. If a chapter with same timestamp
1033 	is found, its name is updated but no entry is created.
1034 	@name: chapter name. If NULL, defaults to 'Chapter N'
1035 	*/
1036 	GF_Err gf_isom_add_chapter(GF_ISOFile *the_file, u32 trackNumber, u64 timestamp, char *name);
1037 
1038 	/*deletes copyright (1-based index, index 0 for all)*/
1039 	GF_Err gf_isom_remove_chapter(GF_ISOFile *the_file, u32 trackNumber, u32 index);
1040 
1041 	/*set watermark info for movie*/
1042 	GF_Err gf_isom_set_watermark(GF_ISOFile *the_file, bin128 UUID, u8* data, u32 length);
1043 
1044 	/*Track Edition functions - used to change the normal playback of the media if desired
1045 	NOTE: IT IS THE USER RESPONSABILITY TO CREATE A CONSISTENT TIMELINE FOR THE TRACK
1046 	This API provides the basic hooks and some basic consistency checking
1047 	but can not check the desired functionality of the track edits
1048 	*/
1049 
1050 	/*update or insert a new edit segment in the track time line. Edits are used to modify
1051 	the media normal timing. EditTime and EditDuration are expressed in Movie TimeScale
1052 	If a segment with EditTime already exists, IT IS ERASED
1053 	if there is a segment before this new one, its duration is adjust to match EditTime of
1054 	the new segment
1055 	WARNING: The first segment always have an EditTime of 0. You should insert an empty or dwelled segment first.*/
1056 	GF_Err gf_isom_set_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u64 EditTime, u64 EditDuration, u64 MediaTime, u8 EditMode);
1057 
1058 	/*same as above except only modifies duartion type and mediaType*/
1059 	GF_Err gf_isom_modify_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u32 seg_index, u64 EditDuration, u64 MediaTime, u8 EditMode);
1060 	/*same as above except only appends new segment*/
1061 	GF_Err gf_isom_append_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u64 EditDuration, u64 MediaTime, u8 EditMode);
1062 
1063 	/*remove the edit segments for the whole track*/
1064 	GF_Err gf_isom_remove_edit_segments(GF_ISOFile *the_file, u32 trackNumber);
1065 
1066 	/*remove the given edit segment (1-based index). If this is not the last segment, the next segment duration
1067 	is updated to maintain a continous timeline*/
1068 	GF_Err gf_isom_remove_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u32 seg_index);
1069 
1070 	/*Updates edit list after track edition: all edit entries with aduration or media starttime larger than the media duration are clamped to media duration*/
1071 	GF_Err gf_isom_update_edit_list_duration(GF_ISOFile *file, u32 track);
1072 
1073 	/*
1074 	User Data Manipulation
1075 
1076 	You can add specific typed data to either a track or the movie: the UserData
1077 	The type must be formated as a FourCC if you have a registered 4CC type
1078 	but the usual is to set a UUID (128 bit ID for box type) which never conflict
1079 	with existing structures in the format
1080 	To manipulate a UUID user data set the UserDataType to 0 and specify a valid UUID.
1081 	Otherwise the UUID parameter is ignored
1082 	Several items with the same ID or UUID can be added (this allows you to store any
1083 	kind/number of private information under a unique ID / UUID)
1084 	*/
1085 	/*Add a user data item in the desired track or in the movie if TrackNumber is 0*/
1086 	GF_Err gf_isom_add_user_data(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID, char *data, u32 DataLength);
1087 
1088 	/*remove all user data items from the desired track or from the movie if TrackNumber is 0*/
1089 	GF_Err gf_isom_remove_user_data(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID);
1090 
1091 	/*remove a user data item from the desired track or from the movie if TrackNumber is 0
1092 	use the UDAT read functions to get the item index*/
1093 	GF_Err gf_isom_remove_user_data_item(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID, u32 UserDataIndex);
1094 
1095 	/*remove track, moov (trackNumber=0) or file-level (trackNumber=0xFFFFFFFF) UUID box of matching type*/
1096 	GF_Err gf_isom_remove_uuid(GF_ISOFile *movie, u32 trackNumber, bin128 UUID);
1097 	/*adds track, moov (trackNumber=0) or file-level (trackNumber=0xFFFFFFFF) UUID box of given type*/
1098 	GF_Err gf_isom_add_uuid(GF_ISOFile *movie, u32 trackNumber, bin128 UUID, const char *data, u32 data_size);
1099 
1100 	/*Add a user data item in the desired track or in the movie if TrackNumber is 0, using a serialzed buffer of ISOBMFF boxes*/
1101 	GF_Err gf_isom_add_user_data_boxes(GF_ISOFile *the_file, u32 trackNumber, char *data, u32 DataLength);
1102 
1103 	/*
1104 	Update of the Writing API for IsoMedia Version 2
1105 	*/
1106 
1107 	/*use a compact track version for sample size. This is not usually recommended
1108 	except for speech codecs where the track has a lot of small samples
1109 	compaction is done automatically while writing based on the track's sample sizes*/
1110 	GF_Err gf_isom_use_compact_size(GF_ISOFile *the_file, u32 trackNumber, u8 CompactionOn);
1111 
1112 	/*sets the brand of the movie*/
1113 	GF_Err gf_isom_set_brand_info(GF_ISOFile *the_file, u32 MajorBrand, u32 MinorVersion);
1114 
1115 	/*adds or remove an alternate brand for the movie*/
1116 	GF_Err gf_isom_modify_alternate_brand(GF_ISOFile *the_file, u32 Brand, u8 AddIt);
1117 
1118 	/*removes all alternate brands except major brand*/
1119 	GF_Err gf_isom_reset_alt_brands(GF_ISOFile *movie);
1120 
1121 	/*set the number of padding bits at the end of a given sample if needed
1122 	if the function is never called the padding bit info is ignored
1123 	this MUST be called on an existin sample*/
1124 	GF_Err gf_isom_set_sample_padding_bits(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u8 NbBits);
1125 
1126 
1127 	/*since v2 you must specify w/h of video tracks for authoring tools (no decode the video cfg / first sample)*/
1128 	GF_Err gf_isom_set_visual_info(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 Width, u32 Height);
1129 
1130 	/*mainly used for 3GPP text since most ISO-based formats ignore these (except MJ2K)
1131 	all coord values are expressed as 16.16 fixed point floats*/
1132 	GF_Err gf_isom_set_track_layout_info(GF_ISOFile *the_file, u32 trackNumber, u32 width, u32 height, s32 translation_x, s32 translation_y, s16 layer);
1133 
1134 	/*sets track matrix - all coordinates are expressed as 16.16 floating points*/
1135 	GF_Err gf_isom_set_track_matrix(GF_ISOFile *the_file, u32 trackNumber, u32 matrix[9]);
1136 
1137 	GF_Err gf_isom_set_pixel_aspect_ratio(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 hSpacing, u32 vSpacing);
1138 
1139 	/*set SR & nbChans for audio description*/
1140 	GF_Err gf_isom_set_audio_info(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 sampleRate, u32 nbChannels, u8 bitsPerSample);
1141 
1142 	/*non standard extensions: set/remove a fragment of a sample - this is used for video packets
1143 	in order to keep AU structure in the file format (no normative tables for that). Info is NOT written to disk*/
1144 	GF_Err gf_isom_add_sample_fragment(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u16 FragmentSize);
1145 	GF_Err gf_isom_remove_sample_fragment(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber);
1146 	/*remove all sample fragment info for this track*/
1147 	GF_Err gf_isom_remove_sample_fragments(GF_ISOFile *the_file, u32 trackNumber);
1148 
1149 	/*set CTS unpack mode (used for B-frames & like): in unpack mode, each sample uses one entry in CTTS tables
1150 	unpack=0: set unpack on - !!creates a CTTS table if none found!!
1151 	unpack=1: set unpack off and repacks all table info
1152 	*/
1153 	GF_Err gf_isom_set_cts_packing(GF_ISOFile *the_file, u32 trackNumber, Bool unpack);
1154 	/*modify CTS offset of a given sample (used for B-frames) - MUST be called in unpack mode only*/
1155 	GF_Err gf_isom_modify_cts_offset(GF_ISOFile *the_file, u32 trackNumber, u32 sample_number, u32 offset);
1156 	/*remove CTS offset table (used for B-frames)*/
1157 	GF_Err gf_isom_remove_cts_info(GF_ISOFile *the_file, u32 trackNumber);
1158 
1159 	/*set 3-char or BCP-47 code media language*/
1160 	GF_Err gf_isom_set_media_language(GF_ISOFile *the_file, u32 trackNumber, char *code);
1161 
1162 	/*removes given stream description*/
1163 	GF_Err gf_isom_remove_sample_description(GF_ISOFile *the_file, u32 trackNumber, u32 streamDescIndex);
1164 
1165 	/*sets the RVC config for the given track sample description*/
1166 	GF_Err gf_isom_set_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 rvc_predefined, char *mime, char *data, u32 size);
1167 
1168 	/*
1169 	some authoring extensions
1170 	*/
1171 	/*sets name for authoring - if name is NULL reset authoring name*/
1172 	GF_Err gf_isom_set_track_name(GF_ISOFile *the_file, u32 trackNumber, char *name);
1173 	/*gets authoring name*/
1174 	const char *gf_isom_get_track_name(GF_ISOFile *the_file, u32 trackNumber);
1175 
1176 	/*
1177 	MPEG-4 Extensions
1178 	*/
1179 
1180 	/*set a profile and level indication for the movie iod (created if needed)
1181 	if the flag is ProfileLevel is 0 this means the movie doesn't require
1182 	the specific codec (equivalent to 0xFF value in MPEG profiles)*/
1183 	GF_Err gf_isom_set_pl_indication(GF_ISOFile *the_file, u8 PL_Code, u8 ProfileLevel);
1184 
1185 	/*set the rootOD ID of the movie if you need it. By default, movies are created without root ODs*/
1186 	GF_Err gf_isom_set_root_od_id(GF_ISOFile *the_file, u32 OD_ID);
1187 
1188 	/*set the rootOD URL of the movie if you need it (only needed to create empty file pointing
1189 	to external ressource)*/
1190 	GF_Err gf_isom_set_root_od_url(GF_ISOFile *the_file, char *url_string);
1191 
1192 	/*remove the root OD*/
1193 	GF_Err gf_isom_remove_root_od(GF_ISOFile *the_file);
1194 
1195 	/*Add a system descriptor to the OD of the movie*/
1196 	GF_Err gf_isom_add_desc_to_root_od(GF_ISOFile *the_file, GF_Descriptor *theDesc);
1197 
1198 	/*add a track to the root OD*/
1199 	GF_Err gf_isom_add_track_to_root_od(GF_ISOFile *the_file, u32 trackNumber);
1200 
1201 	/*remove a track to the root OD*/
1202 	GF_Err gf_isom_remove_track_from_root_od(GF_ISOFile *the_file, u32 trackNumber);
1203 
1204 	/*Create a new StreamDescription (GF_ESD) in the file. The URL and URN are used to
1205 	describe external media, this will creat a data reference for the media*/
1206 	GF_Err gf_isom_new_mpeg4_description(GF_ISOFile *the_file, u32 trackNumber, GF_ESD *esd, char *URLname, char *URNname, u32 *outDescriptionIndex);
1207 
1208 	/*use carefully. Very useful when you made a lot of changes (IPMP, IPI, OCI, ...)
1209 	THIS WILL REPLACE THE WHOLE DESCRIPTOR ...*/
1210 	GF_Err gf_isom_change_mpeg4_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_ESD *newESD);
1211 
1212 	/*Add a system descriptor to the ESD of a stream - you have to delete the descriptor*/
1213 	GF_Err gf_isom_add_desc_to_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_Descriptor *theDesc);
1214 
1215 	/*updates average and max bitrate - if 0 for max, removes bitrate info*/
1216 	GF_Err gf_isom_update_bitrate(GF_ISOFile *movie, u32 trackNumber, u32 sampleDescriptionIndex, u32 average_bitrate, u32 max_bitrate, u32 decode_buffer_size);
1217 
1218 
1219 	/*Default extensions*/
1220 
1221 	/*Create a new unknown StreamDescription in the file. The URL and URN are used to
1222 	describe external media, this will creat a data reference for the media
1223 	use this to store media not currently supported by the ISO media format
1224 	*/
1225 	GF_Err gf_isom_new_generic_sample_description(GF_ISOFile *the_file, u32 trackNumber, char *URLname, char *URNname, GF_GenericSampleDescription *udesc, u32 *outDescriptionIndex);
1226 
1227 	/*change the data field of an unknown sample description*/
1228 	GF_Err gf_isom_change_generic_sample_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_GenericSampleDescription *udesc);
1229 
1230 	/*
1231 	special shortcut for stream description cloning from a given input file (this avoids inspecting for media type)
1232 	@the_file, @trackNumber: destination file and track
1233 	@orig_file, @orig_track, @orig_desc_index: orginal file, track and sample description
1234 	@URLname, @URNname, @outDescriptionIndex: same usage as with gf_isom_new_mpeg4_description
1235 	*/
1236 	GF_Err gf_isom_clone_sample_description(GF_ISOFile *the_file, u32 trackNumber, GF_ISOFile *orig_file, u32 orig_track, u32 orig_desc_index, char *URLname, char *URNname, u32 *outDescriptionIndex);
1237 
1238 	/*clones all sampleDescription entries in new track, after an optional reset of existing entries*/
1239 	GF_Err gf_isom_clone_sample_descriptions(GF_ISOFile *the_file, u32 trackNumber, GF_ISOFile *orig_file, u32 orig_track, Bool reset_existing);
1240 
1241 	/*special shortcut: clones a track (everything except media data and sample info (DTS, CTS, RAPs, etc...)
1242 	also clones sampleDescriptions
1243 	@keep_data_ref: if set, all data references are kept (local ones become external pointing to orig_file name), otherwise all external data refs are removed (track media data will be self-contained)
1244 	@dest_track: track number of cloned track*/
1245 	GF_Err gf_isom_clone_track(GF_ISOFile *orig_file, u32 orig_track, GF_ISOFile *dest_file, Bool keep_data_ref, u32 *dest_track);
1246 	/*special shortcut: clones IOD PLs from orig to dest if any*/
1247 	GF_Err gf_isom_clone_pl_indications(GF_ISOFile *orig, GF_ISOFile *dest);
1248 	/*clones root OD from input to output file, without copying root OD track references*/
1249 	GF_Err gf_isom_clone_root_od(GF_ISOFile *input, GF_ISOFile *output);
1250 
1251 	/*clones the entire movie file to destination. Tracks can be cloned if clone_tracks is set, in which case hint tracks can be
1252 	kept if keep_hint_tracks is set
1253 	if keep_pssh, all pssh boxes will be kept
1254 	fragment information (mvex) is not kept*/
1255 	GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool clone_tracks, Bool keep_hint_tracks, Bool keep_pssh);
1256 
1257 	/*returns true if same set of sample description in both tracks - this does include self-contained checking
1258 	and reserved flags. The specific media cfg (DSI & co) is not analysed, only
1259 	a brutal memory comparaison is done*/
1260 	Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index1, GF_ISOFile *f2, u32 tk2, u32 sdesc_index2);
1261 
1262 	GF_Err gf_isom_set_JPEG2000(GF_ISOFile *mov, Bool set_on);
1263 
1264 	/* sample information for all tracks setup are reset. This allows keeping the memory
1265 	footprint low when playing segments. Note however that seeking in the file is then no longer possible*/
1266 	GF_Err gf_isom_reset_tables(GF_ISOFile *movie, Bool reset_sample_count);
1267 	/* sets the offset for parsing from the input buffer to 0 (used to reclaim input buffer)*/
1268 	GF_Err gf_isom_reset_data_offset(GF_ISOFile *movie, u64 *top_box_start);
1269 
1270 	/*releases current movie segment - this closes the associated file IO object.
1271 	If reset_tables is set, sample information for all tracks setup as segment are destroyed, along with all PSSH boxes. This allows keeping the memory
1272 	footprint low when playing segments. Note however that seeking in the file is then no longer; possible
1273 	WARNING - the sample count is not reset after the release of tables. This means you need to keep counting samples.*/
1274 	GF_Err gf_isom_release_segment(GF_ISOFile *movie, Bool reset_tables);
1275 
1276 	/*Flags for gf_isom_open_segment*/
1277 	enum
1278 	{
1279 		/*FLAT: the MediaData (MPEG4 ESs) is stored at the beginning of the file*/
1280 		GF_ISOM_SEGMENT_NO_ORDER_FLAG = 1,
1281 		GF_ISOM_SEGMENT_SCALABLE_FLAG = 1 << 1,
1282 	};
1283 
1284 	/*opens a new segment file. Access to samples in previous segments is no longer possible
1285 	if end_range>start_range, restricts the URL to the given byterange when parsing*/
1286 	GF_Err gf_isom_open_segment(GF_ISOFile *movie, const char *fileName, u64 start_range, u64 end_range, u32 flags);
1287 
1288 	/*returns track ID of the traf containing the highest enhancement layer for the given base track*/
1289 	u32 gf_isom_get_highest_track_in_scalable_segment(GF_ISOFile *movie, u32 for_base_track);
1290 
1291 #ifndef GPAC_DISABLE_ISOM_FRAGMENTS
1292 
1293 	/*
1294 	Movie Fragments Writing API
1295 	Movie Fragments is a feature of ISO media files for fragmentation
1296 	of a presentation meta-data and interleaving with its media data.
1297 	This enables faster http fast start for big movies, and also reduces the risk
1298 	of data loss in case of a recording crash, because meta data and media data
1299 	can be written to disk at regular times
1300 	This API provides simple function calls to setup such a movie and write it
1301 	The process implies:
1302 	1- creating a movie in the usual way (track, stream descriptions, (IOD setup
1303 	copyright, ...)
1304 	2- possibly add some samples in the regular fashion
1305 	3- setup track fragments for all track that will be written in a fragmented way
1306 	(note that you can create/write a track that has no fragmentation at all)
1307 	4- finalize the movie for fragmentation (this will flush all meta-data and
1308 	any media-data added to disk, ensuring all vital information for the presentation
1309 	is stored on file and not lost in case of crash/poweroff)
1310 
1311 	then 5-6 as often as desired
1312 	5- start a new movie fragment
1313 	6- add samples to each setup track
1314 
1315 
1316 	IMPORTANT NOTES:
1317 	* Movie Fragments can only be used in GF_ISOM_OPEN_WRITE mode (capturing)
1318 	and no editing functionalities can be used
1319 	* the fragmented movie API uses TrackID and not TrackNumber
1320 	*/
1321 
1322 	/*
1323 	setup a track for fragmentation by specifying some default values for
1324 	storage efficiency
1325 	*TrackID: track identifier
1326 	*DefaultStreamDescriptionIndex: the default description used by samples in this track
1327 	*DefaultSampleDuration: default duration of samples in this track
1328 	*DefaultSampleSize: default size of samples in this track (0 if unknown)
1329 	*DefaultSampleIsSync: default key-flag (RAP) of samples in this track
1330 	*DefaultSamplePadding: default padding bits for samples in this track
1331 	*DefaultDegradationPriority: default degradation priority for samples in this track
1332 
1333 	*/
1334 	GF_Err gf_isom_setup_track_fragment(GF_ISOFile *the_file, u32 TrackID,
1335 		u32 DefaultStreamDescriptionIndex,
1336 		u32 DefaultSampleDuration,
1337 		u32 DefaultSampleSize,
1338 		u8 DefaultSampleIsSync,
1339 		u8 DefaultSamplePadding,
1340 		u16 DefaultDegradationPriority);
1341 
1342 	/*change the default parameters of an existing trak fragment - should not be used if samples have
1343 	already been added - semantics are the same as in gf_isom_setup_track_fragment*/
1344 	GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID,
1345 		u32 DefaultSampleDescriptionIndex,
1346 		u32 DefaultSampleDuration,
1347 		u32 DefaultSampleSize,
1348 		u8 DefaultSampleIsSync,
1349 		u8 DefaultSamplePadding,
1350 		u16 DefaultDegradationPriority);
1351 
1352 	/*flushes data to disk and prepare movie fragmentation
1353 	@media_segment_type: 0 if no segments, 1 if regular segment, 2 if single segment*/
1354 	GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *the_file, u32 media_segment_type);
1355 
1356 	/*sets the duration of the movie in case of movie fragments*/
1357 	GF_Err gf_isom_set_movie_duration(GF_ISOFile *movie, u64 duration);
1358 
1359 	/*starts a new movie fragment - if force_cache is set, fragment metadata will be written before
1360 	fragment media data for all tracks*/
1361 	GF_Err gf_isom_start_fragment(GF_ISOFile *movie, Bool moof_first);
1362 
1363 	/*starts a new segment in the file. If SegName is given, the output will be written in the SegName file. If memory_mode is set, all samples writing is done in memory rather than on disk*/
1364 	GF_Err gf_isom_start_segment(GF_ISOFile *movie, const char *SegName, Bool memory_mode);
1365 
1366 	/*sets the baseMediaDecodeTime of the first sample of the given track*/
1367 	GF_Err gf_isom_set_traf_base_media_decode_time(GF_ISOFile *movie, u32 TrackID, u64 decode_time);
1368 
1369 	/*sets Microsoft Smooth Streaming traf 'tfxd' box info, written at the end of each traf*/
1370 	GF_Err gf_isom_set_traf_mss_timeext(GF_ISOFile *movie, u32 reference_track_ID, u64 ntp_in_10mhz, u64 traf_duration_in_10mhz);
1371 
1372 	/*closes current segment - if fragments_per_sidx is <0, no sidx is used - if fragments_per_sidx is ==0, a single sidx is used
1373 	timestamp_shift is the constant difference between media time and presentation time (derived from edit list)*/
1374 	GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegs_per_sidx, u32 referenceTrackID, u64 ref_track_decode_time, s32 timestamp_shift, u64 ref_track_next_cts, Bool daisy_chain_sidx, Bool last_segment, u32 segment_marker_4cc, u64 *index_start_range, u64 *index_end_range);
1375 
1376 	/*writes any pending fragment to file for low-latency output. shall only be used if no SIDX is used (subsegs_per_sidx<0 or flushing all fragments before calling gf_isom_close_segment)*/
1377 	GF_Err gf_isom_flush_fragments(GF_ISOFile *movie, Bool last_segment);
1378 
1379 	/*sets fragment prft box info, written just before the moof*/
1380 	GF_Err gf_isom_set_fragment_reference_time(GF_ISOFile *movie, u32 reference_track_ID, u64 ntp, u64 timestamp);
1381 
1382 	/*writes an empty sidx in the current movie. The SIDX will be forced to have nb_segs entries - nb_segs shall match the number of calls to
1383 	gf_isom_close_segment that will follow. This avoids wasting time and disk space moving data around. Once gf_isom_close_segment has then been called nb_segs times,
1384 	the pre-allocated SIDX is destroyed and sucessive calls to gf_isom_close_segment will create their own sidx (unless gf_isom_allocate_sidx is called again).
1385 	frags_per_sidx, daisy_chain_sidx and frags_per_segment are currently ignored and reserved for future usages where multiple SIDX could be written
1386 	if not NULL, start_range and end_range will contain the byte range of the SIDX box in the movie*/
1387 	GF_Err gf_isom_allocate_sidx(GF_ISOFile *movie, s32 subsegs_per_sidx, Bool daisy_chain_sidx, u32 nb_segs, u32 *frags_per_segment, u32 *start_range, u32 *end_range);
1388 
1389 	enum
1390 	{
1391 		/*indicates that the track fragment has no samples but still has a duration
1392 		(silence-detection in audio codecs, ...).
1393 		param: indicates duration*/
1394 		GF_ISOM_TRAF_EMPTY,
1395 		/*I-Frame detection: this can reduce file size by detecting I-frames and
1396 		optimizing sample flags (padding, priority, ..)
1397 		param: on/off (0/1)*/
1398 		GF_ISOM_TRAF_RANDOM_ACCESS,
1399 		/*activate data cache on track fragment. This is useful when writing interleaved
1400 		media from a live source (typically audio-video), and greatly reduces file size
1401 		param: Number of samples (> 1) to cache before disk flushing. You shouldn't try
1402 		to cache too many samples since this will load your memory. base that on FPS/SR*/
1403 		GF_ISOM_TRAF_DATA_CACHE
1404 	};
1405 
1406 	/*set options. Options can be set at the beginning of each new fragment only, and for the
1407 	lifetime of the fragment*/
1408 	GF_Err gf_isom_set_fragment_option(GF_ISOFile *the_file, u32 TrackID, u32 Code, u32 param);
1409 
1410 
1411 	/*adds a sample to a fragmented track
1412 
1413 	*TrackID: destination track
1414 	*sample: sample to add
1415 	*StreamDescriptionIndex: stream description for this sample. If 0, the default one
1416 	is used
1417 	*Duration: sample duration.
1418 	Note: because of the interleaved nature of the meta/media data, the sample duration
1419 	MUST be provided (in case of regular tracks, this was computed internally by the lib)
1420 	*PaddingBits: padding bits for the sample, or 0
1421 	*DegradationPriority for the sample, or 0
1422 	*redundantCoding: indicates this is samples acts as a sync shadow point
1423 
1424 	*/
1425 
1426 	GF_Err gf_isom_fragment_add_sample(GF_ISOFile *the_file, u32 TrackID, const GF_ISOSample *sample,
1427 		u32 StreamDescriptionIndex,
1428 		u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redundantCoding);
1429 
1430 	/*appends data into last sample of track for video fragments/other media
1431 	CANNOT be used with OD tracks*/
1432 	GF_Err gf_isom_fragment_append_data(GF_ISOFile *the_file, u32 TrackID, char *data, u32 data_size, u8 PaddingBits);
1433 
1434 	/*reset internal info used with fragments and segment. Should be called when seeking (with keep_sample_count=0) or when loading a media segments with the same timing as the previously loaded segment*/
1435 	void gf_isom_reset_fragment_info(GF_ISOFile *movie, Bool keep_sample_count);
1436 
1437 	/*return the duration of the movie+fragments if known, 0 if error*/
1438 	u64 gf_isom_get_fragmented_duration(GF_ISOFile *movie);
1439 	/*returns the number of sidx boxes*/
1440 	u32 gf_isom_get_fragments_count(GF_ISOFile *movie, Bool segments_only);
1441 	/*gets total sample number and duration*/
1442 	GF_Err gf_isom_get_fragmented_samples_info(GF_ISOFile *movie, u32 trackID, u32 *nb_samples, u64 *duration);
1443 
1444 	GF_Err gf_isom_fragment_add_sai(GF_ISOFile *output, GF_ISOFile *input, u32 TrackID, u32 SampleNum);
1445 	GF_Err gf_isom_clone_pssh(GF_ISOFile *output, GF_ISOFile *input, Bool in_moof);
1446 
1447 #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/
1448 
1449 	GF_Err gf_isom_set_sync_table(GF_ISOFile *the_file, u32 trackNumber);
1450 
1451 	/******************************************************************
1452 	GENERIC Publishing API
1453 	******************************************************************/
1454 
1455 	/*Removes all sync shadow entries for a given track. The shadow samples are NOT removed; they must be removed
1456 	by the user app*/
1457 	GF_Err gf_isom_remove_sync_shadows(GF_ISOFile *the_file, u32 trackNumber);
1458 
1459 	/*Use this function to do the shadowing if you use shadowing.
1460 	the sample to be shadowed MUST be a non-sync sample (ignored if not)
1461 	the sample shadowing must be a Sync sample (error if not)*/
1462 	GF_Err gf_isom_set_sync_shadow(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 syncSample);
1463 
1464 	/*set the GroupID of a track (only used for optimized interleaving). By setting GroupIDs
1465 	you can specify the storage order for media data of a group of streams. This is useful
1466 	for BIFS presentation so that static resources of the scene can be downloaded before BIFS*/
1467 	GF_Err gf_isom_set_track_interleaving_group(GF_ISOFile *the_file, u32 trackNumber, u32 GroupID);
1468 
1469 	/*set the priority of a track within a Group (used for optimized interleaving and hinting).
1470 	This allows tracks to be stored before other within a same group, for instance the
1471 	hint track data can be stored just before the media data, reducing disk seeking
1472 	for a same time, within a group of tracks, the track with the lowest inversePriority will
1473 	be written first*/
1474 	GF_Err gf_isom_set_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber, u32 InversePriority);
1475 
1476 	/*set the max SamplesPerChunk (for file optimization, mainly in FLAT and STREAMABLE modes)*/
1477 	GF_Err gf_isom_set_max_samples_per_chunk(GF_ISOFile *the_file, u32 trackNumber, u32 maxSamplesPerChunk);
1478 
1479 	/*associate a given SL config with a given ESD while extracting the OD information
1480 	all the SL params must be fixed by the calling app!
1481 	The SLConfig is stored by the API for further use. A NULL pointer will result
1482 	in using the default SLConfig (predefined = 2) remapped to predefined = 0
1483 	This is useful while reading the IOD / OD stream of an MP4 file. Note however that
1484 	only full AUs are extracted, therefore the calling application must SL-packetize the streams*/
1485 	GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig *slConfig);
1486 
1487 	GF_Err gf_isom_get_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig **slConfig);
1488 
1489 	u32 gf_isom_get_track_group(GF_ISOFile *the_file, u32 trackNumber);
1490 	u32 gf_isom_get_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber);
1491 
1492 	/*stores movie config (storage mode, interleave time, track groupIDs, priorities and names) in UDTA(kept on disk)
1493 	if @remove_all is set, removes all stored info, otherwise recompute all stored info*/
1494 	GF_Err gf_isom_store_movie_config(GF_ISOFile *the_file, Bool remove_all);
1495 	/*restores movie config (storage mode, interleave time, track groupIDs, priorities and names) if found*/
1496 	GF_Err gf_isom_load_movie_config(GF_ISOFile *the_file);
1497 
1498 	/*setup interleaving for storage (shortcut for storeage mode + interleave_time)*/
1499 	GF_Err gf_isom_make_interleave(GF_ISOFile *mp4file, Double TimeInSec);
1500 
1501 
1502 	/******************************************************************
1503 	GENERIC HINTING WRITING API
1504 	******************************************************************/
1505 
1506 	/*supported hint formats - ONLY RTP now*/
1507 	enum
1508 	{
1509 		GF_ISOM_HINT_RTP = GF_4CC('r', 't', 'p', ' '),
1510 	};
1511 
1512 #ifndef GPAC_DISABLE_ISOM_HINTING
1513 
1514 
1515 	/*Setup the resources based on the hint format
1516 	This function MUST be called after creating a new hint track and before
1517 	any other calls on this track*/
1518 	GF_Err gf_isom_setup_hint_track(GF_ISOFile *the_file, u32 trackNumber, u32 HintType);
1519 
1520 	/*Create a HintDescription for the HintTrack
1521 	the rely flag indicates whether a reliable transport protocol is desired/required
1522 	for data transport
1523 	0: not desired (UDP/IP). NB: most RTP streaming servers only support UDP/IP for data
1524 	1: preferable (TCP/IP if possible or UDP/IP)
1525 	2: required (TCP/IP only)
1526 	The HintDescriptionIndex is set, to be used when creating a HINT sample
1527 	*/
1528 	GF_Err gf_isom_new_hint_description(GF_ISOFile *the_file, u32 trackNumber, s32 HintTrackVersion, s32 LastCompatibleVersion, u8 Rely, u32 *HintDescriptionIndex);
1529 
1530 	/*Starts a new sample for the hint track. A sample is just a collection of packets
1531 	the transmissionTime is indicated in the media timeScale of the hint track*/
1532 	GF_Err gf_isom_begin_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TransmissionTime);
1533 
1534 	/*stores the hint sample in the file once all your packets for this sample are done
1535 	set IsRandomAccessPoint if you want to indicate that this is a random access point
1536 	in the stream*/
1537 	GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint);
1538 
1539 
1540 	/******************************************************************
1541 	PacketHandling functions
1542 	Data can be added at the end or at the beginning of the current packet
1543 	by setting AtBegin to 1 the data will be added at the beginning
1544 	This allows constructing the packet payload before any meta-data
1545 	******************************************************************/
1546 
1547 	/*adds a blank chunk of data in the sample that is skipped while streaming*/
1548 	GF_Err gf_isom_hint_blank_data(GF_ISOFile *the_file, u32 trackNumber, u8 AtBegin);
1549 
1550 	/*adds a chunk of data in the packet that is directly copied while streaming
1551 	NOTE: dataLength MUST BE <= 14 bytes, and you should only use this function
1552 	to add small blocks of data (encrypted parts, specific headers, ...)*/
1553 	GF_Err gf_isom_hint_direct_data(GF_ISOFile *the_file, u32 trackNumber, char *data, u32 dataLength, u8 AtBegin);
1554 
1555 	/*adds a reference to some sample data in the packet
1556 	SourceTrackID: the ID of the track where the referenced sample is
1557 	SampleNumber: the sample number containing the data to be added
1558 	DataLength: the length of bytes to copy in the packet
1559 	offsetInSample: the offset in bytes in the sample at which to begin copying data
1560 
1561 	extra_data: only used when the sample is actually the sample that will contain this packet
1562 	(useful to store en encrypted version of a packet only available while streaming)
1563 	In this case, set SourceTrackID to the HintTrack ID and SampleNumber to 0
1564 	In this case, the DataOffset MUST BE NULL and length will indicate the extra_data size
1565 
1566 	Note that if you want to reference a previous HintSample in the hintTrack, you will
1567 	have to parse the sample yourself ...
1568 	*/
1569 	GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, char *extra_data, u8 AtBegin);
1570 
1571 
1572 	/*adds a reference to some stream description data in the packet (headers, ...)
1573 	SourceTrackID: the ID of the track where the referenced sample is
1574 	StreamDescriptionIndex: the index of the stream description in the desired track
1575 	DataLength: the length of bytes to copy in the packet
1576 	offsetInDescription: the offset in bytes in the description at which to begin copying data
1577 
1578 	Since it is far from being obvious what this offset is, we recommend not using this
1579 	function. The ISO Media Format specification is currently being updated to solve
1580 	this issue*/
1581 	GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 StreamDescriptionIndex, u16 DataLength, u32 offsetInDescription, u8 AtBegin);
1582 
1583 
1584 	/******************************************************************
1585 	RTP SPECIFIC WRITING API
1586 	******************************************************************/
1587 
1588 	/*Creates a new RTP packet in the HintSample. If a previous packet was created,
1589 	it is stored in the hint sample and a new packet is created.
1590 	- relativeTime: RTP time offset of this packet in the HintSample if any - in hint track
1591 	time scale. Used for data smoothing by servers.
1592 	- PackingBit: the 'P' bit of the RTP packet header
1593 	- eXtensionBit: the'X' bit of the RTP packet header
1594 	- MarkerBit: the 'M' bit of the RTP packet header
1595 	- PayloadType: the payload type, on 7 bits, format 0x0XXXXXXX
1596 	- B_frame: indicates if this is a B-frame packet. Can be skipped by a server
1597 	- IsRepeatedPacket: indicates if this is a duplicate packet of a previous one.
1598 	Can be skipped by a server
1599 	- SequenceNumber: the RTP base sequence number of the packet. Because of support for repeated
1600 	packets, you have to set the sequence number yourself.*/
1601 	GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, s32 relativeTime, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 PayloadType, u8 B_frame, u8 IsRepeatedPacket, u16 SequenceNumber);
1602 
1603 	/*set the flags of the RTP packet*/
1604 	GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 disposable_packet, u8 IsRepeatedPacket);
1605 
1606 	/*set the time offset of this packet. This enables packets to be placed in the hint track
1607 	in decoding order, but have their presentation time-stamp in the transmitted
1608 	packet in a different order. Typically used for MPEG video with B-frames
1609 	*/
1610 	GF_Err gf_isom_rtp_packet_set_offset(GF_ISOFile *the_file, u32 trackNumber, s32 timeOffset);
1611 
1612 
1613 	/*set some specific info in the HintDescription for RTP*/
1614 
1615 	/*sets the RTP TimeScale that the server use to send packets
1616 	some RTP payloads may need a specific timeScale that is not the timeScale in the file format
1617 	the default timeScale choosen by the API is the MediaTimeScale of the hint track*/
1618 	GF_Err gf_isom_rtp_set_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeScale);
1619 	/*sets the RTP TimeOffset that the server will add to the packets
1620 	if not set, the server adds a random offset*/
1621 	GF_Err gf_isom_rtp_set_time_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeOffset);
1622 	/*sets the RTP SequenceNumber Offset that the server will add to the packets
1623 	if not set, the server adds a random offset*/
1624 	GF_Err gf_isom_rtp_set_time_sequence_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 SequenceNumberOffset);
1625 
1626 
1627 
1628 	/******************************************************************
1629 	SDP SPECIFIC WRITING API
1630 	******************************************************************/
1631 	/*add an SDP line to the SDP container at the track level (media-specific SDP info)
1632 	NOTE: the \r\n end of line for SDP is automatically inserted*/
1633 	GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text);
1634 	/*remove all SDP info at the track level*/
1635 	GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber);
1636 
1637 	/*add an SDP line to the SDP container at the movie level (presentation SDP info)
1638 	NOTE: the \r\n end of line for SDP is automatically inserted*/
1639 	GF_Err gf_isom_sdp_add_line(GF_ISOFile *the_file, const char *text);
1640 	/*remove all SDP info at the movie level*/
1641 	GF_Err gf_isom_sdp_clean(GF_ISOFile *the_file);
1642 
1643 #endif /*GPAC_DISABLE_ISOM_HINTING*/
1644 
1645 
1646 #endif	/*GPAC_DISABLE_ISOM_WRITE*/
1647 
1648 #ifndef GPAC_DISABLE_ISOM_DUMP
1649 
1650 	/*dumps file structures into XML trace file */
1651 	GF_Err gf_isom_dump(GF_ISOFile *file, FILE *trace);
1652 
1653 #endif /*GPAC_DISABLE_ISOM_DUMP*/
1654 
1655 
1656 #ifndef GPAC_DISABLE_ISOM_HINTING
1657 
1658 #ifndef GPAC_DISABLE_ISOM_DUMP
1659 	/*dumps RTP hint samples structure into XML trace file
1660 	@trackNumber, @SampleNum: hint track and hint sample number
1661 	@trace: output
1662 	*/
1663 	GF_Err gf_isom_dump_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 SampleNum, FILE * trace);
1664 #endif
1665 
1666 	/*Get SDP info at the movie level*/
1667 	GF_Err gf_isom_sdp_get(GF_ISOFile *the_file, const char **sdp, u32 *length);
1668 	/*Get SDP info at the track level*/
1669 	GF_Err gf_isom_sdp_track_get(GF_ISOFile *the_file, u32 trackNumber, const char **sdp, u32 *length);
1670 
1671 	u32 gf_isom_get_payt_count(GF_ISOFile *the_file, u32 trackNumber);
1672 	const char *gf_isom_get_payt_info(GF_ISOFile *the_file, u32 trackNumber, u32 index, u32 *payID);
1673 
1674 
1675 
1676 
1677 	/*small hint reader - performs data caching*/
1678 
1679 	/*resets hint reading parameters, returns an error if the hint type is not supported for reading
1680 	packet sequence number is always reseted to 0
1681 	@sample_start: indicates from where the packets should be read (regular 1-based sample number)
1682 	@ts_offset: constant offset for timestamps, must be expressed in media timescale (which is the hint timescale).
1683 	usually 0 (no offset)
1684 	@sn_offset: offset for packet sequence number (first packet will have a SN of 1 + sn_offset)
1685 	usually 0
1686 	@ssrc: sync source identifier for RTP
1687 	*/
1688 	GF_Err gf_isom_reset_hint_reader(GF_ISOFile *the_file, u32 trackNumber, u32 sample_start, u32 ts_offset, u32 sn_offset, u32 ssrc);
1689 
1690 	/*reads next hint packet. ALl packets are read in transmission (decoding) order
1691 	returns an error if not supported, or GF_EOS when no more packets are available
1692 	currently only RTP reader is supported
1693 	@pck_data, @pck_size: output packet data (must be freed by caller) - contains all info to be sent
1694 	on the wire, eg for RTP contains the RTP header and the data
1695 	@disposable (optional): indicates that the packet can be dropped when late (B-frames & co)
1696 	@repeated (optional): indicates this is a repeated packet (same one has already been sent)
1697 	@trans_ts (optional): indicates the transmission time of the packet, expressed in hint timescale, taking into account
1698 	the ts_offset specified in gf_isom_reset_hint_reader. Depending on packets this may not be the same
1699 	as the hint sample timestamp + ts_offset, some packets may need to be sent earlier (B-frames)
1700 	@sample_num (optional): indicates hint sample number the packet belongs to
1701 	*/
1702 	GF_Err gf_isom_next_hint_packet(GF_ISOFile *the_file, u32 trackNumber, char **pck_data, u32 *pck_size, Bool *disposable, Bool *repeated, u32 *trans_ts, u32 *sample_num);
1703 
1704 #endif /*GPAC_DISABLE_ISOM_HINTING*/
1705 
1706 
1707 
1708 	/*
1709 	3GPP specific extensions
1710 	NOTE: MPEG-4 OD Framework cannot be used with 3GPP files.
1711 	Stream Descriptions are not GF_ESD, just generic config options as specified in this file
1712 	*/
1713 
1714 	/*Generic 3GP/3GP2 config record*/
1715 	typedef struct
1716 	{
1717 		/*GF_4CC record type, one fo the above GF_ISOM_SUBTYPE_3GP_ * subtypes*/
1718 		u32 type;
1719 		/*4CC vendor name*/
1720 		u32 vendor;
1721 		/*codec version*/
1722 		u8 decoder_version;
1723 		/*number of sound frames per IsoMedia sample, >0 and <=15. The very last sample may contain less frames. */
1724 		u8 frames_per_sample;
1725 
1726 		/*H263 ONLY - Level and profile*/
1727 		u8 H263_level, H263_profile;
1728 
1729 		/*AMR(WB) ONLY - num of mode for the codec*/
1730 		u16 AMR_mode_set;
1731 		/*AMR(WB) ONLY - changes in codec mode per sample*/
1732 		u8 AMR_mode_change_period;
1733 	} GF_3GPConfig;
1734 
1735 
1736 	/*return the 3GP config for this tream description, NULL if not a 3GPP track*/
1737 	GF_3GPConfig *gf_isom_3gp_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
1738 #ifndef GPAC_DISABLE_ISOM_WRITE
1739 	/*create the track config*/
1740 	GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfig *config, char *URLname, char *URNname, u32 *outDescriptionIndex);
1741 	/*update the track config - subtypes shall NOT differ*/
1742 	GF_Err gf_isom_3gp_config_update(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfig *config, u32 DescriptionIndex);
1743 #endif	/*GPAC_DISABLE_ISOM_WRITE*/
1744 
1745 	/*AVC/H264 extensions - GF_AVCConfig is defined in mpeg4_odf.h*/
1746 
1747 	/*gets uncompressed AVC config - user is responsible for deleting it*/
1748 	GF_AVCConfig *gf_isom_avc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1749 	/*gets uncompressed SVC config - user is responsible for deleting it*/
1750 	GF_AVCConfig *gf_isom_svc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1751 
1752 	typedef enum
1753 	{
1754 		GF_ISOM_AVCTYPE_NONE = 0,
1755 		GF_ISOM_AVCTYPE_AVC_ONLY,
1756 		GF_ISOM_AVCTYPE_AVC_SVC,
1757 		GF_ISOM_AVCTYPE_SVC_ONLY,
1758 	} GF_ISOMAVCType;
1759 
1760 	u32 gf_isom_get_avc_svc_type(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1761 
1762 
1763 	typedef enum
1764 	{
1765 		GF_ISOM_HEVCTYPE_NONE = 0,
1766 		GF_ISOM_HEVCTYPE_HEVC_ONLY,
1767 		GF_ISOM_HEVCTYPE_HEVC_LHVC,
1768 		GF_ISOM_HEVCTYPE_LHVC_ONLY,
1769 	} GF_ISOMHEVCType;
1770 
1771 	u32 gf_isom_get_hevc_lhvc_type(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1772 
1773 	/*gets HEVC config - user is responsible for deleting it*/
1774 	GF_HEVCConfig *gf_isom_hevc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1775 	/*gets LHVC config - user is responsible for deleting it*/
1776 	GF_HEVCConfig *gf_isom_lhvc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1777 
1778 	/*return true if track dependencies implying extractors or implicit reconstruction are found*/
1779 	Bool gf_isom_needs_layer_reconstruction(GF_ISOFile *file);
1780 
1781 	enum
1782 	{
1783 		/*all extractors are rewritten*/
1784 		GF_ISOM_NALU_EXTRACT_DEFAULT = 0,
1785 		/*all extractors are skipped but NALU data from this track is kept*/
1786 		GF_ISOM_NALU_EXTRACT_LAYER_ONLY,
1787 		/*all extractors are kept (untouched sample) - used for dumping modes*/
1788 		GF_ISOM_NALU_EXTRACT_INSPECT,
1789 		/*above mode is applied and PPS/SPS/... are appended in the front of every IDR*/
1790 		GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG = 1 << 16,
1791 		/*above mode is applied and all start codes are rewritten (xPS inband as well)*/
1792 		GF_ISOM_NALU_EXTRACT_ANNEXB_FLAG = 2 << 17,
1793 		/*above mode is applied and VDRD NAL unit is inserted before SVC slice*/
1794 		GF_ISOM_NALU_EXTRACT_VDRD_FLAG = 1 << 18,
1795 		/*all extractors are skipped and only tile track data is kept*/
1796 		GF_ISOM_NALU_EXTRACT_TILE_ONLY = 1 << 19
1797 	};
1798 
1799 	GF_Err gf_isom_set_nalu_extract_mode(GF_ISOFile *the_file, u32 trackNumber, u32 nalu_extract_mode);
1800 	u32 gf_isom_get_nalu_extract_mode(GF_ISOFile *the_file, u32 trackNumber);
1801 
1802 
1803 #ifndef GPAC_DISABLE_ISOM_WRITE
1804 	/*creates new AVC config*/
1805 	GF_Err gf_isom_avc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex);
1806 	/*updates AVC config*/
1807 	GF_Err gf_isom_avc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_AVCConfig *cfg);
1808 	/*updates SVC config. If is_additional is set, the SVCConfig will be added to the AVC sample description, otherwise the sample description will be SVC-only*/
1809 	GF_Err gf_isom_svc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_AVCConfig *cfg, Bool is_additional);
1810 	/*creates new SVC config*/
1811 	GF_Err gf_isom_svc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex);
1812 	/*deletes SVC config*/
1813 	GF_Err gf_isom_svc_config_del(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1814 
1815 	/*sets avc3 entry type (inband SPS/PPS) instead of of avc1 (SPS/PPS in avcC box)*/
1816 	GF_Err gf_isom_avc_set_inband_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1817 
1818 	/*sets hev1 entry type (inband SPS/PPS) instead of of hvc1 (SPS/PPS in avcC box)*/
1819 	GF_Err gf_isom_hevc_set_inband_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);
1820 
1821 	/*sets hvt1 entry type (tile track) or hev2/hvc2 type if is_base_track is set - cfg may be set to indicate sub-profile of the tile. It is the use responsability to set the tbas track reference to the base hevc track*/
1822 	GF_Err gf_isom_hevc_set_tile_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg, Bool is_base_track);
1823 
1824 
1825 	/*creates new HEVC config*/
1826 	GF_Err gf_isom_hevc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_HEVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex);
1827 	/*updates HEVC config*/
1828 	GF_Err gf_isom_hevc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg);
1829 
1830 	/*updates L-HHVC config*/
1831 	typedef enum {
1832 		//changes track type to LHV1/LHE1: no base nor extractors in track, just enhancement layers
1833 		GF_ISOM_LEHVC_ONLY = 0,
1834 		//changes track type to HVC2/HEV2: base and extractors/enh. in track
1835 		GF_ISOM_LEHVC_WITH_BASE,
1836 		//changes track type to HVC1/HEV1 with additionnal cfg: base and enh. in track no extractors
1837 		GF_ISOM_LEHVC_WITH_BASE_BACKWARD,
1838 	} GF_ISOMLHEVCTrackType;
1839 	GF_Err gf_isom_lhvc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg, GF_ISOMLHEVCTrackType track_type);
1840 
1841 #endif /*GPAC_DISABLE_ISOM_WRITE*/
1842 
1843 
1844 	/*
1845 	3GP timed text handling
1846 
1847 	NOTE: currently only writing API is developped, the reading one is not used in MPEG-4 since
1848 	MPEG-4 maps 3GP timed text to MPEG-4 Streaming Text (part 17)
1849 	*/
1850 
1851 	/*set streamihng text reading mode: if do_convert is set, all text samples will be retrieved as TTUs
1852 	and ESD will be emulated for text tracks.*/
1853 	GF_Err gf_isom_text_set_streaming_mode(GF_ISOFile *the_file, Bool do_convert);
1854 
1855 
1856 #ifndef GPAC_DISABLE_ISOM_DUMP
1857 	/*exports text track to given format
1858 	@dump_type: 0 for TTXT, 1 for srt, 2 for SVG
1859 	*/
1860 	typedef enum {
1861 		GF_TEXTDUMPTYPE_TTXT = 0,
1862 		GF_TEXTDUMPTYPE_SRT = 1,
1863 		GF_TEXTDUMPTYPE_SVG = 2,
1864 	} GF_TextDumpType;
1865 	GF_Err gf_isom_text_dump(GF_ISOFile *the_file, u32 track, FILE *dump, GF_TextDumpType dump_type);
1866 #endif
1867 
1868 	/*returns encoded TX3G box (text sample description for 3GPP text streams) as needed by RTP or other standards:
1869 	@sidx: 1-based stream description index
1870 	@sidx_offset:
1871 	if 0, the sidx will NOT be written before the encoded TX3G
1872 	if not 0, the sidx will be written before the encoded TX3G, with the given offset. Offset sshould be at
1873 	least 128 for most commmon usage of TX3G (RTP, MPEG-4 timed text, etc)
1874 
1875 	*/
1876 	GF_Err gf_isom_text_get_encoded_tx3g(GF_ISOFile *file, u32 track, u32 sidx, u32 sidx_offset, char **tx3g, u32 *tx3g_size);
1877 
1878 	/*checks if this text description is already inserted
1879 	@outDescIdx: set to 0 if not found, or descIndex
1880 	@same_style, @same_box: indicates if default styles and box are used
1881 	*/
1882 	GF_Err gf_isom_text_has_similar_description(GF_ISOFile *the_file, u32 trackNumber, GF_TextSampleDescriptor *desc, u32 *outDescIdx, Bool *same_box, Bool *same_styles);
1883 
1884 	/*text sample formatting*/
1885 	typedef struct _3gpp_text_sample GF_TextSample;
1886 	/*creates text sample handle*/
1887 	GF_TextSample *gf_isom_new_text_sample();
1888 	/*destroy text sample handle*/
1889 	void gf_isom_delete_text_sample(GF_TextSample *tx_samp);
1890 
1891 	/*generic subtitle sample formatting*/
1892 	typedef struct _generic_subtitle_sample GF_GenericSubtitleSample;
1893 	/*creates generic subtitle sample handle*/
1894 	GF_GenericSubtitleSample *gf_isom_new_generic_subtitle_sample();
1895 	/*destroy generic subtitle sample handle*/
1896 	void gf_isom_delete_generic_subtitle_sample(GF_GenericSubtitleSample *generic_subtitle_samp);
1897 
1898 
1899 	GF_Err gf_isom_stxt_get_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const char **mime, const char **encoding, const char **config);
1900 	GF_Err gf_isom_new_stxt_description(GF_ISOFile *movie, u32 trackNumber, u32 type, const char *mime, const char *encoding, const char *config, u32 *outDescriptionIndex);
1901 	GF_Err gf_isom_update_stxt_description(GF_ISOFile *movie, u32 trackNumber, const char *encoding, const char *config, u32 DescriptionIndex);
1902 
1903 	GF_Err gf_isom_xml_subtitle_get_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex,
1904 		const char **xmlnamespace, const char **xml_schema_loc, const char **mimes);
1905 	GF_Err gf_isom_new_xml_subtitle_description(GF_ISOFile  *movie, u32 trackNumber,
1906 		const char *xmlnamespace, const char *xml_schema_loc, const char *auxiliary_mimes,
1907 		u32 *outDescriptionIndex);
1908 	GF_Err gf_isom_update_xml_subtitle_description(GF_ISOFile *movie, u32 trackNumber,
1909 		u32 descriptionIndex, GF_GenericSubtitleSampleDescriptor *desc);
1910 
1911 
1912 
1913 	typedef enum
1914 	{
1915 		GF_ISOM_TEXT_FLAGS_OVERWRITE = 0,
1916 		GF_ISOM_TEXT_FLAGS_TOGGLE,
1917 		GF_ISOM_TEXT_FLAGS_UNTOGGLE,
1918 	} GF_TextFlagsMode;
1919 	//sets text display flags according to given mode. If SampleDescriptionIndex is 0, sets the flags for all text descriptions.
1920 	GF_Err gf_isom_text_set_display_flags(GF_ISOFile *file, u32 track, u32 SampleDescriptionIndex, u32 flags, GF_TextFlagsMode op_type);
1921 
1922 #ifndef GPAC_DISABLE_ISOM_WRITE
1923 
1924 	/*Create a new TextSampleDescription in the file.
1925 	The URL and URN are used to describe external media, this will create a data reference for the media
1926 	GF_TextSampleDescriptor is defined in mpeg4_odf.h
1927 	*/
1928 	GF_Err gf_isom_new_text_description(GF_ISOFile *the_file, u32 trackNumber, GF_TextSampleDescriptor *desc, char *URLname, char *URNname, u32 *outDescriptionIndex);
1929 	/*change the text sample description*/
1930 	GF_Err gf_isom_update_text_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_TextSampleDescriptor *desc);
1931 
1932 	/*reset text sample content*/
1933 	GF_Err gf_isom_text_reset(GF_TextSample * tx_samp);
1934 	/*reset text sample styles but keep text*/
1935 	GF_Err gf_isom_text_reset_styles(GF_TextSample * samp);
1936 
1937 	/*sets UTF16 marker for text data. This MUST be called on an empty sample. If text data added later
1938 	on (cf below) is not formatted as UTF16 data(2 bytes char) the resulting text sample won't be compliant,
1939 	but this library WON'T WARN*/
1940 	GF_Err gf_isom_text_set_utf16_marker(GF_TextSample * samp);
1941 	/*append text to sample - text_len is the number of bytes to be written from text_data. This allows
1942 	handling UTF8 and UTF16 strings in a transparent manner*/
1943 	GF_Err gf_isom_text_add_text(GF_TextSample * tx_samp, char *text_data, u32 text_len);
1944 	/*append style modifyer to sample*/
1945 	GF_Err gf_isom_text_add_style(GF_TextSample * tx_samp, GF_StyleRecord *rec);
1946 	/*appends highlight modifier for the sample
1947 	@start_char: first char highlighted,
1948 	@end_char: first char not highlighted*/
1949 	GF_Err gf_isom_text_add_highlight(GF_TextSample * samp, u16 start_char, u16 end_char);
1950 	/*sets highlight color for the whole sample*/
1951 	GF_Err gf_isom_text_set_highlight_color(GF_TextSample * samp, u8 r, u8 g, u8 b, u8 a);
1952 	GF_Err gf_isom_text_set_highlight_color_argb(GF_TextSample * samp, u32 argb);
1953 	/*appends a new karaoke sequence in the sample
1954 	@start_time: karaoke start time expressed in text stream timescale, but relative to the sample media time
1955 	*/
1956 	GF_Err gf_isom_text_add_karaoke(GF_TextSample * samp, u32 start_time);
1957 	/*appends a new segment in the current karaoke sequence - you must build sequences in order to be compliant
1958 	@end_time: segment end time expressed in text stream timescale, but relative to the sample media time
1959 	@start_char: first char highlighted,
1960 	@end_char: first char not highlighted
1961 	*/
1962 	GF_Err gf_isom_text_set_karaoke_segment(GF_TextSample * samp, u32 end_time, u16 start_char, u16 end_char);
1963 	/*sets scroll delay for the whole sample (scrolling is enabled through GF_TextSampleDescriptor.DisplayFlags)
1964 	@scroll_delay: delay for scrolling expressed in text stream timescale
1965 	*/
1966 	GF_Err gf_isom_text_set_scroll_delay(GF_TextSample * samp, u32 scroll_delay);
1967 	/*appends hyperlinking for the sample
1968 	@URL: ASCII url
1969 	@altString: ASCII hint (tooltip, ...) for end user
1970 	@start_char: first char hyperlinked,
1971 	@end_char: first char not hyperlinked
1972 	*/
1973 	GF_Err gf_isom_text_add_hyperlink(GF_TextSample * samp, char *URL, char *altString, u16 start_char, u16 end_char);
1974 	/*sets current text box (display pos&size within the text track window) for the sample*/
1975 	GF_Err gf_isom_text_set_box(GF_TextSample * samp, s16 top, s16 left, s16 bottom, s16 right);
1976 	/*appends blinking for the sample
1977 	@start_char: first char blinking,
1978 	@end_char: first char not blinking
1979 	*/
1980 	GF_Err gf_isom_text_add_blink(GF_TextSample * samp, u16 start_char, u16 end_char);
1981 	/*sets wrap flag for the sample - currently only 0 (no wrap) and 1 ("soft wrap") are allowed in 3GP*/
1982 	GF_Err gf_isom_text_set_wrap(GF_TextSample * samp, u8 wrap_flags);
1983 
1984 	/*formats sample as a regular GF_ISOSample. The resulting sample will always be marked as random access
1985 	text sample content is kept untouched*/
1986 	GF_ISOSample *gf_isom_text_to_sample(GF_TextSample * tx_samp);
1987 
1988 
1989 
1990 	GF_GenericSubtitleSample *gf_isom_new_xml_subtitle_sample();
1991 	void gf_isom_delete_xml_subtitle_sample(GF_GenericSubtitleSample * samp);
1992 	GF_Err gf_isom_xml_subtitle_reset(GF_GenericSubtitleSample *samp);
1993 	GF_ISOSample *gf_isom_xml_subtitle_to_sample(GF_GenericSubtitleSample * tx_samp);
1994 	GF_Err gf_isom_xml_subtitle_sample_add_text(GF_GenericSubtitleSample *samp, char *text_data, u32 text_len);
1995 
1996 #endif	/*GPAC_DISABLE_ISOM_WRITE*/
1997 
1998 	/*****************************************************
1999 	ISMACryp Samples
2000 	*****************************************************/
2001 	/*flags for GF_ISMASample*/
2002 	enum
2003 	{
2004 		/*signals the stream the sample belongs to uses selective encryption*/
2005 		GF_ISOM_ISMA_USE_SEL_ENC = 1,
2006 		/*signals the sample is encrypted*/
2007 		GF_ISOM_ISMA_IS_ENCRYPTED = 2,
2008 	};
2009 
2010 	typedef struct
2011 	{
2012 		/*IV in ISMACryp is Byte Stream Offset*/
2013 		u64 IV;
2014 		u8 IV_length;/*repeated from sampleDesc for convenience*/
2015 		u8 *key_indicator;
2016 		u8 KI_length;/*repeated from sampleDesc for convenience*/
2017 		u32 dataLength;
2018 		char *data;
2019 		u32 flags;
2020 	} GF_ISMASample;
2021 	/**
2022 	* creates a new empty ISMA sample
2023 	*/
2024 	GF_ISMASample *gf_isom_ismacryp_new_sample();
2025 
2026 	/*delete an ISMA sample. NOTE:the buffers content will be destroyed by default.
2027 	if you wish to keep the buffer, set dataLength to 0 in the sample before deleting it*/
2028 	void gf_isom_ismacryp_delete_sample(GF_ISMASample *samp);
2029 
2030 	/*decodes ISMACryp sample based on all info in ISMACryp sample description*/
2031 	GF_ISMASample *gf_isom_ismacryp_sample_from_data(char *data, u32 dataLength, Bool use_selective_encryption, u8 KI_length, u8 IV_length);
2032 	/*rewrites samp content from s content*/
2033 	GF_Err gf_isom_ismacryp_sample_to_sample(GF_ISMASample *s, GF_ISOSample *dest);
2034 
2035 	/*decodes ISMACryp sample based on sample and its descrition index - returns NULL if not an ISMA sample
2036 	Note: input sample is NOT destroyed*/
2037 	GF_ISMASample *gf_isom_get_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, GF_ISOSample *samp, u32 sampleDescriptionIndex);
2038 
2039 	/*returns whether the given media is a protected one or not - return scheme protection 4CC*/
2040 	u32 gf_isom_is_media_encrypted(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2041 
2042 	/*returns whether the given media is a protected ISMACryp one or not*/
2043 	Bool gf_isom_is_ismacryp_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2044 
2045 	/*returns whether the given media is a protected ISMACryp one or not*/
2046 	Bool gf_isom_is_omadrm_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2047 
2048 	GF_Err gf_isom_get_omadrm_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat,
2049 		u32 *outSchemeType, u32 *outSchemeVersion,
2050 		const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength);
2051 	/*retrieves ISMACryp info for the given track & SDI - all output parameters are optional - URIs SHALL NOT BE MODIFIED BY USER
2052 	@outOriginalFormat: retrieves orginal protected media format - usually GF_ISOM_SUBTYPE_MPEG4
2053 	@outSchemeType: retrieves 4CC of protection scheme (GF_ISOM_ISMACRYP_SCHEME = iAEC in ISMACryp 1.0)
2054 	outSchemeVersion: retrieves version of protection scheme (1 in ISMACryp 1.0)
2055 	outSchemeURI: retrieves URI location of scheme
2056 	outKMS_URI: retrieves URI location of key management system - only valid with ISMACryp 1.0
2057 	outSelectiveEncryption: specifies whether sample-based encryption is used in media - only valid with ISMACryp 1.0
2058 	outIVLength: specifies length of Initial Vector - only valid with ISMACryp 1.0
2059 	outKeyIndicationLength: specifies length of key indicator - only valid with ISMACryp 1.0
2060 
2061 	outSelectiveEncryption, outIVLength and outKeyIndicationLength are usually not needed to decode an
2062 	ISMA sample when using gf_isom_get_ismacryp_sample fct above
2063 	*/
2064 	GF_Err gf_isom_get_ismacryp_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, u32 *outSchemeType, u32 *outSchemeVersion, const char **outSchemeURI, const char **outKMS_URI, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength);
2065 
2066 	/*returns original format type of a protected media file*/
2067 	GF_Err gf_isom_get_original_format_type(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat);
2068 
2069 	typedef struct
2070 	{
2071 		u16 bytes_clear_data;
2072 		u32 bytes_encrypted_data;
2073 	} GF_CENCSubSampleEntry;
2074 
2075 	typedef struct __cenc_sample_aux_info
2076 	{
2077 		u8 IV_size; //0, 8 or 16; it MUST NOT be written to file
2078 		bin128 IV; /*can be 0, 64 or 128 bits - if 64, bytes 0-7 are used and 8-15 are 0-padded*/
2079 		u16 subsample_count;
2080 		GF_CENCSubSampleEntry *subsamples;
2081 	} GF_CENCSampleAuxInfo;
2082 
2083 #ifndef GPAC_DISABLE_ISOM_WRITE
2084 	/*removes protection info (does not perform decryption :), for ISMA, OMA and CENC*/
2085 	GF_Err gf_isom_remove_track_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
2086 
2087 	/*creates ISMACryp protection info (does not perform encryption :)*/
2088 	GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type,
2089 		u32 scheme_version, char *scheme_uri, char *kms_URI,
2090 		Bool selective_encryption, u32 KI_length, u32 IV_length);
2091 
2092 	/*change scheme URI and/or KMS URI for crypted files. Other params cannot be changed once the media is crypted
2093 	@scheme_uri: new scheme URI, or NULL to keep previous
2094 	@kms_uri: new KMS URI, or NULL to keep previous
2095 	*/
2096 	GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, char *scheme_uri, char *kms_uri);
2097 
2098 
2099 	GF_Err gf_isom_set_oma_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index,
2100 		char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len,
2101 		Bool selective_encryption, u32 KI_length, u32 IV_length);
2102 
2103 
2104 	GF_Err gf_isom_cenc_allocate_storage(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u32 AlgorithmID, u8 IV_size, bin128 KID);
2105 	GF_Err gf_isom_track_cenc_add_sample_info(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u8 IV_size, char *buf, u32 len);
2106 
2107 
2108 
2109 	GF_Err gf_isom_set_cenc_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type,
2110 		u32 scheme_version, u32 default_IsEncrypted, u8 default_IV_size, bin128 default_KID,
2111 		u8 default_crypt_byte_block, u8 default_skip_byte_block,
2112 		u8 default_constant_IV_size, bin128 default_constant_IV);
2113 
2114 	GF_Err gf_cenc_set_pssh(GF_ISOFile *mp4, bin128 systemID, u32 version, u32 KID_count, bin128 *KID, char *data, u32 len);
2115 
2116 	GF_Err gf_isom_remove_cenc_saiz(GF_ISOFile *the_file, u32 trackNumber);
2117 	GF_Err gf_isom_remove_cenc_saio(GF_ISOFile *the_file, u32 trackNumber);
2118 	GF_Err gf_isom_remove_samp_enc_box(GF_ISOFile *the_file, u32 trackNumber);
2119 	GF_Err gf_isom_remove_samp_group_box(GF_ISOFile *the_file, u32 trackNumber);
2120 	GF_Err gf_isom_remove_pssh_box(GF_ISOFile *the_file);
2121 
2122 	Bool gf_isom_is_adobe_protection_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2123 	GF_Err gf_isom_get_adobe_protection_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, u32 *outSchemeType, u32 *outSchemeVersion);
2124 	GF_Err gf_isom_set_adobe_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, u32 scheme_version, Bool is_selective_enc, char *metadata, u32 len);
2125 
2126 	void gf_isom_ipmpx_remove_tool_list(GF_ISOFile *the_file);
2127 
2128 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2129 
2130 	Bool gf_isom_is_cenc_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2131 	GF_Err gf_isom_get_cenc_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, u32 *outSchemeType, u32 *outSchemeVersion, u32 *outIVLength);
2132 
2133 	void gf_isom_cenc_samp_aux_info_del(GF_CENCSampleAuxInfo *samp_aux_info);
2134 
2135 	/*boxType is type of box which contains the sample auxiliary information. Now we have two type: GF_ISOM_BOX_UUID_PSEC and GF_ISOM_BOX_TYPE_SENC*/
2136 	GF_Err gf_isom_cenc_get_sample_aux_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, GF_CENCSampleAuxInfo **sai, u32 *container_type);
2137 
2138 	void gf_isom_cenc_get_default_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID);
2139 
2140 	Bool gf_isom_cenc_is_pattern_mode(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex);
2141 	void gf_isom_cenc_get_default_pattern_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u8 *default_crypt_byte_block, u8 *default_skip_byte_block);
2142 
2143 	u32 gf_isom_get_pssh_count(GF_ISOFile *file);
2144 	/*index is 1-based, all pointers shall not be free*/
2145 	GF_Err gf_isom_get_pssh_info(GF_ISOFile *file, u32 pssh_index, bin128 SystemID, u32 *KID_count, const bin128 **KIDs, const u8 **private_data, u32 *private_data_size);
2146 
2147 
2148 #ifndef GPAC_DISABLE_ISOM_DUMP
2149 	/*xml dumpers*/
2150 	GF_Err gf_isom_dump_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, FILE * trace);
2151 	GF_Err gf_isom_dump_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, u32 SampleNum, FILE *trace);
2152 #endif
2153 
2154 
2155 	/********************************************************************
2156 	GENERAL META API FUNCTIONS
2157 
2158 	Meta can be stored at several places in the file layout:
2159 	* root level (like moov, ftyp and co)
2160 	* moov level
2161 	* track level
2162 	Meta API uses the following parameters for all functions:
2163 
2164 	gf_isom_*_meta_*(GF_ISOFile *file, Bool root_meta, u32 track_num, ....) with:
2165 	@root_meta: if set, accesses file root meta
2166 	@track_num: if root_meta not set, specifies whether the target meta is at the
2167 	moov level (track_num=0) or at the track level.
2168 
2169 	********************************************************************/
2170 
2171 	/*gets meta type. Returned value: 0 if no meta found, or four char code of meta (eg, "mp21", "smil", ...)*/
2172 	u32 gf_isom_get_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num);
2173 
2174 	/*indicates if the meta has an XML container (note that XML data can also be included as items).
2175 	return value: 0 (no XML or error), 1 (XML text), 2 (BinaryXML, eg BiM) */
2176 	u32 gf_isom_has_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num);
2177 
2178 	/*extracts XML (if any) from given meta
2179 	@outName: output file path and location for writing
2180 	@is_binary: indicates if XML is Bim or regular XML
2181 	*/
2182 	GF_Err gf_isom_extract_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *outName, Bool *is_binary);
2183 
2184 	/*returns number of items described in this meta*/
2185 	u32 gf_isom_get_meta_item_count(GF_ISOFile *file, Bool root_meta, u32 track_num);
2186 
2187 	/*gets item info for the given item
2188 	@item_num: 1-based index of item to query
2189 	@itemID (optional): item ID in file
2190 	@is_self_reference: item is the file itself
2191 	@item_name (optional): item name
2192 	@item_mime_type (optional): item mime type
2193 	@item_encoding (optional): item content encoding type
2194 	@item_url, @item_urn (optional): url/urn of external resource containing this item data if any.
2195 	When item is fully contained in file, these are set to NULL
2196 
2197 	*/
2198 	GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num,
2199 		u32 *itemID, u32 *protection_idx, Bool *is_self_reference,
2200 		const char **item_name, const char **item_mime_type, const char **item_encoding,
2201 		const char **item_url, const char **item_urn);
2202 
2203 
2204 	/*gets item idx from item ID*/
2205 	u32 gf_isom_get_meta_item_by_id(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_ID);
2206 
2207 	/*extracts item from given meta
2208 	@item_num: 1-based index of item to query
2209 	@dump_file_name: if NULL, use item name for dumping
2210 	*/
2211 	GF_Err gf_isom_extract_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num, const char *dump_file_name);
2212 
2213 	/*extracts item from given meta in memory
2214 	@item_num: 1-based index of item to query
2215 	*/
2216 	GF_Err gf_isom_extract_meta_item_mem(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id, char **out_data, u32 *out_size, const char **mime_type);
2217 
2218 	/*retirves primary item ID, 0 if none found (primary can also be stored through meta XML)*/
2219 	u32 gf_isom_get_meta_primary_item_id(GF_ISOFile *file, Bool root_meta, u32 track_num);
2220 
2221 #ifndef GPAC_DISABLE_ISOM_WRITE
2222 
2223 	/*sets meta type (four char int, eg "mp21", ...
2224 	Creates a meta box if none found
2225 	if metaType is 0, REMOVES META
2226 	*/
2227 	GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 metaType);
2228 
2229 	/*removes meta XML info if any*/
2230 	GF_Err gf_isom_remove_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num);
2231 
2232 	/*set meta XML data from file - erase any previously (Binary)XML info*/
2233 	GF_Err gf_isom_set_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *XMLFileName, Bool IsBinaryXML);
2234 	/*set meta XML data from memory - erase any previously (Binary)XML info*/
2235 	GF_Err gf_isom_set_meta_xml_memory(GF_ISOFile *file, Bool root_meta, u32 track_num, unsigned char *data, u32 data_size, Bool IsBinaryXML);
2236 
2237 	typedef enum {
2238 		TILE_ITEM_NONE = 0,
2239 		TILE_ITEM_ALL_NO_BASE,
2240 		TILE_ITEM_ALL_BASE,
2241 		TILE_ITEM_ALL_GRID,
2242 		TILE_ITEM_SINGLE
2243 	} GF_TileItemMode;
2244 
2245 	typedef struct
2246 	{
2247 		u32 width, height;
2248 		u32 hSpacing, vSpacing;
2249 		u32 hOffset, vOffset;
2250 		u32 angle;
2251 		Bool hidden;
2252 		void *config;
2253 		GF_TileItemMode tile_mode;
2254 		u32 single_tile_number;
2255 	} GF_ImageItemProperties;
2256 
2257 	GF_Err gf_isom_meta_get_next_item_id(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 *item_id);
2258 
2259 	GF_Err gf_isom_add_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, Bool self_reference, char *resource_path, const char *item_name, u32 item_id, u32 item_type, const char *mime_type, const char *content_encoding, const char *URL, const char *URN, GF_ImageItemProperties *imgprop);
2260 	/*same as above excepts take the item directly in memory*/
2261 	GF_Err gf_isom_add_meta_item_memory(GF_ISOFile *file, Bool root_meta, u32 track_num, const char *item_name, u32 item_id, u32 item_type, const char *mime_type, const char *content_encoding, GF_ImageItemProperties *image_props, char *data, u32 data_len, GF_List *item_extent_refs);
2262 
2263 	GF_Err gf_isom_iff_create_image_item_from_track(GF_ISOFile *movie, Bool root_meta, u32 meta_track_number, u32 track, const char *item_name, u32 item_id, GF_ImageItemProperties *image_props, GF_List *item_extent_refs);
2264 
2265 	/*removes item from meta*/
2266 	GF_Err gf_isom_remove_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num);
2267 
2268 	/*sets the given item as the primary one. You SHALL NOT use this if the meta has a valid XML data*/
2269 	GF_Err gf_isom_set_meta_primary_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num);
2270 
2271 	GF_Err gf_isom_meta_add_item_ref(GF_ISOFile *file, Bool root_meta, u32 trackID, u32 from_id, u32 to_id, u32 type, u64 *ref_index);
2272 
2273 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2274 
2275 
2276 	/********************************************************************
2277 	Timed Meta-Data extensions
2278 	********************************************************************/
2279 
2280 	GF_Err gf_isom_get_xml_metadata_description(GF_ISOFile *file, u32 track, u32 sampleDescription, const char **_namespace, const char **schema_loc, const char **content_encoding);
2281 
2282 #ifndef GPAC_DISABLE_ISOM_WRITE
2283 	/*create a new timed metat data sample description for this track*/
2284 	GF_Err gf_isom_new_xml_metadata_description(GF_ISOFile *movie, u32 trackNumber, const char *_namespace, const char *schema_loc, const char *content_encoding, u32 *outDescriptionIndex);
2285 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2286 
2287 
2288 	/********************************************************************
2289 	iTunes info tags
2290 	********************************************************************/
2291 	enum
2292 	{
2293 		/*probe is only used to check if iTunes info are present*/
2294 		GF_ISOM_ITUNE_PROBE = 0,
2295 		/*probe is only used to remove all tags*/
2296 		GF_ISOM_ITUNE_ALL = 1,
2297 		GF_ISOM_ITUNE_ALBUM = GF_4CC(0xA9, 'a', 'l', 'b'),
2298 		GF_ISOM_ITUNE_ARTIST = GF_4CC(0xA9, 'A', 'R', 'T'),
2299 		GF_ISOM_ITUNE_COMMENT = GF_4CC(0xA9, 'c', 'm', 't'),
2300 		GF_ISOM_ITUNE_COMPILATION = GF_4CC('c', 'p', 'i', 'l'),
2301 		GF_ISOM_ITUNE_COMPOSER = GF_4CC(0xA9, 'c', 'o', 'm'),
2302 		GF_ISOM_ITUNE_COVER_ART = GF_4CC('c', 'o', 'v', 'r'),
2303 		GF_ISOM_ITUNE_CREATED = GF_4CC(0xA9, 'd', 'a', 'y'),
2304 		GF_ISOM_ITUNE_DISK = GF_4CC('d', 'i', 's', 'k'),
2305 		GF_ISOM_ITUNE_TOOL = GF_4CC(0xA9, 't', 'o', 'o'),
2306 		GF_ISOM_ITUNE_GENRE = GF_4CC('g', 'n', 'r', 'e'),
2307 		GF_ISOM_ITUNE_GROUP = GF_4CC(0xA9, 'g', 'r', 'p'),
2308 		GF_ISOM_ITUNE_ITUNES_DATA = GF_4CC('-', '-', '-', '-'),
2309 		GF_ISOM_ITUNE_NAME = GF_4CC(0xA9, 'n', 'a', 'm'),
2310 		GF_ISOM_ITUNE_TEMPO = GF_4CC('t', 'm', 'p', 'o'),
2311 		GF_ISOM_ITUNE_TRACK = GF_4CC(0xA9, 't', 'r', 'k'),
2312 		GF_ISOM_ITUNE_TRACKNUMBER = GF_4CC('t', 'r', 'k', 'n'),
2313 		GF_ISOM_ITUNE_WRITER = GF_4CC(0xA9, 'w', 'r', 't'),
2314 		GF_ISOM_ITUNE_ENCODER = GF_4CC(0xA9, 'e', 'n', 'c'),
2315 		GF_ISOM_ITUNE_ALBUM_ARTIST = GF_4CC('a', 'A', 'R', 'T'),
2316 		GF_ISOM_ITUNE_GAPLESS = GF_4CC('p', 'g', 'a', 'p'),
2317 	};
2318 	/*get the given tag info.
2319 	!! 'genre' may be coded by ID, the libisomedia doesn't translate the ID. In such a case, the result data is set to NULL
2320 	and the data_len to the genre ID
2321 	returns GF_URL_ERROR if no tag is present in the file
2322 	*/
2323 	GF_Err gf_isom_apple_get_tag(GF_ISOFile *mov, u32 tag, const char **data, u32 *data_len);
2324 #ifndef GPAC_DISABLE_ISOM_WRITE
2325 	/*set the given tag info. If data and data_len are 0, removes the given tag
2326 	For 'genre', data may be NULL in which case the genre ID taken from the data_len parameter
2327 	*/
2328 	GF_Err gf_isom_apple_set_tag(GF_ISOFile *mov, u32 tag, const char *data, u32 data_len);
2329 
2330 	/*sets compatibility tag on AVC tracks (needed by iPod to play files... hurray for standards)*/
2331 	GF_Err gf_isom_set_ipod_compatible(GF_ISOFile *the_file, u32 trackNumber);
2332 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2333 
2334 
2335 	/*3GPP Alternate Group API - (c) 2007 Telecom ParisTech*/
2336 
2337 	/*gets the number of switching groups declared in this track if any:
2338 	trackNumber: track number
2339 	alternateGroupID: alternate group id of track if speciifed, 0 otherwise
2340 	nb_groups: number of switching groups defined for this track
2341 	*/
2342 	GF_Err gf_isom_get_track_switch_group_count(GF_ISOFile *movie, u32 trackNumber, u32 *alternateGroupID, u32 *nb_groups);
2343 
2344 	/*returns the list of criteria (expressed as 4CC IDs, cf 3GPP TS 26.244)
2345 	trackNumber: track number
2346 	group_index: 1-based index of the group to inspect
2347 	switchGroupID: ID of the switch group if any, 0 otherwise (alternate-only group)
2348 	criteriaListSize: number of criteria items in returned list
2349 	*/
2350 	const u32 *gf_isom_get_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u32 group_index, u32 *switchGroupID, u32 *criteriaListSize);
2351 
2352 #ifndef GPAC_DISABLE_ISOM_WRITE
2353 	/*sets a new (switch) group for this track
2354 	trackNumber: track
2355 	trackRefGroup: number of a track belonging to the same alternate group. If 0, a new alternate group will be created for this track
2356 	is_switch_group: if set, indicates that a switch group identifier shall be assigned to the created group. Otherwise, the criteria list is associated with the entire alternate group
2357 	switchGroupID: SHALL NOT BE NULL
2358 	input: specifies the desired switchGroupID to use. If value is 0, next available switchGroupID in file is used.
2359 	output: indicates the switchGroupID used.
2360 	criteriaList, criteriaListCount: criteria list and size. Criterias are expressed as 4CC IDs, cf 3GPP TS 26.244
2361 	*/
2362 	GF_Err gf_isom_set_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u32 trackRefGroup, Bool is_switch_group, u32 *switchGroupID, u32 *criteriaList, u32 criteriaListCount);
2363 
2364 	/*resets track switch group information for the track or for the entire alternate group this track belongs to if reset_all_group is set*/
2365 	GF_Err gf_isom_reset_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, Bool reset_all_group);
2366 
2367 	/*resets ALL track switch group information in the entire movie*/
2368 	GF_Err gf_isom_reset_switch_parameters(GF_ISOFile *movie);
2369 
2370 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2371 
2372 
2373 	typedef struct
2374 	{
2375 		u8 profile;
2376 		u8 level;
2377 		u8 pathComponents;
2378 		Bool fullRequestHost;
2379 		Bool streamType;
2380 		u8 containsRedundant;
2381 		const char *textEncoding;
2382 		const char *contentEncoding;
2383 		const char *content_script_types;
2384 		const char *mime_type;
2385 		const char *xml_schema_loc;
2386 	} GF_DIMSDescription;
2387 
2388 	GF_Err gf_isom_get_dims_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_DIMSDescription *desc);
2389 #ifndef GPAC_DISABLE_ISOM_WRITE
2390 	GF_Err gf_isom_new_dims_description(GF_ISOFile *movie, u32 trackNumber, GF_DIMSDescription *desc, char *URLname, char *URNname, u32 *outDescriptionIndex);
2391 	GF_Err gf_isom_update_dims_description(GF_ISOFile *movie, u32 trackNumber, GF_DIMSDescription *desc, char *URLname, char *URNname, u32 DescriptionIndex);
2392 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2393 
2394 
2395 
2396 	struct __ec3_stream
2397 	{
2398 		u8 fscod;
2399 		u8 bsid;
2400 		u8 bsmod;
2401 		u8 acmod;
2402 		u8 lfon;
2403 		/*only for EC3*/
2404 		u8 nb_dep_sub;
2405 		u8 chan_loc;
2406 	};
2407 
2408 	/*AC3 config record*/
2409 	typedef struct
2410 	{
2411 		u8 is_ec3;
2412 		u8 nb_streams; //1 for AC3, max 8 for EC3
2413 		u16 brcode; //if AC3 is bitrate code, otherwise cumulated datarate of EC3 streams
2414 		struct __ec3_stream streams[8];
2415 	} GF_AC3Config;
2416 
2417 	GF_AC3Config *gf_isom_ac3_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);
2418 
2419 #ifndef GPAC_DISABLE_ISOM_WRITE
2420 	GF_Err gf_isom_ac3_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AC3Config *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex);
2421 #endif /*GPAC_DISABLE_ISOM_WRITE*/
2422 
2423 
2424 
2425 	/*returns the number of subsamples in the given sample for the given flags*/
2426 	u32 gf_isom_sample_has_subsamples(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 flags);
2427 	GF_Err gf_isom_sample_get_subsample(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 flags, u32 subSampleNumber, u32 *size, u8 *priority, u32 *reserved, Bool *discardable);
2428 #ifndef GPAC_DISABLE_ISOM_WRITE
2429 	/*adds subsample information to a given sample. Subsample information shall be added in increasing order of sampleNumbers, insertion of information is not supported.
2430 	Note that you may add subsample information for samples not yet added to the file
2431 	specifying 0 as subSampleSize will remove the last subsample information if any*/
2432 	GF_Err gf_isom_add_subsample(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 flags, u32 subSampleSize, u8 priority, u32 reserved, Bool discardable);
2433 #endif
2434 	/*add subsample information for the latest sample added to the current track fragment*/
2435 	GF_Err gf_isom_fragment_add_subsample(GF_ISOFile *movie, u32 TrackID, u32 flags, u32 subSampleSize, u8 priority, u32 reserved, Bool discardable);
2436 
2437 	/*copy over the subsample and sampleToGroup information of the given sample from the source track/file to the last sample added to the current track fragment of the destination file*/
2438 	GF_Err gf_isom_fragment_copy_subsample(GF_ISOFile *dest, u32 TrackID, GF_ISOFile *orig, u32 track, u32 sampleNumber, Bool sgpd_in_traf);
2439 
2440 	/*gets the number of the next moof to be produced*/
2441 	u32 gf_isom_get_next_moof_number(GF_ISOFile *movie);
2442 	/*Sets the number of the next moof to be produced*/
2443 	void gf_isom_set_next_moof_number(GF_ISOFile *movie, u32 value);
2444 
2445 
2446 	/*returns 'rap ' and 'roll' group info for the given sample*/
2447 	GF_Err gf_isom_get_sample_rap_roll_info(GF_ISOFile *the_file, u32 trackNumber, u32 sample_number, Bool *is_rap, Bool *has_roll, s32 *roll_distance);
2448 
2449 	/*returns opaque data of sample group*/
2450 	Bool gf_isom_get_sample_group_info(GF_ISOFile *the_file, u32 trackNumber, u32 sample_description_index, u32 grouping_type, u32 *default_index, const char **data, u32 *size);
2451 
2452 	/*returns tile info */
2453 	Bool gf_isom_get_tile_info(GF_ISOFile *file, u32 trackNumber, u32 sample_description_index, u32 *default_sample_group_index, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h);
2454 
2455 	/*returns true if date/version info droping is enabled */
2456 	Bool gf_isom_drop_date_version_info_enabled(GF_ISOFile *file);
2457 
2458 	/*sample groups information*/
2459 #ifndef GPAC_DISABLE_ISOM_WRITE
2460 	/*sets rap flag for sample_number - this is used by non-IDR RAPs in AVC (also in USAC) were SYNC flag (stss table) cannot be used
2461 	num_leading_sample is the number of samples to after this RAP that have dependences on samples before this RAP and hence should be discarded
2462 	- currently sample group info MUST be added in order (no insertion in the tables)*/
2463 	GF_Err gf_isom_set_sample_rap_group(GF_ISOFile *movie, u32 track, u32 sample_number, u32 num_leading_samples);
2464 	/*sets roll_distance info for sample_number (number of frames before (<0) or after (>0) this sample to have a complete refresh of the decoded data (used by GDR in AVC)
2465 	- currently sample group info MUST be added in order (no insertion in the tables)*/
2466 	GF_Err gf_isom_set_sample_roll_group(GF_ISOFile *movie, u32 track, u32 sample_number, s16 roll_distance);
2467 
2468 	/*set encryption group for a sample_number; see GF_CENCSampleEncryptionGroupEntry for the parameters*/
2469 	GF_Err gf_isom_set_sample_cenc_group(GF_ISOFile *movie, u32 track, u32 sample_number, u8 isEncrypted, u8 IV_size, bin128 KeyID,
2470 		u8 crypt_byte_block, u8 skip_byte_block, u8 constant_IV_size, bin128 constant_IV);
2471 
2472 	GF_Err gf_isom_set_composition_offset_mode(GF_ISOFile *file, u32 track, Bool use_negative_offsets);
2473 
2474 	//adds the given blob as a sample group description of the given grouping type. If default is set, the sample grouping will be marked as default.
2475 	//sampleGroupDescriptionIndex is optional, used to retrieve the index
2476 	GF_Err gf_isom_add_sample_group_info(GF_ISOFile *movie, u32 track, u32 grouping_type, void *data, u32 data_size, Bool is_default, u32 *sampleGroupDescriptionIndex);
2477 
2478 	//remove a sample group description of the give grouping type (if found)
2479 	GF_Err gf_isom_remove_sample_group(GF_ISOFile *movie, u32 track, u32 grouping_type);
2480 
2481 	//tags the sample in the grouping adds the given blob as a sample group description of the given grouping type. If default is set, the sample grouping will be marked as default
2482 	GF_Err gf_isom_add_sample_info(GF_ISOFile *movie, u32 track, u32 sample_number, u32 grouping_type, u32 sampleGroupDescriptionIndex, u32 grouping_type_parameter);
2483 
2484 
2485 	//sets track in group of type group_type and id track_group_id. If do_add is GF_FALSE, track is removed from that group
2486 	GF_Err gf_isom_set_track_group(GF_ISOFile *file, u32 track_number, u32 track_group_id, u32 group_type, Bool do_add);
2487 
2488 #endif
2489 
2490 	GF_Err gf_isom_get_sample_cenc_info(GF_ISOFile *movie, u32 track, u32 sample_number, u32 *IsEncrypted, u8 *IV_size, bin128 *KID,
2491 		u8 *crypt_byte_block, u8 *skip_byte_block, u8 *constant_IV_size, bin128 *constant_IV);
2492 
2493 
2494 #endif /*GPAC_DISABLE_ISOM*/
2495 
2496 	/*! @} */
2497 
2498 
2499 #ifdef __cplusplus
2500 }
2501 #endif
2502 
2503 
2504 #endif	/*_GF_ISOMEDIA_H_*/
2505 
2506 
2507