Esempio n. 1
0
INT32 si_nit_parser(UINT8 *data, INT32 len, struct section_parameter *param)
{
	INT32 i, ret, dloop_len;
	struct network_descriptor *nw_desc;
	struct nit_section_info *n_info = (struct nit_section_info *)param->priv;
	struct transport_stream_info *ts_info;
	if (data == NULL) {
		n_info->xp_nr = 0;
		return SI_SUCCESS;
	}
	
#if(defined( _MHEG5_ENABLE_) || defined( _MHEG5_V20_ENABLE_)||defined(SUPPORT_FRANCE_HD))
	//network_id
	n_info->net_id = (data[3]<<8) | data[4];
#endif

#ifdef SUPPORT_FRANCE_HD
	n_info->version_num = (data[5]&0x3e)>>1;
#endif

	nw_desc = &((struct nit_section *)data)->network;
	dloop_len = SI_MERGE_HL8(nw_desc->network_descriptor_length);
	
	if (n_info->lp1_nr&&(dloop_len>0)) {
#ifdef AUTO_OTA
		ret = desc_loop_parser(nw_desc->descriptor, dloop_len, 
			n_info->loop1, n_info->lp1_nr, &n_info->p_firstloopinfo.descriptors_parse_stat, n_info);
#else
		ret = desc_loop_parser(nw_desc->descriptor, dloop_len, 
			n_info->loop1, n_info->lp1_nr, NULL, n_info);
#endif
		if (ret != SI_SUCCESS) {
			SN_PRINTF("%s: loop1 parse failure!\n",
				__FUNCTION__);
			return ret;
		}
#ifdef AUTO_OTA
		if(0 == (&n_info->p_firstloopinfo.descriptors_parse_stat)&(1<<NIT_LINKAGE_EXIST_BIT))
			set_linkagetype09_exist(0);
#endif
	}
	
	if (n_info->lp2_nr==0) {
		return SI_SUCCESS;
	}
	
	for(i=sizeof(struct nit_section)+dloop_len-4; i<len-4; 
		i += sizeof(struct transport_stream_info)+dloop_len) {
		ts_info = (struct transport_stream_info *)(data+i);
		n_info->tsid = SI_MERGE_UINT16(ts_info->transport_stream_id);
		n_info->onid = SI_MERGE_UINT16(ts_info->original_network_id);
		dloop_len = SI_MERGE_HL8(ts_info->transport_stream_length);
		if (dloop_len>0) {
			ret = desc_loop_parser(ts_info->descriptor,
				dloop_len, n_info->loop2, n_info->lp2_nr, NULL, n_info);
			if (ret != SI_SUCCESS) {
				SN_PRINTF("%s: loop2 parse failure!\n",
					__FUNCTION__);
				return ret;
			}
		}
	}
		
	return SI_SUCCESS;
}
Esempio n. 2
0
INT32 si_sdtt_parser(UINT8 *section, INT32 length, 
	struct section_parameter *param)
{
	INT32 i,j;	// sec_offset;
	UINT16 current_ver;
	//UINT16 program_number;
	struct sdtt_section*info;
	struct sdtt_content *content;
	//struct program_map *maps;
	struct sdtt_section_info *s_info = (struct sdtt_section_info *)param->priv;	//??

	if (section==NULL) {
	//	s_info->map_counter = 0;
		return SI_SUCCESS;
	} 

	//get current version
	current_ver=SYS_SW_VERSION;


	info = (struct sdtt_section *)section;
	content = (struct sdtt_content *)(section+sizeof(struct sdtt_section));

