video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2021-07-30 8f44600c2e5d6141aebf49536a6ddbafc6c18d75
csrc/thirdparty/gb28181/include/PsToEs.hpp
@@ -109,13 +109,23 @@
      printf("GB28181API end!\n");
      // m_rtpQueue.clearAll();
      m_rtpQueue.clearAll([](frameBuffInfo *info){
         delete[] info->buff;
         delete info;
         if (info){
            delete[] info->buff;
            delete info;
         }
      });
      deleteCamera();
   }
   bool pushInfo(unsigned char *data, int datalen) {
      while(m_rtpQueue.count_queue() > 120){
            auto p = m_rtpQueue.popNotWait();
            if (p){
                delete[] p->buff;
                delete p;
            }
        }
      frameBuffInfo *info = new frameBuffInfo();
      info->buff = new unsigned char[datalen];
@@ -155,6 +165,13 @@
            info->buff = new unsigned char[buffinfo->buffLen - len]{};
            memcpy(info->buff, buffinfo->buff + len, buffinfo->buffLen - len);
            while(_this->m_rtpQueue.count_queue() > 120){
                    auto p = _this->m_rtpQueue.popNotWait();
                    if (p){
                        delete[] p->buff;
                        delete p;
                    }
                }
//            printf("/帧长大于info->buffLen:%d\n", info->buffLen);
            _this->m_rtpQueue.push_front_one(info);
//            printf("/帧长大于info->buffLen\n");
@@ -191,7 +208,7 @@
            //从缓存中获取buffinfo
            if (_this->m_rtpQueue.count_queue() == 0) {
//                printf(" count_queue == 0 \n");
                usleep(10000);
                usleep(200000);
                continue;
            }
@@ -210,6 +227,8 @@
               if (!buffinfo){
                  buffinfo = _this->m_rtpQueue.pop();
               }
               if (!buffinfo) continue;
               auto fpIframe = fopen(fileIFrameName, "wb+");
               fwrite(buffinfo->buff, buffinfo->buffLen, 1, fpIframe);
               fflush(fpIframe);