#include #include "modulecomm.h" #include "xmlparam.h" #include "imx291frame.h" imx291frame * gpframe; std::thread * gpthread; void * gpa; bool gbrun = true; #include #ifdef TEST_SAVEH264 #include QFile gFile; #endif void ThreadGetData() { while(gbrun) { iv::h264framendata xframe; if(gpframe->GetFrame(xframe) == 1) { qint64 recvtime = std::chrono::system_clock::now().time_since_epoch().count(); recvtime = recvtime/1000; double frecvtime = recvtime; frecvtime = frecvtime/1000000.0; #ifdef TEST_SAVEH264 static int ncount = 0; if(ncount<50) { gFile.write(xframe.mpstr_ptr.get(),xframe.mdatalen); gFile.flush(); } // ncount++; #endif // qDebug(" recvtime : %13.6f datatime:%13.6f",frecvtime,xframe.mfrecvtime); iv::modulecomm::ModuleSendMsg(gpa,xframe.mpstr_ptr.get(),xframe.mdatalen); // char * str = (char * )xframe.mpstr_ptr.get(); // if(xframe.mdatalen > 5) // { // qDebug(" Head: %02x %02x %02x %02x %02x",str[0],str[1],str[2],str[3],str[4]); // if(str[4] != 0x67) // { // int a; // a= 1; // } // } } } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::string strxmlpath; if(argc == 1) { strxmlpath = "./driver_h264_usbimx291.xml"; } else { strxmlpath = argv[1]; } #ifdef TEST_SAVEH264 gFile.setFileName("/home/yuchuli/imx291.h264"); gFile.open(QIODevice::ReadWrite); #endif iv::xmlparam::Xmlparam xp(strxmlpath); std::string strdevname = xp.GetParam("devname","/dev/video5"); int nwidth = xp.GetParam("width",1920); int nheigth = xp.GetParam("height",1080); int nbitrate = xp.GetParam("bitrate",4000000); int ngop = xp.GetParam("gop",10); std::string strframename = xp.GetParam("outmsgname","h264frame"); gpa = iv::modulecomm::RegisterSend(strframename.data(),3000000,1); gpframe = new imx291frame(strdevname.data(),nwidth,nheigth,nbitrate,ngop); gpthread = new std::thread(&ThreadGetData); return a.exec(); }