INT32 data_release_event() { INT32 ret,i; date_time start_dt, end_dt; ret = ERR_FAILED; epg_enter_mutex(); do { for(i=0; i<db_block.index; i++) { get_event_start_time(&db_block.node[i], &start_dt); get_event_end_time(&db_block.node[i], &end_dt); if(eit_compare_time(&tw1.t_min,&end_dt)<=0 ||eit_compare_time(&tw1.t_max, &start_dt)>=0 ) {// release event data if(db_block.node[i].status==NODE_ACTIVE) MTP_PRINT("%d-%d\n", start_dt.month, start_dt.day); if(db_block.node[i].status==NODE_ACTIVE && SUCCESS==__del_node(&db_block.node[i])) { MTP_PRINT("cnt:%d\n",db_block.count); ret = SUCCESS; } } } }while(ret!=SUCCESS && update_time_window(&tw0, &tw1, EVN_DATA)==SUCCESS); epg_leave_mutex(); return ret; }
// release one day event's extend data:tw0 INT32 data_release_extend() { INT32 ret,i,j; date_time start_dt, end_dt; UINT8 *tmpbuf = 0; // use to avoid memory fragment ret = ERR_FAILED; epg_enter_mutex(); MTP_PRINT("%s\n", __FUNCTION__); tmpbuf = (UINT8*)MALLOC(300); do { for(i=0; i<db_block.index; i++) { get_event_start_time(&db_block.node[i], &start_dt); get_event_end_time(&db_block.node[i], &end_dt); if(eit_compare_time(&tw0.t_min,&end_dt)<=0 ||eit_compare_time(&tw0.t_max, &start_dt)>=0 ) {// release extend data for(j=0; j<MAX_EPG_LANGUAGE_COUNT; j++) { if(db_block.node[i].status==NODE_ACTIVE && db_block.node[i].lang[j].ext_text_length!=0) { if(tmpbuf!=NULL && db_block.node[i].status==NODE_ACTIVE && db_block.node[i].lang[j].text_length!=0) {// avoid memory fragment MEMCPY(tmpbuf, db_block.node[i].lang[j].text_char, db_block.node[i].lang[j].text_length); DB_FREE(db_block.node[i].lang[j].text_char); db_block.node[i].lang[j].text_char = NULL; } MTP_PRINT("%d-%d\n", start_dt.month, start_dt.day); DB_FREE(db_block.node[i].lang[j].ext_text_char); db_block.node[i].lang[j].ext_text_char = NULL; db_block.node[i].lang[j].ext_text_length = 0; if(tmpbuf!=NULL && db_block.node[i].status==NODE_ACTIVE && db_block.node[i].lang[j].text_length!=0) {// avoid memory fragment db_block.node[i].lang[j].text_char = (UINT8*)DB_MALLOC(db_block.node[i].lang[j].text_length); MEMCPY(db_block.node[i].lang[j].text_char, tmpbuf, db_block.node[i].lang[j].text_length); } ret = SUCCESS; } } } } }while(ret!=SUCCESS && update_time_window(&tw0, &tw1, EXT_DATA)==SUCCESS); if(tmpbuf!=0) FREE(tmpbuf); epg_leave_mutex(); return ret; }
static eit_event_info_t* epg_get_schdedule_event(eit_service_info_t *eit_service_header,date_time *sch_time,INT32* event_number) { date_time cur_time,day_start,day_end,tmp,tmp_start,tmp_end; eit_event_info_t *start_evt=NULL,*ep=NULL, *tmp_ep=NULL; int i=0,day; INT32 hoff,moff,soff; SYSTEM_DATA* sys_data; UINT8 sch_day; #ifdef GET_TOTAL_SCH_EPG //only changed for shenzhou,do not filter the event UI wanted ep=eit_service_header->sch_event_header[0]; while (ep!=NULL) { if (eit_compare_time(&ep->start_time,sch_time)>=0 && // eit_compare_time(&ep->end_time,sch_time)<0) break; else if(eit_compare_time(&ep->start_time,sch_time)<=0) break; ep=ep->next; } start_evt=ep; while (ep!=NULL ) { ep=ep->next; i++; } *event_number=i; return start_evt; #endif sys_data = sys_data_get(); //if (is_time_inited()==FALSE) // eit_get_schedule_time(&cur_time); //else { if(sys_data->local_time.buseGMT) { get_UTC(&cur_time); get_STC_offset(&hoff,&moff,&soff); } else { get_STC_time(&cur_time); hoff=moff=soff=0; } } /*change sch_time -> UTC time*/ tmp=*sch_time; if (eit_compare_time(&tmp,&cur_time)>0) return NULL; day=relative_day(&cur_time, &tmp); if (day>=0 && day < SCHEDULE_DAY) { sch_day = day/4; ep=eit_service_header->sch_event_header[day/4]; if((sch_day+1) < SCHEDULE_TABLE_ID_NUM) { tmp_ep = ep; while(tmp_ep!=NULL) { if((tmp_ep->next)==NULL) break; tmp_ep = tmp_ep->next; } sch_next_event_header_addr = tmp_ep->next=eit_service_header->sch_event_header[sch_day+1]; } } else { return NULL; } convert_time_by_offset(&day_start, &tmp, hoff, moff); day_end = day_start; day_end.hour = 23; day_end.min = 59; #ifndef EPG_SHOW_BYTIME day_start.hour = 0; day_start.min = 0; #endif //soc_printf(" date_start:%04d/%02d/%02d %02d:%02d \n",day_start.year,day_start.month,day_start.day,day_start.hour,day_start.min); //soc_printf(" day_end:%04d/%02d/%02d %02d:%02d \n",day_end.year,day_end.month,day_end.day,day_end.hour,day_end.min); while(ep!=NULL) { convert_time_by_offset(&tmp_start, &(ep->start_time), hoff, moff); convert_time_by_offset(&tmp_end,&(ep->end_time), hoff, moff); //soc_printf(" tmp_start:%04d/%02d/%02d %02d:%02d \n",tmp_start.year,tmp_start.month,tmp_start.day,tmp_start.hour,tmp_start.min); //soc_printf(" tmp_end:%04d/%02d/%02d %02d:%02d \n",tmp_end.year,tmp_end.month,tmp_end.day,tmp_end.hour,tmp_end.min); if ((eit_compare_time(&tmp_start,&day_start)<=0) && (eit_compare_time(&tmp_end,&day_end)>0)) break; ep=ep->next; } start_evt=ep; while(ep!=NULL) { convert_time_by_offset(&tmp_start,&(ep->start_time), hoff, moff); //soc_printf(" !!!!tmp_start:%04d/%02d/%02d %02d:%02d \n",tmp_start.year,tmp_start.month,tmp_start.day,tmp_start.hour,tmp_start.min); if (eit_compare_time(&tmp_start,&day_end)<0) break; ep=ep->next; i++; } //convert_time_by_offset(&tmp_start,&(ep->start_time), hoff, moff); //soc_printf(" !!!!next_start:%04d/%02d/%02d %02d:%02d \n",tmp_start.year,tmp_start.month,tmp_start.day,tmp_start.hour,tmp_start.min); *event_number=i; tmp_ep->next = NULL; return start_evt; }