search.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:27k
- #include <stdio.h>
- #include <string.h>
- #include "gendef.h"
- #include "dmd.h"
- #include "osp.h"
- #include "sipsi.h"
- #include "appltype.h"
- #include "db.h"
- #include "db.h"
- #include "search.h"
- #include "flash.h"
- #include "avplay.h"
- #include "kb_dc.h"
- #include "kb_machblue_client_task.h"
- INT32 g_srchMode;
- KB_SINitStruct g_srchNit;
- KB_SISdtStruct g_srchSDT[100];
- KB_SIPatStruct g_srchPAT;
- KB_SIPmtStruct g_srchPMT;
- KB_DBPrgNode gSrchPrg[KB_DB_MAX_PGM_NODE];
- static T_SEARCH_PARA gSrchApp;
- enum
- {
- SrchPat,
- SrchSDT,
- SrchPMT
- };
- struct HintDisplay_struct
- {
- char *info;
- char *englishinfo;
- unsigned char hinttype;
- unsigned char index;
- }_HintDisplay[];
- //}_HintDisplay[] =
- //{
- // {"信号不良", "Weak signal", 0, KB_SEARCH_HINT1},
- //};
- static INT32 g_WholeNetFreqs[] =
- {
- 107, 115, 123, 131, 139, 147, 155, 163, 171, 179, 187, 195, 203, 211,
- 219, 227, 235, 243, 251, 259, 267, 275, 283, 291, 299, 307, 315, 323,
- 331, 339, 347, 355, 363, 371, 379, 387, 395, 403, 411, 419, 427, 435,
- 443, 451, 459, 467, 474, 482, 490, 498, 506, 514, 522, 530, 538, 546,
- 554, 562, 570, 578, 586, 594, 602, 610, 618, 626, 634, 642, 650, 658,
- 666, 674, 682, 690, 698, 706, 714, 722, 730, 738, 746, 754, 762, 770,
- 778, 786, 794, 802, 810, 818, 826, 834, 842, 850, 858
- };
- //#define WHOLE_NET_FREQ_SUM (95)
- static int _iRefSvcNums;
- static KB_SIRefSvcCell _astNvodCell[KB_SI_MAX_REF_SVC_NUMS];
- static int _iTotalShiftSvcNums;
- //static unsigned long _alShiftSvc[KB_SI_MAX_REF_SVC_NUMS * KB_SI_MAX_SHIFT_SVC_NUMS];
- static UINT16 bCurrentFreqDtvNum;
- static UINT16 bCurrentFreqMusicNum;
- static KB_DMDTunerParameters gSrchFre[WHOLE_NET_FREQ_SUM];
- static UINT8 gSrchFreInx = 0;
- static UINT8 gSrchFreNum =0 ;
- static UINT32 gSrchTaskID;
- static UINT32 gSrchQueID;
- enum{PMTPID_GET_FIRST, PMTPID_GET_NEXT};
- static unsigned short KD_GetPmtPid(unsigned short i_nCallOpt, unsigned short * pmtPid,
- unsigned short * pmtPgmno);
- static void KD_SRCHHandleNit(void);
- static void KD_SrchNvodInit(void);
- static void KD_SrchHandleNovd(KB_SISdtStruct * i_pstSdt, int i_nNum);
- static void KD_SrchAdjustNvod(void);
- static void KD_SrchDis(UINT32 nPara1, UINT32 nPara2, UINT8 nDisTypeEx,
- UINT8 nDisType);
- static void KD_SrchTask(void);
- static INT32 KD_SrchHandleMsg(KB_OSPMsgNode *i_pstMsg);
- static void KD_SrchToNext(void);
- static void KD_SrchSetFre(UINT8 srchMode);
- static void KD_SrchSaveResult(void);
- static void KD_Srchend(void);
- INT32 KB_SEARCHInit(void)
- {
- int nReturn;
-
- gSrchApp.tsParams.frequency = 0;
- gSrchApp.tsParams.details.qam.symbolRatekSs = 0;
- gSrchApp.tsParams.details.qam.modulation = 0;
- gSrchApp.srchMode = KB_SEARCH_IN_NET;
- gSrchApp.srchState = KB_SEARCH_UNACTIVE;
- gSrchApp.pat = NULL;
- gSrchApp.pmtCpt = KB_DB_DTV_FAILURE;
- gSrchApp.sdtCpt = KB_DB_DTV_FAILURE;
- gSrchApp.nitCpt = KB_DB_DTV_FAILURE;
- gSrchApp.dtvNum = 0;
- gSrchApp.radNum = 0;
- gSrchApp.svcIDnum = 0;
- memset(gSrchFre,0,sizeof(gSrchFre));
- gSrchFreInx = 0;
- gSrchFreNum =0 ;
- nReturn = KB_OSPQueInit("SEAQ", 64, &gSrchQueID);
- if (nReturn != Ret_OK)
- {
- return RETFIAL1;
- }
-
- nReturn = KB_OSPTaskInit("SEAT", 64 * 1024, (void (*)(void*))KD_SrchTask,
- SEARCH_PRIORITY, NULL, &gSrchTaskID);
- if (nReturn != Ret_OK)
- {
- return RETFIAL1;
- }
- return RETOK;
- }
- static void KD_SrchTask(void)
- {
- KB_OSPMsgNode msgNode;
- int nReturn;
- while (1)
- {
- nReturn = KB_OSPMsgGet(gSrchQueID, KB_Wait, 0, (KB_OSPMsgNode *)&msgNode);
- if(nReturn != Ret_OK)
- {
- continue;
- }
- KD_SrchHandleMsg(&msgNode);
- }
- }
- void KB_SEARCHCreate(void)
- {
- gSrchApp.srchState = KB_SEARCH_WAITING_CNT;
- gSrchApp.pat = NULL;
- gSrchApp.pmtCpt = KB_DB_DTV_FAILURE;
- gSrchApp.sdtCpt = KB_DB_DTV_FAILURE;
- gSrchApp.nitCpt = KB_DB_DTV_FAILURE;
- gSrchApp.dtvNum = 0;
- gSrchApp.radNum = 0;
- gSrchApp.svcIDnum = 0;
- memset(gSrchFre,0,sizeof(gSrchFre));
- gSrchFreInx = 0;
- gSrchFreNum = 0;
- KB_DBE2pCfgInfoRefresh(DTVPRG);
- KB_DBE2pCfgInfoRefresh(RADIOPRG);
- KB_DBE2pCfgInfoRefresh(DATAPRG);
- switch(gSrchApp.srchMode)
- {
- case KB_SEARCH_IN_TS://手动
- KB_DBGetAllPrgConfig();
- break;
- case KB_SEARCH_IN_NET:
- case KB_SEARCH_IN_WHOLE_NET:
- KB_DBResetDtvInfo(BufferSave);
- KB_DBResetRadInfo(BufferSave);
- KB_DBResetDataInfo(BufferSave);
- KB_DBResetChnnlInfo(BufferSave);
- KB_FlashErase(KB_DB_SECTOR);
- KD_SrchNvodInit();
-
- break;
- default:
- break;
- }
- KD_SrchSetFre(gSrchApp.srchMode);
- if (gSrchApp.srchMode != KB_SEARCH_IN_NET)
- {
- KD_SrchToNext();
- }
- }
- void KB_SEARCHSetPara(unsigned char i_cSearchMode,
- unsigned long i_lFreq, unsigned long i_lSymb,
- unsigned short i_nQam)
- {
- if(i_cSearchMode == KB_SEARCH_IN_WHOLE_NET)
- {
- gSrchApp.srchMode = KB_SEARCH_IN_WHOLE_NET;
- g_srchMode = KB_SEARCH_IN_WHOLE_NET;
- }
- else
- {
- gSrchApp.tsParams.type = DMD_TYPE_QAM;
- gSrchApp.tsParams.inversion = INVERSION_AUTO;
- gSrchApp.tsParams.frequency = i_lFreq;
- gSrchApp.tsParams.details.qam.symbolRatekSs = i_lSymb;
- gSrchApp.tsParams.details.qam.modulation = (unsigned char)i_nQam;
-
- if(i_cSearchMode == KB_SEARCH_IN_TS)
- {
- gSrchApp.srchMode = KB_SEARCH_IN_TS;
- g_srchMode = KB_SEARCH_IN_TS;
- }
- else
- {
- gSrchApp.srchMode = KB_SEARCH_IN_NET;
- g_srchMode = KB_SEARCH_IN_NET;
- }
- }
- }
- INT32 KB_SEARCHHandleMsg(KB_OSPMsgNode *i_pstMsg)
- {
- int nReturn;
- nReturn = KB_OSPMsgSend(gSrchQueID, i_pstMsg);
- return RETOK;
- }
- void KD_SrchParseInit(unsigned short i_lFreq, unsigned short i_lSymb,
- unsigned char i_lQam)
- {
- unsigned short loop;
- for(loop = 0; loop < KB_DB_MAX_PGM_NODE; loop ++)
- {
- gSrchPrg[loop].freq = i_lFreq;
- gSrchPrg[loop].symb = i_lSymb;
- gSrchPrg[loop].qam = i_lQam;
- gSrchPrg[loop].PATVersion = KB_DB_UNKNOWN_VERSION;
- gSrchPrg[loop].SDTVersion = KB_DB_UNKNOWN_VERSION;
- gSrchPrg[loop].PMTVersion = KB_DB_UNKNOWN_VERSION;
- }
- }
- void KD_SrchParseTable(unsigned char i_cTableType, void * i_pstTable,
- unsigned short i_nSvcNum)
- {
- KB_SIPatStruct * pat;
- KB_SISdtStruct * sdt;
- KB_SIPmtStruct * pmt;
- int len;
- unsigned short i, j;
-
- switch(i_cTableType)
- {
- case SrchPat:
- pat = (KB_SIPatStruct *)i_pstTable;
- for(j=0; j<i_nSvcNum; j++)
- {
- for(i = 0; i < pat->num; i ++)
- {
- if (gSrchPrg[j].SerID == pat->program[i].program_number)
- {
- gSrchPrg[j].PATVersion = pat->version_number;
- gSrchPrg[j].PMTPid = pat->program[i].program_map_PID;
- break;
- }
- }
- }
- break;
- case SrchSDT:
- sdt = (KB_SISdtStruct *)i_pstTable;
- for(i = 0; i < i_nSvcNum; i ++)
- {
- len = strlen((char*)sdt[i].chinese.service_name);
- if(len >= 20)
- {
- len = 18;
- }
- if(sdt[i].chinese.service_name[0] != ' ')
- {
- memcpy(gSrchPrg[i].name, sdt[i].chinese.service_name, len);
- }
- else
- {
- if(sdt[i].english.service_name[0] != ' ')
- {
- memcpy(gSrchPrg[i].name, sdt[i].english.service_name, len);
- }
- else
- {
- strcpy(gSrchPrg[i].name, "数字电视");
- }
- }
-
-
- gSrchPrg[i].name[len ] = ' ';
- gSrchPrg[i].name[len + 1 ] = ' ';
-
- gSrchPrg[i].SDTVersion = sdt[i].version_number;
- gSrchPrg[i].service_type = sdt[i].service_type;
- //printf("-=gSrchPrg[%d].service_type=0x%x=-n", i, gSrchPrg[i].service_type);
- gSrchPrg[i].SerID= sdt[i].service_id;
- gSrchPrg[i].TSID = sdt[i].TSID;
- }
- break;
- case SrchPMT:
- pmt = (KB_SIPmtStruct *)i_pstTable;
- for(i = 0; i < i_nSvcNum; i ++)
- {
- if(gSrchPrg[i].SerID== pmt->program_number)
- {
- unsigned short loop;
- gSrchPrg[i].PCR_Pid = pmt->PCR_PID;
- gSrchPrg[i].PMTVersion = pmt->version_number;
-
- if(pmt->CA_descriptor_buffer_len == 0)
- {
- gSrchPrg[i].bCAFlag = KB_DB_PGM_UNENCRYPT;
- }
- else
- {
- gSrchPrg[i].bCAFlag = KB_DB_PGM_ENCRYPT;
- }
- gSrchPrg[i].Audio_Pid = 0;
- gSrchPrg[i].Video_Pid = 0;
- for(loop = 0; loop < pmt->num; loop ++)
- {
- switch(pmt->stream[loop].stream_type)
- {
- case 1:
- case 2:
- if(gSrchPrg[i].Video_Pid != 0)
- {
- break;
- }
-
- gSrchPrg[i].Video_Pid = pmt->stream[loop].elementary_PID;
-
- if(pmt->stream[loop].CA_descriptor_buffer_len > 0)
- {
- gSrchPrg[i].bCAFlag = KB_DB_PGM_ENCRYPT;
- }
- break;
- case 3:
- case 4:
- if(gSrchPrg[i].Audio_Pid != 0)
- {
- break;
- }
- gSrchPrg[i].Audio_Pid = pmt->stream[loop].elementary_PID;
-
- if(pmt->stream[loop].CA_descriptor_buffer_len > 0)
- {
- gSrchPrg[i].bCAFlag = KB_DB_PGM_ENCRYPT;
- }
- break;
- default :
- break;
- }
- }
- break;
- }
- }
- break;
- default:
- break;
- }
- }
- static INT32 KD_SrchHandleMsg(KB_OSPMsgNode *i_pstMsg)
- {
- switch(i_pstMsg->Word1)
- {
- case MOD_TUNER:
- //printf("-=MOD_TUNER:i_pstMsg->Word2=%d=-n", i_pstMsg->Word2);
- switch(i_pstMsg->Word2)
- {
- case DMD_CALLBACK_SIGNAL_CONNECTED:
- if (((gSrchApp.srchState == KB_SEARCH_WAITING_CNT)
- && (gSrchApp.srchMode != KB_SEARCH_IN_NET))
- || ((gSrchApp.srchState == KB_SEARCH_WAITING_CNT)
- && (gSrchApp.srchMode == KB_SEARCH_IN_NET)
- && (gSrchApp.nitCpt == KB_DB_DTV_SUCCESS )))
- {
- KB_SIGetSdt(-1, 100, g_srchSDT, KB_SI_RECEIVE_ONCE, -1);
- gSrchApp.srchState = KB_SEARCH_WAITING_SDT;
- }
-
- break;
-
- case DMD_CALLBACK_SIGNAL_LOST: //丢失连接
- if((gSrchApp.srchState == KB_SEARCH_WAITING_CNT)
- || (gSrchApp.srchState == KB_SEARCH_WAITING_PAT)
- || (gSrchApp.srchState == KB_SEARCH_WAITING_SDT)
- || (gSrchApp.srchState == KB_SEARCH_WAITING_PMT)
- || (gSrchApp.srchState == KB_SEARCH_WAITING_NIT))
- {
- if ((gSrchApp.srchMode == KB_SEARCH_IN_TS)
- /*|| ((gSrchApp.srchMode == KB_SEARCH_IN_NET)
- && (gSrchApp.nitCpt != KB_DB_DTV_SUCCESS ))*/)
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT0, KB_SEARCH_DIS_HELPHINT);
- gSrchApp.srchState = KB_SEARCH_WAITING_EXIT;
- }
- else if (/*(gSrchApp.srchMode == KB_SEARCH_IN_TS)
- || */((gSrchApp.srchMode == KB_SEARCH_IN_NET)
- && (gSrchApp.nitCpt != KB_DB_DTV_SUCCESS )))
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT1, KB_SEARCH_DIS_HELPHINT);
- gSrchApp.srchState = KB_SEARCH_WAITING_EXIT;
- }
- else
- {
- //added by whale 07/03/04
- KD_SrchDis(0, 0, KB_SEARCH_HINT2, KB_SEARCH_DIS_HELPHINT);
- KD_SrchToNext();
- }
- }
-
- break;
- default:
- break;
- }
- break;
- case MOD_SIPSI:
- //printf("-=MOD_SIPSI:i_pstMsg->Word2=%d=-n", i_pstMsg->Word2);
- switch(i_pstMsg->Word2)
- {
- case KB_SI_MSG_NIT_DONE:
- if ((gSrchApp.srchState == KB_SEARCH_WAITING_NIT)
- && (gSrchApp.srchMode == KB_SEARCH_IN_NET))
- {
-
- gSrchApp.nitCpt = KB_DB_DTV_SUCCESS;
- KD_SRCHHandleNit();
-
- KD_SrchToNext();
- }
- break;
- case KB_SI_MSG_NIT_TIMEOUT:
- if ((gSrchApp.srchState == KB_SEARCH_WAITING_NIT)
- && (gSrchApp.srchMode == KB_SEARCH_IN_NET))
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT3, KB_SEARCH_DIS_HELPHINT);
- gSrchApp.srchState = KB_SEARCH_WAITING_EXIT;
- }
- break;
-
- case KB_SI_MSG_PAT_DONE:
- if(gSrchApp.srchState == KB_SEARCH_WAITING_PAT)
- {
- unsigned short ret, pmtPid, pmtPgmno;
- KB_DBRET dbRet;
- //KB_SIPmtStruct *pPmt=NULL;
- gSrchApp.pat = (KB_SIPatStruct *)i_pstMsg->Word3;
- KD_SrchParseTable(SrchPat, (void *)i_pstMsg->Word3,
- gSrchApp.svcIDnum);
- dbRet = KB_DBSaveChlPatVer(
- (UINT16)(gSrchFre[gSrchFreInx-1].frequency / 100),
- (UINT16)gSrchApp.pat->version_number);
- if (KB_SEARCH_IN_TS == gSrchApp.srchMode)
- {
- KD_SrchDis(60, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_PLANHINT);
- }
-
- ret = KD_GetPmtPid(PMTPID_GET_FIRST, &pmtPid, &pmtPgmno);
-
- if(ret != KB_DB_DTV_SUCCESS)
- {
- KD_SrchToNext();
- }
- else
- {
- KB_SIGetPmt(pmtPid, pmtPgmno, &g_srchPMT,KB_SI_RECEIVE_ONCE, -1);
- gSrchApp.srchState = KB_SEARCH_WAITING_PMT;
- }
- }
- break;
- case KB_SI_MSG_PAT_TIMEOUT:
-
- if(gSrchApp.srchState == KB_SEARCH_WAITING_PAT)
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT4, KB_SEARCH_DIS_HELPHINT);
- KD_SrchToNext();
- }
- break;
- case KB_SI_MSG_SDT_DONE:
-
- if(gSrchApp.srchState == KB_SEARCH_WAITING_SDT)
- {
- KB_SISdtStruct *pSdt;
- //KB_SIPatStruct *pPat;
- KB_DBRET ret;
-
- gSrchApp.sdtCpt = KB_DB_DTV_SUCCESS;
- gSrchApp.srchState = KB_SEARCH_WAITING_PAT;
- pSdt = (KB_SISdtStruct *)i_pstMsg->Word3;
-
- gSrchApp.svcIDnum = (UINT16)i_pstMsg->Word4;
-
- KD_SrchParseTable(SrchSDT, (void *)i_pstMsg->Word3,
- gSrchApp.svcIDnum);
- ret = KB_DBSaveChlInfo(0,pSdt->OrgNetID,pSdt->TSID,
- (UINT16)(gSrchFre[gSrchFreInx-1].frequency / 100),
- (UINT16)gSrchFre[gSrchFreInx-1].details.qam.symbolRatekSs,
- gSrchFre[gSrchFreInx-1].details.qam.modulation);
- ret = KB_DBSaveChlSdtVer(
- (UINT16)(gSrchFre[gSrchFreInx-1].frequency / 100),
- (UINT16)pSdt->version_number);
-
- KD_SrchHandleNovd((KB_SISdtStruct *)i_pstMsg->Word3, (int)i_pstMsg->Word4);
-
- KB_SIGetPat(&g_srchPAT, KB_SI_RECEIVE_ONCE, -1);
- if (KB_SEARCH_IN_TS == gSrchApp.srchMode)
- {
- KD_SrchDis(30, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_PLANHINT);
- }
-
- }
- break;
- case KB_SI_MSG_SDT_TIMEOUT:
- if(gSrchApp.srchState == KB_SEARCH_WAITING_SDT)
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT6, KB_SEARCH_DIS_HELPHINT);
- KD_SrchToNext();
- }
- break;
-
- case KB_SI_MSG_PMT_TIMEOUT:
- if (gSrchApp.srchState == KB_SEARCH_WAITING_PMT)
- {
- KD_SrchDis(0, 0, KB_SEARCH_HINT5, KB_SEARCH_DIS_HELPHINT);
- }
- case KB_SI_MSG_PMT_DONE:
- if (gSrchApp.srchState == KB_SEARCH_WAITING_PMT)
- {
- unsigned short ret, pmtPid, pmtPgmno;
-
- if (i_pstMsg->Word2 == KB_SI_MSG_PMT_DONE)
- {
- KD_SrchParseTable(SrchPMT, (void *)i_pstMsg->Word3,
- gSrchApp.svcIDnum);
- }
- ret = KD_GetPmtPid(PMTPID_GET_NEXT, &pmtPid, &pmtPgmno);
- if(ret != KB_DB_DTV_SUCCESS)
- {
- gSrchApp.pmtCpt = KB_DB_DTV_SUCCESS;
- KD_SrchAdjustNvod();
- KD_SrchSaveResult();
- KD_SrchToNext();
- }
- else
- {
- KB_SIGetPmt(pmtPid, pmtPgmno, &g_srchPMT, KB_SI_RECEIVE_ONCE, -1);
- gSrchApp.srchState = KB_SEARCH_WAITING_PMT;
- }
- }
- break;
- }
-
- break;
- case J_TIME_MODULE:
- break;
- default:
- break;
- }
- return KB_DB_DTV_SUCCESS;
- }
- void KB_SEARCHDestroy(void)
- {
- KB_SIStopAllSection();
- KB_DMDDropSignal();
- KD_SrchDis(0, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_CLEAN);
- }
- static void KD_SRCHHandleNit(void)
- {
- KB_DBNetInfo NetworkInfo;
- UINT16 i;
- gSrchFreNum = g_srchNit.num;
- for(i=0; i<gSrchFreNum; i++)
- {
- gSrchFre[i].type = DMD_TYPE_QAM;
- gSrchFre[i].inversion = INVERSION_AUTO;
-
- gSrchFre[i].frequency = g_srchNit.network[i].frequency / 10;
- gSrchFre[i].details.qam.modulation = g_srchNit.network[i].modulation;
- gSrchFre[i].details.qam.symbolRatekSs = g_srchNit.network[i].symbol_rate/10;
- gSrchFre[i].details.qam.fec_inner = g_srchNit.network[i].FEC_inner;
- }
- NetworkInfo.NitVersion = g_srchNit.version_number;
- memcpy(NetworkInfo.NetworkName,g_srchNit.network_name,20);
- NetworkInfo.NetworkName[21] = ' ';
- NetworkInfo.NetworkName[20] = ' ';
-
- KB_DBSaveNitInfo(&NetworkInfo);
- }
- static unsigned short KD_GetPmtPid(unsigned short i_nCallOpt, unsigned short * pmtPid,
- unsigned short * pmtPgmno)
- {
- static unsigned short count;
- if(i_nCallOpt == PMTPID_GET_FIRST)
- {
- count = 0;
- }
- if(count >= gSrchApp.pat->num)
- return KB_DB_DTV_FAILURE;
-
- while(gSrchApp.pat->program[count].program_number == 0)
- {
- count ++;
- if(count >= gSrchApp.pat->num)
- return KB_DB_DTV_FAILURE;
- }
- *pmtPid = gSrchApp.pat->program[count].program_map_PID;
- *pmtPgmno = gSrchApp.pat->program[count].program_number;
- count ++;
- return KB_DB_DTV_SUCCESS;
- }
- static void KD_SrchNvodInit(void)
- {
- _iRefSvcNums = _iTotalShiftSvcNums = 0;
- }
- static void KD_SrchHandleNovd(KB_SISdtStruct * i_pstSdt, int i_nNum)
- {
- int i;
- int loop;
- if(i_nNum > 1000)
- return;
- for(i = 0; i < i_nNum; i ++)
- {
- if(i_pstSdt[i].service_type == 0x04)
- {
- if(_iRefSvcNums >= KB_SI_MAX_REF_SVC_NUMS)
- {
- continue;
- }
-
- if( i_pstSdt[i].TimeShiftedNum == 0 ||
- i_pstSdt[i].TimeShiftedNum >= KB_SI_MAX_SHIFT_SVC_NUMS)
- {
- continue;
- }
-
- for(loop = 0; loop < _iRefSvcNums; loop ++)
- {
- if(i_pstSdt[i].service_id == _astNvodCell[loop].refScvId)
- {
- break;
- }
- }
- if(loop < _iRefSvcNums)
- {
- continue;
- }
- _astNvodCell[_iRefSvcNums].refScvId = i_pstSdt[i].service_id;
- _astNvodCell[_iRefSvcNums].freq = (UINT16)(gSrchApp.tsParams.frequency / 100);
- _astNvodCell[_iRefSvcNums].symb = (UINT16)gSrchApp.tsParams.details.qam.symbolRatekSs;
- _astNvodCell[_iRefSvcNums].qam = gSrchApp.tsParams.details.qam.modulation;
- _astNvodCell[_iRefSvcNums].shiftSvcNum = i_pstSdt[i].TimeShiftedNum;
- memcpy((char*)_astNvodCell[_iRefSvcNums].refScvName,(char*)i_pstSdt[i].chinese.service_name,18);
- _astNvodCell[_iRefSvcNums].refScvName[18]=' ';
- _astNvodCell[_iRefSvcNums].refScvName[19]=' ';
-
- if(_astNvodCell[_iRefSvcNums].shiftSvcNum > 0)
- {
- _astNvodCell[_iRefSvcNums].TsID = i_pstSdt[i].TimeShift[0].TS_ID;
- }
- else
- {
- _astNvodCell[_iRefSvcNums].TsID = 0;
- }
-
- for(loop = 0; loop < _astNvodCell[_iRefSvcNums].shiftSvcNum; loop ++)
- {
- _astNvodCell[_iRefSvcNums].shiftSvc[loop].tsId = i_pstSdt[i].TimeShift[loop].TS_ID;
- _astNvodCell[_iRefSvcNums].shiftSvc[loop].netId = i_pstSdt[i].TimeShift[loop].OrgnetID;
- _astNvodCell[_iRefSvcNums].shiftSvc[loop].svcId = i_pstSdt[i].TimeShift[loop].ServiceID;
- }
- _iRefSvcNums ++;
- }
- #if 0
- else if(i_pstSdt[i].service_type == 0x05)
- {
- if(_iTotalShiftSvcNums >= KB_SI_MAX_REF_SVC_NUMS * KB_SI_MAX_SHIFT_SVC_NUMS)
- continue;
- _alShiftSvc[_iTotalShiftSvcNums] =
- ( ((UINT32)i_pstSdt[i].service_id << 16) & 0xffff0000 ) | (UINT32)i_pstSdt[i].reference_service_id;
- _iTotalShiftSvcNums ++;
- }
- #endif
- }
- }
- static void KD_SrchAdjustNvod(void)
- {
- int i;
- //unsigned long temp;
- //int loop, j;
- //int sum;
- //KB_SIRefSvcCell refSvc;
- #if 0
- sum = 0;
- memset(&refSvc,0,sizeof(KB_SIRefSvcCell));
- for(i = 0; i < _iRefSvcNums; i ++)
- {
- refSvc.refScvId = _astNvodCell[i].refScvId;
- refSvc.TsID = _astNvodCell[i].TsID;
- refSvc.freq = _astNvodCell[i].freq;
- refSvc.symb = _astNvodCell[i].symb;
- refSvc.qam = _astNvodCell[i].qam;
- refSvc.shiftSvcNum = 0;
- strcpy((char*)refSvc.refScvName,(char*)_astNvodCell[i].refScvName);
-
- for(j = 0; j < _astNvodCell[i].shiftSvcNum; j ++)
- {
- temp = ( ((UINT32)_astNvodCell[i].shiftSvc[j].svcId << 16) & 0xffff0000 ) | (UINT32)_astNvodCell[i].refScvId;
- for(loop = 0; loop < _iTotalShiftSvcNums; loop ++)
- {
- if(temp == _alShiftSvc[loop])
- break;
- }
- if(loop < _iTotalShiftSvcNums)
- {
- refSvc.shiftSvc[refSvc.shiftSvcNum].tsId = _astNvodCell[i].shiftSvc[j].tsId;
- refSvc.shiftSvc[refSvc.shiftSvcNum].netId = _astNvodCell[i].shiftSvc[j].netId;
- refSvc.shiftSvc[refSvc.shiftSvcNum].svcId = _astNvodCell[i].shiftSvc[j].svcId;
- refSvc.shiftSvcNum ++;
- }
- }
- if(refSvc.shiftSvcNum > 0)
- {
- memcpy(&_astNvodCell[sum], &refSvc, sizeof(KB_SIRefSvcCell));
- sum ++;
- }
- }
- _iRefSvcNums = sum;
- #endif
- for(i = 0; i < _iRefSvcNums; i ++)
- {
- KB_DBSaveNvodInfo(_astNvodCell[i]);
- }
- }
- /****///wisco
- int dtv_NUM,radio_NUM;
- int get_dtv_num(void)
- {
- int tv_no;
- tv_no = dtv_NUM;
- dtv_NUM = 0;
- return tv_no;
- }
- int get_radio_num(void)
- {
- int r_no;
- r_no = radio_NUM;
- radio_NUM = 0;
- return r_no;
- }
- /****/
- static void KD_SrchDis(UINT32 nPara1, UINT32 nPara2, UINT8 nDisTypeEx,
- UINT8 nDisType)
- {
- //int i;
- //int count;
- KB_OSPMsgNode msgNode;
- memset(&msgNode,0,sizeof(KB_OSPMsgNode));
-
- switch(nDisType)
- {
- case KB_SEARCH_DIS_PGMNUM:
- {
- KB_OSPMsgNode movie_msg;
-
- printf("-=KB_SEARCH_DIS_PGMNUM=-n");
- msgNode.Word1 = J_AV_SEARCH_MODULE;
- msgNode.Word2 = KB_SEARCH_MSG_UPDATE_AVPGM_NUM;
- msgNode.Word3 = nPara1;
- msgNode.Word4= nPara2;
- dtv_NUM = (int)msgNode.Word3;
- radio_NUM= (int)msgNode.Word4;
- //send msg to movie client
- movie_msg.Word1= KB_MOVIE_LC_TO_MOVIE;
- movie_msg.Word2=20;
- kb_machblue_task_post(&movie_msg);
- }
- break;
- case KB_SEARCH_DIS_HELPHINT:
- printf("-=KB_SEARCH_DIS_HELPHINT: nDisTypeEx=%d=-n", nDisTypeEx);
- {
- msgNode.Word1 = J_AV_SEARCH_MODULE;
- msgNode.Word2 = KB_SEARCH_MSG_UPDATE_HINT;
- msgNode.Word3 = nDisTypeEx;
- if (nDisTypeEx!=2)
- {
- //send msg to movie client
- KB_OSPMsgNode movie_msg;
-
- movie_msg.Word1= KB_MOVIE_LC_TO_MOVIE;
- movie_msg.Word2=msgNode.Word3;
- kb_machblue_task_post(&movie_msg);
- }
- else
- {
- //send msg to movie client
- KB_OSPMsgNode movie_msg;
-
- movie_msg.Word1= KB_MOVIE_LC_TO_MOVIE;
- movie_msg.Word2=20;
- kb_machblue_task_post(&movie_msg);
- }
- }
- break;
- case KB_SEARCH_DIS_PLANHINT:
- printf("-=KB_SEARCH_DIS_PLANHINT, nPara1:%ld=-n", nPara1);
- {
- if (0 == nPara2)
- {
- msgNode.Word1 = J_AV_SEARCH_MODULE;
- msgNode.Word2 = KB_SEARCH_MSG_UPDATE_PROGRESS;
- msgNode.Word3 = (UINT32)nPara1;
- //KB_MENUTranslateMsg(&msgNode);
- }
- }
- break;
- case KB_SEARCH_DIS_FREQ:
- printf("-=KB_SEARCH_DIS_FREQ:nPara2=%ld=-n", nPara2);
- {
-
- if (0 == nPara1)
- {
- KB_OSPMsgNode movie_msg;
-
- msgNode.Word1 = J_AV_SEARCH_MODULE;
- msgNode.Word2 = KB_SEARCH_MSG_UPDATE_FREQ;
- msgNode.Word3 = (UINT32)nPara2;
-
- //send msg to movie client
- movie_msg.Word1= KB_MOVIE_LC_TO_MOVIE;
- movie_msg.Word2=msgNode.Word3;
- kb_machblue_task_post(&movie_msg);
- }
- }
- break;
- default:
- break;
- }
- }
- static void KD_SrchSetFre(UINT8 nSrchMode)
- {
- UINT8 i;
- KB_DMDTunerParameters tTs;
- switch(nSrchMode)
- {
- case KB_SEARCH_IN_TS:
- gSrchFre[0] = gSrchApp.tsParams;
- gSrchFreNum = 1;
- gSrchFre[0].frequency=gSrchApp.tsParams.frequency;
- gSrchFre[0].type = DMD_TYPE_QAM;
- gSrchFre[0].inversion = INVERSION_AUTO;
- gSrchFre[0].details.qam.symbolRatekSs = 6875;
- gSrchFre[0].details.qam.modulation = QAM_64;
- break;
-
- case KB_SEARCH_IN_NET:
- KB_SIStopAllSection();
-
- KB_DMDGetSignalParameters(&tTs);
- if (memcmp(&tTs,&gSrchApp.tsParams,sizeof(KB_DMDTunerParameters)) != 0)
- {
- KB_DMDDropSignal();
- //printf("-=KD_SrchSetFre:gSrchApp.tsParams.frequency=%ld=-n", gSrchApp.tsParams.frequency);
- KB_DMDConnectSignal(&gSrchApp.tsParams);
- }
-
- KB_SIGetNit(0x10, &g_srchNit, KB_SI_RECEIVE_ONCE, -1);
- gSrchApp.srchState = KB_SEARCH_WAITING_NIT;
- break;
-
- case KB_SEARCH_IN_WHOLE_NET:
- gSrchFreNum = WHOLE_NET_FREQ_SUM;
-
- for(i=0; i<gSrchFreNum; i++)
- {
- gSrchFre[i].frequency = g_WholeNetFreqs[i]* 1000;
- gSrchFre[i].type = DMD_TYPE_QAM;
- gSrchFre[i].inversion = INVERSION_AUTO;
- gSrchFre[i].details.qam.symbolRatekSs = 6875;
- gSrchFre[i].details.qam.modulation = QAM_64;
- }
- break;
-
- default:
- break;
- }
-
- }
- static void KD_SrchToNext(void)
- {
- UINT8 bHintProgress;
- UINT32 wFreqToShow;
-
- if (gSrchFreInx < gSrchFreNum )
- {
- wFreqToShow = gSrchFre[gSrchFreInx].frequency/100;
- KD_SrchDis(0,wFreqToShow,KB_SEARCH_DISABLED,KB_SEARCH_DIS_FREQ);
-
- bHintProgress = gSrchFreInx + 1;
- if (bHintProgress != gSrchFreNum)
- {
- bHintProgress = (bHintProgress * 100)/ (gSrchFreNum ) ;
- KD_SrchDis(bHintProgress, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_PLANHINT);
- }
- else
- {
- if (gSrchApp.srchMode == KB_SEARCH_IN_WHOLE_NET)
- {
- bHintProgress = ((gSrchFreInx * 100) + 50)/ (gSrchFreNum ) ;
- KD_SrchDis(bHintProgress, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_PLANHINT);
- }
- }
- KD_SrchParseInit(
- (unsigned short)(gSrchFre[gSrchFreInx].frequency/100),
- (unsigned short)(gSrchFre[gSrchFreInx].details.qam.symbolRatekSs),
- (unsigned char)gSrchFre[gSrchFreInx].details.qam.modulation);
-
- KB_SIStopAllSection();
- bCurrentFreqDtvNum =0;
- bCurrentFreqMusicNum =0;
-
- KB_DMDDropSignal();
- //printf("-=KD_SrchToNext:gSrchFre[%d].frequency=%ld=-n", gSrchFreInx, gSrchFre[gSrchFreInx].frequency);
- gSrchApp.tsParams = gSrchFre[gSrchFreInx];
- KB_DMDConnectSignal(&gSrchFre[gSrchFreInx]);
-
- gSrchApp.srchState = KB_SEARCH_WAITING_CNT;
-
- gSrchFreInx++;
- }
- else
- {
- KD_Srchend();
-
- }
- }
- static void KD_SrchSaveResult(void)
- {
- KB_DBAddPrgInfo(gSrchPrg,gSrchApp.svcIDnum,
- &bCurrentFreqDtvNum,&bCurrentFreqMusicNum);
-
- gSrchApp.dtvNum += bCurrentFreqDtvNum;
- gSrchApp.radNum += bCurrentFreqMusicNum;
- //因此, search搜索完成界面,只有视频、音频的更新
- KD_SrchDis(bCurrentFreqDtvNum, bCurrentFreqMusicNum, KB_SEARCH_DISABLED,
- KB_SEARCH_DIS_PGMNUM);
- }
- static void KD_Srchend(void)
- {
- gSrchApp.srchState = KB_SEARCH_WAITING_EXIT;
- KD_SrchAdjustNvod();
-
- KD_SrchDis(100, 0, KB_SEARCH_DISABLED, KB_SEARCH_DIS_PLANHINT);
- //KD_SrchDis(0, 0, KB_SEARCH_HINT7, KB_SEARCH_DIS_HELPHINT);
-
- KB_DBSavePrgInfo(1);
-
- switch(gSrchApp.srchMode)
- {
- case KB_SEARCH_IN_TS:
- KD_SrchDis(0, 0, KB_SEARCH_HINT8, KB_SEARCH_DIS_HELPHINT);
- break;
- case KB_SEARCH_IN_NET:
- KD_SrchDis(0, 0, KB_SEARCH_HINT9, KB_SEARCH_DIS_HELPHINT);
- break;
- case KB_SEARCH_IN_WHOLE_NET:
- KD_SrchDis(0, 0, KB_SEARCH_HINT10, KB_SEARCH_DIS_HELPHINT);
- break;
-
- default:
- break;
- }
- KB_DTVSetPreChnnl();
- }
- INT32 *KB_SrchGetWholeFreq(void)
- {
- return g_WholeNetFreqs;
- }
- KB_DMDTunerParameters *KB_SrchGetSrchFre(void)
- {
- return gSrchFre;
- }
- T_SEARCH_PARA *KB_SrchGetSrchApp(void)
- {
- return &gSrchApp;
- }
- //added by whale 07/07/12 start
- int KB_SrchGetNvodRefSrvNum(void)
- {
- return _iRefSvcNums;
- }
- //added by whale 07/07/12 end
- /* EOF */