| | |
| | | img_str.append(fdfsClient.fastFds->getIp() + "/").append(img_tmp); |
| | | img_url.swap(img_str); |
| | | } |
| | | } else { |
| | | std::string img_str = "http://"; |
| | | if (fdfsClient.fastFds != nullptr) { |
| | | img_str.append(fdfsClient.fastFds->getIp() + "/").append(img_url); |
| | | img_url.swap(img_str); |
| | | } |
| | | } |
| | | |
| | | auto t_results = m_curlDownloadImg.download_jpeg(const_cast<char *>(img_url.c_str())); |
| | |
| | | } |
| | | |
| | | |
| | | std::string devHttpServer_c::getAlarmImageFromVideoFileByPicDate(const std::string& devId,const std::string& picDate, |
| | | std::string devHttpServer_c::getAlarmImageByPicDateAndDevId(const std::string& picDate,const std::string& devId, |
| | | PResponse &response) { |
| | | //DBG("ip:" << ip << "; port:" << port); |
| | | //DBG("content: " << content); |
| | | //Json::Reader reader; |
| | | //Json::Value value; |
| | | try { |
| | | //if (reader.parse(content, value)) { |
| | | if(!devId.empty() && !picDate.empty()) |
| | | { |
| | | std::string videoPath; |
| | | //std::string devId = value["videoNum"].asString(); |
| | | //std::string picDate = value["picDate"].asString(); |
| | | |
| | | //std::string path_uuid = videoPath;//value["path_uuid"].asString(); |
| | | qint64 sub; |
| | | std::string path = getVideoPathByPicDate(picDate, devId, sub); |
| | | |
| | |
| | | } |
| | | fdfsClient.rwLock.unlock(); |
| | | std::string result("{\"img_url\":\"" + img_url + "\"}"); |
| | | // cout << result << endl; |
| | | return result; |
| | | } else { |
| | | response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"传输错误,请检查!\"}"); |
| | | return ""; |
| | | // return "{\"error\":\"传输错误,请检查!\"}"; |
| | | } |
| | | } |
| | | catch (std::exception ex) { |
| | |
| | | std::string devId = value["videoNum"].asString(); |
| | | std::string picDate = value["picDate"].asString(); |
| | | std::string imgKey = value["imgKey"].asString(); |
| | | if(imgKey.empty()) |
| | | //兼容旧版本 |
| | | if(imgKey=="undefined" || imgKey.empty()) |
| | | { |
| | | return getAlarmImageFromVideoFileByPicDate(devId,picDate,response); |
| | | return getAlarmImageByPicDateAndDevId(picDate,devId,response); |
| | | } |
| | | else |
| | | { |
| | | return getAlarmImageFromVideoFileByImageKey(devId,imgKey,response); |
| | | return getAlarmImageByImageKeyAndDevId(imgKey,devId,response); |
| | | } |
| | | } |
| | | else{ |
| | |
| | | |
| | | |
| | | |
| | | std::string devHttpServer_c::getAlarmImageFromVideoFileByImageKey(const std::string& devId,const std::string& imgKey, |
| | | std::string devHttpServer_c::getAlarmImageByImageKeyAndDevId(const std::string& imgKey,const std::string& devId, |
| | | PResponse &response) { |
| | | try { |
| | | if (!devId.empty() && !imgKey.empty()) { |
| | |
| | | |
| | | |
| | | std::string |
| | | devHttpServer_c::getRecordVideoPathNew(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | devHttpServer_c::getRecordVideoPath(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | |
| | | std::string picDate = value["picDate"].asString(); |
| | | std::string imgKey = value["imgKey"].asString(); |
| | | std::string path; |
| | | if(imgKey.empty()) |
| | | |
| | | //兼容旧版本 |
| | | if(imgKey=="undefined"||imgKey.empty()) |
| | | { |
| | | qint64 sub; |
| | | path = getVideoPathByPicDate(picDate,devId,sub); |
| | | } |
| | | else |
| | | { |
| | | path = getVideoPathByImgKey(devId,imgKey); |
| | | path = getVideoPathByImgKey(imgKey,devId); |
| | | } |
| | | //std::string path = getVideoPathByImgKey(imgKey, devId, sub); |
| | | ERR("VideoNum: "<<devId <<" PicDate: "<<picDate<<" imgKey: "<<imgKey); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | std::string |
| | | devHttpServer_c::getRecordVideoPath(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | |
| | | INFO("REQ From: "<<ip<<":"<<port<<" Content:"<<content); |
| | | if (reader.parse(content, value)) { |
| | | std::string devId = value["videoNum"].asString(); |
| | | std::string picDate = value["picDate"].asString(); |
| | | std::string imgKey = value["imgKey"].asString(); |
| | | std::string path; |
| | | if(imgKey.empty()) |
| | | { |
| | | qint64 sub; |
| | | path = getVideoPathByPicDate(picDate,devId,sub); |
| | | } |
| | | else |
| | | { |
| | | path = getVideoPathByImgKey(devId,imgKey); |
| | | } |
| | | |
| | | //std::string path = getVideoPathByTime(picDate, devId, sub); |
| | | if (path.empty()) { |
| | | |
| | | return "{\"ret_status\":\"内容有误,请检查!\"}"; |
| | | } else { |
| | | std::string result = "{\"file_path\":\"" + path + "\"}"; |
| | | return result; |
| | | } |
| | | } else { |
| | | return "{\"ret_status\":\"传输错误,请检查!\"}"; |
| | | } |
| | | } |
| | | |
| | | std::string devHttpServer_c::findDevId(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | std::string devHttpServer_c::GetVideoByImgKey(const std::string strImageName,const std::string& strPath) { |
| | | std::string devHttpServer_c::GetVideoNameByImgKey(const std::string& imgKey,const std::string& strPath) { |
| | | static std::mutex g_mutex; |
| | | std::lock_guard<std::mutex> lock(g_mutex); |
| | | std::vector<std::string> vec = forEachFileByImgKey(strPath); |
| | | ImageName_s_t imgSt = ImageName_s_t::fromString(strImageName); |
| | | ImageName_s_t imgSt = ImageName_s_t::fromString(imgKey); |
| | | if(!imgSt.Valid()) |
| | | { |
| | | ERR("ParseImageName Failed : "<<strImageName); |
| | | ERR("ParseImageName Failed : "<<imgKey); |
| | | return ""; |
| | | } |
| | | //DBG("Path: "<<strPath<<" VecSize: "<<vec.size()); |
| | | std::vector<VideoName_s_t> videoStVec; |
| | | for (const auto &item : vec) { |
| | | auto videoParseResult = VideoName_s_t::fromString(item); |
| | | if (videoParseResult.Valid()) { |
| | | if (videoParseResult.m_startFrameId <= imgSt.m_frameId && |
| | | imgSt.m_frameId < videoParseResult.m_endFrameId) { |
| | | imgSt.m_frameId <= videoParseResult.m_endFrameId) { |
| | | auto imgTm = AppUtil::ParseFromHypenTimeStr(imgSt.m_timeStamp); |
| | | auto videoTm = AppUtil::ParseFromHypenTimeStr(videoParseResult.m_timeStamp); |
| | | if (AppUtil::IsRightAfterLeft(imgTm, videoTm)) { |
| | | videoStVec.emplace_back(videoParseResult); |
| | | INFO("Image " << strImageName << " Video: " << item << " Match"); |
| | | INFO("Image " << imgKey << " Video: " << item << " Match"); |
| | | } else { |
| | | ERR("Image " << strImageName << " Video: " << item << " Not Match"); |
| | | ERR("Image " << imgKey << " Video: " << item << " Not Match"); |
| | | } |
| | | } else{ |
| | | ERR("ImageID: "<<imgSt.m_frameId <<" VideoRange: "<<videoParseResult.m_startFrameId<<" , "<<videoParseResult.m_endFrameId); |
| | |
| | | |
| | | if (videoStVec.size() >= 1) { |
| | | std::string strVideoName = strPath + videoStVec[0].ToVideoName(); |
| | | INFO("ImageName: "<<strImageName<<" SingleMatchVideo: "<<strVideoName); |
| | | INFO("ImageName: "<<imgKey<<" SingleMatchVideo: "<<strVideoName); |
| | | return strVideoName; |
| | | } else { |
| | | ERR("ImageName: "<<strImageName<<" MatchVideoCount: "<<videoStVec.size()); |
| | | ERR("ImageName: "<<imgKey<<" MatchVideoCount: "<<videoStVec.size()); |
| | | for(auto& item:vec) |
| | | { |
| | | ERR("VideoName: "<<item); |
| | |
| | | } |
| | | |
| | | //新的根据图片名称获取路径的方法 |
| | | std::string devHttpServer_c::getVideoPathByImgKey(const std::string &strImageName, const std::string &camId) |
| | | std::string devHttpServer_c::getVideoPathByImgKey(const std::string &imgKey, const std::string &camId) |
| | | { |
| | | INFO("GetVideoFor: "<<strImageName<<" CamID:"<<camId); |
| | | ImageName_s_t imgSt= ImageName_s_t::fromString(strImageName); |
| | | INFO("GetVideoFor: "<<imgKey<<" CamID:"<<camId); |
| | | ImageName_s_t imgSt= ImageName_s_t::fromString(imgKey); |
| | | |
| | | struct tm imgTime = AppUtil::ParseFromHypenTimeStr(imgSt.m_timeStamp); |
| | | char curFolder[128]={0}; |
| | |
| | | imgTime.tm_year+1900,imgTime.tm_mon+1,imgTime.tm_mday,imgTime.tm_hour); |
| | | std::string t_FilePath = appConfig.getStringProperty("cutPath"); |
| | | std::string videoPath = t_FilePath+"/"+camId+"/"+std::string(curFolder); |
| | | return GetVideoByImgKey(strImageName,videoPath); |
| | | return GetVideoNameByImgKey(imgKey,videoPath); |
| | | } |
| | | |
| | | |
| | | /*std::string devHttpServer_c::getVideoPathByTime(const std::string &time, const std::string &camId, qint64 &sub) { |
| | | |
| | | return getVideoPathByTime2(time,camId,sub); |
| | | }*/ |
| | | |
| | | qint64 devHttpServer_c::getVideoTime(/*const std::string &videoPath,*/std::string &str_tmpTime) { |
| | | // std::string cmd_getVideoFileTime( |