#include #include "../DB/LDBTool.h" #include "cutManage.h" #include #include #include //cutManage::cutManage() //{ // init(); //} cutManage::cutManage(LDBTool *dbTool) : TaskManage(dbTool) { init(); } cutManage::~cutManage() { } void cutManage::init(void) { //search all cut_video_info where finish_flag = 0 m_list = db_c->searchCutVideoTableAll(); } getCutFileManage cutManage::getTask(void) { getCutFileManage result; if (m_list.size() > 0) { //get task from cut_video_info Record_Cut_Video_info rec = *m_list.begin(); m_list.pop_front(); result.src_path = rec.str_src_path.toStdString(); } else { //get task from load_file_info //search oldest update time record Record_Load_File_info rec = db_c->searchOldestRecordfromLoadTableByUpdateTime(); if (rec.n_id == 0 || rec.str_storage_dev_id.size() <= 0) { DBG("searchOldestRecordfromChnTableByUpdateTime NULL"); return result; } result.src_path = rec.str_load_file_path.toStdString(); //修改更新时间 rec.tim_update_time = QDateTime::currentDateTime(); //insert rec to cut_video_info && delete load_file_info Record_Cut_Video_info cutVideoRec = {0, rec.str_storage_dev_id, rec.n_chn, rec.str_load_file_path, "", 0, false, QDateTime::currentDateTime(), ""}; bool ret = db_c->insertCutVideoTableAndDeleteLoadFileTable(cutVideoRec, rec.str_storage_dev_id, rec.n_chn, rec.tim_do_time); if (!ret) { return getCutFileManage(); } } return result; } bool cutManage::finishTask(const pfinishCutFileManage finishInfo) { //根据devID&chn&src_path更改cut_video_info完成标志和目标路径,total return db_c->updateCutVideoTable(finishInfo->src_path, finishInfo->dst_path, finishInfo->total); }