From 6540a2a9d69432c4cc475e3b32eae11e9e0ace73 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期四, 11 四月 2019 20:28:10 +0800
Subject: [PATCH] 1.srs的分辨率在config.json配置 2.单播推流控制,国标摄像机差一个关闭测试 3. 底库字段添加

---
 QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp |   57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp
index 374529b..33a73fc 100644
--- a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp
+++ b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp
@@ -39,39 +39,58 @@
         }
     }
 
-    m_picCount++;
-    //鍑犲紶閫変竴寮犳斁鍏edis
-    if (m_picCount % m_nPicsPickOne != 0) {
-        return;
-    } else {
-        m_picCount.store(0);
-    }
+    u_char *data;
+    int width = 0, height = 0, step = 0, cn = 0;
+    cv::Mat copyMat;
 
-    {
-        u_char *data;
-        int width = 0, height = 0, step = 0, cn = 0;
-        m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn);
-
-        cv::Mat img(height, width, CV_8UC3, data, step);
-        cv::Mat copyMat;
-        img.copyTo(copyMat);
-        std::string imageName = m_capture->GetImageName();
-        m_pManager->SaveImageToRedis(m_camId, imageName, copyMat);
-    }
-    //#todo publish Video
+    //#publish Video
     if (m_publishVideoRet) {
         if (videoPublishElement == nullptr) {
             string path = appConfig.getStringProperty("srsAddr") + "cam" + m_camId + ".flv";
             cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height"));
             int gupIdx = appPref.getIntData("gpu.index");
+            DBG("size_:" << size_.width << "X" << size_.height);
             videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx);
+            videoPublishElement->start();
         } else {
+//            DBG("videoPublishElement->setImage()");
+            m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn);
+            cv::Mat img(height, width, CV_8UC3, data, step);
+            img.copyTo(copyMat);
+
+            if (!copyMat.empty()) {
+                videoPublishElement->setImage(copyMat);
+            } else {
+                DBG("copyMat.empty()");
+            }
+        }
+    } else {
+        if (videoPublishElement != nullptr) {
+            DBG("videoPublishElement->stop()");
             videoPublishElement->stop();
             videoPublishElement->wait();
             delete videoPublishElement;
             videoPublishElement = nullptr;
         }
     }
+
+    //鍑犲紶閫変竴寮犳斁鍏edis
+    m_picCount++;
+    if (m_picCount % m_nPicsPickOne != 0) {
+        return;
+    } else {
+        m_picCount.store(0);
+    }
+
+    if (copyMat.empty()) {
+//        ERR("copyMat.empty()");
+        m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn);
+        cv::Mat img(height, width, CV_8UC3, data, step);
+        img.copyTo(copyMat);
+    }
+    std::string imageName = m_capture->GetImageName();
+    m_pManager->SaveImageToRedis(m_camId, imageName, copyMat);
+
     fireConnectors();
 }
 

--
Gitblit v1.8.0