	for(i=0;i<info->numer_of_content;i++)
	{
		UINT16 cont_desc_len,sche_desc_len,trg_ver,new_ver,sch_time_N;
		UINT32 down_desc_total_len,down_desc_pase_size;
		struct sch_time *sched_time;
		struct SDTT_DL_CONT_DESC_1 *down_desc;

		cont_desc_len = content->content_ds_len_lo|(((UINT16)content->content_ds_len_hi)<<4);
		sche_desc_len =  content->schedule_ds_len_lo|(((UINT16)content->schedule_ds_len_hi)<<4);
		sch_time_N = (sche_desc_len/sizeof(struct sch_time));
		down_desc_total_len = cont_desc_len - sche_desc_len;
		sched_time = (struct sch_time *)(((UINT8 *)content)+sizeof(struct sdtt_content));
		down_desc = (struct SDTT_DL_CONT_DESC_1 *)(((UINT8 *)sched_time)+sche_desc_len);

		for(down_desc_pase_size=0;down_desc_pase_size<down_desc_total_len;)
		{
			UINT16 desc_len;
			UINT8 *desc_point;
			
			if(down_desc->compab_flag!=1)
				goto NEXT_CONT; 	//I can't check the model inf, skip it... 

			desc_point = (((UINT8 *)down_desc) + sizeof(struct SDTT_DL_CONT_DESC_1));
			desc_len = si_sdtt_parser_compab_desc((struct SDTT_COMPAB_DESC_1 *)desc_point);

			if(desc_len==0)	//Error parsering Compatibility Desc table
				goto NEXT_CONT;

			down_desc_pase_size += (sizeof(struct SDTT_DL_CONT_DESC_1) + desc_len);
			desc_point += desc_len;

			if(down_desc->mod_inf_flag==1)
			{				
				desc_len = st_sdtt_parser_module_desc(desc_point);
				down_desc_pase_size += desc_len;
				desc_point += desc_len;
			}

			//Private data
			desc_len = (*desc_point);
			desc_point += (desc_len+1);
			down_desc_pase_size += (desc_len+1);

			//text info
			if(down_desc->txt_inf_flag==1)
			{
				desc_point += 3;	//3 Bytes, ISO_639_Lang_code
				desc_len = (*desc_point);
				desc_point += (desc_len+1);
				down_desc_pase_size += (desc_len+1+3);
			}

			down_desc = (struct SDTT_DL_CONT_DESC_1 *)desc_point;	//Point to next download cont desc...			
		}

		//check version
		trg_ver = SDTT_MERG_UINT16(content->target_ver_hi,content->target_ver_lo);
		new_ver = SDTT_MERG_UINT16(content->new_ver_hi,content->new_ver_lo);
		
		switch(content->ver_indicator)
		{
			case SDTT_VER_INDICAT_ALL:
				//Do Nothing...
				break;
		
			case SDTT_VER_INDICAT_LATER:
				if(trg_ver<current_ver)
					goto NEXT_CONT;

				break;
		
			case SDTT_VER_INDICAT_EARLIER:
				if(current_ver<trg_ver)
					goto NEXT_CONT;

				break;
		
			case SDTT_VER_INDICAT_ONLY:
				if(trg_ver!=current_ver)
					goto NEXT_CONT;

				break;
		}

		{
			//Set Timer
			date_time dtSet,dtGet;	
			UINT32 mjd_time,set_dur_time,get_dur_time = 0,fForce;
			UINT8 temp;
			P_NODE p_node;
			T_NODE t_node;

			fForce = content->download_level;

			if(sch_time_N>0)
			{
				for(j=0;j<sch_time_N;j++)
				{
					#define BCD2DEC(a)		((a>>4)*10+(a&0x0F))

					mjd_time =(	(((UINT32)sched_time[j].sch_time_start[0])<<8) |
								(((UINT32)sched_time[j].sch_time_start[1])) );

					dtSet.hour = BCD2DEC(sched_time[j].sch_time_start[2]);
					dtSet.min = BCD2DEC(sched_time[j].sch_time_start[3]);
					dtSet.sec = BCD2DEC(sched_time[j].sch_time_start[4]);

					set_dur_time =(	(((UINT32)sched_time[j].sch_time_duration[0])<<16) |
								(((UINT32)sched_time[j].sch_time_duration[1])<<8) |
								(((UINT32)sched_time[j].sch_time_duration[2])) );						

					mjd_to_ymd(mjd_time,&dtSet.year,&dtSet.month,&dtSet.day,&temp);
					
					api_ota_check_timerinfo(&dtSet,&set_dur_time,&fForce);

					dtGet = dtSet;
					get_dur_time = set_dur_time;
				}
			}
			else
			{
				//Update Now...
				get_local_time(&dtSet);
				convert_time_by_offset2(&dtGet,&dtSet,0,0,3);	//Set time as 3 second later...
				get_dur_time = 1;
			}

			if (get_prog_at(m_SdttChanIndex, &p_node) != SUCCESS)
				return SI_SUCCESS;
			
			get_tp_by_id(p_node.tp_id, &t_node);
			
			sys_data_set_ota_band(t_node.bandwidth*1000);
			sys_data_set_ota_freq(t_node.frq);

			api_ota_timer_open(dtGet,get_dur_time,fForce);
		}		
	
NEXT_CONT:
		content = (struct sdtt_content *)((UINT8 *)content + sizeof(struct sdtt_content) + cont_desc_len);		
	}



	#if 0	
	info->numer_of_content=*(section+sizeof(struct section_header)+6); //get number of content
	sec_offset=sizeof(struct section_header)+7;	//move to start of content 
	for(i=0;  i<info->numer_of_content; i++)
	{
		content=(struct sdtt_content *)(section+sec_offset);	
		//if (SI_MERGE_UINT16(content->group) ==0x1234) //match group?
		{
			//-->It should be fixed!!
			if (( (current_ver <=(SI_MERGE_UINT16(content->target_ver_hi))) && (content->ver_indicator)==2) ||

			((current_ver >=(SI_MERGE_UINT16(content->target_ver_hi))) && (content->ver_indicator)==1) ||
			((current_ver ==(SI_MERGE_UINT16(content->target_ver_hi))) && (content->ver_indicator)==3) ||
			((content->ver_indicator)==0)  )
			{
				// match download
				
				// start to get schedule information
				
			}	
	    	}
		
		sec_offset+=(4+SI_MERGE_UINT16(content->schedule_ds_len_hi));
	}
	#endif

	return SI_SUCCESS;
}