Commit 4a6da4b1041d90de8fd80da367b7ee3b24ac1f6a

Authored by Hu Chunming
1 parent 64a12438

添加SipServer初始化;修复dvpp解码跳帧参数不起作用问题

src/ai_platform/MultiSourceProcess.cpp
@@ -22,6 +22,8 @@ @@ -22,6 +22,8 @@
22 22
23 #include "../util/vpc_util.h" 23 #include "../util/vpc_util.h"
24 24
  25 +#include "../decoder/gb28181/sip/SipServer.h"
  26 +
25 // #define VEHICLE_MULTI_BOXES 27 // #define VEHICLE_MULTI_BOXES
26 28
27 #define WITH_FACE_DET_SS 29 #define WITH_FACE_DET_SS
@@ -84,19 +86,21 @@ CMultiSourceProcess::~CMultiSourceProcess(){ @@ -84,19 +86,21 @@ CMultiSourceProcess::~CMultiSourceProcess(){
84 } 86 }
85 87
86 int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ 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 // #ifdef USE_VILLAGE 93 // #ifdef USE_VILLAGE
88 // if (!CheckTime()) { //时间限制 94 // if (!CheckTime()) { //时间限制
89 -// std::cout << "sy_licence_check failed." << std::endl; 95 +// LOG_ERROR("sy_licence_check failed.");
90 // return AUTHOR_ERROR; 96 // return AUTHOR_ERROR;
91 // } 97 // }
92 // #else 98 // #else
93 // if (!CheckLabel(vptParam.gpuid)) { //机器授权 99 // if (!CheckLabel(vptParam.gpuid)) { //机器授权
94 -// std::cout << "sy_licence_check failed." << std::endl; 100 +// LOG_ERROR("CheckLabel failed.");
95 // return AUTHOR_ERROR; 101 // return AUTHOR_ERROR;
96 // } 102 // }
97 // #endif 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 SourceSingleton::getInstance(); 105 SourceSingleton::getInstance();
102 106
@@ -223,6 +227,21 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ @@ -223,6 +227,21 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){
223 VPCUtil* pVpcUtil = VPCUtil::getInstance(); 227 VPCUtil* pVpcUtil = VPCUtil::getInstance();
224 pVpcUtil->init(m_devId); 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 m_pAlgorthimThread = new thread([](void* arg) { 245 m_pAlgorthimThread = new thread([](void* arg) {
227 CMultiSourceProcess* process = (CMultiSourceProcess*)arg ; 246 CMultiSourceProcess* process = (CMultiSourceProcess*)arg ;
228 process->algorthim_process_thread(); 247 process->algorthim_process_thread();
@@ -329,15 +348,20 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ @@ -329,15 +348,20 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){
329 if (1 == _cur_task_param.dec_type){ 348 if (1 == _cur_task_param.dec_type){
330 config.cfg.port = _cur_task_param.port; 349 config.cfg.port = _cur_task_param.port;
331 config.dec_type = DECODER_TYPE_GB28181; 350 config.dec_type = DECODER_TYPE_GB28181;
332 - config.cfg.uri = task_id;  
333 if(_cur_task_param.protocal == 0){ 351 if(_cur_task_param.protocal == 0){
334 // 指定用udp协议 352 // 指定用udp协议
335 config.cfg.force_tcp = false; 353 config.cfg.force_tcp = false;
336 } 354 }
337 config.cfg.request_stream_cbk = _cur_task_param.gb28181_request_stream_callback ; 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 config.dec_type = DECODER_TYPE_DVPP; 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 config.dec_type = DECODER_TYPE_FFMPEG; 365 config.dec_type = DECODER_TYPE_FFMPEG;
342 } 366 }
343 367
@@ -788,12 +812,8 @@ int CMultiSourceProcess::algorthim_process_thread(){ @@ -788,12 +812,8 @@ int CMultiSourceProcess::algorthim_process_thread(){
788 812
789 while (!m_RgbDataList.empty()){ 813 while (!m_RgbDataList.empty()){
790 DeviceMemory* gpuMem = m_RgbDataList.front(); 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 } else { 817 } else {
798 vec_gpuMem.push_back(gpuMem); 818 vec_gpuMem.push_back(gpuMem);
799 } 819 }
src/ai_platform/header.h
@@ -493,7 +493,7 @@ typedef struct task_param { @@ -493,7 +493,7 @@ typedef struct task_param {
493 algor_config_param *algor_config_params; //该路rtsp流配置的所有算法参数 493 algor_config_param *algor_config_params; //该路rtsp流配置的所有算法参数
494 int algor_counts; //该路rtsp流共配置几种算法 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 int port; // gb28181时port为必填 497 int port; // gb28181时port为必填
498 int protocal; // gb28181 数据接收协议 0 : udp 1: tcp 498 int protocal; // gb28181 数据接收协议 0 : udp 1: tcp
499 GB28181_REQUEST_STREAM_CALLBACK gb28181_request_stream_callback; 499 GB28181_REQUEST_STREAM_CALLBACK gb28181_request_stream_callback;
src/decoder/dvpp/DvppDecoder.cpp
@@ -84,6 +84,7 @@ DvppDecoder::~DvppDecoder(){ @@ -84,6 +84,7 @@ DvppDecoder::~DvppDecoder(){
84 bool DvppDecoder::init(FFDecConfig cfg){ 84 bool DvppDecoder::init(FFDecConfig cfg){
85 85
86 m_dec_name = cfg.dec_name; 86 m_dec_name = cfg.dec_name;
  87 + m_frameSkip = cfg.skip_frame;
87 88
88 AVCodecContext* avctx = init_FFmpeg(cfg); 89 AVCodecContext* avctx = init_FFmpeg(cfg);
89 if(avctx == nullptr){ 90 if(avctx == nullptr){
@@ -855,8 +856,9 @@ bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { @@ -855,8 +856,9 @@ bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) {
855 return true; 856 return true;
856 } 857 }
857 858
858 -void DvppDecoder::display_thread(){ 859 +void DvppDecoder::display_thread() {
859 LOG_INFO("[{}]- display_thread start...", m_dec_name); 860 LOG_INFO("[{}]- display_thread start...", m_dec_name);
  861 + unsigned long index = 0;
860 while(!m_bExitDisplayThd) { 862 while(!m_bExitDisplayThd) {
861 m_decoded_data_queue_mtx.lock(); 863 m_decoded_data_queue_mtx.lock();
862 if(m_decoded_data_queue.size() <= 0) { 864 if(m_decoded_data_queue.size() <= 0) {
@@ -869,11 +871,18 @@ void DvppDecoder::display_thread(){ @@ -869,11 +871,18 @@ void DvppDecoder::display_thread(){
869 m_decoded_data_queue.pop(); 871 m_decoded_data_queue.pop();
870 m_decoded_data_queue_mtx.unlock(); 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
src/decoder/dvpp/DvppDecoder.h
@@ -136,6 +136,8 @@ private: @@ -136,6 +136,8 @@ private:
136 uint64_t m_in_count {0}; 136 uint64_t m_in_count {0};
137 uint64_t m_out_count {0}; 137 uint64_t m_out_count {0};
138 138
  139 + int m_frameSkip {1};
  140 +
139 std::atomic<int> m_DvppCacheCounter{0}; 141 std::atomic<int> m_DvppCacheCounter{0};
140 142
141 VpcUtils m_vpcUtils; 143 VpcUtils m_vpcUtils;