| 1 | /**************************************************************************** |
|---|
| 2 | * NAME: App_Fnc_CC.c |
|---|
| 3 | *---------------------------------------------------------------------------- |
|---|
| 4 | * Copyright (c) DIGITAL STREAM Technology Inc. |
|---|
| 5 | *---------------------------------------------------------------------------- |
|---|
| 6 | * CREATED_BY: Yong Dae Park |
|---|
| 7 | * CREATION_DATE: 2009/09/08 |
|---|
| 8 | * $Author: x2silo $ |
|---|
| 9 | * $Revision: 1.1 $ |
|---|
| 10 | * $Date: 2009/07/08 15:08:26 $ |
|---|
| 11 | *---------------------------------------------------------------------------- |
|---|
| 12 | * PURPOSE: |
|---|
| 13 | * - implement CC API |
|---|
| 14 | *****************************************************************************/ |
|---|
| 15 | |
|---|
| 16 | /*_____ I N C L U D E __________________________________________*/ |
|---|
| 17 | |
|---|
| 18 | #include "App_Main.h" |
|---|
| 19 | |
|---|
| 20 | #if SUPPORT_CC |
|---|
| 21 | |
|---|
| 22 | #include "App_Fnc_Common.h" |
|---|
| 23 | |
|---|
| 24 | #include "cc_api.h" |
|---|
| 25 | #include "DMG_Draw.h" |
|---|
| 26 | |
|---|
| 27 | #include "App_Fnc_CC.h" |
|---|
| 28 | #include "App_Fnc_ChTune.h" |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | #include "App_Res_Resources.h" |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | /*_____ D E F I N I T I O N ____________________________________*/ |
|---|
| 38 | |
|---|
| 39 | #if COMMENT |
|---|
| 40 | _____DbgPrint_____(){} |
|---|
| 41 | #endif |
|---|
| 42 | |
|---|
| 43 | DHL_MODULE("@f_cc", 0); |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | #if COMMENT |
|---|
| 50 | ____Config____(){} |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | #if COMMENT |
|---|
| 58 | ____Types____(){} |
|---|
| 59 | #endif |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | #if COMMENT |
|---|
| 66 | ____Variables____(){} |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | /*_____ F U N C T I O N ________________________________________*/ |
|---|
| 74 | |
|---|
| 75 | #if 0 |
|---|
| 76 | ______________() {} |
|---|
| 77 | #endif |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | static BOOL p_cc_get_wide() |
|---|
| 83 | { |
|---|
| 84 | tDCC_Config cfg; |
|---|
| 85 | |
|---|
| 86 | DCC_GetConfig(&cfg); |
|---|
| 87 | |
|---|
| 88 | return cfg.is_cc_wide; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | static BOOL p_cc_get_src_wide() |
|---|
| 92 | { |
|---|
| 93 | tDCC_Config cfg; |
|---|
| 94 | |
|---|
| 95 | DCC_GetConfig(&cfg); |
|---|
| 96 | |
|---|
| 97 | return cfg.is_src_wide; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | static void p_get_def_cfg(tDCC_Info *pinfo) |
|---|
| 101 | { |
|---|
| 102 | tDCC_Info cc_info; |
|---|
| 103 | |
|---|
| 104 | DCC_GetInfo(&cc_info); |
|---|
| 105 | |
|---|
| 106 | /* main */ |
|---|
| 107 | cc_info.bdisplay_on=FALSE; |
|---|
| 108 | cc_info.bready=FALSE; |
|---|
| 109 | cc_info.service=eDCC_S_CS1; |
|---|
| 110 | cc_info.buser_opt=FALSE; |
|---|
| 111 | |
|---|
| 112 | /* tDCC_Config */ |
|---|
| 113 | cc_info.config.is_cc_wide=FALSE; |
|---|
| 114 | cc_info.config.is_src_wide=FALSE; |
|---|
| 115 | cc_info.config.is_korean=FALSE; |
|---|
| 116 | cc_info.config.is_unicode=FALSE; |
|---|
| 117 | cc_info.config.resolution=eDCC_R_480; |
|---|
| 118 | |
|---|
| 119 | /* tDCC_PenUserAttr */ |
|---|
| 120 | cc_info.pen_attr.s=DCC_AUTO_SET; |
|---|
| 121 | cc_info.pen_attr.fs=DCC_AUTO_SET; |
|---|
| 122 | cc_info.pen_attr.tt=DCC_AUTO_SET; |
|---|
| 123 | cc_info.pen_attr.o=DCC_AUTO_SET; |
|---|
| 124 | cc_info.pen_attr.u=DCC_AUTO_SET; |
|---|
| 125 | cc_info.pen_attr.i=DCC_AUTO_SET; |
|---|
| 126 | cc_info.pen_attr.et=DCC_AUTO_SET; |
|---|
| 127 | |
|---|
| 128 | cc_info.pen_attr.fc=DCC_AUTO_SET; |
|---|
| 129 | cc_info.pen_attr.fo=DCC_AUTO_SET; |
|---|
| 130 | cc_info.pen_attr.bc=DCC_AUTO_SET; |
|---|
| 131 | cc_info.pen_attr.bo=DCC_AUTO_SET; |
|---|
| 132 | cc_info.pen_attr.ec=DCC_AUTO_SET; |
|---|
| 133 | |
|---|
| 134 | /* tDCC_WinAttr */ |
|---|
| 135 | cc_info.win_attr.j=DCC_AUTO_SET; |
|---|
| 136 | cc_info.win_attr.pd=DCC_AUTO_SET; |
|---|
| 137 | cc_info.win_attr.sd=DCC_AUTO_SET; |
|---|
| 138 | cc_info.win_attr.ww=DCC_AUTO_SET; |
|---|
| 139 | cc_info.win_attr.de=DCC_AUTO_SET; |
|---|
| 140 | cc_info.win_attr.ed=DCC_AUTO_SET; |
|---|
| 141 | cc_info.win_attr.es=DCC_AUTO_SET; |
|---|
| 142 | cc_info.win_attr.fc=DCC_AUTO_SET; |
|---|
| 143 | cc_info.win_attr.fo=DCC_AUTO_SET; |
|---|
| 144 | cc_info.win_attr.bt=DCC_AUTO_SET; |
|---|
| 145 | cc_info.win_attr.bc=DCC_AUTO_SET; |
|---|
| 146 | |
|---|
| 147 | cc_info.win_posx=0; |
|---|
| 148 | cc_info.win_posy=0; |
|---|
| 149 | |
|---|
| 150 | cc_info.is_feeding_608=TRUE; //feeding 608Àº true·Î ÇÔ. |
|---|
| 151 | |
|---|
| 152 | *pinfo=cc_info; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | static void p_set_def_cfg() |
|---|
| 157 | { |
|---|
| 158 | tDCC_Info cc_info; |
|---|
| 159 | |
|---|
| 160 | p_get_def_cfg(&cc_info); |
|---|
| 161 | |
|---|
| 162 | DCC_Stop(); |
|---|
| 163 | DCC_Exit(); |
|---|
| 164 | |
|---|
| 165 | DCC_SetService(cc_info.service); |
|---|
| 166 | DCC_SetOption(cc_info.buser_opt); |
|---|
| 167 | DCC_SetKorean(cc_info.config.is_korean); |
|---|
| 168 | |
|---|
| 169 | DCC_ResetConfig(&cc_info.config); |
|---|
| 170 | |
|---|
| 171 | DCC_SetPenUserAttr(&cc_info.pen_attr); |
|---|
| 172 | DCC_SetWinUserAttr(&cc_info.win_attr); |
|---|
| 173 | |
|---|
| 174 | DCC_MoveWinPosition(cc_info.win_posx, cc_info.win_posy); |
|---|
| 175 | DCC_SetFeeding608(cc_info.is_feeding_608); |
|---|
| 176 | |
|---|
| 177 | DCC_SetSync(); //before save var |
|---|
| 178 | |
|---|
| 179 | App_NVM_SaveModuleParam(eAPP_NVR_CC, &cc_info); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | void App_CC_Init() |
|---|
| 184 | { |
|---|
| 185 | tDCC_Info info; |
|---|
| 186 | |
|---|
| 187 | tDCC_ColorMap cm={ |
|---|
| 188 | eDMG_C_BLACK, eDMG_C_RED, eDMG_C_GREEN, eDMG_C_YELLOW, |
|---|
| 189 | eDMG_C_BLUE, eDMG_C_MAGENTA, eDMG_C_CYAN, eDMG_C_WHITE, |
|---|
| 190 | eDMG_C_H_BLACK, eDMG_C_H_RED, eDMG_C_H_GREEN, eDMG_C_H_YELLOW, |
|---|
| 191 | eDMG_C_H_BLUE, eDMG_C_H_MAGENTA, eDMG_C_H_CYAN, eDMG_C_H_WHITE, |
|---|
| 192 | eDMG_C_TRANSPARENT, (UINT8)-1 |
|---|
| 193 | }; |
|---|
| 194 | |
|---|
| 195 | App_NVM_LoadModuleParam(eAPP_NVR_CC, &info); |
|---|
| 196 | |
|---|
| 197 | info.config.is_cc_wide=FALSE; |
|---|
| 198 | info.config.is_src_wide=FALSE; |
|---|
| 199 | info.config.is_korean=FALSE; |
|---|
| 200 | info.config.is_unicode=FALSE; |
|---|
| 201 | info.config.resolution=eDCC_R_480; |
|---|
| 202 | info.config.color_map=&cm; |
|---|
| 203 | |
|---|
| 204 | DCC_Init(&info.config); |
|---|
| 205 | |
|---|
| 206 | DCC_SetService(info.service); |
|---|
| 207 | DCC_SetOption(info.buser_opt); |
|---|
| 208 | DCC_SetKorean(info.config.is_korean); |
|---|
| 209 | |
|---|
| 210 | DCC_SetPenUserAttr(&info.pen_attr); |
|---|
| 211 | DCC_SetWinUserAttr(&info.win_attr); |
|---|
| 212 | |
|---|
| 213 | DCC_MoveWinPosition(info.win_posx, info.win_posy); |
|---|
| 214 | DCC_SetFeeding608(info.is_feeding_608); |
|---|
| 215 | |
|---|
| 216 | if(info.bready) { |
|---|
| 217 | DCC_Ready(); |
|---|
| 218 | // ºÎÆÃ ½Ã¿¡ ¾Æ·¡ÀÇ ½ÇÇàÀ¸·Î ÀÎÇÏ¿© Menu state°¡ ²¿ÀÌ´Â °æ¿ì°¡ ÀÖ´Ù. |
|---|
| 219 | // (AC-on ÈÄ¿¡ ¹Ù·Î ÄÓ¶§ ÆÄ¿ö¸¦ Á¦¿ÜÇÑ ¸ðµç ¹öưÀÌ µ¿ÀÛÇÏÁö ¾Ê´Â ¹®Á¦) |
|---|
| 220 | // Standby procÀÇ exit ½Ã¿¡ ¶Ç ½ÇÇà Çϱ⠶§¹®¿¡, ¿©±â¼ ¾ÈÇØµµ µÈ´Ù. |
|---|
| 221 | //DMG_MenuStart(MID_CC); |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | void App_CCParamInit(void) |
|---|
| 226 | { |
|---|
| 227 | App_NVM_RegisterModule(eAPP_NVR_CC, sizeof(tDCC_Info), p_set_def_cfg); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | void App_CC_SaveVar() |
|---|
| 232 | { |
|---|
| 233 | tDCC_Info info; |
|---|
| 234 | |
|---|
| 235 | DCC_GetInfo(&info); |
|---|
| 236 | |
|---|
| 237 | DCC_SetSync(); //before save var |
|---|
| 238 | |
|---|
| 239 | App_NVM_SaveModuleParam(eAPP_NVR_CC, &info); |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | #if 0 |
|---|
| 245 | ______________() {} |
|---|
| 246 | #endif |
|---|
| 247 | |
|---|
| 248 | STATUS App_CC_GetAspectRatioFromPmt(UINT8 user_cc_service, UINT8 *pis_wide) |
|---|
| 249 | { |
|---|
| 250 | STATUS err=statusOK; |
|---|
| 251 | captionServiceDescriptorPtr_t pcs_desc=NULL; |
|---|
| 252 | int i; |
|---|
| 253 | BOOL bfound; |
|---|
| 254 | BOOL is_wide=TRUE; |
|---|
| 255 | |
|---|
| 256 | err=DMW_EPG_GetCaptionDescriptorInPMT(&pcs_desc); |
|---|
| 257 | |
|---|
| 258 | if(err || pcs_desc==NULL) { |
|---|
| 259 | if (pcs_desc) FreeMpegDescriptor(pcs_desc); |
|---|
| 260 | dprint(0, "!! caption desc is not found in PMT\n"); |
|---|
| 261 | return statusNotFound; |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | for(i=0, bfound=FALSE; i<pcs_desc->number_of_services && !bfound; i++) |
|---|
| 265 | { |
|---|
| 266 | if(pcs_desc->service[i].cc_type==0) { //608 cc |
|---|
| 267 | if(pcs_desc->service[i].cc_id.line21_field==0) { |
|---|
| 268 | if(user_cc_service==eDCC_S_CC1 || user_cc_service==eDCC_S_CC2) bfound=TRUE; |
|---|
| 269 | } |
|---|
| 270 | else { |
|---|
| 271 | if(user_cc_service==eDCC_S_CC3 || user_cc_service==eDCC_S_CC4) bfound=TRUE; |
|---|
| 272 | } |
|---|
| 273 | } |
|---|
| 274 | else { //708 cc |
|---|
| 275 | if(pcs_desc->service[i].cc_id.caption_service_number == |
|---|
| 276 | user_cc_service-eDCC_S_CS1+1) bfound=TRUE; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | if(bfound) is_wide=pcs_desc->service[i].wide_aspect_ratio; |
|---|
| 280 | } |
|---|
| 281 | FreeMpegDescriptor(pcs_desc); |
|---|
| 282 | if(!pis_wide) dprint(0, " --> Service %d, wide %d\n", user_cc_service, is_wide); |
|---|
| 283 | else if(bfound) *pis_wide=is_wide; |
|---|
| 284 | else *pis_wide=TRUE; //foundµÇÁö ¾Ê¾Ò´Ù¸é WIDE·Î °¡Á¤ÇÔ. |
|---|
| 285 | |
|---|
| 286 | return err; |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | STATUS App_CC_GetAspectRatioFromEit(int uid, UINT8 user_cc_service, UINT8 *pis_wide) |
|---|
| 291 | { |
|---|
| 292 | STATUS err=statusOK; |
|---|
| 293 | captionServiceDescriptorPtr_t pcs_desc=NULL; |
|---|
| 294 | int i; |
|---|
| 295 | UINT32 ref_time; |
|---|
| 296 | UINT32 utc; |
|---|
| 297 | BOOL bfound; |
|---|
| 298 | BOOL is_wide=TRUE; |
|---|
| 299 | |
|---|
| 300 | extern SysTimeContext g_stcAutoSync; |
|---|
| 301 | |
|---|
| 302 | err = DMW_GetUTCTime(&g_stcAutoSync, &utc); |
|---|
| 303 | |
|---|
| 304 | if(err) return statusPSIPError; |
|---|
| 305 | |
|---|
| 306 | ref_time=DMW_ConvertUTC2GPS(&g_stcAutoSync, utc); |
|---|
| 307 | |
|---|
| 308 | err = DMW_EPG_GetCaptionDescriptor(uid, ref_time, &pcs_desc); |
|---|
| 309 | |
|---|
| 310 | if(err || pcs_desc==NULL) { |
|---|
| 311 | if (pcs_desc) FreeMpegDescriptor(pcs_desc); |
|---|
| 312 | dprint(0, "!! caption desc is not found in PMT\n"); |
|---|
| 313 | return statusNotFound; |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | for(i=0, bfound=FALSE; i<pcs_desc->number_of_services && !bfound; i++) |
|---|
| 317 | { |
|---|
| 318 | if(pcs_desc->service[i].cc_type==0) { //608 cc |
|---|
| 319 | if(pcs_desc->service[i].cc_id.line21_field==0) { |
|---|
| 320 | if(user_cc_service==eDCC_S_CC1 || user_cc_service==eDCC_S_CC2) bfound=TRUE; |
|---|
| 321 | } |
|---|
| 322 | else { |
|---|
| 323 | if(user_cc_service==eDCC_S_CC3 || user_cc_service==eDCC_S_CC4) bfound=TRUE; |
|---|
| 324 | } |
|---|
| 325 | } |
|---|
| 326 | else { //708 cc |
|---|
| 327 | if(pcs_desc->service[i].cc_id.caption_service_number == |
|---|
| 328 | user_cc_service-eDCC_S_CS1+1) bfound=TRUE; |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | if(bfound) is_wide=pcs_desc->service[i].wide_aspect_ratio; |
|---|
| 332 | } |
|---|
| 333 | FreeMpegDescriptor(pcs_desc); |
|---|
| 334 | if(!pis_wide) dprint(0, " --> Service %d, wide %d\n", user_cc_service, is_wide); |
|---|
| 335 | else if(bfound) *pis_wide=is_wide; |
|---|
| 336 | else *pis_wide=TRUE; //foundµÇÁö ¾Ê¾Ò´Ù¸é WIDE·Î °¡Á¤ÇÔ. |
|---|
| 337 | |
|---|
| 338 | return err; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | void App_CC_SetScreenRatio(void) |
|---|
| 343 | { |
|---|
| 344 | STATUS err=statusOK; |
|---|
| 345 | |
|---|
| 346 | BOOL is_cur_cc_wide; |
|---|
| 347 | BOOL is_cur_src_wide; |
|---|
| 348 | |
|---|
| 349 | BOOL is_cc_wide=TRUE; |
|---|
| 350 | |
|---|
| 351 | tDHL_VideoSeqHdr seq; |
|---|
| 352 | DST_CURCHANNEL ChannelInfo; |
|---|
| 353 | |
|---|
| 354 | int service=DCC_GetService(); |
|---|
| 355 | |
|---|
| 356 | App_Ucm_GetCurChInfo(&ChannelInfo); |
|---|
| 357 | |
|---|
| 358 | is_cur_cc_wide=p_cc_get_wide(); |
|---|
| 359 | is_cur_src_wide=p_cc_get_src_wide(); |
|---|
| 360 | |
|---|
| 361 | if (DHL_AV_VideoSeqInfo(0, &seq) == DHL_OK && DHL_AV_IsWideoFormat(&seq)) |
|---|
| 362 | is_cur_src_wide = TRUE; |
|---|
| 363 | else { |
|---|
| 364 | is_cur_src_wide = FALSE; |
|---|
| 365 | dprint(0, "[CC] input video is 4:3..\n"); |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | if(service==eDCC_S_NONE) return; |
|---|
| 369 | |
|---|
| 370 | dprint(0, "[CC] CC Mode : %d\n", service); |
|---|
| 371 | |
|---|
| 372 | err = App_CC_GetAspectRatioFromEit(ChannelInfo.nUid, service, &is_cc_wide); |
|---|
| 373 | |
|---|
| 374 | if(err) { |
|---|
| 375 | //EIT¿¡·¯ ->PMTÁ¶»ç. |
|---|
| 376 | err = App_CC_GetAspectRatioFromPmt(service, &is_cc_wide); |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | if(err) { |
|---|
| 380 | is_cc_wide = TRUE; |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | { |
|---|
| 384 | tDCC_Config cfg; |
|---|
| 385 | |
|---|
| 386 | DCC_GetConfig(&cfg); |
|---|
| 387 | |
|---|
| 388 | cfg.is_cc_wide=is_cc_wide; |
|---|
| 389 | cfg.is_src_wide=is_cur_src_wide; |
|---|
| 390 | |
|---|
| 391 | DCC_ResetConfig(&cfg); |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | if (is_cur_cc_wide != is_cc_wide || is_cur_src_wide != is_cur_src_wide) |
|---|
| 395 | { |
|---|
| 396 | //and change cc screen ratio |
|---|
| 397 | dprint(0, "[CC] CC Ratio change ===> %s caption, %s video\n", |
|---|
| 398 | is_cc_wide ? "wide" : "narrow", |
|---|
| 399 | is_cur_src_wide ? "wide" : "narrow"); |
|---|
| 400 | |
|---|
| 401 | //Update wide, narrow Á¦¾î |
|---|
| 402 | } |
|---|
| 403 | else { |
|---|
| 404 | dprint(0, "[CC] CC Ratio unchanged, %s caption, %s video\n", |
|---|
| 405 | is_cc_wide ? "wide" : "narrow", |
|---|
| 406 | is_cur_src_wide ? "wide" : "narrow"); |
|---|
| 407 | } |
|---|
| 408 | } |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | BOOL App_CC_IsServiceOn(UINT8 service) |
|---|
| 412 | { |
|---|
| 413 | if(service==0) { |
|---|
| 414 | int i; |
|---|
| 415 | |
|---|
| 416 | for(i=eDCC_S_CC1; i<=eDCC_S_CS6; i++) { |
|---|
| 417 | if(DCC_IsServiceOn((tDCC_Service)i)) return TRUE; |
|---|
| 418 | } |
|---|
| 419 | return FALSE; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | if(service<=eDCC_S_CS6) |
|---|
| 423 | return DCC_IsServiceOn((tDCC_Service)service); |
|---|
| 424 | |
|---|
| 425 | return FALSE; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | |
|---|
| 429 | #endif /* SUPPORT_CC */ |
|---|
| 430 | |
|---|
| 431 | |
|---|
| 432 | /* end of file */ |
|---|