#include #include #include #include #include #include #include #define MAX_PROGRAM 32 class DMXTSPES:public testing::Test{ public : HANDLE flt; HANDLE eventHandle; INT dmxid; BYTE*data; static void SetUpTestCase(){ NGLTunerParam tp;//TRANSPONDER tp; tvutils::GetTuningParams(tp); nglSysInit(); nglTunerInit(); nglTunerLock(0,&tp); nglDmxInit(); printf("DMX::SetUpTestCase\r\n"); } static void TearDownTestCase() { printf("DMX::TearDownTestCase\r\n"); } virtual void SetUp(){ flt=0; dmxid=0; data=(BYTE*)nglMalloc(4096); eventHandle=nglCreateEvent(0,TRUE); printf("data=%p,handle=%p\r\n",data,eventHandle); } virtual void TearDown(){ if(0!=flt) nglFreeSectionFilter(flt); nglFree(data); nglDestroyEvent(eventHandle); } int GetPMTPids(BYTE*pmt,USHORT*pmtpids){ int seclen=((pmt[1]&0x0F)<<8)|pmt[2]; int cnt=0; BYTE*p=pmt+8; unsigned short* pids=pmtpids; for(;pstream_type=des[0]; pids[i]=(des[1]&0x1F)<<8|des[2];//es->pid=(des[1]&0x1F)<<8|des[2]; des+=dlen+5;//es->getLength()+5; } return i; } static void SectionCounterCBK(HANDLE dwVaFilterHandle,const BYTE *pBuffer,UINT uiBufferLength, void *pUserData){ INT*counter=(INT*)pUserData; (*counter)+=1; printf("SectionCounterCBK datalen=%d\r\n",uiBufferLength); } TEST_F(DMXTSPES,AllocFilter_1){ flt=nglAllocateSectionFilter(dmxid,0x10,SectionCounterCBK,NULL,DMX_TS); ASSERT_NE((HANDLE)nullptr,flt); ASSERT_EQ(nglFreeSectionFilter(flt),E_OK); } TEST_F(DMXTSPES,AllocFilter_2){ flt=nglAllocateSectionFilter(dmxid,0x10,SectionCounterCBK,NULL,DMX_PES); ASSERT_NE((HANDLE)nullptr,flt); ASSERT_EQ(nglFreeSectionFilter(flt),E_OK); } TEST_F(DMXTSPES,TS){ BYTE mask[8],value[8]; INT i=0,count=0; flt=nglAllocateSectionFilter(dmxid,0x00,SectionCounterCBK,&count,DMX_TS); ASSERT_NE((HANDLE)nullptr,flt); ASSERT_EQ(0,nglStartSectionFilter(flt)); do{ nglWaitEvent(eventHandle,1000); }while(count<2&&i++<10); ASSERT_GT(count,1); ASSERT_EQ(0,nglStopSectionFilter(flt)); nglFreeSectionFilter(flt); } TEST_F(DMXTSPES,PES){ BYTE mask[8],value[8]; INT i=0,count=0,esc; BYTE PAT[1024]; BYTE PMT[1024]; USHORT pmtpids[128]; USHORT espids[32]; ASSERT_EQ(0,GetSection(0,0,PAT)); GetPMTPids(PAT,pmtpids); ASSERT_EQ(0,GetSection(pmtpids[1],2,PMT)); ASSERT_GT(esc=getElements(PMT,espids),0); for(int i=0;i