source: svn/newcon3bcm2_21bu/dst/app/src/kview/Proc/App_Proc_Epg.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: 38.9 KB
Line 
1#include "App_Main.h"
2#include "App_Proc.h"
3
4#include "DLIB_PSI_Utils.h"
5
6#include "App_Fnc_Common.h"
7#include "App_Fnc_Ucm.h"
8#include "App_Fnc_Time.h"
9
10#include "App_Fnc_Time.h"
11#include "App_Fnc_EPG.h"
12#include "App_Fnc_ChTune.h"
13
14#include "App_OSD_Common.h"
15#include "App_OSD_Epg.h"
16#include "App_OSD_Banner.h"
17
18#include "App_Res_Resources.h"
19
20
21#if 0
22#define MAX_TIME_LEN 32
23#define MAX_EIT_LEN 32
24#define MAX_ETT_LEN 256
25
26#define MAX_NUM_EPG 60
27
28#define EPG_SHOW_TIME_H (14*24)
29        //½Ã°£ ´ÜÀ§, 14ÀÏ
30
31typedef struct {
32        BOOL beit_exist;
33        BOOL bett_exist;
34        UINT16 time_str[MAX_TIME_LEN];
35        UINT16 eit_str[MAX_EIT_LEN];
36        UINT16 ett_str[MAX_ETT_LEN];
37} tPriv_EpgInfo;
38
39
40static tPriv_EpgInfo p_epg_list[MAX_NUM_EPG];
41static int p_num_epg_event;
42
43#define PEPG(i) (p_epg_list[i])
44
45
46
47static UINT32 p_cut_second(UINT32 time_gps)
48{
49        APP_TIME_T time;
50        UINT32 temp;
51
52        AppTime_GetTimeFromGPS(time_gps, &time);
53        temp = time_gps - time.second;
54               
55        return temp;
56}
57
58
59
60void App_Proc_GetEpgInfo(int uid, tPriv_EpgInfo *pepg_list, int *pnum_epg)
61{
62        APP_TIME_T cur_time;
63        STATUS status;
64        UINT32 evt_time, duration;
65        UINT32 flag = GET_EVENT_TITLE | MAX_NUM_EPG;
66       
67        DMW_EpgEventPtr pevent;
68        int num_event;
69       
70        APP_TIME_T stime, etime;
71       
72        int i;
73        char temp1[32], temp2[32];
74       
75        status=AppTime_GetCurTime(&cur_time, 1);
76       
77        if(status) {
78                //ÇöÀç ½Ã°£À» ¾ò¾î¿À´Âµ¥ error°¡ ¹ß»ýÇ߱⠶§¹®¿¡ epg Á¤º¸¸¦ ¾ò¾î¿Ã Çʿ䰡 ¾øÀ½
79               
80                return;
81        }
82       
83        if(DMW_EPG_GetEventInTime(uid, cur_time.sys_time, &pevent,
84                GET_EVENT_TITLE | 0x000001)==statusOK)
85        {
86                if(pevent) {
87                        evt_time = pevent->startTime;
88                        DMW_EPG_FreeEpgEvents(pevent,1);
89                }
90        }
91        else
92                evt_time=p_cut_second(cur_time.sys_time-(cur_time.minute-30)*60);
93       
94        duration=EPG_SHOW_TIME_H*3600-60;
95       
96        if(DMW_EPG_GetEventsInRange(uid, evt_time+59, duration, &pevent, &num_event, flag)
97                ==statusOK)
98        {
99                for(i=0; i<num_event; i++) {
100                       
101                        int len;
102                       
103                        if(pevent[i].titleTextLength<=8) { //ÃÖ¼Ò 8º¸´Ù´Â Ä¿¾ß stringÀ¸·Î ÀνÄ
104                                pepg_list[i].eit_str[0]='\0';
105                                pepg_list[i].beit_exist=FALSE;
106                                continue;
107                        }
108                       
109                        //eit str
110                        len=DLIB_PSI_DecodeMultipleStringStructure(pevent[i].titleTextLength,
111                                pevent[i].titleText, "eng", MAX_EIT_LEN-1, pepg_list[i].eit_str);
112                       
113                        if(len==0) {
114                                pepg_list[i].beit_exist=FALSE;
115                                continue;
116                        }
117                       
118                        pepg_list[i].eit_str[MAX_EIT_LEN-1]='\0';
119                       
120                        pepg_list[i].beit_exist=TRUE;
121                       
122                        //time
123                        AppTime_GetTimeFromGPS(pevent[i].startTime, &stime);
124                        AppTime_GetTimeFromGPS(pevent[i].startTime+pevent[i].programLength, &etime);
125                       
126                        App_MakeDateTimeString(temp1, stime, 2);
127                        App_MakeDateTimeString(temp2, stime, 5);
128                       
129                        strcat(temp1, "~");
130                        strcat(temp1, temp2);
131                       
132                        memcpy(pepg_list[i].time_str, temp1, strlen(temp1));
133                                //ÁÖÀÇ 1byte¿¡¼­ 2byte ±ÛÀÚ·Î memcpyÇØµµ ¹®Á¦°¡ µÇÁö ¾ÊÀ»±î?
134                                //È®ÀÎÀÌ ÇÊ¿äÇÔ.
135                       
136                        //ettµµ ¿©±â¼­ ¾ò¾î¿È.
137                        if(pevent[i].eventETMLength<=8) { //ÃÖ¼Ò 8º¸´Ù´Â Ä¿¾ß stringÀ¸·Î ÀνÄ
138                                pepg_list[i].ett_str[0]='\0';
139                                pepg_list[i].bett_exist=FALSE;
140                                continue;
141                        }
142                       
143                        len=DLIB_PSI_DecodeMultipleStringStructure(pevent[i].eventETMLength,
144                                pevent[i].eventETM, "eng", MAX_ETT_LEN-1, pepg_list[i].ett_str);
145                       
146                        if(len==0) {
147                                pepg_list[i].bett_exist=FALSE;
148                                continue;
149                        }
150                       
151                        pepg_list[i].ett_str[MAX_EIT_LEN-1]='\0';
152                       
153                        pepg_list[i].bett_exist=TRUE;
154                }
155        }
156        else {
157                num_event=0;
158        }
159       
160        *pnum_epg=num_event;
161}
162#endif
163
164/*_____ D E F I N I T I O N ____________________________________*/
165
166#if COMMENT
167____DbgPrint____(){}
168#endif
169
170DHL_MODULE("@p_epg", 0);
171
172
173
174
175
176#if COMMENT
177____Config____(){}
178#endif
179
180/* ?? */
181#define ONLY_DIGITAL    0
182
183
184/* EPG excutive style */
185#define HD5150_REF      0     // 0 : Trinity ¹æ½ÄÀ¸·Î µ¿ÀÛ.
186                              // 1 : HD5150 EPG ¹æ½ÄÀ¸·Î µ¿ÀÛ.
187
188#if HD5150_REF
189#define BLOCK_TUNE      0     // up/down À̵¿½Ã EPG ä³Î Æ©´× ¾ÈÇÔ.
190#define SELECT_TUNE     1     // Select Ű ´­·¶À» ¶§ ä³Î Æ©´×, Prev_ch Ű À϶§ detail banner
191#else
192#define BLOCK_TUNE      0     // up/down À̵¿½Ã EPG ä³Î Æ©´×
193#define SELECT_TUNE     1     // Select Ű ´­·¶À» ¶§ ä³Î Æ©´× ¾ÈÇÔ
194#endif
195
196/* EPG event information */
197#define LINE_NUM        6     // App_OSD_DrawEpgEventInfo line limit
198
199/* Save pre event row & column & page */
200#define SAVE_PRE_EVENT  1     // 0 : Epg Detail banner ´Ù³à¿À¸é ¼±ÅÃÇß´ø À̺¥Æ®·Î º¹±Í
201                              // 1 : Epg Detail banner ´Ù³à¿À¸é ÇöÀç¹æ¼Û À̺¥Æ®·Î º¹±Í
202
203
204
205
206
207#if COMMENT
208____Types____(){}
209#endif
210
211
212
213
214
215#if COMMENT
216____Variables____(){}
217#endif
218
219APP_TIME_T nCurTime, nTempPreTime, nTempPostTime;
220
221#if 0
222DST_CURCHANNEL Temp_Channel;
223#endif
224
225UINT8 NumEvent[6];
226UINT8 pNumEvent[6];
227UINT8 CurRow;                      // ÇöÀç event line (°¡·Î)
228UINT8 SaveRow;                     // EPG detail¿¡¼­ CurRow »ç¿ëÇϱâ À§ÇÑ Àӽú¯¼ö
229SINT8 CurColumn;                   // ÇÑ event line¿¡¼­ ¸î ¹øÂ° eventÀÎÁö ÀúÀåÇÏ´Â º¯¼ö(¼¼·Î)
230UINT8 SaveColumn;                  // EPG detail¿¡¼­ CurColumn »ç¿ëÇϱâ À§ÇÑ Àӽú¯¼ö
231char cursorIdx;
232UINT32 nPageStartTime;             // EPG ÇöÀç ÆäÀÌÁöÀÇ ½ÃÀÛ ½Ã°£
233UINT16 nCurChIdx, nStartChIdx;     // ÇöÀç ä³Î line, ½ÃÀÛÇϴ ä³Î line
234UINT16 nNumChannel;
235UINT16 nCurLineIdx, nStartLineIdx; // EPG detail bannerÀÇ ETM Á¤º¸ Ç¥±â½Ã »ç¿ë
236int g_UIDOnEPGUpdate;
237
238BOOLEAN g_bEnableDTV = TRUE;
239BOOLEAN bReturn = FALSE;           // EPG_EXIT Flag : EPG ³¡³µÀ» °æ¿ì ÃëÇÏ´Â µ¿ÀÛ¿©ºÎ ¾Ë¸²
240BOOLEAN bEpgStart = TRUE;          // EPG start Flag : CurColumnÀÇ ±â¾ï¿©ºÎ Á¤ÇÔ.
241BOOLEAN bNotiBannerOn = FALSE;     // EPG notification Flag : autoscanµÇ¾î ÀÖÁö ¾ÊÀ» ¶§ ¶ç¿ì´Â ¹è³Ê ¿©ºÎ
242
243strEPG_Data **PageEvent = NULL;    // ±×·ÁÁú eventµéÀÇ ¹è¿­
244ChListInfo  *EPGChList  = NULL;    // EPG channel Á¤º¸ & ¸®½ºÆ®
245
246
247/* from App_Fnc_EPG.c */
248extern BOOLEAN g_EPG_ScreenUpdate;
249extern BOOLEAN g_bEPGGet_OneEIT;
250
251
252/*_____ F U N C T I O N ________________________________________*/
253
254#if COMMENT
255__EPG_Parsing__() {}
256#endif
257
258/******************************************************************************************
259FUNCTION:
260  - App_EpgParsing
261
262Purpose:
263  - epg data parsing function
264******************************************************************************************/
265int App_LoadUid(int idx)
266{
267        return EPGChList[idx].ListUID;
268}
269
270void App_EpgParsing()
271{
272        UINT16 nList; //, num_ch;                   // num_ch : nNumChannel - nStartChIdx;
273        int i, j, l, idx;
274       
275        BOOLEAN bTuneByDRF = FALSE;                             // draw¸¸
276        BOOLEAN TempVCT_Flag = FALSE;
277       
278        STATUS status   = statusError;
279       
280       
281        // Variable Initialize
282        nList = 0;
283        CurRow = 0;
284        CurColumn = 0;
285        nNumChannel = 0;
286#if SAVE_PRE_EVENT
287        /* nCurChIdx no initialize */
288#else
289        nCurChIdx = 0;
290#endif
291       
292       
293        //////////////////
294        // Parsing DATA //
295        //////////////////
296       
297        if(g_UIDOnEPGUpdate > 0)
298                App_EpgUpdateCancel();
299       
300        PageEvent = (strEPG_Data**)DHL_OS_Malloc(sizeof(strEPG_Data*)*6);
301        if(PageEvent == NULL)
302        {
303                dprint(0, "[ERROR] DST_Draw_EPG : PageEvent buffer malloc error !!!\n");
304                DMG_MenuExit(MID_EPG);
305        }
306        for(i=0; i<6; i++)
307        {
308                PageEvent[i] = (strEPG_Data*)DHL_OS_Malloc(sizeof(strEPG_Data)*50);     
309                if(PageEvent[i] == NULL)
310                {
311                        dprint(0, "[ERROR] DST_Draw_EPG : Sub PageEvent buffer malloc error !!!\n");
312                        DMG_MenuExit(MID_EPG);
313                }
314                NumEvent[i]  = 0;
315                pNumEvent[i] = 0;
316        }
317
318        for(i=0; i<6; i++)
319        {
320                for(j=0; j<50; j++)
321                        PageEvent[i][j].StatusFlag = Program_EMPTY;
322        }
323       
324       
325        DMW_MSC_LockUcm(); ////////////////////////////
326       
327        if(APP_CUR_CH.nUid <= 0)
328                bTuneByDRF = TRUE;
329        else
330        {
331                idx = DMW_MSC_Uid2Index(APP_CUR_CH.nUid);
332                if(idx >= 0)
333                {
334                        if(g_UCM[idx].Skipped)
335                        {
336                                bTuneByDRF = TRUE;
337                                TempVCT_Flag = g_UCM[idx].VctFlag;                             
338                        }
339                }
340        }
341       
342       
343        /* ÇÊ¿äÇÑ ¸¸Å­¸¸ ¸Þ¸ð¸®¸¦ ÇÒ´çÇϱâ À§ÇÑ ÀÛ¾÷ */
344        for(i=0; i<g_UCM_number; i++)
345        {
346                if(!g_UCM[i].Skipped && !g_UCM[i].hidden && !g_UCM[i].disabled)
347                        nNumChannel++;
348        }
349       
350        if(bTuneByDRF)       // Current Channel is tuned by DRF
351                nNumChannel++;
352       
353       
354        /* °Ë»öµÈ ä³ÎÀÌ ¾øÀ¸¸é epg¸¦ ³ª°¡°í ä³ÎÀÌ ¾ø´Ù´Â osd¸¦ ¶ç¿î´Ù. */
355        if(nNumChannel == 0)
356        {
357                if(PageEvent)
358                {
359                        for(i=0; i<6; i++)
360                        {
361                                if(PageEvent[i])
362                                {
363                                        DHL_OS_Free((void **)&PageEvent[i]);
364                                }
365                        }
366                        DHL_OS_Free((void **)&PageEvent);
367                }
368                DMW_MSC_UnlockUcm(); ////////////////////////////
369                bNotiBannerOn = TRUE;
370               
371                App_OSD_DrawEpgNotiBanner();
372                return;
373        }
374       
375        /* ½ÅÈ£°¡ ¾øÀ» ¶§¿¡´Â À­ ¶óÀο¡¼­ bNotiBannerOn = TRUE°¡ µÇ°í, return µÇ¾î ³¡³­´Ù.
376           ½ÅÈ£°¡ °©Àڱ⠻ý°åÀ» ¶§(RF¸¦ »¯´Ù°¡ ²Å¾ÒÀ» ¶§ µî) ¿ø·¡ ÃʱⰪÀÎ FALSE °ªÀ» ³Ö¾îÁÖ¾î¾ß ÇÑ´Ù. */
377        bNotiBannerOn = FALSE;
378       
379        EPGChList = DHL_OS_Malloc(sizeof(ChListInfo)*nNumChannel);
380        memset(EPGChList, 0, sizeof(ChListInfo)*nNumChannel);
381       
382        if(EPGChList == NULL)
383        {
384                dprint(0, "[ERROR] DST_Draw_EPG : Channel buffer calloc error !!!\n");
385                DMW_MSC_UnlockUcm();
386                DMG_MenuExit(MID_EPG);
387                return;
388        }
389       
390        DMW_MSC_UnlockUcm();
391       
392       
393        if(App_GetChSortMode()==APP_CH_SORT_GROUP) {
394               
395                //hd, sd, audio only..
396                int uid=-1, mode=0;
397                tApp_ChSelParam ch_sel_param={TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE};
398               
399                for(mode=0; mode<3; mode++)
400                {
401                        tApp_UcmShortInfo ucm_info;
402                       
403                        switch(mode) {
404                                case 0:
405                                        ch_sel_param.exc_hd=FALSE;
406                                        ch_sel_param.exc_sd=TRUE;
407                                        ch_sel_param.exc_audio=TRUE;
408                                        break;
409                                       
410                                case 1:
411                                        ch_sel_param.exc_hd=TRUE;
412                                        ch_sel_param.exc_sd=FALSE;
413                                        ch_sel_param.exc_audio=TRUE;
414                                        break;
415                                       
416                                case 2:
417                                        ch_sel_param.exc_hd=TRUE;
418                                        ch_sel_param.exc_sd=TRUE;
419                                        ch_sel_param.exc_audio=FALSE;
420                                        break;
421                        }
422                       
423                        while(1) {
424                                int idx;
425                               
426                                uid=App_Ucm_GetNextChannel(uid, &ch_sel_param);
427                               
428                                if(uid<=0) break;
429                               
430                                DMW_MSC_LockUcm();
431                               
432                                idx=DMW_MSC_Uid2Index(uid);
433                               
434                                DMW_MSC_UnlockUcm();
435                               
436                                App_Ucm_GetShortInfobyIndex(idx, &ucm_info);
437                               
438                                //hiddenÀº À§ÀÇ Á¶°Ç¿¡¼­ ºüÁ³À¸³ª disabled°¡ ³²¾ÆÀÖÀ½..
439                                if(App_Ucm_CheckDisabledCh(idx)) continue;
440                               
441                                EPGChList[nList].ListUID=uid;
442                               
443                                if(EPGChList[nList].ListUID==APP_CUR_CH.nUid)
444                                {
445#if SAVE_PRE_EVENT
446                                        if(bEpgStart == FALSE) // Detail banner¿¡¼­ µ¹¾Æ¿À´Â °æ¿ì
447                                        {
448                                                /* nCurChIdx no initialize */
449                                        }
450                                        else
451                                        {
452                                                nCurChIdx = nList;
453                                        }
454#else
455                                        nCurChIdx = nList;
456#endif
457                                }
458                                else
459                                {
460#if ONLY_DIGITAL                                       
461                                        nCurChIdx = 0;
462#endif
463                                        dprint(0, "[ERROR] channel should not be found in EPGChList\n");       
464                                }
465                                EPGChList[nList].ListMajor = ucm_info.major;
466                                EPGChList[nList].ListMinor = ucm_info.minor;
467                                EPGChList[nList].ListSourceId = ucm_info.source_id;
468                                EPGChList[nList].ListRF    = ucm_info.rf;
469                                EPGChList[nList].VctFlag   = ucm_info.vct_flag;                 
470                                nList++;
471                        }
472                       
473                }
474        }
475        else if (App_GetChSortMode() == APP_CH_SORT_NUMBER)
476        {
477                int idx;
478                int uid = 0;
479                tApp_UcmShortInfo ucm_info;
480               
481                DMW_MSC_LockUcm();
482                for(i = 0; i < g_UCM_number; i++)
483                {
484                        uid=App_Ucm_GetNextChannelNumber(i, FALSE, FALSE);
485                        if(uid<=0) break;
486                        idx=DMW_MSC_Uid2Index(uid);
487                        App_Ucm_GetShortInfobyIndex(idx, &ucm_info);
488                        if(App_Ucm_CheckDisabledCh(idx)) continue;
489                        EPGChList[nList].ListUID=uid;
490                        if(EPGChList[nList].ListUID==APP_CUR_CH.nUid)
491                        {
492#if SAVE_PRE_EVENT
493                                if(bEpgStart == FALSE) // Detail banner¿¡¼­ µ¹¾Æ¿À´Â °æ¿ì
494                                {
495                                        /* nCurChIdx no initialize */
496                                }
497                                else
498                                {
499                                        nCurChIdx = nList;
500                                }
501#else
502                                nCurChIdx = nList;
503#endif
504                        }
505                        else
506                        {
507#if ONLY_DIGITAL                                       
508                                nCurChIdx = 0;
509#endif
510                                dprint(0, "[ERROR] channel should not be found in EPGChList\n");       
511                        }
512               
513                        EPGChList[nList].ListMajor = ucm_info.major;
514                        EPGChList[nList].ListMinor = ucm_info.minor;
515                        EPGChList[nList].ListSourceId = ucm_info.source_id;
516                        EPGChList[nList].ListRF    = ucm_info.rf;
517                        EPGChList[nList].VctFlag   = ucm_info.vct_flag;                 
518                        nList++;
519                }
520               
521                DMW_MSC_UnlockUcm();
522        }
523        else {
524       
525                DMW_MSC_LockUcm();
526       
527        /* EPGChList¿¡ ÇÊ¿äÇÑ Á¤º¸¸¦ ä¿î´Ù. */
528        for(i=0; i<g_UCM_number; i++)
529        {
530                if(!g_UCM[i].Skipped && !g_UCM[i].hidden && !g_UCM[i].disabled)
531                {
532#if ONLY_DIGITAL                       
533                        if( g_UCM[i].Minor<1024 )
534                        {
535#endif
536                                if(nList > (nNumChannel-1))
537                                {
538                                        dprint(0, "[ERROR] DST_Draw_EPG : Iinvalid Channel list number!\n");
539                                        break;
540                                }
541                                EPGChList[nList].ListUID = DMW_MSC_Index2Uid(i);
542                               
543                                if(EPGChList[nList].ListUID==APP_CUR_CH.nUid)
544                                {
545#if SAVE_PRE_EVENT
546                                        if(bEpgStart == FALSE) // Detail banner¿¡¼­ µ¹¾Æ¿À´Â °æ¿ì
547                                        {
548                                                /* nCurChIdx no initialize */
549                                        }
550                                        else
551                                        {
552                                                nCurChIdx = nList;
553                                        }
554#else
555                                        nCurChIdx = nList;
556#endif
557                                }
558                                else
559                                {
560#if ONLY_DIGITAL                                       
561                                        nCurChIdx = 0;
562#endif
563                                        dprint(0, "[ERROR] channel should not be found in EPGChList\n");       
564                                }
565                                EPGChList[nList].ListMajor = g_UCM[i].Major;
566                                EPGChList[nList].ListMinor = g_UCM[i].Minor;
567                                EPGChList[nList].ListSourceId = g_UCM[i].source_id;
568                                EPGChList[nList].ListRF    = g_UCM[i].RF;
569                                EPGChList[nList].VctFlag   = g_UCM[i].VctFlag;                 
570                                nList++;
571#if ONLY_DIGITAL
572                        }
573#endif
574                       
575                }
576        }
577        DMW_MSC_UnlockUcm(); ////////////////////////////
578        }
579       
580       
581        if(bTuneByDRF)
582        {
583                EPGChList[nNumChannel-1].ListUID                = APP_CUR_CH.nUid;
584                EPGChList[nNumChannel-1].ListMajor      = APP_CUR_CH.nMajor;
585                EPGChList[nNumChannel-1].ListMinor      = APP_CUR_CH.nMinor;
586                EPGChList[nNumChannel-1].ListSourceId = APP_CUR_CH.nSourceId;
587                EPGChList[nNumChannel-1].ListRF                 = APP_CUR_CH.nRF;
588                EPGChList[nNumChannel-1].VctFlag                = TempVCT_Flag;
589               
590                p_epg_sort_list(EPGChList, nNumChannel);
591                nCurChIdx = p_find_curIndex(EPGChList, nNumChannel, APP_CUR_CH.nMajor);
592        }
593       
594        /* ù¹øÂ° ÆäÀÌÁö°¡ ¾Æ´Ò °æ¿ì ÇöÀç ä³ÎÀÌ µÇµµ·Ï °¡¿îµ¥ À§Ä¡ÇÏ°Ô ÇÑ´Ù. */
595        if(nCurChIdx > 5)
596        {
597                if(nCurChIdx+2 > nNumChannel-1)
598                        nStartChIdx = nNumChannel-1-4;
599                else
600                        nStartChIdx = nCurChIdx - 2;
601        }
602        else
603                nStartChIdx = 0;
604       
605        // Get Current Time for Setting
606        status = AppTime_GetCurTime(&nCurTime, 1);
607       
608        if(status != 0) //Get Time Error
609        {
610                dprint(0, "Get Time Error!!!!!\n");
611        }
612
613#if 0   
614        if(g_bEnableDTV)
615        {
616                memset(&Temp_Channel, 0, sizeof(Temp_Channel));         
617                Temp_Channel.nChannelType   = APP_CUR_CH.nChannelType;   
618                Temp_Channel.nCableType     = APP_CUR_CH.nCableType;   
619                Temp_Channel.nRF            = APP_CUR_CH.nRF;   
620                Temp_Channel.nServiceType   = APP_CUR_CH.nServiceType;         
621                Temp_Channel.nMajor         = APP_CUR_CH.nMajor;               
622                Temp_Channel.nMinor         = APP_CUR_CH.nMinor;               
623                Temp_Channel.nProgramNumber = APP_CUR_CH.nProgramNumber;
624                Temp_Channel.nSourceId      = APP_CUR_CH.nSourceId;
625                Temp_Channel.uPcrPid        = APP_CUR_CH.uPcrPid;
626                Temp_Channel.uVidPid        = APP_CUR_CH.uVidPid;
627                Temp_Channel.uAudPid        = APP_CUR_CH.uAudPid;
628                Temp_Channel.nUid           = APP_CUR_CH.nUid;
629                memcpy(Temp_Channel.ShortName, APP_CUR_CH.ShortName, sizeof(APP_CUR_CH.ShortName));     
630        }
631#endif
632       
633#if SAVE_PRE_EVENT
634        if(bEpgStart == FALSE) // Detail banner¿¡¼­ µ¹¾Æ¿À´Â °æ¿ì
635        {
636                /* nPageStartTime no initialize */
637        }
638        else
639        {
640                if(AppTime_GetCurTime(&nCurTime, 1) == 0)
641                {
642                        if(nCurTime.minute>=30)
643                                nPageStartTime = p_cut_second(nCurTime.sys_time - (nCurTime.minute-30)*60);
644                        else
645                                nPageStartTime = p_cut_second(nCurTime.sys_time - nCurTime.minute*60);
646                }
647                else
648                {
649                        DMG_MenuExit(MID_EPG);
650                }
651        }
652       
653#else
654
655        if(AppTime_GetCurTime(&nCurTime, 1) == 0)
656        {
657                if(nCurTime.minute>=30)
658                        nPageStartTime = p_cut_second(nCurTime.sys_time - (nCurTime.minute-30)*60);
659                else
660                        nPageStartTime = p_cut_second(nCurTime.sys_time - nCurTime.minute*60);
661        }
662        else
663        {
664                DMG_MenuExit(MID_EPG);
665        }
666#endif // #if SAVE_PRE_EVENT
667       
668       
669        //////////////////
670        // Draw EPG OSD //
671        //////////////////
672       
673        // Draw Epg background
674        App_OSD_DrawEpgBase();
675       
676        // Draw Epg current time & time ruler
677        App_OSD_DrawEpgCurrentTime(nCurTime, FALSE);
678       
679        // Make Event Schedule
680        App_OSD_MakeEpgContents(nCurTime, nPageStartTime, EPGChList, nStartChIdx, PageEvent, NumEvent, pNumEvent);
681       
682#if SAVE_PRE_EVENT
683        if(bEpgStart == FALSE)   // Detail banner¿¡¼­ µ¹¾Æ¿À´Â °æ¿ì
684        {
685                if(nCurChIdx < 5)      // ä³ÎÀÌ 6°³°¡ ³ÑÁö ¾Ê¾Æ ÇÑ ÆäÀÌÁö ¾È¿¡ ÀÖÀ» ¶§¿¡´Â ÀúÀåµÈ ¿­À» º¸¿©ÁÖ°í
686                        CurRow = SaveRow;
687                else                   // ÇÑ ÆäÀÌÁö ÀÌ»óÀÏ ¶§¿¡´Â °¡¿îµ¥ ¿­À» º¸¿©ÁÖµµ·Ï ÇÑ´Ù.
688                        CurRow = nCurChIdx-nStartChIdx;
689                       
690                CurColumn = SaveColumn;// ¿­°ú »ó°ü¾øÀÌ ÇàÀº ±×´ë·Î ±â¾ïÇÑ´Ù.
691                dprint(3, "[%d] SaveRow:%d, CurRow:%d\n", __LINE__, SaveRow, CurRow);
692        }
693        else                   // EPG óÀ½ ½ÃÀÛÇÏ´Â °æ¿ì
694        {
695                CurRow = nCurChIdx-nStartChIdx;
696//              CurColumn = p_catch_event_position(PageEvent, CurRow, NumEvent[CurRow], k);
697                dprint(3, "[%d] SaveRow:%d, CurRow:%d\n", __LINE__, SaveRow, CurRow);
698        }
699#else
700       
701        CurRow = nCurChIdx-nStartChIdx;
702        CurColumn = p_catch_event_position(PageEvent, CurRow, NumEvent[CurRow], k);
703       
704#endif // #if SAVE_PRE_EVENT
705       
706        /* Draw Epg event information */
707        App_OSD_CommonBox2(84, 140+(34*cursorIdx), 255, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
708        App_OSD_CommonBox2(344, 140+(34*cursorIdx), 267, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
709        for (l = 0; l < 7; l++)
710        {
711                if((PageEvent[CurRow][CurColumn+l].StatusFlag & Program_EMPTY) == Program_EMPTY)
712                {
713                        App_OSD_DrawEpgEventInfo(0, l, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
714                }
715                else
716                {
717                        App_OSD_DrawEpgEventInfo(0, l, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], PageEvent[CurRow][CurColumn+l].EPG_event, FALSE);
718                }
719        }
720
721        /* Draw Epg channel number */
722        App_OSD_DrawEpgChNum(EPGChList, nCurChIdx, FALSE);
723}
724
725
726void App_EpgFree()
727{
728        int i, j;
729       
730        dprint(2, "////////// [EPG_EXIT] EPG Free Start !! ///////////\n");
731       
732        for(i=0; i<6; i++)
733        {
734                j = 0;
735               
736                // Erase previous EVENT.
737                while(TRUE)
738                { // ¼öÁ¤ÇÒ »çÇ×. epg update µµÁß ¹«Á¶°Ç ¸Þ¸ð¸®¸¦ free ½ÃŰ¸é µµÁß¿¡ ÇÒ´çµÈ ¸Þ¸ð¸®°¡
739                        // InvalidµÇ¾î ¾÷µ¥ÀÌÆ® µµÁß »ç¶óÁø´Ù. ¸ÕÀú ¾÷µ¥ÀÌÆ® Ãë¼ÒÇÑ ÈÄ free ½ÃÄÑÁØ´Ù.
740                        if(pNumEvent[i] > 0 && !(PageEvent[i][j].StatusFlag & Program_EMPTY))
741                        {
742                                DMW_EPG_FreeEpgEvents(PageEvent[i][j].EPG_event,pNumEvent[i]);
743                                break;
744                        }
745                        j++;
746                        if(j > NumEvent[i]-1)
747                                break;
748                }
749        }
750
751        if(PageEvent)
752        {
753                for(i=0; i<6; i++)
754                {
755                        if(PageEvent[i])
756                        {
757                                DHL_OS_Free((void **)&PageEvent[i]);
758                        }
759                }
760                DHL_OS_Free((void **)&PageEvent);
761        }
762        if(EPGChList)
763        {
764                DHL_OS_Free((void **)&EPGChList);
765        }
766        for(i=0; i<6; i++)
767        {
768                NumEvent[i]=0;
769                pNumEvent[i]=0;
770        }
771}
772
773void App_EpgInitVar()
774{
775        CurRow = 0;
776        CurColumn = 0;
777        cursorIdx = 0;
778        nPageStartTime = 0;
779        nCurChIdx = 0;
780        nStartChIdx = 0;
781        nNumChannel = 0;
782}
783
784BOOL App_EpgDoRedraw()
785{
786        #define EPG_EVENT_X     199
787        #define EPG_EVENT_Y     121
788               
789        if(((PageEvent[CurRow][CurColumn].StatusFlag & Program_EMPTY) == Program_EMPTY) &&
790                PageEvent[CurRow][CurColumn].nX == EPG_EVENT_X &&
791                PageEvent[CurRow][CurColumn].nW == EPG_EVENT_W+1) return TRUE;
792       
793        return FALSE;
794}
795
796
797
798#if COMMENT
799__EPG_User_Proc__() {}
800#endif
801
802BOOL App_Proc_Epg(tDMG_CMD cmd, UINT32 opt, UINT32 param1, UINT32 param2)
803{
804        BOOL bret = TRUE;
805        static BOOL is_epg_started=FALSE;
806                //EPG ۰¡ ¿¬¼ÓÀ¸·Î ´­¸± °æ¿ì, EXIT Äڵ尡 µÎ ¹ø ºÒ¸± ¼ö ÀÖÀ½
807#if SELECT_TUNE
808        tDMG_Menu *pmenu;
809#endif
810
811        int i, j, k, l;
812        int list_uid; // EPG exit ÈÄ, Ch Banner¿¡ uid¸¦ Àü´ÞÇϱâ À§ÇÑ º¯¼ö
813
814#if 0
815        UINT32 tm_start= DHL_OS_GetMsCount();
816#endif
817
818        dprint(1, "%s proc : cmd(%x), param1(%x), param2(%x)\n", __FUNCTION__, cmd, param1, param2);
819        switch(cmd)
820        {
821                case eDMG_CMD_ON_MENU_ACTIVE :
822                       
823                        is_epg_started=TRUE;
824                       
825                        if (bReturn)
826                        {
827                                App_EpgFree();
828                        }
829                        App_EpgParsing();
830                        DMG_SetTimer(TIMER_ID_EPG, TIMER_EPG_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
831                       
832                        if(bNotiBannerOn == FALSE) // refresh´Â ½ÅÈ£°¡ ÀÖÀ» ¶§¿¡¸¸ »ç¿ëÇÑ´Ù.
833                                DMG_SetTimer(TIMER_ID_EPG_REFRESH, 1000, eDMG_CMD_OPT_MENU_UPDATE);
834                       
835                        bReturn = FALSE;
836                        break;
837                       
838                case eDMG_CMD_ON_TIME :
839                        if(param1==TIMER_ID_EPG)
840                        {              /* kill */
841                                DMG_MenuExit(MID_EPG);
842                        }
843                        else if(param1==TIMER_ID_EPG_REFRESH)
844                        { /* update */
845                                /* 2Ãʸ¶´Ù ´ÙÀ½ÀÇ »çÇ×À» update */
846                                dprint(3, "EPG refresh test... \n\n");
847                                App_OSD_DrawEpgCurrentTime(nCurTime, TRUE);          // ÇöÀç ½Ã°£
848                        }
849                        else if(param1==TIMER_ID_L1)
850                        {
851                                p_erase_epgbase();
852                                App_EpgFree();
853                                App_EpgParsing(); //EPG ´Ù½Ã ±×¸®±â
854                        }
855                        else
856                                bret=FALSE;
857                        break;
858               
859                case eDMG_CMD_ON_TIMEOUT :
860                        DMG_MenuExit(MID_MAIN);
861                        DMG_MenuExit(MID_EPG);
862                        break;
863                       
864                case eDMG_CMD_ON_KEY :
865                        if(bNotiBannerOn == FALSE)
866                        {    // autoscanÀÌ µÇ¾î ÀÖÀ» ¶§ EPG µ¿ÀÛ.
867                                switch(param2)
868                                {
869        ///////////////////////////////////////// UP ////////////////
870                                        case APP_VK_UP :
871                                                if (cursorIdx == 0)
872                                                {
873                                                        if (CurColumn == 0)
874                                                        {
875                                                                if (pNumEvent[CurRow] < 7)
876                                                                {
877                                                                        cursorIdx = pNumEvent[CurRow] - 1;
878                                                                }
879                                                                else
880                                                                {
881                                                                CurColumn = pNumEvent[CurRow] - 7;
882                                                                cursorIdx = 6;
883                                                        }
884                                                        }
885                                                        else
886                                                        {
887                                                                CurColumn--;
888                                                                cursorIdx = 0;
889                                                        }
890                                                }
891                                                else if ((0 < cursorIdx) && (cursorIdx < 7))
892                                                {
893                                                        cursorIdx--;
894                                                }
895
896                                                p_erase_event_info();                                                  // erase event info
897                                                App_OSD_RestoreScreen(82, 138, 530, 376); // restore event info
898                                                App_OSD_RestoreScreen(612, 138, 25, 238); // restore scroll
899                                                App_OSD_RestoreScreen(103, 392, 220, 20); // restore bottom description
900                                                for (k = 0; k < 7; k++)
901                                                {
902                                                        if (cursorIdx == k)
903                                                        {
904                                                                App_OSD_CommonBox2(84, 140+(34*k), 255, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
905                                                                App_OSD_CommonBox2(344, 140+(34*k), 267, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
906                                                        }
907                                               
908                                                        if ((PageEvent[CurRow][CurColumn+k].StatusFlag & Program_EMPTY) == Program_EMPTY)
909                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
910                                                        else
911                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], PageEvent[CurRow][CurColumn+k].EPG_event, FALSE);
912                                                }
913                                               
914                                                DMG_SetTimer(TIMER_ID_EPG, TIMER_EPG_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
915                                                break;
916
917        ///////////////////////////////////////// DOWN ////////////////
918                                        case APP_VK_DOWN :
919                                                if (cursorIdx == 6)
920                                                {
921                                                        if (CurColumn == (pNumEvent[CurRow] - 7))
922                                                        {
923                                                                CurColumn = 0;
924                                                                cursorIdx = 0;
925                                                        }
926                                                        else
927                                                        {
928                                                                CurColumn++;
929                                                                cursorIdx = 6;
930                                                        }
931                                                }
932                                                else if ((0 <= cursorIdx) && (cursorIdx < 7))
933                                                {
934                                                        if (pNumEvent[CurRow] < 7)
935                                                        {
936                                                                if (cursorIdx == (pNumEvent[CurRow]-1))
937                                                                        cursorIdx = 0;
938                                                                else
939                                                                        cursorIdx++;
940                                                        }
941                                                        else
942                                                        cursorIdx++;
943                                                }
944
945                                                p_erase_event_info();                                                  // erase event info
946                                                App_OSD_RestoreScreen(82, 138, 530, 376); // restore event info
947                                                App_OSD_RestoreScreen(612, 138, 25, 238); // restore scroll
948                                                App_OSD_RestoreScreen(103, 392, 220, 20); // restore bottom description
949                                                for (k = 0; k < 7; k++)
950                                                {
951                                                        if (cursorIdx == k)
952                                                        {
953                                                                App_OSD_CommonBox2(84, 140+(34*k), 255, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
954                                                                App_OSD_CommonBox2(344, 140+(34*k), 267, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
955                                                        }
956
957                                                        if((PageEvent[CurRow][CurColumn+k].StatusFlag & Program_EMPTY) == Program_EMPTY)
958                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
959                                                        else
960                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], PageEvent[CurRow][CurColumn+k].EPG_event, FALSE);
961                                                }
962                                               
963                                                DMG_SetTimer(TIMER_ID_EPG, TIMER_EPG_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
964                                                break;
965
966        ///////////////////////////////////////// CH UP ////////////////
967                                        case APP_VK_CH_UP       :
968#if 0 //CH upÇϸé Á×´Â ¹®Á¦°¡ »ý°Ü¼­ ÀÏ´Ü ¸·¾Æ³õÀ½
969                                                dprint(3, "[[APP_VK_CH_UP]] nCurChIdx:%d, nStartChIdx:%d\n", nCurChIdx, nStartChIdx);
970                                                if (nCurChIdx < nNumChannel-1)
971                                                        nCurChIdx++;
972                                                else if (nCurChIdx == nNumChannel-1)
973                                                        nCurChIdx = nNumChannel-nNumChannel;
974                                               
975                                                CurRow = nCurChIdx;
976                                                if(EPGChList[nCurChIdx].ListUID < 0)    // DRF Channel
977                                                {
978                                                        dprint(1, "!! uid invalid, nCurChIdx %d\n", nCurChIdx);
979                                                }
980                                                else
981                                                {
982                                                        if(g_bEnableDTV)
983                                                        {
984//#if BLOCK_TUNE
985                                                                p_epg_tuneChannel(EPGChList[nCurChIdx].ListUID);
986                                                                if(App_EpgDoRedraw())
987                                                                {
988                                                                        DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_ONESHOT | eDMG_CMD_OPT_TIMER_LOCAL1);
989                                                                }
990//#endif
991                                                        }
992                                                }
993                                       
994                                                CurColumn = 0;
995                                                cursorIdx = 0;
996                                               
997                                                App_OSD_MakeEpgContents(nCurTime, nPageStartTime, EPGChList, nStartChIdx, PageEvent, NumEvent, pNumEvent);
998                                                p_erase_epgbase();
999                                                p_restore_epgbase();
1000                                                App_OSD_CommonBox2(84, 140+(34*cursorIdx), 255, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
1001                                                App_OSD_CommonBox2(344, 140+(34*cursorIdx), 267, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
1002                                                for (k = 0; k < 7; k++)
1003                                                {
1004                                                        if((PageEvent[CurRow][CurColumn+k].StatusFlag & Program_EMPTY) == Program_EMPTY)
1005                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
1006                                                        else
1007                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], PageEvent[CurRow][CurColumn+k].EPG_event, FALSE);
1008                                                }
1009                                               
1010                                                DMG_SetTimer(TIMER_ID_EPG, TIMER_EPG_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
1011#endif
1012                                                break;
1013                                       
1014        ///////////////////////////////////////// CH DOWN ////////////////
1015                                        case APP_VK_CH_DOWN :
1016#if 0 //CH upÇϸé Á×´Â ¹®Á¦°¡ »ý°Ü¼­ ÀÏ´Ü ¸·¾Æ³õÀ½
1017                                                dprint(3, "[[APP_VK_CH_DOWN]] nCurChIdx:%d, nStartChIdx:%d\n", nCurChIdx, nStartChIdx);                         
1018                                                if (nCurChIdx > 0)
1019                                                        nCurChIdx--;
1020                                                else if (nCurChIdx == 0)
1021                                                        nCurChIdx = nNumChannel-1;
1022                       
1023                                                CurRow = nCurChIdx;
1024                                                if(EPGChList[nCurChIdx].ListUID < 0)    // DRF Channel
1025                                                {
1026                                                        dprint(1, "!! uid invalid, nCurChIdx %d\n", nCurChIdx);
1027                                                }
1028                                                else
1029                                                {
1030                                                        if(g_bEnableDTV)
1031                                                        {
1032//#if BLOCK_TUNE
1033                                                                p_epg_tuneChannel(EPGChList[nCurChIdx].ListUID);
1034                                                                if(App_EpgDoRedraw())
1035                                                                {
1036                                                                        DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_ONESHOT | eDMG_CMD_OPT_TIMER_LOCAL1);
1037                                                                }
1038//#endif
1039                                                        }
1040                                                }
1041                                               
1042                                                CurColumn = 0;
1043                                                cursorIdx = 0;
1044
1045                                                App_OSD_MakeEpgContents(nCurTime, nPageStartTime, EPGChList, nStartChIdx, PageEvent, NumEvent, pNumEvent);
1046                                                p_erase_epgbase();
1047                                                p_restore_epgbase();
1048                                                App_OSD_CommonBox2(84, 140+(34*cursorIdx), 255, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
1049                                                App_OSD_CommonBox2(344, 140+(34*cursorIdx), 267, 30, 2, EPG_BG_COLOR_1, EPG_BG_COLOR_1, EPG_BG_COLOR_1);
1050                                                for (k = 0; k < 7; k++)
1051                                                {
1052                                                        if((PageEvent[CurRow][CurColumn+k].StatusFlag & Program_EMPTY) == Program_EMPTY)
1053                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
1054                                                        else
1055                                                                App_OSD_DrawEpgEventInfo(0, k, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], PageEvent[CurRow][CurColumn+k].EPG_event, FALSE);
1056                                                }
1057                                               
1058                                                DMG_SetTimer(TIMER_ID_EPG, TIMER_EPG_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
1059#endif
1060                                                break;
1061#if SELECT_TUNE
1062#if 0
1063        ///////////////////////////////////////// PREV_CH : EPG DETAIL ////////////////
1064                                case APP_VK_PREV_CH :
1065                                                if((PageEvent[CurRow][CurColumn].StatusFlag & Program_EMPTY)
1066                                                { // ºñ¾îÀÖÀ» °æ¿ì ۰¡ ¸ÔÁö ¾Êµµ·Ï ÇÑ´Ù.
1067                                                        break;
1068                                                }
1069                                                SaveRow = CurRow;
1070                                                SaveColumn = CurColumn;
1071                                                DMG_MenuStart(MID_EPG_DETAIL);
1072                                                break;
1073        ///////////////////////////////////////// SELECT //////////////////////////////
1074                                        case APP_VK_SELECT :
1075                                                pmenu=(tDMG_Menu *)param1;
1076                                                pmenu->param1=DMG_MAKEWORD(1, 0);
1077                                               
1078                                                list_uid = EPGChList[nCurChIdx].ListUID;
1079                                               
1080                                                if(param2==APP_VK_SELECT)
1081                                                {
1082                                                        DMG_MenuExit(MID_EPG);  // Ch Banner ÀÌÀü¿¡ EPG OSDºÎÅÍ Áö¿ö¾ß ÇÑ´Ù.
1083                                                        bEpgStart = TRUE;
1084                                                       
1085                                                        DMG_MenuStart(MID_CH_BANNER);
1086                                                        DMG_SetUserDefined(UD_ID_EPG_EXIT_ALARM, list_uid, 0);
1087                                                        p_epg_tuneChannel(EPGChList[nCurChIdx].ListUID);
1088                                                        if((App_EpgDoRedraw())
1089                                                                DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_ONESHOT | eDMG_CMD_OPT_TIMER_LOCAL1);
1090                                                        goto EPG_EXIT;
1091                                                }
1092#else
1093                                case APP_VK_SELECT :
1094                                        if(EPGChList[nCurChIdx].ListUID < 0)    // DRF Channel
1095                                        {
1096                                                dprint(1, "!! uid invalid, nCurChIdx %d\n", nCurChIdx);
1097                                        }
1098                                        else if(EPGChList[nCurChIdx].ListUID != APP_CUR_CH.nUid) /* ä³Î Æ©´× */
1099                                        {
1100                                                if(g_bEnableDTV)
1101                                                {
1102                                                        p_epg_tuneChannel(EPGChList[nCurChIdx].ListUID);
1103                                                        if(App_EpgDoRedraw())
1104                                                                DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_ONESHOT | eDMG_CMD_OPT_TIMER_LOCAL1);
1105                                                }
1106                                        } /* EPG Detail ·Î µé¾î°¨ */
1107                                        else
1108                                        {
1109                                                if(PageEvent[CurRow][CurColumn+cursorIdx].StatusFlag & Program_EMPTY)
1110                                                { 
1111                                                        // ºñ¾îÀÖÀ» °æ¿ì ۰¡ ¸ÔÁö ¾Êµµ·Ï ÇÑ´Ù.
1112                                                }
1113                                                else
1114                                                {
1115                                                        SaveRow = CurRow;
1116                                                        SaveColumn = CurColumn;
1117                                                        DMG_KillTimer(TIMER_ID_EPG_REFRESH); //  EPG Detail banner¿¡¼­´Â refresh µ¿ÀÛÀ» ¾ÈÇÑ´Ù.
1118                                                        DMG_MenuStart(MID_EPG_DETAIL);
1119                                                }
1120                                        }
1121                                        break;
1122#endif
1123
1124
1125
1126#else
1127        ///////////////////////////////////////// SELECT //////////////////////////////
1128                                        case APP_VK_SELECT :
1129                                                if((PageEvent[CurRow][CurColumn].StatusFlag & Program_EMPTY))
1130                                                { // ºñ¾îÀÖÀ» °æ¿ì ۰¡ ¸ÔÁö ¾Êµµ·Ï ÇÑ´Ù.
1131                                                        break;
1132                                                }
1133                                                SaveRow = CurRow;
1134                                                SaveColumn = CurColumn;
1135                                                DMG_KillTimer(TIMER_ID_EPG_REFRESH); //  EPG Detail banner¿¡¼­´Â refresh µ¿ÀÛÀ» ¾ÈÇÑ´Ù.
1136                                                DMG_MenuStart(MID_EPG_DETAIL);
1137                                                break;
1138#endif  // #if SELECT_TUNE
1139        ///////////////////////////////////////// MENU/BACK ///////////////////////////
1140                                        case APP_VK_MENU :
1141                                        case APP_VK_BACK :
1142#if 0//SELECT_TUNE
1143                                                /* 2009.11.16 foxhunt
1144                                                   p_epg_tuneChannel -> BACK(Main Menu) -> Program Guide ½Ã¿¡
1145                                                   Ã¤³Î°ú À̺¥Æ®°¡ ÀÏÄ¡ÇÏÁö ¾Ê´Â ¹®Á¦ ¹ß»ý
1146                                                */
1147                                                // recover channel property
1148                                                APP_CUR_CH.nChannelType = Temp_Channel.nChannelType;   
1149                                                APP_CUR_CH.nCableType           = Temp_Channel.nCableType;     
1150                                                APP_CUR_CH.nRF                                          = Temp_Channel.nRF;     
1151                                                APP_CUR_CH.nServiceType = Temp_Channel.nServiceType;           
1152                                                APP_CUR_CH.nMajor                               = Temp_Channel.nMajor;         
1153                                                APP_CUR_CH.nMinor                               = Temp_Channel.nMinor;         
1154                                                APP_CUR_CH.nProgramNumber= Temp_Channel.nProgramNumber;
1155                                                APP_CUR_CH.nSourceId                    = Temp_Channel.nSourceId;
1156                                                APP_CUR_CH.uPcrPid                              = Temp_Channel.uPcrPid;
1157                                                APP_CUR_CH.uVidPid                              = Temp_Channel.uVidPid;
1158                                                APP_CUR_CH.uAudPid                              = Temp_Channel.uAudPid;
1159                                                APP_CUR_CH.nUid                                 = Temp_Channel.nUid;
1160                                                memcpy(APP_CUR_CH.ShortName, Temp_Channel.ShortName, sizeof(Temp_Channel.ShortName));
1161#endif
1162                                               
1163                                                DMG_MenuExit(MID_EPG);
1164                                                bEpgStart = TRUE;
1165                                                //goto EPG_EXIT;
1166                                                break;
1167                               
1168                                        case APP_VK_EPG :
1169                                        case APP_VK_EXIT :
1170                                                if(!is_epg_started) break;
1171                                                is_epg_started=FALSE;
1172                       
1173                                                list_uid = EPGChList[nCurChIdx].ListUID;
1174                                                App_EpgInitVar();
1175                                                DMG_MenuExit(MID_EPG);
1176                                                bEpgStart = TRUE;
1177#if 0 //¿Ö ä³Î ¹è³Ê¸¦ ¶ç¿ìÁö?
1178                                                DMG_MenuStart(MID_CH_BANNER);
1179#endif
1180                                                DMG_SetUserDefined(UD_ID_EPG_EXIT_ALARM, list_uid, 0);
1181                                                break;
1182
1183                                        case APP_VK_FAV :
1184                                                break;
1185                                       
1186                                        default :
1187                                                bret=FALSE;
1188                                }  // switch(param2)
1189                        }    // if(bNotiBannerOn == FALSE)
1190                       
1191                        else // autoscan µÇ¾î ÀÖÁö ¾ÊÀ» ¶§ ¶ç¿ì´Â EPG °æ°í ¹è³Ê µ¿ÀÛ
1192                        {
1193                                switch(param2) {
1194                                        case APP_VK_SELECT :
1195                                        case APP_VK_EPG :
1196                                        case APP_VK_EXIT :
1197                                                APP_OSD_EraseWarningBanner();
1198                                                DMG_MenuExit(MID_EPG);
1199                                        break;
1200                                       
1201                                        case APP_VK_MENU :
1202                                        case APP_VK_BACK :
1203                                                APP_OSD_EraseWarningBanner();
1204                                                DMG_MenuExit(MID_EPG);
1205                                        break;
1206                                       
1207                                        default :
1208                                                bret=FALSE;
1209                                }  // switch(param2)
1210                        }    // if(bNotiBannerOn == TRUE)
1211                       
1212                        break;
1213               
1214                case eDMG_CMD_ON_MENU_EXIT :
1215                       
1216                        App_EpgFree();
1217                        App_EpgInitVar();
1218                       
1219                        DMG_KillTimer(TIMER_ID_EPG);
1220                        DMG_KillTimer(TIMER_ID_EPG_REFRESH);
1221                        p_erase_epgbase();
1222                        break;
1223
1224                default :
1225                        bret=FALSE;
1226                        break;
1227        }       // end of switch(cmd)
1228       
1229        if(!bret) 
1230                bret=App_Proc_Idle(cmd, opt, param1, param2);
1231               
1232        App_OSD_RefreshEpg();
1233       
1234        return bret;
1235}
1236
1237
1238#if COMMENT
1239__EPG_Detail_Parsing__() {}
1240#endif
1241
1242/******************************************************************************************
1243FUNCTION:
1244  - App_EpgDetailParsing
1245
1246Purpose:
1247  - ¼±ÅÃµÈ À̺¥Æ®¸¦ Ŭ¸¯½Ã, ÀÚ¼¼ÇÑ Á¤º¸¸¦ º¸¿©ÁÖ´Â ¹è³Ê
1248******************************************************************************************/
1249void App_EpgDetailParsing(strEPG_Data event)
1250{
1251        UINT16 pText[500];            // ETM Å©±â ¼³Á¤
1252        UINT16 txtLen = 0;
1253        BOOLEAN bInfo = FALSE;        // ETMÀÌ ÀÖÀ» ¶§ TRUE·Î ¼³Á¤
1254        int i, Line, LineGap, TotVal;
1255       
1256        nCurLineIdx = nStartLineIdx = 0;
1257       
1258
1259        /* Draw Epg Detail Banner Background */
1260        App_OSD_DrawEpgDetailBanner();
1261        App_OSD_DrawEpgCurrentTime(nCurTime, FALSE);
1262       
1263        /* Make Epg information */
1264        CurRow = SaveRow;
1265        CurColumn = SaveColumn;
1266#if 1
1267        if((event.StatusFlag & Program_EMPTY) == Program_EMPTY)
1268                App_OSD_DrawEpgEventInfo(1, 0, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], NULL, FALSE);
1269        else
1270                App_OSD_DrawEpgEventInfo(1, 0, (int)cursorIdx, (int)CurColumn, (int)pNumEvent[CurRow], EPGChList[nCurChIdx], event.EPG_event, FALSE);
1271#endif 
1272        dprint(3, "[%s/%d] event.StatusFlag : %d / Program_EMPTY : %d\n", __FUNCTION__, __LINE__,
1273           event.StatusFlag, Program_EMPTY);
1274        if(event.StatusFlag==0 || event.StatusFlag==1 || !Program_EMPTY)
1275        {
1276                memset(pText, 0, sizeof(UINT16)*500);
1277                if(event.EPG_event)
1278                {
1279                        dprint(1, "[DEBUG] Selected ETM Length : %d \n",event.EPG_event->eventETMLength);
1280                        dprint(1, "[DEBUG] Selected ETM String : %s \n",event.EPG_event->eventETM);
1281                        if(event.EPG_event->eventETMLength > 8)
1282                        {
1283                                txtLen = DLIB_PSI_DecodeMultipleStringStructure(event.EPG_event->eventETMLength,
1284                                                        event.EPG_event->eventETM,"eng",500,pText);
1285                                dprint(3, "[%s/%d] txtLen : %d, pText : %s\n", __FUNCTION__, __LINE__, txtLen, pText);
1286                                bInfo = TRUE;
1287                        }
1288                }
1289               
1290                if(txtLen < 500)
1291                        pText[txtLen] = 0;
1292                else
1293                        pText[500-1] = 0;
1294               
1295        }
1296       
1297        if(bInfo)
1298        {
1299                DMG_PrintUStrEx(101, 223, 500, 130, pText, 0xFFB2E0F8, DMG_OPT_A_TP);
1300                bInfo = FALSE;
1301        }
1302        else
1303        {
1304                PRINT_STR_EX(101, 223, 493, 20, EPG_DETAIL_NO_INFO, 0xFFB2E0F8, DMG_OPT_A_LT);
1305        }
1306
1307        App_OSD_DrawEpgChNum(EPGChList, nCurChIdx, FALSE);
1308}
1309
1310
1311static void FreeEpgEventItem(DMW_EpgEvent *pEvent)
1312{
1313        if ((pEvent->titleTextLength) > 0 && (pEvent->titleText))
1314        {
1315                DHL_OS_Free((void **)&pEvent->titleText);
1316                pEvent->titleTextLength = 0;
1317        }
1318
1319        if ((pEvent->eventETMLength > 0) && (pEvent->eventETM))
1320        {
1321                DHL_OS_Free((void **)&pEvent->eventETM);
1322                pEvent->eventETMLength = 0;
1323        }
1324
1325        if (pEvent->caption)
1326        {
1327                FreeMpegDescriptor(pEvent->caption);
1328                pEvent->caption = NULL;
1329        }
1330       
1331}
1332
1333
1334#if COMMENT
1335__EPG_Detail_User_Proc__() {}
1336#endif
1337
1338BOOL App_Proc_Epg_Detail(tDMG_CMD cmd, UINT32 opt, UINT32 param1, UINT32 param2)
1339{
1340        BOOL bret=TRUE;
1341        tDMG_Menu *pmenu;
1342        UINT32 flag = GET_EVENT_TITLE | GET_EVENT_TEXT;
1343        int list_uid; // EPG exit ÈÄ, Ch Banner¿¡ uid¸¦ Àü´ÞÇϱâ À§ÇÑ º¯¼ö
1344        static strEPG_Data curr_epg_data;
1345       
1346        dprint(1, "%s proc : cmd(%x), param1(%x), param2(%x)\n", __FUNCTION__, cmd, param1, param2);
1347       
1348        switch(cmd)
1349        {
1350                case eDMG_CMD_ON_MENU_ACTIVE :
1351                        pmenu=(tDMG_Menu *)param1;
1352                       
1353                        /* EPG Detail window ÀÏ °æ¿ì, ETMÀ» ¹Þ¾Æ¿Â´Ù. */
1354                        /* ¿Ö Å×½ºÆ® ÇÔ¼ö¸¦ °®´Ù ½èÁö? ¾Æ¹«Æ°..ºôµå warning ¹æÁö ÇÊ¿ä */
1355                       
1356                        {
1357                                void TestEpgFindEventByEvid(int rf, int source_id, UINT16 evid);
1358                                TestEpgFindEventByEvid(EPGChList[nCurChIdx].ListRF, EPGChList[nCurChIdx].ListSourceId, 
1359                                                PageEvent[CurRow][CurColumn+cursorIdx].EPG_event->programId);
1360                        }
1361                        // Àӽ÷ΠÇöÀç EPG_Data¿¡ ´ëÇÑ º¹»çº»À» ¸¸µé¾î¼­, ±× ¾ÈÀÇ
1362                        // EPG_event¸¸ »õ·Î ¹Þ¾Æ¼­ »ç¿ëÀ» ÇÑ´Ù.
1363                        // ±âÁ¸¿¡´Â PageEvent ¸®½ºÆ®ÀÇ ÇöÀç À§Ä¡¿¡ ÇØ´çÇÏ´Â EPG_event¸¦
1364                        // µ¤¾î ½á¹ö·È±â ¶§¹®¿¡ ¸Þ¸ð¸®°¡ »õ°í ÀÖ¾úÀ½
1365                        memcpy(&curr_epg_data, &PageEvent[CurRow][CurColumn+cursorIdx], sizeof(curr_epg_data));
1366                        curr_epg_data.EPG_event = NULL;
1367                        DMW_EPG_GetEventByEvidAndRf(EPGChList[nCurChIdx].ListRF, EPGChList[nCurChIdx].ListSourceId, 
1368                                                PageEvent[CurRow][CurColumn+cursorIdx].EPG_event->programId, &(curr_epg_data.EPG_event), flag);
1369                        App_EpgDetailParsing(curr_epg_data);
1370                        DMG_SetTimer(TIMER_ID_EPG_DETAIL, TIMER_EPG_DETAIL_DUR, eDMG_CMD_OPT_TIMER_ONESHOT);
1371                        break;
1372               
1373                case eDMG_CMD_ON_TIME :
1374                        /* kill */
1375                        if(param1==TIMER_ID_EPG_DETAIL)
1376                        {
1377                                pmenu=DMG_GetCurMenu();
1378                                DMG_MenuExit(pmenu->id);
1379                        }
1380                        else
1381                                bret=FALSE;
1382                        break;
1383               
1384                case eDMG_CMD_ON_TIMEOUT :
1385                        DMG_MenuExit(MID_MAIN);
1386                        DMG_MenuExit(MID_EPG);
1387                        DMG_MenuExit(MID_EPG_DETAIL);
1388                        break;
1389                       
1390                case eDMG_CMD_ON_KEY :
1391                        pmenu=(tDMG_Menu *)param1;
1392                       
1393                        switch(param2)
1394                        {
1395                                case APP_VK_SELECT :
1396                                        /* nothing any action */
1397                                        // 2009.11.17 foxhunt : ¼³Á¤ÇصÎÁö ¾ÊÀ¸¸é info banner°¡ µ¿ÀÛ ÇÔ
1398                                        break;
1399                               
1400                                case APP_VK_CH_UP :
1401                                case APP_VK_CH_DOWN :
1402                                        break;
1403                                       
1404                                case APP_VK_MENU :
1405                                case APP_VK_BACK :
1406                                        bEpgStart = FALSE;
1407                                        if(bEpgStart == FALSE)
1408                                        {
1409                                                SaveRow = CurRow;
1410                                                SaveColumn = CurColumn;
1411                                        }
1412                                       
1413                                        DMG_MenuExit(MID_EPG_DETAIL);
1414                                        break;
1415                                       
1416                                case APP_VK_EPG :
1417                                case APP_VK_EXIT :
1418                                        list_uid = EPGChList[nCurChIdx].ListUID;
1419                                       
1420                                        DMG_MenuExit(MID_EPG);       // HIDE µÇ¾î ÀÖ´ø EPG¸¦ ¸ÕÀú ´Ý¾Æ¾ß ±ôºýÀÓÀÌ ¾Èº¸ÀδÙ.
1421                                        DMG_MenuExit(MID_EPG_DETAIL);
1422                                        bEpgStart = TRUE;
1423#if 0
1424                                        DMG_MenuStart(MID_CH_BANNER);
1425#endif
1426                                        DMG_SetUserDefined(UD_ID_EPG_EXIT_ALARM, list_uid, 0);
1427                                        break;
1428                                       
1429                                case APP_VK_FAV :
1430                                                break;
1431                                       
1432                                default :
1433                                        bret=FALSE;
1434                        }
1435                        break;
1436               
1437                case eDMG_CMD_ON_MENU_EXIT :
1438                        DMG_KillTimer(TIMER_ID_EPG_DETAIL);
1439                       
1440                        /* EPG Detail Window¿¡¼­ time out µÉ °æ¿ì¿¡ memory free */
1441                        //DMW_EPG_FreeEpgEvent(PageEvent[CurRow][CurColumn].EPG_event);
1442                        FreeEpgEventItem(curr_epg_data.EPG_event);
1443                        DHL_OS_Free((void**)&curr_epg_data.EPG_event);
1444                        memset(&curr_epg_data, 0, sizeof(curr_epg_data));
1445                       
1446                        p_erase_epgbase();
1447                       
1448                        bReturn = TRUE;
1449                        break;
1450                       
1451                default :
1452                        bret=FALSE;
1453                        break;
1454        }
1455       
1456        if(!bret) 
1457                bret=App_Proc_Idle(cmd, opt, param1, param2);
1458       
1459        App_OSD_RefreshEpg();
1460       
1461        return bret;
1462}
1463
1464
1465
1466
1467
1468#if COMMENT
1469__EPG_Local_Func__() {}
1470#endif
1471
1472void App_Menu_CreateEpg()
1473{
1474        if(DMG_GetMenu(MID_EPG)) {
1475                return;
1476        }
1477       
1478        DMG_CreateMenu(MID_EPG_CFG);
1479}
1480
1481
1482void App_Menu_CreateEpgDetail()
1483{
1484        if(DMG_GetMenu(MID_EPG_DETAIL)) {
1485                return;
1486        }
1487       
1488        DMG_CreateMenu(MID_EPG_DETAIL_CFG);
1489}
1490
Note: See TracBrowser for help on using the repository browser.