From 00f7c180ceedecab842ce2a05308f435f9f54718 Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期二, 09 四月 2019 14:24:19 +0800
Subject: [PATCH] # Type(<scope>): <subject>
---
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h | 2 +-
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp | 38 ++++++++++++++++++++++++++++----------
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp | 18 +++++++++++++++++-
3 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index af7f598..f1386f5 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -5,6 +5,7 @@
#include <zconf.h>
#include <opencv2/opencv.hpp>
#include "FFmpegDecoderJPG.h"
+#include <cstring>
void BASICGB28181::initFFmpeg() {
av_register_all();
@@ -278,6 +279,20 @@
// BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image);
p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(p_this->frame));
+ if(p_this->m_image.empty()) {
+ ERR("camID:" << p_this->m_camIdx << " frameW:" << p_this->frame->width << "frame.data.len" << strlen(p_this->frame->data[0]));
+ continue;
+ }
+// else {
+// static int count =0;
+// count ++;
+// if(count > 100){
+// ERR("camID:" << p_this->m_camIdx << " cols:" << p_this->m_image.cols <<\
+// " rows:" << p_this->m_image.rows << " channels:" << p_this->m_image.channels());
+// count = 0;
+// }
+//
+// }
// 灏唅甯т繚瀛樹负蹇収
if (p_this->m_SnapshotNotSaveRet && (p_this->pkt.flags & AV_PKT_FLAG_KEY)) {
try {
@@ -317,6 +332,7 @@
#endif
//瑙﹀彂涓婂眰淇″彿
gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
+// DBG("emitSigal: " << p_this->m_camIdx);
//#ifdef TestCode
// DBG("emitSigal(\"DecoderImageOK\") after");
//#endif
@@ -536,7 +552,7 @@
m_frameIndex++;
m_packetsVec.push_back({m_frameIndex, newPacket});
if (newPacket.flags & AV_PKT_FLAG_KEY) {
- DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
+// DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
m_last_I_FrameId = m_frameIndex;
}
}
diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
index 9b7b775..fdd97a4 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -49,28 +49,45 @@
DBG("waitSignal(\"DecoderImageOK\") begin");
#endif
//绛夊緟淇″彿瑙﹀彂
+// DBG("waitSignal before: " << p_this->m_chanPubID);
gSignalLock.waitSignal(p_this->m_chanPubID + "DecoderImageOK");
+// DBG("waitSignal: " << p_this->m_chanPubID);
#ifdef TestCode
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);
- }
+
// 浠巉fmpeg瑙g爜绫讳腑鑾峰彇鍥剧墖
p_this->m_fFmpegDecoderJPG.getImage().copyTo(p_this->m_image);
+ /****debug*****///todo
+ if (p_this->m_image.empty()) {
+ ERR("camID:" << p_this->m_chanPubID);
+ continue;
+ }
+// else {
+// static int count =0;
+// count ++;
+// if(count > 100){
+// ERR("camID:" << p_this->m_chanPubID << " cols:" << p_this->m_image.cols <<\
+// " rows:" << p_this->m_image.rows << " channels:" << p_this->m_image.channels());
+// count = 0;
+// }
+// }
+
{
+ /****褰曞儚妯″潡浠g爜*****/
+ p_this->m_picCount++;
+ //鍑犲紶閫変竴寮犳斁鍏edis
+ if (p_this->m_picCount % m_nPicsPickOne != 0) {
+ continue;
+ } else {
+ p_this->m_picCount.store(0);
+ }
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_pManager->SaveImageToRedis(p_this->m_chanPubID, imageName, copyMat);
}
- /*********/
p_this->submit();
}
@@ -129,6 +146,7 @@
p_this->m_running = false;
stop();
INFO("grabFrame faild, element stopping");
+ break;
} else {
//todo 涓氬姟姝婚攣
usleep((6 - reopenTime--) * 1000000);
diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
index 0ca39eb..1eaf254 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
@@ -73,7 +73,7 @@
std::atomic<bool> m_running;
std::atomic<bool> m_waitSignal;
- std::atomic<bool> m_waitSignalrunning;
+ std::atomic<bool> m_waitSignalrunning{false};
//鐢ㄦ潵淇濆瓨褰曞儚瑙嗛鐨勮矾寰�
std::string m_cutPath;
--
Gitblit v1.8.0