From 591aacee97f4a6486631c38a6b418e20b2c4109c Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 10 九月 2020 14:56:47 +0800 Subject: [PATCH] update --- device/hcnetdisk.c | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff --git a/device/hcnetdisk.c b/device/hcnetdisk.c index a4fc6e0..b6061a1 100644 --- a/device/hcnetdisk.c +++ b/device/hcnetdisk.c @@ -71,8 +71,8 @@ port = loginInfo.port; - startChannel = struDeviceInfo.struDeviceV30.byStartDChan; - maxChannels = struDeviceInfo.struDeviceV30.byIPChanNum + struDeviceInfo.struDeviceV30.byHighDChanNum * 256; + deviceInfo.startChannel = struDeviceInfo.struDeviceV30.byStartDChan; + deviceInfo.maxChannels = struDeviceInfo.struDeviceV30.byIPChanNum + struDeviceInfo.struDeviceV30.byHighDChanNum * 256; return 0; } @@ -118,11 +118,16 @@ request.channel, mktime(&start), i); - // printf("%s\n", destfile); - // downloadByTime_wrapper(userid, request.channel, &start, &end, destfile); - if(files != NULL) { - files->push_back(destfile); - } + std::cout << "destfile:" << destfile << std::endl; + char *destfiledup = strdup(destfile); + if(downloadByTime_wrapper(userid, request.channel, &start, &end, destfiledup) != -1) { + if(files != NULL) { + // std::cout << "push destfile:" << destfile << std::endl; + files->push_back(destfile); + } + } + free(destfiledup); + start = end; i++; } @@ -135,7 +140,7 @@ /** * @return success: 0, failture : -1 */ -int HCNetdisk::downloadByTime_wrapper(long userid, int channel, struct tm *start, struct tm *end, char *destfile) { +int HCNetdisk::downloadByTime_wrapper(const long userid, const int channel, const struct tm *start, const struct tm *end, const char *destfile) { NET_DVR_FILECOND_V40 struFileCond = {0}; struFileCond.dwFileType = 0xFF; @@ -181,7 +186,8 @@ char strFileName[256] = {0}; if (destfile != NULL) { sprintf(strFileName, "%s", destfile); - char *dir = dirname(strdup(destfile)); + //char *dir = dirname(strdup(destfile)); + char *dir = dirname(const_cast<char *>(destfile)); printf("dir === %s\n", dir); if ((mkdir(dir, DIR_MODE) == -1) && (errno != EEXIST)) { err_msg(errno, "hc_downloadByTime mkdir error "); @@ -216,9 +222,8 @@ -int HCNetdisk::saveRecordFile(int userId, char * srcfile, char * destfile) +int HCNetdisk::saveRecordFile( int userId, char * srcfile, char * destfile) { - printf("destfile=%s\n", destfile); int bRes = 1; int hPlayback = 0; //鎸夋枃浠跺悕涓嬭浇褰曞儚 @@ -236,14 +241,13 @@ return bRes; } int nPos = 0; + //涓嬭浇杩涘害 for (nPos = 0; nPos < 100 && nPos >= 0; nPos = NET_DVR_GetDownloadPos(hPlayback)) { printf("Be downloading...%d %%\n", nPos); sleep(1); -//涓嬭浇杩涘害 -//millisecond } - printf("have got %d\n", nPos); + // printf("have got %d\n", nPos); //鍋滄涓嬭浇 if (!NET_DVR_StopGetFile(hPlayback)) { @@ -251,7 +255,7 @@ bRes = -1; return bRes; } - printf("%s\n", srcfile); + // printf("%s\n", srcfile); if (nPos < 0 || nPos > 100) { printf("download err [%d]\n", NET_DVR_GetLastError()); -- Gitblit v1.8.0