source: svn/newcon3bcm2_21bu/dst/dmw/src/EPG/DMW_Xds.c @ 22

Last change on this file since 22 was 22, checked in by phkim, 11 years ago
  1. phkim
  2. newcon3sk 를 kctv 로 브랜치 함
  • Property svn:executable set to *
File size: 46.7 KB
Line 
1/********************************************************************
2 *
3 * DMW_Xds.c
4 *
5 *
6 * Copyright 2002-2004 Digital STREAM Technology, Inc.
7 * All Rights Reserved
8 *
9 * DMW_Xds.c, v 1.0 2004/12/22 cafrii
10 *
11 *******************************************************************/
12
13#include "Zoran.h"
14
15#include <TLOS.h>
16
17#include "DHL_OSAL.h"
18#include "DMW_Status.h"
19#include "DMW_Config.h"
20
21
22#include "DMW_DebugUtil.h"
23#include "DMW_Mutex.h"
24
25#include "DMW_ChannelAPI.h"
26
27#include "DMW_EpgInterface.h"
28#include "DMW_Xds.h"
29
30
31DHL_MODULE("$xds", 1);
32
33
34//===========================================================================
35//
36//       Design Notes
37//
38//
39
40#if 0
41
42        XDS data processingÀº Å©°Ô µÎ ºÎºÐÀ¸·Î ³ª´²Áø´Ù.
43       
44        FrontEnd
45       
46                ½ÇÁ¦·Î µ¥ÀÌÅ͸¦ ¹Þ¾ÆµéÀÌ´Â ºÎºÐ
47                XDS µ¥ÀÌÅÍ´Â VBI µ¥ÀÌÅÍ ¾È¿¡ Æ÷ÇԵǾî Àֱ⠶§¹®¿¡ NTSC Decoder µå¶óÀ̹ö ¸ðµâ¿¡¼­
48                VBI µ¥ÀÌÅ͸¦ ÃßÃâ ¹× ºÐ¼®ÇÏ¿© XDS µ¥ÀÌÅ͸¸À» »Ì¾Æ³»°Ô µÈ´Ù.
49               
50                ÀÌ ÄÚµå´Â NTSC CC ÄÚµå ¿¡ °°ÀÌ Æ÷ÇԵǾî ÀÖ´Â °æ¿ì°¡ ¸¹À¸¸ç,
51                ±×·² °æ¿ì CC ¸ðµâÀÇ VBI ó¸® ¸ðµâÀÌ FrontEnd°¡ µÈ´Ù.
52                CC Á¤º¸°¡ ¾Æ´Ñ XDS µ¥ÀÌÅÍÀÎ °æ¿ì¿¡¸¸ BackEnd·Î ³Ñ°ÜÁÖ¸é µÈ´Ù.
53               
54               
55                FrontEnd°¡ DTV Module ÀÌ ¾Æ´Ñ ¿ÜºÎ ÀåÄ¡¿¡ ÀÖÀ» ¼öµµ Àִµ¥ (¿¹: TV Host)
56                ±×·² °æ¿ì¿¡´Â TV Host°¡ FrontEnd À̸ç, Åë½Å Interface¸¦ ÅëÇØ¼­
57                DTV Module BackEnd·Î µ¥ÀÌÅͰ¡ ³Ñ°ÜÁø´Ù.
58                À̶§ ³Ñ°ÜÁö´Â µ¥ÀÌÅÍÀÇ Çü½ÄÀº °¢ Host ±Ô°Ý¿¡ µû¶ó ´Þ¶óÁú ¼ö ÀÖ´Ù.
59               
60               
61        BackEnd
62               
63                FrontEnd ºÎºÐ¿¡¼­ ¹ÞÀº XDS raw data (¶Ç´Â ÀϺΠparsing µÈ µ¥ÀÌÅÍ)¸¦ ºÐ¼®Çϰí
64                À̸¦ DB È­ ÇÏ¿© ÀúÀåÇÑ´Ù.
65               
66               
67
68        Interface
69       
70                1. FrontEnd - BackEnd Interface
71               
72                        - VBI Raw µ¥ÀÌÅ͸¦ BackEnd ¿¡ ³Ñ°ÜÁÖ´Â ÀÎÅÍÆäÀ̽º
73                          Raw µ¥ÀÌÅÍÀÇ Çü½ÄÀº ¾ÆÁ÷ ¹ÌÁ¤..
74                       
75                                OnReceiveXDS...
76                       
77                        - ¿ÜºÎ NTSC Decoder ÀåÄ¡ (¿¹: TV Host)°¡ ¼ö½ÅÇÑ XDS µ¥ÀÌÅ͸¦
78                          ¾î´ÀÁ¤µµ Á¤¸®ÇÏ¿© ³Ñ°ÜÁÖ´Â ÀÎÅÍÆäÀ̽º
79                       
80                                DMW_XDS_UpdateXdsXXX API
81
82
83                2. Application Control Interface
84
85                        - XDS DB control
86                                DB ÃʱâÈ­, ÀúÀå µî..
87                       
88                        - RF change notification
89                                FrontEnd¿¡¼­ Raw XDS packetÀ» ³Ñ°ÜÁÙ °æ¿ì¶ó¸é
90                                ÇöÀç ¾î´À RF ¿¡¼­ ¼ö½Å ÁßÀÎÁö BackEnd°¡ ¾Ë°í ÀÖ¾î¾ß¸¸ DB ±¸¼ºÀ» ÇÒ ¼ö ÀÖÀ½.
91                       
92                        - XDS time setting??
93                               
94
95
96                3. Application Query Interface
97               
98                        - DB ·Î ÀúÀåµÈ XDS µ¥ÀÌÅÍ Áß¿¡¼­ Application ¿¡¼­ EPG ¿ëµµ·Î »ç¿ëÇÒ
99                          µ¥ÀÌÅ͸¦ query ÇÏ´Â API
100               
101                                DMW_XDS_GetXXXXInfo
102                                DMW_XDS_FreeXXXInfo..
103
104                               
105               
106                4. Application Notification Interface
107               
108                        - ÀÌ ¸ðµâ ³»ºÎ¿¡¼­ ¹ß»ýµÇ´Â ¿©·¯°¡Áö Á¤º¸¸¦ Application¿¡°Ô ¾Ë·ÁÁÖ´Â
109                          notification callback
110                         
111                         
112                         
113       
114
115
116#endif
117
118
119//===========================================================================
120//
121//      Configuration parameters
122//
123//   °¢Á¾ ¿É¼Ç ±â´ÉÀÇ On/Off ¼³Á¤, ÄÄÆÄÀÏ·¯ ¿É¼Ç ¼³Á¤,
124//   µå¶óÀ̹ö °ü·Ã ȯ°æ ¼³Á¤ µî..
125//
126
127
128
129
130
131
132//===========================================================================
133//
134//       Constants, Variables, Function declarations
135//
136
137
138
139XdsChannelInfo *g_XdsChannel;
140
141
142
143
144
145enum 
146{
147        XDS_EVENT_CH_DB_UPDATED = 1000,
148                //
149                // XDS data°¡ ¼ö½ÅµÇ¾î¼­ Channel DB (ÁÖ·Î CSD) Ç׸ñÀÌ º¯°æµÇ¾úÀ½.
150                // NvRam ¿¡ DB update¸¦ ÇØ¾ß ÇÒ Çʿ䰡 ÀÖ´Ù.
151                //
152                // param : none
153                //
154
155        XDS_EVENT_EPG_DB_UPDATED,
156                //
157                // XDS data°¡ ¼ö½ÅµÇ¾î¼­ Program DB Ç׸ñÀÌ º¯°æµÇ¾úÀ½.
158               
159};
160
161
162
163typedef STATUS (*XdsEventCallback)(int event, UINT32 param);
164
165
166
167//
168// user callback function pointer
169//  user¿¡°Ô ¾Ë·ÁÁÙ Á¤º¸°¡ ÀÖÀ¸¸é ÀÌ callbackÀ» ÅëÇØ¼­ ¾Ë·ÁÁØ´Ù.
170//
171XdsEventCallback g_fnXdsEventCallback;
172
173
174
175
176//===========================================================================
177//
178//       Implementations
179//
180
181
182
183
184#if COMMENT
185____Mutex______(){}
186#endif
187
188
189//   Mutex = { SemID, Owner, lockCnt, FailCnt, UseOsMutex, Name, flag,        traceLvl }
190//
191DMW_MUTEX
192   g_MutexXdsInfo = { 0,     0,     0,       0,       FALSE,  "XdsInfo", OS_SEM_PRIO, FALSE, };
193   
194
195
196void LockXdsInfoMutex(BOOL bLock)
197{
198        if (bLock)
199                DMW_LockMutex(&g_MutexXdsInfo);
200        else
201                DMW_UnlockMutex(&g_MutexXdsInfo);
202}
203
204void DeleteXdsInfoMutex()
205{
206        DMW_DeleteMutex(&g_MutexXdsInfo);
207}
208
209
210
211
212
213#if COMMENT
214____XdsInfo_______(){}
215#endif
216
217
218
219//------------------------------------------
220//  FindXdsChannelInfoByRf
221//
222//  rf ¿¡ ÇØ´çÇÏ´Â Channel Info¸¦ ã¾Æ¼­ Æ÷ÀÎÅ͸¦ ¸®ÅÏ.
223//  ¾øÀ¸¸é NULLÀ» ¸®ÅÏÇÑ´Ù.
224//
225//  Unlock »óÅ¿¡¼­ ÀÛ¾÷Çϱ⠶§¹®¿¡ caller°¡ LockÀ» ÇØ¾ß ÇÑ´Ù.
226//
227XdsChannelInfo *FindXdsChannelInfoByRf(int rf)
228{
229        XdsChannelInfo *chInfo = g_XdsChannel;
230       
231        while (chInfo)
232        {
233                if (chInfo->rf == rf)
234                        return chInfo;
235                       
236                chInfo = chInfo->pNext;
237        }
238        return NULL;
239}
240
241
242//------------------------------------------
243//  AllocateNewXdsChannelInfo
244//
245//  »õ·Ó°Ô XdsChannelInfo ¸Þ¸ð¸®¸¦ ÇÒ´çÇϰí, DB¿¡ Ãß°¡ÇÑ ÈÄ¿¡
246//  Æ÷ÀÎÅ͸¦ ¸®ÅÏÇÑ´Ù.
247//  ÁöÁ¤ÇÑ rfÀÇ channel info´Â ±âÁ¸ DB¿¡ ¾ø¾î¾ß ÇÑ´Ù. (¾È±×·¯¸é µ¿ÀÏÇÑ rf·Î µÎ°³ ÀÌ»óÀÇ info Á¸Àç)
248//
249XdsChannelInfo *AllocateNewXdsChannelInfo(int rf)
250{
251        XdsChannelInfo *newChInfo, *chInfo, *chInfoPrev;
252       
253       
254        newChInfo = OS_Calloc(1, sizeof(XdsChannelInfo));
255       
256        if (newChInfo == NULL) {
257                //dprint(0, "!! out of memory for XdsChannelInfo\n");
258                return NULL;
259        }
260       
261        newChInfo->rf = rf;
262       
263        // traverse channel info chain until proper position found in linked-list
264        //
265        chInfo = g_XdsChannel;
266        chInfoPrev = NULL;
267       
268        while (chInfo)
269        {
270                // check so that sort state is not broken..
271                if (rf <= chInfo->rf)
272                {
273                        if (rf == chInfo->rf)
274                                dprint(0, "!! same rf %d channel exist in allocate\n", rf);
275                       
276                        break;
277                }
278               
279                chInfoPrev = chInfo;
280                chInfo = chInfo->pNext;
281        }
282       
283        // we have to insert newChInfo between chInfoPrev and chInfo
284       
285        if (chInfoPrev == NULL)
286        {
287                // head of whole list
288                dprint(2, " new chInfo inserted head of list\n");
289               
290                g_XdsChannel = newChInfo;
291                newChInfo->pNext = chInfo;
292        }
293        else
294        {
295                chInfoPrev->pNext = newChInfo;
296                newChInfo->pNext = chInfo;      // chInfo may be NULL, but that's ok.
297        }
298       
299        return newChInfo;
300}
301
302
303
304//------------------------------------------
305//  FindXdsProgramInfoByProgramID
306//
307//  ÇØ´ç channel info Á¤º¸¿¡¼­ programID¿Í ÀÏÄ¡ÇÏ´Â program info¸¦ °Ë»öÇÑ´Ù.
308//  ¾øÀ¸¸é NULLÀ» ¸®ÅÏ.
309//
310XdsProgramInfo *FindXdsProgramInfoByProgramID(XdsChannelInfo *chInfo, UINT32 startTime)
311{
312        XdsProgramInfo *programInfo;
313       
314        if (chInfo == NULL || chInfo->programs == NULL)
315                return NULL;
316
317        programInfo = chInfo->programs;
318       
319        while (programInfo)
320        {
321                if (programInfo->startTime == startTime)
322                {
323                        return programInfo;
324                }
325                       
326                programInfo = programInfo->pNext;
327        }
328        return NULL;
329}
330
331
332
333
334//------------------------------------------
335//  AllocateNewXdsProgramInfo
336//
337// »õ·Ó°Ô XdsProgramInfo ¸Þ¸ð¸®¸¦ ÇÒ´çÇϰí, DB¿¡ Ãß°¡ÇÑ ÈÄ¿¡ Æ÷ÀÎÅ͸¦ ¸®ÅÏÇÑ´Ù.
338//
339// ÁöÁ¤ÇÑ startTime ÀÇ program info´Â ±âÁ¸ DB¿¡ ¾ø¾î¾ß ÇÑ´Ù.
340// Ãß°¡ µÉ ¶§´Â startTime ±âÁØÀ¸·Î Á¤·ÄµÇ¾î¼­ list¿¡ µé¾î°£´Ù.
341//
342//
343XdsProgramInfo *AllocateNewXdsProgramInfo(XdsChannelInfo *chInfo, UINT32 startTime)
344{
345//»ç¿ëÇÏÁö ¾Ê´Â º¯¼ö Á¦°Å :     programID, newProgramID         probability
346//      UINT32 programID, newProgramID;
347       
348        XdsProgramInfo *newProgramInfo, *programInfo, *programInfoPrev;
349       
350       
351        newProgramInfo = OS_Calloc(1, sizeof(XdsProgramInfo));
352       
353        if (newProgramInfo == NULL) {
354                //dprint(0, "!! out of memory for XdsChannelInfo\n");
355                return NULL;
356        }
357       
358        newProgramInfo->rf = chInfo->rf;
359        newProgramInfo->startTime = startTime;
360
361       
362        // traverse channel info chain until proper position found in linked-list
363        //
364        programInfo = chInfo->programs;
365        programInfoPrev = NULL;
366       
367        while (programInfo)
368        {
369                // check so that sort state is not broken..
370
371                if (startTime <= programInfo->startTime)
372                {
373                        if (startTime == programInfo->startTime)
374                                dprint(0, "!! same progID 0x%x exist in allocate\n", startTime);
375                               
376                        break;
377                }
378
379                programInfoPrev = programInfo;
380                programInfo = programInfo->pNext;
381        }
382       
383        // we have to insert 'newProgramInfo' between 'programInfoPrev' and 'programInfo'
384       
385        if (programInfoPrev == NULL)
386        {
387                // head of whole list
388                dprint(2, " new program info inserted head of list\n");
389               
390                chInfo->programs = newProgramInfo;
391                newProgramInfo->pNext = programInfo;
392        }
393        else
394        {
395                programInfoPrev->pNext = newProgramInfo;
396                newProgramInfo->pNext = programInfo;    // programInfo may be NULL, but that's ok.
397        }
398       
399        return newProgramInfo; 
400}
401
402
403
404
405
406//------------------------------------------
407//  DeleteXdsProgramInfoItems
408//
409//  ÇØ´ç program info ¾ÈÀÇ °¢Á¾ item µéÀ» »èÁ¦ÇÑ´Ù.
410//  ¿¬°áµÇ¾î ÀÖ´Â ¸ðµç pointer µéµµ ±ú²ýÀÌ »èÁ¦ÇÑ´Ù.
411//
412//  ÁÖÀÇ!
413//  ÀÌ program info´Â DBÀÇ ÀϺκРÀϼöµµ ÀÖ°í, Query API¸¦ ÀÌ¿ëÇØ¼­
414//  Application ¿¡ ³Ñ°ÜÁø »çº» Àϼöµµ ÀÖ´Ù.
415//
416//
417void DeleteXdsProgramInfoItems(XdsProgramInfo *programInfo)
418{
419        if (programInfo == NULL)
420                return;
421       
422        if (programInfo->ratingInfo) {
423                dprint(3, "    free rating info\n");
424                OS_Free(&programInfo->ratingInfo);
425        }
426
427        if (programInfo->audioInfo) {
428                dprint(3, "    free audio info\n");
429                OS_Free(&programInfo->audioInfo);
430        }
431
432        if (programInfo->captionInfo) {
433                dprint(3, "    free caption info\n");
434                OS_Free(&programInfo->captionInfo);
435        }
436
437        if (programInfo->cgmsaInfo) {
438                dprint(3, "    free cgmsa info\n");
439                OS_Free(&programInfo->cgmsaInfo);
440        }
441
442        if (programInfo->aspectRatioInfo) {
443                dprint(3, "    free aspect ratio info\n");
444                OS_Free(&programInfo->aspectRatioInfo);
445        }
446
447        if (programInfo->programDescription) {
448                dprint(3, "    free prog desc info\n");
449                OS_Free(&programInfo->programDescription);
450        }
451}
452
453
454
455//------------------------------------------
456//  DeleteXdsProgramInfoList
457//
458//  ƯÁ¤ channelÀÇ ¸ðµç program info¸¦ »èÁ¦.
459//  local time ±âÁØÀ¸·Î program info°¡ ÀÛ¼ºµÇ¾ú±â ¶§¹®¿¡
460//  time Á¤º¸°¡ º¯°æµÇ¸é ¸ðµç program info ÀÚü°¡ ¹«ÀǹÌÇØÁø´Ù.
461//
462//  ÀÌ ChannelInfo, ProgramInfo´Â ¸ðµÎ DBÀÇ ÀϺκÐÀ̾î¾ß ÇÑ´Ù.
463//
464void DeleteXdsProgramInfoList(XdsChannelInfo *chInfo)
465{
466        XdsProgramInfo *programInfo, *programInfoPrev;
467       
468        if (chInfo == NULL || chInfo->programs == NULL)
469                return;
470       
471        programInfo = chInfo->programs;
472        programInfoPrev = NULL;
473       
474        while (programInfo)
475        {
476                programInfoPrev = programInfo;
477                programInfo = programInfo->pNext;
478               
479                // delete programInfoPrev..
480                //
481                DeleteXdsProgramInfoItems(programInfoPrev);
482                OS_Free(&programInfoPrev);
483        }
484       
485        chInfo->programs = NULL;
486}
487
488
489
490//------------------------------------------
491//  CopyXdsProgramInfo
492//
493//  XdsProgramInfo ÀÇ °¢ field link±îÁö ¸ðµÎ º¹»ç¸¦ ÇÑ´Ù.
494//  Query API ³»ºÎ¿¡¼­ program infoÀÇ »çº»À» ¸¸µé¶§ »ç¿ëµÈ´Ù.
495//
496//
497STATUS CopyXdsProgramInfo(XdsProgramInfo *pDst, XdsProgramInfo *pSrc)
498{
499        int err = statusOutOfMemory;
500       
501        memcpy(pDst, pSrc, sizeof(XdsProgramInfo));
502       
503       
504        if (pSrc->ratingInfo)
505        {
506                pDst->ratingInfo = OS_Calloc(1, sizeof(XdsRatingInfo));
507               
508                if (pDst->ratingInfo == NULL)
509                        goto label_err_exit;
510                       
511                memcpy(pDst->ratingInfo, pSrc->ratingInfo, sizeof(XdsRatingInfo));
512        }
513
514        if (pSrc->audioInfo)
515        {
516                pDst->audioInfo = OS_Calloc(1, sizeof(XdsAudioInfo));
517
518                if (pDst->ratingInfo == NULL)
519                        goto label_err_exit;
520                       
521                memcpy(pDst->audioInfo, pSrc->audioInfo, sizeof(XdsAudioInfo));
522        }
523       
524        if (pSrc->captionInfo)
525        {
526                pDst->captionInfo = OS_Calloc(1, sizeof(XdsCaptionInfo));
527
528                if (pDst->captionInfo == NULL)
529                        goto label_err_exit;
530                       
531                memcpy(pDst->captionInfo, pSrc->captionInfo, sizeof(XdsCaptionInfo));
532        }
533       
534        if (pSrc->cgmsaInfo)
535        {
536                pDst->cgmsaInfo = OS_Calloc(1, sizeof(XdsCGMSA));
537
538                if (pDst->cgmsaInfo == NULL)
539                        goto label_err_exit;
540                       
541                memcpy(pDst->cgmsaInfo, pSrc->cgmsaInfo, sizeof(XdsCGMSA));
542        }
543       
544        if (pSrc->aspectRatioInfo)
545        {
546                pDst->aspectRatioInfo = OS_Calloc(1, sizeof(XdsAspectRatioInfo));
547
548                if (pDst->aspectRatioInfo == NULL)
549                        goto label_err_exit;
550                       
551                memcpy(pDst->aspectRatioInfo, pSrc->aspectRatioInfo, sizeof(XdsAspectRatioInfo));
552        }
553       
554        if (pSrc->programDescription)
555        {
556                pDst->programDescription = OS_Calloc(1, sizeof(XdsProgramDescription));
557               
558                if (pDst->programDescription == NULL)
559                        goto label_err_exit;
560                       
561                memcpy(pDst->programDescription, pSrc->programDescription, sizeof(XdsProgramDescription));
562        }
563       
564        pDst->pNext = NULL;
565       
566        return statusOK;
567       
568label_err_exit:
569
570        if (pDst->ratingInfo)
571                OS_Free(&pDst->ratingInfo);
572               
573        if (pDst->audioInfo)
574                OS_Free(&pDst->audioInfo);
575
576        if (pDst->captionInfo)
577                OS_Free(&pDst->captionInfo);
578
579        if (pDst->cgmsaInfo)
580                OS_Free(&pDst->cgmsaInfo);
581
582        if (pDst->aspectRatioInfo)
583                OS_Free(&pDst->aspectRatioInfo);
584
585        if (pDst->programDescription)
586                OS_Free(&pDst->programDescription);
587
588        return err;
589       
590}
591
592
593
594#if COMMENT
595____VBI_IF_______(){}
596#endif
597
598
599#if 0
600
601
602void GoToControlCodeRoutine( XDSControlClass_t xdsClass , UINT8 controlType , UINT8 *xdsDataBuffer , UINT8 xdsDataSize )
603{
604        if(xdsClass == CurrentClass)
605        {
606                switch(controlType)
607                {
608                        case 0x01:              /*Program Identification Number*/
609#if XDS_DEBUG
610                                OS_DbgPrintf("Current :: ProgramIdentificationNumber\n");
611#endif
612                                ProgramIdentificationNumber(xdsDataBuffer , xdsDataSize);
613                                break;         
614                               
615                        case 0x02:              /*Length/Time-in-Show*/
616#if XDS_DEBUG
617                                OS_DbgPrintf("Current :: Length/Time-in-Show\n");
618#endif
619                                LengthTimeInShow(xdsDataBuffer , xdsDataSize);
620                                break;
621                               
622                        case 0x03:              /*Program Name(title)*/
623#if XDS_DEBUG
624                                OS_DbgPrintf("Current :: Program Name(title)\n");
625#endif
626                                ProgramName(xdsDataBuffer , xdsDataSize);
627                                break;
628                               
629                        case 0x04:              /*Program Type*/
630#if XDS_DEBUG
631                                OS_DbgPrintf("Current :: Program Type\n");
632#endif
633                                ProgramType(xdsDataBuffer , xdsDataSize);
634                                break;
635                               
636                        case 0x05:              /*Content Advisory*/
637#if XDS_DEBUG
638                                OS_DbgPrintf("Current :: Content Advisory\n");
639#endif
640                                ContentAdvisory(xdsDataBuffer , xdsDataSize);
641                                break;
642                               
643                        case 0x06:              /*Audio Services*/
644#if XDS_DEBUG
645                                OS_DbgPrintf("Current :: Audio Services\n");
646#endif
647                                AudioServices(xdsDataBuffer , xdsDataSize);
648                                break;
649                               
650                        case 0x07:              /*Caption Services*/
651#if XDS_DEBUG
652                                OS_DbgPrintf("Current :: Caption Services\n");
653#endif
654                                CaptionServices(xdsDataBuffer , xdsDataSize);
655                                break;
656                               
657                        case 0x08:              /*Copy Generation Management System(Analog)*/
658#if XDS_DEBUG
659                                OS_DbgPrintf("Current :: Copy Generation Management System(Analog)\n");
660#endif
661                                CopyGenerationManagementSystemA(xdsDataBuffer , xdsDataSize);
662                                break;
663                               
664                        case 0x09:              /*Aspect Ration Information*/
665#if XDS_DEBUG
666                                OS_DbgPrintf("Current :: Aspect Ration Information\n");
667#endif
668                                AspectRatioInformation(xdsDataBuffer ,  xdsDataSize);
669                                break;
670                               
671                        case 0x0C:              /*Composite Packet1*/
672#if XDS_DEBUG
673                                OS_DbgPrintf("Current :: Composite Packet1\n");
674#endif
675                                CompositePacket1(xdsDataBuffer , xdsDataSize);
676                                break;
677                               
678                        case 0x0D:              /*Composite Packet2*/
679#if XDS_DEBUG
680                                OS_DbgPrintf("Current :: Composite Packet2\n");
681#endif
682                                CompositePacket2(xdsDataBuffer , xdsDataSize);
683                                break;
684                               
685                        case 0x10:              /*Program Description Row 1 to Row 8*/
686                        case 0x11:
687                        case 0x12:
688                        case 0x13:
689                        case 0x14:
690                        case 0x15:
691                        case 0x16:
692                        case 0x17:
693#if XDS_DEBUG
694                                OS_DbgPrintf("Current :: Program Description\n");
695#endif
696                                ProgramDescription( xdsDataBuffer , xdsDataSize , controlType-0x10 );
697                                break;
698                }       /*switch(controlType)*/
699        }/*ÇöÀç program¸¸ À¯È¿ÇÑ °É·Î Ãë±ÞÇÏ´Â mode°¡ ¾Æ´Ï °æ¿ì¿¡¸¸ futureclass¸¦ parsingÇÏÀÚ.*/
700        else if ( (xdsClass == FutureClass) && (DMW_608B_IsCurrentOnlyMode() == false))
701        {
702                switch(controlType)
703                {
704                        case 0x01:              /*Program Identification Number*/
705#if XDS_DEBUG
706                                OS_DbgPrintf("Future :: ProgramIdentificationNumber\n");
707#endif
708                                ProgramIdentificationNumber(xdsDataBuffer , xdsDataSize);
709                                break;         
710                               
711                        case 0x02:              /*Length/Time-in-Show*/
712#if XDS_DEBUG
713                                OS_DbgPrintf("Future :: Length/Time-in-Show\n");
714#endif
715                                LengthTimeInShow(xdsDataBuffer , xdsDataSize);
716                                break;
717                               
718                        case 0x03:              /*Program Name(title)*/
719#if XDS_DEBUG
720                                OS_DbgPrintf("Future :: Program Name(title)\n");
721#endif
722                                ProgramName(xdsDataBuffer , xdsDataSize);
723                                break;
724                               
725                        case 0x04:              /*Program Type*/
726#if XDS_DEBUG
727                                OS_DbgPrintf("Future :: Program Type\n");
728#endif
729                                ProgramType(xdsDataBuffer , xdsDataSize);
730                                break;
731                               
732                        case 0x05:              /*Content Advisory*/
733#if XDS_DEBUG
734                                OS_DbgPrintf("Future :: Content Advisory\n");
735#endif
736                                ContentAdvisory(xdsDataBuffer , xdsDataSize);
737                                break;
738                               
739                        case 0x06:              /*Audio Services*/
740#if XDS_DEBUG
741                                OS_DbgPrintf("Future :: Audio Services\n");
742#endif
743                                AudioServices(xdsDataBuffer , xdsDataSize);
744                                break;
745                               
746                        case 0x07:              /*Caption Services*/
747#if XDS_DEBUG
748                                OS_DbgPrintf("Future :: Caption Services\n");
749#endif
750                                CaptionServices(xdsDataBuffer , xdsDataSize);
751                                break;
752                               
753                        case 0x08:              /*Copy Generation Management System(Analog)*/
754#if XDS_DEBUG
755                                OS_DbgPrintf("Future :: Copy Generation Management System(Analog)\n");
756#endif
757                                CopyGenerationManagementSystemA(xdsDataBuffer , xdsDataSize);
758                                break;
759                               
760                        case 0x09:              /*Aspect Ration Information*/
761#if XDS_DEBUG
762                                OS_DbgPrintf("Future :: Aspect Ration Information\n");
763#endif
764                                AspectRatioInformation(xdsDataBuffer ,  xdsDataSize);
765                                break;
766                               
767                        case 0x0C:              /*Composite Packet1*/
768#if XDS_DEBUG
769                                OS_DbgPrintf("Future :: Composite Packet1\n");
770#endif
771                                CompositePacket1(xdsDataBuffer , xdsDataSize);
772                                break;
773                               
774                        case 0x0D:              /*Composite Packet2*/
775#if XDS_DEBUG
776                                OS_DbgPrintf("Future :: Composite Packet2\n");
777#endif
778                                CompositePacket2(xdsDataBuffer , xdsDataSize);
779                                break;
780                               
781                        case 0x10:              /*Program Description Row 1 to Row 8*/
782                        case 0x11:
783                        case 0x12:
784                        case 0x13:
785                        case 0x14:
786                        case 0x15:
787                        case 0x16:
788                        case 0x17:
789#if XDS_DEBUG
790                                OS_DbgPrintf("Future :: Program Description\n");
791#endif
792                                break;
793                }       /*switch(controlType)*/
794        }
795        else if (xdsClass == ChannelClass)
796        {
797                switch(controlType)
798                {
799                        case 0x01:              /*Network Name*/
800#if XDS_DEBUG
801                                OS_DbgPrintf("Network Name\n");
802#endif
803                                NetworkName(xdsDataBuffer , xdsDataSize);
804                                break;
805                               
806                        case 0x02:              /*Call Letters(StatonID) and Native Channel*/
807#if XDS_DEBUG
808                                OS_DbgPrintf("Call Letters(StatonID) and Native Channel\n");
809#endif
810                                CallLetters(xdsDataBuffer , xdsDataSize);
811                                break;
812                               
813                        case 0x03:              /*Tape Delay*/
814#if XDS_DEBUG
815                                OS_DbgPrintf("Tape Delay\n");
816#endif
817                                TapeDelay(xdsDataBuffer , xdsDataSize);
818                                break;
819                               
820                        case 0x04:              /*Transmission Signal Identifier(TSID)*/
821#if XDS_DEBUG
822                                OS_DbgPrintf("Transmission Signal Identifier(TSID)\n");
823#endif
824                                TransmissionSignalIdentifier(xdsDataBuffer , xdsDataSize);
825                                break;
826                               
827                }       /*switch(conrolType)*/
828        }
829        else if (xdsClass == MiscellaneousClass)
830        {
831                switch(controlType)
832                {
833                        case 0x01:              /*Time of Day*/
834#if XDS_DEBUG
835
836                                OS_DbgPrintf("Time of Day\n");
837#endif
838                                TimeOfDay(xdsDataBuffer , xdsDataSize);
839                                break;
840                               
841                        case 0x02:              /*Impulse Capture ID*/
842#if XDS_DEBUG
843                                OS_DbgPrintf("Impulse Capture ID\n");
844#endif
845                                ImpulseCaptureID(xdsDataBuffer , xdsDataSize);
846                                break;
847                               
848                        case 0x03:              /*Supplemental Data Location*/
849#if XDS_DEBUG
850                                OS_DbgPrintf("Supplemental Data Location\n");
851#endif
852                                SupplementDataLocation(xdsDataBuffer , xdsDataSize);
853                                break;
854                               
855                        case 0x04:              /*Local Time Zone & DST Use*/
856#if XDS_DEBUG
857                                OS_DbgPrintf("Local Time Zone & DST Use\n");
858#endif
859                                LocalTimeZone_DSTUse (xdsDataBuffer , xdsDataSize);
860                                break;
861                               
862                        case 0x40:              /*Out-of-Band Channel Number*/
863#if XDS_DEBUG
864                                OS_DbgPrintf("Out-of-Band Channel Number\n");
865#endif
866                                OutOfBandChannelNumber(xdsDataBuffer , xdsDataSize);
867                                break;
868                               
869                        case 0x41:              /*Channel Map Pointer*/
870#if XDS_DEBUG
871                                OS_DbgPrintf("Channel Map Pointer\n");
872#endif
873                                ChannelMapPointer(xdsDataBuffer , xdsDataSize);
874                                break;
875                               
876                        case 0x42:              /*Channel Map Header Packet*/
877#if XDS_DEBUG
878                                OS_DbgPrintf("Channel Map Header Packet\n");
879#endif
880                                ChannelMapHeaderPacket(xdsDataBuffer , xdsDataSize);
881                               
882                                break;
883                               
884                        case 0x43:              /*Channel Map Packet*/
885#if XDS_DEBUG
886                                OS_DbgPrintf("Channel Map Packet\n");
887#endif
888                                ChannelMapPacket(xdsDataBuffer , xdsDataSize);
889                               
890                                break;                         
891                }       /*switch(controlType)*/
892        }
893        else if (xdsClass == PublicServiceClass)
894        {
895                switch(controlType)
896                {
897                        case 0x01:              /*National Weather Service Code(WRSAME)*/
898#if XDS_DEBUG
899                                OS_DbgPrintf("National Weather Service Code(WRSAME)\n");
900#endif
901                                NationalWeatherServiceCode(xdsDataBuffer , xdsDataSize);
902                                break;
903                               
904                        case 0x02:              /*National Weather Service Message*/
905#if XDS_DEBUG
906                                OS_DbgPrintf("National Weather Service Message\n");
907#endif
908                                break; 
909                }
910        }
911        else if(xdsClass == PrivateClass)
912        {
913                /*nothing*/
914        }       
915}
916
917
918
919
920
921void OnReceiveXDSData( UINT8 *VBIData )
922{
923        static UINT8 xdsDataBuffer[32];                                 /*The maximum size of XDS Data field is 32 bytes.*/     
924        static XDSControlClass_t xdsClass = CurrentClass;       /*class type : current ,future , channel , miscellaneous , public service , private , all*/
925        static UINT8 controlType = 0;                                   /*it is specific to the class*/
926        static UINT8 bufferPos = 0;
927        static UINT16   checkSum = 0;
928        static UINT16   checkSum2=0;
929        int i=0;
930       
931        switch ( VBIData[0] )
932        {
933                case 0x01:              /*Control Code : Current class Start Function.*/
934                case 0x03:              /*Control Code : Future class Start Function.*/
935                case 0x05:              /*Control Code : Channel class Start Function.*/
936#if DMW_XDS_TIMEOFDAY_BUG_FIX_1
937                case 0x07:              /*Control Code: Miscellaneous */
938                case 0x09:              /*Control Code: PublicServiceClass */
939                case 0x0B:              /*reserved*/
940                case 0x0D:              /*Control Code: PrivaeClass*/
941#endif
942               
943                        /*clear a data buffer*/
944                        memset( xdsDataBuffer , 0 , 32 );
945                        bufferPos = 0;
946                        checkSum = 0;
947                       
948                        checkSum += VBIData[0]+VBIData[1];
949                       
950                        #if _XDS_CHECKSUM_DEBUG
951                                OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ (%d)START checksum=%d, [%d,%d]\n ",VBIData[0],checkSum, VBIData[0],VBIData[1]);
952                        #endif
953                       
954                        /*decide the what is a real control code.*/
955                        controlType = VBIData[1];
956                       
957                        if( VBIData[0] == 0x01 )
958                        {
959                                xdsClass = CurrentClass;
960                        }
961                        else if (VBIData[0] == 0x03)
962                        {
963                                xdsClass = FutureClass;
964                        }
965                        else if (VBIData[0] == 0x05)
966                        {
967                                xdsClass = ChannelClass;
968                        }
969                        else if (VBIData[0] == 0x07)
970                        {
971                                xdsClass = MiscellaneousClass;
972                        }
973                        else if (VBIData[0] == 0x09)
974                        {
975                                xdsClass = PublicServiceClass;
976                        }
977                        else if (VBIData[0] == 0x0B)
978                        {
979                                //reserved;
980                        }
981                        else if (VBIData[0] == 0x0D)
982                        {
983                                xdsClass = PrivateClass;
984                        }
985                       
986                        break;
987                       
988                case 0x02:              /*Control Code : Current class Continue Function.*/
989                case 0x04:              /*Control Code : Future class Continue Function.*/
990                case 0x06:              /*Control Code : Channel class Continue Function.*/
991                case 0x08:              /*Control Code : Miscellaneous Continue Function.*/
992                case 0x0A:              /*Control Code : PublicService Continue Function.*/
993                case 0x0C:              /*reserved.*/
994                case 0x0E:              /*Control Code : Private Continue Functioin.*/
995               
996                        if( controlType != VBIData[1])         
997                                return;                                                 /*if continue Fuction code¶ó¸é ÀÌÀü¿¡ ¿Ô´ø
998                                                                                                  controlÀÇ ¿¬ÀåÀ̾î¾ß ÇϹǷΠcontrolTypeÀÌ ÀÏÄ¡ÇÑ
999                                                                                                  °æ¿ì¸¸ À¯È¿ÇÏ´Ù.*/
1000                //      checkSum += (VBIData[0]+VBIData[1]);   
1001                        break;
1002                       
1003                case 0x0F:             
1004                /*Control Code : All class End Function.*/
1005                /* checksumÀ» °è»êÇϰí, checksum error°¡ ¾ø´Ù¸é ÇØ´ç·çƾÀ» call.*/
1006                        checkSum += VBIData[0];
1007                        #if DMW_XDS_WORKAROUND_CHECKSUM
1008                                checkSum2=checkSum;
1009                                for(i=0;i<bufferPos;i++){
1010                                        if(xdsClass== CurrentClass && controlType== 0x03&& xdsDataBuffer[i]==0x0){//currentClass & ProgramName& (0x00->0x20)
1011                                                checkSum2=checkSum+0x20;//leon for test         
1012                                        }
1013                                }
1014       
1015                                checkSum2 = (((~checkSum2)&0x7F)+1)&0x7F;       // make 2's complement.
1016                        #endif
1017                        checkSum = (((~checkSum)&0x7F)+1)&0x7F; // make 2's complement.
1018                       
1019                        #if _XDS_CHECKSUM_DEBUG
1020                                OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ (%d) END (cal_checksum,checksum)=(%d, %d)%d\n ",VBIData[0],checkSum, VBIData[1],checkSum2);
1021                        #endif
1022                       
1023                #if DMW_XDS_WORKAROUND_CHECKSUM                                         
1024                        if(checkSum==VBIData[1] ||checkSum2==VBIData[1])
1025                #else
1026                        if(checkSum==VBIData[1])        // this XDS packet is valid.    //test
1027                #endif
1028                        //if(1)
1029                        {
1030#if XDS_DEBUG
1031                                dprint(2, "Received Valid XDS packet\n");
1032#endif
1033                                GoToControlCodeRoutine( xdsClass , controlType , xdsDataBuffer , bufferPos);
1034                        }
1035#if XDS_DEBUG                   
1036                        else{
1037
1038                                dprint(2, "CheckSum Error\n");
1039
1040                        }
1041#endif                                                 
1042                        break;
1043                       
1044                default  :              /*condtorl code¸¦ Á¦¿ÜÇßÀ¸´Ï ¸ðµÎ data·Á´Ï...*/
1045                        if(bufferPos > 32 )             /*data size°¡ 32º¸´Ù Å©¸é ¹º°¡ À߸ø ³¯¾Æ ¿Â °Å´Ù.*/
1046                                return;
1047                               
1048                        checkSum += VBIData[0]+VBIData[1];
1049                        #if _XDS_CHECKSUM_DEBUG
1050                                if(VBIData[0]<0x20 ||VBIData[0]>0x7F){
1051                                        OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ Data0 Error [0x%x]\n",VBIData[0]);
1052                                }
1053                                if(VBIData[1]<0x20 ||VBIData[1]>0x7F){
1054                                        OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ Data1 Error [0x%x]\n",VBIData[1]);
1055                                }                               
1056                               
1057                                OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ (%d) ... (cal_checksum=%d),(%d, %d) (0x%x,0x%x) cnt=%d\n ",VBIData[0],checkSum, VBIData[0],VBIData[1],VBIData[0],VBIData[1],bufferPos);
1058                                OS_DbgPrintf("_XDS_CHECKSUM_DEBUG_ (%d) ... (cal_checksum=%d),(%c, %c) cnt=%d\n ",VBIData[0],checkSum, VBIData[0],VBIData[1],bufferPos);
1059                        #endif
1060                       
1061                        xdsDataBuffer[bufferPos++] = VBIData[0];
1062                        xdsDataBuffer[bufferPos++] = VBIData[1];
1063                        break; 
1064                                       
1065        }
1066
1067/*     
1068        if(VBIData[0]!=0x0F)    // ÀÏ¹Ý XDS char.
1069        {
1070                checkSum += (VBIData[0]+VBIData[1]);
1071        }
1072        else             // XDS End. check the checksum.
1073        {
1074                checkSum += VBIData[0];
1075        }       
1076*/
1077
1078}
1079
1080
1081
1082
1083#endif
1084
1085
1086
1087#if COMMENT
1088____COM_IF_________(){}
1089#endif
1090
1091       
1092
1093//-------------------------------------------------------
1094//  DMW_XDS_UpdateXdsChannelInfo
1095//
1096//  XDS ä³Î Á¤º¸¸¦ DB¿¡ µî·ÏÇÑ´Ù.
1097//
1098//  ÀÎÀÚ·Î ³Ñ¾î¿À´Â newChannelInfo °¡ DB¿¡ Á÷Á¢ insertµÇ´Â °ÍÀÌ ¾Æ´Ï°í º°µµÀÇ ¸Þ¸ð¸®°¡ ÇÒ´çµÈ´Ù.
1099//  µû¶ó¼­ caller´Â local area¿¡ newChannelInfo¸¦ Àӽ÷ΠÇÒ´çÇØµµ µÈ´Ù.
1100//
1101//  newChannelInfoÀÇ rf °ªÀº ¹Ýµå½Ã valid ÇØ¾ß ÇÑ´Ù. (º°µµÀÇ valid mask °ªÀº ¾øÀ½)
1102//
1103//  CallLetter, NetworkName µîÀº NULL·Î Á¾·áµÇ´Â ASCIIZ ÇüÅÂÀ̾î¾ß ÇÑ´Ù.
1104//
1105STATUS DMW_XDS_UpdateXdsChannelInfo(XdsChannelInfo *newChannelInfo, UINT32 validMask)
1106{
1107        XdsChannelInfo *chInfo;
1108       
1109        STATUS err, returnStatus = statusError;
1110        BOOL bChannelNameUpdated;
1111       
1112        if (newChannelInfo == NULL || newChannelInfo->rf <= 0) 
1113                return statusInvalidArgument;
1114
1115
1116        // ´Ü¼øÈ÷ ¸Þ¸ð¸® ÇÒ´ç ¸¸ÀÇ ¿ëµµ¶ó¸é validMask´Â 0ÀÏ ¼ö ÀÖÀ½.
1117        //if (validMask == 0)
1118        //      return statusInvalidArgument;
1119
1120
1121        LockXdsInfoMutex(TRUE); //<----- Lock
1122
1123        // rf ¿¡ ÇØ´çÇÏ´Â ±âÁ¸ XdsChInfo¸¦ °Ë»ö...
1124       
1125        chInfo = FindXdsChannelInfoByRf(newChannelInfo->rf);
1126       
1127        if (chInfo == NULL)
1128        {
1129                // make new one
1130                //
1131                chInfo = AllocateNewXdsChannelInfo(newChannelInfo->rf);
1132               
1133                if (chInfo == NULL) {
1134                        dprint(0, "!! cannot allocate new xds channel info\n");
1135                        returnStatus = statusOutOfMemory;
1136                        goto label_end;
1137                }
1138        }
1139       
1140        // channelInfo <-- newChannelInfo ¿¡ update..
1141        // validMask ¿¡ set µÈ bit¿¡ ÇØ´çµÇ´Â field ¸¸ À¯È¿ÇÏ´Ù.
1142
1143        bChannelNameUpdated = FALSE;
1144       
1145        if (validMask & XVM_NETWORK_NAME)
1146        {
1147//compile warming Á¦°Å¸¦ À§ÇÑ Çüº¯È¯ : (char *)         probability     
1148                strncpy((char *)chInfo->networkName, (char *)newChannelInfo->networkName, 32);
1149                chInfo->networkName[32] = 0;
1150
1151                dprint(3, "   network name '%s' updated\n", chInfo->networkName);
1152
1153                // update to CSD
1154                //
1155                // source_id 0 is reserved for PSIP specification.
1156                // we use value '0' as an indication of analog channel.
1157                //
1158//compile warming Á¦°Å¸¦ À§ÇÑ Çüº¯È¯ : (char *)         probability
1159                err = DMW_CDB_UpdateUcmCsdEntry(chInfo->rf, 0, CSD_TAG_XDS_NETWORK_NAME, 
1160                                                        strlen((char *)chInfo->networkName) + 1, chInfo->networkName);
1161
1162                if (err == statusNotChanged) {
1163                        dprint(2, "  same network name\n");
1164                }
1165                else if (err) {
1166                        dprint(1, "  !! update xds network name to csd err %d, %s (rf %d)\n", 
1167                                                err, DMW_CDB_ErrString(err), chInfo->rf);
1168                }
1169                else {
1170                        bChannelNameUpdated = TRUE;
1171                }
1172        }
1173        if (validMask & XVM_CALL_LETTER)
1174        {
1175                memcpy(chInfo->stationId, newChannelInfo->stationId, 7);  // including NULL terminator
1176
1177                dprint(3, "   call letter '%s' updated\n", chInfo->stationId);
1178               
1179                err = DMW_CDB_UpdateUcmCsdEntry(chInfo->rf, 0, CSD_TAG_XDS_CALL_LETTER, 
1180                                                        7, chInfo->stationId);
1181
1182                if (err == statusNotChanged) {
1183                        dprint(2, "  same call-letter\n");
1184                }
1185                else if (err) {
1186                        dprint(1, "  !! update xds call letter to csd err %d, %s (rf %d)\n",
1187                                                err, DMW_CDB_ErrString(err), chInfo->rf);
1188                }
1189                else {
1190                        bChannelNameUpdated = TRUE;
1191                }
1192               
1193        }
1194        if (validMask & XVM_TSID)
1195        {
1196                chInfo->tsid = newChannelInfo->tsid;
1197        }
1198        if (validMask & XVM_TAPE_DELAY)
1199        {
1200                chInfo->tapeMinute = newChannelInfo->tapeMinute;
1201                chInfo->tapeHour = newChannelInfo->tapeHour;
1202        }
1203       
1204
1205        // notify to user if something in CSD changed..
1206        //
1207        if (bChannelNameUpdated)
1208        {
1209                //
1210                // Caller ¶Ç´Â User¿¡°Ô ÀÌ »ç½ÇÀ» ¾Ë·Á¼­
1211                // UCM update¸¦ Çϵµ·Ï ÇØ¾ß ÇÑ´Ù.
1212                //
1213                if (g_fnXdsEventCallback)
1214                        g_fnXdsEventCallback(XDS_EVENT_CH_DB_UPDATED, 0);
1215               
1216        }
1217       
1218        returnStatus = statusOK;
1219       
1220label_end:
1221
1222        LockXdsInfoMutex(FALSE); //-----> Unlock
1223       
1224        return returnStatus;
1225}
1226
1227
1228
1229
1230
1231
1232
1233//-------------------------------------------------------
1234//  DMW_XDS_UpdateXdsProgramInfo
1235//
1236//  XDS ProgramInfo¸¦ DB¿¡ µî·ÏÇÑ´Ù.
1237//
1238//  ½ÇÁ¦·Î Àû¿ëµÉ fieldÀÇ bit¸¦ validMask¿¡ setÇØ¾ß ÇÑ´Ù.
1239//
1240STATUS DMW_XDS_UpdateXdsProgramInfo(XdsProgramInfo *newProgramInfo, UINT32 validMask)
1241{
1242        STATUS err, returnStatus = statusError;
1243
1244        XdsChannelInfo *chInfo;
1245        XdsProgramInfo *programInfo;
1246
1247//»ç¿ëµÇÁö ¾Ê´Â º¯¼ö Á¦°Å : programID[5]                probability
1248//      UINT8 programID[5];
1249       
1250        if (newProgramInfo == NULL || newProgramInfo->rf <= 0) 
1251                return statusInvalidArgument;
1252
1253
1254        // ¹Ýµå½Ã Program ID Çʵå´Â À¯È¿ÇØ¾ß ÇÑ´Ù. ±×·¡¾ß ÇØ´ç ProgramInfo¸¦ °Ë»öÇÒ ¼ö ÀÖÀ¸´Ï±î
1255        //
1256        if ((validMask & XVM_PROGRAM_ID) == 0)
1257                return statusInvalidArgument;
1258               
1259
1260        LockXdsInfoMutex(TRUE); //<----- Lock
1261
1262        // rf ¿¡ ÇØ´çÇÏ´Â ±âÁ¸ XdsChInfo¸¦ °Ë»ö...
1263       
1264        chInfo = FindXdsChannelInfoByRf(newProgramInfo->rf);
1265       
1266        if (chInfo == NULL)
1267        {
1268                // channel 'rf' not exist. make new one..
1269
1270                XdsChannelInfo newChInfo;
1271               
1272                memset(&newChInfo, 0, sizeof(newChInfo));
1273                newChInfo.rf = newProgramInfo->rf;
1274               
1275                err = DMW_XDS_UpdateXdsChannelInfo(&newChInfo, 0);  // no valid mask..
1276               
1277                if (err == statusOK)
1278                        chInfo = FindXdsChannelInfoByRf(newProgramInfo->rf);
1279               
1280                if (chInfo == NULL) {
1281                        dprint(0, "!! cannot allocate new xds ch info\n");
1282                        returnStatus = statusOutOfMemory;
1283                        goto label_end;
1284                }
1285               
1286        }
1287
1288        // chInfo ¿¡¼­ program info¸¦ °Ë»ö..   
1289        //
1290        programInfo = FindXdsProgramInfoByProgramID(chInfo, newProgramInfo->startTime);
1291
1292        if (programInfo == NULL)
1293        {
1294                // »õ·Ó°Ô program info¸¦ ÇÒ´ç ÇÏ¿©, chInfo->programs list ¿¡ Ãß°¡ÇÑ´Ù.
1295               
1296                //programInfo = AllocateNewXdsProgramInfo(chInfo, programID);
1297               
1298                programInfo = AllocateNewXdsProgramInfo(chInfo, newProgramInfo->startTime);
1299
1300                if (programInfo == NULL) {
1301                        dprint(0, "!! cannot allocate new xds program info\n");
1302                        returnStatus = statusOutOfMemory;
1303                        goto label_end;
1304                }
1305        }
1306       
1307               
1308        // programInfo ¿¡ update..
1309        // validMask ¿¡ set µÈ bit¿¡ ÇØ´çµÇ´Â field ¸¸ À¯È¿ÇÏ´Ù.
1310
1311        if (validMask & XVM_PROGRAM_ID)
1312        {
1313                programInfo->startTime = newProgramInfo->startTime;
1314               
1315                dprint(3, "   program id 0x%08x updated\n", programInfo->startTime);
1316
1317        }
1318        if (validMask & XVM_PROGRAM_LENGTH)
1319        {
1320                programInfo->minLength   = min(newProgramInfo->minLength, 59);
1321                programInfo->hourLength  = min(newProgramInfo->hourLength, 63);
1322
1323                programInfo->minElapsed  = newProgramInfo->minElapsed;
1324                programInfo->hourElapsed = newProgramInfo->hourElapsed;
1325                programInfo->secElapsed  = newProgramInfo->secElapsed;
1326               
1327                dprint(3, "   program length %d:%02d min updated\n", 
1328                                        programInfo->hourLength, programInfo->minLength);
1329               
1330        }
1331        if (validMask & XVM_PROGRAM_NAME)
1332        {
1333//compile warming Á¦°Å¸¦ À§ÇÑ Çüº¯È¯ : (char *)         probability
1334                strncpy((char *)programInfo->programName, (char *)newProgramInfo->programName, 32);
1335                programInfo->programName[32] = 0;
1336
1337                dprint(3, "   program name '%s' updated\n", programInfo->programName);
1338
1339        }
1340        if (validMask & XVM_PROGRAM_TYPE)
1341        {
1342                memcpy(programInfo->programType, newProgramInfo->programType, 32);
1343               
1344        }
1345        if (validMask & XVM_CONTENT_ADVISORY)
1346        {
1347                if (newProgramInfo->ratingInfo)
1348                {
1349                        if (programInfo->ratingInfo)
1350                                OS_Free(&programInfo->ratingInfo);
1351                               
1352                        programInfo->ratingInfo = OS_Calloc(1, sizeof(XdsRatingInfo));
1353                       
1354                        if (programInfo->ratingInfo)
1355                                *(programInfo->ratingInfo) = *(newProgramInfo->ratingInfo);
1356                        else
1357                                dprint(0, "!! out of memory for xds rating info\n");
1358                }
1359                else
1360                        dprint(0, "!! source xds rating info NULL\n");
1361                       
1362        }
1363        if (validMask & XVM_AUDIO_SERVICES)
1364        {
1365                if (newProgramInfo->audioInfo)
1366                {
1367                        if (programInfo->audioInfo)
1368                                OS_Free(&programInfo->audioInfo);
1369
1370                        programInfo->audioInfo = OS_Calloc(1, sizeof(XdsAudioInfo));
1371                       
1372                        if (programInfo->audioInfo)
1373                                *(programInfo->audioInfo) = *(newProgramInfo->audioInfo);
1374                        else
1375                                dprint(0, "!! out of memory for xds audio info\n");
1376                }
1377                else
1378                        dprint(0, "!! source xds audio info NULL\n");
1379
1380        }
1381        if (validMask & XVM_CAPTION_SERVICES)
1382        {
1383                if (newProgramInfo->captionInfo)
1384                {
1385                        if (programInfo->captionInfo)
1386                                OS_Free(&programInfo->captionInfo);
1387
1388                        programInfo->captionInfo = OS_Calloc(1, sizeof(XdsCaptionInfo));
1389                       
1390                        if (programInfo->captionInfo)
1391                                *(programInfo->captionInfo) = *(newProgramInfo->captionInfo);
1392                        else
1393                                dprint(0, "!! out of memory for xds caption info\n");
1394                }
1395                else
1396                        dprint(0, "!! source xds caption  info NULL\n");
1397               
1398        }
1399        if (validMask & XVM_CGMSA)
1400        {
1401                if (newProgramInfo->cgmsaInfo)
1402                {
1403                        if (programInfo->cgmsaInfo)
1404                                OS_Free(&programInfo->cgmsaInfo);
1405
1406                        programInfo->cgmsaInfo = OS_Calloc(1, sizeof(XdsCGMSA));
1407                       
1408                        if (programInfo->cgmsaInfo)
1409                                *(programInfo->cgmsaInfo) = *(newProgramInfo->cgmsaInfo);
1410                        else
1411                                dprint(0, "!! out of memory for xds cgmsa info\n");
1412                }
1413                else
1414                        dprint(0, "!! source xds cgmsa info NULL\n");
1415
1416        }
1417        if (validMask & XVM_ASPECT_RATIO)
1418        {
1419                if (newProgramInfo->aspectRatioInfo)
1420                {
1421                        if (programInfo->aspectRatioInfo)
1422                                OS_Free(&programInfo->aspectRatioInfo);
1423                       
1424                        programInfo->aspectRatioInfo = OS_Calloc(1, sizeof(XdsAspectRatioInfo));
1425                       
1426                        if (programInfo->aspectRatioInfo)
1427                                *(programInfo->aspectRatioInfo) = *(newProgramInfo->aspectRatioInfo);
1428                        else
1429                                dprint(0, "!! out of memory for xds aspect ratio info\n");
1430                }
1431                else
1432                        dprint(0, "!! source xds aspect ratio info NULL\n");
1433
1434        }
1435        if (validMask & XVM_PROGRAM_DESCRIPTION)
1436        {
1437                if (newProgramInfo->programDescription)
1438                {
1439                        if (programInfo->programDescription)
1440                                OS_Free(&programInfo->programDescription);
1441                       
1442                        programInfo->programDescription = OS_Calloc(1, sizeof(XdsProgramDescription));
1443                       
1444                        if (programInfo->programDescription)
1445                                *(programInfo->programDescription) = *(newProgramInfo->programDescription);
1446                        else
1447                                dprint(0, "!! out of memory for xds prog desc \n");
1448                }
1449                else
1450                        dprint(0, "!! source xds prog desc NULL\n");
1451
1452        }
1453        returnStatus = statusOK;
1454
1455label_end:
1456
1457        LockXdsInfoMutex(FALSE); //-----> Unlock
1458
1459        return returnStatus;
1460}
1461
1462
1463
1464
1465
1466
1467#if COMMENT
1468______API______(){}
1469#endif
1470
1471
1472//------------------------------------------
1473//  DMW_XDS_DeleteAllXdsProgramInfo
1474//
1475//  ¸ðµç ä³ÎÀÇ ¸ðµç Program Info Á¤º¸¸¦ »èÁ¦ÇÑ´Ù.
1476//  Channel Info´Â »èÁ¦ÇÏÁö ¾Ê´Â´Ù.
1477//
1478//  ÀÌ APIÀÇ ÁÖµÈ ¿ëµµ´Â, System ¿¡¼­ SysTime Á¤º¸¸¦ º¯°æÇßÀ»¶§
1479//  (TimeZone °ªÀÌ º¯°æ)
1480//  Local time ±â¹ÝÀÎ XDS program Á¤º¸°¡ ÀÇ¹Ì ¾ø¾îÁö±â ¶§¹®ÀÌ´Ù.
1481//
1482STATUS DMW_XDS_DeleteAllXdsProgramInfo()
1483{
1484        XdsChannelInfo *chInfo;
1485
1486        dprint(1, "DeleteAllXdsProgramInfo\n");
1487       
1488        LockXdsInfoMutex(TRUE);
1489       
1490        chInfo = g_XdsChannel;
1491       
1492        while (chInfo)
1493        {
1494                dprint(2, "  delete xds channel rf %d\n", chInfo->rf);
1495               
1496                DeleteXdsProgramInfoList(chInfo);
1497                        // ÁÖÀÇ!
1498                        // chInfo ÀÚü´Â »èÁ¦ÇÏ¸é ¾ÈµÈ´Ù...
1499                       
1500                chInfo = chInfo->pNext;
1501        }
1502       
1503        LockXdsInfoMutex(FALSE);
1504
1505//Á¤»ó Á¾·á ÇßÀ» °æ¿ì return 0          probability
1506        return 0;
1507
1508}
1509
1510
1511//------------------------------------------
1512//
1513//
1514//
1515//
1516STATUS DMW_XDS_RegisterEventCallback(XdsEventCallback cb)
1517{
1518        dprint(2, "RegisterUserCallback 0x%x\n", cb);
1519       
1520        g_fnXdsEventCallback = cb;
1521
1522        //Á¤»ó Á¾·á ÇßÀ» °æ¿ì return 0          probability
1523        return 0;
1524}
1525
1526
1527
1528
1529
1530
1531#if COMMENT
1532______QueryAPI______(){}
1533#endif
1534
1535
1536
1537//------------------------------------------
1538//  DMW_XDS_FreeChannelInfo
1539//
1540//  DMW_XDS_GetChannelInfo ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ¾òÀº channel »çº»À» »ç¿ë ÈÄ »èÁ¦ÇÑ´Ù.
1541// 
1542//
1543STATUS DMW_XDS_FreeChannelInfo(XdsChannelInfo *channel)
1544{
1545        if (channel == NULL)
1546                return statusInvalidArgument;
1547               
1548        OS_Free(&channel);
1549       
1550        return statusOK;
1551}
1552
1553
1554//------------------------------------------
1555//  DMW_XDS_FreeProgramInfoArray
1556//
1557//  DMW_XDS_GetProgramInfo ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ¾òÀº program Á¤º¸ »çº»À» »ç¿ë ÈÄ »èÁ¦ÇÑ´Ù.
1558//  programÀº array ÇüÅ·ΠµÇ¾î Àֱ⠶§¹®¿¡ ¸î°³ÀÇ program element°¡ ÀÖ´ÂÁö¸¦
1559//  nProgramÀ» ÅëÇØ ¾Ë·ÁÁà¾ß ÇÑ´Ù.
1560//
1561//
1562STATUS DMW_XDS_FreeProgramInfoArray(XdsProgramInfo *programs, int nProgram)
1563{
1564        int i;
1565       
1566        for (i=0; i<nProgram; i++)
1567        {
1568                dprint(2, "  delete xds program [%d], rf %d..\n", i, programs[i].rf);
1569                DeleteXdsProgramInfoItems(&programs[i]);
1570                //
1571                // programs[i] ÀÚü´Â arrayÀÇ element À̴ϱî Free ½Ãų ¼ö ¾ø´Ù.
1572        }
1573
1574        dprint(2, "  delete xds program array..\n");
1575        OS_Free(&programs);
1576
1577        return statusOK;
1578}
1579
1580
1581
1582//------------------------------------------
1583//  DMW_XDS_GetChannelInfo
1584//
1585//  ÇØ´ç rf ÀÇ XDS channel Á¤º¸¸¦ °¡Á®¿Â´Ù.
1586//  ÇÊ¿äÇÑ ¸Þ¸ð¸®´Â ³»ºÎ¿¡¼­ ÇÒ´çÇÑ´Ù.
1587//  caller´Â channel Á¤º¸¸¦ »ç¿ëÇÑ ÈÄ Free¸¦ ½ÃÄÑ¾ß ÇÑ´Ù. (º°µµ API ÀÌ¿ë)
1588//
1589//  channel Á¤º¸ ¾ÈÀÇ program Á¤º¸´Â NULL·Î µÇ¾î ÀÖÀ¸¸ç, ÇØ´ç program
1590//  Á¤º¸¸¦ quryÇÏ·Á¸é º°µµÀÇ query API¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù.
1591//
1592//
1593STATUS DMW_XDS_GetChannelInfo(int rf, XdsChannelInfo **ppChanInfo)
1594{
1595        XdsChannelInfo *chInfo;
1596       
1597        if (ppChanInfo == NULL)
1598                return statusInvalidArgument;
1599       
1600        chInfo = FindXdsChannelInfoByRf(rf);
1601       
1602        if (chInfo == NULL)
1603                return statusNotFound;
1604               
1605       
1606        *ppChanInfo = OS_Calloc(1, sizeof(XdsChannelInfo));
1607       
1608        if (*ppChanInfo == NULL)
1609                return statusOutOfMemory;
1610               
1611
1612        memcpy(*ppChanInfo, chInfo, sizeof(XdsChannelInfo));
1613       
1614       
1615        (*ppChanInfo)->programs = NULL;
1616                // program Á¤º¸±îÁö »õ·Ó°Ô duplicate¸¦ ÇÏÁö´Â ¾Ê´Â´Ù.
1617                // ³ªÁß¿¡ Free ½Ãų¶§ ÀÌ program Á¤º¸±îÁö °°ÀÌ Áö¿ö¹ö¸±Áö ¸ð¸£¹Ç·Î
1618                // program Á¤º¸´Â link¸¦ ¾ø¾Ø´Ù.
1619               
1620        (*ppChanInfo)->pNext = NULL;
1621
1622        return statusOK;       
1623}
1624
1625
1626//------------------------------------------
1627//  DMW_XDS_GetProgramInfo
1628//
1629//  nStartTime ºÎÅÍ nDuration ±â°£ À̳»¿¡ µé¾îÀÖ´Â ¸ðµç ÇÁ·Î±×·¥ Á¤º¸¸¦ ¸®ÅÏÇÑ´Ù.
1630//  ÇÁ·Î±×·¥ÀÇ ÀϺθ¸ °ãÄ¡´õ¶óµµ ¸®ÅϵȴÙ.
1631// 
1632//  ÇÊ¿äÇÑ ¸Þ¸ð¸® aFoundProgram Àº ³»ºÎ¿¡¼­ µ¿ÀûÀ¸·Î ÇÒ´çµÇ¹Ç·Î
1633//  caller´Â »ç¿ë ÈÄ¿¡ FreeProgram API·Î »èÁ¦ÇØ¾ß ÇÑ´Ù.
1634//
1635//  nStartTimeÀº GPS ½Ã°£, nDurationÀº ÃÊ ´ÜÀ§..
1636//
1637//
1638STATUS DMW_XDS_GetProgramInfo(int rf, UINT32 nStartTime, UINT32 nDuration, 
1639                                                XdsProgramInfo **aFoundProgram, int *pnPrograms)
1640{
1641        XdsChannelInfo *chInfo;
1642        XdsProgramInfo *progInfo;
1643        int nLengthInSec;
1644        int nProgram;
1645        int err;
1646        UINT32 max_start_time, min_end_time;
1647       
1648        chInfo = FindXdsChannelInfoByRf(rf);
1649       
1650        if (chInfo == NULL)
1651                return statusNotFound;
1652               
1653
1654        progInfo = chInfo->programs;
1655        nProgram = 0;
1656
1657        // ¸ÕÀú °¹¼ö¸¦ ¼¼¾î¼­ ÇÊ¿äÇÑ ¸Þ¸ð¸® Å©±â¸¦ °è»ê..
1658        //             
1659        while (progInfo)
1660        {
1661
1662                nLengthInSec = progInfo->minLength * 60 + progInfo->hourLength * 3600;
1663
1664                max_start_time = max(nStartTime, progInfo->startTime);
1665                min_end_time = min(nStartTime + nDuration-1, progInfo->startTime + nLengthInSec-1);
1666               
1667                if (max_start_time <= min_end_time)
1668                        nProgram++;
1669       
1670                progInfo = progInfo->pNext;     
1671        }
1672
1673        dprint(2, "  %d programs are in range\n", nProgram);
1674       
1675       
1676        *aFoundProgram = OS_Calloc(nProgram, sizeof(XdsProgramInfo));
1677       
1678        if (*aFoundProgram == NULL)
1679                return statusOutOfMemory;
1680               
1681       
1682        *pnPrograms = 0;
1683       
1684        progInfo = chInfo->programs;
1685       
1686        while (progInfo)
1687        {
1688                nLengthInSec = progInfo->minLength * 60 + progInfo->hourLength * 3600;
1689
1690                max_start_time = max(nStartTime, progInfo->startTime);
1691                min_end_time = min(nStartTime + nDuration-1, progInfo->startTime + nLengthInSec-1);
1692               
1693                if (max_start_time <= min_end_time)
1694                {
1695                        dprint(2, "  copy %dth program..\n", *pnPrograms);
1696                       
1697                        err = CopyXdsProgramInfo(&(*aFoundProgram)[*pnPrograms], progInfo);
1698                        if (err)
1699                                break;
1700                       
1701                        (*pnPrograms)++;
1702                }
1703       
1704                if (*pnPrograms >= nProgram)
1705                        break;
1706               
1707                progInfo = progInfo->pNext;     
1708        }
1709
1710
1711        return statusOK;       
1712       
1713}
1714
1715
1716
1717
1718//-------------------------------------------------------------
1719
1720
1721
1722#if COMMENT
1723______TEST______(){}
1724#endif
1725
1726
1727
1728extern char *GpsTimeString(UINT32 gps, char *buf);
1729        // defined in EpgDebug.c
1730
1731
1732//
1733//  XDS program ÇϳªÀÇ Á¤º¸¸¦ Ãâ·Â
1734//
1735void TestPrintXdsProgram(int index, XdsProgramInfo *program)
1736{
1737        char buf[50];
1738       
1739        if (program == NULL)
1740                return;
1741
1742        program->programName[32] = 0; // for safety
1743               
1744        DMW_DBG_SimplePrint("   (%d) %s (0x%x), %d minutes, '%s'\n",
1745                                index, 
1746                                GpsTimeString(program->startTime, buf),
1747                                program->startTime,
1748                                program->hourLength * 60 + program->minLength,
1749                                program->programName);
1750}
1751
1752
1753//
1754//  Query µÈ program »çº» Á¤º¸¸¦ Ç¥½Ã
1755//
1756void TestPrintXdsProgramArray(XdsProgramInfo *program, int nProgram)
1757{
1758        int i;
1759       
1760        for (i=0; i<nProgram; i++)
1761        {
1762                TestPrintXdsProgram(i, &program[i]);
1763        }
1764       
1765        DMW_DBG_SimplePrint("\n");
1766}
1767
1768
1769//
1770// ÇØ´ç XDS channel Á¤º¸¸¦ Ç¥½Ã.
1771// bPrintProgramInfo °¡ TRUE ÀÌ¸é ±× Ã¤³Î ¾ÈÀÇ ¸ðµç Program Á¤º¸µµ Ç¥½Ã.
1772//
1773void TestPrintXdsChannel(int index, XdsChannelInfo *chInfo, BOOL bPrintProgramInfo)
1774{
1775        int numPrograms;
1776        XdsProgramInfo *program;
1777       
1778        if (chInfo == NULL)
1779                return;
1780
1781        chInfo->networkName[32] = 0; // for safety..
1782       
1783        numPrograms = 0;
1784        program = chInfo->programs;
1785        while (program)
1786        {
1787                numPrograms++;
1788                program = program->pNext;
1789        }
1790       
1791        DMW_DBG_SimplePrint(" (%d) RF %d, '%s', '%s', TSID 0x%x, TD %d:%02d, %d programs\n",
1792                                index, chInfo->rf, chInfo->networkName, chInfo->stationId, chInfo->tsid, 
1793                                chInfo->tapeHour, chInfo->tapeMinute, numPrograms);
1794                               
1795                               
1796        if (bPrintProgramInfo && chInfo->programs)
1797        {
1798                numPrograms = 0;
1799                program = chInfo->programs;
1800                while (program)
1801                {
1802                        TestPrintXdsProgram(numPrograms, program);
1803
1804                        numPrograms++;
1805                        program = program->pNext;
1806                }
1807                DMW_DBG_SimplePrint("\n");
1808        }
1809       
1810}
1811
1812//
1813//  ÇØ´ç rfÀÇ Ã¤³Î Á¤º¸¸¦ Ç¥½Ã.
1814//
1815//  rf °¡ 0ÀÌ¸é ¸ðµç ä³Î Á¤º¸ Ç¥½Ã.
1816
1817//  bPrintProgramAlso °¡ TRUE À̸é ä³Î ¾ÈÀÇ ÇÁ·Î±×·¥ Á¤º¸µµ °°ÀÌ Ç¥½Ã.
1818//
1819void TestPrintXdsChannelList(int rf, BOOL bPrintProgramAlso)
1820{
1821        XdsChannelInfo *chInfo;
1822        int nChannel = 0;
1823       
1824        LockXdsInfoMutex(TRUE);
1825       
1826        if (rf) 
1827        {
1828                chInfo = FindXdsChannelInfoByRf(rf);
1829                if (chInfo == NULL) {
1830                        dprint(0, "!! xds channel info rf %d not found\n", rf);
1831                        goto label_print_all;
1832                }
1833
1834                DMW_DBG_SimplePrint("------ XdsChannel RF %d ------\n", rf);
1835               
1836                TestPrintXdsChannel(0, chInfo, bPrintProgramAlso);
1837
1838                LockXdsInfoMutex(FALSE);
1839                return;
1840        }
1841
1842label_print_all:
1843
1844        DMW_DBG_SimplePrint("------ XdsChannelList ------\n");
1845
1846        chInfo = g_XdsChannel;
1847
1848        while (chInfo)
1849        {
1850                TestPrintXdsChannel(nChannel, chInfo, bPrintProgramAlso);
1851               
1852                chInfo = chInfo->pNext;
1853                nChannel++;
1854        }
1855        DMW_DBG_SimplePrint("\n");
1856
1857        LockXdsInfoMutex(FALSE);
1858}
1859
1860
1861
1862//---------------------------------------------------------------------
1863
1864
1865
1866//
1867//  XDS ä³Î Á¤º¸ update ¿¹Á¦
1868//
1869//
1870void TestUpdateXdsChannel(int rf, char *call_letter, char *network_name)
1871{
1872        XdsChannelInfo chInfo;
1873        int err;
1874
1875        if (rf == 0) {
1876                dprint(0, "Usage: TestUpdateXdsChannel rf, \"call_letter\", \"name\"\n");
1877                return;
1878        }
1879       
1880        memset(&chInfo, 0, sizeof(XdsChannelInfo));
1881
1882        chInfo.rf = rf;
1883//compile warming Á¦°Å¸¦ À§ÇÑ Çüº¯È¯ : (char *)         probability
1884        strncpy((char *)chInfo.networkName, network_name, 32);
1885        strncpy((char *)chInfo.stationId, call_letter, 6);
1886       
1887        dprint(1, "UpdateXdsChannel: rf %d, call letter '%s', network name '%s'\n",
1888                        chInfo.rf, call_letter, network_name);
1889       
1890        err = DMW_XDS_UpdateXdsChannelInfo(&chInfo, XVM_NETWORK_NAME | XVM_CALL_LETTER);
1891
1892        if (err)
1893                dprint(0, "!! err update xds channel info\n");
1894        else
1895                dprint(2, "   update channel ok\n");
1896       
1897}
1898
1899
1900
1901//
1902//  XDS ÇÁ·Î±×·¥ Á¤º¸ update ¿¹Á¦
1903//
1904//
1905void TestUpdateXdsProgram(int rf, UINT32 start_gps_time, int length_in_minute, char *title, BOOL bCCExist)
1906{
1907        XdsProgramInfo progInfo;
1908        char buf[50];
1909        int err;
1910
1911        if (rf == 0) {
1912                dprint(0, "Usage: TestUpdateXdsProgram rf, gps_time, length_in_min, \"title\"\n");
1913                return;
1914        }
1915       
1916        memset(&progInfo, 0, sizeof(XdsProgramInfo));
1917
1918        progInfo.rf = rf;
1919        progInfo.startTime = start_gps_time;
1920
1921        progInfo.minLength = length_in_minute % 60;
1922        progInfo.hourLength = length_in_minute / 60;
1923
1924//compile warming Á¦°Å¸¦ À§ÇÑ Çüº¯È¯ : (char *)         probability
1925        strncpy((char *)progInfo.programName, title, 32);
1926       
1927        if (bCCExist) 
1928        {
1929                progInfo.captionInfo = OS_Calloc(1, sizeof(XdsCaptionInfo));
1930               
1931                if (progInfo.captionInfo == NULL)
1932                        dprint(0, "!! out of memory for caption info\n");
1933                else
1934                        progInfo.captionInfo->iCapService = 1;
1935                        // ´Ù¸¥ CC °ü·Ã Á¤º¸´Â ÇöÀç not-available Çϸç, ´ÜÁö CC°¡ Á¸ÀçÇÑ´Ù ¾ÈÇÑ´Ù¸¸ ¾Ë¼ö ÀÖ´Ù.
1936                        // µû¶ó¼­ Caption service °¹¼ö¸¸ 1·Î µî·Ï½ÃÄÑ ³õ°í ³ª¸ÓÁö µ¥ÀÌÅÍ´Â ±×³É empty..
1937                        // application¿¡¼­´Â ÀÌ·± Á¡À» ¿°µÎÇØ µÎ°í µ¥ÀÌÅ͸¦ ÀÌ¿ëÇØ¾ß ÇÒ °ÍÀÓ.
1938        }
1939       
1940        dprint(1, "UpdateXdsProgram: rf %d, time %s, len %d:%d, '%s'\n",
1941                        progInfo.rf, 
1942                        GpsTimeString(progInfo.startTime, buf),
1943                        progInfo.hourLength, progInfo.minLength,
1944                        progInfo.programName);
1945
1946        err = DMW_XDS_UpdateXdsProgramInfo(&progInfo, XVM_PROGRAM_ID | XVM_PROGRAM_LENGTH | XVM_PROGRAM_NAME);
1947
1948        if (err)
1949                dprint(0, "!! err update xds program info\n");
1950        else
1951                dprint(2, "   update program ok\n");
1952       
1953}
1954
1955
1956
1957
1958
1959
1960#if COMMENT
1961______Script______(){}
1962#endif
1963
1964#if 0
1965
1966        test script..
1967
1968        ## ÀÓÀÇ·Î Á¤º¸¸¦ ¸¸µé¾î ³Ö´Â´Ù. UCM¿¡ RF 24, 25°¡ ÀÖÀ¸¸é UpdateCSD¿¡¼­ ¿¡·¯°¡ ³ªÁö ¾Ê´Â´Ù.
1969        ## CSD update ½Ã¿¡´Â ¿¡·¯°¡ ³ªµµ »ó°ü ¾ø´Ù.
1970
1971        TestUpdateXdsChannel 24, "WBCD", "MBC Analog"
1972       
1973        TestUpdateXdsProgram 24, 780000000, 60, "Man in black"
1974        TestUpdateXdsProgram 24, 780001000, 5, "CF"
1975        TestUpdateXdsProgram 24, 780002000, 25, "News 9", 1
1976        TestUpdateXdsProgram 24, 780003000, 60, "MBC Drama"
1977        TestUpdateXdsProgram 24, 780004000, 120, "MBC Movie"
1978
1979        TestUpdateXdsChannel 25, "WXSA", "HOME CGV"
1980       
1981        TestUpdateXdsProgram 25, 780001000, 60, "Send & Chihiro", 1
1982        TestUpdateXdsProgram 25, 780002000, 5,  "Ad"
1983        TestUpdateXdsProgram 25, 780003000, 25, "Movie World"
1984
1985
1986        ## update µÈ Á¤º¸¸¦ Ãâ·ÂÇØº¸ÀÚ.
1987
1988        TestPrintXdsChannelList
1989
1990        TestPrintXdsChannelList 24, 1
1991        TestPrintXdsChannelList 25, 1
1992
1993
1994        ## Query, Free µîÀÇ API Å×½ºÆ®. ¸Þ¸ð¸® ´©¼ö°¡ ÀÖ´ÂÁöµµ °°ÀÌ Å×½ºÆ®..
1995
1996        memShow
1997
1998        chInfo = 0
1999        DMW_XDS_GetChannelInfo 24, &chInfo
2000        TestPrintXdsChannel 0, chInfo
2001
2002        DMW_XDS_FreeChannelInfo chInfo
2003
2004
2005        memShow
2006
2007        progInfo = 0
2008        nProg = 0
2009        DMW_XDS_GetProgramInfo 24, 780000000, 10000, &progInfo, &nProg
2010       
2011        TestPrintXdsProgramArray progInfo, nProg
2012       
2013        DMW_XDS_FreeProgramInfoArray progInfo, nProg
2014
2015        memShow
2016       
2017 
2018
2019#endif
2020
2021
2022/*******************************************************************
2023  Update:
2024
2025        1.00  2004/12/20  first design
2026
2027*******************************************************************/
2028
2029
2030
Note: See TracBrowser for help on using the repository browser.