
typedef struct
{
	GF_Fraction64 period_start;
	const char *period_id;
} PeriodInfo;

static u32 dasher_period_count(GF_List *streams_in /*GF_DashStream*/)
{
	u32 nb_periods, i, j;
	PeriodInfo *info;
	GF_List *pinfos = gf_list_new();

	for (i=0; i < gf_list_count(streams_in); i++) {
		Bool same_period = GF_FALSE;
		GF_DashStream *ds = gf_list_get(streams_in, i);
		//check if we already have a period info with same ID or same start time
		nb_periods = gf_list_count(pinfos);
		for (j=0; j < nb_periods; j++) {
			info = gf_list_get(pinfos, j);
			if (info->period_start.num * ds->period_start.den == ds->period_start.num * info->period_start.den) {
				same_period = GF_TRUE;
				break;
			}
			if (info->period_id && ds->period_id && !strcmp(info->period_id, ds->period_id)) {
				same_period = GF_TRUE;
				break;
			}
		}
		//nope, register it
		if (!same_period) {
			GF_SAFEALLOC(info, PeriodInfo);
			if (info) {
				info->period_start = ds->period_start;
				info->period_id = ds->period_id;
				gf_list_add(pinfos, info);
			}
		}
	}
	nb_periods = gf_list_count(pinfos);
	while (1) {
		info = gf_list_pop_back(pinfos);

typedef struct
{
	GF_Fraction64 period_start;
	const char *period_id;
} PeriodInfo;

static u32 dasher_period_count(GF_List *streams_in  )
{
	u32 nb_periods, i, j;
	PeriodInfo *info;
	GF_List *pinfos = gf_list_new();

	for (i=0; i < gf_list_count(streams_in); i++) {
		Bool same_period = GF_FALSE;
		GF_DashStream *ds = gf_list_get(streams_in, i);
		 
		nb_periods = gf_list_count(pinfos);
		for (j=0; j < nb_periods; j++) {
			info = gf_list_get(pinfos, j);
			if (info->period_start.num * ds->period_start.den == ds->period_start.num * info->period_start.den) {
				same_period = GF_TRUE;
				break;
			}
			if (info->period_id && ds->period_id && !strcmp(info->period_id, ds->period_id)) {
				same_period = GF_TRUE;
				break;
			}
		}
		 
		if (!same_period) {
			GF_SAFEALLOC(info, PeriodInfo);
			if (info) {
				info->period_start = ds->period_start;
				info->period_id = ds->period_id;
				gf_list_add(pinfos, info);
			}
		}
	}
	nb_periods = gf_list_count(pinfos);
	while (1) {
		info = gf_list_pop_back(pinfos);