GF_Err set_file_udta(GF_ISOFile *dest, u32 tracknum, u32 udta_type, char *src, Bool is_box_array, Bool is_string)
{
	u8 *data = NULL;
	GF_Err res = GF_OK;
	u32 size;
	bin128 uuid;
	memset(uuid, 0 , 16);

	if (!udta_type && !is_box_array) return GF_BAD_PARAM;

	if (!src || !strlen(src)) {
		GF_Err e = gf_isom_remove_user_data(dest, tracknum, udta_type, uuid);
		if (e==GF_EOS) {
			e = GF_OK;
			M4_LOG(GF_LOG_WARNING, ("No track.udta found, ignoring\n"));
		}
		return e;
	}

#ifndef GPAC_DISABLE_CORE_TOOLS
	if (!strnicmp(src, "base64", 6)) {
		src += 7;
		size = (u32) strlen(src);
		data = gf_malloc(sizeof(char) * size);
		size = gf_base64_decode((u8 *)src, size, data, size);
	} else
#endif
	if (is_string) {
		data = (u8 *) src;
		size = (u32) strlen(src)+1;
		is_box_array = 0;
	} else {
		GF_Err e = gf_file_load_data(src, (u8 **) &data, &size);
		if (e) return e;
	}

	if (size && data) {
		if (is_box_array) {
			res = gf_isom_add_user_data_boxes(dest, tracknum, data, size);
		} else {
			res = gf_isom_add_user_data(dest, tracknum, udta_type, uuid, data, size);
		}
		if (!is_string)
			gf_free(data);
	}
	return res;
}
GF_Err set_file_udta(GF_ISOFile *dest, u32 tracknum, u32 udta_type, char *src, Bool is_box_array, Bool is_string)
{
	u8 *data = NULL;
	GF_Err res = GF_OK;
	u32 size;
	bin128 uuid;
	memset(uuid, 0 , 16);

	if (!udta_type && !is_box_array) return GF_BAD_PARAM;

	if (!src || !strlen(src)) {
		GF_Err e = gf_isom_remove_user_data(dest, tracknum, udta_type, uuid);
		if (e==GF_EOS) {
			e = GF_OK;
			M4_LOG(GF_LOG_WARNING, ("No track.udta found, ignoring\n"));
		}
		return e;
	}

#ifndef GPAC_DISABLE_CORE_TOOLS
	if (!strnicmp(src, "base64", 6)) {
		src += 7;
		size = (u32) strlen(src);
		data = gf_malloc(sizeof(char) * size);
		size = gf_base64_decode((u8 *)src, size, data, size);
	} else
#endif
	if (is_string) {
		data = (u8 *) src;
		size = (u32) strlen(src)+1;
		is_box_array = 0;
	} else {
		GF_Err e = gf_file_load_data(src, (u8 **) &data, &size);
		if (e) return e;
	}

	if (size && data) {
		if (is_box_array) {
			res = gf_isom_add_user_data_boxes(dest, tracknum, data, size);
		} else {
			res = gf_isom_add_user_data(dest, tracknum, udta_type, uuid, data, size);
		}
		if (!is_string)
			gf_free(data);
	}
	return res;
}