source: svn/newcon3bcm2_21bu/dst/dhl/src/DHL_PSI_Impl.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 18.7 KB
Line 
1/**
2        @file
3                DHL_PSI_Impl.c
4
5        @brief
6                PSI implementation
7
8        Copyright 2006~2010 Digital STREAM Technology, Inc.
9        All Rights Reserved
10*/
11
12
13#include "DHL_OSAL.h"
14#include "DHL_DBG.h"
15#include "DHL_PSI.h"
16#include "DHL_PSI_Priv.h"
17#include "DHL_UTL.h"
18#include "bsettop_smessage.h"
19//#include <stdio.h>
20////#include <string.h>
21
22
23//DHL_MODULE("*psi", 0);
24
25
26
27#if COMMENT
28___Util_Mem_Func___(){}
29#endif
30
31#define SECTION_TID           0              /* TID index                    */
32#define SECTION_LEN_HI        1              /* length hi index              */
33#define SECTION_LEN_LO        2              /* length lo index              */
34#define SECTION_TID_EXT_HI        3              /* Table ID extension high index*/
35#define SECTION_TID_EXT_LO    4              /* Table ID extension low index */
36#define SECTION_VERSION       5              /* version number index         */
37#define SECTION_NUM           6              /* section number index         */
38#define SECTION_NUM_LAST      7              /* last section number index    */
39#define SECTION_HEADER_LENGTH 8                          /* number of bytes in section header */
40
41#define SECTION_LEN_MASK      0x0FFF         /* length bit mask              */
42#define SECTION_VERSION_MASK  0x3E           /* version number bit mask      */
43#define SECTION_VERSION_SHIFT 1                  /* version number bit shift     */
44
45#define PSI_GET_TID(hdr) ((hdr)[SECTION_TID])
46#define PSI_GET_PRIV_INDI(hdr) ((hdr)[SECTION_LEN_HI]&0x8)
47#define PSI_GET_LEN(hdr) ((((hdr)[SECTION_LEN_HI]&0xF)<<8)+(hdr)[SECTION_LEN_LO])
48#define PSI_GET_VER(hdr) (((hdr)[SECTION_VERSION]&SECTION_VERSION_MASK)>>SECTION_VERSION_SHIFT)
49#define PSI_GET_NUM(hdr) ((hdr)[SECTION_NUM])
50#define PSI_GET_LAST_NUM(hdr) ((hdr)[SECTION_NUM_LAST])
51
52
53void *dhl_psi_alloc_memory(UINT32 size, UINT32 flags)
54{
55        void *p;
56
57        p = DHL_OS_Malloc(size);
58
59        if (p && (flags & DHL_PSI_MEMORY_CLEAR))
60                memset(p, 0, size);
61       
62        return p;
63}
64
65
66void dhl_psi_free_memory(void *block)
67{
68        DHL_OS_Free((void**)&block);
69}
70
71static UINT32 p_get_data_crc(UINT8 *data, UINT32 len)
72{
73        UINT32 crc;
74        DHL_ASSERT(len >= 4, "p_get_data_crc: data too small!");
75        data += (len - 4);
76        crc = ((*data) << 24) | ((*(data+1)) << 16) | ((*(data+2)) << 8) | *(data+3);
77        return(crc);
78}
79
80
81
82#if COMMENT
83____Config____(){}
84#endif
85
86
87
88
89#if COMMENT
90____Types____(){}
91#endif
92
93
94
95#if COMMENT
96____Macros____(){}
97#endif
98
99#define DHL_PSIDescriptorSize(nelem) (sizeof(tDHL_PSI_DataArray) + \
100                        ((nelem)-DYNARRAY_SECTPTR)*sizeof(UINT8 *))
101
102#if COMMENT
103____Variables____(){}
104#endif
105
106
107
108
109#if COMMENT
110____Debug____(){}
111#endif
112
113static char *psi_tid_str(UINT8 t)
114{
115        static char buf[10];
116        return
117                (t)==0x00 ? "pat" : \
118                (t)==0x02 ? "pmt" : \
119                (t)==0xC7 ? "mgt" : \
120                (t)==0xC8 ? "tvt" : \
121                (t)==0xC9 ? "cvt" : \
122                (t)==0xCA ? "rrt" : \
123                (t)==0xCB ? "eit" : \
124                (t)==0xCC ? "ett" : \
125                (t)==0xCD ? "stt" : \
126                (t)==0xD8 ? "eas" : \
127                (sprintf(buf, "x%02x", t), buf);
128}
129
130
131#if COMMENT
132____ProcPSI____(){}
133#endif
134
135void dhl_psi_free_data_array(tDHL_PSI_DataArray *psi)
136{
137        int i;
138        for(i=0; i<psi->numSections; i++) {
139                if (psi->sectPtr[i])
140                        dhl_psi_free_memory(psi->sectPtr[i]);
141        }
142        dhl_psi_free_memory(psi);
143}
144
145void dhl_psi_set_filter_value(tDHL_PSI_Filter *pFilter, tDHL_FilterAttr attrType, UINT32 value)
146{
147        switch(attrType) {
148#if 1//BRCM
149        case eFILTERATTR_TID :
150                pFilter->mask[0]=0x0;
151                pFilter->coef[0]=(value&0xff);
152                break;
153               
154        case eFILTERATTR_CURNEXTINDICATOR :
155                pFilter->mask[5]=(UINT8)~0x1;
156                pFilter->coef[5]|=(value&0x1);
157                break;
158               
159        case eFILTERATTR_TIDEXTENSION :
160        //case eFILTERATTR_SOURCEID :
161        //case eFILTERATTR_BOTHFIELD :
162                pFilter->mask[3]=0x0;
163                pFilter->mask[4]=0x0;
164                pFilter->coef[3]=(value>>8)&0xff;
165                pFilter->coef[4]=(value&0xff);
166                break;
167
168        case eFILTERATTR_TOPFIELD :
169                pFilter->mask[3]=0x0;
170                pFilter->coef[3]=(value&0xff);
171                break;
172
173        case eFILTERATTR_BOTTOMFIELD :
174                pFilter->mask[4]=0x0;
175                pFilter->coef[4]=(value&0xff);
176                break;
177               
178        case eFILTERATTR_ETMID :
179                pFilter->mask[9]=0x0;
180                pFilter->mask[10]=0x0;
181                pFilter->mask[11]=0x0;
182                pFilter->mask[12]=0x0;
183               
184                pFilter->coef[9]=(value>>24)&0xff;
185                pFilter->coef[10]=(value>>16)&0xff;
186                pFilter->coef[11]=(value>>8)&0xff;
187                pFilter->coef[12]=(value&0xff);
188                break;
189
190        case eFILTERATTR_FIRSTPAYLOAD :
191                // it is for checking protocol version. should be 8.
192                pFilter->mask[8]=0x0;
193                pFilter->coef[8]=(value&0xff);
194                break;
195
196        case eFILTERATTR_VERSION :
197                pFilter->excl[5]=(UINT8)~0x3e;
198                pFilter->coef[5]|=(value<<1)&0x3e;
199                break;
200
201#else
202                case eFILTERATTR_TID :
203                        pFilter->mask[0]=pFilter->mode[0]=0xff;
204                        pFilter->data[0]=(value&0xff);
205                        break;
206                       
207                case eFILTERATTR_CURNEXTINDICATOR :
208                        pFilter->mask[5]=pFilter->mode[5]=(UINT8)0x1;
209                        pFilter->data[5]|=(value&0x1);
210                        break;
211                       
212                case eFILTERATTR_TIDEXTENSION :
213                //case eFILTERATTR_SOURCEID :
214                //case eFILTERATTR_BOTHFIELD :
215                        pFilter->mask[3]=pFilter->mode[3]=0xff;
216                        pFilter->mask[4]=pFilter->mode[4]=0xff;
217                        pFilter->data[3]=(value>>8)&0xff;
218                        pFilter->data[4]=(value&0xff);
219                        break;
220               
221                case eFILTERATTR_TOPFIELD :
222                        pFilter->mask[3]=pFilter->mode[3]=0xff;
223                        pFilter->data[3]=(value&0xff);
224                        break;
225               
226                case eFILTERATTR_BOTTOMFIELD :
227                        pFilter->mask[4]=pFilter->mode[4]=0xff;
228                        pFilter->data[4]=(value&0xff);
229                        break;
230                       
231                case eFILTERATTR_ETMID :
232                        pFilter->mask[9]=pFilter->mode[9]=0xff;
233                        pFilter->mask[10]=pFilter->mode[10]=0xff;
234                        pFilter->mask[11]=pFilter->mode[11]=0xff;
235                        pFilter->mask[12]=pFilter->mode[12]=0xff;
236                       
237                        pFilter->data[9]=(value>>24)&0xff;
238                        pFilter->data[10]=(value>>16)&0xff;
239                        pFilter->data[11]=(value>>8)&0xff;
240                        pFilter->data[12]=(value&0xff);
241                        break;
242               
243                case eFILTERATTR_FIRSTPAYLOAD :
244                        // it is for checking protocol version. should be 8.
245                        pFilter->mask[8]=pFilter->mode[8]=0xff;
246                        pFilter->data[8]=(value&0xff);
247                        break;
248               
249                case eFILTERATTR_VERSION :
250                        pFilter->mask[5]=(UINT8)0x3e;
251                        pFilter->mode[5]=(UINT8)0;//~0x3e;
252                        pFilter->data[5]|=(value<<1)&0x3e;
253                        break;
254#endif
255                default :
256                        return;
257        }
258       
259        // pFilter->attrCoef|=attrType;
260
261        return;
262}
263
264
265#if DST_SW_FILTERING
266DHL_RESULT check_sw_filter(tDHL_PSI_Filter* pFilter, UINT8* buf, int len)
267{
268//      UINT8 data, mask, mode; // ÇÊÅÍÀÇ data, mask, mode
269//      UINT8 filter;
270        int i;
271
272        // len °ª 13º¸´Ù ÀÛÀºÁö üũ
273        if (len < FILTER_MAX_BYTE)
274                return DHL_FAIL;
275
276        for(i = 0 ; i < FILTER_MAX_BYTE; i++)
277        {
278#if 1//BRCM
279                // match mask
280                if (((~pFilter->mask[i]) & pFilter->coef[i]) != ((~pFilter->mask[i]) & buf[i]))
281                {
282                        return FALSE; // 'FALSE' means 'not matched'
283                }
284                // exclude mask
285                if ((pFilter->excl[i] != 0xff) &&
286                        ((~pFilter->excl[i]) & pFilter->coef[i]) == ((~pFilter->excl[i]) & buf[i]))
287                {
288                        return FALSE; // 'FALSE' means 'not matched'
289                }
290
291#else
292                if(pFilter->mask[i] == 0x00)    // mask°ªÀÌ 0ÀÌ¸é ºñ±³ÇÏÁö ¾ÊÀ½
293                        continue;
294
295                data = pFilter->data[i];
296                mask = pFilter->mask[i];
297                mode = pFilter->mode[i];
298
299                // equal filtering validity check
300                filter = mask & mode;
301                if (filter != 0 && (buf[i] & filter) != (data & filter))
302                        return DHL_FAIL;
303
304                // not equal filtering validity check
305                filter = (mask & ~mode);
306                if (filter != 0 && (buf[i] & filter) == (data & filter))
307                        return DHL_FAIL;
308#endif
309        }
310
311        return DHL_OK;
312}
313
314#endif
315
316tDHL_PSI_Event dhl_psi_post_data_received(tDHL_PSI_FiltCtl *pFltCtl, UINT8 *pdata, int len, int *procLen)
317{
318                BOOL useCRC;
319                tDHL_PSI_DataArray *desc=NULL;
320                tDHL_PSI_Event event = ePSIEVENT_NOEVENT;
321                UINT8 *buffer=NULL;
322                int sectionNumber;
323                int maxSections;
324                int version;
325       
326                *procLen = PSI_GET_LEN(pdata) + 3;
327
328                // ÀÔ·ÂµÈ ¼½¼Ç µ¥ÀÌÅÍÀÇ ±æÀ̰¡ ¼½¼Ç ³» section length°ªº¸´Ù ÀÛÀº °æ¿ì ¿¡·¯
329                if (len < *procLen)
330                {
331//                      event = ePSIEVENT_SYNCERR;      // SYNCERR ´Â ´Ù¸¥ ¿ëµµ·Î »ç¿ëµÇ´Ï ePSIEVENT_NOEVENT ¸®Åϵǵµ·Ï ÇÏÀÚ.
332                        *procLen = len;
333                        goto label_exit;
334                }       
335
336#if DST_CRC_RECHECK
337                if (pdata[SECTION_LEN_HI]&0x80) {       // section syntax indicator
338                        if (DHL_UTL_CalcCRC32(0xffffffff, pdata, *procLen) != 0)
339                        {
340                                printf( "section crc err!!\n");
341                                goto label_exit;
342                        }
343                }
344#endif
345
346#if DST_SW_FILTERING
347                if(pFltCtl->pFltData == NULL)
348                {       
349                        printf( "sw section filter data ptr(pFltData) is NULL!!\n");
350                        goto label_exit;
351                }
352
353                if(check_sw_filter(pFltCtl->pFltData, pdata, *procLen) != DHL_OK)
354                {
355                        //printf( "sw section filter detected error!!\n");
356                        goto label_exit;
357                }
358#endif
359       
360                version = PSI_GET_VER(pdata);
361       
362                switch(pFltCtl->param.psiMode) 
363                {
364                       
365                case ePSIMODE_SECTION:
366                        /*
367                         * In private mode, we simply pass the data along. We check CRC if
368                         * the section_syntax_indicator is set.
369                         * Section mode is like private mode except that we assume section
370                         * syntax and force a CRC check regardless of the section_syntax_indicator
371                         * bit.
372                         */
373       
374                        pFltCtl->receiveCount++;
375       
376                        // ¸Þ¸ð¸®¸¦ »õ·Î ÇÒ´çÇÏ°í º¹»çÇØ¼­ »ç¿ë
377                        buffer = dhl_psi_alloc_memory(*procLen, 0);
378                        if (!buffer) {
379                                /* cafrii 090720 bugfix, desc will be freed before exit this function */
380                                if(desc)
381                                        dhl_psi_free_data_array(desc);
382                                event = ePSIEVENT_MEMORYERROR;
383                                goto label_exit;
384                        }
385                        memcpy(buffer, pdata, *procLen);
386                       
387                        useCRC = (buffer[SECTION_LEN_HI]&0x80);
388                       
389                        if (pFltCtl->param.updateMode == ePSIUPDATE_CRCCHANGE && useCRC) 
390                        {
391                                // CRC üũ¸¦ ÇØ¾ß ÇÏ´Â ¸ðµå..
392                               
393                                pFltCtl->runningCRC = p_get_data_crc(buffer, *procLen);
394                                // section ¸ðµå¿¡¼­ runningCRC´Â ±×Àú temp º¯¼ö Á¤µµ¿¡ Áö³ªÁö ¾Ê´Â´Ù.
395                               
396                                if (pFltCtl->lastCRCValid && pFltCtl->runningCRC == pFltCtl->lastCRC) 
397                                {
398                                        //printf( "section: crc same. ignored.\n");
399                                        dhl_psi_free_memory(buffer);
400                                        pFltCtl->runningCRC = 0;
401                                        goto label_exit; 
402                                }
403       
404                                if (pFltCtl->lastCRCValid)
405                                {
406                                        //printf( "section: crc changed, 0x%08x -> 0x%08x\n",
407                                        //      pFltCtl->lastCRCValid ? pFltCtl->lastCRC : 0, pFltCtl->runningCRC);
408                                }
409       
410                                pFltCtl->lastCRC = pFltCtl->runningCRC;
411                                pFltCtl->lastCRCValid = TRUE;
412                                pFltCtl->runningCRC = 0;
413                        }
414                        else if (pFltCtl->param.updateMode == ePSIUPDATE_VERCHANGE)
415                        {
416                                // ÀÌ ÇÊÅÍ¿¡¼­ ¸Ç óÀ½ ¼ö½ÅµÈ sectionÀÌ¸é ¹«Á¶°Ç ±â¾ïÇØ¾ß ÇÑ´Ù.
417                                //
418                                if (pFltCtl->curVersion >= 0 && pFltCtl->curVersion == version) 
419                                {
420                                        //printf( "section: ver same %d. ignored\n", version);
421                                       
422                                        dhl_psi_free_memory(buffer);
423                                        // ´õ ÀÌ»ó ÀÌ ¹öÀüÀº ¼ö½ÅÇÏÁö ¸»¶ó°í ¼³Á¤..
424       
425                                        dhl_psi_set_filter_value(pFltCtl->pFltData, eFILTERATTR_VERSION, version);
426
427                                        update_psi_filter(pFltCtl);
428
429                                        goto label_exit;
430                                }
431                               
432                                if (pFltCtl->curVersion >= 0)
433                                {
434                                        //printf( "section: ver changed, %d -> %d\n",
435                                        //              pFltCtl->curVersion >= 0 ? pFltCtl->curVersion : -1, version);
436                                }
437                                dhl_psi_set_filter_value(pFltCtl->pFltData, eFILTERATTR_VERSION, version);
438       
439                                update_psi_filter(pFltCtl);
440       
441                                pFltCtl->curVersion = version;
442                        }
443       
444                        /* cafrii 090720, array size¸¦ 1·Î ¼³Á¤. section À̹ǷΠ1°³¸é µÊ.
445                        */
446                        desc = dhl_psi_alloc_memory(DHL_PSIDescriptorSize((unsigned int)1), DHL_PSI_MEMORY_CLEAR);
447                        if (!desc) {
448                                dhl_psi_free_memory(buffer);
449                                event = ePSIEVENT_MEMORYERROR;
450                                goto label_exit;
451                        }
452                       
453                        desc->pid = pFltCtl->pid;
454                        desc->handle = pFltCtl->handle; //pFltCtl;
455                        desc->numSections = 1;
456                        desc->maxSections = 1;
457                        desc->sectPtr[0] = buffer;
458       
459                        if (pFltCtl->curDataArray) {
460                                // ÀÌ °æ¿ì´Â caller°¡ event proc ±¸ÇöÀ» ÇÏÁö ¾Ê¾Ò°Å³ª (½É°¢ÇÏÁö ¾ÊÀ½)
461                                // ¼º´É µîÀÇ ¹®Á¦·Î 󸮰¡ ´Ê¾îÁ®¼­ »ý±â´Â ¹®Á¦ÀÌ´Ù. (½É°¢ÇÔ)
462                                //printf( "!! prev section data still exist, %s\n",
463                                //              psi_tid_str(PSI_GET_TID(buffer)));
464                                dhl_psi_free_data_array(pFltCtl->curDataArray);
465                        }
466                        // section ¸ðµå¿¡¼­´Â 'nextDataArray'´Â ¹Ì»ç¿ë.
467                       
468                        // ³ªÁß¿¡ ¹öÀü üũ¸¦ Çϱâ À§Çؼ­ ¹öÀü Á¤º¸ ±â¾ï..
469                        pFltCtl->curDataArray = desc;
470       
471                        // ¸Ç ¸¶Áö¸·¿¡ À§Ä¡ÇØ¾ß ÇÔ. ¿¡·¯°¡ ³­ °æ¿ì´Â ´Ù½Ã ¹Þ¾Æ¾ß ÇϹǷÎ..
472                        if (pFltCtl->param.updateMode == ePSIUPDATE_ONESHOT) {
473                                //printf( "section: flt[%d] stop action for one shot mode\n", pFltCtl->index);
474                                pause_psi_filter(pFltCtl);
475                        }
476                        event = ePSIEVENT_DATARECEIVED;
477                        pFltCtl->goodCount++;   
478                       
479                        break;
480                       
481                       
482                case ePSIMODE_TABLE:
483                       
484                        pFltCtl->receiveCount++;
485                        sectionNumber = PSI_GET_NUM(pdata); // ¹æ±Ý ¼ö½ÅµÈ sectionÀÇ section number
486                        maxSections = PSI_GET_LAST_NUM(pdata)+1;
487                        desc = pFltCtl->nextDataArray; // Áö±Ý ¸ð¾ÆÁö°í ÀÖ´Â data array
488       
489                        // basic sanity test.
490                        // section ÀÌ table ÀÇ version °ú ´Ù¸£°Å³ª, section number°¡ ¹Ù²î¾î¹ö¸° °æ¿ì
491                        // ´õ ÀÌ»ó ÁøÇàÀÌ ºÒ°¡´ÉÇÏ´Ù.
492                        if (desc &&
493                                (pFltCtl->nextVersion != version ||
494                                desc->maxSections != maxSections)) 
495                        {
496                                // comment: nextDataArray °¡ Á¸ÀçÇϸé versionÀº Ç×»ó valid ÇÏ´Ù.
497       
498                                //      The version number changed or else something weird happened because
499                                //      last_section_number changed. In any case, throw away what we had
500                                printf( "!! inconsistency! ver (in %d, stored %d) max_sec (in %d, stored %d)\n",
501                                                version,
502                                                pFltCtl->nextVersion,
503                                                maxSections,
504                                                desc->maxSections);
505       
506                                // comment: nextDataArray °¡ Á¸ÀçÇϸé versionÀº Ç×»ó valid ÇÏ´Ù.
507                               
508                                dhl_psi_free_data_array(pFltCtl->nextDataArray);
509                                pFltCtl->nextDataArray = desc = NULL;
510                                pFltCtl->runningCRC = 0;
511                        }
512                       
513                        if (desc)
514                        {
515                                //      This is a second or subsequent section in the table. Take it if
516                                //       we haven't seen it yet. Else, discard it.
517                                if (sectionNumber >= desc->maxSections) {
518                                        //      This section is beyond maxSections, but we have already informed
519                                        //      the client that this has happened.
520                                        event = ePSIEVENT_MAXSECTIONOVERFLOW;
521                                        printf( "!! table: sect[%d] beyond max %d. drop!\n", sectionNumber, desc->maxSections);
522                                        goto label_exit;
523                                }
524                                else if (desc->sectPtr[sectionNumber] != NULL) {       
525                                        //      we have already received this section, so discard this one quietly.
526                                        //printf( "table: sect[%d] already exist\n", sectionNumber);
527                                        goto label_exit;
528                                }
529                        }
530                        else 
531                        {
532                                // We are getting the first section of a new table
533                                if (maxSections > pFltCtl->param.maxSections) {
534                                        printf( "!! table: sect[%d]'s max %d beyond max %d. adjusted to %d\n", 
535                                                        sectionNumber, maxSections, desc->maxSections,
536                                                        pFltCtl->param.maxSections);
537                                        event = ePSIEVENT_MAXSECTIONOVERFLOW;
538                                        maxSections = pFltCtl->param.maxSections; // use caller's param.
539                                }
540                               
541                                if (sectionNumber >= maxSections) {
542                                        event = ePSIEVENT_LASTSECTIONOVERFLOW;
543                                        goto label_exit;
544                                }
545                                desc = dhl_psi_alloc_memory(DHL_PSIDescriptorSize(maxSections), DHL_PSI_MEMORY_CLEAR);
546       
547                                if (!desc) {
548                                        event = ePSIEVENT_MEMORYERROR;
549                                        goto label_exit;
550                                }
551                               
552                                desc->pid = pFltCtl->pid;
553                                desc->handle = pFltCtl->handle;//pFltCtl;
554                                desc->numSections = 0;
555                                desc->maxSections = maxSections;
556                                // desc->sectPtr is reset to zero in dhl_psi_alloc_memory
557       
558                                pFltCtl->runningCRC = 0;
559                                pFltCtl->nextVersion = version;
560                                pFltCtl->nextDataArray = desc;
561                        }
562                       
563                        // ¸Þ¸ð¸®¸¦ »õ·Î ÇÒ´çÇÏ°í º¹»çÇØ¼­ »ç¿ë
564                        buffer = dhl_psi_alloc_memory(*procLen, 0);
565                        if (!buffer) {
566                                event = ePSIEVENT_MEMORYERROR;
567                                dhl_psi_free_data_array(desc);
568                                goto label_exit;
569                        }
570                        memcpy(buffer, pdata, *procLen);
571       
572                        desc->sectPtr[sectionNumber] = buffer;
573                        // ÀÌÁ¦ºÎÅÍ´Â buffer¸¦ µû·Î free ½Ãų ÇÊ¿ä ¾øÀ½. ÇÊ¿äÇϸé desc¸¸ free ÇÏ¸é µÈ´Ù.
574                       
575                        if (pFltCtl->param.updateMode == ePSIUPDATE_CRCCHANGE) {
576                                pFltCtl->runningCRC ^= p_get_data_crc(buffer, *procLen);
577                        }
578                        pFltCtl->curSection = sectionNumber;
579                        desc->numSections++;
580       
581                        if (desc->numSections < desc->maxSections) // ¾ÆÁ÷ ¸ðµç section ÀÌ ¸ð¾ÆÁöÁö ¾Ê¾ÒÀ½.
582                                break;
583
584
585///////////////////////////////////////////////////////////////////////////////
586//      We have the whole table, so we can now feed it to the client
587///////////////////////////////////////////////////////////////////////////////
588       
589                        if (pFltCtl->param.updateMode == ePSIUPDATE_ONESHOT) 
590                        {
591                                pause_psi_filter(pFltCtl);
592                        }
593                        else if (pFltCtl->param.updateMode == ePSIUPDATE_CRCCHANGE) 
594                        {
595                                if (pFltCtl->lastCRCValid && pFltCtl->runningCRC == pFltCtl->lastCRC) {
596                                        // µ¿ÀÏÇÑ CRC.. ¹«½Ã..
597                                        //printf( "table: crc same. ignored\n");
598                                        pFltCtl->runningCRC = 0;
599                                        dhl_psi_free_data_array(desc);
600                                        pFltCtl->nextDataArray = NULL;
601                                        goto label_exit; 
602                                }
603                                // CRC Change ¸ðµåÀÎ °æ¿ì´Â ÇöÀç ¼³Á¤À» À¯ÁöÇÑ Ã¤ CRC¸¸ ±â¾ïÇØ ³õ´Â´Ù.
604       
605                                //printf( "table: crc changed, 0x%08x -> 0x%08x\n",
606                                //      pFltCtl->lastCRCValid ? pFltCtl->lastCRC : 0, pFltCtl->runningCRC);
607                               
608                                pFltCtl->lastCRC = pFltCtl->runningCRC;
609                                pFltCtl->lastCRCValid = TRUE;
610                                pFltCtl->runningCRC = 0;
611                        }
612                        else if (pFltCtl->param.updateMode == ePSIUPDATE_VERCHANGE) 
613                        {
614                                /*
615                                 * Here, we modify the psiFilter to only fire on a version different
616                                 * from the one we just received.
617                                 */
618                                // ½ÇÁ¦·Î ¹öÀüÀÌ º¯°æ µÈ °ÍÀÎÁö ºñ±³ÇÏ´Â ÄÚµå´Â ¾ø´Ù.
619                                // hw filter°¡ Á¦´ë·Î µ¿ÀÛÇß´Ù°í º¸´Â °ÍÀÓ.
620       
621                                if (pFltCtl->curVersion >= 0 && pFltCtl->curVersion == version) 
622                                {
623                                        //printf( "table: ver same %d. ignored\n", version);
624                                        // ´õ ÀÌ»ó ÀÌ ¹öÀüÀº ¼ö½ÅÇÏÁö ¸»¶ó°í ¼³Á¤..
625                                        dhl_psi_set_filter_value(pFltCtl->pFltData, eFILTERATTR_VERSION, version);
626                                        update_psi_filter(pFltCtl);
627                                       
628                                        dhl_psi_free_data_array(desc);
629                                        pFltCtl->nextDataArray = NULL;
630       
631                                        goto label_exit; 
632                                }
633                               
634                                //printf( "table: ver changed, %d -> %d\n",
635                                //              pFltCtl->curVersion >= 0 ? pFltCtl->curVersion : -1, version);
636                                dhl_psi_set_filter_value(pFltCtl->pFltData, eFILTERATTR_VERSION, version);
637       
638                                update_psi_filter(pFltCtl);
639                               
640                                pFltCtl->curVersion = version;
641                        }
642       
643                        if (pFltCtl->curDataArray) {
644                                // ÀÌ °æ¿ì´Â caller°¡ event proc ±¸ÇöÀ» ÇÏÁö ¾Ê¾Ò°Å³ª (½É°¢ÇÏÁö ¾ÊÀ½)
645                                // ¼º´É µîÀÇ ¹®Á¦·Î 󸮰¡ ´Ê¾îÁ®¼­ »ý±â´Â ¹®Á¦ÀÌ´Ù. (½É°¢ÇÔ)
646                                printf( "!! prev table data still exist, %s\n", 
647                                                psi_tid_str(PSI_GET_TID(desc->sectPtr[0])));
648                                dhl_psi_free_data_array(pFltCtl->curDataArray);
649                        }
650                        pFltCtl->curDataArray = desc;
651                        pFltCtl->nextDataArray = NULL;
652                       
653                        event = ePSIEVENT_DATARECEIVED;
654                        pFltCtl->goodCount++;   
655                        break;
656               
657                default :
658                        printf("FATAL: dhl_psi_post_data_received: Bad PSI mode\n");
659                }
660               
661                return event;
662               
663        label_exit :
664       
665                return event;
666       
667}
668
669
670#if COMMENT
671____Symbol____(){}
672#endif
673
674
675#if DHL_REGISTER_DEUBG_SYMBOLS
676
677#if 0 
678static DHL_SymbolTable _XxxxSymbols[] =
679{
680        /* however, if you want typing short-cut, it is good usage.
681        */
682        DHL_FNC_SYM_ENTRY2("epg_start", App_EpgUpdateStart),
683        DHL_FNC_SYM_ENTRY2("epg_stop", App_EpgUpdateCancel),
684        DHL_FNC_SYM_ENTRY2("epg_list", Dmc_EpgPrintAllTables),
685        DHL_FNC_SYM_ENTRY2("epg_delete", App_EpgDeleteAll),
686
687        DHL_VAR_SYM_ENTRY(g_XX_TestMode),
688
689};
690#endif
691
692#endif  /* DHL_REGISTER_DEUBG_SYMBOLS */
693
694
695/* end of file */
696
Note: See TracBrowser for help on using the repository browser.