PSDK相机管理,下载媒体文件,下载完之后是否需要释放结构体参数,示例中没有释放?
Completed1、DjiCameraManager_DownloadFileList(position, &s_meidaFileList) 下载完之后是否需要释放s_meidaFileList结构体参数,源码中没看到释放?
2、DjiCameraManager_DownloadFileList() 和DjiCameraManager_DownloadFileByIndex()的区别
DjiCameraManager_DownloadFileList:是下载选定的相机媒体文件列表,那么是下载文件还是仅获取文件列表信息?
DjiCameraManager_DownloadFileByIndex:是通过文件索引下载选定的相机媒体文件;
那么DjiCameraManager_RegDownloadFileDataCallback注册的回调函数是在DjiCameraManager_DownloadFileList和DjiCameraManager_DownloadFileByIndex哪个函数之后执行?
3、下载完之后,如果不删除图片,再次下载文件,是否会导致重复下载?
源码示例粘贴如下:
static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_DjiMountPosition position)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
uint16_t downloadCount = 0;
uint16_t subFileDownloadCount = 0;
int i = 0, j= 0;
s_nextDownloadFileIndex = 0;
returnCode = DjiCameraManager_RegDownloadFileDataCallback(position, DjiTest_CameraManagerDownloadFileDataCallback);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Register download file data callback failed, error code: 0x%08X.", returnCode);
return returnCode;
}
returnCode = DjiCameraManager_ObtainDownloaderRights(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Obtain downloader rights failed, error code: 0x%08X.", returnCode);
}
returnCode = DjiCameraManager_DownloadFileList(position, &s_meidaFileList);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download file list failed, error code: 0x%08X.", returnCode);
return returnCode;
}
if (s_meidaFileList.totalCount > 0) {
downloadCount = s_meidaFileList.totalCount;
subFileDownloadCount = s_meidaFileList.fileListInfo->subFileListTotalNum;
printf(
"\033[1;33;40m -> Download file list finished, total media file count is %d "
"the following %d is list details: \033[0m\r\n",
s_meidaFileList.totalCount, downloadCount);
...
osalHandler->TaskSleepMs(1000);
downloadCount = s_meidaFileList.totalCount;
for (i = 0; i < downloadCount; ++i) {
redownload:
if (i != s_nextDownloadFileIndex) {
i = s_nextDownloadFileIndex;
}
returnCode = DjiCameraManager_DownloadFileByIndex(position, s_meidaFileList.fileListInfo[i].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download media file by index failed, error code: 0x%08X.", returnCode);
s_nextDownloadFileIndex--;
goto redownload;
}
if (s_meidaFileList.fileListInfo[i].type == DJI_CAMERA_FILE_TYPE_LDRT) {
for (j = 0; j < s_meidaFileList.fileListInfo[i].subFileListTotalNum; j++) {
subFileRedownload:
returnCode = DjiCameraManager_DownloadSubFileByIndexAndSubType(position,
s_meidaFileList.fileListInfo[i].fileIndex,
s_meidaFileList.fileListInfo[i].subFileListInfo[j].type);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download sub media file by index and type failed, error code: 0x%08X.", returnCode);
goto subFileRedownload;
}
}
}
}
if (s_meidaFileList.fileListInfo[0].type == DJI_CAMERA_FILE_TYPE_JPEG) {
returnCode = DjiCameraManager_DeleteFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Delete media file by index failed, error code: 0x%08X.", returnCode);
return returnCode;
}
}
osalHandler->TaskSleepMs(1000);
} else {
USER_LOG_WARN("Media file is not existed in sdcard.\r\n");
}
returnCode = DjiCameraManager_ReleaseDownloaderRights(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Release downloader rights failed, error code: 0x%08X.", returnCode);
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
Please sign in to leave a comment.
Comments
3 comments