	}

	if (ctx->def_max_seg_dur)
		ctx->mpd->max_segment_duration = 0;
	return GF_OK;
}

static void dasher_reset_stream(GF_Filter *filter, GF_DashStream *ds, Bool is_destroy)
{
	//we do not remove the destination filter, it will be removed automatically once all remove_pids are called
	//removing it explicitly will discard the upper chain and any packets not yet processed

	ds->dst_filter = NULL;
	if (ds->seg_template) gf_free(ds->seg_template);
	if (ds->idx_template) gf_free(ds->idx_template);
	if (ds->init_seg) gf_free(ds->init_seg);
	if (ds->multi_pids) gf_list_del(ds->multi_pids);
	ds->multi_pids = NULL;
	if (ds->multi_tracks) gf_list_del(ds->multi_tracks);
	ds->multi_tracks = NULL;

	if (ds->pending_segment_urls) gf_list_del(ds->pending_segment_urls);
	ds->pending_segment_urls = NULL;
	if (ds->pending_segment_states) gf_list_del(ds->pending_segment_states);
	ds->pending_segment_states = NULL;

	if (is_destroy) {
		if (ds->cues) gf_free(ds->cues);
		gf_list_del(ds->complementary_streams);
		gf_free(ds->rep_id);
		//string properties are locally copied
#define RESET_PROP_STR(_prop) \
		if (_prop) gf_free(_prop);

		RESET_PROP_STR(ds->src_url)
		RESET_PROP_STR(ds->template)
		RESET_PROP_STR(ds->lang)
		RESET_PROP_STR(ds->hls_vp_name)
		RESET_PROP_STR(ds->xlink)
		RESET_PROP_STR(ds->period_id)
		RESET_PROP_STR(ds->period_continuity_id)

#undef RESET_PROP_STR
		return;
	}
	ds->init_seg = ds->seg_template = ds->idx_template = NULL;
	ds->split_set_names = GF_FALSE;
	ds->nb_sap_3 = 0;
	ds->nb_sap_4 = 0;
	ds->pid_id = 0;
	ds->force_timescale = 0;
	ds->set = NULL;
	ds->owns_set = GF_FALSE;
	ds->rep = NULL;
	ds->muxed_base = NULL;
	ds->nb_comp = ds->nb_comp_done = 0;
	gf_list_reset(ds->complementary_streams);
	ds->inband_params = 0;
	ds->seg_start_time = 0;
	ds->seg_number = ds->startNumber;
	ds->nb_segments_purged = 0;
	ds->dur_purged = 0;
	ds->moof_sn_inc = 0;
	ds->moof_sn = 0;
	ds->seg_done = 0;
	ds->subdur_done = 0;
	if (ds->packet_queue) {
		while (gf_list_count(ds->packet_queue)) {
	}

	if (ctx->def_max_seg_dur)
		ctx->mpd->max_segment_duration = 0;
	return GF_OK;
}

static void dasher_reset_stream(GF_Filter *filter, GF_DashStream *ds, Bool is_destroy)
{
	 
	 

	ds->dst_filter = NULL;
	if (ds->seg_template) gf_free(ds->seg_template);
	if (ds->idx_template) gf_free(ds->idx_template);
	if (ds->init_seg) gf_free(ds->init_seg);
	if (ds->multi_pids) gf_list_del(ds->multi_pids);
	ds->multi_pids = NULL;
	if (ds->multi_tracks) gf_list_del(ds->multi_tracks);
	ds->multi_tracks = NULL;

	if (ds->pending_segment_urls) gf_list_del(ds->pending_segment_urls);
	ds->pending_segment_urls = NULL;
	if (ds->pending_segment_states) gf_list_del(ds->pending_segment_states);
	ds->pending_segment_states = NULL;

	if (is_destroy) {
		if (ds->cues) gf_free(ds->cues);
		gf_list_del(ds->complementary_streams);
		gf_free(ds->rep_id);
		 
#define RESET_PROP_STR(_prop) \
		if (_prop) gf_free(_prop);

		RESET_PROP_STR(ds->src_url)
		RESET_PROP_STR(ds->template)
		RESET_PROP_STR(ds->lang)
		RESET_PROP_STR(ds->hls_vp_name)
		RESET_PROP_STR(ds->xlink)
		RESET_PROP_STR(ds->period_id)
		RESET_PROP_STR(ds->period_continuity_id)

#undef RESET_PROP_STR
		return;
	}
	ds->init_seg = ds->seg_template = ds->idx_template = NULL;
	ds->split_set_names = GF_FALSE;
	ds->nb_sap_3 = 0;
	ds->nb_sap_4 = 0;
	ds->pid_id = 0;
	ds->force_timescale = 0;
	ds->set = NULL;
	ds->owns_set = GF_FALSE;
	ds->rep = NULL;
	ds->muxed_base = NULL;
	ds->nb_comp = ds->nb_comp_done = 0;
	gf_list_reset(ds->complementary_streams);
	ds->inband_params = 0;
	ds->seg_start_time = 0;
	ds->seg_number = ds->startNumber;
	ds->nb_segments_purged = 0;
	ds->dur_purged = 0;
	ds->moof_sn_inc = 0;
	ds->moof_sn = 0;
	ds->seg_done = 0;
	ds->subdur_done = 0;
	if (ds->packet_queue) {
		while (gf_list_count(ds->packet_queue)) {