#ifndef GRPCCLIENT_H #define GRPCCLIENT_H #include #include #include #include #include #include #include #include #include #include "modulecomm.h" #include "cloud.pb.h" #include #include #include #include #include "uploadthreadmsg.grpc.pb.h" #define NUM_CAM 4 #define NUM_THREAD_PERCAM 1 #define NUM_FRAMEBUFFSIZE 30 namespace iv { struct msgunit { char mstrmsgname[256]; int mnBufferSize = 10000; int mnBufferCount = 1; void * mpa; std::shared_ptr mpstrmsgdata; int mndatasize = 0; bool mbRefresh = false; bool mbImportant = false; int mnkeeptime = 100; }; struct h264frame { bool mbIframe = false; //if SPS, is true std::shared_ptr mpstrframedata; int mDataSize; }; struct threadpicunit { std::vector mvectorframe; bool mbRefresh = false; qint64 mnMsgTime; std::shared_ptr mpstrmsgdata; int mDataSize; QMutex mWaitMutex; QWaitCondition mwc; QMutex mMutex; std::vector mvectorlatency; int mnSkipBase = 2; int mnDefSkipBase = 1; int mnCount = 0; bool mbRecvIFrame = false; }; } using grpc::Channel; using grpc::ClientContext; using grpc::Status; class grpcclient : public QThread { public: grpcclient(std::string stryamlpath); ~grpcclient(); private: std::string gstrserverip = "127.0.0.1";//111.33.136.149";//"0.0.0.0";//"192.168.14.98";// "123.57.212.138"; std::string gstrserverport = "50051";//"9000"; std::string gstruploadinterval = "1000"; void * gpa; QMutex gMutexMsg; std::thread * guploadthread; std::vector mvectormsgunit; std::vector mvectorctrlmsgunit; std::string gstrVIN = "AAAAAAAAAAAAAAAAA"; std::string gstrqueryMD5 = "5d41402abc4b2a76b9719d911017c591";//"5d41402abc4b2a76b9719d911017c592"; std::string gstrctrlMD5 = "5d41402abc4b2a76b9719d911017c591"; int gindex = 0; public: void UpdateData(const char * strdata,const unsigned int nSize,const char * strmemname); void UpdatePicData(const char * strdata,const unsigned int nSize,const char * strmemname); private: void run(); void dec_yaml(const char * stryamlpath); void sharectrlmsg(iv::cloud::cloudmsg * pxmsg); private: void threadpicupload(int nCamPos); iv::threadpicunit mpicbuf[NUM_CAM]; void * mpaPic[NUM_CAM]; std::string mstrpicmsgname[NUM_CAM]; std::thread * mpThread[NUM_CAM * NUM_THREAD_PERCAM]; bool mbPicUpload = true; qint64 CalcLateny(std::vector & xvectorlatency); int mnskip = 2; bool mbFrameUpdate = false; }; #endif // GRPCCLIENT_H