#include #include #include #include #include #include #include #define MAX_PROGRAM 32 class DMX: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(;p>8; value[2]=pmtpids[i*2]&0xFF; counters[i]=0; flts[i]=nglAllocateSectionFilter(dmxid,pmtpids[i*2+1],SectionCounterCBK,counters+i,DMX_SECTION); ASSERT_NE((HANDLE)nullptr,flts[i]); ASSERT_EQ(0,nglSetSectionFilterParameters(flts[i],mask,value,masklen)); ASSERT_EQ(0,nglStartSectionFilter(flts[i])); } nglWaitEvent(eventHandle,5000); for(int i=0;i>8; value[2]=pmtpids[i*2]&0xFF; flt=nglAllocateSectionFilter(dmxid,pmtpids[i*2+1],FilterCBK,params,DMX_SECTION); ASSERT_NE((HANDLE)nullptr,flt); ASSERT_EQ(0,nglSetSectionFilterParameters(flt,mask,value,masklen)); ASSERT_EQ(0,nglStartSectionFilter(flt)); ASSERT_EQ(0,nglWaitEvent(eventHandle,2000)); ASSERT_EQ(data[0],2); ASSERT_EQ(data[3]<<8|data[4],pmtpids[i*2]); ASSERT_EQ(0,nglStopSectionFilter(flt)); ASSERT_EQ(0,nglFreeSectionFilter(flt)); } } static void EIT_CBK(HANDLE dwVaFilterHandle,const BYTE *pBuffer,UINT uiBufferLength, void *pUserData){ static int count=0; memcpy(pUserData,pBuffer,uiBufferLength); if(count++%1000==0)printf("%02x %02x %02x %02x %p/%p %d\r\n",pBuffer[0],pBuffer[1],pBuffer[2],pBuffer[3], pUserData,pBuffer,uiBufferLength); } TEST_F(DMX,GX){ BYTE buffer[4096]; BYTE mask[8],value[8]; data[0]=0xFF; flt=nglAllocateSectionFilter(dmxid,0x12,EIT_CBK,buffer,DMX_SECTION); ASSERT_NE((HANDLE)nullptr,flt); mask[0]=0x00;value[0]=0x00;//for PAT ASSERT_EQ(0,nglSetSectionFilterParameters(flt,mask,value,1)); ASSERT_EQ(0,nglStartSectionFilter(flt)); ASSERT_EQ(0,nglWaitEvent(eventHandle,2000*1000)); ASSERT_EQ(data[0],0); ASSERT_EQ(0,nglStopSectionFilter(flt)); nglFreeSectionFilter(flt); }