| | |
| | | dst.data, dst.linesize); |
| | | sws_freeContext(convert_ctx); |
| | | |
| | | DBG("m.size is " << m.size()); |
| | | // DBG("m.size is " << m.size()); |
| | | // LOG_IF(); |
| | | |
| | | return m; |
| | |
| | | vi = i; |
| | | break; |
| | | } |
| | | } |
| | | if(vi == -1)//无视频包 |
| | | { |
| | | ERR("no video packet!!"); |
| | | p_this->m_running = false; |
| | | continue; |
| | | } |
| | | p_this->stream = p_this->ic->streams[vi]; |
| | | p_this->video_st = p_this->stream; |
| | |
| | | delete iter->m_packet.data; |
| | | iter = m_packetsVec.erase(iter); |
| | | while (!(iter->m_packet.flags & AV_PKT_FLAG_KEY)) { |
| | | INFO("DropFrame: " << iter->m_frameId); |
| | | // INFO("DropFrame: " << iter->m_frameId); |
| | | delete iter->m_packet.data; |
| | | iter = m_packetsVec.erase(iter); |
| | | } |
| | |
| | | } |
| | | |
| | | #include <mutex> |
| | | #include <basic/pipe/TimerElement.h> |
| | | |
| | | namespace BASICGB28181 { |
| | | |
| | |
| | | #include <stdlib.h> |
| | | #include <time.h> |
| | | #include <string.h> |
| | | #include <VideoToImageMulth/RtspAnalysManager.h> |
| | | #include "28181SDK.h" |
| | | #include "SpinLock.hpp" |
| | | |
| | |
| | | //打印事件回调信息 |
| | | static void enventcallback(int eventtype, int eventparam, int datalen, char *data) { |
| | | printf("eventtype:%d, eventparam:%d, datalen:%d, data:%s\n", eventtype, eventparam, datalen, data); |
| | | if (eventtype == 2) { |
| | | if (eventtype == EVENT_DEVICE_CATALOG) { |
| | | // GB28181Server::bGetLoaclRes = true; |
| | | } else if (eventtype == 1 && eventparam == 1) { |
| | | } else if (eventtype == EVENT_REGISTER_STATUS && eventparam == 1) { |
| | | C_GetResource(NULL); |
| | | } else if (eventtype == EVENT_VIDEO_EXCEPTION){ |
| | | if(gRtspAnalysManagerCamera) { |
| | | auto cameraHandlePtr = (RtspAnalysManager *) gRtspAnalysManagerCamera; |
| | | ERR("gRtspAnalysManagerCamera ADDR:" << gRtspAnalysManagerCamera); |
| | | string camID(data, datalen); |
| | | ERR("EVENT_VIDEO_EXCEPTION reopen camID:" << camID); |
| | | cameraHandlePtr->addCamera(camID, camID); |
| | | }else{ |
| | | ERR("gRtspAnalysManagerCamera is nullptr"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | p_this->m_running = true; |
| | | //启动ffmpeg解码模块 |
| | | p_this->m_fFmpegDecoderJPG.startThd(p_this->m_chanPubID, p_this->m_fps, p_this->m_gpuIdx); |
| | | usleep(1000000); |
| | | //阻塞线程,等待外部触发关闭点播 |
| | | while (p_this->m_running) { |
| | | // if(p_this->m_fFmpegDecoderJPG.getRunning()) { |
| | | usleep(300000); |
| | | // }else{ |
| | | // p_this->m_running = false; |
| | | // break; |
| | | // } |
| | | if(p_this->m_fFmpegDecoderJPG.getRunning()) { |
| | | usleep(300000); |
| | | } else { |
| | | |
| | | // 根据reopenTime判断是否需要重启 |
| | | if (reopenTime < 0) { |
| | | p_this->m_running = false; |
| | | stop(); |
| | | INFO("grabFrame faild, element stopping"); |
| | | } else { |
| | | //todo 业务死锁 |
| | | usleep((6 - reopenTime--) * 1000000); |
| | | INFO("grabFrame faild, try reopen video: "); |
| | | |
| | | //关闭ffmpeg解码模块 |
| | | p_this->m_fFmpegDecoderJPG.stopThd(); |
| | | //启动ffmpeg解码模块 |
| | | p_this->m_fFmpegDecoderJPG.startThd(p_this->m_chanPubID, p_this->m_fps, p_this->m_gpuIdx); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | DBG("videoCaptureElementThd stop ..."); |
| | | //停止点播 |
| | |
| | | INFO("grabFrame faild, element stopping"); |
| | | return; |
| | | } else { |
| | | //todo 业务死锁 |
| | | usleep(reopenTime * 1000); |
| | | INFO("grabFrame faild, try reopen video: "); |
| | | startRtpStream(m_streamTransType); |
| | |
| | | std::string MakeDir(const std::string &timeStamp); |
| | | |
| | | private: |
| | | int reopenTime{1000}; |
| | | int reopenTime{10}; |
| | | int m_gpuIdx; |
| | | int m_fps; |
| | | int m_streamTransType; |
| | |
| | | |
| | | |
| | | using std::string; |
| | | void *gRtspAnalysManagerCamera = nullptr; |
| | | |
| | | RtspAnalysManager::RtspAnalysManager(LDBTool *_dbTool) : m_lDBTool(nullptr), m_maxCount(50), m_currentCount(0) { |
| | | // INFO("MYH DEBUG HERE"); |
| | | m_lDBTool = new LDBTool; |
| | | m_lDBTool = _dbTool; |
| | | init(); |
| | | |
| | | } |
| | |
| | | void RtspAnalysManager::init() { |
| | | // INFO("MYH DEBUG HERE") |
| | | |
| | | gRtspAnalysManagerCamera = this; |
| | | DBG("gRtspAnalysManagerCamera ADDR:" << gRtspAnalysManagerCamera); |
| | | |
| | | m_GB28181_Enable = appPref.getIntData("GB28181_Enable"); |
| | | //#todo GB28181 |
| | | if (m_GB28181_Enable) { |
| | |
| | | //#include <VideoToImageMulth/rpc/RtspAnalysServer.h> |
| | | |
| | | //using BASICGB28181::VideoCaptureElementWithRtp; |
| | | |
| | | //外部使用的全局指针 |
| | | extern void *gRtspAnalysManagerCamera; |
| | | //用来实现recordVideo的RPC的接口类 |
| | | class RtspAnalysManager : public ::RtspAnalys::RtspAnalysServer { |
| | | |