NEW: add the download media file by slices support
Esse commit está contido em:
@@ -1738,6 +1738,22 @@ class CameraManager {
|
|||||||
*/
|
*/
|
||||||
ErrorCode::ErrorCodeType startReqFileList(PayloadIndexType index, FileMgr::FileListReqCBType cb, void *userData);
|
ErrorCode::ErrorCodeType startReqFileList(PayloadIndexType index, FileMgr::FileListReqCBType cb, void *userData);
|
||||||
|
|
||||||
|
/*! @brief start to requeset the filelist data of camera by slices, non-blocking calls
|
||||||
|
*
|
||||||
|
* @platforms M300
|
||||||
|
* @param index Camera module index, input limit see enum
|
||||||
|
* DJI::OSDK::PayloadIndexType
|
||||||
|
* @param startFileIndex: the index of the file list to start downloading, from 0-N
|
||||||
|
* @param count: the number of file lists downloaded at a time
|
||||||
|
* @param cb The download result will be called by this cb. The detail
|
||||||
|
* of the callback ref to the DJI::OSDK::FileMgr::FileListReqCBType
|
||||||
|
* @param userData The parameter to pass user data into the cb
|
||||||
|
* @return ErrorCode::ErrorCodeType error code
|
||||||
|
*/
|
||||||
|
ErrorCode::ErrorCodeType startReqFileListbySlices(PayloadIndexType index,
|
||||||
|
uint32_t startFileIndex, uint16_t count,
|
||||||
|
FileMgr::FileListReqCBType cb, void *userData);
|
||||||
|
|
||||||
/*! @brief start to requeset the files of camera, non-blocking calls
|
/*! @brief start to requeset the files of camera, non-blocking calls
|
||||||
*
|
*
|
||||||
* @platforms M300
|
* @platforms M300
|
||||||
|
|||||||
@@ -1190,6 +1190,15 @@ ErrorCode::ErrorCodeType CameraManager::startReqFileList(PayloadIndexType index,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorCode::ErrorCodeType CameraManager::startReqFileListbySlices(PayloadIndexType index,
|
||||||
|
uint32_t startFileIndex, uint16_t count,
|
||||||
|
FileMgr::FileListReqCBType cb, void *userData) {
|
||||||
|
ErrorCode::ErrorCodeType ret;
|
||||||
|
ret = fileMgr->startReqFileListBySlices(OSDK_COMMAND_DEVICE_TYPE_CAMERA,
|
||||||
|
PAYLOAD_INDEX_TO_DEVICE_ID(index), startFileIndex, count, cb, userData);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType CameraManager::startReqFileData(PayloadIndexType index, int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb, void *userData) {
|
ErrorCode::ErrorCodeType CameraManager::startReqFileData(PayloadIndexType index, int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb, void *userData) {
|
||||||
ErrorCode::ErrorCodeType ret;
|
ErrorCode::ErrorCodeType ret;
|
||||||
ret = fileMgr->startReqFileData(OSDK_COMMAND_DEVICE_TYPE_CAMERA,
|
ret = fileMgr->startReqFileData(OSDK_COMMAND_DEVICE_TYPE_CAMERA,
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class FileMgr {
|
|||||||
typedef void (*FileDataReqCBType)(E_OsdkStat ret_code, void* userData);
|
typedef void (*FileDataReqCBType)(E_OsdkStat ret_code, void* userData);
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType startReqFileList(E_OSDKCommandDeiveType type, uint8_t index, FileListReqCBType cb, void* userData);
|
ErrorCode::ErrorCodeType startReqFileList(E_OSDKCommandDeiveType type, uint8_t index, FileListReqCBType cb, void* userData);
|
||||||
|
ErrorCode::ErrorCodeType startReqFileListBySlices(E_OSDKCommandDeiveType type, uint8_t index, uint32_t startFileIndex,
|
||||||
|
uint16_t count, FileListReqCBType cb, void* userData);
|
||||||
ErrorCode::ErrorCodeType startReqFileData(E_OSDKCommandDeiveType type, uint8_t index, int fileIndex, std::string localPath, FileDataReqCBType cb, void* userData);
|
ErrorCode::ErrorCodeType startReqFileData(E_OSDKCommandDeiveType type, uint8_t index, int fileIndex, std::string localPath, FileDataReqCBType cb, void* userData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -98,11 +98,14 @@ class FileMgrImpl {
|
|||||||
|
|
||||||
void setTargetDevice(E_OSDKCommandDeiveType type, uint8_t index);
|
void setTargetDevice(E_OSDKCommandDeiveType type, uint8_t index);
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType startReqFileList(FileMgr::FileListReqCBType cb, void* userData);
|
ErrorCode::ErrorCodeType startReqFileList(FileMgr::FileListReqCBType cb,
|
||||||
|
uint32_t startFileIndex,
|
||||||
|
uint16_t count,
|
||||||
|
void* userData);
|
||||||
ErrorCode::ErrorCodeType startReqFileData(int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb, void* userData);
|
ErrorCode::ErrorCodeType startReqFileData(int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb, void* userData);
|
||||||
|
|
||||||
void HandlePushPack(dji_general_transfer_msg_ack *rsp);
|
void HandlePushPack(dji_general_transfer_msg_ack *rsp);
|
||||||
ErrorCode::ErrorCodeType SendReqFileListPack();
|
ErrorCode::ErrorCodeType SendReqFileListPack(uint32_t index, uint32_t count);
|
||||||
ErrorCode::ErrorCodeType SendReqFileDataPack(int fileIndex) ;
|
ErrorCode::ErrorCodeType SendReqFileDataPack(int fileIndex) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -126,6 +129,7 @@ class FileMgrImpl {
|
|||||||
uint8_t index;
|
uint8_t index;
|
||||||
FileNameRule nameRule;
|
FileNameRule nameRule;
|
||||||
FileNameRule getNameRule();
|
FileNameRule getNameRule();
|
||||||
|
uint16_t sessionId;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//typedef void (*FileDataReqCBType)(E_OsdkStat ret_code, dji_general_transfer_msg_ack* ackData);
|
//typedef void (*FileDataReqCBType)(E_OsdkStat ret_code, dji_general_transfer_msg_ack* ackData);
|
||||||
|
|||||||
@@ -50,7 +50,17 @@ FileMgr::~FileMgr(){
|
|||||||
ErrorCode::ErrorCodeType FileMgr::startReqFileList(E_OSDKCommandDeiveType type,
|
ErrorCode::ErrorCodeType FileMgr::startReqFileList(E_OSDKCommandDeiveType type,
|
||||||
uint8_t index, FileListReqCBType cb, void* userData) {
|
uint8_t index, FileListReqCBType cb, void* userData) {
|
||||||
impl->setTargetDevice(type, index);
|
impl->setTargetDevice(type, index);
|
||||||
return impl->startReqFileList(cb, userData);
|
return impl->startReqFileList(cb, 0, 0xFFFF, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode::ErrorCodeType FileMgr::startReqFileListBySlices(E_OSDKCommandDeiveType type,
|
||||||
|
uint8_t index,
|
||||||
|
uint32_t startFileIndex,
|
||||||
|
uint16_t count,
|
||||||
|
FileListReqCBType cb,
|
||||||
|
void* userData) {
|
||||||
|
impl->setTargetDevice(type, index);
|
||||||
|
return impl->startReqFileList(cb, startFileIndex, count, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType FileMgr::startReqFileData(E_OSDKCommandDeiveType type,
|
ErrorCode::ErrorCodeType FileMgr::startReqFileData(E_OSDKCommandDeiveType type,
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ void FileMgrImpl::fileDataMonitorTask(void *arg) {
|
|||||||
FileMgrImpl::FileMgrImpl(Linker *linker) : linker(linker) {
|
FileMgrImpl::FileMgrImpl(Linker *linker) : linker(linker) {
|
||||||
type = OSDK_COMMAND_DEVICE_TYPE_NONE;
|
type = OSDK_COMMAND_DEVICE_TYPE_NONE;
|
||||||
index = 0;
|
index = 0;
|
||||||
|
sessionId = 999;
|
||||||
fileListHandler = new DownloadListHandler();
|
fileListHandler = new DownloadListHandler();
|
||||||
fileDataHandler = new DownloadDataHandler();
|
fileDataHandler = new DownloadDataHandler();
|
||||||
localSenderId = OSDK_COMMAND_DEVICE_ID(OSDK_COMMAND_DEVICE_TYPE_APP, 0);
|
localSenderId = OSDK_COMMAND_DEVICE_ID(OSDK_COMMAND_DEVICE_TYPE_APP, 0);
|
||||||
@@ -256,6 +257,7 @@ FileMgrImpl::FileMgrImpl(Linker *linker) : linker(linker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileMgrImpl::~FileMgrImpl(){
|
FileMgrImpl::~FileMgrImpl(){
|
||||||
|
sessionId = 999;
|
||||||
if (fileListHandler) {
|
if (fileListHandler) {
|
||||||
delete fileListHandler;
|
delete fileListHandler;
|
||||||
}
|
}
|
||||||
@@ -265,7 +267,7 @@ FileMgrImpl::~FileMgrImpl(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType FileMgrImpl::SendReqFileListPack() {
|
ErrorCode::ErrorCodeType FileMgrImpl::SendReqFileListPack(uint32_t index, uint32_t count) {
|
||||||
uint8_t reqBuf[1024] = {0};
|
uint8_t reqBuf[1024] = {0};
|
||||||
dji_general_transfer_msg_req
|
dji_general_transfer_msg_req
|
||||||
*setting = (dji_general_transfer_msg_req *) reqBuf;
|
*setting = (dji_general_transfer_msg_req *) reqBuf;
|
||||||
@@ -274,13 +276,13 @@ ErrorCode::ErrorCodeType FileMgrImpl::SendReqFileListPack() {
|
|||||||
setting->task_id = DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_LIST;
|
setting->task_id = DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_LIST;
|
||||||
setting->func_id = DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_REQ;
|
setting->func_id = DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_REQ;
|
||||||
setting->msg_flag = 0;
|
setting->msg_flag = 0;
|
||||||
setting->session_id = 999;
|
setting->session_id = sessionId++;
|
||||||
setting->seq = 0;
|
setting->seq = 0;
|
||||||
|
|
||||||
dji_file_list_download_req reqData = {0};
|
dji_file_list_download_req reqData = {0};
|
||||||
reqData.index.drive = 0;
|
reqData.index.drive = 0;
|
||||||
reqData.index.index = 1;
|
reqData.index.index = index + 1;
|
||||||
reqData.count = 0xffff;
|
reqData.count = count;
|
||||||
reqData.type = DJI_MEDIA;
|
reqData.type = DJI_MEDIA;
|
||||||
uint32_t reqDataLen =
|
uint32_t reqDataLen =
|
||||||
sizeof(reqData) - sizeof(reqData.filter_enable)
|
sizeof(reqData) - sizeof(reqData.filter_enable)
|
||||||
@@ -329,7 +331,7 @@ ErrorCode::ErrorCodeType FileMgrImpl::SendReqFileDataPack(int fileIndex) {
|
|||||||
setting->task_id = DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_FILE;
|
setting->task_id = DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_FILE;
|
||||||
setting->func_id = DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_REQ;
|
setting->func_id = DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_REQ;
|
||||||
setting->msg_flag = 0;
|
setting->msg_flag = 0;
|
||||||
setting->session_id = 999;
|
setting->session_id = sessionId++;
|
||||||
setting->seq = 0;
|
setting->seq = 0;
|
||||||
|
|
||||||
dji_file_download_req reqData = {0};
|
dji_file_download_req reqData = {0};
|
||||||
@@ -405,7 +407,10 @@ FileMgrImpl::FileNameRule FileMgrImpl::getNameRule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode::ErrorCodeType FileMgrImpl::startReqFileList(FileMgr::FileListReqCBType cb, void* userData) {
|
ErrorCode::ErrorCodeType FileMgrImpl::startReqFileList(FileMgr::FileListReqCBType cb,
|
||||||
|
uint32_t startFileIndex,
|
||||||
|
uint16_t count,
|
||||||
|
void* userData) {
|
||||||
if ((fileListHandler->downloadState == DOWNLOAD_IDLE) &&
|
if ((fileListHandler->downloadState == DOWNLOAD_IDLE) &&
|
||||||
(fileDataHandler->downloadState == DOWNLOAD_IDLE)) {
|
(fileDataHandler->downloadState == DOWNLOAD_IDLE)) {
|
||||||
nameRule = getNameRule();
|
nameRule = getNameRule();
|
||||||
@@ -426,7 +431,7 @@ ErrorCode::ErrorCodeType FileMgrImpl::startReqFileList(FileMgr::FileListReqCBTyp
|
|||||||
fileListHandler->reqCB = cb;
|
fileListHandler->reqCB = cb;
|
||||||
fileListHandler->reqCBUserData = userData;
|
fileListHandler->reqCBUserData = userData;
|
||||||
|
|
||||||
return SendReqFileListPack();
|
return SendReqFileListPack(startFileIndex, count);
|
||||||
} else {
|
} else {
|
||||||
DERROR("Current state cannot support to do downloading ...");
|
DERROR("Current state cannot support to do downloading ...");
|
||||||
return ErrorCode::CameraCommonErr::InvalidState;
|
return ErrorCode::CameraCommonErr::InvalidState;
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ int main(int argc, char **argv) {
|
|||||||
<< std::endl
|
<< std::endl
|
||||||
<< "| [b] Download main camera filedata from case a |"
|
<< "| [b] Download main camera filedata from case a |"
|
||||||
<< std::endl
|
<< std::endl
|
||||||
|
<< "| [c] Download main camera filelist by slices |"
|
||||||
|
<< std::endl
|
||||||
|
<< "| [d] Download main camera filedata from case c |"
|
||||||
|
<< std::endl
|
||||||
<< "| [q] Quit |"
|
<< "| [q] Quit |"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
char inputChar = 0;
|
char inputChar = 0;
|
||||||
@@ -98,7 +102,27 @@ int main(int argc, char **argv) {
|
|||||||
ErrorCode::printErrorCodeMsg(ret);
|
ErrorCode::printErrorCodeMsg(ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'b': {
|
case 'c':
|
||||||
|
ErrorCode::ErrorCodeType ret;
|
||||||
|
DSTATUS("Play back mode setting......");
|
||||||
|
vehicle->cameraManager->setModeSync(PAYLOAD_INDEX_0,
|
||||||
|
CameraModule::WorkMode::PLAYBACK,
|
||||||
|
2);
|
||||||
|
DSTATUS("Get liveview right......");
|
||||||
|
ret = vehicle->cameraManager->obtainDownloadRightSync(PAYLOAD_INDEX_0,
|
||||||
|
true, 2);
|
||||||
|
ErrorCode::printErrorCodeMsg(ret);
|
||||||
|
DSTATUS("Try to download file list by slices .......");
|
||||||
|
ret = vehicle->cameraManager->startReqFileListbySlices(
|
||||||
|
PAYLOAD_INDEX_0,
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
fileListReqCB,
|
||||||
|
(void*)("Download main camera file list by slices."));
|
||||||
|
ErrorCode::printErrorCodeMsg(ret);
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
case 'd': {
|
||||||
ErrorCode::ErrorCodeType ret;
|
ErrorCode::ErrorCodeType ret;
|
||||||
DSTATUS("Download file number : %d", cur_file_list.media.size());
|
DSTATUS("Download file number : %d", cur_file_list.media.size());
|
||||||
uint32_t downloadCnt = cur_file_list.media.size();
|
uint32_t downloadCnt = cur_file_list.media.size();
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário