kb_machblue_client_data.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:24k
源码类别:

DVD

开发平台:

C/C++

  1. /*---------------------------------------------------------------------------
  2.  *  mbtv_customer_struct_managemment.c
  3.  *
  4.  *--------------------------------------------------------------------------*/
  5. #include "db.h"
  6. #include "epg.h"
  7. #include "sipsi.h"
  8. #include "timeclk.h"
  9. #include "machblue_defines.h"
  10. #include "machblue_customer.h"
  11. #include "machblue_tv_defines.h"
  12. #include "machblue_tv_customer.h"
  13. #include "machblue_porting_core.h"
  14. #include "kb_machblue_client_data.h"
  15. #include "kb_machblue_client_define.h"
  16. #include "machblue_tv_porting.h"
  17. #include "appltype.h"
  18. #include "Demand.h"
  19. #include "sr_time.h"
  20. extern UINT16 KB_DBGetSvcIDByNO(UINT8 prgType, UINT16 prgInx);
  21. kb_movie_serviceList_t _kb_mb_serviceList[list_last];
  22. kb_movie_serviceContext_t _kb_mb_serviceContext;
  23. static kb_movie_stream_t _kb_mb_serviceStream;
  24. static unsigned long  _kb_mb_service_id=0;
  25. static unsigned long _kb_mb_radio_service_id = 0;
  26. static unsigned long _kb_mb_NVOD_service_id = 0;
  27. static unsigned long  _kb_mb_event_id=0;
  28. static mb_tv_notify_f  *_kb_mb_tvNotifyFun=NULL;
  29. static void  *_kb_mb_tvClientData=NULL;
  30. static mb_error_t kb_machblue_service_list_all_tv_init(void);
  31. static mb_error_t kb_machblue_service_list_radio_init(void);
  32. //void kb_machblue_search_schedule(void);
  33. extern int KB_TimeGetCurTime(time_t  *plTime);
  34. unsigned short getServiceIndex(unsigned short serviceID)
  35. {
  36. unsigned short index, videoCnt;
  37. videoCnt=(unsigned short )_kb_mb_serviceList[all_tv_list].count;
  38. for(index=0;index<videoCnt;index++)
  39. {
  40. if(_kb_mb_serviceList[all_tv_list].services[index].info.display_id==serviceID)
  41. break;
  42. }
  43. return index;
  44. }
  45. /**
  46. *This function initialize the present and the following event
  47. *@return MB_SUCCESS on success, MB_FAILURE on failure.
  48. */
  49. mb_error_t KB_mb_PF_Update(KB_SIEitPF *Cur_ptEitPf,KB_SIEitPF *Fol_ptEitPf)
  50. {
  51. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.attributes.start_time = Cur_ptEitPf->start_time;
  52. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.attributes.event_info.duration= Cur_ptEitPf->duration;
  53. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.attributes.event_info.id= Cur_ptEitPf->event_id;
  54. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.attributes.event_info.name,Cur_ptEitPf->chinese.event_name,51);
  55. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.attributes.event_info.short_desc,Cur_ptEitPf->chinese.text,128);
  56. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)].current_event.service=&_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Cur_ptEitPf->service_id)];
  57. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.attributes.start_time = Fol_ptEitPf->start_time;
  58. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.attributes.event_info.duration= Fol_ptEitPf->duration;
  59. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.attributes.event_info.id= Fol_ptEitPf->event_id;
  60. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.attributes.event_info.name,Fol_ptEitPf->chinese.event_name,51);
  61. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.attributes.event_info.short_desc,Fol_ptEitPf->chinese.text,128);   
  62. _kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)].following_event.service= &_kb_mb_serviceList[all_tv_list].services[getServiceIndex(Fol_ptEitPf->service_id)];
  63. //KB_MB_lc_2_movie_Post_Task();
  64. KB_MB_lc_2_movie_word_Post_Task(1);
  65. return MB_SUCCESS;
  66. }
  67. /**
  68.  * This function init the service list information. 
  69.  * @return MB_SUCCESS on success, MB_FAILURE on failure.
  70.  */
  71. mb_error_t kb_mb_service_list_init(void)
  72. {
  73. kb_machblue_service_list_all_tv_init();
  74. kb_machblue_service_list_radio_init();
  75. return MB_SUCCESS;
  76. }
  77. mb_error_t kb_mb_schdule_clear(kb_movie_service_t *service)
  78. {
  79. unsigned char index;
  80. for(index=0;index<7;index++)
  81. {
  82. mb_free(service->evs[index].events);
  83. service->evs[index].evtCount=0;
  84. }
  85. return MB_SUCCESS;
  86. }
  87. mb_error_t kb_mb_service_list_clear(void)
  88. {
  89. unsigned short index;
  90. _kb_mb_service_id=0;
  91. _kb_mb_event_id=0;
  92. //clear
  93. for(index=0;index<_kb_mb_serviceList[all_tv_list].count;index++)
  94. {
  95. kb_mb_schdule_clear(&(_kb_mb_serviceList[all_tv_list].services[index]));
  96. mb_memset(&(_kb_mb_serviceList[all_tv_list].services[index]),0,sizeof(kb_movie_service_t));
  97. }
  98. mb_free(_kb_mb_serviceList[all_tv_list].services);
  99. mb_memset(&(_kb_mb_serviceList[all_tv_list]),0,sizeof(kb_movie_serviceList_t));
  100. for(index=0;index<_kb_mb_serviceList[radio_list].count;index++)
  101. {
  102. kb_mb_schdule_clear(&(_kb_mb_serviceList[radio_list].services[index]));
  103. mb_memset(&(_kb_mb_serviceList[radio_list].services[index]),0,sizeof(kb_movie_service_t));
  104. }
  105. mb_free(_kb_mb_serviceList[radio_list].services);
  106. mb_memset(&(_kb_mb_serviceList[radio_list]),0,sizeof(kb_movie_serviceList_t));
  107. return MB_SUCCESS;
  108. }
  109. mb_error_t kb_mb_service_list_reset(void)
  110. {
  111. //clear
  112. kb_mb_service_list_clear();
  113. //add
  114. kb_mb_service_list_init();
  115. //search
  116. //kb_machblue_search_schedule();
  117. return MB_SUCCESS;
  118. }
  119. mb_error_t kb_mb_service_list_resetEx(void)
  120. {
  121. //clear
  122. kb_mb_service_list_clear();
  123. //add
  124. kb_mb_service_list_init();
  125. kb_mb_chledit_list_reset();
  126. return MB_SUCCESS;
  127. }
  128. mb_error_t kb_mb_event_schedule_reset(void)
  129. {
  130. unsigned short index;
  131. //clear
  132. for(index=0;index<_kb_mb_serviceList[all_tv_list].count;index++)
  133. {
  134. kb_mb_schdule_clear(&(_kb_mb_serviceList[all_tv_list].services[index]));
  135. }
  136. for(index=0;index<_kb_mb_serviceList[radio_list].count;index++)
  137. {
  138. kb_mb_schdule_clear(&(_kb_mb_serviceList[radio_list].services[index]));
  139. }
  140. //search
  141. //kb_machblue_search_schedule();
  142. return MB_SUCCESS;
  143. }
  144. static mb_error_t kb_machblue_service_list_all_tv_init(void)
  145. {
  146. unsigned short videoCnt=0,index;
  147. UINT16 service_ID;
  148. unsigned char *service_name;
  149. _kb_mb_serviceList[all_tv_list].info.id=0;
  150. mb_memcpy(_kb_mb_serviceList[all_tv_list].info.name,"All Service",11);
  151. mb_memcpy(_kb_mb_serviceList[all_tv_list].info.logo_url," ",1);
  152. mb_memcpy(_kb_mb_serviceList[all_tv_list].info.extra_info," ",1);
  153. _kb_mb_serviceList[all_tv_list].services=NULL;
  154. _kb_mb_serviceList[all_tv_list].count=0;
  155. //_kb_mb_serviceList[all_tv_list].svl_manager=NULL;
  156. videoCnt=KB_DBGetPrgTotal(DTVPRG);
  157. if(videoCnt==0)
  158. return MB_SUCCESS;
  159. //malloc service memory
  160. _kb_mb_serviceList[all_tv_list].services=mb_malloc(sizeof(kb_movie_service_t)*videoCnt);
  161. if(_kb_mb_serviceList[all_tv_list].services==NULL)
  162. {
  163. mb_printf("n[Machblue]:Service list 1 init no memory.");
  164.        return MB_FAILURE;
  165. }
  166. mb_memset(_kb_mb_serviceList[all_tv_list].services,0,sizeof(kb_movie_service_t)*videoCnt);
  167. //insert video service
  168. for(index=0;index<videoCnt;index++)
  169. {
  170. //service info
  171. service_ID = KB_DBGetSvcIDByNO(DTVPRG, index);
  172. service_name = KB_DBGetPrgName(DTVPRG,index+1);
  173. _kb_mb_serviceList[all_tv_list].services[index].info.id=(int)_kb_mb_service_id++;
  174. _kb_mb_serviceList[all_tv_list].services[index].info.display_id=service_ID;//gPrgAllInfo.gDTVInfo.PgmList[index].SvcID;
  175. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[index].info.name,service_name,MB_TV_SERVICE_NAME_LENGTH);
  176. _kb_mb_serviceList[all_tv_list].services[index].info.name[15]='';
  177. mb_memcpy(_kb_mb_serviceList[all_tv_list].services[index].info.logo_url,"0000 ",5);
  178. //mb_memcpy(_kb_mb_serviceList[all_tv_list].services[index].info.name[15],"",1);
  179. //mb_printf("nProgram [%d] name is [%s]",index+1,_kb_mb_serviceList[all_tv_list].services[index].info.name);
  180. _kb_mb_serviceList[all_tv_list].services[index].info.type=MB_TV_DIGITAL_SERVICE;
  181.    _kb_mb_serviceList[all_tv_list].services[index].info.source_info.id=0;
  182. _kb_mb_serviceList[all_tv_list].services[index].info.source_info.type=MB_TV_CABLE_SOURCE;
  183. //service state
  184. _kb_mb_serviceList[all_tv_list].services[index].state=MB_TV_SERVICE_DISCONNECTED;
  185. //authorization
  186. _kb_mb_serviceList[all_tv_list].services[index].auth=MB_TV_AF_AUTHORIZED;
  187. //
  188. _kb_mb_serviceList[all_tv_list].services[index].serInfo.tsID=KB_DBGetPrgTsID(DTVPRG,index+1);
  189. //event
  190. mb_memset(&(_kb_mb_serviceList[all_tv_list].services[index].evs),0,sizeof(kb_movie_eventSchedule_t));
  191. mb_memset(&(_kb_mb_serviceList[all_tv_list].services[index].current_event),0,sizeof(kb_movie_event_t));
  192. mb_memset(&(_kb_mb_serviceList[all_tv_list].services[index].following_event),0,sizeof(kb_movie_event_t));
  193. //pointer
  194. _kb_mb_serviceList[all_tv_list].services[index].svl=&_kb_mb_serviceList[all_tv_list];
  195. _kb_mb_serviceList[all_tv_list].services[index].svc=&_kb_mb_serviceContext;
  196. _kb_mb_serviceList[all_tv_list].services[index].streams=&_kb_mb_serviceStream;
  197. _kb_mb_serviceList[all_tv_list].services[index].current_event.service=&_kb_mb_serviceList[all_tv_list].services[index];
  198. _kb_mb_serviceList[all_tv_list].services[index].current_event.evs=&_kb_mb_serviceList[all_tv_list].services[index].evs[0];
  199. _kb_mb_serviceList[all_tv_list].services[index].following_event.service=&_kb_mb_serviceList[all_tv_list].services[index];
  200. _kb_mb_serviceList[all_tv_list].services[index].following_event.evs=&_kb_mb_serviceList[all_tv_list].services[index].evs[0];
  201. //service count
  202. _kb_mb_serviceList[all_tv_list].count+=1;
  203.      }
  204. return MB_SUCCESS;
  205. }
  206. static mb_error_t kb_machblue_service_list_radio_init(void)
  207. {
  208. unsigned short audioCnt=0,index;
  209. UINT16 service_ID;
  210. unsigned char *service_name;
  211. _kb_mb_serviceList[radio_list].info.id=1;
  212. mb_memcpy(_kb_mb_serviceList[radio_list].info.name,"Radio Service",13);
  213. mb_memcpy(_kb_mb_serviceList[radio_list].info.logo_url," ",1);
  214. mb_memcpy(_kb_mb_serviceList[radio_list].info.extra_info," ",1);
  215. _kb_mb_serviceList[radio_list].services=NULL;
  216. _kb_mb_serviceList[radio_list].count=0;
  217. //_kb_mb_serviceList[all_tv_list].svl_manager=NULL;
  218. audioCnt=KB_DBGetPrgTotal(RADIOPRG);
  219. if(audioCnt==0)
  220. return MB_SUCCESS;
  221. //malloc service memory
  222. _kb_mb_serviceList[radio_list].services=mb_malloc(sizeof(kb_movie_service_t)*audioCnt);
  223. if(_kb_mb_serviceList[radio_list].services==NULL)
  224. {
  225. mb_printf("n[Machblue]:Service list 2 init no memory.");
  226.        return MB_FAILURE;
  227. }
  228. mb_memset(_kb_mb_serviceList[radio_list].services,0,sizeof(kb_movie_service_t)*audioCnt);
  229. //insert video service
  230. for(index=0;index<audioCnt;index++)
  231. {
  232. //service info
  233. service_ID = KB_DBGetSvcIDByNO(RADIOPRG, index);
  234. service_name = KB_DBGetPrgName(RADIOPRG,index+1);
  235. _kb_mb_serviceList[radio_list].services[index].info.id=(int)_kb_mb_radio_service_id++;
  236. _kb_mb_serviceList[radio_list].services[index].info.display_id=service_ID;//gPrgAllInfo.gDTVInfo.PgmList[index].SvcID;
  237. mb_memcpy(_kb_mb_serviceList[radio_list].services[index].info.name,service_name,MB_TV_SERVICE_NAME_LENGTH);
  238. mb_memcpy(_kb_mb_serviceList[radio_list].services[index].info.logo_url,"0000 ",5);
  239. _kb_mb_serviceList[radio_list].services[index].info.type=MB_TV_DIGITAL_SERVICE;
  240.    _kb_mb_serviceList[radio_list].services[index].info.source_info.id=0;
  241. _kb_mb_serviceList[radio_list].services[index].info.source_info.type=MB_TV_CABLE_SOURCE;
  242. //service state
  243. _kb_mb_serviceList[radio_list].services[index].state=MB_TV_SERVICE_DISCONNECTED;
  244. //authorization
  245. _kb_mb_serviceList[radio_list].services[index].auth=MB_TV_AF_AUTHORIZED;
  246. //
  247. _kb_mb_serviceList[radio_list].services[index].serInfo.tsID=KB_DBGetPrgTsID(RADIOPRG,index+1);
  248. //event
  249. mb_memset(&(_kb_mb_serviceList[radio_list].services[index].evs),0,sizeof(kb_movie_eventSchedule_t));
  250. mb_memset(&(_kb_mb_serviceList[radio_list].services[index].current_event),0,sizeof(kb_movie_event_t));
  251. mb_memset(&(_kb_mb_serviceList[radio_list].services[index].following_event),0,sizeof(kb_movie_event_t));
  252. //pointer
  253. _kb_mb_serviceList[radio_list].services[index].svl=&_kb_mb_serviceList[radio_list];
  254. _kb_mb_serviceList[radio_list].services[index].svc=&_kb_mb_serviceContext;
  255. _kb_mb_serviceList[radio_list].services[index].streams=&_kb_mb_serviceStream;
  256. _kb_mb_serviceList[radio_list].services[index].current_event.service=&_kb_mb_serviceList[radio_list].services[index];
  257. _kb_mb_serviceList[radio_list].services[index].current_event.evs=&_kb_mb_serviceList[radio_list].services[index].evs[0];
  258. _kb_mb_serviceList[radio_list].services[index].following_event.service=&_kb_mb_serviceList[radio_list].services[index];
  259. _kb_mb_serviceList[radio_list].services[index].following_event.evs=&_kb_mb_serviceList[radio_list].services[index].evs[0];
  260. //service count
  261. _kb_mb_serviceList[radio_list].count+=1;
  262.      }
  263. return MB_SUCCESS;
  264. }
  265. mb_error_t kb_machblue_nvod_flag(time_t start_time,time_t duration )
  266. {
  267. time_t plTime, end_time;
  268. //KB_TimeGetCurTime(&plTime);
  269. plTime = KB_TimeGetCurGMTTime();
  270. end_time = start_time + duration;
  271. //mb_printf("nptime = %ld,start = %ld, end = %ld",plTime, start_time, end_time);
  272. if ((plTime>=start_time)&&(plTime<end_time))
  273. {
  274. /*
  275. {
  276. char out[30];
  277. ConvertTimeStampToHHMMSS(plTime, out);
  278. mb_printf("n[machblue]hhmmss is %sn",out);
  279. ConvertTimeStampToDateString(plTime, out);
  280. mb_printf("n[machblue]yymmdd is %sn",out);
  281. }
  282. */
  283. return MB_SUCCESS;
  284. }
  285. return MB_FAILURE;
  286. }
  287. mb_error_t kb_machblue_service_list_NVOD_init(UINT8 count,KB_NVOD_Info*pNVOD[])
  288. {
  289. unsigned short NVODCnt=0,index;
  290. char *service_name;
  291. int i,j,k=0;
  292. kb_movie_service_t *service;
  293. _kb_mb_serviceList[NVOD_list].info.id=2;
  294. mb_memcpy(_kb_mb_serviceList[NVOD_list].info.name,"NVOD Service",12);
  295. mb_memcpy(_kb_mb_serviceList[NVOD_list].info.logo_url," ",2);
  296. mb_memcpy(_kb_mb_serviceList[NVOD_list].info.extra_info," ",2);
  297. _kb_mb_serviceList[NVOD_list].services=NULL;
  298. _kb_mb_serviceList[NVOD_list].count=0;
  299. for(index = 0;index<count;index++)
  300. {
  301. NVODCnt = NVODCnt+pNVOD[index]->RefEventNum;
  302. }
  303. if(NVODCnt==0)
  304. return MB_SUCCESS;
  305. _kb_mb_serviceList[NVOD_list].services=mb_malloc(sizeof(kb_movie_service_t)*NVODCnt);
  306. if(_kb_mb_serviceList[NVOD_list].services==NULL)
  307. {
  308. mb_printf("n[Machblue]:Service list 2 init no memory.");
  309.        return MB_FAILURE;
  310. }
  311. //malloc service memory
  312. mb_memset(_kb_mb_serviceList[NVOD_list].services,0,sizeof(kb_movie_service_t)*NVODCnt);
  313. _kb_mb_NVOD_service_id = 0;
  314. for(index = 0;index<count;index++)
  315. {
  316. for(i = 0;i < pNVOD[index]->RefEventNum;i++,k++)
  317. {
  318. //service info
  319. //service_ID = i;
  320. service_name = pNVOD[index]->RefEventData[i].PrgName;
  321. _kb_mb_serviceList[NVOD_list].services[k].info.id=(int)_kb_mb_NVOD_service_id++;
  322. _kb_mb_serviceList[NVOD_list].services[k].info.display_id=k;//gPrgAllInfo.gDTVInfo.PgmList[index].SvcID;
  323. mb_memcpy(_kb_mb_serviceList[NVOD_list].services[k].info.name,service_name,MB_TV_SERVICE_NAME_LENGTH);
  324. _kb_mb_serviceList[NVOD_list].services[k].info.name[15]='';
  325. //mb_printf("nzhengyang_NVOD's name is %s,ID is %dn",pNVOD[index]->RefEventData[i].PrgName,k);
  326. //mb_printf("nwisco_NVOD's name is %sn",_kb_mb_serviceList[NVOD_list].services[i].info.name);
  327. _kb_mb_serviceList[NVOD_list].services[k].info.type=MB_TV_DIGITAL_SERVICE;
  328.    _kb_mb_serviceList[NVOD_list].services[k].info.source_info.id=0;
  329. _kb_mb_serviceList[NVOD_list].services[k].info.source_info.type=MB_TV_CABLE_SOURCE;
  330. //service state
  331. _kb_mb_serviceList[NVOD_list].services[k].state=MB_TV_SERVICE_DISCONNECTED;
  332. //authorization
  333. _kb_mb_serviceList[NVOD_list].services[k].auth=MB_TV_AF_AUTHORIZED;
  334. //event
  335. mb_memset(&(_kb_mb_serviceList[NVOD_list].services[k].evs),0,sizeof(kb_movie_eventSchedule_t));
  336. mb_memset(&(_kb_mb_serviceList[NVOD_list].services[k].current_event),0,sizeof(kb_movie_event_t));
  337. mb_memset(&(_kb_mb_serviceList[NVOD_list].services[k].following_event),0,sizeof(kb_movie_event_t));
  338. //pointer
  339. _kb_mb_serviceList[NVOD_list].services[k].svl=&_kb_mb_serviceList[NVOD_list];
  340. _kb_mb_serviceList[NVOD_list].services[k].svc=&_kb_mb_serviceContext;
  341. _kb_mb_serviceList[NVOD_list].services[k].streams=&_kb_mb_serviceStream;
  342. //service count
  343. _kb_mb_serviceList[NVOD_list].count+=1;
  344. service = &_kb_mb_serviceList[NVOD_list].services[k];
  345. //_kb_mb_event_id = 0;
  346. if (pNVOD[index]->RefEventData[i].TimeNum == 0)
  347. {
  348. continue;
  349. }
  350. service->evs[0].evtCount=pNVOD[index]->RefEventData[i].TimeNum;
  351. if (service->evs[0].evtCount > 30)
  352. service->evs[0].evtCount = 30;
  353. service->evs[0].events=mb_malloc((mb_size_t)(sizeof(kb_movie_event_t)*service->evs[0].evtCount));
  354. for(j = 0;j <service->evs[0].evtCount; j++)
  355. {
  356. service->evs[0].events[j].attributes.event_info.id=j;//_kb_mb_event_id++;
  357. service->evs[0].events[j].attributes.event_info.duration=pNVOD[index]->RefEventData[i].durTime;
  358. mb_memcpy(service->evs[0].events[j].attributes.event_info.name, "",1);
  359. mb_memcpy(service->evs[0].events[j].attributes.event_info.short_desc,
  360.  pNVOD[index]->RefEventData[i].PrgTxt,
  361.  MB_TV_EVENT_DESCRIPTION_LENGTH);
  362. service->evs[0].events[j].attributes.event_info.short_desc[MB_TV_EVENT_DESCRIPTION_LENGTH]='';
  363. service->evs[0].events[j].attributes.start_time=pNVOD[index]->RefEventData[i].TimeNode[j].startTime;//+8*3600;
  364. service->evs[0].events[j].attributes.cost=0;
  365. service->evs[0].events[j].attributes.expiration_date=0;
  366. service->evs[0].events[j].auth=MB_TV_AF_AUTHORIZED;
  367. service->evs[0].events[j].day=0;
  368. service->evs[0].events[j].service=service;
  369. service->evs[0].events[j].evs=&service->evs[0];
  370. if(kb_machblue_nvod_flag((time_t)pNVOD[index]->RefEventData[i].TimeNode[j].startTime,(time_t)pNVOD[index]->RefEventData[i].durTime))
  371. {
  372. //mb_printf("n在播节目%d == %s",j,service->info.name);
  373. //{
  374. // char out[30];
  375. // ConvertTimeStampToHHMMSS((time_t)service->evs[0].events[j].attributes.start_time, out);
  376. // mb_printf("n[machblue]hhmmss is %sn",out);
  377. // ConvertTimeStampToDateString((time_t)service->evs[0].events[j].attributes.start_time, out);
  378. // mb_printf("n[machblue]yymmdd is %sn",out);
  379. //}
  380. mb_memcpy((void*)service->evs[0].events[j].attributes.event_info.genre,"Y",2);
  381. }
  382. else
  383. mb_memcpy((void*)service->evs[0].events[j].attributes.event_info.genre,"N",2);
  384. }
  385. }
  386. }
  387. /*
  388. for(i=0;i<_kb_mb_serviceList[NVOD_list].services[1].evs[0].evtCount;i++)
  389. {
  390. mb_printf("n[machblue]service[%d]=id = %d,[%d]=name = %sn",i,_kb_mb_serviceList[NVOD_list].services[1].info.id,i,_kb_mb_serviceList[NVOD_list].services[1].info.name);
  391. mb_printf("n[machblue]event[%d]=id = %d,[%d]=name = %ldn",i,_kb_mb_serviceList[NVOD_list].services[1].evs[0].events[i].attributes.event_info.id,i,_kb_mb_serviceList[NVOD_list].services[1].evs[0].events[i].attributes.start_time);
  392. }
  393. */
  394. return MB_SUCCESS;
  395. }
  396. /**
  397.  * This function delete the service list information. 
  398.  * @return MB_SUCCESS on success, MB_FAILURE on failure.
  399.  */
  400. mb_error_t kb_mb_service_list_delete(void)
  401. {
  402. return MB_SUCCESS;
  403. }
  404. /**
  405.  * This function get the service list pointer. 
  406.  * @return pointer of service list.
  407.  */
  408. kb_movie_serviceList_t *kb_mb_service_list_get(void)
  409. {
  410. return _kb_mb_serviceList;
  411. }
  412. /**
  413.  * This function create event schedule of service. 
  414.  * service < service which event belong to >
  415.  
  416.  * @return MB_SUCCESS on success, MB_FAILURE on failure.
  417.  */
  418. mb_error_t kb_mb_event_schedule_create(kb_movie_service_t *service)
  419. {
  420. KB_EPGDayInfo  *pDayInfo;
  421. unsigned long  i,j,evtCount=0,count=0;
  422. time_t plTime;
  423. //U32 hour, min, seconds;
  424. //U32 y, m, d;
  425. int index;
  426. if(service==NULL)
  427. {
  428. mb_printf("n[Machblue]:TV notification send NULL.");
  429. return MB_FAILURE;
  430. }
  431. KB_TimeGetCurTime(&plTime);
  432. for(i=0;i<7;i++)
  433. {
  434. pDayInfo=(KB_EPGDayInfo *)KD_EPGGetSCH(KB_EPG_GetTsNumFromTsId(service->serInfo.tsID),service->info.display_id,i);
  435. evtCount=pDayInfo->nEventCount;
  436. count+=evtCount;
  437. if(evtCount==0)
  438. continue;
  439. service->evs[i].events=mb_malloc((mb_size_t)(sizeof(kb_movie_event_t)*evtCount));
  440. service->evs[i].service=service;
  441. service->evs[i].evtCount=evtCount;
  442. //add event information
  443. for(j=0;j<pDayInfo->nEventCount;j++)
  444. {
  445. service->evs[i].events[j].attributes.event_info.id=(int)_kb_mb_event_id++;
  446. service->evs[i].events[j].attributes.event_info.duration=pDayInfo->ptEvent[j].duration;
  447. mb_memcpy(service->evs[i].events[j].attributes.event_info.name,
  448.  pDayInfo->ptEvent[j].chinese.event_name,
  449.  sizeof(pDayInfo->ptEvent[j].chinese.event_name));
  450. mb_memcpy(service->evs[i].events[j].attributes.event_info.short_desc,
  451.  pDayInfo->ptEvent[j].chinese.text,
  452.  MB_TV_EVENT_DESCRIPTION_LENGTH);
  453. service->evs[i].events[j].attributes.start_time=pDayInfo->ptEvent[j].start_time;
  454. service->evs[i].events[j].attributes.cost=0;
  455. service->evs[i].events[j].attributes.expiration_date=0;
  456. service->evs[i].events[j].auth=MB_TV_AF_AUTHORIZED;
  457. service->evs[i].events[j].day=(unsigned char)i;
  458. service->evs[i].events[j].service=service;
  459. service->evs[i].events[j].evs=&service->evs[i];
  460. if(service->svl->info.id==0)
  461. {
  462. for(index = 0; index<_kb_mb_serviceList[all_tv_list].count;index++)
  463. {
  464. if(_kb_mb_serviceList[all_tv_list].services[index].info.display_id==service->info.display_id)//gPrgAllInfo.gDTVInfo.PgmList[index].SvcID;
  465. break;
  466. }
  467. if(KB_CheckDmdEnt(index,(int)j,(int)i,(int)DT_EPG))
  468. {
  469. mb_memcpy((void*)service->evs[i].events[j].attributes.event_info.genre,"Y",2);
  470. }
  471. else
  472. mb_memcpy((void*)service->evs[i].events[j].attributes.event_info.genre,"N",2);
  473. }
  474. }
  475. }
  476. //mb_printf("nkb_mb_event_schedule_create service [%s] event count[%d]",service->info.name,count);
  477. return MB_SUCCESS;
  478. }
  479. /**
  480.  * This function init the service context information. 
  481.  * @return MB_SUCCESS on success, MB_FAILURE on failure.
  482.  */
  483. mb_error_t kb_mb_service_context_init(void)
  484. {
  485. mb_memset(&_kb_mb_serviceContext,0,sizeof(_kb_mb_serviceContext));
  486. _kb_mb_serviceContext.info.id=1;
  487. //_kb_mb_serviceContext.info.
  488. _kb_mb_serviceContext.service=&_kb_mb_serviceList[all_tv_list].services[0];
  489. return MB_SUCCESS;
  490. }
  491. void kb_mb_service_context_evaluation(int serviceIndex,int service_type)
  492. {
  493. int ser_list_type;
  494.                  
  495. if(service_type == DTVPRG)
  496. ser_list_type =all_tv_list;
  497. if (service_type == RADIOPRG)
  498. ser_list_type = radio_list;
  499. if(serviceIndex>0)
  500. _kb_mb_serviceContext.service=&_kb_mb_serviceList[ser_list_type].services[serviceIndex-1];
  501. }
  502. /**
  503.  * This function get the service context pointer. 
  504.  * @return pointer of service context.
  505.  */
  506. kb_movie_serviceContext_t *kb_mb_service_context_get(void)
  507. {
  508. return &_kb_mb_serviceContext;
  509. }
  510. /**
  511.  * This function set notification and client data. 
  512.  * @return none.
  513.  */
  514. void kb_mb_notification_set(mb_tv_notify_f *notify_fct,void *clientdata)
  515. {
  516. _kb_mb_tvNotifyFun=notify_fct;
  517. _kb_mb_tvClientData=clientdata;
  518. }
  519. /**
  520.  * This function send notification to machblue player. 
  521.  * @return MB_SUCCESS on success, MB_FAILURE on failure.
  522.  */
  523. mb_error_t kb_mb_notification_send(mb_tv_notif_reason_t reason,mb_args_t *args)
  524. {
  525. if(_kb_mb_tvNotifyFun==NULL)
  526. {
  527. mb_printf("n[Machblue]:TV notification send NULL.");
  528. return MB_FAILURE;
  529. }
  530. // invokes native callback
  531. return _kb_mb_tvNotifyFun(reason,args,_kb_mb_tvClientData);
  532. }