	if (!ctx->mpd->supplemental_properties)
		ctx->mpd->supplemental_properties = gf_list_new();

	gf_list_add(ctx->mpd->supplemental_properties, d);
}


static GF_Err dasher_update_mpd(GF_DasherCtx *ctx)
{
	char profiles_string[GF_MAX_PATH];
	GF_XMLAttribute *cenc_att = NULL;
	GF_XMLAttribute *xlink_att = NULL;

	u32 i, count=gf_list_count(ctx->mpd->x_attributes);
	for (i=0; i<count; i++) {
		GF_XMLAttribute * att = gf_list_get(ctx->mpd->x_attributes, i);
		if (!strcmp(att->name, "xmlns:cenc")) cenc_att = att;
		if (!strcmp(att->name, "xmlns:xlink")) xlink_att = att;

	}
	if (ctx->dmode==GF_MPD_TYPE_DYNAMIC) {
		ctx->mpd->type = GF_MPD_TYPE_DYNAMIC;
	} else {
		ctx->mpd->type = GF_MPD_TYPE_STATIC;
		ctx->mpd->availabilityStartTime = 0;
	}

	Bool is_m2ts = (ctx->muxtype==DASHER_MUX_TS) ? GF_TRUE : GF_FALSE;
	if (ctx->profile==GF_DASH_PROFILE_LIVE) {
		if (ctx->use_xlink && !is_m2ts) {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-segext-live:2014");
		} else {
			sprintf(profiles_string, "urn:mpeg:dash:profile:%s:2011", is_m2ts ? "mp2t-simple" : "isoff-live");
		}
	} else if (ctx->profile==GF_DASH_PROFILE_ONDEMAND) {
		if (ctx->use_xlink) {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-segext-on-demand:2014");
		} else {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-on-demand:2011");
		}
	} else if (ctx->profile==GF_DASH_PROFILE_MAIN) {
		sprintf(profiles_string, "urn:mpeg:dash:profile:%s:2011", is_m2ts ? "mp2t-main" : "isoff-main");
	} else if (ctx->profile==GF_DASH_PROFILE_HBBTV_1_5_ISOBMF_LIVE) {
		strcpy(profiles_string, "urn:hbbtv:dash:profile:isoff-live:2012");
	} else if (ctx->profile==GF_DASH_PROFILE_AVC264_LIVE) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash264");
	} else if (ctx->profile==GF_DASH_PROFILE_AVC264_ONDEMAND) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-on-demand:2011,http://dashif.org/guidelines/dash264");
	} else if (ctx->profile==GF_DASH_PROFILE_DASHIF_LL) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-live:2011,http://www.dashif.org/guidelines/low-latency-live-v5");
	} else {
		strcpy(profiles_string, "urn:mpeg:dash:profile:full:2011");
	}

	if (ctx->cmaf) {
		const size_t offset = strlen(profiles_string);
		strncat(profiles_string+offset, ",urn:mpeg:dash:profile:cmaf:2019", GF_MAX_PATH-offset-1);
	}

	if (ctx->profX) {
		char profiles_w_ext[GF_MAX_PATH+256];
		sprintf(profiles_w_ext, "%s,%s", profiles_string, ctx->profX);
		if (ctx->mpd->profiles) gf_free(ctx->mpd->profiles);
		ctx->mpd->profiles = gf_strdup(profiles_w_ext);
	} else {
		if (ctx->mpd->profiles) gf_free(ctx->mpd->profiles);
		ctx->mpd->profiles = gf_strdup(profiles_string);
	}

	if (ctx->use_cenc && !cenc_att) {
		cenc_att = gf_xml_dom_create_attribute("xmlns:cenc", "urn:mpeg:cenc:2013");
		gf_list_add(ctx->mpd->x_attributes, cenc_att);
	}
	if (ctx->use_xlink && !xlink_att) {
		xlink_att = gf_xml_dom_create_attribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
		gf_list_add(ctx->mpd->x_attributes, xlink_att);
	}

	ctx->mpd->time_shift_buffer_depth = 0;
	ctx->mpd->minimum_update_period = 0;

	if (ctx->dmode==GF_MPD_TYPE_DYNAMIC) {
		ctx->mpd->time_shift_buffer_depth = (u32) -1;
		if (ctx->tsb>=0) ctx->mpd->time_shift_buffer_depth = (u32) (1000*ctx->tsb);
		if (ctx->spd>0) ctx->mpd->suggested_presentation_delay = ctx->spd;

		if (ctx->refresh>=0) {
			if (ctx->refresh) {
				ctx->mpd->minimum_update_period = (u32) (1000*ctx->refresh);
			} else {
				ctx->mpd->minimum_update_period = ctx->segdur.num * 1000;
				ctx->mpd->minimum_update_period /= ctx->segdur.den;
			}
		} else {
	if (!ctx->mpd->supplemental_properties)
		ctx->mpd->supplemental_properties = gf_list_new();

	gf_list_add(ctx->mpd->supplemental_properties, d);
}


static GF_Err dasher_update_mpd(GF_DasherCtx *ctx)
{
	char profiles_string[GF_MAX_PATH];
	GF_XMLAttribute *cenc_att = NULL;
	GF_XMLAttribute *xlink_att = NULL;

	u32 i, count=gf_list_count(ctx->mpd->x_attributes);
	for (i=0; i<count; i++) {
		GF_XMLAttribute * att = gf_list_get(ctx->mpd->x_attributes, i);
		if (!strcmp(att->name, "xmlns:cenc")) cenc_att = att;
		if (!strcmp(att->name, "xmlns:xlink")) xlink_att = att;

	}
	if (ctx->dmode==GF_MPD_TYPE_DYNAMIC) {
		ctx->mpd->type = GF_MPD_TYPE_DYNAMIC;
	} else {
		ctx->mpd->type = GF_MPD_TYPE_STATIC;
		ctx->mpd->availabilityStartTime = 0;
	}

	Bool is_m2ts = (ctx->muxtype==DASHER_MUX_TS) ? GF_TRUE : GF_FALSE;
	if (ctx->profile==GF_DASH_PROFILE_LIVE) {
		if (ctx->use_xlink && !is_m2ts) {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-segext-live:2014");
		} else {
			sprintf(profiles_string, "urn:mpeg:dash:profile:%s:2011", is_m2ts ? "mp2t-simple" : "isoff-live");
		}
	} else if (ctx->profile==GF_DASH_PROFILE_ONDEMAND) {
		if (ctx->use_xlink) {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-segext-on-demand:2014");
		} else {
			strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-on-demand:2011");
		}
	} else if (ctx->profile==GF_DASH_PROFILE_MAIN) {
		sprintf(profiles_string, "urn:mpeg:dash:profile:%s:2011", is_m2ts ? "mp2t-main" : "isoff-main");
	} else if (ctx->profile==GF_DASH_PROFILE_HBBTV_1_5_ISOBMF_LIVE) {
		strcpy(profiles_string, "urn:hbbtv:dash:profile:isoff-live:2012");
	} else if (ctx->profile==GF_DASH_PROFILE_AVC264_LIVE) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash264");
	} else if (ctx->profile==GF_DASH_PROFILE_AVC264_ONDEMAND) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-on-demand:2011,http://dashif.org/guidelines/dash264");
	} else if (ctx->profile==GF_DASH_PROFILE_DASHIF_LL) {
		strcpy(profiles_string, "urn:mpeg:dash:profile:isoff-live:2011,http://www.dashif.org/guidelines/low-latency-live-v5");
	} else {
		strcpy(profiles_string, "urn:mpeg:dash:profile:full:2011");
	}

	if (ctx->cmaf) {
		const size_t offset = strlen(profiles_string);
		strncat(profiles_string+offset, ",urn:mpeg:dash:profile:cmaf:2019", GF_MAX_PATH-offset-1);
	}

	if (ctx->profX) {
		char profiles_w_ext[GF_MAX_PATH+256];
		sprintf(profiles_w_ext, "%s,%s", profiles_string, ctx->profX);
		if (ctx->mpd->profiles) gf_free(ctx->mpd->profiles);
		ctx->mpd->profiles = gf_strdup(profiles_w_ext);
	} else {
		if (ctx->mpd->profiles) gf_free(ctx->mpd->profiles);
		ctx->mpd->profiles = gf_strdup(profiles_string);
	}

	if (ctx->use_cenc && !cenc_att) {
		cenc_att = gf_xml_dom_create_attribute("xmlns:cenc", "urn:mpeg:cenc:2013");
		gf_list_add(ctx->mpd->x_attributes, cenc_att);
	}
	if (ctx->use_xlink && !xlink_att) {
		xlink_att = gf_xml_dom_create_attribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
		gf_list_add(ctx->mpd->x_attributes, xlink_att);
	}

	ctx->mpd->time_shift_buffer_depth = 0;
	ctx->mpd->minimum_update_period = 0;

	if (ctx->dmode==GF_MPD_TYPE_DYNAMIC) {
		ctx->mpd->time_shift_buffer_depth = (u32) -1;
		if (ctx->tsb>=0) ctx->mpd->time_shift_buffer_depth = (u32) (1000*ctx->tsb);
		if (ctx->spd>0) ctx->mpd->suggested_presentation_delay = ctx->spd;

		if (ctx->refresh>=0) {
			if (ctx->refresh) {
				ctx->mpd->minimum_update_period = (u32) (1000*ctx->refresh);
			} else {
				ctx->mpd->minimum_update_period = ctx->segdur.num * 1000;
				ctx->mpd->minimum_update_period /= ctx->segdur.den;
			}
		} else {