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 / MPEG-4 Object Descriptor sub-project
9 *
10 *  GPAC is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License as published by
12 *  the Free Software Foundation; either version 2, or (at your option)
13 *  any later version.
14 *
15 *  GPAC is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU Lesser General Public License for more details.
19 *
20 *  You should have received a copy of the GNU Lesser General Public
21 *  License along with this library; see the file COPYING.  If not, write to
22 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 
26 #ifndef _GF_MPEG4_ODF_H_
27 #define _GF_MPEG4_ODF_H_
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 	/*!
34 	*	\file <gpac/mpeg4_odf.h>
35 	*	\brief MPEG-4 Object Descriptor Framework.
36 	*/
37 
38 	/*! \defgroup mpeg4sys_grp MPEG-4 Systems
39 	*	\brief MPEG-4 Systems.
40 	*/
41 
42 	/*!
43 	*	\addtogroup odf_grp MPEG-4 OD
44 	*	\ingroup mpeg4sys_grp
45 	*	\brief MPEG-4 Object Descriptor Framework
46 	*
47 	*This section documents the MPEG-4 OD, OCI and IPMPX functions of the GPAC framework.
48 	*	@{
49 	*/
50 
51 #include <gpac/list.h>
52 #include <gpac/bitstream.h>
53 #include <gpac/sync_layer.h>
54 
55 	/***************************************
56 	Descriptors Tag
57 	***************************************/
58 	enum
59 	{
60 		GF_ODF_OD_TAG = 0x01,
61 		GF_ODF_IOD_TAG = 0x02,
62 		GF_ODF_ESD_TAG = 0x03,
63 		GF_ODF_DCD_TAG = 0x04,
64 		GF_ODF_DSI_TAG = 0x05,
65 		GF_ODF_SLC_TAG = 0x06,
66 		GF_ODF_CI_TAG = 0x07,
67 		GF_ODF_SCI_TAG = 0x08,
68 		GF_ODF_IPI_PTR_TAG = 0x09,
69 		GF_ODF_IPMP_PTR_TAG = 0x0A,
70 		GF_ODF_IPMP_TAG = 0x0B,
71 		GF_ODF_QOS_TAG = 0x0C,
72 		GF_ODF_REG_TAG = 0x0D,
73 
74 		/*FILE FORMAT RESERVED IDs - NEVER CREATE / USE THESE DESCRIPTORS*/
75 		GF_ODF_ESD_INC_TAG = 0x0E,
76 		GF_ODF_ESD_REF_TAG = 0x0F,
77 		GF_ODF_ISOM_IOD_TAG = 0x10,
78 		GF_ODF_ISOM_OD_TAG = 0x11,
79 		GF_ODF_ISOM_IPI_PTR_TAG = 0x12,
80 		/*END FILE FORMAT RESERVED*/
81 
82 		GF_ODF_EXT_PL_TAG = 0x13,
83 		GF_ODF_PL_IDX_TAG = 0x14,
84 
85 		GF_ODF_ISO_BEGIN_TAG = 0x15,
86 		GF_ODF_ISO_END_TAG = 0x3F,
87 
88 		GF_ODF_CC_TAG = 0x40,
89 		GF_ODF_KW_TAG = 0x41,
90 		GF_ODF_RATING_TAG = 0x42,
91 		GF_ODF_LANG_TAG = 0x43,
92 		GF_ODF_SHORT_TEXT_TAG = 0x44,
93 		GF_ODF_TEXT_TAG = 0x45,
94 		GF_ODF_CC_NAME_TAG = 0x46,
95 		GF_ODF_CC_DATE_TAG = 0x47,
96 		GF_ODF_OCI_NAME_TAG = 0x48,
97 		GF_ODF_OCI_DATE_TAG = 0x49,
98 		GF_ODF_SMPTE_TAG = 0x4A,
99 
100 		GF_ODF_SEGMENT_TAG = 0x4B,
101 		GF_ODF_MEDIATIME_TAG = 0x4C,
102 
103 		GF_ODF_IPMP_TL_TAG = 0x60,
104 		GF_ODF_IPMP_TOOL_TAG = 0x61,
105 
106 		GF_ODF_ISO_RES_BEGIN_TAG = 0x62,
107 		GF_ODF_ISO_RES_END_TAG = 0xBF,
108 
109 		GF_ODF_USER_BEGIN_TAG = 0xC0,
110 
111 		/*! internal descriptor for mux input description*/
112 		GF_ODF_MUXINFO_TAG = GF_ODF_USER_BEGIN_TAG,
113 		/*! internal descriptor for bifs config input description*/
114 		GF_ODF_BIFS_CFG_TAG = GF_ODF_USER_BEGIN_TAG + 1,
115 		/*! internal descriptor for UI config input description*/
116 		GF_ODF_UI_CFG_TAG = GF_ODF_USER_BEGIN_TAG + 2,
117 		/*! internal descriptor for TextConfig description*/
118 		GF_ODF_TEXT_CFG_TAG = GF_ODF_USER_BEGIN_TAG + 3,
119 		/*! internal descriptor for Text/TX3G description*/
120 		GF_ODF_TX3G_TAG = GF_ODF_USER_BEGIN_TAG + 4,
121 		/*! internal descriptor for BIFS_anim input description*/
122 		GF_ODF_ELEM_MASK_TAG = GF_ODF_USER_BEGIN_TAG + 5,
123 		/*! internal descriptor for LASeR config input description*/
124 		GF_ODF_LASER_CFG_TAG = GF_ODF_USER_BEGIN_TAG + 6,
125 		/*! internal descriptor for subtitle stream description*/
126 		GF_ODF_GEN_SUB_CFG_TAG = GF_ODF_USER_BEGIN_TAG + 7,
127 
128 		GF_ODF_USER_END_TAG = 0xFE,
129 
130 		GF_ODF_OCI_BEGIN_TAG = 0x40,
131 		GF_ODF_OCI_END_TAG = (GF_ODF_ISO_RES_BEGIN_TAG - 1),
132 
133 		GF_ODF_EXT_BEGIN_TAG = 0x80,
134 		GF_ODF_EXT_END_TAG = 0xFE,
135 
136 
137 		/*descriptor for aucilary video data*/
138 		GF_ODF_AUX_VIDEO_DATA = GF_ODF_EXT_BEGIN_TAG + 1
139 	};
140 
141 
142 	/***************************************
143 	Descriptors
144 	***************************************/
145 
146 #define BASE_DESCRIPTOR \
147 		u8 tag;
148 
149 
150 	/*!	base descriptor used as base type in many function.*/
151 	typedef struct
152 	{
153 		BASE_DESCRIPTOR
154 	} GF_Descriptor;
155 
156 
157 	/*!	default descriptor.
158 	NOTE: The decoderSpecificInfo is used as a default desc with tag 0x05 */
159 	typedef struct
160 	{
161 		BASE_DESCRIPTOR
162 			u32 dataLength;
163 		char *data;
164 	} GF_DefaultDescriptor;
165 
166 	/*! Object Descriptor*/
167 	typedef struct
168 	{
169 		BASE_DESCRIPTOR
170 			GF_List *ipmp_tools;
171 	} GF_IPMP_ToolList;
172 
173 	/*! ObjectDescriptor*/
174 	typedef struct
175 	{
176 		BASE_DESCRIPTOR
177 			u16 objectDescriptorID;
178 		char *URLString;
179 		GF_List *ESDescriptors;
180 		GF_List *OCIDescriptors;
181 		/*includes BOTH IPMP_DescriptorPointer (IPMP & IPMPX) and GF_IPMP_Descriptor (IPMPX only)*/
182 		GF_List *IPMP_Descriptors;
183 		GF_List *extensionDescriptors;
184 		/*MPEG-2 (or other service mux formats) service ID*/
185 		u16 ServiceID;
186 		/*pointer to the service interface (GF_InputService) of the service having declared the object
187 		only used for DASH*/
188 		void *service_ifce;
189 	} GF_ObjectDescriptor;
190 
191 	/*! GF_InitialObjectDescriptor - WARNING: even though the bitstream IOD is not
192 	a bit extension of OD, internally it is a real overclass of OD
193 	we usually typecast IOD to OD when flags are not needed !!!*/
194 	typedef struct
195 	{
196 		BASE_DESCRIPTOR
197 			u16 objectDescriptorID;
198 		char *URLString;
199 		GF_List *ESDescriptors;
200 		GF_List *OCIDescriptors;
201 		/*includes BOTH IPMP_DescriptorPointer (IPMP & IPMPX) and GF_IPMP_Descriptor (IPMPX only)*/
202 		GF_List *IPMP_Descriptors;
203 		GF_List *extensionDescriptors;
204 		/*MPEG-2 (or other service mux formats) service ID*/
205 		u16 ServiceID;
206 		/*pointer to the service interface (GF_InputService) of the service having declared the object
207 		only used for DASH*/
208 		void *service_ifce;
209 
210 		/*IOD extensions*/
211 		u8 inlineProfileFlag;
212 		u8 OD_profileAndLevel;
213 		u8 scene_profileAndLevel;
214 		u8 audio_profileAndLevel;
215 		u8 visual_profileAndLevel;
216 		u8 graphics_profileAndLevel;
217 
218 		GF_IPMP_ToolList *IPMPToolList;
219 	} GF_InitialObjectDescriptor;
220 
221 	/*! File Format Object Descriptor*/
222 	typedef struct
223 	{
224 		BASE_DESCRIPTOR
225 			u16 objectDescriptorID;
226 		char *URLString;
227 		GF_List *ES_ID_RefDescriptors;
228 		GF_List *OCIDescriptors;
229 		GF_List *IPMP_Descriptors;
230 		GF_List *extensionDescriptors;
231 		GF_List *ES_ID_IncDescriptors;
232 	} GF_IsomObjectDescriptor;
233 
234 	/*! File Format Initial Object Descriptor - same remark as IOD*/
235 	typedef struct
236 	{
237 		BASE_DESCRIPTOR
238 			u16 objectDescriptorID;
239 		char *URLString;
240 		GF_List *ES_ID_RefDescriptors;
241 		GF_List *OCIDescriptors;
242 		GF_List *IPMP_Descriptors;
243 		GF_List *extensionDescriptors;
244 		GF_List *ES_ID_IncDescriptors;
245 
246 		u8 inlineProfileFlag;
247 		u8 OD_profileAndLevel;
248 		u8 scene_profileAndLevel;
249 		u8 audio_profileAndLevel;
250 		u8 visual_profileAndLevel;
251 		u8 graphics_profileAndLevel;
252 
253 		GF_IPMP_ToolList *IPMPToolList;
254 	} GF_IsomInitialObjectDescriptor;
255 
256 
257 	/*! File Format ES Descriptor for IOD*/
258 	typedef struct {
259 		BASE_DESCRIPTOR
260 			u32 trackID;
261 	} GF_ES_ID_Inc;
262 
263 	/*! File Format ES Descriptor for OD*/
264 	typedef struct {
265 		BASE_DESCRIPTOR
266 			u16 trackRef;
267 	} GF_ES_ID_Ref;
268 
269 	/*! Decoder config Descriptor*/
270 	typedef struct
271 	{
272 		BASE_DESCRIPTOR
273 			/*coded on 8 bit, but we use 32 bits for internal signaling in GPAC to enable usage of 4CC*/
274 			u32 objectTypeIndication;
275 		u8 streamType;
276 		u8 upstream;
277 		u32 bufferSizeDB;
278 		u32 maxBitrate;
279 		u32 avgBitrate;
280 		GF_DefaultDescriptor *decoderSpecificInfo;
281 
282 		/*placeholder for RVC decoder config if any*/
283 		u16 predefined_rvc_config;
284 		GF_DefaultDescriptor *rvc_config;
285 
286 		GF_List *profileLevelIndicationIndexDescriptor;
287 		/*pass through data for some modules*/
288 		void *udta;
289 	} GF_DecoderConfig;
290 
291 
292 	/*! Content Identification Descriptor*/
293 	typedef struct {
294 		BASE_DESCRIPTOR
295 			u8 compatibility;
296 		u8 protectedContent;
297 		u8 contentTypeFlag;
298 		u8 contentIdentifierFlag;
299 		u8 contentType;
300 		u8 contentIdentifierType;
301 		/*international code string*/
302 		char *contentIdentifier;
303 	} GF_CIDesc;
304 
305 	/*! Supplementary Content Identification Descriptor)*/
306 	typedef struct {
307 		BASE_DESCRIPTOR
308 			u32 languageCode;
309 		char *supplContentIdentifierTitle;
310 		char *supplContentIdentifierValue;
311 	} GF_SCIDesc;
312 
313 	/*! IPI (Intelectual Property Identification) Descriptor Pointer*/
314 	typedef struct {
315 		BASE_DESCRIPTOR
316 			u16 IPI_ES_Id;
317 	} GF_IPIPtr;
318 
319 	/*! IPMP Descriptor Pointer*/
320 	typedef struct {
321 		BASE_DESCRIPTOR
322 			u8 IPMP_DescriptorID;
323 		u16 IPMP_DescriptorIDEx;
324 		u16 IPMP_ES_ID;
325 	} GF_IPMPPtr;
326 
327 	/*! IPMPX control points*/
328 	enum
329 	{
330 		/*no control point*/
331 		IPMP_CP_NONE = 0,
332 		/*control point between DB and decoder*/
333 		IPMP_CP_DB = 1,
334 		/*control point between decoder and CB*/
335 		IPMP_CP_CB = 2,
336 		/*control point between CB and render*/
337 		IPMP_CP_CM = 3,
338 		/*control point in BIFS tree (???)*/
339 		IPMP_CP_BIFS = 4
340 		/*the rest is reserved or forbidden(0xFF)*/
341 	};
342 
343 	/*! IPMPX base classe*/
344 #define GF_IPMPX_BASE	\
345 	u8 tag;	\
346 	u8 version;	\
347 	u32 dataID;	\
348 
349 	/*! IPMPX base object used for type casting in many function*/
350 	typedef struct
351 	{
352 		GF_IPMPX_BASE
353 	} GF_GF_IPMPX_Base;
354 
355 	/*! IPMP descriptor*/
356 	typedef struct {
357 		BASE_DESCRIPTOR
358 			u8 IPMP_DescriptorID;
359 		u16 IPMPS_Type;
360 		/*if IPMPS_Type=0, NULL-terminated URL, else if IPMPS_Type is not IPMPX, opaque data*/
361 		char *opaque_data;
362 		/*if IPMPS_Type=0, irrelevant (strlen(URL)), else if IPMPS_Type is not IPMPX, opaque data size*/
363 		u32 opaque_data_size;
364 
365 		/*IPMPX specific*/
366 		u16 IPMP_DescriptorIDEx;
367 		bin128 IPMP_ToolID;
368 		u8 control_point;
369 		u8 cp_sequence_code;
370 		GF_List *ipmpx_data;
371 	} GF_IPMP_Descriptor;
372 
373 
374 	/*! IPMPX max number of tools*/
375 #define MAX_IPMP_ALT_TOOLS	20
376 
377 	/*! IPMPX Tool*/
378 	typedef struct
379 	{
380 		BASE_DESCRIPTOR
381 			bin128 IPMP_ToolID;
382 		/*if set, this is an alternate tool*/
383 		u32 num_alternate;
384 		bin128 specificToolID[MAX_IPMP_ALT_TOOLS];
385 
386 		struct _tagIPMPXParamDesc *toolParamDesc;
387 		char *tool_url;
388 	} GF_IPMP_Tool;
389 
390 
391 	/*! Elementary Mask of Bifs Config - parsing only */
392 	typedef struct {
393 		BASE_DESCRIPTOR
394 			u32 node_id;			/* referenced nodeID */
395 		char *node_name;		/* referenced node name */
396 	} GF_ElementaryMask;
397 
398 	/*! BIFSConfig - parsing only, STORED IN ESD:DCD:DSI*/
399 	typedef struct __tag_bifs_config
400 	{
401 		BASE_DESCRIPTOR
402 			u32 version;
403 		u16 nodeIDbits;
404 		u16 routeIDbits;
405 		u16 protoIDbits;
406 		Bool pixelMetrics;
407 		u16 pixelWidth, pixelHeight;
408 		/*BIFS-Anim stuff*/
409 		Bool randomAccess;
410 		GF_List *elementaryMasks;
411 		/*internal extensions for encoding*/
412 		Bool useNames;
413 	} GF_BIFSConfig;
414 
415 	/*! flags for text style*/
416 	enum
417 	{
418 		GF_TXT_STYLE_NORMAL = 0,
419 		GF_TXT_STYLE_BOLD = 1,
420 		GF_TXT_STYLE_ITALIC = 2,
421 		GF_TXT_STYLE_UNDERLINED = 4
422 	};
423 
424 	/*! text style record*/
425 	typedef struct
426 	{
427 		u16 startCharOffset;
428 		u16 endCharOffset;
429 		u16 fontID;
430 		u8 style_flags;
431 		u8 font_size;
432 		/*ARGB*/
433 		u32 text_color;
434 	} GF_StyleRecord;
435 
436 	/*! font record for text*/
437 	typedef struct
438 	{
439 		u16 fontID;
440 		char *fontName;
441 	} GF_FontRecord;
442 
443 	/*! positioning record for text*/
444 	typedef struct
445 	{
446 		s16 top, left, bottom, right;
447 	} GF_BoxRecord;
448 
449 	/*scroll flags for text*/
450 	enum
451 	{
452 		GF_TXT_SCROLL_CREDITS = 0,
453 		GF_TXT_SCROLL_MARQUEE = 1,
454 		GF_TXT_SCROLL_DOWN = 2,
455 		GF_TXT_SCROLL_RIGHT = 3
456 	};
457 
458 	/* display flags for text*/
459 	enum
460 	{
461 		GF_TXT_SCROLL_IN = 0x00000020,
462 		GF_TXT_SCROLL_OUT = 0x00000040,
463 		/*use one of the scroll flags, eg GF_TXT_SCROLL_DIRECTION | GF_TXT_SCROLL_CREDITS*/
464 		GF_TXT_SCROLL_DIRECTION = 0x00000180,
465 		GF_TXT_KARAOKE = 0x00000800,
466 		GF_TXT_VERTICAL = 0x00020000,
467 		GF_TXT_FILL_REGION = 0x00040000,
468 
469 		GF_TXT_NO_SCALE = 0x2,
470 		GF_TXT_MOVIE_BACK_COLOR = 0x8,
471 		GF_TXT_CONTINUOUS_SCROLL = 0x200,
472 		GF_TXT_DROP_SHADOW = 0x1000,
473 		GF_TXT_FILL_ANTIALIAS = 0x2000,
474 		GF_TXT_SOME_SAMPLES_FORCED = 0x40000000,
475 		GF_TXT_ALL_SAMPLES_FORCED = 0x80000000,
476 	};
477 
478 	/*! Text sample description descriptor (eg mostly a copy of ISOBMF sample entry)*/
479 	typedef struct
480 	{
481 		/*this is defined as a descriptor for parsing*/
482 		BASE_DESCRIPTOR
483 
484 			u32 displayFlags;
485 		/*left, top: 0 -  centered: 1 - bottom, right: -1*/
486 		s8 horiz_justif, vert_justif;
487 		/*ARGB*/
488 		u32 back_color;
489 		GF_BoxRecord default_pos;
490 		GF_StyleRecord	default_style;
491 
492 		u32 font_count;
493 		GF_FontRecord *fonts;
494 
495 		/*unused in isomedia but needed for streamingText*/
496 		u8 sample_index;
497 	} GF_TextSampleDescriptor;
498 
499 	/*! Text stream descriptor, internal only*/
500 	typedef struct
501 	{
502 		BASE_DESCRIPTOR
503 			/*only 0x10 shall be used for 3GP text stream*/
504 			u8 Base3GPPFormat;
505 		/*only 0x10 shall be used for StreamingText*/
506 		u8 MPEGExtendedFormat;
507 		/*only 0x10 shall be used for StreamingText (base profile, base level)*/
508 		u8 profileLevel;
509 		u32 timescale;
510 		/*0 forbidden, 1: out-of-band desc only, 2: in-band desc only, 3: both*/
511 		u8 sampleDescriptionFlags;
512 		/*More negative layer values are towards the viewer*/
513 		s16 layer;
514 		/*text track width & height*/
515 		u16 text_width;
516 		u16 text_height;
517 		/*compatible 3GP formats, same coding as 3GPPBaseFormat*/
518 		u8 nb_compatible_formats;
519 		u8 compatible_formats[20];
520 		/*defined in isomedia.h*/
521 		GF_List *sample_descriptions;
522 
523 		/*if true info below are valid (cf 3GPP for their meaning)*/
524 		Bool has_vid_info;
525 		u16 video_width;
526 		u16 video_height;
527 		s16 horiz_offset;
528 		s16 vert_offset;
529 	} GF_TextConfig;
530 
531 	/*! generic subtitle sample description descriptor*/
532 	typedef struct
533 	{
534 		/*this is defined as a descriptor for parsing*/
535 		BASE_DESCRIPTOR
536 
537 			/*unused in isomedia but needed for streamingText*/
538 			u8 sample_index;
539 	} GF_GenericSubtitleSampleDescriptor;
540 
541 	/*! generic subtitle descriptor*/
542 	typedef struct
543 	{
544 		BASE_DESCRIPTOR
545 			u32 timescale;
546 		/*More negative layer values are towards the viewer*/
547 		s16 layer;
548 		/*text track width & height*/
549 		u16 text_width;
550 		u16 text_height;
551 		/*defined in isomedia.h*/
552 		GF_List *sample_descriptions;
553 
554 		/*if true info below are valid (cf 3GPP for their meaning)*/
555 		Bool has_vid_info;
556 		u16 video_width;
557 		u16 video_height;
558 		s16 horiz_offset;
559 		s16 vert_offset;
560 	} GF_GenericSubtitleConfig;
561 
562 
563 	/*! MuxInfo descriptor - parsing only, stored in ESD:extDescr*/
564 	typedef struct {
565 		BASE_DESCRIPTOR
566 			/*input location*/
567 			char *file_name;
568 		/*input groupID for interleaving*/
569 		u32 GroupID;
570 		/*input stream format (not required, guessed from file_name)*/
571 		char *streamFormat;
572 		/*time offset in ms from first TS (appends an edit list in mp4)*/
573 		s32 startTime;
574 
575 		/*media length to import in ms (from 0)*/
576 		u32 duration;
577 
578 		/*SRT/SUB import extensions - only support for text and italic style*/
579 		char *textNode;
580 		char *fontNode;
581 
582 		/*video and SUB import*/
583 		Double frame_rate;
584 
585 		/*same as importer flags, cf media.h*/
586 		u32 import_flags;
587 
588 		/*indicates input file shall be destryed - used during SWF import*/
589 		Bool delete_file;
590 
591 		/*carousel configuration*/
592 		u32 carousel_period_plus_one;
593 		u16 aggregate_on_esid;
594 
595 		/*original source URL*/
596 		char *src_url;
597 	} GF_MuxInfo;
598 
599 	/*! UI config descriptor for InputSensor streams*/
600 	typedef struct
601 	{
602 		BASE_DESCRIPTOR
603 			/*input type*/
604 			char *deviceName;
605 		/*string sensor terminaison (validation) char*/
606 		char termChar;
607 		/*string sensor deletion char*/
608 		char delChar;
609 		/*device-specific data*/
610 		char *ui_data;
611 		u32 ui_data_length;
612 	} GF_UIConfig;
613 
614 	/*! LASERConfig - parsing only, STORED IN ESD:DCD:DSI*/
615 	typedef struct __tag_laser_config
616 	{
617 		BASE_DESCRIPTOR
618 			u8 profile;
619 		u8 level;
620 		u8 pointsCodec;
621 		u8 pathComponents;
622 		u8 fullRequestHost;
623 		u16 time_resolution;
624 		u8 colorComponentBits;
625 		s8 resolution;
626 		u8 coord_bits;
627 		u8 scale_bits_minus_coord_bits;
628 		u8 newSceneIndicator;
629 		u8 extensionIDBits;
630 
631 		/*the rest of the structure is never coded, only used for the config of GPAC...*/
632 		Bool force_string_ids;/*forces all nodes to be defined with string IDs*/
633 	} GF_LASERConfig;
634 
635 
636 	/*! QoS Tags */
637 	enum
638 	{
639 		QoSMaxDelayTag = 0x01,
640 		QoSPrefMaxDelayTag = 0x02,
641 		QoSLossProbTag = 0x03,
642 		QoSMaxGapLossTag = 0x04,
643 		QoSMaxAUSizeTag = 0x41,
644 		QoSAvgAUSizeTag = 0x42,
645 		QoSMaxAURateTag = 0x43
646 	};
647 
648 	/*! QoS Descriptor*/
649 	typedef struct {
650 		BASE_DESCRIPTOR
651 			u8 predefined;
652 		GF_List *QoS_Qualifiers;
653 	} GF_QoS_Descriptor;
654 
655 
656 #define QOS_BASE_QUALIFIER \
657 	u8 tag;	\
658 	u32 size;
659 
660 	/*! QoS Default Qualifier*/
661 	typedef struct {
662 		QOS_BASE_QUALIFIER
663 	} GF_QoS_Default;
664 
665 	/*! QoS Max Delay Qualifier*/
666 	typedef struct {
667 		QOS_BASE_QUALIFIER
668 			u32 MaxDelay;
669 	} GF_QoS_MaxDelay;
670 
671 	/*! QoS Prefered Max Delay Qualifier*/
672 	typedef struct {
673 		QOS_BASE_QUALIFIER
674 			u32 PrefMaxDelay;
675 	} GF_QoS_PrefMaxDelay;
676 
677 	/*! QoS loss probability Qualifier*/
678 	typedef struct {
679 		QOS_BASE_QUALIFIER
680 			Float LossProb;
681 	} GF_QoS_LossProb;
682 
683 	/*! QoS Max Gap Loss Qualifier*/
684 	typedef struct {
685 		QOS_BASE_QUALIFIER
686 			u32 MaxGapLoss;
687 	} GF_QoS_MaxGapLoss;
688 
689 	/*! QoS Max AU Size Qualifier*/
690 	typedef struct {
691 		QOS_BASE_QUALIFIER
692 			u32 MaxAUSize;
693 	} GF_QoS_MaxAUSize;
694 
695 	/*! QoS Average AU Size Qualifier*/
696 	typedef struct {
697 		QOS_BASE_QUALIFIER
698 			u32 AvgAUSize;
699 	} GF_QoS_AvgAUSize;
700 
701 	/*! QoS AU rate Qualifier*/
702 	typedef struct {
703 		QOS_BASE_QUALIFIER
704 			u32 MaxAURate;
705 	} GF_QoS_MaxAURate;
706 
707 	/*! QoS private  Qualifier*/
708 	typedef struct {
709 		QOS_BASE_QUALIFIER
710 			/*! max size class is  2^28 - 1*/
711 			u32 DataLength;
712 		char *Data;
713 	} GF_QoS_Private;
714 
715 
716 	/*! Registration Descriptor*/
717 	typedef struct {
718 		BASE_DESCRIPTOR
719 			u32 formatIdentifier;
720 		u32 dataLength;
721 		char *additionalIdentificationInfo;
722 	} GF_Registration;
723 
724 	/*! Language Descriptor*/
725 	typedef struct {
726 		BASE_DESCRIPTOR
727 			u32 langCode;
728 		char *full_lang_code;
729 	} GF_Language;
730 
731 	/*! Elementary Stream Descriptor*/
732 	typedef struct
733 	{
734 		BASE_DESCRIPTOR
735 			u16 ESID;
736 		u16 OCRESID;
737 		u16 dependsOnESID;
738 		u8 streamPriority;
739 		char *URLString;
740 		GF_DecoderConfig *decoderConfig;
741 		GF_SLConfig *slConfig;
742 		GF_IPIPtr *ipiPtr;
743 		GF_QoS_Descriptor *qos;
744 		GF_Registration *RegDescriptor;
745 		/*! 0 or 1 lang desc*/
746 		GF_Language *langDesc;
747 
748 		GF_List *IPIDataSet;
749 		GF_List *IPMPDescriptorPointers;
750 		GF_List *extensionDescriptors;
751 
752 		//GPAC internals
753 
754 		/*! 1 if this stream has scalable layers, 0 otherwise (GPAC internals)*/
755 		Bool has_scalable_layers;
756 		/*! service URL (GPAC internals)*/
757 		const char *service_url;
758 	} GF_ESD;
759 
760 
761 	/*! Auxiliary Video Data Descriptor*/
762 	typedef struct {
763 		BASE_DESCRIPTOR
764 			u32 aux_video_type;
765 		u32 position_offset_h;
766 		u32 position_offset_v;
767 		u32 knear;
768 		u32 kfar;
769 		u32 parallax_zero;
770 		u32 parallax_scale;
771 		u32 dref;
772 		u32 wref;
773 	} GF_AuxVideoDescriptor;
774 
775 	/*! Content Classification Descriptor*/
776 	typedef struct {
777 		BASE_DESCRIPTOR
778 			u32 classificationEntity;
779 		u16 classificationTable;
780 		u32 dataLength;
781 		char *contentClassificationData;
782 	} GF_CCDescriptor;
783 
784 
785 	/*! this structure is used in GF_KeyWord*/
786 	typedef struct {
787 		char *keyWord;
788 	} GF_KeyWordItem;
789 
790 	/*! Key Word Descriptor*/
791 	typedef struct {
792 		BASE_DESCRIPTOR
793 			u32 languageCode;
794 		u8 isUTF8;
795 		GF_List *keyWordsList;
796 	} GF_KeyWord;
797 
798 	/*! Rating Descriptor*/
799 	typedef struct {
800 		BASE_DESCRIPTOR
801 			u32 ratingEntity;
802 		u16 ratingCriteria;
803 		u32 infoLength;
804 		char *ratingInfo;
805 	} GF_Rating;
806 
807 
808 	/*! Short Textual Descriptor*/
809 	typedef struct {
810 		BASE_DESCRIPTOR
811 			u32 langCode;
812 		u8 isUTF8;
813 		char *eventName;
814 		char *eventText;
815 	} GF_ShortTextual;
816 
817 
818 	/*! this structure is used in GF_ExpandedTextual*/
819 	typedef struct {
820 		char *text;
821 	} GF_ETD_ItemText;
822 
823 	/*! Expanded Textual Descriptor*/
824 	typedef struct {
825 		BASE_DESCRIPTOR
826 			u32 langCode;
827 		u8 isUTF8;
828 		GF_List *itemDescriptionList;
829 		GF_List *itemTextList;
830 		char *NonItemText;
831 	} GF_ExpandedTextual;
832 
833 	/*! this structure is used in GF_CC_Name*/
834 	typedef struct {
835 		u32 langCode;
836 		u8 isUTF8;
837 		char *contentCreatorName;
838 	} GF_ContentCreatorInfo;
839 
840 	/*! Content Creator Name GF_Descriptor
841 	NOTE: the desctructor will delete all the items in the list
842 	(GF_ContentCreatorInfo items) */
843 	typedef struct {
844 		BASE_DESCRIPTOR
845 			GF_List *ContentCreators;
846 	} GF_CC_Name;
847 
848 	/*! Content Creation Date Descriptor*/
849 	typedef struct {
850 		BASE_DESCRIPTOR
851 			char contentCreationDate[5];
852 	} GF_CC_Date;
853 
854 
855 	/*! this structure is used in GF_OCICreators*/
856 	typedef struct {
857 		u32 langCode;
858 		u8 isUTF8;
859 		char *OCICreatorName;
860 	} GF_OCICreator_item;
861 
862 	/*! OCI Creator Name Descriptor*/
863 	typedef struct {
864 		BASE_DESCRIPTOR
865 			GF_List *OCICreators;
866 	} GF_OCICreators;
867 
868 	/*! OCI Creation Date Descriptor*/
869 	typedef struct {
870 		BASE_DESCRIPTOR
871 			char OCICreationDate[5];
872 	} GF_OCI_Data;
873 
874 
875 	/*! this structure is used in GF_SMPTECamera*/
876 	typedef struct {
877 		u8 paramID;
878 		u32 param;
879 	} GF_SmpteParam;
880 
881 	/*! Smpte Camera Position Descriptor*/
882 	typedef struct {
883 		BASE_DESCRIPTOR
884 			u8 cameraID;
885 		GF_List *ParamList;
886 	} GF_SMPTECamera;
887 
888 
889 	/*! Extension Profile Level Descriptor*/
890 	typedef struct {
891 		BASE_DESCRIPTOR
892 			u8 profileLevelIndicationIndex;
893 		u8 ODProfileLevelIndication;
894 		u8 SceneProfileLevelIndication;
895 		u8 AudioProfileLevelIndication;
896 		u8 VisualProfileLevelIndication;
897 		u8 GraphicsProfileLevelIndication;
898 		u8 MPEGJProfileLevelIndication;
899 	} GF_PLExt;
900 
901 	/*! Profile Level Indication Index Descriptor*/
902 	typedef struct {
903 		BASE_DESCRIPTOR
904 			u8 profileLevelIndicationIndex;
905 	} GF_PL_IDX;
906 
907 	/*! used for storing AVC sequenceParameterSetNALUnit and pictureParameterSetNALUnit*/
908 	typedef struct
909 	{
910 		u16 size;
911 		char *data;
912 		/* used of AVC/SVC detection */
913 		s32 id;
914 	} GF_AVCConfigSlot;
915 
916 	/*! AVC config record - not a real MPEG-4 descriptor
917 	*/
918 	typedef struct
919 	{
920 		u8 configurationVersion;
921 		u8 AVCProfileIndication;
922 		u8 profile_compatibility;
923 		u8 AVCLevelIndication;
924 		u8 nal_unit_size;
925 
926 		GF_List *sequenceParameterSets;
927 		GF_List *pictureParameterSets;
928 
929 		/*for SVC*/
930 		u8 complete_representation;
931 
932 		/*for high profiles*/
933 		u8 chroma_format;
934 		u8 luma_bit_depth;
935 		u8 chroma_bit_depth;
936 		/*may be NULL*/
937 		GF_List *sequenceParameterSetExtensions;
938 	} GF_AVCConfig;
939 
940 
941 
942 	/*! used for storing HEVC SPS/PPS/VPS/SEI*/
943 	typedef struct
944 	{
945 		u8 type;
946 		u8 array_completeness;
947 		GF_List *nalus;
948 	} GF_HEVCParamArray;
949 
950 	/*! HEVC config record - not a real MPEG-4 descriptor*/
951 	typedef struct
952 	{
953 		u8 configurationVersion;
954 		u8 profile_space;
955 		u8 tier_flag;
956 		u8 profile_idc;
957 		u32 general_profile_compatibility_flags;
958 		u8 progressive_source_flag;
959 		u8 interlaced_source_flag;
960 		u8 non_packed_constraint_flag;
961 		u8 frame_only_constraint_flag;
962 		/*only lowest 44 bits used*/
963 		u64 constraint_indicator_flags;
964 		u8 level_idc;
965 		u16 min_spatial_segmentation_idc;
966 
967 		u8 parallelismType;
968 		u8 chromaFormat;
969 		u8 luma_bit_depth;
970 		u8 chroma_bit_depth;
971 		u16 avgFrameRate;
972 		u8 constantFrameRate;
973 		u8 numTemporalLayers;
974 		u8 temporalIdNested;
975 
976 		u8 nal_unit_size;
977 
978 		GF_List *param_array;
979 		//used in LHVC config
980 		Bool complete_representation;
981 
982 		//following are internal to libgpac and NEVER serialized
983 
984 		//set by libisomedia at import/export/parsing time to differentiate between lhcC and hvcC time
985 		Bool is_lhvc;
986 	} GF_HEVCConfig;
987 
988 	/*! Media Segment Descriptor used for Media Control Extensions*/
989 	typedef struct
990 	{
991 		BASE_DESCRIPTOR
992 			Double startTime;
993 		Double Duration;
994 		char *SegmentName;
995 	} GF_Segment;
996 
997 	/*! Media Time Descriptor used for Media Control Extensions*/
998 	typedef struct
999 	{
1000 		BASE_DESCRIPTOR
1001 			Double mediaTimeStamp;
1002 	} GF_MediaTime;
1003 
1004 
1005 	/*! MPEG-4 SYSTEMS OD Commands Tags */
1006 	enum
1007 	{
1008 		GF_ODF_OD_UPDATE_TAG = 0x01,
1009 		GF_ODF_OD_REMOVE_TAG = 0x02,
1010 		GF_ODF_ESD_UPDATE_TAG = 0x03,
1011 		GF_ODF_ESD_REMOVE_TAG = 0x04,
1012 		GF_ODF_IPMP_UPDATE_TAG = 0x05,
1013 		GF_ODF_IPMP_REMOVE_TAG = 0x06,
1014 
1015 		/*file format reserved*/
1016 		GF_ODF_ESD_REMOVE_REF_TAG = 0x07,
1017 
1018 		GF_ODF_COM_ISO_BEGIN_TAG = 0x0D,
1019 		GF_ODF_COM_ISO_END_TAG = 0xBF,
1020 
1021 		GF_ODF_COM_USER_BEGIN_TAG = 0xC0,
1022 		GF_ODF_COM_USER_END_TAG = 0xFE
1023 	};
1024 
1025 #define BASE_OD_COMMAND \
1026 	u8 tag;
1027 
1028 	/*! MPEG-4 SYSTEMS OD - (abstract) base command. */
1029 	typedef struct {
1030 		BASE_OD_COMMAND
1031 	} GF_ODCom;
1032 
1033 	/*! MPEG-4 SYSTEMS OD - default command*/
1034 	typedef struct {
1035 		BASE_OD_COMMAND
1036 			u32 dataSize;
1037 		char *data;
1038 	} GF_BaseODCom;
1039 
1040 	/*! MPEG-4 SYSTEMS OD - Object Descriptor Update
1041 	NB: the list can contain OD or IOD, except internally in the File Format (only MP4_OD)*/
1042 	typedef struct
1043 	{
1044 		BASE_OD_COMMAND
1045 			GF_List *objectDescriptors;
1046 	} GF_ODUpdate;
1047 
1048 	/*! MPEG-4 SYSTEMS OD - Object Descriptor Remove*/
1049 	typedef struct
1050 	{
1051 		BASE_OD_COMMAND
1052 			u32 NbODs;
1053 		u16 *OD_ID;
1054 	} GF_ODRemove;
1055 
1056 	/*! MPEG-4 SYSTEMS OD - Elementary Stream Descriptor Update*/
1057 	typedef struct
1058 	{
1059 		BASE_OD_COMMAND
1060 			u16 ODID;
1061 		GF_List *ESDescriptors;
1062 	} GF_ESDUpdate;
1063 
1064 	/*! MPEG-4 SYSTEMS OD - Elementary Stream Descriptor Remove*/
1065 	typedef struct {
1066 		BASE_OD_COMMAND
1067 			u16 ODID;
1068 		u32 NbESDs;
1069 		u16 *ES_ID;
1070 	} GF_ESDRemove;
1071 
1072 	/*! MPEG-4 SYSTEMS OD - IPMP Descriptor Update*/
1073 	typedef struct {
1074 		BASE_OD_COMMAND
1075 			GF_List *IPMPDescList;
1076 	} GF_IPMPUpdate;
1077 
1078 	/*! MPEG-4 SYSTEMS OD - IPMP Descriptor Remove*/
1079 	typedef struct {
1080 		BASE_OD_COMMAND
1081 			u32 NbIPMPDs;
1082 		/*now this is bad: only IPMPv1 descriptors can be removed at run tim...*/
1083 		u8 *IPMPDescID;
1084 	} GF_IPMPRemove;
1085 
1086 
1087 
1088 
1089 
1090 
1091 	/*! MPEG-4 SYSTEMS OD - OD API */
1092 
1093 	/*! OD CODEC object - just a simple reader/writer*/
1094 	typedef struct tagODCoDec
1095 	{
1096 		GF_BitStream *bs;
1097 		GF_List *CommandList;
1098 	} GF_ODCodec;
1099 
1100 
1101 	/*! OD codec construction
1102 	\return new codec object*/
1103 	GF_ODCodec *gf_odf_codec_new();
1104 	/*! OD codec destruction
1105 	\param codec OD codec to destroy
1106 	*/
1107 	void gf_odf_codec_del(GF_ODCodec *codec);
1108 	/*! add a command to the codec command list.
1109 	\param codec target codec
1110 	\param command command to add
1111 	\return error if any
1112 	*/
1113 	GF_Err gf_odf_codec_add_com(GF_ODCodec *codec, GF_ODCom *command);
1114 	/*! encode the current command list.
1115 	\param codec target codec
1116 	\param cleanup_type specifies what to do with the command after encoding. The following values are accepted:
1117 	0: commands are removed from the list but not destroyed
1118 	1: commands are removed from the list and destroyed
1119 	2: commands are kept in the list and not destroyed
1120 	\return error if any
1121 	*/
1122 	GF_Err gf_odf_codec_encode(GF_ODCodec *codec, u32 cleanup_type);
1123 	/*! get the encoded AU.
1124 	\param codec target codec
1125 	\param outAU output buffer allocated by the codec, user is responsible of freeing the allocated space
1126 	\param au_length size of the AU (allocated buffer)
1127 	\return error if any
1128 	*/
1129 	GF_Err gf_odf_codec_get_au(GF_ODCodec *codec, char **outAU, u32 *au_length);
1130 	/* !set the encoded AU to the codec
1131 	\param codec target codec
1132 	\param au target AU to decode
1133 	\param au_length size in bytes of the AU to decode
1134 	\return error if any
1135 	*/
1136 	GF_Err gf_odf_codec_set_au(GF_ODCodec *codec, const char *au, u32 au_length);
1137 	/*! decode the previously set-up AU
1138 	\param codec target codec
1139 	\return error if any
1140 	*/
1141 	GF_Err gf_odf_codec_decode(GF_ODCodec *codec);
1142 	/*! get the first OD command in the list. Once called, the command is removed
1143 	from the command list. Return NULL when commandList is empty
1144 	\param codec target codec
1145 	\return deocded command or NULL
1146 	*/
1147 	GF_ODCom *gf_odf_codec_get_com(GF_ODCodec *codec);
1148 
1149 	/*! apply a command to the codec command list. Command is duplicated if needed
1150 	This is used for state maintenance and RAP generation.
1151 	\param codec target codec
1152 	\param command the command to apply
1153 	\return error if any
1154 	*/
1155 	GF_Err gf_odf_codec_apply_com(GF_ODCodec *codec, GF_ODCom *command);
1156 
1157 
1158 	/*! MPEG-4 SYSTEMS OD Command Creation
1159 	\param tag type of command to create
1160 	\return the created command or NULL
1161 	*/
1162 	GF_ODCom *gf_odf_com_new(u8 tag);
1163 	/*! MPEG-4 SYSTEMS OD Command Destruction
1164 	\param com the command to delete. Pointer is set back to NULL
1165 	*/
1166 	GF_Err gf_odf_com_del(GF_ODCom **com);
1167 
1168 
1169 	/************************************************************
1170 	Descriptors Functions
1171 	************************************************************/
1172 
1173 	/*! Descriptors Creation
1174 	\param tag type of descriptor to create
1175 	\return created descriptor or NULL
1176 	*/
1177 	GF_Descriptor *gf_odf_desc_new(u8 tag);
1178 	/*! Descriptors Destruction
1179 	\param desc the descriptor to destroy
1180 	*/
1181 	void gf_odf_desc_del(GF_Descriptor *desc);
1182 
1183 	/*! helper for building a preformatted GF_ESD with decoderConfig, decoderSpecificInfo with no data and
1184 	SLConfig descriptor with predefined
1185 	\param sl_predefined type of predefined sl config
1186 	\return the ESD created
1187 	*/
1188 	GF_ESD *gf_odf_desc_esd_new(u32 sl_predefined);
1189 
1190 	/*! special function for authoring - convert DSI to BIFSConfig
1191 	\param dsi BIFS decoder specific info
1192 	\param oti BIFS object type indication
1193 	\return decoded BIFS Config descriptor - It is the caller responsability of freeing it
1194 	*/
1195 	GF_BIFSConfig *gf_odf_get_bifs_config(GF_DefaultDescriptor *dsi, u8 oti);
1196 	/*! special function for authoring - convert DSI to LASERConfig
1197 	\param dsi LASER decoder specific info
1198 	\param cfg the LASER config object to be filled
1199 	\return error if any
1200 	*/
1201 	GF_Err gf_odf_get_laser_config(GF_DefaultDescriptor *dsi, GF_LASERConfig *cfg);
1202 	/*! sepcial function for authoring - convert DSI to TextConfig
1203 	\param dsi TEXT decoder specific info
1204 	\param oti TEXT object type indication
1205 	\param cfg the text config object to be filled
1206 	\return error if any
1207 	*/
1208 	GF_Err gf_odf_get_text_config(GF_DefaultDescriptor *dsi, u8 oti, GF_TextConfig *cfg);
1209 	/*! special function for authoring - convert DSI to UIConfig
1210 	\param dsi text decoder specific info
1211 	\param cfg the text config object to be filled
1212 	\return error if any
1213 	*/
1214 	GF_Err gf_odf_get_ui_config(GF_DefaultDescriptor *dsi, GF_UIConfig *cfg);
1215 	/*! converts UIConfig to dsi - does not destroy input descr but does create output one
1216 	\param cfg the UI config object
1217 	\param out_dsi the decoder specific info created. It is the caller responsability of freeing it
1218 	\return error if any
1219 	*/
1220 	GF_Err gf_odf_encode_ui_config(GF_UIConfig *cfg, GF_DefaultDescriptor **out_dsi);
1221 
1222 	/*! AVC config constructor
1223 	\return the created AVC config*/
1224 	GF_AVCConfig *gf_odf_avc_cfg_new();
1225 	/*! AVC config destructor
1226 	\param cfg the AVC config to destroy*/
1227 	void gf_odf_avc_cfg_del(GF_AVCConfig *cfg);
1228 	/*! gets GF_AVCConfig from MPEG-4 DSI
1229 	\param dsi encoded AVC decoder specific info
1230 	\param dsi_size encoded AVC decoder specific info size
1231 	\return the decoded AVC config
1232 	*/
1233 	GF_AVCConfig *gf_odf_avc_cfg_read(char *dsi, u32 dsi_size);
1234 	/*! writes GF_AVCConfig as MPEG-4 DSI
1235 	\param cfg the AVC config to encode
1236 	\param outData encoded dsi buffer - it is the caller responsability to free this
1237 	\param outSize  encoded dsi buffer size
1238 	\return error if any
1239 	*/
1240 	GF_Err gf_odf_avc_cfg_write(GF_AVCConfig *cfg, char **outData, u32 *outSize);
1241 
1242 
1243 	/*! HEVC config constructor
1244 	\return the created HEVC config*/
1245 	GF_HEVCConfig *gf_odf_hevc_cfg_new();
1246 	/*! HEVC config destructor
1247 	\param cfg the HEVC config to destroy*/
1248 	void gf_odf_hevc_cfg_del(GF_HEVCConfig *cfg);
1249 	/*! writes GF_HEVCConfig as MPEG-4 DSI in a bitstream object
1250 	\param cfg the HEVC config to encode
1251 	\param bs output bitstream object in which the config is written
1252 	\return error if any
1253 	*/
1254 	GF_Err gf_odf_hevc_cfg_write_bs(GF_HEVCConfig *cfg, GF_BitStream *bs);
1255 	/*! writes GF_HEVCConfig as MPEG-4 DSI
1256 	\param cfg the HEVC config to encode
1257 	\param outData encoded dsi buffer - it is the caller responsability to free this
1258 	\param outSize  encoded dsi buffer size
1259 	\return error if any
1260 	*/
1261 	GF_Err gf_odf_hevc_cfg_write(GF_HEVCConfig *cfg, char **outData, u32 *outSize);
1262 	/*! gets GF_HEVCConfig from bitstream MPEG-4 DSI
1263 	\param bs bitstream containing the encoded HEVC decoder specific info
1264 	\param is_lhvc if GF_TRUE, indicates if the dsi is LHVC
1265 	\return the decoded HEVC config
1266 	*/
1267 	GF_HEVCConfig *gf_odf_hevc_cfg_read_bs(GF_BitStream *bs, Bool is_lhvc);
1268 	/*! gets GF_HEVCConfig from MPEG-4 DSI
1269 	\param dsi encoded HEVC decoder specific info
1270 	\param dsi_size encoded HEVC decoder specific info size
1271 	\param is_lhvc if GF_TRUE, indicates if the dsi is LHVC
1272 	\return the decoded HEVC config
1273 	*/
1274 	GF_HEVCConfig *gf_odf_hevc_cfg_read(char *dsi, u32 dsi_size, Bool is_lhvc);
1275 
1276 	/*! destroy the descriptors in a list but not the list
1277 	\param descList descriptor list to destroy
1278 	\return error if any
1279 	*/
1280 	GF_Err gf_odf_desc_list_del(GF_List *descList);
1281 
1282 	/*! use this function to decode a standalone descriptor
1283 	the raw descriptor MUST be formatted with tag and size field!!!
1284 	a new desc is created and you must delete it when done
1285 	\param raw_desc encoded descriptor to decode
1286 	\param descSize size of descriptor to decode
1287 	\param outDesc output decoded descriptor - it is the caller responsability to free this
1288 	\return error if any
1289 	*/
1290 	GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor **outDesc);
1291 
1292 	/*! use this function to encode a standalone descriptor
1293 	the desc will be formatted with tag and size field
1294 	the output buffer is allocated and you must delete it when done
1295 	\param desc descriptor to encode
1296 	\param outEncDesc output encoded descriptor - it is the caller responsability to free this
1297 	\param outSize size of encoded descriptor
1298 	\return error if any
1299 	*/
1300 	GF_Err gf_odf_desc_write(GF_Descriptor *desc, char **outEncDesc, u32 *outSize);
1301 
1302 	/*! use this function to encode a standalone descriptor in a bitstream object
1303 	the desc will be formatted with tag and size field
1304 	\param desc descriptor to encode
1305 	\param bs the bitstream object in write mode
1306 	\return error if any
1307 	*/
1308 	GF_Err gf_odf_desc_write_bs(GF_Descriptor *desc, GF_BitStream *bs);
1309 
1310 	/*! use this function to get the size of a standalone descriptor (including tag and size fields)
1311 	\param desc descriptor to encode
1312 	\return 0 if error or encoded desc size otherwise*/
1313 	u32 gf_odf_desc_size(GF_Descriptor *desc);
1314 
1315 	/*! duplicate descriptors
1316 	\param inDesc descriptor to copy
1317 	\param outDesc copied descriptor - it is the caller responsability to free this
1318 	\return error if any
1319 	*/
1320 	GF_Err gf_odf_desc_copy(GF_Descriptor *inDesc, GF_Descriptor **outDesc);
1321 
1322 	/*! Adds a descriptor to a parent one. Handles internally what desc can be added to another desc
1323 	and adds it. NO DUPLICATION of the descriptor, so
1324 	once a desc is added to its parent, destroying the parent WILL DESTROY
1325 	this descriptor
1326 	\param parentDesc parent descriptor
1327 	\param newDesc descriptor to add to parent
1328 	\return error if any
1329 	*/
1330 	GF_Err gf_odf_desc_add_desc(GF_Descriptor *parentDesc, GF_Descriptor *newDesc);
1331 
1332 	/*! Gets a textual description of a stream
1333 	\param esd target descriptor
1334 	\return textural description of the descriptor
1335 	*/
1336 	const char *gf_esd_get_textual_description(GF_ESD *esd);
1337 
1338 	/*! Gets a textual description of an AFX stream type
1339 	\param afx_code target stream type descriptor
1340 	\return textural description of the AFX stream
1341 	*/
1342 	const char *gf_afx_get_type_description(u8 afx_code);
1343 
1344 	/*! Gets the stream type name based on stream type
1345 	\param streamType stream type GF_STREAM_XXX as defined in constants.h
1346 	\return NULL if unknown, otherwise value
1347 	*/
1348 	const char *gf_odf_stream_type_name(u32 streamType);
1349 
1350 	/*! Gets the stream type based on stream type name
1351 	\param streamType name of the stream type
1352 	\return stream type GF_STREAM_XXX as defined in constants.h, 0 if unknown
1353 	*/
1354 	u32 gf_odf_stream_type_by_name(const char *streamType);
1355 
1356 	/*! Since IPMP V2, we introduce a new set of functions to read / write a list of descriptors
1357 	that have no containers (a bit like an OD command, but for descriptors)
1358 	This is useful for IPMPv2 DecoderSpecificInfo which contains a set of IPMP_Declarators
1359 	As it could be used for other purposes we keep it generic
1360 	you must create the list yourself, the functions just encode/decode from/to the list*/
1361 
1362 	/*! uncompress an encoded list of descriptors. You must pass an empty GF_List structure
1363 	to know exactly what was in the buffer
1364 	\param raw_list encoded list of descriptors
1365 	\param raw_size size of the encoded list of descriptors
1366 	\param descList list in which the decoded descriptors will be placed
1367 	\return error if any
1368 	*/
1369 	GF_Err gf_odf_desc_list_read(char *raw_list, u32 raw_size, GF_List *descList);
1370 
1371 	/*! compress all descriptors in the list into a single buffer. The buffer is allocated
1372 	by the lib and must be destroyed by your app
1373 	you must pass (outEncList != NULL  && *outEncList == NULL)
1374 	\param descList list of descriptors to be encoded
1375 	\param outEncList buffer of encoded descriptors
1376 	\param outSize size of buffer of encoded descriptors
1377 	\return error if any
1378 	*/
1379 	GF_Err gf_odf_desc_list_write(GF_List *descList, char **outEncList, u32 *outSize);
1380 
1381 	/*! returns size of encoded desc list
1382 	\param descList list of descriptors to be encoded
1383 	\param outSize size of buffer of encoded descriptors
1384 	\return error if any
1385 	*/
1386 	GF_Err gf_odf_desc_list_size(GF_List *descList, u32 *outSize);
1387 
1388 
1389 #ifndef GPAC_MINIMAL_ODF
1390 
1391 
1392 	/************************************************************
1393 	QoS Qualifiers Functions
1394 	************************************************************/
1395 
1396 	/*! QoS Qualifiers constructor
1397 	\param tag tag of QoS descriptor to create
1398 	\return created QoS descriptor
1399 	*/
1400 	GF_QoS_Default *gf_odf_qos_new(u8 tag);
1401 	/*! QoS Qualifiers destructor
1402 	\param qos descriptor to destroy. The pointer is set back to NULL upon destruction
1403 	\return error if any
1404 	*/
1405 	GF_Err gf_odf_qos_del(GF_QoS_Default **qos);
1406 
1407 	/*! READ/WRITE functions: QoS qualifiers are special descriptors but follow the same rules as descriptors.
1408 	therefore, use gf_odf_desc_read and gf_odf_desc_write for QoS*/
1409 
1410 	/*! Adds a QoS qualificator to a parent QoS descriptor
1411 	\param desc parent QoS descriptor
1412 	\param qualif  QoS qualificator
1413 	\return error if any
1414 	*/
1415 	GF_Err gf_odf_qos_add_qualif(GF_QoS_Descriptor *desc, GF_QoS_Default *qualif);
1416 
1417 
1418 
1419 	/*
1420 	OCI Stream AU is a list of OCI event (like OD AU is a list of OD commands)
1421 	*/
1422 
1423 	typedef struct __tag_oci_event OCIEvent;
1424 
1425 	OCIEvent *gf_oci_event_new(u16 EventID);
1426 	void gf_oci_event_del(OCIEvent *event);
1427 
1428 	GF_Err gf_oci_event_set_start_time(OCIEvent *event, u8 Hours, u8 Minutes, u8 Seconds, u8 HundredSeconds, u8 IsAbsoluteTime);
1429 	GF_Err gf_oci_event_set_duration(OCIEvent *event, u8 Hours, u8 Minutes, u8 Seconds, u8 HundredSeconds);
1430 	GF_Err gf_oci_event_add_desc(OCIEvent *event, GF_Descriptor *oci_desc);
1431 
1432 	GF_Err gf_oci_event_get_id(OCIEvent *event, u16 *ID);
1433 	GF_Err gf_oci_event_get_start_time(OCIEvent *event, u8 *Hours, u8 *Minutes, u8 *Seconds, u8 *HundredSeconds, u8 *IsAbsoluteTime);
1434 	GF_Err gf_oci_event_get_duration(OCIEvent *event, u8 *Hours, u8 *Minutes, u8 *Seconds, u8 *HundredSeconds);
1435 	u32 gf_oci_event_get_desc_count(OCIEvent *event);
1436 	GF_Descriptor *gf_oci_event_get_desc(OCIEvent *event, u32 DescIndex);
1437 	GF_Err gf_oci_event_rem_desc(OCIEvent *event, u32 DescIndex);
1438 
1439 
1440 
1441 	typedef struct __tag_oci_codec OCICodec;
1442 
1443 	/*construction / destruction
1444 	IsEncoder specifies an OCI Event encoder
1445 	version is for future extensions, and only 0x01 is valid for now*/
1446 	OCICodec *gf_oci_codec_new(u8 IsEncoder, u8 Version);
1447 	void gf_oci_codec_del(OCICodec *codec);
1448 
1449 	/*				ENCODER FUNCTIONS
1450 	add a command to the codec event list.
1451 	The event WILL BE DESTROYED BY THE CODEC after encoding*/
1452 	GF_Err gf_oci_codec_add_event(OCICodec *codec, OCIEvent *event);
1453 
1454 	/*encode AU. The memory allocation is done in place
1455 	WARNING: once this function called, the codec event List is empty
1456 	and events destroyed
1457 	you must set *outAU = NULL*/
1458 	GF_Err gf_oci_codec_encode(OCICodec *codec, char **outAU, u32 *au_length);
1459 
1460 
1461 
1462 	/*Decoder: decode the previously set-up AU
1463 	the input buffer is cleared once decoded*/
1464 	GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length);
1465 
1466 	/*get the first OCI Event in the list. Once called, the event is removed
1467 	from the event list. Return NULL when the event List is empty
1468 	you MUST delete events */
1469 	OCIEvent *gf_oci_codec_get_event(OCICodec *codec);
1470 
1471 
1472 #ifndef GPAC_DISABLE_OD_DUMP
1473 
1474 	/*! Dumps an OD AU
1475 	\param data encoded OD AU
1476 	\param dataLength encoded OD AU size
1477 	\param trace destination file for dumping
1478 	\param indent number of spaces to use as base index
1479 	\param XMTDump
1480 	*/
1481 	GF_Err gf_odf_dump_au(char *data, u32 dataLength, FILE *trace, u32 indent, Bool XMTDump);
1482 	/*! Dumps an OD AU
1483 	\param com OD command to dump
1484 	\param trace destination file for dumping
1485 	\param indent number of spaces to use as base index
1486 	\param XMTDump if GF_TRUE dumpos as XMT, otherwise as BT
1487 	*/
1488 	GF_Err gf_odf_dump_com(GF_ODCom *com, FILE *trace, u32 indent, Bool XMTDump);
1489 	/*! Dumps an OD Descriptor
1490 	\param desc descriptor to dump
1491 	\param trace destination file for dumping
1492 	\param indent number of spaces to use as base index
1493 	\param XMTDump if GF_TRUE dumpos as XMT, otherwise as BT
1494 	*/
1495 	GF_Err gf_odf_dump_desc(GF_Descriptor *desc, FILE *trace, u32 indent, Bool XMTDump);
1496 	/*! Dumps an OD Descriptor
1497 	\param commandList descriptor list to dump
1498 	\param trace destination file for dumping
1499 	\param indent number of spaces to use as base index
1500 	\param XMTDump if GF_TRUE dumpos as XMT, otherwise as BT
1501 	*/
1502 	GF_Err gf_odf_dump_com_list(GF_List *commandList, FILE *trace, u32 indent, Bool XMTDump);
1503 
1504 	/*! Dumps an OCI event
1505 	\param ev OCI event to dump
1506 	\param trace destination file for dumping
1507 	\param indent number of spaces to use as base index
1508 	\param XMTDump if GF_TRUE dumpos as XMT, otherwise as BT
1509 	*/
1510 	GF_Err gf_oci_dump_event(OCIEvent *ev, FILE *trace, u32 indent, Bool XMTDump);
1511 	/*! Dumps an OCI AU
1512 	\param version version of the OCI stream
1513 	\param au OCI AU to dump
1514 	\param au_length size of the OCI AU to dump
1515 	\param trace destination file for dumping
1516 	\param indent number of spaces to use as base index
1517 	\param XMTDump if GF_TRUE dumpos as XMT, otherwise as BT
1518 	*/
1519 	GF_Err gf_oci_dump_au(u8 version, char *au, u32 au_length, FILE *trace, u32 indent, Bool XMTDump);
1520 
1521 #endif /*GPAC_DISABLE_OD_DUMP*/
1522 
1523 
1524 #endif /*GPAC_MINIMAL_ODF*/
1525 
1526 	/*! Gets descriptor tag by name
1527 	\param descName target descriptor name
1528 	\return descriptor tag or 0 if error
1529 	*/
1530 	u32 gf_odf_get_tag_by_name(char *descName);
1531 
1532 	/*! field type for OD/QoS/IPMPX/etc*/
1533 	typedef enum
1534 	{
1535 		/*! regular type*/
1536 		GF_ODF_FT_DEFAULT = 0,
1537 		/*! single descriptor type*/
1538 		GF_ODF_FT_OD = 1,
1539 		/*! descriptor list type*/
1540 		GF_ODF_FT_OD_LIST = 2,
1541 		/*! IPMP Data type*/
1542 		GF_ODF_FT_IPMPX = 3,
1543 		/*! IPMP Data list type*/
1544 		GF_ODF_FT_IPMPX_LIST = 4,
1545 		/*! IPMP ByteArray type*/
1546 		GF_ODF_FT_IPMPX_BA = 5,
1547 		/*! IPMP ByteArray list type*/
1548 		GF_ODF_FT_IPMPX_BA_LIST = 6
1549 	} GF_ODF_FieldType;
1550 	/*! Gets ODF field type by name
1551 	\param desc target descriptor
1552 	\param fieldName  descriptor field name
1553 	\return the descriptor field type
1554 	*/
1555 	GF_ODF_FieldType gf_odf_get_field_type(GF_Descriptor *desc, char *fieldName);
1556 
1557 	/*! Set non-descriptor field value - value string shall be presented without ' or " characters
1558 	\param desc target descriptor
1559 	\param fieldName descriptor field name
1560 	\param val field value to parse
1561 	\return error if any
1562 	*/
1563 	GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val);
1564 
1565 #ifndef GPAC_MINIMAL_ODF
1566 
1567 
1568 
1569 	/*
1570 	IPMPX extensions - IPMP Data only (messages are not supported yet)
1571 	*/
1572 
1573 	/*! IPMPX base buffer object*/
1574 	typedef struct
1575 	{
1576 		u32 length;
1577 		char *data;
1578 	} GF_IPMPX_ByteArray;
1579 
1580 #define GF_IPMPX_AUTH_DESC	\
1581 	u8 tag;	\
1582 
1583 	/*! IPMPX authentication descriptor*/
1584 	typedef struct
1585 	{
1586 		GF_IPMPX_AUTH_DESC
1587 	} GF_IPMPX_Authentication;
1588 
1589 	enum
1590 	{
1591 		GF_IPMPX_AUTH_Forbidden_Tag = 0x00,
1592 		GF_IPMPX_AUTH_AlgorithmDescr_Tag = 0x01,
1593 		GF_IPMPX_AUTH_KeyDescr_Tag = 0x02
1594 	};
1595 
1596 	/*! IPMPX authentication key descriptor*/
1597 	typedef struct
1598 	{
1599 		GF_IPMPX_AUTH_DESC
1600 			char *keyBody;
1601 		u32 keyBodyLength;
1602 	} GF_IPMPX_AUTH_KeyDescriptor;
1603 
1604 	/*! IPMPX authentication algorithm descriptor*/
1605 	typedef struct
1606 	{
1607 		GF_IPMPX_AUTH_DESC
1608 			/*used if no specAlgoID*/
1609 			u16 regAlgoID;
1610 		GF_IPMPX_ByteArray *specAlgoID;
1611 		GF_IPMPX_ByteArray *OpaqueData;
1612 	} GF_IPMPX_AUTH_AlgorithmDescriptor;
1613 
1614 
1615 	/*! IPMPX data message types*/
1616 	enum
1617 	{
1618 		GF_IPMPX_OPAQUE_DATA_TAG = 0x01,
1619 		GF_IPMPX_AUDIO_WM_INIT_TAG = 0x02,
1620 		GF_IPMPX_VIDEO_WM_INIT_TAG = 0x03,
1621 		GF_IPMPX_SEL_DEC_INIT_TAG = 0x04,
1622 		GF_IPMPX_KEY_DATA_TAG = 0x05,
1623 		GF_IPMPX_AUDIO_WM_SEND_TAG = 0x06,
1624 		GF_IPMPX_VIDEO_WM_SEND_TAG = 0x07,
1625 		GF_IPMPX_RIGHTS_DATA_TAG = 0x08,
1626 		GF_IPMPX_SECURE_CONTAINER_TAG = 0x09,
1627 		GF_IPMPX_ADD_TOOL_LISTENER_TAG = 0x0A,
1628 		GF_IPMPX_REMOVE_TOOL_LISTENER_TAG = 0x0B,
1629 		GF_IPMPX_INIT_AUTHENTICATION_TAG = 0x0C,
1630 		GF_IPMPX_MUTUAL_AUTHENTICATION_TAG = 0x0D,
1631 		GF_IPMPX_USER_QUERY_TAG = 0x0E,
1632 		GF_IPMPX_USER_RESPONSE_TAG = 0x0F,
1633 		GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG = 0x10,
1634 		GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG = 0x11,
1635 		GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG = 0x12,
1636 		/*NO ASSOCIATED STRUCTURE*/
1637 		GF_IPMPX_GET_TOOLS_TAG = 0x13,
1638 		GF_IPMPX_GET_TOOLS_RESPONSE_TAG = 0x14,
1639 		GF_IPMPX_GET_TOOL_CONTEXT_TAG = 0x15,
1640 		GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG = 0x16,
1641 		GF_IPMPX_CONNECT_TOOL_TAG = 0x17,
1642 		GF_IPMPX_DISCONNECT_TOOL_TAG = 0x18,
1643 		GF_IPMPX_NOTIFY_TOOL_EVENT_TAG = 0x19,
1644 		GF_IPMPX_CAN_PROCESS_TAG = 0x1A,
1645 		GF_IPMPX_TRUST_SECURITY_METADATA_TAG = 0x1B,
1646 		GF_IPMPX_TOOL_API_CONFIG_TAG = 0x1C,
1647 
1648 		/*ISMA*/
1649 		GF_IPMPX_ISMACRYP_TAG = 0xD0,
1650 
1651 		/*intern ones for parsing (not real datas)*/
1652 		GF_IPMPX_TRUSTED_TOOL_TAG = 0xA1,
1653 		GF_IPMPX_TRUST_SPECIFICATION_TAG = 0xA2,
1654 		/*emulate algo descriptors as base IPMP classes for parsing...*/
1655 		GF_IPMPX_ALGORITHM_DESCRIPTOR_TAG = 0xA3,
1656 		GF_IPMPX_KEY_DESCRIPTOR_TAG = 0xA4,
1657 		GF_IPMPX_PARAM_DESCRIPTOR_ITEM_TAG = 0xA5,
1658 		GF_IPMPX_SEL_ENC_BUFFER_TAG = 0xA6,
1659 		GF_IPMPX_SEL_ENC_FIELD_TAG = 0xA7
1660 	};
1661 
1662 	typedef char GF_IPMPX_Date[5];
1663 
1664 
1665 #define GF_IPMPX_DATA_BASE	\
1666 	u8 tag;	\
1667 	u8 Version;	\
1668 	u8 dataID;	\
1669 
1670 	/*! Base IPMPX data*/
1671 	typedef struct
1672 	{
1673 		GF_IPMPX_DATA_BASE
1674 	} GF_IPMPX_Data;
1675 
1676 	/*! IPMPX Init Authentiactaion data*/
1677 	typedef struct
1678 	{
1679 		GF_IPMPX_DATA_BASE
1680 			u32 Context;
1681 		u8 AuthType;
1682 	} GF_IPMPX_InitAuthentication;
1683 
1684 	/*! IPMPX Trust Specification data
1685 	NOT a real DATA, only used as data for parsing
1686 	*/
1687 	typedef struct
1688 	{
1689 		GF_IPMPX_DATA_BASE
1690 			GF_IPMPX_Date startDate;
1691 		u8 attackerProfile;
1692 		u32 trustedDuration;
1693 		GF_IPMPX_ByteArray	*CCTrustMetadata;
1694 	} GF_IPMPX_TrustSpecification;
1695 
1696 	/*! IPMPX Trusted Tool data
1697 	NOT a real DATA, only used as data for parsing
1698 	*/
1699 	typedef struct
1700 	{
1701 		GF_IPMPX_DATA_BASE
1702 			bin128 toolID;
1703 		GF_IPMPX_Date AuditDate;
1704 		GF_List *trustSpecifications;
1705 	} GF_IPMPX_TrustedTool;
1706 
1707 	/*! IPMPX Trust Security Metadata data
1708 	*/
1709 	typedef struct _ipmpx_TrustSecurityMetadata
1710 	{
1711 		GF_IPMPX_DATA_BASE
1712 			GF_List *TrustedTools;
1713 	} GF_IPMPX_TrustSecurityMetadata;
1714 
1715 
1716 	/*! IPMPX Mutual Authentication data
1717 	*/
1718 	typedef struct
1719 	{
1720 		GF_IPMPX_DATA_BASE
1721 			Bool failedNegotiation;
1722 
1723 		GF_List *candidateAlgorithms;
1724 		GF_List *agreedAlgorithms;
1725 		GF_IPMPX_ByteArray *AuthenticationData;
1726 
1727 		/*inclAuthCodes will be set if any of the members is set (cf spec...)*/
1728 		u32 certType;
1729 		/*GF_IPMPX_ByteArray list*/
1730 		GF_List *certificates;
1731 		GF_IPMPX_AUTH_KeyDescriptor *publicKey;
1732 		GF_IPMPX_ByteArray *opaque;
1733 		GF_IPMPX_TrustSecurityMetadata *trustData;
1734 		GF_IPMPX_ByteArray *authCodes;
1735 	} GF_IPMPX_MutualAuthentication;
1736 
1737 	/*! IPMPX Secure Container data
1738 	*/
1739 	typedef struct
1740 	{
1741 		GF_IPMPX_DATA_BASE
1742 			/*if set MAC is part of the encrypted data*/
1743 			Bool isMACEncrypted;
1744 
1745 		GF_IPMPX_ByteArray *encryptedData;
1746 		GF_IPMPX_Data *protectedMsg;
1747 		GF_IPMPX_ByteArray *MAC;
1748 	} GF_IPMPX_SecureContainer;
1749 
1750 	/*! IPMPX Tool Response container
1751 	*/
1752 	typedef struct
1753 	{
1754 		GF_List *ipmp_tools;
1755 	} GF_IPMPX_GetToolsResponse;
1756 
1757 	/*! IPMPX Parametric Description Item data
1758 	*/
1759 	typedef struct
1760 	{
1761 		GF_IPMPX_DATA_BASE
1762 			GF_IPMPX_ByteArray	*main_class;
1763 		GF_IPMPX_ByteArray	*subClass;
1764 		GF_IPMPX_ByteArray	*typeData;
1765 		GF_IPMPX_ByteArray	*type;
1766 		GF_IPMPX_ByteArray	*addedData;
1767 	} GF_IPMPX_ParametricDescriptionItem;
1768 
1769 	/*! IPMPX Parametric Description data
1770 	*/
1771 	typedef struct _tagIPMPXParamDesc
1772 	{
1773 		GF_IPMPX_DATA_BASE
1774 			GF_IPMPX_ByteArray *descriptionComment;
1775 		u8 majorVersion;
1776 		u8 minorVersion;
1777 		/*list of GF_IPMPX_ParametricDescriptionItem*/
1778 		GF_List *descriptions;
1779 	} GF_IPMPX_ParametricDescription;
1780 
1781 	/*! IPMPX Tool Capability Query data
1782 	*/
1783 	typedef struct
1784 	{
1785 		GF_IPMPX_DATA_BASE
1786 			GF_IPMPX_ParametricDescription *description;
1787 	} GF_IPMPX_ToolParamCapabilitiesQuery;
1788 
1789 	/*! IPMPX Tool Capability Response data
1790 	*/
1791 	typedef struct
1792 	{
1793 		GF_IPMPX_DATA_BASE
1794 			Bool capabilitiesSupported;
1795 	} GF_IPMPX_ToolParamCapabilitiesResponse;
1796 
1797 
1798 	/*! IPMPX Connected Tool data
1799 	*/
1800 	typedef struct
1801 	{
1802 		GF_IPMPX_DATA_BASE
1803 			GF_IPMP_Descriptor *toolDescriptor;
1804 	} GF_IPMPX_ConnectTool;
1805 
1806 	/*! IPMPX Disconnected Tool data
1807 	*/
1808 	typedef struct
1809 	{
1810 		GF_IPMPX_DATA_BASE
1811 			u32 IPMP_ToolContextID;
1812 	} GF_IPMPX_DisconnectTool;
1813 
1814 
1815 	/*! IPMPX Tool Context ID query data
1816 	*/
1817 	typedef struct
1818 	{
1819 		GF_IPMPX_DATA_BASE
1820 			u8 scope;
1821 		u16 IPMP_DescriptorIDEx;
1822 	} GF_IPMPX_GetToolContext;
1823 
1824 
1825 	/*! IPMPX Get Tool response data
1826 	*/
1827 	typedef struct
1828 	{
1829 		GF_IPMPX_DATA_BASE
1830 			u16 OD_ID;
1831 		u16 ESD_ID;
1832 		u32 IPMP_ToolContextID;
1833 	} GF_IPMPX_GetToolContextResponse;
1834 
1835 	/*! GF_IPMPX_LISTEN_Types*/
1836 	typedef enum
1837 	{
1838 		GF_IPMPX_LISTEN_CONNECTED = 0x00,
1839 		GF_IPMPX_LISTEN_CONNECTIONFAILED = 0x01,
1840 		GF_IPMPX_LISTEN_DISCONNECTED = 0x02,
1841 		GF_IPMPX_LISTEN_DISCONNECTIONFAILED = 0x03,
1842 		GF_IPMPX_LISTEN_WATERMARKDETECTED = 0x04
1843 	} GF_IPMPX_ListenType;
1844 
1845 	/*! IPMPX Add Tool Listener data
1846 	*/
1847 	typedef struct
1848 	{
1849 		GF_IPMPX_DATA_BASE
1850 			u8 scope;
1851 		/*events to listen to*/
1852 		u8 eventTypeCount;
1853 		GF_IPMPX_ListenType eventType[10];
1854 	} GF_IPMPX_AddToolNotificationListener;
1855 
1856 	/*! IPMPX Remove Tool Listener data
1857 	*/
1858 	typedef struct
1859 	{
1860 		GF_IPMPX_DATA_BASE
1861 			u8 eventTypeCount;
1862 		GF_IPMPX_ListenType eventType[10];
1863 	} GF_IPMPX_RemoveToolNotificationListener;
1864 
1865 	/*! IPMPX Tool Notify Event data
1866 	*/
1867 	typedef struct
1868 	{
1869 		GF_IPMPX_DATA_BASE
1870 			u16 OD_ID;
1871 		u16 ESD_ID;
1872 		u8 eventType;
1873 		u32 IPMP_ToolContextID;
1874 	} GF_IPMPX_NotifyToolEvent;
1875 
1876 	/*! IPMPX Can Process data
1877 	*/
1878 	typedef struct
1879 	{
1880 		GF_IPMPX_DATA_BASE
1881 			Bool canProcess;
1882 	} GF_IPMPX_CanProcess;
1883 
1884 	/*! IPMPX Opaque Data container data
1885 	*/
1886 	typedef struct
1887 	{
1888 		GF_IPMPX_DATA_BASE
1889 			GF_IPMPX_ByteArray *opaqueData;
1890 	} GF_IPMPX_OpaqueData;
1891 
1892 
1893 	/*! IPMPX Key data
1894 	*/
1895 	typedef struct
1896 	{
1897 		GF_IPMPX_DATA_BASE
1898 			GF_IPMPX_ByteArray *keyBody;
1899 		/*flags meaning
1900 		hasStartDTS = 1;
1901 		hasStartPacketID = 1<<1;
1902 		hasExpireDTS = 1<<2;
1903 		hasExpirePacketID = 1<<3
1904 		*/
1905 		u32 flags;
1906 
1907 		u64 startDTS;
1908 		u32 startPacketID;
1909 		u64 expireDTS;
1910 		u32 expirePacketID;
1911 		GF_IPMPX_ByteArray *OpaqueData;
1912 	} GF_IPMPX_KeyData;
1913 
1914 	/*! IPMPX Rights data
1915 	*/
1916 	typedef struct
1917 	{
1918 		GF_IPMPX_DATA_BASE
1919 			GF_IPMPX_ByteArray *rightsInfo;
1920 	} GF_IPMPX_RightsData;
1921 
1922 
1923 	/*! IPMPX Selective Encryption Buffer data
1924 	not a real GF_IPMPX_Data in spec, but emulated as if for parsing
1925 	*/
1926 	typedef struct
1927 	{
1928 		GF_IPMPX_DATA_BASE
1929 			bin128 cipher_Id;
1930 		u8 syncBoundary;
1931 		/*block mode if stream cypher info is NULL*/
1932 		u8 mode;
1933 		u16 blockSize;
1934 		u16 keySize;
1935 		GF_IPMPX_ByteArray *Stream_Cipher_Specific_Init_Info;
1936 	} GF_IPMPX_SelEncBuffer;
1937 
1938 	/*! IPMPX Selective Encryption Field data
1939 	not a real GF_IPMPX_Data in spec, but emulated as if for parsing
1940 	*/
1941 	typedef struct
1942 	{
1943 		GF_IPMPX_DATA_BASE
1944 			u8 field_Id;
1945 		u8 field_Scope;
1946 		u8 buf;
1947 
1948 		u16 mappingTableSize;
1949 		u16 *mappingTable;
1950 		GF_IPMPX_ByteArray *shuffleSpecificInfo;
1951 	} GF_IPMPX_SelEncField;
1952 
1953 
1954 	/*! IPMPX mediaTypeExtension*/
1955 	enum
1956 	{
1957 		GF_IPMPX_SE_MT_ISO_IEC = 0x00,
1958 		GF_IPMPX_SE_MT_ITU = 0x01
1959 		/*the rest is reserved or forbidden*/
1960 	};
1961 
1962 	/*! IPMPX compliance*/
1963 	enum
1964 	{
1965 		GF_IPMPX_SE_COMP_FULLY = 0x00,
1966 		GF_IPMPX_SE_COMP_VIDEO_PACKETS = 0x01,
1967 		GF_IPMPX_SE_COMP_VIDEO_VOP = 0x02,
1968 		GF_IPMPX_SE_COMP_VIDEO_NONE = 0x03,
1969 		GF_IPMPX_SE_COMP_VIDEO_GOB = 0x04,
1970 		/*0x05-2F	ISO Reserved for video*/
1971 		GF_IPMPX_SE_COMP_AAC_DF = 0x30,
1972 		GF_IPMPX_SE_COMP_AAC_NONE = 0x31
1973 		/*
1974 		0x32 -  0x5F	ISO Reserved for audio
1975 		0x60 - 0xCF	ISO Reserved
1976 		0xD0 - 0xFE	User Defined
1977 		0xFF	Forbidden
1978 		*/
1979 	};
1980 
1981 	/*! IPMPX syncBoundary*/
1982 	enum
1983 	{
1984 		GF_IPMPX_SE_SYNC_VID7EO_PACKETS = 0x00,
1985 		GF_IPMPX_SE_SYNC_VIDEO_VOP = 0x01,
1986 		GF_IPMPX_SE_SYNC_VIDEO_GOV = 0x02,
1987 		/*0x03-2F	ISO Reserved for video,*/
1988 		GF_IPMPX_SE_SYNC_AAC_DF = 0x30
1989 		/*0x31 -  0x5F	ISO Reserved for audio
1990 		0x60 - 0xCF	ISO Reserved
1991 		0xD0 - 0xFE	User Defined
1992 		0xFF	Forbidden
1993 		*/
1994 	};
1995 
1996 	/*! IPMPX field_Id for selective encryption*/
1997 	enum
1998 	{
1999 		GF_IPMPX_SE_FID_VIDEO_MV = 0x00,
2000 		GF_IPMPX_SE_FID_VIDEO_DC = 0x01,
2001 		GF_IPMPX_SE_FID_VIDEO_DCT_SIGN = 0x02,
2002 		GF_IPMPX_SE_FID_VIDEO_DQUANT = 0x03,
2003 		GF_IPMPX_SE_FID_VIDEO_DCT_COEF = 0x04,
2004 		GF_IPMPX_SE_FID_VIDEO_ALL = 0x05,
2005 		/*0x06-2F	ISO Reserved for video*/
2006 		GF_IPMPX_SE_FID_AAC_SIGN = 0x30,
2007 		GF_IPMPX_SE_FID_AAC_CODEWORDS = 0x31,
2008 		GF_IPMPX_SE_FID_AAC_SCALE = 0x32
2009 		/*0x32 -  0x5F	ISO Reserved for audio
2010 		0x60 - 0xCF	ISO Reserved
2011 		0xD0 - 0xFE	User Defined
2012 		0xFF	Forbidden*/
2013 	};
2014 
2015 
2016 	/*! IPMPX Selective Encryption Init data
2017 	*/
2018 	typedef struct
2019 	{
2020 		GF_IPMPX_DATA_BASE
2021 			u8 mediaTypeExtension;
2022 		u8 mediaTypeIndication;
2023 		u8 profileLevelIndication;
2024 		u8 compliance;
2025 
2026 		GF_List *SelEncBuffer;
2027 
2028 		GF_List *SelEncFields;
2029 
2030 		u16 RLE_DataLength;
2031 		u16 *RLE_Data;
2032 	} GF_IPMPX_SelectiveDecryptionInit;
2033 
2034 
2035 	/*! IPMPX watermark init ops*/
2036 	enum
2037 	{
2038 		GF_IPMPX_WM_INSERT = 0,
2039 		GF_IPMPX_WM_EXTRACT = 1,
2040 		GF_IPMPX_WM_REMARK = 2,
2041 		GF_IPMPX_WM_DETECT_COMPRESSION = 3
2042 	};
2043 
2044 	/*! IPMPX Watermark Init data
2045 	used for both audio and video WM init
2046 	*/
2047 	typedef struct
2048 	{
2049 		GF_IPMPX_DATA_BASE
2050 			/*
2051 			for audio: PCM defined (0x01) and all audio objectTypeIndications
2052 			for video: YUV defined (0x01) and all visual objectTypeIndications
2053 			*/
2054 			u8 inputFormat;
2055 		u8 requiredOp;
2056 
2057 		/*valid for audio WM, inputFormat=0x01*/
2058 		u8 nChannels;
2059 		u8 bitPerSample;
2060 		u32 frequency;
2061 
2062 		/*valid for video WM, inputFormat=0x01*/
2063 		u16 frame_horizontal_size;
2064 		u16 frame_vertical_size;
2065 		u8 chroma_format;
2066 
2067 		u32 wmPayloadLen;
2068 		char *wmPayload;
2069 
2070 		u16 wmRecipientId;
2071 
2072 		u32 opaqueDataSize;
2073 		char *opaqueData;
2074 	} GF_IPMPX_WatermarkingInit;
2075 
2076 
2077 
2078 	/*! IPMPX Watermark status*/
2079 	enum
2080 	{
2081 		GF_IPMPX_WM_PAYLOAD = 0,
2082 		GF_IPMPX_WM_NOPAYLOAD = 1,
2083 		GF_IPMPX_WM_NONE = 2,
2084 		GF_IPMPX_WM_UNKNOWN = 3
2085 	};
2086 
2087 	/*! IPMPX compression status*/
2088 	enum
2089 	{
2090 		GF_IPMPX_WM_COMPRESSION = 0,
2091 		GF_IPMPX_WM_NO_COMPRESSION = 1,
2092 		GF_IPMPX_WM_COMPRESSION_UNKNOWN = 2
2093 	};
2094 
2095 	/*! IPMPX Send Watermark data
2096 	*/
2097 	typedef struct
2098 	{
2099 		GF_IPMPX_DATA_BASE
2100 			u8 wm_status;
2101 		u8 compression_status;
2102 		/*if payload is set, status is FORCED to AUDIO_GF_IPMPX_WM_PAYLOAD*/
2103 		GF_IPMPX_ByteArray *payload;
2104 		GF_IPMPX_ByteArray *opaqueData;
2105 	} GF_IPMPX_SendWatermark;
2106 
2107 
2108 	/*! IPMPX Tool API config data
2109 	*/
2110 	typedef struct
2111 	{
2112 		GF_IPMPX_DATA_BASE
2113 			/*GPAC only supports non-0 IDs*/
2114 			u32 Instantiation_API_ID;
2115 		u32 Messaging_API_ID;
2116 		GF_IPMPX_ByteArray *opaqueData;
2117 	} GF_IPMPX_ToolAPI_Config;
2118 
2119 	/*! IPMPX ISMACryp data
2120 	*/
2121 	typedef struct
2122 	{
2123 		GF_IPMPX_DATA_BASE
2124 			u8 cryptoSuite;
2125 		u8 IV_length;
2126 		Bool use_selective_encryption;
2127 		u8 key_indicator_length;
2128 	} GF_IPMPX_ISMACryp;
2129 
2130 
2131 	/* constructor */
2132 	GF_IPMPX_Data *gf_ipmpx_data_new(u8 tag);
2133 	/* destructor */
2134 	void gf_ipmpx_data_del(GF_IPMPX_Data *p);
2135 
2136 	/* parse from bitstream */
2137 	GF_Err gf_ipmpx_data_parse(GF_BitStream *bs, GF_IPMPX_Data **out_data);
2138 	/*! get IPMP_Data contained size (eg without tag & sizeofinstance)*/
2139 	u32 gf_ipmpx_data_size(GF_IPMPX_Data *p);
2140 	/*! get fulml IPMP_Data encoded size (eg with tag & sizeofinstance)*/
2141 	u32 gf_ipmpx_data_full_size(GF_IPMPX_Data *p);
2142 	/*! writes IPMP_Data to buffer*/
2143 	GF_Err gf_ipmpx_data_write(GF_BitStream *bs, GF_IPMPX_Data *_p);
2144 
2145 	/*! returns GF_IPMPX_Tag based on name*/
2146 	u8 gf_ipmpx_get_tag(char *dataName);
2147 	/*! return values: cf above */
2148 	u32 gf_ipmpx_get_field_type(GF_IPMPX_Data *p, char *fieldName);
2149 	GF_Err gf_ipmpx_set_field(GF_IPMPX_Data *desc, char *fieldName, char *val);
2150 	/*! assign subdata*/
2151 	GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *desc, char *fieldName, GF_IPMPX_Data *subdesc);
2152 	/*! assign bytearray*/
2153 	GF_Err gf_ipmpx_set_byte_array(GF_IPMPX_Data *p, char *field, char *str);
2154 
2155 	/*! ipmpx dumper*/
2156 	GF_Err gf_ipmpx_dump_data(GF_IPMPX_Data *_p, FILE *trace, u32 indent, Bool XMTDump);
2157 
2158 
2159 #endif /*GPAC_MINIMAL_ODF*/
2160 
2161 	/*! @} */
2162 
2163 #ifdef __cplusplus
2164 }
2165 #endif
2166 
2167 #endif	/*_GF_MPEG4_ODF_H_*/
2168