			ctx->mpd->minimum_update_period = 0;
		}
	}
	dasher_check_chaining(ctx, "urn:mpeg:dash:mpd-chaining:2016", ctx->chain);
	dasher_check_chaining(ctx, "urn:mpeg:dash:fallback:2016", ctx->chain_fbk);
	return GF_OK;
}
static GF_Err dasher_setup_mpd(GF_DasherCtx *ctx)
{
	u32 i, count;
	GF_MPD_ProgramInfo *info;
	ctx->mpd = gf_mpd_new();
	ctx->mpd->xml_namespace = "urn:mpeg:dash:schema:mpd:2011";
	ctx->mpd->base_URLs = gf_list_new();
	ctx->mpd->locations = gf_list_new();
	ctx->mpd->program_infos = gf_list_new();
	ctx->mpd->periods = gf_list_new();
	//created by default because we store xmlns in it
	ctx->mpd->x_attributes = gf_list_new();
	if (ctx->buf<0) {
		s32 buf = -ctx->buf;
		ctx->mpd->min_buffer_time = (u32) ( ctx->segdur.num * 10 * buf / ctx->segdur.den); //*1000 (ms) / 100 (percent)
	} else
		ctx->mpd->min_buffer_time = ctx->buf;

	GF_SAFEALLOC(info, GF_MPD_ProgramInfo);
	if (info) {
		gf_list_add(ctx->mpd->program_infos, info);
		if (ctx->title)
			info->title = gf_strdup(ctx->title);
		else {
			char tmp[256];
			const char *name = NULL;
			if (ctx->out_path) {
				const char *url = ctx->out_path;
				if (!strncmp(ctx->out_path, "gfio://", 7)) {
					url = gf_fileio_translate_url(ctx->out_path);
					if (!url) url = "";
				}
				name = strrchr(url, '/');
				if (!name) name = strrchr(url, '\\');
				if (!name) name = url;
				else name++;
			}
			snprintf(tmp, 255, "%s generated by GPAC", name ? name : "");
			tmp[255]=0;
			info->title = gf_strdup(tmp);
		}
		if (ctx->cprt) info->copyright = gf_strdup(ctx->cprt);
		if (ctx->info) info->more_info_url = gf_strdup(ctx->info);
		else info->more_info_url = gf_strdup("http://gpac.io");
		if (ctx->source) info->source = gf_strdup(ctx->source);
		if (ctx->lang) info->lang = gf_strdup(ctx->lang);
	}

	count = ctx->location.nb_items;
	for (i=0; i<count; i++) {
		char *l = ctx->location.vals[i];
		gf_list_add(ctx->mpd->locations, gf_strdup(l));
	}
	count = ctx->base.nb_items;
	for (i=0; i<count; i++) {
		GF_MPD_BaseURL *base;
		char *b = ctx->base.vals[i];
		GF_SAFEALLOC(base, GF_MPD_BaseURL);
			ctx->mpd->minimum_update_period = 0;
		}
	}
	dasher_check_chaining(ctx, "urn:mpeg:dash:mpd-chaining:2016", ctx->chain);
	dasher_check_chaining(ctx, "urn:mpeg:dash:fallback:2016", ctx->chain_fbk);
	return GF_OK;
}
static GF_Err dasher_setup_mpd(GF_DasherCtx *ctx)
{
	u32 i, count;
	GF_MPD_ProgramInfo *info;
	ctx->mpd = gf_mpd_new();
	ctx->mpd->xml_namespace = "urn:mpeg:dash:schema:mpd:2011";
	ctx->mpd->base_URLs = gf_list_new();
	ctx->mpd->locations = gf_list_new();
	ctx->mpd->program_infos = gf_list_new();
	ctx->mpd->periods = gf_list_new();
	 
	ctx->mpd->x_attributes = gf_list_new();
	if (ctx->buf<0) {
		s32 buf = -ctx->buf;
		ctx->mpd->min_buffer_time = (u32) ( ctx->segdur.num * 10 * buf / ctx->segdur.den);  
	} else
		ctx->mpd->min_buffer_time = ctx->buf;

	GF_SAFEALLOC(info, GF_MPD_ProgramInfo);
	if (info) {
		gf_list_add(ctx->mpd->program_infos, info);
		if (ctx->title)
			info->title = gf_strdup(ctx->title);
		else {
			char tmp[256];
			const char *name = NULL;
			if (ctx->out_path) {
				const char *url = ctx->out_path;
				if (!strncmp(ctx->out_path, "gfio://", 7)) {
					url = gf_fileio_translate_url(ctx->out_path);
					if (!url) url = "";
				}
				name = strrchr(url, '/');
				if (!name) name = strrchr(url, '\\');
				if (!name) name = url;
				else name++;
			}
			snprintf(tmp, 255, "%s generated by GPAC", name ? name : "");
			tmp[255]=0;
			info->title = gf_strdup(tmp);
		}
		if (ctx->cprt) info->copyright = gf_strdup(ctx->cprt);
		if (ctx->info) info->more_info_url = gf_strdup(ctx->info);
		else info->more_info_url = gf_strdup("http://gpac.io");
		if (ctx->source) info->source = gf_strdup(ctx->source);
		if (ctx->lang) info->lang = gf_strdup(ctx->lang);
	}

	count = ctx->location.nb_items;
	for (i=0; i<count; i++) {
		char *l = ctx->location.vals[i];
		gf_list_add(ctx->mpd->locations, gf_strdup(l));
	}
	count = ctx->base.nb_items;
	for (i=0; i<count; i++) {
		GF_MPD_BaseURL *base;
		char *b = ctx->base.vals[i];
		GF_SAFEALLOC(base, GF_MPD_BaseURL);