Exemplo n.º 1
0
UINT8* epg_get_event_name(eit_event_info_t *ep, INT32 *name_len)
{
	UINT8 *name;
	UINT8 len;
	UINT32 refcode;
	if (ep==NULL)
		return NULL;

	if (ep->event_type == PRESENT_EVENT)
		name = (UINT8*)p_event_name;
	else if (ep->event_type == FOLLOWING_EVENT)
		name = (UINT8*)f_event_name;
	else
		name = (UINT8*)sch_event_name;

	//select language
#ifdef EPG_MULTI_LANG
	for (epg_lang_select=0; epg_lang_select<MAX_EPG_LANGUAGE_COUNT; epg_lang_select++)
	{
		if (compare_iso639_lang(lang2tolang3(ep->lang[epg_lang_select].lang_code2), g_current_lang_code) == 0)
			break;
	}
	if (epg_lang_select >= MAX_EPG_LANGUAGE_COUNT)
		epg_lang_select = 0;
#endif
	if (ep->lang[epg_lang_select].text_char == NULL)
	{
		dvb_to_unicode("No Name", 7, (UINT16 *)name, MAX_EVENT_NAME_LEN, 1);
		return name;
	}

	len = ep->lang[epg_lang_select].text_char[0];
	if (len > 0)
	{
		refcode = get_iso639_refcode(lang2tolang3(ep->lang[epg_lang_select].lang_code2));
    *name_len = dvb_to_unicode(ep->lang[epg_lang_select].text_char+1, len, (UINT16*)name, MAX_EVENT_NAME_LEN,refcode);  
		return name;
	}
	else
	{
		dvb_to_unicode("No Name", 7, (UINT16 *)name, MAX_EVENT_NAME_LEN, 1);
		return name;
	}
}
Exemplo n.º 2
0
static __inline__ void psi_convert_string(DB_ETYPE *dest, UINT8 *src)
{
    UINT32 refcode=0;
//#ifdef DB_USE_UNICODE_STRING
#ifdef DB_USE_UNICODE_STRING
#ifdef GB2312_SUPPORT
    refcode = 2312;//GB2312 coding
#endif
	dvb_to_unicode(src+1, *src, dest, MAX_SERVICE_NAME_LENGTH, refcode);
#else
	dvb_string_to_ascii(dest, src, MAX_SERVICE_NAME_LENGTH);
#endif
}
Exemplo n.º 3
0
UINT32 epg_get_event_all_short_detail(eit_event_info_t *ep,UINT16 *short_buf,UINT32 maxLen)
{
	UINT8* text;
	UINT16 len;

	if (ep==NULL)	return 0;

	if (ep->lang[epg_lang_select].text_char == NULL)	return 0;

	len = ep->lang[epg_lang_select].text_char[0];			//event name
	text = ep->lang[epg_lang_select].text_char + len + 1;	//short text char
	len = text[0];
	if (len > 0)
	{
		return dvb_to_unicode(text+1, len, short_buf, maxLen,
							get_iso639_refcode(lang2tolang3(ep->lang[epg_lang_select].lang_code2)));
	}
	else
		return 0;
}
Exemplo n.º 4
0
nvod_db_status_t nvod_data_add_svc(void *p_data, sdt_t *p_sdt)
{
  nvod_db_t *p_nvod = (nvod_db_t *)p_data;
  nvod_reference_svc_t *p_svc = NULL;
  sdt_svc_descriptor_t *p_svc_des = NULL;
  nvod_reference_descr_t *p_nvod_des = NULL;
  u8 loopi = 0;
  u8 loopj = 0;
  
  MT_ASSERT(p_nvod != NULL);
  
  for (loopi = 0; loopi < p_sdt->svc_count; loopi ++)
  {
    p_svc_des = &p_sdt->svc_des[loopi];
    switch (p_svc_des->service_type)
    {
    case DVB_NVOD_REF_SVC:
      {
        if (p_nvod->nvod_svc_cnt >= MAX_NVOD_REFERENCE_SVC)
        {
          return NVOD_DB_OVERFLOW;
        }
        
        for (loopj = 0; loopj < p_nvod->nvod_svc_cnt; loopj ++)
        {
          if (p_nvod->svc[loopj].svc_id == p_svc_des->svc_id
            && p_svc_des->svc_id)
          {
            return NVOD_DB_NORM;
          }
        }

        p_svc = &p_nvod->svc[loopj];

        p_svc->tp.frequency = p_nvod->locked_tp.frequency;
        p_svc->tp.symbol_rate = p_nvod->locked_tp.symbol_rate;
        p_svc->tp.modulation = p_nvod->locked_tp.modulation;
        if (p_svc_des->nvod_reference_des_found)
        {
          p_svc->time_shifted_svc_cnt = p_svc_des->nvod;
          p_nvod_des = (nvod_reference_descr_t *)p_svc_des->p_nvod_mosaic_des;
          for (loopj = 0; loopj < p_svc_des->nvod; loopj ++)
          {
            p_svc->time_shifted_svc[loopj].orig_network_id = p_nvod_des[loopj].orig_network_id;
            p_svc->time_shifted_svc[loopj].stream_id = p_nvod_des[loopj].stream_id;
            p_svc->time_shifted_svc[loopj].svc_id = p_nvod_des[loopj].svc_id;
          }
        }
        dvb_to_unicode(p_svc_des->name, MAX_SVC_NAME_LEN - 1, p_svc->name, MAX_SVC_NAME_LEN);
        p_nvod->nvod_svc_cnt ++;
        p_svc->svc_id = p_svc_des->svc_id;
        return NVOD_DB_REF_SVC_FOUND;
      }
      
    case DVB_NVOD_TIME_SHIFTED_SVC:
      break;
      
    default:
      break;
    }
  }
  
  return NVOD_DB_NORM;
}
Exemplo n.º 5
0
static u32 add_ref_svc_evt(void *p_data, eit_t *p_eit_info)
{
  nvod_db_t *p_nvod = (nvod_db_t *)p_data;
  nvod_reference_svc_t *p_svc = NULL;
  sht_evt_desc_t *p_evt_desc = NULL;
  nvod_reference_svc_evt_t *p_new_evt = NULL;
  u8 evt_idx = 0;
  u8 cont_idx = 0;
  u16 sht_idx = 0;
  u16 short_txt_len = 0;
  u32 evt_count = 0;

  p_svc = (nvod_reference_svc_t *)(&p_nvod->svc[p_nvod->cur_ref_svc_idx]);
  while (evt_idx < p_eit_info->tot_evt_num)
  {
    if (evt_idx >= MAX_EVT_PER_SEC)
    {
      break;
    }

    p_evt_desc = &p_eit_info->sht_evt_info[evt_idx];
    short_txt_len = 0;

    if (check_ref_svc_evt_exist(p_data, p_evt_desc->evt_id, p_nvod->cur_ref_svc_idx))
    {
      evt_idx ++;
      continue;
    }
    
    for (sht_idx = 0; sht_idx < p_eit_info->tot_sht_txt_num; sht_idx ++)
    {
      if (sht_idx >= MAX_SHT_TXT_NUM)
      {
        return evt_count;
      }
      
      if (p_eit_info->sht_txt[sht_idx].evt_id == p_evt_desc->evt_id
        && p_eit_info->sht_txt[sht_idx].txt_len != 0)
      {
        short_txt_len = p_eit_info->sht_txt[sht_idx].txt_len + 1;
        break;
      }
    }
    
    p_new_evt = lib_memp_alloc(&p_nvod->ref_evt_memp,
      sizeof(nvod_reference_svc_evt_t) + short_txt_len * sizeof(u16));
    MT_ASSERT(p_new_evt != NULL);
    memset(p_new_evt, 0, sizeof(nvod_reference_svc_evt_t) + short_txt_len * sizeof(u16));
    p_new_evt->shift_evt_cnt = 0;
    p_new_evt->p_next_evt = NULL;
    p_new_evt->p_shift_evt = NULL;
    p_new_evt->sht_txt_len = short_txt_len;
    p_new_evt->event_id = p_evt_desc->evt_id;
    p_new_evt->ref_svc_idx = p_nvod->cur_ref_svc_idx;
    if (sht_idx == p_eit_info->tot_sht_txt_num)
    {
      p_new_evt->p_sht_txt = NULL;
    }
    else
    {
      p_new_evt->p_sht_txt = (u16 *)(p_new_evt + sizeof(nvod_reference_svc_evt_t));
      dvb_to_unicode(p_eit_info->sht_txt[sht_idx].txt,
        p_eit_info->sht_txt[sht_idx].txt_len,
        p_new_evt->p_sht_txt, 
        p_new_evt->sht_txt_len);
    }

    if (p_eit_info->sht_txt[sht_idx].name_len >0)
    {
      dvb_to_unicode(p_eit_info->sht_txt[sht_idx].evt_nm, 
      p_eit_info->sht_txt[sht_idx].name_len,
        p_new_evt->event_name, MAX_EVT_NAME_LEN + 1);
    }
    else
    {
      p_new_evt->event_name[0] = 32;
      p_new_evt->event_name[1] = 0;
    }
    
    dvb_to_unicode(p_eit_info->sht_txt[sht_idx].lang_code, LANGUAGE_CODE_LEN , 
                              p_new_evt->lang_code, LANGUAGE_CODE_LEN + 1);
    
    //check content desc
    for (cont_idx = 0; cont_idx < p_eit_info->tot_cont_num; cont_idx ++)
    {
      if (cont_idx >= MAX_EVT_PER_SEC)
      {
        break;
      }
      if (p_eit_info->cont_desc[cont_idx].evt_id == p_evt_desc->evt_id)
      {
        break;
      }
    }

    if ((cont_idx >= MAX_EVT_PER_SEC) || (cont_idx >= p_eit_info->tot_cont_num))
    {
      p_new_evt->cont_valid_flag = 0;
    }
    else
    {
      p_new_evt->cont_valid_flag = 1;
      p_new_evt->cont_level  = p_eit_info->cont_desc[cont_idx].cont_level;
      p_new_evt->usr_nib   = p_eit_info->cont_desc[cont_idx].usr_nib;
    }

    insert_ref_svc_evt(p_data, p_new_evt);

    p_nvod->total_ref_evt_cnt ++;
    p_svc->reference_evt_cnt ++;
    evt_count = p_svc->reference_evt_cnt;
    evt_idx++;
  }

  return evt_count;
}
Exemplo n.º 6
0
void cti_chnchg_function()
{
	UINT16 chn_idx=0xffff;
	date_time local_time;
	CTI_CHN_CHG_CONTENT chnchg_data;
	UINT8 save;
	BOOL need_change = TRUE,info_changed = FALSE;
	win_popup_choice_t sel;
	UINT16 string[CHANNEL_JUMP_STR_LEN_MAX/2+1];

	INT sec = 0;
	if(pre_channel_index!=sys_data_get_cur_group_cur_mode_channel())//换台了
	{
		cti_chnchg_para_reset();
	}

	if(!get_cti_chnchg_flg())
	{
		return;
	}

	MEMSET(&local_time,0,sizeof(date_time));
	get_local_time(&local_time);

	MEMSET(&chnchg_data,0,sizeof(CTI_CHN_CHG_CONTENT));
	get_cti_chnchg_data(&chnchg_data);

	//显示内容有没有变化
	if(MEMCMP(pre_info,chnchg_data.pString,sizeof(chnchg_data.pString))==0)
	{
		info_changed = FALSE;
	}
	else
	{
		info_changed = TRUE;
	}

	chn_idx=GetPlayChannelID(chnchg_data.bType,chnchg_data.wPart1,
							chnchg_data.wPart2,chnchg_data.wPart3,chnchg_data.wPart4);

	if((chnchg_data.bStatus==0)
		||(chnchg_data.bStatus==2))//立即跳转
	{
		set_cti_chnchg_flg(FALSE);
	}
	else//时间跳转
	{
		if(api_compare_day_time_ext(&(chnchg_data.stStartTime),&local_time)>=0)	//跳转时间没有到
		{
			need_change = FALSE;
		}
		else if(api_compare_day_time_ext(&(chnchg_data.stEndTime),&local_time)>=0)	//正常跳转
		{
			sec = cti_mktime(&(chnchg_data.stEndTime),&local_time);
		}
		else//控制时间已过
		{
			need_change = FALSE;
			set_cti_chnchg_flg(FALSE);
			return;
		}
	}

	if((chn_idx!=0xffff)
		&&(chn_idx!=sys_data_get_cur_group_cur_mode_channel())
		&&need_change)
	{

		if(chnchg_data.bStatus==0)//强制立即跳转
		{
			BackToFullScrPlay();
			win_compopup_init ( WIN_POPUP_TYPE_SMSG );
			win_compopup_set_frame ( 100, 140, 400, 120);
			//win_compopup_set_frame(100, 180, 400, 80);
			win_compopup_set_msg_ext(NULL,NULL, RS_CTI_CHANNEL_JUMP);
			win_compopup_open_ext ( &save );
			osal_task_sleep(3000);
			win_compopup_close();
		}
		else if(chnchg_data.bStatus==1)//强制时间跳转
		{
			if(!info_showed)
			{
				BackToFullScrPlay();
				win_compopup_init ( WIN_POPUP_TYPE_SMSG );
				win_compopup_set_frame ( 100, 140, 400, 120);
				//win_compopup_set_frame(100, 180, 400, 80);
				win_compopup_set_msg_ext(NULL,NULL, RS_CTI_CHANNEL_JUMP);
				win_compopup_open_ext ( &save );
				osal_task_sleep(3000);
				win_compopup_close();
				info_showed = TRUE;
			}
		}
		else if(chnchg_data.bStatus==2)//用户选择立即跳转
		{
			if((sys_data_get_cur_group_cur_mode_channel()==chn_idx_sel_no)
				&&(!info_changed))
			{
				return;
			}
			else
			{
				BackToFullScrPlay();

				MEMSET(string,0,sizeof(string));
				MEMSET(pre_info,0,sizeof(pre_info));
#ifdef GB2312_SUPPORT
				convert_gb2312_to_unicode(chnchg_data.pString, 
				sizeof(chnchg_data.pString),string, CHANNEL_JUMP_STR_LEN_MAX/2);
#else
				dvb_to_unicode(chnchg_data.pString, 
				sizeof(chnchg_data.pString),string, CHANNEL_JUMP_STR_LEN_MAX/2, 0);
#endif
				MEMCPY(pre_info,chnchg_data.pString,sizeof(chnchg_data.pString));
				win_compopup_init ( WIN_POPUP_TYPE_OKNO);				
				//win_compopup_set_frame ( 100, 120, 400, 160);
				win_compopup_set_frame ( 100, 100, 400, 160);
				win_compopup_set_msg_ext(NULL, string, 0);
				win_compopup_set_default_choice(WIN_POP_CHOICE_YES);
				sel = win_compopup_open_ext_timeout(&save, 5);
				if (sel == WIN_POP_CHOICE_NO)
				{
					chn_idx_sel_no = sys_data_get_cur_group_cur_mode_channel();
					return;//do not change
				}	
				//choice yes,so change channel
			}
		}
		else if(chnchg_data.bStatus==3)//用户选择按时间跳转
		{
			if((!info_showed)||info_changed)//没有显示过或者字符变化了
			{
				BackToFullScrPlay();

				MEMSET(string,0,sizeof(string));
				MEMSET(pre_info,0,sizeof(pre_info));
#ifdef GB2312_SUPPORT				
				convert_gb2312_to_unicode(chnchg_data.pString, 
				sizeof(chnchg_data.pString),string, CHANNEL_JUMP_STR_LEN_MAX/2);
#else
				dvb_to_unicode(chnchg_data.pString, 
				sizeof(chnchg_data.pString),string, CHANNEL_JUMP_STR_LEN_MAX/2, 0);
#endif
				MEMCPY(pre_info,chnchg_data.pString,sizeof(chnchg_data.pString));
				win_compopup_init ( WIN_POPUP_TYPE_OKNO);
				win_compopup_set_frame ( 100, 100, 400, 160);
				win_compopup_set_msg_ext(NULL, string, 0);
				win_compopup_set_default_choice(WIN_POP_CHOICE_YES);
				sel = win_compopup_open_ext_timeout(&save, sec);
				choiced_yes = FALSE;
				info_showed = TRUE;
				if ((sel == WIN_POP_CHOICE_NO) || (sel == WIN_POP_CHOICE_TIMEOUT))
				{
					return;//do not change
				}	
				choiced_yes = TRUE;
			}
			else if(choiced_yes==TRUE)//用户选择yes,则继续判断是否需要跳转
			{

			}
			else
			{
				return;//提示过,不再提醒,也不换台
			}

		}

		api_play_channel(chn_idx, TRUE, TRUE, FALSE);
	}
}
Exemplo n.º 7
0
///====================================================================================================================
//// sub functions
static void ci_info_set_string(UINT16 *uni_text, UINT16 max_len, char *str)
{
//	ComAscStr2Uni(str, uni_text);
	dvb_to_unicode(str, STRLEN(str), uni_text, max_len, 1);
	
}
Exemplo n.º 8
0
static void save_prog(channel_table_t *p_ch)
{
  u16 i = 0, j = 0, k = 0;
  channel_node_t *p_node = NULL;
  channel_service_t *p_svc = NULL;
  dvbs_tp_node_t tp = {0};
  dvbs_prog_node_t pg = {0};
  u32 tp_id = 0;
  component_desc_t *p_com = NULL;
  u8 aud_cnt = 0;

   p_table->vv_id_pro = db_dvbs_create_view(DB_DVBS_ALL_PG, 0, NULL);
   p_table->vv_id_tp = db_dvbs_create_view(DB_DVBS_ALL_TP, 0, NULL);

  for(i = 0; i < p_ch->total_node_num; i ++)
  {
    p_node = &p_ch->node[i];
    if(is_new_tp(p_node->cable.freq, p_node->cable.sym, &tp_id))
    {
      //add tp
      tp.freq = p_node->cable.freq;
      tp.sym = p_node->cable.sym;
    //  tp.is_scramble = p_node->.is_scrable;
      switch(p_node->cable.modulation)
      {
        case 1:
          tp.nim_modulate = NIM_MODULA_QAM16;
          break;
        case 2:
          tp.nim_modulate = NIM_MODULA_QAM32;
          break;
        case 3:
          tp.nim_modulate = NIM_MODULA_QAM64;
          break;
        case 4:
          tp.nim_modulate = NIM_MODULA_QAM128;
          break;
        default:
          tp.nim_modulate = NIM_MODULA_QAM64;
          break;
      }
      db_dvbs_add_tp( p_table->vv_id_tp,&tp);

      tp_id = tp.id;
    }

    for(j = 0; j < p_node->total_svc_num; j ++)
    {
      // add pg
      p_svc = &p_node->svc[j];
      pg.tp_id = tp_id;
      pg.ts_id = p_node->ts_id;
      pg.orig_net_id = p_node->net_id;
      pg.s_id = p_svc->s_id;
//      pg.logical_num = p_svc->setting.ch_no;

      if(p_svc->service.type == 0x6
        || p_svc->service.type == 0xB)
      {
        pg.mosaic_flag = TRUE;
      }

      pg.service_type = p_svc->service.type;
      if(p_node->cas.ca_sys_id != 0)
        pg.is_scrambled = 1;
   //   pg.bouquet_id = p_svc->s_content.bouquet_id;
      pg.volume = 10; //DEFAULT
      pg.pmt_pid = 0x1fff;
	  aud_cnt = 0;
      for(k = 0; k < p_svc->total_component_num; k ++)
      {
        p_com = &p_svc->component[k];

        if(p_com->type == 2)
        {//video
          pg.video_pid = p_com->pid;
        }
        else if(p_com->type == 4)
        {
          pg.audio[aud_cnt].p_id = p_com->pid;
          //pg.audio[aud_cnt].type = 0;
          pg.audio[aud_cnt].type = AUDIO_MP2;
          aud_cnt ++;
        }
        else
        {

        }
      }
      pg.pcr_pid = p_svc->pcr_pid;
      pg.audio_ch_num = aud_cnt;
      pg.ca_system_id = p_node->cas.ca_sys_id;
      pg.cas_ecm[0].ca_sys_id = p_node->cas.ca_sys_id;
      pg.cas_ecm[0].ecm_pid = p_node->cas.ca_pid;
      dvb_to_unicode((u8*)p_svc->service.svc_name,
        sizeof(p_svc->service.svc_name), (u16*)pg.name, DB_DVBS_MAX_NAME_LENGTH);

      db_dvbs_add_program( p_table->vv_id_pro, &pg);
    }
  }

  db_dvbs_save( p_table->vv_id_tp);
  db_dvbs_save( p_table->vv_id_pro);

}
/*!
  Add program information into database
  \param[in]
  */
