|
@@ -92,7 +92,7 @@ void threadcam(iv::threadcam * pthreadcam)
|
|
|
pthreadcam->mbUpdate = true;
|
|
|
pthreadcam->mmutexdata.unlock();
|
|
|
pthreadcam->mcv.notify_all();
|
|
|
- // std::cout<<std::chrono::system_clock::now().time_since_epoch().count()/1000<< " "<<nLen<<std::endl;
|
|
|
+ // std::cout<<std::chrono::system_clock::now().time_since_epoch().count()/1000<< " "<<nLen<<std::endl;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -230,8 +230,72 @@ int StartCam(const char * strvideoname,int image_width,int image_height,int imag
|
|
|
}
|
|
|
|
|
|
|
|
|
+int GetJPEGDataWithWait(char * strvideoname, char * str,int * x,int nwaitms)
|
|
|
+{
|
|
|
+ std::string strvideo = strvideoname;
|
|
|
+
|
|
|
+ int nsize;
|
|
|
+ int i;
|
|
|
+ iv::threadcam * pthreadcam = NULL;
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
+ {
|
|
|
+ if(gvectorthreadcam[i]->mstrvideoname == strvideo)
|
|
|
+ {
|
|
|
+ pthreadcam = gvectorthreadcam[i];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(pthreadcam == NULL)
|
|
|
+ {
|
|
|
+ std::cout<<" video device not open."<<std::endl;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ int nRtn = 0;
|
|
|
+ pthreadcam->mmutexdata.lock();
|
|
|
+ if(pthreadcam->mbUpdate)
|
|
|
+ {
|
|
|
+// str.copy(gstrbuf,gnLen);
|
|
|
+ memcpy(str,pthreadcam->mpstr_data.get(),pthreadcam->mndatasize);
|
|
|
+ nRtn = pthreadcam->mndatasize;
|
|
|
+ *x = pthreadcam->mndatasize;
|
|
|
+ pthreadcam->mbUpdate= false;
|
|
|
+ }
|
|
|
+ pthreadcam->mmutexdata.unlock();
|
|
|
+
|
|
|
+ if(nRtn > 0)return nRtn;
|
|
|
+
|
|
|
+ if(nwaitms == 0)return nRtn;
|
|
|
+
|
|
|
+ std::unique_lock<std::mutex> lk(pthreadcam->mmutexcv);
|
|
|
+ if(pthreadcam->mcv.wait_for(lk,std::chrono::milliseconds(nwaitms)) == std::cv_status::timeout)
|
|
|
+ {
|
|
|
+ lk.unlock();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lk.unlock();
|
|
|
+ }
|
|
|
+ pthreadcam->mmutexdata.lock();
|
|
|
+ if(pthreadcam->mbUpdate)
|
|
|
+ {
|
|
|
+// str.copy(gstrbuf,gnLen);
|
|
|
+ memcpy(str,pthreadcam->mpstr_data.get(),pthreadcam->mndatasize);
|
|
|
+ nRtn = pthreadcam->mndatasize;
|
|
|
+ *x = pthreadcam->mndatasize;
|
|
|
+ pthreadcam->mbUpdate= false;
|
|
|
+ }
|
|
|
+ pthreadcam->mmutexdata.unlock();
|
|
|
+
|
|
|
+ return nRtn;
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
int GetJPEGData(char * strvideoname, char * str,int * x)
|
|
|
{
|
|
|
+ return GetJPEGDataWithWait(strvideoname,str,x,0);
|
|
|
std::string strvideo = strvideoname;
|
|
|
|
|
|
int nsize;
|