			return e;
		}
	}
	return GF_OK;
}


static void dasher_finalize(GF_Filter *filter)
{
	GF_DasherCtx *ctx = gf_filter_get_udta(filter);

	while (gf_list_count(ctx->pids)) {
		GF_DashStream *ds = gf_list_pop_back(ctx->pids);
		dasher_reset_stream(filter, ds, GF_TRUE);
		if (ds->packet_queue) gf_list_del(ds->packet_queue);
		if (ds->cinfo) gf_crypt_info_del(ds->cinfo);
		gf_free(ds);
	}
	gf_list_del(ctx->pids);
	if (ctx->mpd) gf_mpd_del(ctx->mpd);

	while (gf_list_count(ctx->tpl_records)) {
		DashTemplateRecord *tr = gf_list_pop_back(ctx->tpl_records);
		gf_free(tr->tpl);
		gf_free(tr);
	}
	gf_list_del(ctx->tpl_records);

	if (ctx->next_period->period) gf_mpd_period_free(ctx->next_period->period);
	gf_list_del(ctx->current_period->streams);
			return e;
		}
	}
	return GF_OK;
}


static void dasher_finalize(GF_Filter *filter)
{
	GF_DasherCtx *ctx = gf_filter_get_udta(filter);

	while (gf_list_count(ctx->pids)) {
		GF_DashStream *ds = gf_list_pop_back(ctx->pids);
		dasher_reset_stream(filter, ds, GF_TRUE);
		if (ds->packet_queue) gf_list_del(ds->packet_queue);
		if (ds->cinfo) gf_crypt_info_del(ds->cinfo);
		gf_free(ds);
	}
	gf_list_del(ctx->pids);
	if (ctx->mpd) gf_mpd_del(ctx->mpd);

	while (gf_list_count(ctx->tpl_records)) {
		DashTemplateRecord *tr = gf_list_pop_back(ctx->tpl_records);
		gf_free(tr->tpl);
		gf_free(tr);
	}
	gf_list_del(ctx->tpl_records);

	if (ctx->next_period->period) gf_mpd_period_free(ctx->next_period->period);
	gf_list_del(ctx->current_period->streams);