chenshijun
2019-03-30 91c3b892e976ecf33819c0c2664e4dfcfd88e434
添加新版本的GB28181代码
7个文件已修改
66 ■■■■ 已修改文件
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/GB28181Server.h 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.h 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -32,7 +32,7 @@
              dst.data, dst.linesize);
    sws_freeContext(convert_ctx);
    DBG("m.size is " << m.size());
//    DBG("m.size is " << m.size());
//    LOG_IF();
    return m;
@@ -197,6 +197,12 @@
                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;
@@ -446,7 +452,7 @@
            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);
            }
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.h
@@ -37,6 +37,7 @@
}
#include <mutex>
#include <basic/pipe/TimerElement.h>
namespace BASICGB28181 {
QiaoJiaSystem/GB28181DecoderModel/GB28181Server.h
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <VideoToImageMulth/RtspAnalysManager.h>
#include "28181SDK.h"
#include "SpinLock.hpp"
@@ -80,10 +81,20 @@
    //打印事件回调信息
    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");
            }
        }
    }
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -111,14 +111,30 @@
                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 ...");
                //停止点播
@@ -187,6 +203,7 @@
            INFO("grabFrame faild, element stopping");
            return;
        } else {
            //todo 业务死锁
            usleep(reopenTime * 1000);
            INFO("grabFrame faild, try reopen video: ");
            startRtpStream(m_streamTransType);
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h
@@ -53,7 +53,7 @@
        std::string MakeDir(const std::string &timeStamp);
    private:
        int reopenTime{1000};
        int reopenTime{10};
        int m_gpuIdx;
        int m_fps;
        int m_streamTransType;
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
@@ -7,10 +7,11 @@
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();
}
@@ -41,6 +42,9 @@
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) {
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.h
@@ -19,7 +19,8 @@
//#include <VideoToImageMulth/rpc/RtspAnalysServer.h>
//using BASICGB28181::VideoCaptureElementWithRtp;
//外部使用的全局指针
extern void *gRtspAnalysManagerCamera;
//用来实现recordVideo的RPC的接口类
class RtspAnalysManager : public ::RtspAnalys::RtspAnalysServer {