From f4be410904ad23c153422961431dfa721ff27839 Mon Sep 17 00:00:00 2001 From: payton Date: Tue, 9 Jan 2024 19:28:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E9=A2=84=E7=BA=A6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cardv/SrcCode/PrjCfg_HUNTING_S550.h | 1 + .../sf_app/code/include/sf_param_struct.h | 1 + .../source/sf_app/code/source/4gMng/sf_ftp.c | 57 ++++++++--------- .../source/sf_app/code/source/4gMng/sf_sms.c | 63 ++++++++++--------- .../sf_app/code/source/app/sf_service.c | 18 +----- .../sifar/code/source/common/sf_common.c | 25 ++++---- 6 files changed, 78 insertions(+), 87 deletions(-) diff --git a/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h b/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h index 00f0261aa..00da1f0ba 100755 --- a/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h +++ b/code/application/source/cardv/SrcCode/PrjCfg_HUNTING_S550.h @@ -944,6 +944,7 @@ #define SF_HD_DIR_LIST SF_SEND_LIST_DIR"HD/send.list" //No use #define SF_HD_DIR SF_SEND_LIST_DIR"HD" #define SF_HD_DIR_CARDV "A:\\THUMB\\HD\\" //No use +#define SF_HD_DIR_EMMC "B:\\THUMB\\HD\\" //No use #define SF_FW_CFG_FILE_NAME "SPHOST_REVEAL.CFG" diff --git a/code/application/source/sf_app/code/include/sf_param_struct.h b/code/application/source/sf_app/code/include/sf_param_struct.h index a5e837d17..0a539ed0e 100755 --- a/code/application/source/sf_app/code/include/sf_param_struct.h +++ b/code/application/source/sf_app/code/include/sf_param_struct.h @@ -301,6 +301,7 @@ typedef struct HDImgList { UINT16 dirKey; UINT16 fileKey; + UINT16 storage;//0:emmc; 1:sd } HDImgList_t; typedef struct sf_HDFILE_ATTR_S { UINT8 filecnt; diff --git a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c index 85010df6d..c613dc635 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c @@ -1799,15 +1799,6 @@ SINT32 sf_hd_ftp_send(void) UINT8 timeoutCnt = 0; double elapsed_time = 0; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return SF_FAILURE; - } - - char font = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_HANDLE : SF_SD_DCF_HANDLE; - sf_set_send_hd(0); sf_custom_str_get(CamNameStr); sf_4G_signal_level_get(sf_get_net_generation(),sf_get_cq_signal(),&csqlevel); @@ -1821,9 +1812,9 @@ SINT32 sf_hd_ftp_send(void) { while((sf_app_while_flag()) && (((piccount) < SendFileTotal)) && ((pPara->GprsMode == 1) || ((pSifarPara->subscribeSendCnt < SUBSCRIBE_SEND_MAX_NUM) && (pPara->GprsMode != 1)))) { - snprintf((char *)ftpFileName, sizeof(ftpFileName), "W%c%03d%04d.JPG", font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); - snprintf((char *)filePath, sizeof(filePath), "%s%s/%s", strg_path, SF_HD_DIR, ftpFileName); - free(strg_path); + //snprintf((char *)ftpFileName, sizeof(ftpFileName), "W%c%03d%04d.JPG", font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + //snprintf((char *)filePath, sizeof(filePath), "%s%s/%s", strg_path, SF_HD_DIR, ftpFileName); + //free(strg_path); sf_set_del_flag(FALSE); ret1 = SF_SUCCESS;//sf_quectel_upload_file_to_module(filePath, ftpFileName); @@ -1840,10 +1831,19 @@ SINT32 sf_hd_ftp_send(void) battery = sf_app_get_battery(); memset(cameraID, '\0', sizeof(cameraID)); memset(ftpFileName, '\0', sizeof(ftpFileName)); - //memset(filePath, '\0', sizeof(filePath)); + memset(filePath, '\0', sizeof(filePath)); snprintf(cameraID, sizeof(cameraID), "%s-%d-%d-%s-", pPara->ModuleImei, battery, csqlevel, CamNameStr); - snprintf((char *)ftpFileName, sizeof(ftpFileName), "%sHD-W%c%03d%04d.JPG", cameraID, font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + if(fileCfg->stfileattr[piccount].storage == 1) + { + snprintf((char *)ftpFileName, sizeof(ftpFileName), "%sHD-%c%03d%04d.JPG", cameraID, SF_SD_DCF_HANDLE, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + snprintf((char *)filePath, sizeof(filePath), "%s%s/%c%03d%04d.JPG", SF_SD_ROOT, SF_HD_DIR, SF_SD_DCF_HANDLE, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + } + else{ + snprintf((char *)ftpFileName, sizeof(ftpFileName), "%sHD-%c%03d%04d.JPG", cameraID, SF_EMMC_DCF_HANDLE, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + snprintf((char *)filePath, sizeof(filePath), "%s%s/%c%03d%04d.JPG", SF_EMMC_ROOT, SF_HD_DIR, SF_EMMC_DCF_HANDLE, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + } + //snprintf((char *)filePath, sizeof(filePath), "UFS:/W%03d%04d.JPG", fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); @@ -1959,7 +1959,7 @@ SF_HD_END: Return: file size Others: N/A *************************************************/ -UINT32 sf_video_find_file(UINT16 dirKey, UINT16 fileKey, UINT8 *destFname) +UINT32 sf_video_find_file(UINT16 dirKey, UINT16 fileKey, UINT16 storage, UINT8 *destFname) { UINT32 fileIndex = 0; UINT32 fileSize = 0; @@ -1967,22 +1967,20 @@ UINT32 sf_video_find_file(UINT16 dirKey, UINT16 fileKey, UINT8 *destFname) char fname[50] = {0}; //UINT8 srcFname[50] = {0}; - char *strg_path = sf_get_root_path(); - char *dcf_file = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_FILE_NAME : SF_SD_DCF_FILE_NAME; - if(strg_path == NULL) - { - free(strg_path); - return SF_FAILURE; - } - fileIndex = dirKey * 10000 + fileKey + 1; for(i = 0; i < 3; i++) { dirKey = fileIndex / 10000; fileKey = fileIndex % 10000; - SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", strg_path, SF_DCIM_DIR, dirKey, dcf_file, fileKey); - + if(storage == 1) + { + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", SF_SD_ROOT, SF_DCIM_DIR, dirKey, SF_SD_DCF_FILE_NAME, fileKey); + } + else + { + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", SF_EMMC_ROOT, SF_DCIM_DIR, dirKey, SF_EMMC_DCF_FILE_NAME, fileKey); + } //fileSize = sf_get_file_size(fname); sf_file_size_get(fname,&fileSize); printf("find video:%s size=%d\n", fname, fileSize); @@ -1994,7 +1992,6 @@ UINT32 sf_video_find_file(UINT16 dirKey, UINT16 fileKey, UINT8 *destFname) } fileIndex++; } - free(strg_path); return fileSize; } /************************************************* @@ -2039,8 +2036,6 @@ SINT32 sf_video_ftp_send(void) double elapsed_time = 0; SINT64 sendEndTime = 0; UINT32 size = 0; - - char font = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_HANDLE : SF_SD_DCF_HANDLE; sf_set_send_video(0); sf_custom_str_get(CamNameStr); @@ -2055,11 +2050,11 @@ SINT32 sf_video_ftp_send(void) { while((sf_app_while_flag()) && (((piccount) < SendFileTotal)) && ((pPara->GprsMode == 1) || ((pSifarPara->subscribeVideoSendCnt < SUBSCRIBE_VIDEO_SEND_MAX_NUM) && (pPara->GprsMode != 1)))) { - snprintf((char *)ftpFileName, sizeof(ftpFileName), "W%c%03d%04d.MP4", font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + //snprintf((char *)ftpFileName, sizeof(ftpFileName), "W%c%03d%04d.MP4", font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); //snprintf((char *)filePath, sizeof(filePath), "%s/%s", SF_HD_DIR, ftpFileName); printf("[%s:%d] piccount:%d dirKey:%d fileKey:%d\n", __FUNCTION__, __LINE__, piccount, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); - size = sf_video_find_file(fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey,filePath); + size = sf_video_find_file(fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey, fileCfg->stfileattr[piccount].storage, filePath); if(size == 0) { pSifarPara->videoSendCount--; @@ -2085,7 +2080,7 @@ SINT32 sf_video_ftp_send(void) //memset(filePath, '\0', sizeof(filePath)); snprintf(cameraID, sizeof(cameraID), "%s-%d-%d-%s-", pPara->ModuleImei, battery, csqlevel, CamNameStr); - snprintf((char *)ftpFileName, sizeof(ftpFileName), "%sW%c%03d%04d.MP4", cameraID, font, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); + snprintf((char *)ftpFileName, sizeof(ftpFileName), "%s%c%03d%04d.MP4", cameraID, fileCfg->stfileattr[piccount].storage == 0 ? SF_EMMC_DCF_HANDLE : SF_SD_DCF_HANDLE, fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); //snprintf((char *)filePath, sizeof(filePath), "UFS:/W%03d%04d.MP4", fileCfg->stfileattr[piccount].dirKey, fileCfg->stfileattr[piccount].fileKey); diff --git a/code/application/source/sf_app/code/source/4gMng/sf_sms.c b/code/application/source/sf_app/code/source/4gMng/sf_sms.c index ecdd02550..7099bb5d9 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_sms.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_sms.c @@ -1973,24 +1973,24 @@ void sf_hd_pic_add_to_list(UINT8 *fileName) UINT16 dirKey = 0; UINT16 fileKey = 0; UINT8 tempStr[20] = {0}; - char emmcsdStr[4] = {0}; - + UINT16 storage = 0; SubImgList_t *pList = pSubImgListHead; SubImgList_t *qList = pSubImgListHead; char fname[50] = {0}; printf("[%s:%d] add to list:%s\n", __FUNCTION__, __LINE__, fileName); - SF_STRNCPY(emmcsdStr, fileName, 1); SF_STRNCPY(tempStr, fileName+1, 3); dirKey = atoi((const char *)tempStr); fileKey = atoi((const char *)fileName+4); - if(strstr(emmcsdStr, "E")) + if(strstr((char*)fileName, "E")) { - SF_SPRINTF(fname, "mmt/sd/%s/%03dMEDIA/%s%04d.JPG", SF_DCIM_DIR, dirKey, SF_SD_DCF_FILE_NAME, fileKey); + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.JPG", SF_SD_ROOT,SF_DCIM_DIR, dirKey, SF_SD_DCF_FILE_NAME, fileKey); + storage = 1; } else { - SF_SPRINTF(fname, "mmt/sd2/%s/%03dMEDIA/%s%04d.JPG", SF_DCIM_DIR, dirKey, SF_EMMC_DCF_FILE_NAME, fileKey); + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.JPG", SF_EMMC_ROOT, SF_DCIM_DIR, dirKey, SF_EMMC_DCF_FILE_NAME, fileKey); + storage = 0; } if(sf_file_IsExsit(fname) != SF_TRUE) { @@ -2018,6 +2018,7 @@ void sf_hd_pic_add_to_list(UINT8 *fileName) /* add file key to list*/ pList->dirKey = dirKey; pList->fileKey = fileKey; + pList->storage = storage; pList->pNext = NULL; break; } @@ -2050,16 +2051,17 @@ void sf_hd_pic_list_print(void) printf("[%s:%d] print list:\n", __FUNCTION__, __LINE__); SF_HDFILE_ATTR_S* fileCfg = sf_file_hd_cfg_get(); - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return; - } - - snprintf(hd_dir, sizeof(hd_dir), "%s%s", strg_path, SF_HD_DIR); - free(strg_path); - + snprintf(hd_dir, sizeof(hd_dir), "%s%s", SF_SD_ROOT, SF_HD_DIR); + if (stat(hd_dir, &st_buffer) == 0 && S_ISDIR(st_buffer.st_mode)) { + printf("%s exists\n", hd_dir); + } + else{ + if (mkdir(hd_dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { + printf("Failed to create directory"); + } + } + + snprintf(hd_dir, sizeof(hd_dir), "%s%s", SF_EMMC_ROOT, SF_HD_DIR); if (stat(hd_dir, &st_buffer) == 0 && S_ISDIR(st_buffer.st_mode)) { printf("%s exists\n", hd_dir); } @@ -2077,9 +2079,10 @@ void sf_hd_pic_list_print(void) { //snprintf(buff, sizeof(buff), "%d%d\r\n", pList->dirKey, pList->fileKey); //write(fd, buff, strlen(buff)); - printf("ID:%d f:%d,%d\n", i++, pList->dirKey, pList->fileKey); + printf("ID:%d f:%d,%d,%d\n", i++, pList->dirKey, pList->fileKey, pList->storage); fileCfg->stfileattr[fileCfg->filecnt].dirKey = pList->dirKey; fileCfg->stfileattr[fileCfg->filecnt].fileKey = pList->fileKey; + fileCfg->stfileattr[fileCfg->filecnt].storage = pList->storage; fileCfg->filecnt += 1; pList = pList->pNext; } @@ -2121,15 +2124,9 @@ void sf_video_add_to_list(UINT8 *fileName) UINT8 i = 0; UINT16 dirKeytmp = 0; UINT16 fileKeytmp = 0; - char *dcf_file = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_FILE_NAME : SF_SD_DCF_FILE_NAME; - printf("add to list:%s\n", fileName); + UINT16 storage = 0; - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return; - } + printf("add to list:%s\n", fileName); SF_STRNCPY(tempStr, fileName+1, 3); dirKey = atoi((const char *)tempStr); @@ -2141,8 +2138,16 @@ void sf_video_add_to_list(UINT8 *fileName) { dirKeytmp = fileIndex / 10000; fileKeytmp = fileIndex % 10000; - SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", strg_path, SF_DCIM_DIR, dirKeytmp, dcf_file, fileKeytmp); - free(strg_path); + if(strstr((char*)fileName, "E")) + { + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", SF_SD_ROOT, SF_DCIM_DIR, dirKeytmp, SF_SD_DCF_FILE_NAME, fileKeytmp); + storage = 1; + } + else + { + SF_SPRINTF(fname, "%s%s/%03dMEDIA/%s%04d.MP4", SF_EMMC_ROOT, SF_DCIM_DIR, dirKeytmp, SF_EMMC_DCF_FILE_NAME, fileKeytmp); + storage = 0; + } sf_file_size_get(fname,&fileSize); printf("find video:%s size=%d\n", fname, fileSize); @@ -2179,6 +2184,7 @@ void sf_video_add_to_list(UINT8 *fileName) /* add file key to list*/ pList->dirKey = dirKey; pList->fileKey = fileKey; + pList->storage = storage; pList->pNext = NULL; break; } @@ -2209,8 +2215,9 @@ void sf_video_list_print(void) { fileCfg->stfileattr[fileCfg->filecnt].dirKey = pList->dirKey; fileCfg->stfileattr[fileCfg->filecnt].fileKey = pList->fileKey; + fileCfg->stfileattr[fileCfg->filecnt].storage = pList->storage; fileCfg->filecnt += 1; - printf("filecnt:%d f:%d,%d\n", fileCfg->filecnt, pList->dirKey, pList->fileKey); + printf("filecnt:%d f:%d,%d,%d\n", fileCfg->filecnt, pList->dirKey, pList->fileKey, pList->storage); pList = pList->pNext; } } diff --git a/code/application/source/sf_app/code/source/app/sf_service.c b/code/application/source/sf_app/code/source/app/sf_service.c index 474361c07..473385bd5 100755 --- a/code/application/source/sf_app/code/source/app/sf_service.c +++ b/code/application/source/sf_app/code/source/app/sf_service.c @@ -2080,29 +2080,13 @@ SINT32 sf_app_to_cardv_hd_ture(void) { SINT32 s32ret = SF_FAILURE; MLOGI(" falg:%d\n",falg); - char *strg_path = sf_get_root_path(); - if(strg_path == NULL) - { - free(strg_path); - return SF_FAILURE; - } - - char sendHDName[64] = {0}; if(falg) { return falg; } falg = 1; - snprintf(sendHDName, sizeof(sendHDName), "%s%s", strg_path, SF_HD_DIR); - - if(sf_file_IsExsit((CHAR *)sendHDName) != SF_TRUE) - { - MLOGI(" not HD Dir [%s]\n",sendHDName); - - } - MLOGI(" [%s]\n",sendHDName); - s32ret = sf_share_mem_hd_down(1); + MLOGI(" e ret:0x%08X\n",s32ret); return s32ret; } diff --git a/code/lib/source/sifar/code/source/common/sf_common.c b/code/lib/source/sifar/code/source/common/sf_common.c index e472b679f..bdb3784ad 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -1640,11 +1640,11 @@ UINT32 sf_cardv_adc_value_get(UINT32 mux, UINT32 *pval) void sf_transcode_bs_ready_cb(void* bitstream_va, UINT32 size) { //SF_HD_DIR - char tmp[64] = {'\0'}; - snprintf(tmp, sizeof(tmp), "%s%s", SF_HD_DIR_CARDV, HdflieName); - SLOGI("bitstream_va = %lx , size = %lx File:%s\n", bitstream_va, size, tmp); + //char tmp[64] = {'\0'}; + //snprintf(tmp, sizeof(tmp), "%s%s", SF_HD_DIR_CARDV, HdflieName); + SLOGI("bitstream_va = %lx , size = %lx File:%s\n", bitstream_va, size, HdflieName); - FST_FILE fp = FileSys_OpenFile(tmp, FST_OPEN_ALWAYS | FST_OPEN_WRITE); + FST_FILE fp = FileSys_OpenFile(HdflieName, FST_OPEN_ALWAYS | FST_OPEN_WRITE); FileSys_WriteFile(fp, (UINT8*)bitstream_va, &size, 0, NULL); FileSys_CloseFile(fp); @@ -2917,8 +2917,6 @@ void* sf_cardv_hd_cap_thread(void *arg) UINT8 PowerOnMode = sf_cardv_convert_power_on_mode(); MLOGD(" HD start PowerOnMode:%d\n", PowerOnMode); - char font = sf_get_strg_dev() == MMC_DEV_EMMC ? SF_EMMC_DCF_HANDLE : SF_SD_DCF_HANDLE; - char *font_str = sf_get_strg_dev() == MMC_DEV_EMMC ? "BX" : "EX"; if((PWR_ON_SMS == PowerOnMode) || (PWR_ON_TIME_SYNC == PowerOnMode)) { //if(TRUE != sf_is_preview()) @@ -2926,8 +2924,6 @@ void* sf_cardv_hd_cap_thread(void *arg) if(!hdFlagInit) { hdFlagInit = 1; - FileSys_MakeDir(PHOTO_THUMB_PATH); - FileSys_MakeDir(SF_HD_DIR_CARDV); sf_hd_flag_init(); } char *arg[2] = { 0 }; @@ -2945,9 +2941,16 @@ void* sf_cardv_hd_cap_thread(void *arg) //HdflieName memset(HdflieName, '\0', sizeof(HdflieName)); sf_hd_flag_clear_done(0); - snprintf(HdflieName, sizeof(HdflieName), "W%c%03d%04d.JPG", font, fileCfg->stfileattr[fileIndex].dirKey, fileCfg->stfileattr[fileIndex].fileKey); - snprintf(str, 64, "A:\\DCIM\\%03d%s\\%s%s%04d.JPG", fileCfg->stfileattr[fileIndex].dirKey, DCF_DIR_NAME, DCF_FILE_NAME, font_str, fileCfg->stfileattr[fileIndex].fileKey); - printf("%s\n", str); + if(fileCfg->stfileattr[fileIndex].storage == 1) + { + snprintf(HdflieName, sizeof(HdflieName), "%s%c%03d%04d.JPG", SF_HD_DIR_CARDV, (SF_SD_DCF_HANDLE), fileCfg->stfileattr[fileIndex].dirKey, fileCfg->stfileattr[fileIndex].fileKey); + snprintf(str, 64, "A:\\DCIM\\%03d%s\\%s%04d.JPG", fileCfg->stfileattr[fileIndex].dirKey, DCF_DIR_NAME, SF_SD_DCF_FILE_NAME, fileCfg->stfileattr[fileIndex].fileKey); + } + else { + snprintf(HdflieName, sizeof(HdflieName), "%s%c%03d%04d.JPG", SF_HD_DIR_EMMC , (SF_EMMC_DCF_HANDLE), fileCfg->stfileattr[fileIndex].dirKey, fileCfg->stfileattr[fileIndex].fileKey); + snprintf(str, 64, "B:\\DCIM\\%03d%s\\%s%04d.JPG", fileCfg->stfileattr[fileIndex].dirKey, DCF_DIR_NAME, SF_EMMC_DCF_FILE_NAME, fileCfg->stfileattr[fileIndex].fileKey); + } + printf("flie:%s HdflieName:%s\n", str, HdflieName); arg[0] = str; sf_cmd_transcode_start(arg); if(sf_hd_flag_wait_done_timeout(HD_FLAG_INITT_OK, 5000))