瀏覽代碼

change grpc_h264.

yuchuli 3 年之前
父節點
當前提交
2d7a5635d4

+ 3 - 3
src/driver/driver_cloud_grpc_server_h264/cumsgbuffer.cpp

@@ -7,7 +7,7 @@ cumsgbuffer::cumsgbuffer()
 
 void cumsgbuffer::addmsg(int id, qint64 ntime, std::string strVIN, std::string strqueryMD5, std::string strctrlMD5, std::vector<char> *pxdata,bool bImportant,int nkeeptime)
 {
-    qDebug("ntime is %lld",ntime);
+//    qDebug("ntime is %lld",ntime);
     mMutex.lock();
     iv::cumsg * pmsg = 0;
     int nsize = mvectormsg.size();
@@ -81,7 +81,7 @@ int cumsgbuffer::getmsg(std::string strVIN,std::string strqueryMD5, qint64 nlast
 
     if(pmsg == 0)
     {
-        std::cout<<" no this vin data"<<std::endl;;
+//        std::cout<<" no this vin data"<<std::endl;;
         mMutex.unlock();
         return -1;
     }
@@ -173,7 +173,7 @@ int cumsgbuffer::getPicData(std::string strVIN, std::string strqueryMD5,std::sha
 
     if(pmsg == 0)
     {
-        std::cout<<" no this vin data"<<std::endl;;
+//        std::cout<<" no this vin data"<<std::endl;;
         mMutex.unlock();
         return -1;
     }

+ 1 - 1
src/driver/driver_cloud_grpc_server_h264/main.cpp

@@ -40,7 +40,7 @@ class UploadServiceImpl final : public iv::UploadThread::Service {
                   iv::UploadReplyThread* reply) override {
 
     std::vector<char> xvectordata;
-    qDebug("size is %d",request->xdata().size());
+//    qDebug("size is %d",request->xdata().size());
     if(request->xdata().size()>0)
     {
 

+ 1 - 1
src/driver/driver_cloud_grpc_server_h264/pcmsgbuffer.cpp

@@ -113,7 +113,7 @@ int pcmsgbuffer::getmsg(std::string strVIN, std::string strctrlMD5, int &id, qin
 
     if(pmsg == 0)
     {
-        std::cout<<" no this vin data"<<std::endl;;
+//        std::cout<<" no this vin data"<<std::endl;;
         mMutex.unlock();
         return 0;
     }

+ 24 - 17
src/driver/driver_cloud_grpc_server_h264/picbuf.cpp

@@ -35,27 +35,34 @@ void PicBuf::AddData(iv::PicData xPicData)
     mvectordata_ptr.push_back(xPicData);
     mLastBufTime = xPicData.mnMsgTime;
 
-    int i;
-    bool bRemove = false;
-    for(i=0;i<(int)(mvectordata_ptr.size());i++)
-    {
-        if(abs(mLastBufTime - mvectordata_ptr.at(i).mnMsgTime) > mBufTime)
-        {
-            bRemove = true;
-            mvectordata_ptr.erase(mvectordata_ptr.begin() + i);
-            i--;
-        }
 
-    }
-    if(bRemove)
+    while(mvectordata_ptr.size()>30)
     {
-        while(mvectordata_ptr.size()>0)
-        {
-            if(mvectordata_ptr[0].mbSPSFrame)break;
-            mvectordata_ptr.erase(mvectordata_ptr.begin());
-        }
+//        if(mvectordata_ptr[0].mbSPSFrame)break;
+        mvectordata_ptr.erase(mvectordata_ptr.begin());
     }
 
+//    int i;
+//    bool bRemove = false;
+//    for(i=0;i<(int)(mvectordata_ptr.size());i++)
+//    {
+//        if(abs(mLastBufTime - mvectordata_ptr.at(i).mnMsgTime) > mBufTime)
+//        {
+//            bRemove = true;
+//            mvectordata_ptr.erase(mvectordata_ptr.begin() + i);
+//            i--;
+//        }
+
+//    }
+//    if(bRemove)
+//    {
+//        while(mvectordata_ptr.size()>0)
+//        {
+//            if(mvectordata_ptr[0].mbSPSFrame)break;
+//            mvectordata_ptr.erase(mvectordata_ptr.begin());
+//        }
+//    }
+
     mMutexBuf.unlock();
 }
 

+ 1 - 0
src/driver/driver_h264_dec/ivh264framedecode.cpp

@@ -27,6 +27,7 @@ int ivh264framedecode::GetUpdatedIndex()
 
 int ivh264framedecode::GetUpdatedIndex(int nwaitms)
 {
+    if(mvectorupdateindex.size()>0)return mvectorupdateindex[0];
     std::unique_lock<std::mutex> lk(mmutex_cvread);
     if(mcvread.wait_for(lk, std::chrono::milliseconds(nwaitms)) == std::cv_status::timeout)
     {

+ 7 - 6
src/tool/RemoteCtrl_h264/grpcpc.cpp

@@ -193,7 +193,6 @@ int grpcpc::AddQueryMsg(iv::cloud::cloudmsg & xcloudmsg)
 void grpcpc::run()
 {
 //    int i;
-
     qint64 nlasttime = 0;
 
     int ninterval = atoi(gstruploadinterval.data());
@@ -417,11 +416,11 @@ void grpcpc::threadpicdownload(int nCamPos)
             continue;
         }
 
-        if(abs(xTime.elapsed() - nlastsend)<10)
-        {
-            std::this_thread::sleep_for(std::chrono::milliseconds(1));
-            continue;
-        }
+//        if(abs(xTime.elapsed() - nlastsend)<30)
+//        {
+//            std::this_thread::sleep_for(std::chrono::milliseconds(1));
+//            continue;
+//        }
 
 
         request.set_strclientid(strcclientid);
@@ -477,6 +476,8 @@ void grpcpc::threadpicdownload(int nCamPos)
             }
             else
             {
+                std::cout<<"  slleeeeeep "<<std::endl;
+                std::this_thread::sleep_for(std::chrono::milliseconds(10));
  //               std::this_thread::sleep_for(std::chrono::milliseconds(10*NUM_THREAD_PERCAM));
             }
         } else {

+ 2 - 1
src/tool/RemoteCtrl_h264/mainwindow.cpp

@@ -1008,9 +1008,10 @@ void MainWindow::threadframe(int ncamppos)
 
 void MainWindow::threadpic(int ncampos)
 {
+
     while(mbThreadrun)
     {
-        int nindex = mph264decode[ncampos]->GetUpdatedIndex(100);
+        int nindex = mph264decode[ncampos]->GetUpdatedIndex(10);
         if(nindex<0)continue;
         std::cout<<" recv a yuv."<<std::endl;
         iv::framedecodebuf * pbuf =  mph264decode[ncampos]->LockReadBuff(nindex);