| 1 | #include "DST_WinManager.h" |
|---|
| 2 | #include "DST_CommonAPI.h" |
|---|
| 3 | #include "DST_ChannelTune.h" |
|---|
| 4 | #include "DST_DB_Engine.h" |
|---|
| 5 | #include "DST_DB.h" |
|---|
| 6 | |
|---|
| 7 | static bool bCCEngineReady = false; |
|---|
| 8 | |
|---|
| 9 | static bool bAutoDetectUnicode = false; // CC µ¥ÀÌÅ͸¦ ºÐ¼®ÇÏ¿© ÀÚµ¿À¸·Î ¿Ï¼ºÇüÀÎÁö À¯´ÏÄÚµåÀÎÁö ¾Ë¾Æ³½´Ù. |
|---|
| 10 | |
|---|
| 11 | void DST_708_Callback(DS_U8 *bytearray,int size) |
|---|
| 12 | { |
|---|
| 13 | if (size == 0) return; |
|---|
| 14 | if (bCCEngineReady == false) return; |
|---|
| 15 | // Sequence Header°¡ ¿Ã¹Ù¸¥Áö È®ÀÎÇØº»´Ù. |
|---|
| 16 | if (size < 0) // Sequence Header ¿¡·¯°¡ ³ °æ¿ì |
|---|
| 17 | { |
|---|
| 18 | DST_Printf("Sequence Header Error\n"); |
|---|
| 19 | DST_SendWindowEventWithOnlyCmd(WM_SEQ_ERROR); |
|---|
| 20 | return; |
|---|
| 21 | } |
|---|
| 22 | if (size > 31) return; |
|---|
| 23 | int nCharTotal = 0; |
|---|
| 24 | int i; |
|---|
| 25 | for ( i=0; i < size; i++) if (bytearray[i] == 0x18) nCharTotal++; |
|---|
| 26 | if (nCharTotal > 0) DST_g_CC_DataReceiveTick = DST_OS_GetTickCount(); |
|---|
| 27 | if (DST_EEPROM_GetCC() == 0) return; // ÀÎÆ÷¹è³Ê CC ¾ÆÀÌÄÜ Á¤º¸¸¦ ¾÷µ¥ÀÌÆ® Çϰí CC ²¨Á®ÀÖÀ¸¸é ¸¶¹«¸® |
|---|
| 28 | SWinEventMsg msg; |
|---|
| 29 | msg.cmd = WM_CS1; |
|---|
| 30 | msg.data[0] = size; |
|---|
| 31 | memcpy(&msg.data[1], bytearray, size); |
|---|
| 32 | DST_SendWindowEvent(msg); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | typedef void (*CC708_CallBack)(DS_U8 *bytearray,int size); |
|---|
| 36 | /*extern "C" */void SetCC708_CallBack(CC708_CallBack callback); |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | static bool DST_CCAvailable() |
|---|
| 40 | { |
|---|
| 41 | if (DST_g_PowerOn == false) return false; |
|---|
| 42 | if (DST_g_SignalState != SM_GOOD_SIGNAL) return false; // ½ÅÈ£ »óŰ¡ ÁÁÀº °æ¿ì¿¡¸¸ CC¸¦ º¸¿©ÁÖµµ·Ï ÇÔ |
|---|
| 43 | // if (DST_g_SleepState != 0) return false; // normal »óŰ¡ ¾Æ´Ï¸é CC ´Ý´Â´Ù |
|---|
| 44 | if (DST_EEPROM_GetCC() == 0) return false; |
|---|
| 45 | if (DST_g_LastTuneTime == 0) return false; |
|---|
| 46 | if (DST_IsVideoPlay() == false) return false; |
|---|
| 47 | if (DST_g_LastTuneTryTime > DST_OS_GetTickCount()) DST_g_LastTuneTryTime = DST_OS_GetTickCount(); |
|---|
| 48 | if (DST_OS_GetTickCount() - DST_g_LastTuneTryTime < DST_OS_GetTicksPerSecond() * 3) return false; |
|---|
| 49 | int id; |
|---|
| 50 | for ( id = (int)WIN_NULL+1; id < (int)WIN_CAPTION; id++) |
|---|
| 51 | { |
|---|
| 52 | if (id == WIN_VOLUME) continue; |
|---|
| 53 | if (id == WIN_VOLUME_MUTE) continue; |
|---|
| 54 | if (DST_GetWin((WinID)id)) return false; |
|---|
| 55 | } |
|---|
| 56 | return true; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | static void tCCManager() |
|---|
| 60 | { |
|---|
| 61 | DST_OS_Delay(3000); // 3ÃÊ ½¬°í ½ÃÀÛ |
|---|
| 62 | bCCEngineReady = true; |
|---|
| 63 | DST_CreateWin(WIN_CAPTION, WIN_NULL, 1, 0, 0, 0); |
|---|
| 64 | while (1) |
|---|
| 65 | { |
|---|
| 66 | // T(); |
|---|
| 67 | DST_OS_Delay(100); |
|---|
| 68 | CWindow *pWin = DST_GetWin(WIN_CAPTION); |
|---|
| 69 | if (DST_CCAvailable()) |
|---|
| 70 | { |
|---|
| 71 | if (pWin) continue; |
|---|
| 72 | DST_CreateWin(WIN_CAPTION, WIN_NULL, 1, 0,0,0); |
|---|
| 73 | int i; |
|---|
| 74 | for ( i = 0; i < 5; i++) |
|---|
| 75 | { |
|---|
| 76 | DST_OS_Delay(100);// ½ÇÁ¦ À©µµ¿ì°¡ »ý¼ºµÉ¶§±îÁö ´ë±â |
|---|
| 77 | if (DST_GetWin(WIN_CAPTION)) break; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | else |
|---|
| 81 | { |
|---|
| 82 | if (pWin == 0) continue; |
|---|
| 83 | DST_SendWindowEventWithOnlyCmd(WM_CC_CLOSE); |
|---|
| 84 | int i; |
|---|
| 85 | for ( i = 0; i < 5; i++) |
|---|
| 86 | { |
|---|
| 87 | DST_OS_Delay(100);// ½ÇÁ¦ À©µµ¿ì°¡ »ý¼ºµÉ¶§±îÁö ´ë±â |
|---|
| 88 | if (DST_GetWin(WIN_CAPTION)==0) break; |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | void DST_CCManagerInit() |
|---|
| 95 | { |
|---|
| 96 | static int TaskID = 0; |
|---|
| 97 | if (TaskID != 0) return; |
|---|
| 98 | TaskID = DST_OS_SpawnTask((void(*)(void *))tCCManager, (char*)"CCManager", APP_TASK_PRIO_CC_MGR, WIN_MGR_TASK_STACKSIZE, 0); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | void DST_CheckCCDescription(DS_U8 nServiceNumber, bool *bKorean, bool *bWideScreen, bool *bUnicode) |
|---|
| 102 | { |
|---|
| 103 | *bKorean = DST_g_CC_bCCKorean; |
|---|
| 104 | *bWideScreen = DST_g_CC_bWideScreen; |
|---|
| 105 | *bUnicode = DST_g_CC_bUnicode; // CC µð½ºÅ©¸³ÅÍ »ç¿ë |
|---|
| 106 | // *bUnicode = bAutoDetectUnicode; // ÀÚµ¿ °ËÃâ |
|---|
| 107 | } |
|---|