From 438d661832cce9431ec1b56aa13aae61cb896b47 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期六, 30 三月 2019 18:36:45 +0800
Subject: [PATCH] C_RealVideoStart失败后再次打开
---
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h | 1
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp | 96 ++++++++++++++++++++++++++----------------------
2 files changed, 53 insertions(+), 44 deletions(-)
diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
index 8859d91..2f7010f 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -35,44 +35,49 @@
bool BASICGB28181::VideoCaptureElementWithRtp::startRtpStream(int streamTransType) {
- //绛夊緟涓嬪眰ffmpeg灏唕tp鍖呰В鐮佹垚涓哄浘鐗囧悗瑙﹀彂淇″彿,鐒跺悗瑙﹀彂褰撳墠绫荤殑submit
- std::thread waitSignalAndEmit([&](BASICGB28181::VideoCaptureElementWithRtp *p_this) {
- p_this->m_waitSignal = true;
- //寰幆锛岀敱鎴愬憳鍙橀噺鏉ョ淮鎶よ繖涓嚎绋嬬殑杩愯鐘舵��
- while (p_this->m_waitSignal) {
+ if(!m_waitSignalrunning) {
+ DBG("std::thread waitSignalAndEmit create New!!");
+ //绛夊緟涓嬪眰ffmpeg灏唕tp鍖呰В鐮佹垚涓哄浘鐗囧悗瑙﹀彂淇″彿,鐒跺悗瑙﹀彂褰撳墠绫荤殑submit
+ std::thread waitSignalAndEmit([&](BASICGB28181::VideoCaptureElementWithRtp *p_this) {
+ p_this->m_waitSignal = true;
+ p_this->m_waitSignalrunning = true;
+ //寰幆锛岀敱鎴愬憳鍙橀噺鏉ョ淮鎶よ繖涓嚎绋嬬殑杩愯鐘舵��
+ while (p_this->m_waitSignal) {
//#TODO wait test
#ifdef TestCode
- DBG("waitSignal(\"DecoderImageOK\") begin");
+ DBG("waitSignal(\"DecoderImageOK\") begin");
#endif
- //绛夊緟淇″彿瑙﹀彂
- gSignalLock.waitSignal(p_this->m_chanPubID + "DecoderImageOK");
+ //绛夊緟淇″彿瑙﹀彂
+ gSignalLock.waitSignal(p_this->m_chanPubID + "DecoderImageOK");
#ifdef TestCode
- DBG("waitSignal(\"DecoderImageOK\") after");
+ DBG("waitSignal(\"DecoderImageOK\") after");
#endif
- /****褰曞儚妯″潡浠g爜*****/
- p_this->m_picCount++;
- //鍑犲紶閫変竴寮犳斁鍏edis
- if (p_this->m_picCount % m_nPicsPickOne != 0) {
- continue;
- } else {
- p_this->m_picCount.store(0);
- }
+ /****褰曞儚妯″潡浠g爜*****/
+ p_this->m_picCount++;
+ //鍑犲紶閫変竴寮犳斁鍏edis
+ if (p_this->m_picCount % m_nPicsPickOne != 0) {
+ continue;
+ } else {
+ p_this->m_picCount.store(0);
+ }
// 浠巉fmpeg瑙g爜绫讳腑鑾峰彇鍥剧墖
- p_this->m_fFmpegDecoderJPG.getImage().copyTo(p_this->m_image);
- {
- cv::Mat copyMat;
- std::string imageName = p_this->m_fFmpegDecoderJPG.GetImageName();
- p_this->m_image.copyTo(copyMat);
- m_pManager->SaveImageToRedis(p_this->m_chanPubID, imageName, copyMat);
- }
- /*********/
+ p_this->m_fFmpegDecoderJPG.getImage().copyTo(p_this->m_image);
+ {
+ cv::Mat copyMat;
+ std::string imageName = p_this->m_fFmpegDecoderJPG.GetImageName();
+ p_this->m_image.copyTo(copyMat);
+ m_pManager->SaveImageToRedis(p_this->m_chanPubID, imageName, copyMat);
+ }
+ /*********/
- p_this->submit();
- }
- INFO("waitSignalAndEmit is exit...");
- }, this);
- waitSignalAndEmit.detach();
+ p_this->submit();
+ }
+ p_this->m_waitSignalrunning = false;
+ INFO("waitSignalAndEmit is exit...");
+ }, this);
+ waitSignalAndEmit.detach();
+ }
TryCath(
//--------------鍥芥爣璁惧鎴栧垯鍥芥爣涓嬬骇骞冲彴蹇呴』鏀寔GB28181-2016----------------------------------------------
@@ -146,9 +151,12 @@
//鐐规挱澶辫触
p_this->m_waitSignal = false;
p_this->m_running = false;
+
//鍏抽棴ffmpeg瑙g爜妯″潡
p_this->m_fFmpegDecoderJPG.stopThd();
ERR(p_this->m_chanPubID << " C_RealVideoStart is error lrealhandle is " << lrealhandle);
+
+ p_this->startRtpStream(p_this->m_streamTransType);
}
}, this, streamTransType);
@@ -196,20 +204,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_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;
+// }
+// }
fireConnectors();
}
diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
index 5f98e6a..f2915cc 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
@@ -68,6 +68,7 @@
std::atomic<bool> m_running;
std::atomic<bool> m_waitSignal;
+ std::atomic<bool> m_waitSignalrunning;
//鐢ㄦ潵淇濆瓨褰曞儚瑙嗛鐨勮矾寰�
std::string m_cutPath;
--
Gitblit v1.8.0