diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index bc7c94c..b354cce 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -22,6 +22,8 @@ #include "../util/vpc_util.h" +#include "../decoder/gb28181/sip/SipServer.h" + // #define VEHICLE_MULTI_BOXES #define WITH_FACE_DET_SS @@ -84,19 +86,21 @@ CMultiSourceProcess::~CMultiSourceProcess(){ } int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ + + set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); + LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); + // #ifdef USE_VILLAGE // if (!CheckTime()) { //时间限制 -// std::cout << "sy_licence_check failed." << std::endl; +// LOG_ERROR("sy_licence_check failed."); // return AUTHOR_ERROR; // } // #else // if (!CheckLabel(vptParam.gpuid)) { //机器授权 -// std::cout << "sy_licence_check failed." << std::endl; +// LOG_ERROR("CheckLabel failed."); // return AUTHOR_ERROR; // } // #endif - set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); - LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); SourceSingleton::getInstance(); @@ -223,6 +227,21 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ VPCUtil* pVpcUtil = VPCUtil::getInstance(); pVpcUtil->init(m_devId); + // 初始化SIP服务器 + ServerInfo info( + "SY_Sip_Server", + "12345678", + "192.168.60.179", + 15060, + "34020000002000000002", + "3402000000", + "sy123456", + 1800, + 3600); + + SipServer* pSipServer = SipServer::getInstance(); + pSipServer->Init(info); + m_pAlgorthimThread = new thread([](void* arg) { CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; process->algorthim_process_thread(); @@ -329,15 +348,20 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ if (1 == _cur_task_param.dec_type){ config.cfg.port = _cur_task_param.port; config.dec_type = DECODER_TYPE_GB28181; - config.cfg.uri = task_id; if(_cur_task_param.protocal == 0){ // 指定用udp协议 config.cfg.force_tcp = false; } config.cfg.request_stream_cbk = _cur_task_param.gb28181_request_stream_callback ; - }else if (2 == _cur_task_param.dec_type){ + } else if (2 == _cur_task_param.dec_type){ config.dec_type = DECODER_TYPE_DVPP; - }else { + } else if (3 == _cur_task_param.dec_type){ + config.dec_type = DECODER_TYPE_DVPP_GB28181; + if(_cur_task_param.protocal == 0){ + // 指定用udp协议 + config.cfg.force_tcp = false; + } + } else { config.dec_type = DECODER_TYPE_FFMPEG; } @@ -788,12 +812,8 @@ int CMultiSourceProcess::algorthim_process_thread(){ while (!m_RgbDataList.empty()){ DeviceMemory* gpuMem = m_RgbDataList.front(); - // if(gpuMem->getMem() == nullptr) { - if(gpuMem->getMem() == nullptr || gpuMem->getFrameNb() % skip_frame_) { //跳帧 - // 错误数据,直接删除 - if(gpuMem->getMem() == nullptr) LOG_WARN("mem is null"); - delete gpuMem; - gpuMem = nullptr; + if(gpuMem->getMem() == nullptr) { + LOG_WARN("mem is null"); } else { vec_gpuMem.push_back(gpuMem); } diff --git a/src/ai_platform/header.h b/src/ai_platform/header.h index 1ee1d76..731d84a 100755 --- a/src/ai_platform/header.h +++ b/src/ai_platform/header.h @@ -493,7 +493,7 @@ typedef struct task_param { algor_config_param *algor_config_params; //该路rtsp流配置的所有算法参数 int algor_counts; //该路rtsp流共配置几种算法 - int dec_type{0}; // 0: ffmpeg 1: gb28181 2:dvpp + int dec_type{0}; // 0: ffmpeg 1: gb28181 2:dvpp 3: dvpp_gb28181 int port; // gb28181时port为必填 int protocal; // gb28181 数据接收协议 0 : udp 1: tcp GB28181_REQUEST_STREAM_CALLBACK gb28181_request_stream_callback; diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index 4f77a12..bc16f29 100644 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -84,6 +84,7 @@ DvppDecoder::~DvppDecoder(){ bool DvppDecoder::init(FFDecConfig cfg){ m_dec_name = cfg.dec_name; + m_frameSkip = cfg.skip_frame; AVCodecContext* avctx = init_FFmpeg(cfg); if(avctx == nullptr){ @@ -855,8 +856,9 @@ bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { return true; } -void DvppDecoder::display_thread(){ +void DvppDecoder::display_thread() { LOG_INFO("[{}]- display_thread start...", m_dec_name); + unsigned long index = 0; while(!m_bExitDisplayThd) { m_decoded_data_queue_mtx.lock(); if(m_decoded_data_queue.size() <= 0) { @@ -869,11 +871,18 @@ void DvppDecoder::display_thread(){ m_decoded_data_queue.pop(); m_decoded_data_queue_mtx.unlock(); - if(post_decoded_cbk) { - post_decoded_cbk(m_postDecArg, mem); - } else { - delete mem; - mem = nullptr; + if (mem) { + if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk){ + post_decoded_cbk(m_postDecArg, mem); + } else { + delete mem; + mem = nullptr; + } + } + + index++; + if(index >= 100000){ + index = 0; } } diff --git a/src/decoder/dvpp/DvppDecoder.h b/src/decoder/dvpp/DvppDecoder.h index 53b5021..4a75329 100644 --- a/src/decoder/dvpp/DvppDecoder.h +++ b/src/decoder/dvpp/DvppDecoder.h @@ -136,6 +136,8 @@ private: uint64_t m_in_count {0}; uint64_t m_out_count {0}; + int m_frameSkip {1}; + std::atomic m_DvppCacheCounter{0}; VpcUtils m_vpcUtils;