kb_watch.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:5k
- #include "swf.h"
- #include "kb_watch.h"
- #include "time.h"
- #include "osp.h"
- #include "stbmoviesinfo.h"
- #include "XmlStbInfo.h"
- #include "kb_dc_task.h"
- #include "avplay.h"
- #include "pub_st.h"
- #include "timeclk.h"
- #include "kb_machblue_client.h"
- void KB_WatchTask(void)
- {
- time_t curTime, end_time;
- KB_OSPMsgNode msg;
- KB_MovieInfoNode *movieInfo=NULL;
- unsigned short curTSID,curServiceID;
- int x;
- unsigned long year,month,day,hour,minter,second;
- unsigned char verSTB=0,verDC=0;
- static bool updateInfo=false;
- while(1)
- {
- KB_OSPTaskDelay(2000);
- KB_TimeGetCurTime(&curTime);
- #if 0
- ConvertTimeStampToDate(curTime,&year,&month,&day);
- ConvertTimeStampToTime(curTime,&hour,&minter,&second);
- mb_printf("nKB_WatchTask current time[%d],year[%d],month[%d],day[%d],hour[%d],minter[%d],second[%d]",curTime,year,month,day,hour,minter,second);
- #endif
- movieInfo=KB_GetXmlMovieInfoHead();
- while(movieInfo!=NULL)
- {
- //数据广播数据文件
- if(((movieInfo->st_MovieInfo.m_cfgType==kb_dc_data_broadcast)||
- (movieInfo->st_MovieInfo.m_cfgType==kb_dc_data_vote))&&
- (movieInfo->st_MovieInfo.m_dataGet==kb_dc_data_no))
- {
- movieInfo->st_MovieInfo.m_dataGet=kb_dc_data_searching;
- msg.Word1=kb_db_data_get;
- msg.Word2=(UINT32)movieInfo;
- KB_DcMsgSend(&msg);
- }
- //交互广告影片文件
- else if((movieInfo->st_MovieInfo.m_cfgType==kb_dc_adv_alter)&&
- (movieInfo->st_MovieInfo.m_dataGet==kb_dc_data_no))
- {
- movieInfo->st_MovieInfo.m_dataGet=kb_dc_data_searching;
- msg.Word1=kb_dc_movie_get;
- msg.Word2=(UINT32)movieInfo;
- KB_DcMsgSend(&msg);
- }
- //界面更新影片文件
- else if((movieInfo->st_MovieInfo.m_cfgType==kb_dc_swf_update)&&
- (movieInfo->st_MovieInfo.m_dataGet==kb_dc_data_no))
- {
- verDC=movieInfo->st_MovieInfo.m_reserve2;
-
- //下发的版本号无效
- if((verDC==0)||(verDC==255))
- {
- movieInfo->st_MovieInfo.m_dataGet=kb_dc_data_searched;
- }
- else
- {
- if(movieInfo->st_MovieInfo.m_reserve1==kb_movie_adve_logo)
- verSTB=KB_SWF_VersionGet(0);
- else
- verSTB=KB_SWF_VersionGet(1);
- if(((verSTB>=250)&&(verSTB!=verDC))||(verSTB<verDC))
- {
- movieInfo->st_MovieInfo.m_dataGet=kb_dc_data_searching;
- msg.Word1=kb_dc_movie_get;
- msg.Word2=(UINT32)movieInfo;
- KB_DcMsgSend(&msg);
- }
- else
- {
- movieInfo->st_MovieInfo.m_dataGet=kb_dc_data_searched;
- }
- }
- }
- //插播广告
- else if(movieInfo->st_MovieInfo.m_cfgType==kb_dc_adv_rt)
- {
- if(KB_DTVGetCurPrgInfo(&curTSID,&curServiceID)==FALSE)
- {
- printf("nKB_DcTask get current program information error.");
- }
- else
- {
- //if((movieInfo->st_MovieInfo.m_tsID==curTSID)&&(movieInfo->st_MovieInfo.m_serviceID==curServiceID))
- if(movieInfo->st_MovieInfo.m_serviceID==curServiceID)
- {
- end_time = movieInfo->st_MovieInfo.m_nStartTime + (movieInfo->st_MovieInfo.m_nTimeStep*(movieInfo->st_MovieInfo.m_nTimesPlayed-1) + 10);
- if( (curTime>movieInfo->st_MovieInfo.m_nStartTime)&&(curTime<=end_time) )
- {
- x = (curTime - movieInfo->st_MovieInfo.m_nStartTime)%(movieInfo->st_MovieInfo.m_nTimeStep);
- if((x>=0)&&(x<=10))
- {
- msg.Word1 = kb_dc_movie_play;
- msg.Word2=(UINT32)movieInfo;
- KB_DcMsgSend(&msg);
- }
- }
- }
- }
- }
-
- movieInfo=movieInfo->m_pNext;
- }
-
- if(!updateInfo)
- {
- movieInfo=KB_GetXmlMovieInfoHead();
- if(movieInfo==NULL)
- continue;
- else
- updateInfo=true;
-
- while(movieInfo!=NULL)
- {
- if((movieInfo->st_MovieInfo.m_cfgType==kb_dc_swf_update)&&
- (movieInfo->st_MovieInfo.m_dataGet==kb_dc_data_no))
- {
- updateInfo=false;
- break;
- }
- movieInfo=movieInfo->m_pNext;
- }
- if(updateInfo)
- {
- KB_MovieInfoNode *tmpInfo=NULL,*p1=tmpInfo,*p2;
-
- movieInfo=KB_GetXmlMovieInfoHead();
- while(movieInfo!=NULL)
- {
- //生成链表
- if((movieInfo->st_MovieInfo.m_cfgType==kb_dc_swf_update)&&
- (movieInfo->st_MovieInfo.m_pData!=NULL))
- {
- p2=(KB_MovieInfoNode*)mb_malloc(sizeof(KB_MovieInfoNode));
- mb_memcpy(p2,movieInfo,sizeof(KB_MovieInfoNode));
- p2->st_MovieInfo.m_pData=(unsigned char*)mb_malloc(p2->st_MovieInfo.m_nSize);
- mb_memcpy(p2->st_MovieInfo.m_pData,movieInfo->st_MovieInfo.m_pData,p2->st_MovieInfo.m_nSize);
- if(tmpInfo==NULL)
- {
- tmpInfo=p2;
- p1->m_pNext=NULL;
- }
- else
- {
- p1->m_pNext=p2;
- p1=p2;
- p1->m_pNext=NULL;
- }
- }
-
- movieInfo=movieInfo->m_pNext;
- }
- KB_SWF_Update(tmpInfo);
- while(tmpInfo!=NULL)
- {
- mb_free(tmpInfo->st_MovieInfo.m_pData);
- p1=tmpInfo;
- tmpInfo=tmpInfo->m_pNext;
- mb_free(p1);
- }
- }
- }
- }
- }
- void KB_WatchTaskInit(void)
- {
- unsigned long TaskId;
-
- KB_OSPTaskInit("KB_WatchTask", 8*1024,(void(*)(void *))KB_WatchTask,
- 1*16,NULL,&TaskId);
- }