static BOOL edit_pg_into_db(scan_pg_info_t *p_pg_info, u16 similar_idx)
{
  //Edit program into database
  event_t evt = {SCAN_EVT_PG_FOUND};
  db_dvbs_ret_t db_ret = DB_DVBS_OK;
  dvbs_prog_node_t *p_pg_node = g_p_scan_priv->pg_list + similar_idx;
  u16  pg_name_uni[DB_DVBS_MAX_NAME_LENGTH+1] = {0};
  
  
  //the below is read only for user
  MT_ASSERT(p_pg_node->s_id == p_pg_info->s_id);

  #ifndef SUPPORT_NIGNORE_PRECODE
  {
  	u8 filter_name[MAX_SVC_NAME_SUPPORTED] = {0};
  	str_uni_filter(filter_name, p_pg_info->name);
  	memset(p_pg_info->name, 0, MAX_SVC_NAME_SUPPORTED);
  	memcpy(p_pg_info->name, filter_name, MAX_SVC_NAME_SUPPORTED);
  }
  #endif
  
  //make a name for no name for some pgs
  if(strlen((char *)p_pg_info->name) == 0)
  {
    u8 p_name[MAX_SVC_NAME_SUPPORTED] = {0};
    u8 name_size = 0;
    if(p_pg_info->video_pid != 0)
    {
      sprintf((char *)p_name,"%s%d","TV CH",p_pg_info->s_id);
    }
    else
    {
      sprintf((char *)p_name,"%s%d","RADIO CH",p_pg_info->s_id);
    }
    name_size = strlen((char *)p_name);
    if(name_size > MAX_SVC_NAME_SUPPORTED)
    {
      name_size = MAX_SVC_NAME_SUPPORTED;
    }
    strncpy((char *)p_pg_info->name,(char *)p_name,name_size);
  }
  
  dvb_to_unicode(p_pg_info->name, MAX_SVC_NAME_SUPPORTED,
    pg_name_uni, DB_DVBS_MAX_NAME_LENGTH+1);
  
  if((p_pg_node->hide_flag == 1)
    ||(p_pg_node->video_pid != p_pg_info->video_pid)
    || (p_pg_node->audio_ch_num != p_pg_info->audio_ch_num)
    || (memcmp(p_pg_node->audio, p_pg_info->audio,
      sizeof(audio_t) * p_pg_info->audio_ch_num)) 
    || (p_pg_node->pcr_pid != p_pg_info->pcr_pid) 
    || (p_pg_node->skp_flag != 0)
    || (p_pg_node->is_scrambled != p_pg_info->is_scrambled) 
    || (uni_strcmp(p_pg_node->name, pg_name_uni) != 0)
//    || (p_pg_node->volume_compensate != p_pg_info->volume_compensate) 
#ifdef LOGIC_NUM_SUPPORT
    || (p_pg_node->logical_num != p_pg_info->logical_num && p_pg_info->logical_num != 0)
#endif
    //|| (p_pg_node->bouquet_id != p_pg_info->bouquet_id)
    )
  {
#ifdef AISET_BOUQUET_SUPPORT
    switch(find_show_flag_by_sid(p_pg_info->s_id))
    {
      case 0x01://the service is always showing on service list
        p_pg_node->hide_flag = 0;
        break;    
      case 0x02://the service is always hiding on service list
        p_pg_node->hide_flag = 1;
        break;    
      case 0x00://if service is not authorized by operator then the service is hided on service list
        p_pg_node->hide_flag = 0;
        p_pg_node->operator_flag = 1;
        break;    
      default:
        break;
    }
#else
    p_pg_node->hide_flag = 0;
#endif
    p_pg_node->pcr_pid = p_pg_info->pcr_pid;
    p_pg_node->video_pid = p_pg_info->video_pid;
    uni_strncpy(p_pg_node->name, pg_name_uni, DB_DVBS_MAX_NAME_LENGTH);
    p_pg_node->tv_flag = (p_pg_node->video_pid != 0) ? 1 : 0;
    p_pg_node->skp_flag = 0;
    p_pg_node->audio_ch_num = p_pg_info->audio_ch_num;
    p_pg_node->is_scrambled = p_pg_info->is_scrambled;
//    p_pg_node->volume_compensate = p_pg_info->volume_compensate;
    p_pg_node->ca_system_id = p_pg_info->ca_system_id;
    p_pg_node->service_type = check_service_type(p_pg_info);
    p_pg_node->video_type = p_pg_info->video_type;
#ifdef LOGIC_NUM_SUPPORT
    //p_pg_node->logical_num = p_pg_info->logical_num;
    p_pg_info->logical_num = find_logic_number_by_sid(p_pg_info->s_id);
    if(p_pg_info->logical_num)
    {
      p_pg_node->logical_num = p_pg_info->logical_num;
    }
    else
    {
      u16 un_india_ts_logic_num = sys_status_get_default_logic_num();
      p_pg_info->logical_num = un_india_ts_logic_num;
      p_pg_node->logical_num = p_pg_info->logical_num;
      un_india_ts_logic_num++;
      sys_status_set_default_logic_num(un_india_ts_logic_num);
    }
#endif
    //p_pg_node->bouquet_id = p_pg_info->bouquet_id;
    memcpy(p_pg_node->audio, p_pg_info->audio,
      sizeof(audio_t)*p_pg_node->audio_ch_num);
    db_ret = db_dvbs_edit_program(p_pg_node);
    MT_ASSERT(db_ret == DB_DVBS_OK);
  }
  
  evt.data1 = (u32)p_pg_node;
  ap_frm_send_evt_to_ui(APP_SCAN, &evt);
 
  return TRUE;
}
static BOOL add_pg_into_db(scan_pg_info_t *p_pg_info)
{
  //Add program into database
  event_t evt = {0};
  db_dvbs_ret_t db_ret = DB_DVBS_OK;
  dvbs_prog_node_t *p_pg_node = g_p_scan_priv->pg_list
    + g_p_scan_priv->pg_depth;  //add into the end
  u8 str[16] = {0};
  u16 uni_str[32] = {0}, uni_str2[32] = {0};
  
  RET_CODE ret = SUCCESS;

  //check "HD" str
  strcpy(str, "HD");
  str_asc2uni(str, uni_str);
  #ifndef SUPPORT_NIGNORE_PRECODE
  {
  	u8 filter_name[MAX_SVC_NAME_SUPPORTED] = {0};
  	str_uni_filter(filter_name, p_pg_info->name);
  	memset(p_pg_info->name, 0, MAX_SVC_NAME_SUPPORTED);
  	memcpy(p_pg_info->name, filter_name, MAX_SVC_NAME_SUPPORTED);
  }
  #endif
  str_asc2uni(p_pg_info->name, uni_str2);
  if(match_string(uni_str2, uni_str, FALSE))
    p_pg_info->service_type = 0x11;
  
  memset(p_pg_node, 0, sizeof(dvbs_prog_node_t));
  p_pg_node->s_id = p_pg_info->s_id;
  p_pg_node->ts_id = p_pg_info->ts_id;
  p_pg_node->orig_net_id = p_pg_info->orig_net_id;
  p_pg_node->sat_id = g_p_scan_priv->cur_sat_id;
  p_pg_node->tp_id = g_p_scan_priv->cur_tp_id;
  p_pg_node->pcr_pid = p_pg_info->pcr_pid;
  p_pg_node->video_pid = p_pg_info->video_pid;
  p_pg_node->volume = DEFAULT_VOLUME;
  p_pg_node->is_scrambled = p_pg_info->is_scrambled;
//  p_pg_node->volume_compensate = p_pg_info->volume_compensate;
  p_pg_node->ca_system_id = p_pg_info->ca_system_id;
  p_pg_node->service_type = check_service_type(p_pg_info);
  p_pg_node->pmt_pid = p_pg_info->pmt_pid;
  p_pg_node->ecm_num = p_pg_info->ecm_num;
  p_pg_node->video_type = p_pg_info->video_type;
  //p_pg_node->aud_modify_flg = FALSE;
#ifdef LOGIC_NUM_SUPPORT
  //p_pg_node->logical_num = p_pg_info->logical_num;
  p_pg_info->logical_num = find_logic_number_by_sid(p_pg_info->s_id);
  if(p_pg_info->logical_num)
  {
    p_pg_node->logical_num = p_pg_info->logical_num;
  }
  else
  {
    u16 un_india_ts_logic_num = sys_status_get_default_logic_num();
    p_pg_info->logical_num = un_india_ts_logic_num;
    p_pg_node->logical_num = p_pg_info->logical_num;
    un_india_ts_logic_num++;
    sys_status_set_default_logic_num(un_india_ts_logic_num);
  }
#endif
  //p_pg_node->bouquet_id = p_pg_info->bouquet_id;

  //make a name for no name for some pgs
  if(strlen((char *)p_pg_info->name) == 0)
  {
    u8 p_name[MAX_SVC_NAME_SUPPORTED] = {0};
    u8 name_size = 0;
    if(p_pg_info->video_pid != 0)
    {
      sprintf((char *)p_name,"%s%d","TV CH",p_pg_info->s_id);
    }
    else
    {
      sprintf((char *)p_name,"%s%d","RADIO CH",p_pg_info->s_id);
    }
    name_size = strlen((char *)p_name);
    if(name_size > MAX_SVC_NAME_SUPPORTED)
      {
        name_size = MAX_SVC_NAME_SUPPORTED;
      }
    strncpy((char *)p_pg_info->name,(char *)p_name,name_size);
  }
  //Transfer name to unicode
  ret = dvb_to_unicode(p_pg_info->name, 
        sizeof(p_pg_info->name), p_pg_node->name, DB_DVBS_MAX_NAME_LENGTH+1);

#ifdef AISET_BOUQUET_SUPPORT
  switch(find_show_flag_by_sid(p_pg_info->s_id))
  {
    case 0x01: //the service is always showing on service list
      p_pg_node->hide_flag = 0;
      break;    
    case 0x02://the service is always hiding on service list
      p_pg_node->hide_flag = 1;
      break;    
    case 0x00://if service is not authorized by operator then the service is hided on service list
      p_pg_node->hide_flag = 0;
      p_pg_node->operator_flag = 1;
      break;    
    default:
      break;
  }
#else
  p_pg_node->hide_flag = 0;      
#endif
  p_pg_node->tv_flag = (p_pg_node->video_pid != 0) ? 1 : 0;
  p_pg_node->skp_flag = 0;
  p_pg_node->audio_ch_num = p_pg_info->audio_ch_num;
  if (p_pg_node->service_type != DVB_NVOD_REF_SVC)
  {
    memcpy(p_pg_node->audio, p_pg_info->audio,
      sizeof(audio_t)*p_pg_node->audio_ch_num);
  }

  p_pg_node->mosaic_flag = 0;
  if (p_pg_info->mosaic_flag)
  {
    if (p_pg_node->service_type == DVB_MOSAIC_SVC)
    {
      p_pg_node->mosaic_flag = p_pg_info->mosaic_flag;
      memcpy(&p_pg_node->mosaic, p_pg_info->p_mosaic, sizeof(mosaic_t));
    }

    p_pg_info->mosaic_flag = 0;
  }
  
  if (p_pg_node->ecm_num)
  {
    memcpy(&p_pg_node->cas_ecm, p_pg_info->ca_ecm, sizeof(cas_desc_t) * p_pg_node->ecm_num);
  }
  
  db_ret = db_dvbs_add_program(g_p_scan_priv->pg_view_id, p_pg_node);

  if(DB_DVBS_OK == db_ret)
  {
    evt.id = SCAN_EVT_PG_FOUND;
    evt.data1 = (u32)p_pg_node;
    g_p_scan_priv->pg_depth++;
  }
  else 
  {
    evt.id = SCAN_EVT_NO_MEMORY;
  }
  
  ap_frm_send_evt_to_ui(APP_SCAN, &evt);
  return (DB_DVBS_OK == db_ret);
}