GF_Err gf_odf_size_descriptor(GF_Descriptor *desc, u32 *outSize)
{
	switch(desc->tag) {
	case GF_ODF_IOD_TAG :
		return gf_odf_size_iod((GF_InitialObjectDescriptor *)desc, outSize);
	case GF_ODF_ESD_TAG :
		return gf_odf_size_esd((GF_ESD *)desc, outSize);
	case GF_ODF_DCD_TAG :
		return gf_odf_size_dcd((GF_DecoderConfig *)desc, outSize);
	case GF_ODF_SLC_TAG :
		return gf_odf_size_slc((GF_SLConfig *)desc, outSize);

	case GF_ODF_OD_TAG:
		return gf_odf_size_od((GF_ObjectDescriptor *)desc, outSize);
	case GF_ODF_ISOM_IOD_TAG:
		return gf_odf_size_isom_iod((GF_IsomInitialObjectDescriptor *)desc, outSize);
	case GF_ODF_ISOM_OD_TAG:
		return gf_odf_size_isom_od((GF_IsomObjectDescriptor *)desc, outSize);
	case GF_ODF_ESD_INC_TAG:
		return gf_odf_size_esd_inc((GF_ES_ID_Inc *)desc, outSize);
	case GF_ODF_ESD_REF_TAG:
		return gf_odf_size_esd_ref((GF_ES_ID_Ref *)desc, outSize);

	case GF_ODF_SEGMENT_TAG:
		return gf_odf_size_segment((GF_Segment *) desc, outSize);
	case GF_ODF_MUXINFO_TAG:
		return gf_odf_size_muxinfo((GF_MuxInfo *) desc, outSize);

	case GF_ODF_AUX_VIDEO_DATA:
		return gf_odf_size_auxvid((GF_AuxVideoDescriptor *)desc, outSize);

	case GF_ODF_LANG_TAG:
	case GF_ODF_GPAC_LANG:
		return gf_odf_size_lang((GF_Language *)desc, outSize);

#ifndef GPAC_MINIMAL_ODF
	case GF_ODF_MEDIATIME_TAG:
		return gf_odf_size_mediatime((GF_MediaTime *) desc, outSize);
	case GF_ODF_CC_TAG:
		return gf_odf_size_cc((GF_CCDescriptor *)desc, outSize);
	case GF_ODF_CC_DATE_TAG:
		return gf_odf_size_cc_date((GF_CC_Date *)desc, outSize);
	case GF_ODF_CC_NAME_TAG:
		return gf_odf_size_cc_name((GF_CC_Name *)desc, outSize);
	case GF_ODF_CI_TAG:
		return gf_odf_size_ci((GF_CIDesc *)desc, outSize);
	case GF_ODF_TEXT_TAG:
		return gf_odf_size_exp_text((GF_ExpandedTextual *)desc, outSize);
	case GF_ODF_EXT_PL_TAG:
		return gf_odf_size_pl_ext((GF_PLExt *)desc, outSize);
	case GF_ODF_IPI_PTR_TAG:
	case GF_ODF_ISOM_IPI_PTR_TAG:
		return gf_odf_size_ipi_ptr((GF_IPIPtr *)desc, outSize);
	case GF_ODF_IPMP_TAG:
		return gf_odf_size_ipmp((GF_IPMP_Descriptor *)desc, outSize);
	case GF_ODF_IPMP_PTR_TAG:
		return gf_odf_size_ipmp_ptr((GF_IPMPPtr *)desc, outSize);
	case GF_ODF_KW_TAG:
		return gf_odf_size_kw((GF_KeyWord *)desc, outSize);
	case GF_ODF_OCI_DATE_TAG:
		return gf_odf_size_oci_date((GF_OCI_Data *)desc, outSize);
	case GF_ODF_OCI_NAME_TAG:
		return gf_odf_size_oci_name((GF_OCICreators *)desc, outSize);
	case GF_ODF_PL_IDX_TAG:
		return gf_odf_size_pl_idx((GF_PL_IDX *)desc, outSize);
	case GF_ODF_QOS_TAG:
		return gf_odf_size_qos((GF_QoS_Descriptor *)desc, outSize);
	case GF_ODF_RATING_TAG:
		return gf_odf_size_rating((GF_Rating *)desc, outSize);
	case GF_ODF_REG_TAG:
		return gf_odf_size_reg((GF_Registration *)desc, outSize);
	case GF_ODF_SHORT_TEXT_TAG:
		return gf_odf_size_short_text((GF_ShortTextual *)desc, outSize);
	case GF_ODF_SMPTE_TAG:
		return gf_odf_size_smpte_camera((GF_SMPTECamera *)desc, outSize);
	case GF_ODF_SCI_TAG:
		return gf_odf_size_sup_cid((GF_SCIDesc *)desc, outSize);


	case GF_ODF_IPMP_TL_TAG:
		return gf_odf_size_ipmp_tool_list((GF_IPMP_ToolList *)desc, outSize);
	case GF_ODF_IPMP_TOOL_TAG:
		return gf_odf_size_ipmp_tool((GF_IPMP_Tool *)desc, outSize);

#endif /*GPAC_MINIMAL_ODF*/
	default:
		/*don't write out l descriptors*/
		if ((desc->tag>=GF_ODF_MUXINFO_TAG) && (desc->tag<=GF_ODF_LASER_CFG_TAG)) {
			*outSize = 0;
			return GF_OK;
		}
		return gf_odf_size_default((GF_DefaultDescriptor *)desc, outSize);
	}
	return GF_OK;
}
GF_Err gf_odf_size_descriptor(GF_Descriptor *desc, u32 *outSize)
{
	switch(desc->tag) {
	case GF_ODF_IOD_TAG :
		return gf_odf_size_iod((GF_InitialObjectDescriptor *)desc, outSize);
	case GF_ODF_ESD_TAG :
		return gf_odf_size_esd((GF_ESD *)desc, outSize);
	case GF_ODF_DCD_TAG :
		return gf_odf_size_dcd((GF_DecoderConfig *)desc, outSize);
	case GF_ODF_SLC_TAG :
		return gf_odf_size_slc((GF_SLConfig *)desc, outSize);

	case GF_ODF_OD_TAG:
		return gf_odf_size_od((GF_ObjectDescriptor *)desc, outSize);
	case GF_ODF_ISOM_IOD_TAG:
		return gf_odf_size_isom_iod((GF_IsomInitialObjectDescriptor *)desc, outSize);
	case GF_ODF_ISOM_OD_TAG:
		return gf_odf_size_isom_od((GF_IsomObjectDescriptor *)desc, outSize);
	case GF_ODF_ESD_INC_TAG:
		return gf_odf_size_esd_inc((GF_ES_ID_Inc *)desc, outSize);
	case GF_ODF_ESD_REF_TAG:
		return gf_odf_size_esd_ref((GF_ES_ID_Ref *)desc, outSize);

	case GF_ODF_SEGMENT_TAG:
		return gf_odf_size_segment((GF_Segment *) desc, outSize);
	case GF_ODF_MUXINFO_TAG:
		return gf_odf_size_muxinfo((GF_MuxInfo *) desc, outSize);

	case GF_ODF_AUX_VIDEO_DATA:
		return gf_odf_size_auxvid((GF_AuxVideoDescriptor *)desc, outSize);

	case GF_ODF_LANG_TAG:
	case GF_ODF_GPAC_LANG:
		return gf_odf_size_lang((GF_Language *)desc, outSize);

#ifndef GPAC_MINIMAL_ODF
	case GF_ODF_MEDIATIME_TAG:
		return gf_odf_size_mediatime((GF_MediaTime *) desc, outSize);
	case GF_ODF_CC_TAG:
		return gf_odf_size_cc((GF_CCDescriptor *)desc, outSize);
	case GF_ODF_CC_DATE_TAG:
		return gf_odf_size_cc_date((GF_CC_Date *)desc, outSize);
	case GF_ODF_CC_NAME_TAG:
		return gf_odf_size_cc_name((GF_CC_Name *)desc, outSize);
	case GF_ODF_CI_TAG:
		return gf_odf_size_ci((GF_CIDesc *)desc, outSize);
	case GF_ODF_TEXT_TAG:
		return gf_odf_size_exp_text((GF_ExpandedTextual *)desc, outSize);
	case GF_ODF_EXT_PL_TAG:
		return gf_odf_size_pl_ext((GF_PLExt *)desc, outSize);
	case GF_ODF_IPI_PTR_TAG:
	case GF_ODF_ISOM_IPI_PTR_TAG:
		return gf_odf_size_ipi_ptr((GF_IPIPtr *)desc, outSize);
	case GF_ODF_IPMP_TAG:
		return gf_odf_size_ipmp((GF_IPMP_Descriptor *)desc, outSize);
	case GF_ODF_IPMP_PTR_TAG:
		return gf_odf_size_ipmp_ptr((GF_IPMPPtr *)desc, outSize);
	case GF_ODF_KW_TAG:
		return gf_odf_size_kw((GF_KeyWord *)desc, outSize);
	case GF_ODF_OCI_DATE_TAG:
		return gf_odf_size_oci_date((GF_OCI_Data *)desc, outSize);
	case GF_ODF_OCI_NAME_TAG:
		return gf_odf_size_oci_name((GF_OCICreators *)desc, outSize);
	case GF_ODF_PL_IDX_TAG:
		return gf_odf_size_pl_idx((GF_PL_IDX *)desc, outSize);
	case GF_ODF_QOS_TAG:
		return gf_odf_size_qos((GF_QoS_Descriptor *)desc, outSize);
	case GF_ODF_RATING_TAG:
		return gf_odf_size_rating((GF_Rating *)desc, outSize);
	case GF_ODF_REG_TAG:
		return gf_odf_size_reg((GF_Registration *)desc, outSize);
	case GF_ODF_SHORT_TEXT_TAG:
		return gf_odf_size_short_text((GF_ShortTextual *)desc, outSize);
	case GF_ODF_SMPTE_TAG:
		return gf_odf_size_smpte_camera((GF_SMPTECamera *)desc, outSize);
	case GF_ODF_SCI_TAG:
		return gf_odf_size_sup_cid((GF_SCIDesc *)desc, outSize);


	case GF_ODF_IPMP_TL_TAG:
		return gf_odf_size_ipmp_tool_list((GF_IPMP_ToolList *)desc, outSize);
	case GF_ODF_IPMP_TOOL_TAG:
		return gf_odf_size_ipmp_tool((GF_IPMP_Tool *)desc, outSize);

#endif  
	default:
		 
		if ((desc->tag>=GF_ODF_MUXINFO_TAG) && (desc->tag<=GF_ODF_LASER_CFG_TAG)) {
			*outSize = 0;
			return GF_OK;
		}
		return gf_odf_size_default((GF_DefaultDescriptor *)desc, outSize);
	}
	return GF_OK;
}