| 1 | /** |
|---|
| 2 | @file |
|---|
| 3 | DLIB_PSIP_Monitor.c |
|---|
| 4 | |
|---|
| 5 | @brief |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #include "DHL_DBG.h" |
|---|
| 10 | #include "DHL_PSI.h" |
|---|
| 11 | |
|---|
| 12 | #include "DLIB_PSIP.h" |
|---|
| 13 | #include "DLIB_PSIP_Monitor.h" |
|---|
| 14 | |
|---|
| 15 | #include "DLIB_PSIP_Parser.h" |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #if COMMENT |
|---|
| 20 | ____Config____(){} |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #if COMMENT |
|---|
| 27 | ____Types____(){} |
|---|
| 28 | #endif |
|---|
| 29 | |
|---|
| 30 | #define psi_section_length(ptr) ((((ptr[1])<<8)+(ptr[2]))&0x0FFF) |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | #if COMMENT |
|---|
| 34 | ____Variables____(){} |
|---|
| 35 | #endif |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | #if COMMENT |
|---|
| 39 | ____Misc____(){} |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | char *psi_event_string(tDHL_PSI_Event event) |
|---|
| 43 | { |
|---|
| 44 | switch(event) { |
|---|
| 45 | case ePSIEVENT_NOEVENT: return("psiNoEvent"); |
|---|
| 46 | case ePSIEVENT_DUP3PACKET: return("psiDup3Packet"); |
|---|
| 47 | case ePSIEVENT_LOSTPACKET: return("psiLostPacket"); |
|---|
| 48 | case ePSIEVENT_DISCONTINUITY: return("psiDiscontinuity"); |
|---|
| 49 | case ePSIEVENT_SPLICINGPOINT: return("psiSplicingPoint"); |
|---|
| 50 | case ePSIEVENT_SYNCERR: return("psiSyncErr"); |
|---|
| 51 | case ePSIEVENT_SCRAMBLEDERROR: return("psiScrambledErr"); |
|---|
| 52 | // case ePSIEVENT_SECTIONRECEIVED: return("psiSectionReceived"); not used |
|---|
| 53 | case ePSIEVENT_DATARECEIVED: return("psiDataReceived"); |
|---|
| 54 | case ePSIEVENT_MEMORYERROR: return("psiMemoryError"); |
|---|
| 55 | case ePSIEVENT_SECTIONTOOBIG: return("psiSectionTooBig"); |
|---|
| 56 | case ePSIEVENT_CRCERROR: return("psiCRCError"); |
|---|
| 57 | case ePSIEVENT_CRCUNCHANGED: return("psiCRCUnchanged"); |
|---|
| 58 | case ePSIEVENT_VERSIONCHANGED: return("psiVersionChanged"); |
|---|
| 59 | case ePSIEVENT_MAXSECTIONOVERFLOW: return("psiMaxSectionOverflow"); |
|---|
| 60 | case ePSIEVENT_LASTSECTIONOVERFLOW:return("psiLastSectionOverflow"); |
|---|
| 61 | case ePSIEVENT_KILLUSRTASK: return("killUserTask"); |
|---|
| 62 | case ePSIEVENT_FIFOFULLEVENT: return("psiFifoFullEvent"); |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | default: return("unknown DHL_PSIEvent"); |
|---|
| 66 | |
|---|
| 67 | } |
|---|
| 68 | /*!PRM unreachable TLASSERT(0,"PSIEventString: bad DHL_PSIEvent"); |
|---|
| 69 | return("???");*/ |
|---|
| 70 | |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | #if COMMENT |
|---|
| 75 | ____Monitor____(){} |
|---|
| 76 | #endif |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | DHL_RESULT MonitorStt (tDHL_TSD tsd, tDHL_PSI_Update updateMode, tDHL_PSI_EventProc eventProc, |
|---|
| 80 | UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 81 | { |
|---|
| 82 | tDHL_PSI_Filter *pref; |
|---|
| 83 | DHL_RESULT err; |
|---|
| 84 | |
|---|
| 85 | /* Set up the Table ID filter */ |
|---|
| 86 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_system_time_table,TRUE))) { |
|---|
| 87 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 88 | return(err); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 92 | #if 1//BRCM |
|---|
| 93 | pref->mask[8] = 0; |
|---|
| 94 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 95 | #else |
|---|
| 96 | pref->mask[8] = 0xff; |
|---|
| 97 | pref->mode[8] = 0xff; |
|---|
| 98 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 99 | #endif |
|---|
| 100 | /* Set up PID Filter */ |
|---|
| 101 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, ePSIMODE_SECTION, // section only |
|---|
| 102 | updateMode, pref, 1024, 1, |
|---|
| 103 | eventProc, userParam, psiCtl))) { |
|---|
| 104 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 105 | DHL_PSI_FreeFilter(pref); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | return(err); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | DHL_RESULT MonitorMgt (tDHL_TSD tsd, tDHL_PSI_Update updateMode, |
|---|
| 113 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 114 | { |
|---|
| 115 | tDHL_PSI_Filter *pref; |
|---|
| 116 | DHL_RESULT err; |
|---|
| 117 | |
|---|
| 118 | /* Set up the Table ID filter */ |
|---|
| 119 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_master_guide_table,TRUE))) { |
|---|
| 120 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 121 | return(err); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 125 | #if 1//BRCM |
|---|
| 126 | pref->mask[8] = 0; |
|---|
| 127 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 128 | #else |
|---|
| 129 | pref->mask[8] = 0xff; |
|---|
| 130 | pref->mode[8] = 0xff; |
|---|
| 131 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 132 | #endif |
|---|
| 133 | /* Set up PID Filter */ |
|---|
| 134 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, ePSIMODE_SECTION, // section only |
|---|
| 135 | updateMode, pref, 4096, 1, // 1 section max 4K |
|---|
| 136 | eventProc, userParam, psiCtl))) { |
|---|
| 137 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 138 | DHL_PSI_FreeFilter(pref); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | return(err); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | DHL_RESULT MonitorTvct (tDHL_TSD tsd, tDHL_PSI_Mode psiMode, tDHL_PSI_Update updateMode, |
|---|
| 145 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 146 | { |
|---|
| 147 | tDHL_PSI_Filter *pref; |
|---|
| 148 | DHL_RESULT err; |
|---|
| 149 | UINT32 maxSections; |
|---|
| 150 | |
|---|
| 151 | /* Set up the Table ID filter */ |
|---|
| 152 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_terr_virtual_chan_table,TRUE))) |
|---|
| 153 | { |
|---|
| 154 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 155 | return(err); |
|---|
| 156 | } |
|---|
| 157 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 158 | #if 1//BRCM |
|---|
| 159 | pref->mask[8] = 0; |
|---|
| 160 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 161 | #else |
|---|
| 162 | pref->mask[8] = 0xff; |
|---|
| 163 | pref->mode[8] = 0xff; |
|---|
| 164 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 165 | #endif |
|---|
| 166 | maxSections = (psiMode == ePSIMODE_TABLE) ? 256 : 1; |
|---|
| 167 | |
|---|
| 168 | /* Set up PID Filter */ |
|---|
| 169 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, psiMode, |
|---|
| 170 | updateMode, pref, 1024, maxSections, // |
|---|
| 171 | eventProc, userParam, psiCtl))) { |
|---|
| 172 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 173 | DHL_PSI_FreeFilter(pref); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | return(err); |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | DHL_RESULT MonitorCvct (tDHL_TSD tsd, tDHL_PSI_Mode psiMode, tDHL_PSI_Update updateMode, |
|---|
| 181 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 182 | { |
|---|
| 183 | tDHL_PSI_Filter *pref; |
|---|
| 184 | DHL_RESULT err; |
|---|
| 185 | UINT32 maxSections; |
|---|
| 186 | |
|---|
| 187 | /* Set up the Table ID filter */ |
|---|
| 188 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_cable_virtual_chan_table,TRUE))) { |
|---|
| 189 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 190 | return(err); |
|---|
| 191 | } |
|---|
| 192 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 193 | #if 1//BRCM |
|---|
| 194 | pref->mask[8] = 0; |
|---|
| 195 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 196 | #else |
|---|
| 197 | pref->mask[8] = 0xff; |
|---|
| 198 | pref->mode[8] = 0xff; |
|---|
| 199 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 200 | #endif |
|---|
| 201 | maxSections = (psiMode == ePSIMODE_TABLE) ? 256 : 1; |
|---|
| 202 | |
|---|
| 203 | /* Set up PID Filter */ |
|---|
| 204 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, psiMode, |
|---|
| 205 | updateMode, pref, 1024, maxSections, // |
|---|
| 206 | eventProc, userParam, psiCtl))) { |
|---|
| 207 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 208 | DHL_PSI_FreeFilter(pref); |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | return(err); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | DHL_RESULT MonitorRrt (tDHL_TSD tsd, UINT8 region, tDHL_PSI_Update updateMode, |
|---|
| 217 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 218 | { |
|---|
| 219 | tDHL_PSI_Filter *pref; |
|---|
| 220 | DHL_RESULT err; |
|---|
| 221 | |
|---|
| 222 | /* Set up the Table ID filter */ |
|---|
| 223 | // cafrii, HAL does not support TidEx field mask. so we just use TID only. |
|---|
| 224 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_rating_region_table, TRUE))) { |
|---|
| 225 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 226 | return(err); |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 230 | #if 1//BRCM |
|---|
| 231 | pref->mask[8] = 0; |
|---|
| 232 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 233 | #else |
|---|
| 234 | pref->mask[8] = 0xff; |
|---|
| 235 | pref->mode[8] = 0xff; |
|---|
| 236 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 237 | #endif |
|---|
| 238 | /* Set up PID Filter */ |
|---|
| 239 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, ePSIMODE_SECTION, |
|---|
| 240 | updateMode, pref, 1024, 1, // |
|---|
| 241 | eventProc, userParam, psiCtl))) { |
|---|
| 242 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 243 | DHL_PSI_FreeFilter(pref); |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | return(err); |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | DHL_RESULT MonitorEit (tDHL_TSD tsd, UINT16 PID, UINT16 source_id, tDHL_PSI_Mode psiMode, tDHL_PSI_Update updateMode, |
|---|
| 251 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 252 | { |
|---|
| 253 | tDHL_PSI_Filter *pref; |
|---|
| 254 | DHL_RESULT err; |
|---|
| 255 | UINT32 maxSections; |
|---|
| 256 | |
|---|
| 257 | #if 1 |
|---|
| 258 | /* zooyouny 100617, DHL_PSI_AllocFilterWithTid(or Ex) »ç¿ë ÇÏ´Â ¹æ¹ýÀ¸·Î ´ëü*/ |
|---|
| 259 | if (source_id == 0) // source id°¡ 0ÀÌ¸é ¸ðµç source id |
|---|
| 260 | err = DHL_PSI_AllocFilterWithTid(&pref, tid_event_information_table, TRUE); |
|---|
| 261 | else |
|---|
| 262 | err = DHL_PSI_AllocFilterWithTidEx(&pref, tid_event_information_table, source_id, TRUE); // source_id¿Í table id ext´Â À§Ä¡°¡ µ¿ÀÏ |
|---|
| 263 | |
|---|
| 264 | if (err) |
|---|
| 265 | { |
|---|
| 266 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 267 | return(err); |
|---|
| 268 | } |
|---|
| 269 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 270 | #if 1//BRCM |
|---|
| 271 | pref->mask[8] = 0; |
|---|
| 272 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 273 | #else |
|---|
| 274 | pref->mask[8] = 0xff; |
|---|
| 275 | pref->mode[8] = 0xff; |
|---|
| 276 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 277 | #endif |
|---|
| 278 | #else |
|---|
| 279 | /* Set up the Table ID filter */ |
|---|
| 280 | // cafrii 070326, eit¿ëÀ¸·Î´Â Ưº°ÇÑ filter¸¦ »ç¿ëÇØ¾ß ÇÔ. |
|---|
| 281 | if (err = DHL_GetEITPSIFilter(&pref,tid_event_information_table, source_id, TRUE)) { |
|---|
| 282 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 283 | return(err); |
|---|
| 284 | } |
|---|
| 285 | #endif |
|---|
| 286 | maxSections = (psiMode == ePSIMODE_TABLE) ? 256 : 1; |
|---|
| 287 | |
|---|
| 288 | /* Set up PID Filter */ |
|---|
| 289 | if ((err = DHL_PSI_StartMonitor(tsd, PID, psiMode, |
|---|
| 290 | updateMode, pref, 4096, maxSections, // |
|---|
| 291 | eventProc, userParam, psiCtl))) { |
|---|
| 292 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 293 | DHL_PSI_FreeFilter(pref); |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | return(err); |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | DHL_RESULT MonitorEtt (tDHL_TSD tsd, UINT16 PID, UINT32 ETM_id, tDHL_PSI_Update updateMode, |
|---|
| 301 | tDHL_PSI_EventProc eventProc, UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 302 | { |
|---|
| 303 | tDHL_PSI_Filter *pref; |
|---|
| 304 | DHL_RESULT err; |
|---|
| 305 | |
|---|
| 306 | /* Set up the Table ID filter */ |
|---|
| 307 | #if 1 |
|---|
| 308 | /* zooyouny 100617, DHL_PSI_AllocFilterWithTid »ç¿ë ÇÏ´Â ¹æ¹ýÀ¸·Î ´ëü*/ |
|---|
| 309 | err = DHL_PSI_AllocFilterWithTid(&pref, tid_extended_text_table, TRUE); |
|---|
| 310 | |
|---|
| 311 | if (err) |
|---|
| 312 | { |
|---|
| 313 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 314 | return(err); |
|---|
| 315 | } |
|---|
| 316 | #if 1//BRCM |
|---|
| 317 | // etmid ¼³Á¤ |
|---|
| 318 | pref->mask[9] = pref->mask[10] = pref->mask[11] = pref->mask[12] = 0; |
|---|
| 319 | pref->coef[9] = (ETM_id>>24)&0xff; |
|---|
| 320 | pref->coef[10] =(ETM_id>>16)&0xff; |
|---|
| 321 | pref->coef[11] =(ETM_id>> 8)&0xff; |
|---|
| 322 | pref->coef[12] =(ETM_id )&0xff; |
|---|
| 323 | |
|---|
| 324 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 325 | pref->mask[8] = 0; |
|---|
| 326 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 327 | #else |
|---|
| 328 | // etmid ¼³Á¤ |
|---|
| 329 | pref->mask[9] = pref->mask[10] = pref->mask[11] = pref->mask[12] = 0xff; |
|---|
| 330 | pref->mode[9] = pref->mode[10] = pref->mode[11] = pref->mode[12] = 0xff; |
|---|
| 331 | pref->data[9] = (ETM_id>>24)&0xff; |
|---|
| 332 | pref->data[10] =(ETM_id>>16)&0xff; |
|---|
| 333 | pref->data[11] =(ETM_id>> 8)&0xff; |
|---|
| 334 | pref->data[12] =(ETM_id )&0xff; |
|---|
| 335 | |
|---|
| 336 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 337 | pref->mask[8] = 0xff; |
|---|
| 338 | pref->mode[8] = 0xff; |
|---|
| 339 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 340 | #endif |
|---|
| 341 | #else |
|---|
| 342 | if (err = DHL_GetETTPSIFilter(&pref, tid_extended_text_table, ETM_id, TRUE)) { |
|---|
| 343 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 344 | return(err); |
|---|
| 345 | } |
|---|
| 346 | #endif |
|---|
| 347 | |
|---|
| 348 | /* Set up PID Filter */ |
|---|
| 349 | if ((err = DHL_PSI_StartMonitor(tsd, PID, ePSIMODE_SECTION, |
|---|
| 350 | updateMode, pref, 4096, 1, // |
|---|
| 351 | eventProc, userParam, psiCtl))) { |
|---|
| 352 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 353 | DHL_PSI_FreeFilter(pref); |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | return(err); |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | |
|---|
| 360 | DHL_RESULT MonitorEAS(tDHL_TSD tsd, tDHL_PSI_Update updateMode, tDHL_PSI_EventProc eventProc, |
|---|
| 361 | UINT32 userParam, tDHL_PSI_ControlHandle *psiCtl) |
|---|
| 362 | { |
|---|
| 363 | tDHL_PSI_Filter *pref; |
|---|
| 364 | DHL_RESULT err = DHL_OK; |
|---|
| 365 | |
|---|
| 366 | /* Set up the Table ID filter */ |
|---|
| 367 | if ((err = DHL_PSI_AllocFilterWithTid(&pref,tid_emergency_alert_service_table,TRUE))) { |
|---|
| 368 | DHL_OS_Printf("!! %s: get filter err\n", __FUNCTION__); |
|---|
| 369 | return(err); |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | // protocol versionÀº 0À̾î¾ß ÇÔ, as defined in PSIP |
|---|
| 373 | #if 1//BRCM |
|---|
| 374 | pref->mask[8] = 0; |
|---|
| 375 | pref->coef[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 376 | #else |
|---|
| 377 | pref->mask[8] = 0xff; |
|---|
| 378 | pref->mode[8] = 0xff; |
|---|
| 379 | pref->data[8] = PSIP_PROTOCOL_VERSION; |
|---|
| 380 | #endif |
|---|
| 381 | /* Set up PID Filter */ |
|---|
| 382 | if ((err = DHL_PSI_StartMonitor(tsd, BASE_PID, ePSIMODE_SECTION, |
|---|
| 383 | updateMode, pref, 4096, 1, |
|---|
| 384 | eventProc, userParam, psiCtl))) { |
|---|
| 385 | DHL_OS_Printf("!! %s: DHL_PSI_StartMonitor err %d\n", __FUNCTION__, err); |
|---|
| 386 | DHL_PSI_FreeFilter(pref); |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | return(err); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | #if COMMENT |
|---|
| 395 | ____Get____(){} |
|---|
| 396 | #endif |
|---|
| 397 | |
|---|
| 398 | typedef struct PSIEventProcData_t { |
|---|
| 399 | tDHL_PSI_DataArray *desc; |
|---|
| 400 | DHL_RESULT err; |
|---|
| 401 | DHL_OS_SEMA_ID semaphore; |
|---|
| 402 | } PSIEventProcData; |
|---|
| 403 | |
|---|
| 404 | static void atsc_sync_event_proc(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, UINT32 userParam) |
|---|
| 405 | { |
|---|
| 406 | PSIEventProcData *procData; |
|---|
| 407 | tDHL_PSI_DataArray *desc; |
|---|
| 408 | DHL_RESULT err; |
|---|
| 409 | |
|---|
| 410 | if (userParam == 0) { |
|---|
| 411 | DHL_OS_Printf("%s: ==> %s\n", __FUNCTION__, psi_event_string(event)); |
|---|
| 412 | return; |
|---|
| 413 | } |
|---|
| 414 | // check time elapsed for semaphore transfer. |
|---|
| 415 | DHL_OS_Printf("%s: evt %d, ms %d\n", __FUNCTION__, event, DHL_OS_GetMsCount()); |
|---|
| 416 | procData = (PSIEventProcData *)userParam; |
|---|
| 417 | |
|---|
| 418 | switch (event) { |
|---|
| 419 | case ePSIEVENT_DATARECEIVED: |
|---|
| 420 | err = DHL_PSI_ReadPSIData(psiCtl, &desc); |
|---|
| 421 | if (err) { |
|---|
| 422 | DHL_OS_Printf(" ReadPSIData returned %d\n",err); |
|---|
| 423 | } |
|---|
| 424 | else { |
|---|
| 425 | procData->desc = desc; |
|---|
| 426 | } |
|---|
| 427 | procData->err = err; |
|---|
| 428 | break; |
|---|
| 429 | default: |
|---|
| 430 | DHL_OS_Printf("!! %s\n",psi_event_string(event)); |
|---|
| 431 | break; |
|---|
| 432 | } |
|---|
| 433 | DHL_OS_GiveSemaphore(procData->semaphore); |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | DHL_RESULT GetSttSection (tDHL_TSD tsd, sttSectionPtr_t *sttSectPtr, int timeOut) |
|---|
| 437 | { |
|---|
| 438 | PSIEventProcData procData; |
|---|
| 439 | tDHL_PSI_ControlHandle psiCtl; |
|---|
| 440 | int semErr; |
|---|
| 441 | DHL_RESULT err = DHL_OK; |
|---|
| 442 | |
|---|
| 443 | *sttSectPtr = NULL; |
|---|
| 444 | procData.desc = NULL; |
|---|
| 445 | procData.err = DHL_OK; |
|---|
| 446 | #if 0 // zooyouny OS_CreateReuseSemaphore ¾øÀ¸¹Ç·Î »èÁ¦ |
|---|
| 447 | #if USE_SEM_REUSE |
|---|
| 448 | procData.semaphore = OS_CreateReuseSemaphore("GetStt",OS_SEM_PRIO,0); |
|---|
| 449 | #else |
|---|
| 450 | procData.semaphore = OS_CreateCountingSemaphore("GetStt",OS_SEM_PRIO,0); |
|---|
| 451 | #endif |
|---|
| 452 | #else |
|---|
| 453 | procData.semaphore = DHL_OS_CreateCountingSemaphore("GetStt",OS_SEM_PRIO,0); |
|---|
| 454 | #endif |
|---|
| 455 | if (!procData.semaphore) { |
|---|
| 456 | DHL_OS_Printf("!! %s: create sem err\n", __FUNCTION__); |
|---|
| 457 | return(DHL_FAIL_OUT_OF_MEMORY); |
|---|
| 458 | } |
|---|
| 459 | err = MonitorStt(tsd, ePSIUPDATE_ONESHOT,atsc_sync_event_proc,(UINT32)&procData,&psiCtl); |
|---|
| 460 | if (err) { |
|---|
| 461 | goto GetSectionExit; |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | if (timeOut == 0) { |
|---|
| 465 | semErr = DHL_OS_TakeSemaphore(procData.semaphore, DHL_TIMEOUT_FOREVER); |
|---|
| 466 | } |
|---|
| 467 | else { |
|---|
| 468 | semErr = DHL_OS_TakeSemaphore(procData.semaphore, timeOut); |
|---|
| 469 | } |
|---|
| 470 | if (semErr) { |
|---|
| 471 | err = DHL_FAIL_TIMEOUT; |
|---|
| 472 | goto CancelPsiMonitor; |
|---|
| 473 | } |
|---|
| 474 | DHL_OS_Printf("%s: sem taken. ms %d\n", __FUNCTION__, DHL_OS_GetMsCount()); |
|---|
| 475 | if ((err = procData.err)) { |
|---|
| 476 | goto CancelPsiMonitor; |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | memdump(procData.desc->sectPtr[0], psi_section_length(procData.desc->sectPtr[0]), "STT"); |
|---|
| 480 | err = ParseSttSection(procData.desc->sectPtr[0], sttSectPtr); |
|---|
| 481 | |
|---|
| 482 | CancelPsiMonitor: |
|---|
| 483 | DHL_PSI_StopMonitor(psiCtl); |
|---|
| 484 | DHL_PSI_FreePSIData(procData.desc); |
|---|
| 485 | |
|---|
| 486 | GetSectionExit: |
|---|
| 487 | #if 0 // zooyouny OS_CreateReuseSemaphore ¾øÀ¸¹Ç·Î »èÁ¦ |
|---|
| 488 | #if USE_SEM_REUSE |
|---|
| 489 | OS_DeleteReuseSemaphore(procData.semaphore); |
|---|
| 490 | #else |
|---|
| 491 | OS_DeleteSemaphore(procData.semaphore); |
|---|
| 492 | #endif |
|---|
| 493 | #else |
|---|
| 494 | DHL_OS_DeleteSemaphore(procData.semaphore); |
|---|
| 495 | #endif |
|---|
| 496 | return (err); |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | DHL_RESULT GetTvct (tDHL_TSD tsd, tvctPtr_t *tvct, int timeOut) |
|---|
| 501 | { |
|---|
| 502 | PSIEventProcData procData; |
|---|
| 503 | tDHL_PSI_ControlHandle psiCtl; |
|---|
| 504 | int semErr; |
|---|
| 505 | DHL_RESULT err = DHL_OK; |
|---|
| 506 | |
|---|
| 507 | *tvct = NULL; |
|---|
| 508 | procData.desc = NULL; |
|---|
| 509 | procData.err = DHL_OK; |
|---|
| 510 | |
|---|
| 511 | #if 0 // zooyouny OS_CreateReuseSemaphore ¾øÀ¸¹Ç·Î »èÁ¦ |
|---|
| 512 | #if USE_SEM_REUSE |
|---|
| 513 | procData.semaphore = OS_CreateReuseSemaphore("GetTvct",OS_SEM_PRIO,0); |
|---|
| 514 | #else |
|---|
| 515 | procData.semaphore = OS_CreateCountingSemaphore("GetTvct",OS_SEM_PRIO,0); |
|---|
| 516 | //procData.semaphore = OS_CreateBinarySemaphore("GetTvct",OS_SEM_PRIO,0); |
|---|
| 517 | #endif |
|---|
| 518 | #else |
|---|
| 519 | procData.semaphore = DHL_OS_CreateCountingSemaphore("GetTvct",OS_SEM_PRIO,0); |
|---|
| 520 | #endif |
|---|
| 521 | |
|---|
| 522 | if (!procData.semaphore) { |
|---|
| 523 | DHL_OS_Printf("!! %s: create sem err\n", __FUNCTION__); |
|---|
| 524 | return(DHL_FAIL_OUT_OF_MEMORY); |
|---|
| 525 | } |
|---|
| 526 | err = MonitorTvct(tsd, ePSIMODE_TABLE, ePSIUPDATE_ONESHOT,atsc_sync_event_proc,(UINT32)&procData,&psiCtl); |
|---|
| 527 | if (err) { |
|---|
| 528 | goto GetSectionExit; |
|---|
| 529 | } |
|---|
| 530 | |
|---|
| 531 | if (timeOut == 0) { |
|---|
| 532 | semErr = DHL_OS_TakeSemaphore(procData.semaphore, DHL_TIMEOUT_FOREVER); |
|---|
| 533 | } |
|---|
| 534 | else { |
|---|
| 535 | semErr = DHL_OS_TakeSemaphore(procData.semaphore, timeOut); |
|---|
| 536 | } |
|---|
| 537 | if (semErr) { |
|---|
| 538 | err = DHL_FAIL_TIMEOUT; |
|---|
| 539 | goto CancelPsiMonitor; |
|---|
| 540 | } |
|---|
| 541 | DHL_OS_Printf("%s: sem taken. ms %d\n", __FUNCTION__, DHL_OS_GetMsCount()); |
|---|
| 542 | if ((err = procData.err)) { |
|---|
| 543 | goto CancelPsiMonitor; |
|---|
| 544 | } |
|---|
| 545 | |
|---|
| 546 | err = ParseTvct(procData.desc->sectPtr, tvct); |
|---|
| 547 | |
|---|
| 548 | CancelPsiMonitor: |
|---|
| 549 | DHL_PSI_StopMonitor(psiCtl); |
|---|
| 550 | DHL_PSI_FreePSIData(procData.desc); |
|---|
| 551 | |
|---|
| 552 | GetSectionExit: |
|---|
| 553 | #if 0 // zooyouny OS_CreateReuseSemaphore ¾øÀ¸¹Ç·Î »èÁ¦ |
|---|
| 554 | #if USE_SEM_REUSE |
|---|
| 555 | OS_DeleteReuseSemaphore(procData.semaphore); |
|---|
| 556 | #else |
|---|
| 557 | OS_DeleteSemaphore(procData.semaphore); |
|---|
| 558 | #endif |
|---|
| 559 | #else |
|---|
| 560 | DHL_OS_DeleteSemaphore(procData.semaphore); |
|---|
| 561 | #endif |
|---|
| 562 | return (err); |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | #if COMMENT |
|---|
| 567 | ____Debug____(){} |
|---|
| 568 | #endif |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | |
|---|
| 572 | |
|---|
| 573 | #if COMMENT |
|---|
| 574 | ____Symbol____(){} |
|---|
| 575 | #endif |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | #if COMMENT |
|---|
| 581 | ____Init____(){} |
|---|
| 582 | #endif |
|---|
| 583 | |
|---|
| 584 | |
|---|
| 585 | |
|---|
| 586 | /* end of file */ |
|---|
| 587 | |
|---|