Commit 4a6da4b1041d90de8fd80da367b7ee3b24ac1f6a
1 parent
64a12438
添加SipServer初始化;修复dvpp解码跳帧参数不起作用问题
Showing
4 changed files
with
51 additions
and
20 deletions
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -22,6 +22,8 @@ |
22 | 22 | |
23 | 23 | #include "../util/vpc_util.h" |
24 | 24 | |
25 | +#include "../decoder/gb28181/sip/SipServer.h" | |
26 | + | |
25 | 27 | // #define VEHICLE_MULTI_BOXES |
26 | 28 | |
27 | 29 | #define WITH_FACE_DET_SS |
... | ... | @@ -84,19 +86,21 @@ CMultiSourceProcess::~CMultiSourceProcess(){ |
84 | 86 | } |
85 | 87 | |
86 | 88 | int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ |
89 | + | |
90 | + set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); | |
91 | + LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); | |
92 | + | |
87 | 93 | // #ifdef USE_VILLAGE |
88 | 94 | // if (!CheckTime()) { //时间限制 |
89 | -// std::cout << "sy_licence_check failed." << std::endl; | |
95 | +// LOG_ERROR("sy_licence_check failed."); | |
90 | 96 | // return AUTHOR_ERROR; |
91 | 97 | // } |
92 | 98 | // #else |
93 | 99 | // if (!CheckLabel(vptParam.gpuid)) { //机器授权 |
94 | -// std::cout << "sy_licence_check failed." << std::endl; | |
100 | +// LOG_ERROR("CheckLabel failed."); | |
95 | 101 | // return AUTHOR_ERROR; |
96 | 102 | // } |
97 | 103 | // #endif |
98 | - set_default_logger(LogLevel(vptParam.log_level), "multi_source_process", vptParam.log_path, vptParam.log_mem, vptParam.log_mem); | |
99 | - LOG_INFO("编译时间:{} {}", __DATE__, __TIME__); | |
100 | 104 | |
101 | 105 | SourceSingleton::getInstance(); |
102 | 106 | |
... | ... | @@ -223,6 +227,21 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ |
223 | 227 | VPCUtil* pVpcUtil = VPCUtil::getInstance(); |
224 | 228 | pVpcUtil->init(m_devId); |
225 | 229 | |
230 | + // 初始化SIP服务器 | |
231 | + ServerInfo info( | |
232 | + "SY_Sip_Server", | |
233 | + "12345678", | |
234 | + "192.168.60.179", | |
235 | + 15060, | |
236 | + "34020000002000000002", | |
237 | + "3402000000", | |
238 | + "sy123456", | |
239 | + 1800, | |
240 | + 3600); | |
241 | + | |
242 | + SipServer* pSipServer = SipServer::getInstance(); | |
243 | + pSipServer->Init(info); | |
244 | + | |
226 | 245 | m_pAlgorthimThread = new thread([](void* arg) { |
227 | 246 | CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; |
228 | 247 | process->algorthim_process_thread(); |
... | ... | @@ -329,15 +348,20 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
329 | 348 | if (1 == _cur_task_param.dec_type){ |
330 | 349 | config.cfg.port = _cur_task_param.port; |
331 | 350 | config.dec_type = DECODER_TYPE_GB28181; |
332 | - config.cfg.uri = task_id; | |
333 | 351 | if(_cur_task_param.protocal == 0){ |
334 | 352 | // 指定用udp协议 |
335 | 353 | config.cfg.force_tcp = false; |
336 | 354 | } |
337 | 355 | config.cfg.request_stream_cbk = _cur_task_param.gb28181_request_stream_callback ; |
338 | - }else if (2 == _cur_task_param.dec_type){ | |
356 | + } else if (2 == _cur_task_param.dec_type){ | |
339 | 357 | config.dec_type = DECODER_TYPE_DVPP; |
340 | - }else { | |
358 | + } else if (3 == _cur_task_param.dec_type){ | |
359 | + config.dec_type = DECODER_TYPE_DVPP_GB28181; | |
360 | + if(_cur_task_param.protocal == 0){ | |
361 | + // 指定用udp协议 | |
362 | + config.cfg.force_tcp = false; | |
363 | + } | |
364 | + } else { | |
341 | 365 | config.dec_type = DECODER_TYPE_FFMPEG; |
342 | 366 | } |
343 | 367 | |
... | ... | @@ -788,12 +812,8 @@ int CMultiSourceProcess::algorthim_process_thread(){ |
788 | 812 | |
789 | 813 | while (!m_RgbDataList.empty()){ |
790 | 814 | DeviceMemory* gpuMem = m_RgbDataList.front(); |
791 | - // if(gpuMem->getMem() == nullptr) { | |
792 | - if(gpuMem->getMem() == nullptr || gpuMem->getFrameNb() % skip_frame_) { //跳帧 | |
793 | - // 错误数据,直接删除 | |
794 | - if(gpuMem->getMem() == nullptr) LOG_WARN("mem is null"); | |
795 | - delete gpuMem; | |
796 | - gpuMem = nullptr; | |
815 | + if(gpuMem->getMem() == nullptr) { | |
816 | + LOG_WARN("mem is null"); | |
797 | 817 | } else { |
798 | 818 | vec_gpuMem.push_back(gpuMem); |
799 | 819 | } | ... | ... |
src/ai_platform/header.h
... | ... | @@ -493,7 +493,7 @@ typedef struct task_param { |
493 | 493 | algor_config_param *algor_config_params; //该路rtsp流配置的所有算法参数 |
494 | 494 | int algor_counts; //该路rtsp流共配置几种算法 |
495 | 495 | |
496 | - int dec_type{0}; // 0: ffmpeg 1: gb28181 2:dvpp | |
496 | + int dec_type{0}; // 0: ffmpeg 1: gb28181 2:dvpp 3: dvpp_gb28181 | |
497 | 497 | int port; // gb28181时port为必填 |
498 | 498 | int protocal; // gb28181 数据接收协议 0 : udp 1: tcp |
499 | 499 | GB28181_REQUEST_STREAM_CALLBACK gb28181_request_stream_callback; | ... | ... |
src/decoder/dvpp/DvppDecoder.cpp
... | ... | @@ -84,6 +84,7 @@ DvppDecoder::~DvppDecoder(){ |
84 | 84 | bool DvppDecoder::init(FFDecConfig cfg){ |
85 | 85 | |
86 | 86 | m_dec_name = cfg.dec_name; |
87 | + m_frameSkip = cfg.skip_frame; | |
87 | 88 | |
88 | 89 | AVCodecContext* avctx = init_FFmpeg(cfg); |
89 | 90 | if(avctx == nullptr){ |
... | ... | @@ -855,8 +856,9 @@ bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { |
855 | 856 | return true; |
856 | 857 | } |
857 | 858 | |
858 | -void DvppDecoder::display_thread(){ | |
859 | +void DvppDecoder::display_thread() { | |
859 | 860 | LOG_INFO("[{}]- display_thread start...", m_dec_name); |
861 | + unsigned long index = 0; | |
860 | 862 | while(!m_bExitDisplayThd) { |
861 | 863 | m_decoded_data_queue_mtx.lock(); |
862 | 864 | if(m_decoded_data_queue.size() <= 0) { |
... | ... | @@ -869,11 +871,18 @@ void DvppDecoder::display_thread(){ |
869 | 871 | m_decoded_data_queue.pop(); |
870 | 872 | m_decoded_data_queue_mtx.unlock(); |
871 | 873 | |
872 | - if(post_decoded_cbk) { | |
873 | - post_decoded_cbk(m_postDecArg, mem); | |
874 | - } else { | |
875 | - delete mem; | |
876 | - mem = nullptr; | |
874 | + if (mem) { | |
875 | + if ((m_frameSkip == 1 || index % m_frameSkip == 0) && post_decoded_cbk){ | |
876 | + post_decoded_cbk(m_postDecArg, mem); | |
877 | + } else { | |
878 | + delete mem; | |
879 | + mem = nullptr; | |
880 | + } | |
881 | + } | |
882 | + | |
883 | + index++; | |
884 | + if(index >= 100000){ | |
885 | + index = 0; | |
877 | 886 | } |
878 | 887 | } |
879 | 888 | ... | ... |