93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
/*
|
|
* @Date: 2024-09-04 14:52:27
|
|
* @LastEditors: Jacky
|
|
* @LastEditTime: 2024-09-11 11:44:01
|
|
* @FilePath: /GeneralTracker/Universal/CModuleVdec.cpp
|
|
*/
|
|
#include "CModuleVdec.h"
|
|
#include "InterfaceVdec.h"
|
|
#include "IDebugTouch.h"
|
|
|
|
int CModuleVdec::create(const char* name){
|
|
m_pcName = std::string(name);
|
|
m_pSelfQueue.queueInit(m_pcName, QUEUE_SIZE, pool::QUEUE_OWNER);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int CModuleVdec::destroy(){
|
|
stop();
|
|
return 0;
|
|
}
|
|
|
|
int CModuleVdec::set_data(const char* data, void* value){
|
|
return 0;
|
|
}
|
|
|
|
char* CModuleVdec::get_data(){
|
|
return nullptr;
|
|
}
|
|
|
|
int CModuleVdec::start(const char* data){
|
|
if(_vi_thread){
|
|
return -1;
|
|
}
|
|
|
|
ICaptureConfig config("./config/capture.json");
|
|
config.parse(m_pcName, [this](ICaptureConfig::capture_config_t ¶m) ->int {
|
|
_chn = param.chn;
|
|
|
|
printf("decode :%d, url:%s\n", param.chn, param.url.c_str());
|
|
|
|
DecodeAttr_t attr;
|
|
attr.outputFormat = GD_PIXEL_FORMAT_NV12;
|
|
attr.dstWidth = param.width;
|
|
attr.dstHeight = param.height;
|
|
decodeOpen(param.chn, param.url, &attr, nullptr, nullptr);
|
|
decodeStart(param.chn);
|
|
return 0;
|
|
});
|
|
|
|
_thread_flag = true;
|
|
_vi_thread = new std::thread(std::bind(&CModuleVdec::moduleThread, std::ref(*this)));
|
|
return 0;
|
|
}
|
|
int CModuleVdec::stop(){
|
|
if(_vi_thread){
|
|
_thread_flag = false;
|
|
_vi_thread->join();
|
|
delete _vi_thread;
|
|
_vi_thread = nullptr;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void CModuleVdec::push_data(DataProcessBase *src, pool::IMemoryBlock* block){
|
|
m_pSelfQueue.sendFrame(block);
|
|
}
|
|
|
|
int CModuleVdec::moduleThread(){
|
|
int timeout = 500;
|
|
_fps = new Fps(m_pcName);
|
|
while(_thread_flag){
|
|
pool::IMemoryBlock* mb = m_pSelfQueue.getFrame(timeout);
|
|
if(mb){
|
|
AdditionalImp* imp = mb->data();
|
|
GD_VIDEO_FRAME_S *frame = mb->yuv();
|
|
|
|
//解码图像
|
|
int ret = decodeGetFrame(_chn, frame);
|
|
if(ret == 0){
|
|
IDebugTouch touch("./dump_decode");
|
|
touch.dump(frame, "./decode.yuv");
|
|
|
|
_fps->fps();
|
|
push_input_pipe(mb);
|
|
}
|
|
m_pSelfQueue.releaseFrame(mb);
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
}
|
|
}
|
|
return 0;
|
|
}
|