/* DMW_PsiAPI.c DST TV MW PSI Scan Module PSI Scan API implementation Copyright 2006~2009 Digital STREAM Technology, Inc. All Rights Reserved */ #include "DMW_Platform.h" #define __DEFINE_PSIM_STRING__ #include "DMW_PsiAPI.h" #undef __DEFINE_PSIM_STRING__ #include "DMW_PsiEngine.h" #include "DMW_PsiDatabase.h" #if COMMENT ____API____(){} #endif /* PSI moduleÀ» ÃʱâÈ­ ÇÑ´Ù. */ STATUS DMW_PSI_Init(void) { STATUS status = statusOK; S_PSIM_CONTEXT *module; module = PSIE_InitEngine(); DHL_ASSERT(module != NULL, "psiengine_init err"); status = PSITASK_Init(module); DHL_ASSERT(status == statusOK, "psitask_init err"); return status; } /* ƯÁ¤ ts portÀÇ PSI/PSIP µ¥ÀÌÅÍ scanÀ» ½ÃÀÛÇÑ´Ù. ¿©±â¼­ ÁöÁ¤ÇÏ´Â @rf´Â ´Ü¼øÈ÷ id ¿ëµµ·Î¸¸ »ç¿ëÀÌ µÇ¸ç, ½ÇÁ¦ FrontEnd ¼³Á¤Àº caller°¡ ´ã´ç. @tsd Çϳª´ç ÇϳªÀÇ scan ÀÛ¾÷ÀÌ °¡´ÉÇÏ´Ù. N°³ÀÇ tsd°¡ µ¿½Ã¿¡ scan µÉ ¼ö ÀÖ´Ù. ÃÖ´ë tsd °¹¼ö´Â hardware ¸¶´Ù ´Ù¸¥µ¥, SW ³»ºÎÀûÀ¸·Î´Â MAX_TS_INPUT À¸·Î Á¦ÇѵǾî ÀÖ´Ù. flags: PSI_FLAGS_XXX °ªÀÇ Á¶ÇÕ. @program_number, @source_id ´Â PSI_FLAGS_AUTOSCAN °ú °°Àº ƯÁ¤ ¸ðµå¿¡¼­´Â »ç¿ëµÇÁö ¾Ê´Â´Ù. ±× ¿Ü¿¡´Â Á¤È®ÇÑ °ªÀ» ÁöÁ¤ÇØ Áà¾ß ÇÑ´Ù. */ STATUS DMW_PSI_StartUpdate(tDHL_TSD tsd, int rf, int program_number, int source_id, UINT32 flags, F_PSIM_EVENT_PROC userproc, UINT32 userparam) { S_PSIM_USER_INPUT input; input.rf = rf; input.program_number = program_number; input.source_id = source_id; input.flags = flags; input.userproc = userproc; input.userparam = userparam; // we can use local variable because we use sync'ed call. // bWait should be "TRUE". return PSITASK_SendCommand(ePSIM_CMD_ScanStart, (UINT32)tsd, (UINT32)&input, TRUE); // jump to PsiMsgHandler_ScanStart } /* ÁöÁ¤ÇÑ @tsd Æ÷Æ®ÀÇ µ¿ÀÛ ÁßÀÎ psi scan ÀÛ¾÷À» Áß´ÜÇÑ´Ù. ±× ¿ÜÀÇ tsd Æ÷Æ® scan ÀÛ¾÷Àº ¿µÇâ ¹ÞÁö ¾Ê°í °è¼Ó µÈ´Ù. */ void DMW_PSI_CancelUpdate(tDHL_TSD tsd) { PSITASK_SendCommand(ePSIM_CMD_ScanStop, (UINT32)tsd, 0, TRUE); // jump to PsiMsgHandler_ScanStop } /* PSI DBÀÇ °¢Á¾ Å×À̺íÀ» Á¦°Å. @rf ¸¦ ÁöÁ¤Çϸé ÇØ´ç rfÀÇ Tables ¸¸ »èÁ¦Çϰí, @rf ·Î 0À» ÁöÁ¤ÇÏ¸é ¸ðµç TableµéÀ» »èÁ¦ÇÑ´Ù. */ void DMW_PSI_DeleteTables(int rf) { PSITASK_SendCommand(ePSIM_CMD_DeleteTables, rf, 0, TRUE); // jump to PsiMsgHandler_DeleteTables } /* PSI DB¿¡ Á¢±ÙÇϱâ À§Çؼ­ »ç¿ëÇÏ´Â mutex lock API. Rule: PsiTask ¿¡¼­ DB´Â ÀÚÀ¯·Ó°Ô ÀÐÀ» ¼ö ÀÖÀ½. PsiTask ¿¡¼­´Â Lock ÈÄ DB ¼öÁ¤ °¡´É. ÀÓÀÇ task¿¡¼­´Â Lock ÈÄ DB Àб⠰¡´É. ÀÓÀÇ task¿¡¼­ DBÀÇ º¯°æÀº Àý´ë ±ÝÁö. */ void DMW_PSI_LockDB(BOOL bLock) { PSIDB_LockDB(bLock); } S_PSIM_CHINFO *DMW_PSI_GetChInfo(int rf) { return PSIDB_GetPsiChInfo(rf); } S_PSIM_SUBCHINFO *DMW_PSI_GetSubChInfo(int rf, int source_id) { return PSIDB_GetPsiSubChInfo(rf, source_id); } #if 0 STATUS DMW_PSI_GetCurrentProgramInfo (TSD *tsd, DPG_ProgramInfo *info) { } STATUS DMW_PSI_FreeProgramInfo (DPG_ProgramInfo *info) { } #endif const char *DMW_PSI_ScanStatusString(E_PSIM_SCAN_STATUS e) { return PSIM_SCAN_STATUS_STRING(e); } const char *DMW_PSI_EventString(E_PSIM_EVENT e) { return PSIM_EVENT_STRING(e); } #if COMMENT ____Test____(){} #endif #define OS_DbgPrintf DHL_OS_Printf void TEST_PSI_TryTune(int rf, int pn, int sid) { S_PSIM_CHINFO *chInfo; int i; MPEG_PMT *pmt = NULL; DMW_PSI_LockDB(TRUE); chInfo = DMW_PSI_GetChInfo(rf); if (chInfo) { OS_DbgPrintf("### pat %x, vct %x\n", chInfo->pat, chInfo->vct); if (chInfo->pat && chInfo->pmts) { for (i=0; ipat->numPrograms; i++) { if (chInfo->pmts[i]->program_number == pn) { pmt = chInfo->pmts[i]; OS_DbgPrintf("### pmt[%d] %x\n", i, pmt); break; } } if (pmt && chInfo->vct) { // get pid info using chInfo->vct and pmt.. // // vpid = xx, apid = xx.. OS_DbgPrintf("### ready for AV start..\n"); } } } DMW_PSI_LockDB(FALSE); // tune! } void TEST_PSI_EventProc(tDHL_TSD tsd, E_PSIM_EVENT evt, UINT32 param) { if (0); else if (evt == ePSIM_EVENT_PatReceived) { //MPEG_PAT *pat = (MPEG_PAT *)status; //OS_DbgPrintf("\n\n ######## event, pat %x received, user %x\n\n\n", // pat, param->userparam); } //-------------------------------------- // belows are for viewing & recording else if (evt == ePSIM_EVENT_PmtReceived) { MPEG_PMT *pmt = (MPEG_PMT *)param; OS_DbgPrintf("\n\n ######## event, pmt %x received, user %x\n", pmt); //TEST_PSI_TryTune(param->rf, param->program_number, param->source_id); OS_DbgPrintf("\n\n"); } else if (evt == ePSIM_EVENT_VctReceived) { xvctPtr_t vct = (xvctPtr_t)param; OS_DbgPrintf("\n\n ######## event, vct %x received\n", vct); //TEST_PSI_TryTune(param->rf, param->program_number, param->source_id); OS_DbgPrintf("\n\n"); } //-------------------------------------- // belows are for autoscan.. else if (evt == ePSIM_EVENT_BasePsipReceived) { OS_DbgPrintf("\n\n ######## event, base psip received\n"); OS_DbgPrintf("\n\n"); } else if (evt == ePSIM_EVENT_AllPmtsReceived) { OS_DbgPrintf("\n\n ######## event, all pmts received\n"); OS_DbgPrintf("\n\n"); } } void TEST_PSI_Init(void) { //extern STATUS Dmc_PausePsiMonitor(UINT32 bPause); //extern UINT8 g_Trace_PsiFilter, g_Trace_PsiFilterTidCount; Dmc_PausePsiMonitor(TRUE); // compiler warning will be removed later.. //g_Trace_PsiFilter = 4; //g_Trace_PsiFilterTidCount = 20; DHL_DBG_SetModuleLevel("psieng", 3); DHL_DBG_SetModuleLevel("psitsk", 3); DMW_PSI_Init(); } void TEST_PSI_Scan(int rf) { tDHL_TSD *tsd = DHL_DMX_GetTsd(); DMW_PSI_StartUpdate(tsd, rf, 0, 0, PSI_FLAGS_AUTOSCAN, TEST_PSI_EventProc, 0x11); } void TEST_PSI_Start(int rf, int pn, int si) { tDHL_TSD *tsd = DHL_DMX_GetTsd(); DMW_PSI_StartUpdate(tsd, rf, pn, si, PSI_FLAGS_NORMAL, TEST_PSI_EventProc, ((pn & 0xffff)<<16) | (si & 0xffff)); } void TEST_PSI_Stop(int rf) { tDHL_TSD *tsd = DHL_DMX_GetTsd(); DMW_PSI_CancelUpdate(tsd); } #if 0 // Dmc_GetMainChannelTables(TSD * tsd, DmcMainTables * tbls, int timeOut, BOOL(* ckfn)(UINT32)) STATUS DMW_XXX_GetTablesForAutoScan (tsd, rf, timeout, cancelchk, tbls [out]) { } #endif