GF_Descriptor *gf_odf_create_descriptor(u8 tag)
{
	GF_Descriptor *desc;

	switch (tag) {
	case GF_ODF_IOD_TAG:
		return gf_odf_new_iod();
	case GF_ODF_OD_TAG:
		return gf_odf_new_od();
	case GF_ODF_ESD_TAG:
		return gf_odf_new_esd();
	case GF_ODF_DCD_TAG:
		return gf_odf_new_dcd();
	case GF_ODF_SLC_TAG:
		//default : we create it without any predefinition...
		return gf_odf_new_slc(0);
	case GF_ODF_MUXINFO_TAG:
		return gf_odf_new_muxinfo();
	case GF_ODF_BIFS_CFG_TAG:
		return gf_odf_new_bifs_cfg();
	case GF_ODF_UI_CFG_TAG:
		return gf_odf_new_ui_cfg();
	case GF_ODF_TEXT_CFG_TAG:
		return gf_odf_new_text_cfg();
	case GF_ODF_TX3G_TAG:
		return gf_odf_new_tx3g();
	case GF_ODF_ELEM_MASK_TAG:
		return gf_odf_New_ElemMask();
	case GF_ODF_LASER_CFG_TAG:
		return gf_odf_new_laser_cfg();

	case GF_ODF_DSI_TAG:
		desc = gf_odf_new_default();
		if (!desc) return desc;
		desc->tag = GF_ODF_DSI_TAG;
		return desc;

	case GF_ODF_AUX_VIDEO_DATA:
		return gf_odf_new_auxvid();

	case GF_ODF_SEGMENT_TAG:
		return gf_odf_new_segment();

	//File Format Specific
	case GF_ODF_ISOM_IOD_TAG:
		return gf_odf_new_isom_iod();
	case GF_ODF_ISOM_OD_TAG:
		return gf_odf_new_isom_od();
	case GF_ODF_ESD_INC_TAG:
		return gf_odf_new_esd_inc();
	case GF_ODF_ESD_REF_TAG:
		return gf_odf_new_esd_ref();
	case GF_ODF_LANG_TAG:
		return gf_odf_new_lang();
	case GF_ODF_GPAC_LANG:
		desc = gf_odf_new_lang();
		if (desc) desc->tag = GF_ODF_GPAC_LANG;
		return desc;

#ifndef GPAC_MINIMAL_ODF
	case GF_ODF_MEDIATIME_TAG:
		return gf_odf_new_mediatime();
	case GF_ODF_CI_TAG:
		return gf_odf_new_ci();
	case GF_ODF_SCI_TAG:
		return gf_odf_new_sup_cid();
	case GF_ODF_IPI_PTR_TAG:
		return gf_odf_new_ipi_ptr();
	//special case for the file format
	case GF_ODF_ISOM_IPI_PTR_TAG:
		desc = gf_odf_new_ipi_ptr();
		if (!desc) return desc;
		desc->tag = GF_ODF_ISOM_IPI_PTR_TAG;
		return desc;

	case GF_ODF_IPMP_PTR_TAG:
		return gf_odf_new_ipmp_ptr();
	case GF_ODF_IPMP_TAG:
		return gf_odf_new_ipmp();
	case GF_ODF_QOS_TAG:
		return gf_odf_new_qos();
	case GF_ODF_REG_TAG:
		return gf_odf_new_reg();
	case GF_ODF_CC_TAG:
		return gf_odf_new_cc();
	case GF_ODF_KW_TAG:
		return gf_odf_new_kw();
	case GF_ODF_RATING_TAG:
		return gf_odf_new_rating();
	case GF_ODF_SHORT_TEXT_TAG:
		return gf_odf_new_short_text();
	case GF_ODF_TEXT_TAG:
		return gf_odf_new_exp_text();
	case GF_ODF_CC_NAME_TAG:
		return gf_odf_new_cc_name();
	case GF_ODF_CC_DATE_TAG:
		return gf_odf_new_cc_date();
	case GF_ODF_OCI_NAME_TAG:
		return gf_odf_new_oci_name();
	case GF_ODF_OCI_DATE_TAG:
		return gf_odf_new_oci_date();
	case GF_ODF_SMPTE_TAG:
		return gf_odf_new_smpte_camera();
	case GF_ODF_EXT_PL_TAG:
		return gf_odf_new_pl_ext();
	case GF_ODF_PL_IDX_TAG:
		return gf_odf_new_pl_idx();

	case GF_ODF_IPMP_TL_TAG:
		return gf_odf_new_ipmp_tool_list();
	case GF_ODF_IPMP_TOOL_TAG:
		return gf_odf_new_ipmp_tool();

	case 0:
	case 0xFF:
		return NULL;
#endif /*GPAC_MINIMAL_ODF*/
	default:
		//ISO Reserved
		if ( (tag >= GF_ODF_ISO_RES_BEGIN_TAG) &&
		        (tag <= GF_ODF_ISO_RES_END_TAG) ) {
			return NULL;
		}
		desc = gf_odf_new_default();
		if (!desc) return desc;
		desc->tag = tag;
		return desc;
	}
}
GF_Descriptor *gf_odf_create_descriptor(u8 tag)
{
	GF_Descriptor *desc;

	switch (tag) {
	case GF_ODF_IOD_TAG:
		return gf_odf_new_iod();
	case GF_ODF_OD_TAG:
		return gf_odf_new_od();
	case GF_ODF_ESD_TAG:
		return gf_odf_new_esd();
	case GF_ODF_DCD_TAG:
		return gf_odf_new_dcd();
	case GF_ODF_SLC_TAG:
		 
		return gf_odf_new_slc(0);
	case GF_ODF_MUXINFO_TAG:
		return gf_odf_new_muxinfo();
	case GF_ODF_BIFS_CFG_TAG:
		return gf_odf_new_bifs_cfg();
	case GF_ODF_UI_CFG_TAG:
		return gf_odf_new_ui_cfg();
	case GF_ODF_TEXT_CFG_TAG:
		return gf_odf_new_text_cfg();
	case GF_ODF_TX3G_TAG:
		return gf_odf_new_tx3g();
	case GF_ODF_ELEM_MASK_TAG:
		return gf_odf_New_ElemMask();
	case GF_ODF_LASER_CFG_TAG:
		return gf_odf_new_laser_cfg();

	case GF_ODF_DSI_TAG:
		desc = gf_odf_new_default();
		if (!desc) return desc;
		desc->tag = GF_ODF_DSI_TAG;
		return desc;

	case GF_ODF_AUX_VIDEO_DATA:
		return gf_odf_new_auxvid();

	case GF_ODF_SEGMENT_TAG:
		return gf_odf_new_segment();

	 
	case GF_ODF_ISOM_IOD_TAG:
		return gf_odf_new_isom_iod();
	case GF_ODF_ISOM_OD_TAG:
		return gf_odf_new_isom_od();
	case GF_ODF_ESD_INC_TAG:
		return gf_odf_new_esd_inc();
	case GF_ODF_ESD_REF_TAG:
		return gf_odf_new_esd_ref();
	case GF_ODF_LANG_TAG:
		return gf_odf_new_lang();
	case GF_ODF_GPAC_LANG:
		desc = gf_odf_new_lang();
		if (desc) desc->tag = GF_ODF_GPAC_LANG;
		return desc;

#ifndef GPAC_MINIMAL_ODF
	case GF_ODF_MEDIATIME_TAG:
		return gf_odf_new_mediatime();
	case GF_ODF_CI_TAG:
		return gf_odf_new_ci();
	case GF_ODF_SCI_TAG:
		return gf_odf_new_sup_cid();
	case GF_ODF_IPI_PTR_TAG:
		return gf_odf_new_ipi_ptr();
	 
	case GF_ODF_ISOM_IPI_PTR_TAG:
		desc = gf_odf_new_ipi_ptr();
		if (!desc) return desc;
		desc->tag = GF_ODF_ISOM_IPI_PTR_TAG;
		return desc;

	case GF_ODF_IPMP_PTR_TAG:
		return gf_odf_new_ipmp_ptr();
	case GF_ODF_IPMP_TAG:
		return gf_odf_new_ipmp();
	case GF_ODF_QOS_TAG:
		return gf_odf_new_qos();
	case GF_ODF_REG_TAG:
		return gf_odf_new_reg();
	case GF_ODF_CC_TAG:
		return gf_odf_new_cc();
	case GF_ODF_KW_TAG:
		return gf_odf_new_kw();
	case GF_ODF_RATING_TAG:
		return gf_odf_new_rating();
	case GF_ODF_SHORT_TEXT_TAG:
		return gf_odf_new_short_text();
	case GF_ODF_TEXT_TAG:
		return gf_odf_new_exp_text();
	case GF_ODF_CC_NAME_TAG:
		return gf_odf_new_cc_name();
	case GF_ODF_CC_DATE_TAG:
		return gf_odf_new_cc_date();
	case GF_ODF_OCI_NAME_TAG:
		return gf_odf_new_oci_name();
	case GF_ODF_OCI_DATE_TAG:
		return gf_odf_new_oci_date();
	case GF_ODF_SMPTE_TAG:
		return gf_odf_new_smpte_camera();
	case GF_ODF_EXT_PL_TAG:
		return gf_odf_new_pl_ext();
	case GF_ODF_PL_IDX_TAG:
		return gf_odf_new_pl_idx();

	case GF_ODF_IPMP_TL_TAG:
		return gf_odf_new_ipmp_tool_list();
	case GF_ODF_IPMP_TOOL_TAG:
		return gf_odf_new_ipmp_tool();

	case 0:
	case 0xFF:
		return NULL;
#endif  
	default:
		 
		if ( (tag >= GF_ODF_ISO_RES_BEGIN_TAG) &&
		        (tag <= GF_ODF_ISO_RES_END_TAG) ) {
			return NULL;
		}
		desc = gf_odf_new_default();
		if (!desc) return desc;
		desc->tag = tag;
		return desc;
	}
}