From 12879769af38a00425309e292b2c167afc6612c1 Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期四, 04 四月 2019 11:27:38 +0800
Subject: [PATCH] 增加点播功能

---
 QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp |   41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
index 2f7010f..9b7b775 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -5,6 +5,7 @@
 #include <opencv2/imgproc.hpp>
 #include <qt5/QtCore/QDateTime>
 #include <basic/util/app/AppPreference.hpp>
+#include <basic/util/app/AppConfig.h>
 #include "VideoCaptureElementWithRtp.h"
 #include <VideoToImageMulth/RtspAnalysManager.h>
 
@@ -35,7 +36,7 @@
 
 bool BASICGB28181::VideoCaptureElementWithRtp::startRtpStream(int streamTransType) {
 
-    if(!m_waitSignalrunning) {
+    if (!m_waitSignalrunning) {
         DBG("std::thread waitSignalAndEmit create New!!");
         //绛夊緟涓嬪眰ffmpeg灏唕tp鍖呰В鐮佹垚涓哄浘鐗囧悗瑙﹀彂淇″彿,鐒跺悗瑙﹀彂褰撳墠绫荤殑submit
         std::thread waitSignalAndEmit([&](BASICGB28181::VideoCaptureElementWithRtp *p_this) {
@@ -119,7 +120,7 @@
                 usleep(1000000);
                 //闃诲绾跨▼锛岀瓑寰呭閮ㄨЕ鍙戝叧闂偣鎾�
                 while (p_this->m_running) {
-                    if(p_this->m_fFmpegDecoderJPG.getRunning()) {
+                    if (p_this->m_fFmpegDecoderJPG.getRunning()) {
                         usleep(300000);
                     } else {
 
@@ -204,20 +205,20 @@
 
 void BASICGB28181::VideoCaptureElementWithRtp::threadFunc() {
 
-//    if ((!m_running) || (!m_waitSignal)) {
-////        鏍规嵁reopenTime鍒ゆ柇鏄惁闇�瑕侀噸鍚�
-//        if (reopenTime < 0) {
-//            stop();
-//            INFO("grabFrame faild, element stopping");
-//            return;
-//        } else {
-//            //todo 涓氬姟姝婚攣
-//            usleep(reopenTime * 1000);
-//            INFO("grabFrame faild, try reopen video: ");
-//            startRtpStream(m_streamTransType);
-//            return;
-//        }
-//    }
+    if (m_publishVideoRet) {
+        if (videoPublishElement == nullptr) {
+            string path = appConfig.getStringProperty("srsAddr") + "cam" + m_chanPubID + ".flv";
+            cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height"));
+            int gupIdx = appPref.getIntData("gpu.index");
+            videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx);
+        } else {
+            videoPublishElement->stop();
+            videoPublishElement->wait();
+            delete videoPublishElement;
+            videoPublishElement = nullptr;
+        }
+    }
+
     fireConnectors();
 }
 
@@ -270,3 +271,11 @@
 
     return t_FilePath;
 }
+
+void BASICGB28181::VideoCaptureElementWithRtp::startPublishVideo() {
+    m_publishVideoRet = true;
+}
+
+void BASICGB28181::VideoCaptureElementWithRtp::stopPublishVideo() {
+    m_publishVideoRet = false;
+}

--
Gitblit v1.8.0