| 1 | /* |
|---|
| 2 | DMW_PsiEngine.h |
|---|
| 3 | |
|---|
| 4 | DST TV MW PSI Scan Module |
|---|
| 5 | |
|---|
| 6 | PSI Scan Core Engine implementation |
|---|
| 7 | |
|---|
| 8 | Copyright 2006~2010 Digital STREAM Technology, Inc. |
|---|
| 9 | All Rights Reserved |
|---|
| 10 | |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #ifndef __DMW_PSI_ENGINE_H__ |
|---|
| 15 | #define __DMW_PSI_ENGINE_H__ |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #include "DMW_PsiConfig.h" |
|---|
| 19 | #include "DMW_PsiTypes.h" |
|---|
| 20 | |
|---|
| 21 | #include "DMW_PsiAPI.h" |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #ifdef __cplusplus |
|---|
| 25 | extern "C" { |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | #if COMMENT |
|---|
| 31 | ____Overview____(){} |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | #if COMMENT |
|---|
| 39 | ____PortInfo____(){} |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | /* |
|---|
| 44 | Transport stream Port Context |
|---|
| 45 | |
|---|
| 46 | TS ÀԷ ä³Î ´ç Çϳª¾¿ Á¸Àç. |
|---|
| 47 | ÇØ´ç TS ÀԷ ä³ÎÀÇ µ¿ÀÛ |
|---|
| 48 | |
|---|
| 49 | ÇöÀç Port´Â stateless À̰í, ÀÔ·Â event¿¡ µû¶ó¼ ÇØ´çµÇ´Â µ¿ÀÛÀ» ÇÏ´Â ±¸Á¶ÀÌ´Ù. |
|---|
| 50 | Áï PAT¸¦ ¹ÞÀ¸¸é PMT¸¦ monitorÇÏÁö, ÇöÀç pat_received_state µî°ú °°Àº state º¯¼ö°¡ ¾ø´Ù. |
|---|
| 51 | |
|---|
| 52 | */ |
|---|
| 53 | |
|---|
| 54 | struct S_PSIM_TASK_t; |
|---|
| 55 | |
|---|
| 56 | typedef struct |
|---|
| 57 | { |
|---|
| 58 | tDHL_TSD tsd; |
|---|
| 59 | |
|---|
| 60 | S_PSIM_USER_INPUT input; |
|---|
| 61 | |
|---|
| 62 | //struct S_PSIM_TASK_t *context; |
|---|
| 63 | // back link |
|---|
| 64 | |
|---|
| 65 | //------- |
|---|
| 66 | int n_active_monitors; // ÇöÀç °¡µ¿ ÁßÀÎ ÃÑ psi monitor °¹¼ö. |
|---|
| 67 | |
|---|
| 68 | int max_monitors; // ÃÖ´ë »ç¿ë °¡´ÉÇÑ monitor °¹¼ö. |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | //------- |
|---|
| 72 | // program change monitor |
|---|
| 73 | int last_event_id; |
|---|
| 74 | |
|---|
| 75 | //------- |
|---|
| 76 | // psi monitor controls |
|---|
| 77 | |
|---|
| 78 | tDHL_PSI_ControlHandle patPsiCtl; |
|---|
| 79 | |
|---|
| 80 | int num_programs; // number of below pmtPsiCtlArray. |
|---|
| 81 | // ¿¹¿Ü »óȲ¿¡¼± num_programs°¡ 0ÀÏ °æ¿ìµµ ÀÖÀ½. |
|---|
| 82 | |
|---|
| 83 | tDHL_PSI_ControlHandle *pmtPsiCtlArray; |
|---|
| 84 | |
|---|
| 85 | //------- |
|---|
| 86 | // psip monitor controls |
|---|
| 87 | |
|---|
| 88 | tDHL_PSI_ControlHandle mgtPsiCtl, sttPsiCtl, tvctPsiCtl, cvctPsiCtl, rrtPsiCtl, easPsiCtl; |
|---|
| 89 | |
|---|
| 90 | // source_id |
|---|
| 91 | UINT16 source_id; // source id of subchannel which is being downloaded. |
|---|
| 92 | // óÀ½ psi scan ½ÃÀÛÇÒ ¶§¿¡´Â user inputÀÇ source_id ¿Í µ¿ÀÏÇϰÚÁö¸¸ |
|---|
| 93 | // ½Ã°£ÀÌ Áö³ª¸é¼ subchannelÀÌ complete°¡ µÇ¸é |
|---|
| 94 | // ´Ù¸¥ subchannel·Î ÀÚµ¿ °Ë»ö ÀüȯµÉ ¶§ º¯°æµÈ´Ù. |
|---|
| 95 | |
|---|
| 96 | tDHL_PSI_ControlHandle eitPsiCtl[128]; |
|---|
| 97 | |
|---|
| 98 | tDHL_PSI_ControlHandle ettPsiCtl[128]; |
|---|
| 99 | tDHL_PSI_ControlHandle ettvPsiCtl; // channel-ett |
|---|
| 100 | |
|---|
| 101 | } S_PSIM_PORT; |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | #if COMMENT |
|---|
| 105 | ____State____(){} |
|---|
| 106 | #endif |
|---|
| 107 | |
|---|
| 108 | /* |
|---|
| 109 | module state. |
|---|
| 110 | |
|---|
| 111 | multi-tuner°¡ Áö¿øµÇ¾î¾ß ÇÑ´Ù¸é psi moduleÀÇ »óź¸´Ù´Â |
|---|
| 112 | °¢ tunerÀÇ »óŰ¡ ´õ Áß¿äÇϹǷÎ, »ç½Ç »ç¿ëµÇÁö ¾ÊÀ½. |
|---|
| 113 | |
|---|
| 114 | ÀÌ ºÎºÐÀº ¾ÕÀ¸·Îµµ »ç¿ëµÇÁö ¾ÊÀ» °Í °°À½. |
|---|
| 115 | */ |
|---|
| 116 | |
|---|
| 117 | typedef enum |
|---|
| 118 | { |
|---|
| 119 | ePSIM_MODULE_STATE_Init, |
|---|
| 120 | |
|---|
| 121 | ePSIM_MODULE_STATE_Idle, |
|---|
| 122 | |
|---|
| 123 | //ePSIM_MODULE_STATE_Scanning, |
|---|
| 124 | // scanning ÀÛ¾÷Àº °¢ Æ÷Æ®º°·Î °¢°¢ ÁøÇàµÇ¹Ç·Î |
|---|
| 125 | // taskÀÇ state·Î º¸±ä ¾î·Æ´Ù. |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | } E_PSIM_MODULE_STATE; |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | #if COMMENT |
|---|
| 133 | ____Context____(){} |
|---|
| 134 | #endif |
|---|
| 135 | |
|---|
| 136 | #define PSI_ENGINE_MAGICKEY 0x31415926 |
|---|
| 137 | |
|---|
| 138 | /* |
|---|
| 139 | PSI engineÀÇ context |
|---|
| 140 | |
|---|
| 141 | ÇöÀç·Î¼´Â module state¿Í port Á¤º¸ »ÓÀÌ´Ù. |
|---|
| 142 | |
|---|
| 143 | */ |
|---|
| 144 | |
|---|
| 145 | typedef struct |
|---|
| 146 | { |
|---|
| 147 | UINT32 magic; // valid marker |
|---|
| 148 | |
|---|
| 149 | E_PSIM_MODULE_STATE state; |
|---|
| 150 | |
|---|
| 151 | S_PSIM_PORT tsport[MAX_TS_INPUT]; |
|---|
| 152 | |
|---|
| 153 | } S_PSIM_CONTEXT; |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | #if COMMENT |
|---|
| 160 | ____TaskCommand____(){} |
|---|
| 161 | #endif |
|---|
| 162 | |
|---|
| 163 | /* |
|---|
| 164 | API ¶Ç´Â event¿¡¼ psi engine task·Î Àü´ÞÇÏ´Â ¸í·É. |
|---|
| 165 | |
|---|
| 166 | */ |
|---|
| 167 | typedef enum |
|---|
| 168 | { |
|---|
| 169 | // command from external clients |
|---|
| 170 | |
|---|
| 171 | ePSIM_CMD_ScanStart = 0x10, |
|---|
| 172 | // [0] tDHL_TSD *tsd |
|---|
| 173 | // [1] S_PSIM_USER_INPUT *input |
|---|
| 174 | |
|---|
| 175 | ePSIM_CMD_ScanStop, |
|---|
| 176 | // [0] tDHL_TSD *tsd |
|---|
| 177 | // [1] -- |
|---|
| 178 | |
|---|
| 179 | ePSIM_CMD_DeleteTables, |
|---|
| 180 | // [0] int id (rf). if id is 0, delete all tables. |
|---|
| 181 | // [1] -- |
|---|
| 182 | |
|---|
| 183 | // event from HAL/driver |
|---|
| 184 | |
|---|
| 185 | ePSIM_CMD_TableReceived, |
|---|
| 186 | // [0] S_PSIM_PORT *tsport |
|---|
| 187 | // [1] tDHL_PSIDataArray *desc |
|---|
| 188 | |
|---|
| 189 | //ePSIM_CMD_PatReceived, |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | // belows are internal use. |
|---|
| 194 | |
|---|
| 195 | ePSIM_CMD_Init, |
|---|
| 196 | ePSIM_CMD_Exit, |
|---|
| 197 | |
|---|
| 198 | } E_PSIM_CMD; |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | #if COMMENT |
|---|
| 204 | ____Task____(){} |
|---|
| 205 | #endif |
|---|
| 206 | |
|---|
| 207 | STATUS PSITASK_Init(void *pModuleContext); |
|---|
| 208 | |
|---|
| 209 | STATUS PSITASK_SendCommand(E_PSIM_CMD cmd_id, UINT32 payload_0, UINT32 payload_1, BOOL bWait); |
|---|
| 210 | |
|---|
| 211 | BOOL PSITASK_IsPsiTask(void); |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | #if COMMENT |
|---|
| 216 | ____Engine____(){} |
|---|
| 217 | #endif |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | E_PSIM_MODULE_STATE PSIE_GetModuleState(S_PSIM_CONTEXT *pContext); |
|---|
| 221 | void PSIE_ChangeModuleState(S_PSIM_CONTEXT *pContext, E_PSIM_MODULE_STATE newState); |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | STATUS PSIE_StartPsiScan(S_PSIM_CONTEXT *pContext, tDHL_TSD tsd, S_PSIM_USER_INPUT *input); |
|---|
| 225 | STATUS PSIE_StopPsiScan(S_PSIM_CONTEXT *pContext, tDHL_TSD tsd); |
|---|
| 226 | STATUS PSIE_StopAllPsiScan(S_PSIM_CONTEXT *pContext); |
|---|
| 227 | |
|---|
| 228 | STATUS PSIE_DeleteTables(S_PSIM_CONTEXT *pContext, int id); |
|---|
| 229 | |
|---|
| 230 | STATUS PSIE_ProcessReceivedTable(S_PSIM_CONTEXT *pContext, S_PSIM_PORT *tsport, tDHL_PSI_DataArray *desc); |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | void PSIE_DoPeridicProcessing(S_PSIM_CONTEXT *pContext); |
|---|
| 234 | |
|---|
| 235 | #define PSIM_WAIT_FOREVER ((UINT32)-1) |
|---|
| 236 | UINT32 PSIE_GetTimeout(S_PSIM_CONTEXT *pContext); |
|---|
| 237 | |
|---|
| 238 | S_PSIM_CONTEXT *PSIE_InitEngine(void); |
|---|
| 239 | S_PSIM_CONTEXT *PSIE_GetEngine(void); |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | #ifdef __cplusplus |
|---|
| 243 | } /* extern "C" */ |
|---|
| 244 | #endif |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | #endif // __DMW_PSI_ENGINE_H__ |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | |
|---|