|
@@ -4,106 +4,195 @@
|
|
|
|
|
|
static grpcpc * ggrpcpc;
|
|
static grpcpc * ggrpcpc;
|
|
|
|
|
|
-void ListenData(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
|
-{
|
|
|
|
- ggrpcpc->UpdateData(strdata,nSize,strmemname);
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
grpcpc::grpcpc(std::string stryamlpath)
|
|
grpcpc::grpcpc(std::string stryamlpath)
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
- mstrpicmsgname[0] = "h264front1";
|
|
|
|
- mstrpicmsgname[1] = "h264rear1";
|
|
|
|
- mstrpicmsgname[2] = "h264left1";
|
|
|
|
- mstrpicmsgname[3] = "h264right1";
|
|
|
|
-
|
|
|
|
|
|
|
|
ggrpcpc = this;
|
|
ggrpcpc = this;
|
|
- dec_yaml(stryamlpath.data());
|
|
|
|
|
|
|
|
- if(mvectormsgunit.size() == 0)
|
|
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ for(i=0;i<NUM_CAM;i++)
|
|
{
|
|
{
|
|
- iv::msgunit xmu;
|
|
|
|
- snprintf(xmu.mstrmsgname,256,"hcp2_gpsimu");
|
|
|
|
- xmu.mnBufferSize = 10000;
|
|
|
|
- xmu.mnBufferCount = 1;
|
|
|
|
- mvectormsgunit.push_back(xmu);
|
|
|
|
- snprintf(xmu.mstrmsgname,256,"simpletrace");
|
|
|
|
- xmu.mnBufferSize = 100000;
|
|
|
|
- xmu.mnBufferCount = 1;
|
|
|
|
- mvectormsgunit.push_back(xmu);
|
|
|
|
-
|
|
|
|
- if(mvectorctrlmsgunit.size() == 0)
|
|
|
|
|
|
+ unsigned int j;
|
|
|
|
+ for(j=0;j<NUM_THREAD_PERCAM;j++)
|
|
{
|
|
{
|
|
- snprintf(xmu.mstrmsgname,256,"xodrdst");
|
|
|
|
- xmu.mnBufferSize = 1000;
|
|
|
|
- xmu.mnBufferCount = 1;
|
|
|
|
- mvectorctrlmsgunit.push_back(xmu);
|
|
|
|
- snprintf(xmu.mstrmsgname,256,"xodrreq");
|
|
|
|
- xmu.mnBufferSize = 1000;
|
|
|
|
- xmu.mnBufferCount = 1;
|
|
|
|
- xmu.mbImportant = true;
|
|
|
|
- xmu.mnkeeptime = 3000;
|
|
|
|
- mvectorctrlmsgunit.push_back(xmu);
|
|
|
|
- snprintf(xmu.mstrmsgname,256,"remotectrl");
|
|
|
|
- xmu.mnBufferSize = 1000;
|
|
|
|
- xmu.mnBufferCount = 1;
|
|
|
|
- mvectorctrlmsgunit.push_back(xmu);
|
|
|
|
|
|
+ mpThread[i*NUM_THREAD_PERCAM + j] = new std::thread(&grpcpc::threadpicdownload,this,i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
- unsigned int i;
|
|
|
|
- for(i=0;i<mvectormsgunit.size();i++)
|
|
|
|
|
|
+int grpcpc::Produceh264frame(int ncampos,iv::h264rawframedata & xframe)
|
|
|
|
+{
|
|
|
|
+ mmutexh264frame[ncampos].lock();
|
|
|
|
+ if(mvectorh264frame[ncampos].size() > mnframebuffersize)
|
|
{
|
|
{
|
|
- bool bPicMsg = false;
|
|
|
|
- unsigned int j;
|
|
|
|
- for(j=0;j<NUM_CAM;j++)
|
|
|
|
- {
|
|
|
|
- if(strncmp(mvectormsgunit[i].mstrmsgname,mstrpicmsgname[j].data(),255 ) == 0)
|
|
|
|
|
|
+ while(mvectorh264frame[ncampos].size()>mnframebuffersize)
|
|
{
|
|
{
|
|
- bPicMsg = true;
|
|
|
|
- break;
|
|
|
|
|
|
+ mvectorh264frame[ncampos].erase(mvectorh264frame[ncampos].begin());
|
|
|
|
+ std::cout<<"Because Consume slow. erase a frame."<<std::endl;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if(bPicMsg)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- mvectormsgunit[i].mpa = iv::modulecomm::RegisterSend(mvectormsgunit[i].mstrmsgname,mvectormsgunit[i].mnBufferSize,mvectormsgunit[i].mnBufferCount);
|
|
|
|
}
|
|
}
|
|
|
|
+ mvectorh264frame[ncampos].push_back(xframe);
|
|
|
|
+ mmutexh264frame[ncampos].unlock();
|
|
|
|
+ mcv[ncampos].notify_all();
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
|
|
- for(i=0;i<mvectorctrlmsgunit.size();i++)
|
|
|
|
|
|
+int grpcpc::Consumeh264frame(int ncampos,iv::h264rawframedata & xframe)
|
|
|
|
+{
|
|
|
|
+ int nrtn = 0;
|
|
|
|
+ mmutexh264frame[ncampos].lock();
|
|
|
|
+ if(mvectorh264frame[ncampos].size() == 0)nrtn = 0;
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- mvectorctrlmsgunit[i].mpa = iv::modulecomm::RegisterRecv(mvectorctrlmsgunit[i].mstrmsgname,ListenData);
|
|
|
|
|
|
+ xframe = mvectorh264frame[ncampos][0];
|
|
|
|
+ mvectorh264frame[ncampos].erase(mvectorh264frame[ncampos].begin());
|
|
|
|
+ nrtn = 1;
|
|
}
|
|
}
|
|
|
|
+ mmutexh264frame[ncampos].unlock();
|
|
|
|
+ return nrtn;
|
|
|
|
+}
|
|
|
|
|
|
- for(i=0;i<NUM_CAM;i++)
|
|
|
|
|
|
+int grpcpc::Consumeh264frame(int ncampos,iv::h264rawframedata & xframe,int nwaitms)
|
|
|
|
+{
|
|
|
|
+ int nrtn = 0;
|
|
|
|
+ mmutexh264frame[ncampos].lock();
|
|
|
|
+ if(mvectorh264frame[ncampos].size() == 0)nrtn = 0;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ xframe = mvectorh264frame[ncampos][0];
|
|
|
|
+ mvectorh264frame[ncampos].erase(mvectorh264frame[ncampos].begin());
|
|
|
|
+ nrtn = 1;
|
|
|
|
+ }
|
|
|
|
+ mmutexh264frame[ncampos].unlock();
|
|
|
|
+ if(nrtn == 1)return nrtn;
|
|
|
|
+ if(nwaitms <= 0)return nrtn;
|
|
|
|
+ std::unique_lock<std::mutex> lk(mmutexh264cv[ncampos]);
|
|
|
|
+ if(mcv[ncampos].wait_for(lk, std::chrono::milliseconds(nwaitms)) == std::cv_status::timeout)
|
|
|
|
+ {
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+ mmutexh264frame[ncampos].lock();
|
|
|
|
+ if(mvectorh264frame[ncampos].size() == 0)nrtn = 0;
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- mpaPic[i] = iv::modulecomm::RegisterSend(mstrpicmsgname[i].data(),2000000,1);
|
|
|
|
- mnPicUpLatency[i] = 1000;
|
|
|
|
- mnFrameRate[i] = 0;
|
|
|
|
- mnPicDownLatency[i] = 1000;
|
|
|
|
|
|
+ xframe = mvectorh264frame[ncampos][0];
|
|
|
|
+ mvectorh264frame[ncampos].erase(mvectorh264frame[ncampos].begin());
|
|
|
|
+ nrtn = 1;
|
|
}
|
|
}
|
|
|
|
+ mmutexh264frame[ncampos].unlock();
|
|
|
|
+ return nrtn;
|
|
|
|
|
|
|
|
|
|
- for(i=0;i<NUM_CAM;i++)
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int grpcpc::SetCtrlMsg(std::string strmsgname,char * strdata,int ndatasize)
|
|
|
|
+{
|
|
|
|
+ mmutexctrlmsg.lock();
|
|
|
|
+ if(mvectorctrlmsg.size() == 0)
|
|
{
|
|
{
|
|
- unsigned int j;
|
|
|
|
- for(j=0;j<NUM_THREAD_PERCAM;j++)
|
|
|
|
|
|
+ iv::cloud::cloudmsg xmsg;
|
|
|
|
+ mvectorctrlmsg.push_back(xmsg);
|
|
|
|
+ }
|
|
|
|
+ iv::cloud::cloudmsg * pmsg = &mvectorctrlmsg[0];
|
|
|
|
+ bool bExist =false;
|
|
|
|
+ int i;
|
|
|
|
+ for(i=0;i<pmsg->xclouddata_size();i++)
|
|
|
|
+ {
|
|
|
|
+ iv::cloud::cloudunit * punit = pmsg->mutable_xclouddata(i);
|
|
|
|
+ if(strmsgname == punit->msgname())
|
|
{
|
|
{
|
|
- mpThread[i*NUM_THREAD_PERCAM + j] = new std::thread(&grpcpc::threadpicdownload,this,i);
|
|
|
|
|
|
+ punit->set_data(strdata,ndatasize);
|
|
|
|
+ bExist = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(bExist == false)
|
|
|
|
+ {
|
|
|
|
+ iv::cloud::cloudunit * punit = pmsg->add_xclouddata();
|
|
|
|
+ punit->set_msgname(strmsgname);
|
|
|
|
+ punit->set_data(strdata,ndatasize);
|
|
|
|
+ }
|
|
|
|
+ mmutexctrlmsg.unlock();
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int grpcpc::GetCtrlMsg(iv::cloud::cloudmsg & xcloudmsg)
|
|
|
|
+{
|
|
|
|
+ int nrtn = 0;
|
|
|
|
+ mmutexctrlmsg.lock();
|
|
|
|
+ if(mvectorctrlmsg.size() == 0)nrtn = 0;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ xcloudmsg.CopyFrom(mvectorctrlmsg[0]);
|
|
|
|
+ mvectorctrlmsg.clear();
|
|
|
|
+ nrtn = 1;
|
|
|
|
+ }
|
|
|
|
+ mmutexctrlmsg.unlock();
|
|
|
|
+ return nrtn;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int grpcpc::GetQueryMsg(iv::cloud::cloudmsg & xcloudmsg)
|
|
|
|
+{
|
|
|
|
+ int nrtn = 0;
|
|
|
|
+ mmutexquerymsg.lock();
|
|
|
|
+ if(mvectorquerymsg.size() == 0)nrtn = 0;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ xcloudmsg.CopyFrom(mvectorquerymsg[0]);
|
|
|
|
+ mvectorquerymsg.erase(mvectorquerymsg.begin());
|
|
|
|
+ nrtn = 1;
|
|
|
|
+ }
|
|
|
|
+ mmutexquerymsg.unlock();
|
|
|
|
+ return nrtn;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int grpcpc::GetQueryMsg(iv::cloud::cloudmsg &xcloudmsg, int nwaitms)
|
|
|
|
+{
|
|
|
|
+ int nrtn = 0;
|
|
|
|
+ nrtn = GetQueryMsg(xcloudmsg);
|
|
|
|
+
|
|
|
|
+ if(nrtn == 1)return nrtn;
|
|
|
|
+ if(nwaitms <= 0)return nrtn;
|
|
|
|
+ std::unique_lock<std::mutex> lk(mmutexquerycv);
|
|
|
|
+ if(mcvquery.wait_for(lk, std::chrono::milliseconds(nwaitms)) == std::cv_status::timeout)
|
|
|
|
+ {
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ lk.unlock();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return GetQueryMsg(xcloudmsg);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int grpcpc::AddQueryMsg(iv::cloud::cloudmsg & xcloudmsg)
|
|
|
|
+{
|
|
|
|
+ mmutexquerymsg.lock();
|
|
|
|
+ while(mvectorquerymsg.size() > mnquerymsgbufsize)
|
|
|
|
+ {
|
|
|
|
+ mvectorquerymsg.erase(mvectorquerymsg.begin());
|
|
|
|
+ }
|
|
|
|
+ mvectorquerymsg.push_back(xcloudmsg);
|
|
|
|
+ mmutexctrlmsg.unlock();
|
|
|
|
+ mcvquery.notify_all();
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
|
|
void grpcpc::run()
|
|
void grpcpc::run()
|
|
{
|
|
{
|
|
- int nsize = mvectormsgunit.size();
|
|
|
|
- int nctrlsize = mvectorctrlmsgunit.size();
|
|
|
|
- int i;
|
|
|
|
|
|
+// int i;
|
|
|
|
|
|
qint64 nlasttime = 0;
|
|
qint64 nlasttime = 0;
|
|
|
|
|
|
@@ -153,34 +242,34 @@ void grpcpc::run()
|
|
int nkeeptime = 0;
|
|
int nkeeptime = 0;
|
|
|
|
|
|
iv::cloud::cloudmsg xmsg;
|
|
iv::cloud::cloudmsg xmsg;
|
|
|
|
+ GetCtrlMsg(xmsg);
|
|
xmsg.set_xtime(QDateTime::currentMSecsSinceEpoch());
|
|
xmsg.set_xtime(QDateTime::currentMSecsSinceEpoch());
|
|
nlastsend = xTime.elapsed();
|
|
nlastsend = xTime.elapsed();
|
|
- gMutexMsg.lock();
|
|
|
|
-
|
|
|
|
- // std::vector<iv::msgunit> xv = mvectorctrlmsgunit;
|
|
|
|
- for(i=0;i<nctrlsize;i++)
|
|
|
|
- {
|
|
|
|
- if(mvectorctrlmsgunit[i].mbRefresh)
|
|
|
|
- {
|
|
|
|
- mvectorctrlmsgunit[i].mbRefresh = false;
|
|
|
|
|
|
|
|
- if(mvectorctrlmsgunit[i].mbImportant)
|
|
|
|
- {
|
|
|
|
- bImportant = true;
|
|
|
|
- }
|
|
|
|
- if(mvectorctrlmsgunit[i].mnkeeptime > nkeeptime)
|
|
|
|
- {
|
|
|
|
- nkeeptime = mvectorctrlmsgunit[i].mnkeeptime;
|
|
|
|
- }
|
|
|
|
- iv::cloud::cloudunit xcloudunit;
|
|
|
|
- xcloudunit.set_msgname(mvectorctrlmsgunit[i].mstrmsgname);
|
|
|
|
- xcloudunit.set_data(mvectorctrlmsgunit[i].mpstrmsgdata.get(),mvectorctrlmsgunit[i].mndatasize);
|
|
|
|
- iv::cloud::cloudunit * pcu = xmsg.add_xclouddata();
|
|
|
|
- pcu->CopyFrom(xcloudunit);
|
|
|
|
- }
|
|
|
|
|
|
+// gMutexMsg.lock();
|
|
|
|
+// for(i=0;i<nctrlsize;i++)
|
|
|
|
+// {
|
|
|
|
+// if(mvectorctrlmsgunit[i].mbRefresh)
|
|
|
|
+// {
|
|
|
|
+// mvectorctrlmsgunit[i].mbRefresh = false;
|
|
|
|
+
|
|
|
|
+// if(mvectorctrlmsgunit[i].mbImportant)
|
|
|
|
+// {
|
|
|
|
+// bImportant = true;
|
|
|
|
+// }
|
|
|
|
+// if(mvectorctrlmsgunit[i].mnkeeptime > nkeeptime)
|
|
|
|
+// {
|
|
|
|
+// nkeeptime = mvectorctrlmsgunit[i].mnkeeptime;
|
|
|
|
+// }
|
|
|
|
+// iv::cloud::cloudunit xcloudunit;
|
|
|
|
+// xcloudunit.set_msgname(mvectorctrlmsgunit[i].mstrmsgname);
|
|
|
|
+// xcloudunit.set_data(mvectorctrlmsgunit[i].mpstrmsgdata.get(),mvectorctrlmsgunit[i].mndatasize);
|
|
|
|
+// iv::cloud::cloudunit * pcu = xmsg.add_xclouddata();
|
|
|
|
+// pcu->CopyFrom(xcloudunit);
|
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
|
- gMutexMsg.unlock();
|
|
|
|
|
|
+// }
|
|
|
|
+// gMutexMsg.unlock();
|
|
|
|
|
|
|
|
|
|
{
|
|
{
|
|
@@ -231,7 +320,8 @@ void grpcpc::run()
|
|
iv::cloud::cloudmsg xmsg;
|
|
iv::cloud::cloudmsg xmsg;
|
|
if(xmsg.ParseFromArray(xreply.xdata().data(),xreply.xdata().size()))
|
|
if(xmsg.ParseFromArray(xreply.xdata().data(),xreply.xdata().size()))
|
|
{
|
|
{
|
|
- sharequerymsg(&xmsg);
|
|
|
|
|
|
+ AddQueryMsg(xmsg);
|
|
|
|
+ // sharequerymsg(&xmsg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -266,160 +356,7 @@ void grpcpc::run()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-void grpcpc::dec_yaml(const char *stryamlpath)
|
|
|
|
-{
|
|
|
|
- YAML::Node config;
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- config = YAML::LoadFile(stryamlpath);
|
|
|
|
- }
|
|
|
|
- catch(YAML::BadFile e)
|
|
|
|
- {
|
|
|
|
- qDebug("load error.");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- std::vector<std::string> vecmodulename;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(config["server"])
|
|
|
|
- {
|
|
|
|
- gstrserverip = config["server"].as<std::string>();
|
|
|
|
- }
|
|
|
|
- if(config["port"])
|
|
|
|
- {
|
|
|
|
- gstrserverport = config["port"].as<std::string>();
|
|
|
|
- }
|
|
|
|
- if(config["uploadinterval"])
|
|
|
|
- {
|
|
|
|
- gstruploadinterval = config["uploadinterval"].as<std::string>();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(config["VIN"])
|
|
|
|
- {
|
|
|
|
- gstrVIN = config["VIN"].as<std::string>();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(config["queryMD5"])
|
|
|
|
- {
|
|
|
|
- gstrqueryMD5 = config["queryMD5"].as<std::string>();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(config["ctrlMD5"])
|
|
|
|
- {
|
|
|
|
- gstrctrlMD5 = config["ctrlMD5"].as<std::string>();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- std::string strmsgname;
|
|
|
|
-
|
|
|
|
- if(config["querymessage"])
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- for(YAML::const_iterator it= config["querymessage"].begin(); it != config["querymessage"].end();++it)
|
|
|
|
- {
|
|
|
|
- std::string strtitle = it->first.as<std::string>();
|
|
|
|
- std::cout<<strtitle<<std::endl;
|
|
|
|
-
|
|
|
|
- if(config["querymessage"][strtitle]["msgname"]&&config["querymessage"][strtitle]["buffersize"]&&config["querymessage"][strtitle]["buffercount"])
|
|
|
|
- {
|
|
|
|
- iv::msgunit xmu;
|
|
|
|
- strmsgname = config["querymessage"][strtitle]["msgname"].as<std::string>();
|
|
|
|
- strncpy(xmu.mstrmsgname,strmsgname.data(),255);
|
|
|
|
- xmu.mnBufferSize = config["querymessage"][strtitle]["buffersize"].as<int>();
|
|
|
|
- xmu.mnBufferCount = config["querymessage"][strtitle]["buffercount"].as<int>();
|
|
|
|
- mvectormsgunit.push_back(xmu);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(config["ctrlmessage"])
|
|
|
|
- {
|
|
|
|
- std::string strnodename = "ctrlmessage";
|
|
|
|
- for(YAML::const_iterator it= config[strnodename].begin(); it != config[strnodename].end();++it)
|
|
|
|
- {
|
|
|
|
- std::string strtitle = it->first.as<std::string>();
|
|
|
|
- std::cout<<strtitle<<std::endl;
|
|
|
|
-
|
|
|
|
- if(config[strnodename][strtitle]["msgname"]&&config[strnodename][strtitle]["buffersize"]&&config[strnodename][strtitle]["buffercount"])
|
|
|
|
- {
|
|
|
|
- iv::msgunit xmu;
|
|
|
|
- strmsgname = config[strnodename][strtitle]["msgname"].as<std::string>();
|
|
|
|
- strncpy(xmu.mstrmsgname,strmsgname.data(),255);
|
|
|
|
- xmu.mnBufferSize = config[strnodename][strtitle]["buffersize"].as<int>();
|
|
|
|
- xmu.mnBufferCount = config[strnodename][strtitle]["buffercount"].as<int>();
|
|
|
|
-
|
|
|
|
- if(config[strnodename][strtitle]["bimportant"])
|
|
|
|
- {
|
|
|
|
- std::string strimportant = config[strnodename][strtitle]["bimportant"].as<std::string>();
|
|
|
|
- if(strimportant == "true")
|
|
|
|
- {
|
|
|
|
- xmu.mbImportant = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(config[strnodename][strtitle]["keeptime"])
|
|
|
|
- {
|
|
|
|
- std::string strkeep = config[strnodename][strtitle]["keeptime"].as<std::string>();
|
|
|
|
- xmu.mnkeeptime = atoi(strkeep.data());
|
|
|
|
- }
|
|
|
|
- mvectorctrlmsgunit.push_back(xmu);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void grpcpc::sharequerymsg(iv::cloud::cloudmsg *pxmsg)
|
|
|
|
-{
|
|
|
|
- int i;
|
|
|
|
- int nsize = pxmsg->xclouddata_size();
|
|
|
|
- for(i=0;i<nsize;i++)
|
|
|
|
- {
|
|
|
|
- int j;
|
|
|
|
- int nquerysize = mvectormsgunit.size();
|
|
|
|
- for(j=0;j<nquerysize;j++)
|
|
|
|
- {
|
|
|
|
- if(strncmp(pxmsg->xclouddata(i).msgname().data(), mvectormsgunit[j].mstrmsgname,255) == 0)
|
|
|
|
- {
|
|
|
|
- qDebug("size is %d ",pxmsg->xclouddata(i).data().size());
|
|
|
|
- iv::modulecomm::ModuleSendMsg(mvectormsgunit[j].mpa,pxmsg->xclouddata(i).data().data(),pxmsg->xclouddata(i).data().size());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void grpcpc::UpdateData(const char *strdata, const unsigned int nSize,const char * strmemname)
|
|
|
|
-{
|
|
|
|
- int nsize = mvectorctrlmsgunit.size();
|
|
|
|
- int i;
|
|
|
|
- for(i=0;i<nsize;i++)
|
|
|
|
- {
|
|
|
|
- if(strncmp(strmemname,mvectorctrlmsgunit[i].mstrmsgname,255) == 0)
|
|
|
|
- {
|
|
|
|
- gMutexMsg.lock();
|
|
|
|
- char * strtem = new char[nSize];
|
|
|
|
- memcpy(strtem,strdata,nSize);
|
|
|
|
- mvectorctrlmsgunit[i].mpstrmsgdata.reset(strtem);
|
|
|
|
- mvectorctrlmsgunit[i].mndatasize = nSize;
|
|
|
|
- mvectorctrlmsgunit[i].mbRefresh = true;
|
|
|
|
- gMutexMsg.unlock();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
std::string grpcpc::GetVIN()
|
|
std::string grpcpc::GetVIN()
|
|
{
|
|
{
|
|
@@ -427,15 +364,10 @@ std::string grpcpc::GetVIN()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//int gnPicNum[NUM_CAM];
|
|
|
|
-//QMutex gMutexPic[NUM_CAM];
|
|
|
|
-//qint64 gnTimeSecond[NUM_CAM];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
void grpcpc::threadpicdownload(int nCamPos)
|
|
void grpcpc::threadpicdownload(int nCamPos)
|
|
{
|
|
{
|
|
std::cout<<"thread cam "<<nCamPos<<"run"<<std::endl;
|
|
std::cout<<"thread cam "<<nCamPos<<"run"<<std::endl;
|
|
- int nsize = mvectormsgunit.size();
|
|
|
|
|
|
+ // int nsize = mvectormsgunit.size();
|
|
int i;
|
|
int i;
|
|
|
|
|
|
std::string strcclientid = ServiceRCIni.GetClientID();
|
|
std::string strcclientid = ServiceRCIni.GetClientID();
|
|
@@ -485,6 +417,12 @@ void grpcpc::threadpicdownload(int nCamPos)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(abs(xTime.elapsed() - nlastsend)<10)
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
request.set_strclientid(strcclientid);
|
|
request.set_strclientid(strcclientid);
|
|
request.set_ncampos(nCamPos);
|
|
request.set_ncampos(nCamPos);
|
|
@@ -509,9 +447,27 @@ void grpcpc::threadpicdownload(int nCamPos)
|
|
mnPicUpLatency[nCamPos] = reply.npicuplatency();
|
|
mnPicUpLatency[nCamPos] = reply.npicuplatency();
|
|
mnFrameRate[nCamPos] = reply.npicframerate();
|
|
mnFrameRate[nCamPos] = reply.npicframerate();
|
|
mnPicDownLatency[nCamPos] = QDateTime::currentMSecsSinceEpoch() - time1;
|
|
mnPicDownLatency[nCamPos] = QDateTime::currentMSecsSinceEpoch() - time1;
|
|
- mMutexPic[nCamPos].lock();
|
|
|
|
- iv::modulecomm::ModuleSendMsg(mpaPic[nCamPos],reply.xdata().data(),reply.xdata().size());
|
|
|
|
- mMutexPic[nCamPos].unlock();
|
|
|
|
|
|
+
|
|
|
|
+ char * pstrdata = (char * )reply.xdata().data();
|
|
|
|
+ int * np = (int * )reply.xdata().data();
|
|
|
|
+ int npacsize = np[0];
|
|
|
|
+ int nmaxpac = 10;
|
|
|
|
+ int npos = (1+nmaxpac)*sizeof(int) ;
|
|
|
|
+ for(i=0;i<npacsize;i++)
|
|
|
|
+ {
|
|
|
|
+ iv::h264rawframedata xframe;
|
|
|
|
+ int ndatasize = np[i+1];
|
|
|
|
+ std::cout<<" i "<<i<<" size: "<<ndatasize<<std::endl;
|
|
|
|
+ xframe.mdatasize = ndatasize;
|
|
|
|
+ xframe.mpstr_ptr = std::shared_ptr<char>(new char[ndatasize]);
|
|
|
|
+ memcpy(xframe.mpstr_ptr.get(),pstrdata + npos,xframe.mdatasize);
|
|
|
|
+ Produceh264frame(nCamPos,xframe);
|
|
|
|
+ npos = npos + ndatasize;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// mMutexPic[nCamPos].lock();
|
|
|
|
+// iv::modulecomm::ModuleSendMsg(mpaPic[nCamPos],reply.xdata().data(),reply.xdata().size());
|
|
|
|
+// mMutexPic[nCamPos].unlock();
|
|
nlastpicquerytime = reply.npictime();
|
|
nlastpicquerytime = reply.npictime();
|
|
// iv::cloud::cloudmsg xmsg;
|
|
// iv::cloud::cloudmsg xmsg;
|
|
// if(xmsg.ParseFromArray(reply.xdata().data(),reply.xdata().size()))
|
|
// if(xmsg.ParseFromArray(reply.xdata().data(),reply.xdata().size()))
|
|
@@ -521,7 +477,7 @@ void grpcpc::threadpicdownload(int nCamPos)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(10*NUM_THREAD_PERCAM));
|
|
|
|
|
|
+ // std::this_thread::sleep_for(std::chrono::milliseconds(10*NUM_THREAD_PERCAM));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
std::cout << status.error_code() << ": " << status.error_message()
|
|
std::cout << status.error_code() << ": " << status.error_message()
|