feat:update config file and lib

Update config file and lib
Esse commit está contido em:
jinxi.chen
2020-04-13 21:40:12 +08:00
commit 0950fb1931
21 arquivos alterados com 2026 adições e 7 exclusões
+2
Ver Arquivo
@@ -54,3 +54,5 @@ osdk-core/advanced-sensing-*
osdk-core/v1-1.0.0
osdk-core/mo-protocol-*
osdk-core/waypointv2-core*
cmake-build-debug
.vscode/
@@ -58,7 +58,6 @@ class Perception {
OSDK_LIVEVIEW_UNKNOWN = 0xFF,
} PerceptionErrCode;
typedef enum CamPositionType : uint32_t {
RECTIFY_DOWN_LEFT = 1,
RECTIFY_DOWN_RIGHT = 2,
@@ -74,7 +73,7 @@ class Perception {
RECTIFY_RIGHT_RIGHT = 26
} CamPositionType;
typedef enum DirectionType {
typedef enum DirectionType : uint8_t {
RECTIFY_DOWN = 0,
RECTIFY_FRONT = 1,
RECTIFY_REAR = 2,
@@ -86,7 +85,7 @@ class Perception {
#pragma pack(1)
typedef struct RawImageInfoType {
uint32_t index;
uint8_t direction;
DirectionType direction;
uint8_t bpp;
uint32_t width;
uint32_t height;
@@ -101,9 +100,9 @@ class Perception {
} ImageInfoType;
typedef struct CamParamType {
int8_t direction;
DirectionType direction;
float leftIntrinsics[9];
float rightIntrinsic[9];
float rightIntrinsics[9];
float rotaionLeftInRight[9];
float translationLeftInRight[3];
} CamParamType;
@@ -115,18 +114,51 @@ class Perception {
} CamParamPacketType;
#pragma pack()
/*! @bref callback type to receive stereo camera parameters */
typedef void(*PerceptionCamParamCB)
(Perception::CamParamPacketType paramPacket, void *userData);
/*! @bref callback type to receive stereo camera image */
typedef void(*PerceptionImageCB)
(Perception::ImageInfoType, uint8_t *imageRawBuffer, int bufferLen, void *userData);
public:
/*! @brief subscribe the raw images of both stereo cameras in the same
* direction. Default frequency at 20 Hz.
*
* @param direction to specifly the direction of the subscription. Ref to
* DJI::OSDK::Perception::DirectionType
* @param cb callback to observer the stereo camera image and info.
* @param userData when cb is called, used in cb.
* @return error code. Ref to DJI::OSDK::Perception::PerceptionErrCode
*/
PerceptionErrCode subscribePerceptionImage(DirectionType direction, PerceptionImageCB cb, void* userData);
/*! @brief unsubscribe the raw image of both stereo cameras in the same
* direction.
*
* @param direction to specifly the direction of the subscription. Ref to
* DJI::OSDK::Perception::DirectionType
* @return error code. Ref to DJI::OSDK::Perception::PerceptionErrCode
*/
PerceptionErrCode unsubscribePerceptionImage(DirectionType direction);
/*! @brief trigger stereo cameras parameters pushing once.
*
* @param direction to specifly the direction of the subscription. Ref to
* DJI::OSDK::Perception::DirectionType
* @return error code. Ref to DJI::OSDK::Perception::PerceptionErrCode
*/
PerceptionErrCode triggerStereoCamParamsPushing();
/*! @brief set callback to get stereo camera parameters after trigger stereo
* camera parameters pushing.
*
* @param cb callback to observer the parameters of stereo cameras. Ref to
* DJI::OSDK:Perception::PerceptionCamParamCB
* @param userData when cb is called, used in cb.
*/
void setStereoCamParamsObserver(PerceptionCamParamCB cb, void *userData);
private:
Arquivo binário não exibido.
@@ -0,0 +1,44 @@
//
// commondatarangehandler.h
// djisdk
//
// Created by husong on 1/14/18.
//
//
#ifndef commondatarangehandler_h
#define commondatarangehandler_h
#include <vector>
#include <cstdint>
namespace DJI {
namespace OSDK {
struct Range {
uint32_t seq_num;
uint32_t length;
};
class CommonDataRangeHandler final {
public:
void DeInit();
// seqNum: 收到包seq
// confirmSeq: 确认收到最大连续包seq
// bufSize: 缓存buf的大小
void AddSeqIndex(uint32_t seqNum, uint32_t confirmSeq, uint32_t bufSize);
bool IsResentAllNeeded();
std::vector<Range>& GetNoAckRanges();
uint32_t GetLastNotReceiveSeq();
private:
std::vector<Range> m_noAckRanges;
uint32_t m_lastNotReceivedSeq = 0;
bool m_is_resent_all = false;
};
} // namespace OSDK
} // namespace DJI
#endif /* commondatarangehandler_h */
@@ -31,6 +31,7 @@
#include <vector>
#include "dji_camera_module.hpp"
#include "dji_file_mgr.hpp"
namespace DJI {
namespace OSDK {
@@ -1604,7 +1605,8 @@ class CameraManager {
ErrorCode::ErrorCodeType obtainDownloadRightSync(PayloadIndexType index,
bool enable, int timeout);
ErrorCode::ErrorCodeType startReqFileList(int timeout);
ErrorCode::ErrorCodeType startReqFileList(FileMgr::FileListReqCBType cb);
ErrorCode::ErrorCodeType startReqFileData(int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb);
private:
FileMgr *fileMgr;
+62
Ver Arquivo
@@ -0,0 +1,62 @@
/** @file dji_file_mgr.hpp
* @version 4.0
* @date July 2020
*
* @brief Implementation for file manager
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_FILE_MGR_HPP
#define DJI_FILE_MGR_HPP
#include "dji_error.hpp"
#include "dji_file_mgr_define.hpp"
namespace DJI {
namespace OSDK {
// Forward Declaration
class Linker;
class FileMgrImpl;
class FileMgr {
public:
FileMgr(Linker *linker, uint8_t type, uint8_t index);
~FileMgr();
typedef void (*FileListReqCBType)(E_OsdkStat ret_code, const FilePackage file_list);
typedef void (*FileDataReqCBType)(E_OsdkStat ret_code);
ErrorCode::ErrorCodeType startReqFileList(FileListReqCBType cb);
ErrorCode::ErrorCodeType startReqFileData(int fileIndex, std::string localPath, FileDataReqCBType cb);
private:
FileMgrImpl *impl;
uint8_t type;
uint8_t index;
};
}
}
#endif // DJI_FILE_MGR_HPP
@@ -0,0 +1,306 @@
//
// Created by dji on 4/8/20.
//
#ifndef DJI_FILE_MGR_DEFINE_HPP
#define DJI_FILE_MGR_DEFINE_HPP
#include <vector>
namespace DJI {
namespace OSDK {
typedef enum {
DJI_CAMERA_TYPE_FC350 = 0, // Inpire 1
DJI_CAMERA_TYPE_FC550 = 1, // Inpire 1 pro
DJI_CAMERA_TYPE_FC260 = 2, // phantom3C
DJI_CAMERA_TYPE_FC300S = 3, // phantom3S
DJI_CAMERA_TYPE_FC300X = 4, // phantom3X
DJI_CAMERA_TYPE_FC550RAW = 5, // Inpire 1 pro Raw
DJI_CAMERA_TYPE_FC330X = 6, // Phantom 4
DJI_CAMERA_TYPE_TAU640 = 7, // Flir 640
DJI_CAMERA_TYPE_TAU336 = 8, // Flir 336
DJI_CAMERA_TYPE_FC220 = 9, // wm220 camera
DJI_CAMERA_TYPE_FC300XW = 10, // phantom3 4k
DJI_CAMERA_TYPE_CV600 = 11, // cv600 3.5x
DJI_CAMERA_TYPE_FC65XXUNKNOWN = 12, // IN2的 SENSOR未检测到
DJI_CAMERA_TYPE_FC6310 = 13, // P4PRO IMX183 相机
DJI_CAMERA_TYPE_FC6510 = 14, // IN2的 H1 IMX183, X4
DJI_CAMERA_TYPE_FC6520 = 15, // IN2的 H1IMX269 目前确定在用, X5S
DJI_CAMERA_TYPE_FC6532 = 16, // IN2的全画幅(MN34401)
DJI_CAMERA_TYPE_FC6540 = 17, // IN2的S35
DJI_CAMERA_TYPE_FC220LOW = 18, // 小飞机低端版本
DJI_CAMERA_TYPE_FC1102 = 19, // 小小飞机
DJI_CAMERA_TYPE_GD600 = 20, // 30X变焦
DJI_CAMERA_TYPE_FC6310A = 21, // P4A IMX183 相机
DJI_CAMERA_TYPE_P3SE = 22, // P3C魔改版,P3SE
DJI_CAMERA_TYPE_WM230 = 23, // WM230 Mavic Air
DJI_CAMERA_TYPE_HG200 = 24, // OSMO MINI 小相机
DJI_CAMERA_TYPE_FC2204 = 25, // WM240 IMX477 相机
DJI_CAMERA_TYPE_FC1705 = 26, // XT2
DJI_CAMERA_TYPE_HG330 = 27, // HG330 相机
DJI_CAMERA_TYPE_FC6310S = 28, // P4PRO V2.0P4P SDR版本)IMX183 相机
DJI_CAMERA_TYPE_FC2211 = 29, // WM240 IMX283 相机
DJI_CAMERA_TYPE_OCUSYNC = 30, // ZV811
DJI_CAMERA_TYPE_P_SDK = 31, // 第三方相机通用相机类型
DJI_CAMERA_TYPE_OCUSYNC2 = 32, // OcuSync2型
DJI_CAMERA_TYPE_AC101 = 33, // AC101运动相机
DJI_CAMERA_TYPE_EC1704 = 34, // EC1704
DJI_CAMERA_TYPE_EC1709 = 35, // EC1709
DJI_CAMERA_TYPE_BR1609 = 36, // BR1609
DJI_CAMERA_TYPE_XW0607_OV5695 = 37, // XW0607(教育机器人) OV5695 相机
DJI_CAMERA_TYPE_FC2220 = 38, // WM245 IMX477 相机
DJI_CAMERA_TYPE_MATRICE_FPV = 39, // M200系列、VITOL系列FPV相机
DJI_CAMERA_TYPE_FC2403 = 40, // WM245 IMX378 相机
DJI_CAMERA_TYPE_TP1810 = 41, // 国产红外相机,基于Iray LT模组
DJI_CAMERA_TYPE_GD610_DOUBLE_CAM =
42, // GD610 双光相机(一路imx378 Wide,一路imx204 Zoom)
DJI_CAMERA_TYPE_GD610_TRIPLE_CAM =
43, // GD610 三光相机(一路imx378 Wide,一路imx204 Zoom,一路自研红外)
DJI_CAMERA_TYPE_FC7103 = 44, // WM160 IMX378 相机
DJI_CAMERA_TYPE_WM231 = 45, // WM231 IMX586 相机
DJI_CAMERA_TYPE_WM170 = 46, // WM170 IMX577 相机
DJI_CAMERA_TYPE_THIRDPARTYSTART = 160, // 比这个大的都认为是第三方相机
DJI_CAMERA_TYPE_HASSELH6D_50C = 166, // 哈苏
DJI_CAMERA_TYPE_HASSELH6D_100C = 167,
DJI_CAMERA_TYPE_UNK = 255, // Inpire 1
} DJI_CAMERA_TYPE;
enum class FileType {
MEDIA = 0, //媒体文件
COMMON = 1, //普通文件例如日志
SPEAKER_AUDIO = 2, //扬声器音频文件
UNKNOWN = 0xFFFF, //Unknown
};
enum class FileLocation {
SD_CARD = 0,
INTERNAL_STORAGE = 1,
EXTENDED_SD_CARD = 2,
UNKNOWN = 0xFFFF, //Unknown
};
enum class MediaFileType {
JPEG = 0,
DNG = 1,
MOV = 2,
MP4 = 3,
PANORAMA = 4,
TIFF = 5,
UL_CTRL_INFO = 6,
UL_CTRL_INFO_LZ4 = 7,
AUDIO = 10,
UNKNOWN = 0xFFFF, //Unknown
};
struct DateTime {
int year; // 年
int month; // 月
int day; // 日
int hour; // 小时
int minute; // 分钟
int second; // 秒钟
};
struct CommonFile {
int fileIndex; //文件编号
MediaFileType fileType; //文件类型
std::string fileName; //文件名
int64_t fileSize; //文件大小
DateTime date; //创建日期
};
struct FileExifInfo {
bool focalLength35mmFormatEnabled;
bool lightSourceEnabled;
bool meteringModeEnabled;
bool exposureCompensationEnabled;
bool isoEnabled;
bool exposureProgramEnabled;
bool fNumberEnabled;
bool exposureTimeEnabled;
int exposureProgram;
int iso;
int meteringMode;
int lightSource;
int focalLength35mmFormat;
std::string shutterSpeedText; //exposureTime格式化后的Shutter 1/12.5
std::string apertureText; //fnumber格式化后的光圈 1.3
std::string exposureCompensationText; //exposureCompensation格式化后的EV +3.5
};
enum class MediaFileStarTag {
NONE = 0,
TAGGED = 1,
UNKNOWN = 0xFF,
};
enum class CameraOrientation {
DEFAULT = 0,
CW90 = 1,
CW180 = 2,
CW270 = 3,
UNKNOWN = 0xFFFF, //Unknown
};
enum class VideoFrameRate {
RATE_15FPS = 0,
RATE_24FPS = 1,
RATE_25FPS = 2,
RATE_30FPS = 3,
RATE_48FPS = 4,
RATE_50FPS = 5,
RATE_60FPS = 6,
RATE_120FPS = 7,
RATE_240FPS = 8,
RATE_480FPS = 9,
RATE_100PS = 10,
RATE_96FPS = 11,
RATE_180FPS = 12,
RATE_TRUE24FPS = 13,
RATE_TRUE30FPS = 14,
RATE_TRUE48FPS = 15,
RATE_TRUE60FPS = 16,
RATE_90FPS = 17,
RATE_192FPS = 18,
RATE_200FPS = 19,
RATE_400FPS = 20,
RATE_8FPS = 21,
RATE_20FPS = 22,
RATE_8_DOT_8FPS = 23,
};
enum class VideoResolution {
RESOLUTION_640X480P = 0, // 640X480P
RESOLUTION_640X480I = 1, // 640X480I
RESOLUTION_1280X640P = 2, // 1280X640P
RESOLUTION_1280X640I = 3, // 1280X640I
RESOLUTION_1280X720P = 4, // 1280X720P
RESOLUTION_1280X720I = 5, // 1280X720I
RESOLUTION_1280X960P = 6, // 1280X960P
RESOLUTION_1280X960I = 7, // 1280X960I
RESOLUTION_1920X960P = 8, // 1920X960P
RESOLUTION_1920X960I = 9, // 1920X960I
RESOLUTION_1920X1080P = 10, // 1920X1080P
RESOLUTION_1920X1080I = 11, // 1920X1080I
RESOLUTION_1920X1440P = 12, // 1920X1440P
RESOLUTION_1920X1440I = 13, // 1920X1440I
RESOLUTION_3840X1920P = 14, // 3840X1920P
RESOLUTION_3840X1920I = 15, // 3840X1920I
RESOLUTION_3840X2160P = 16, // 3840X2160P
RESOLUTION_3840X2160I = 17, // 3840X2160I
RESOLUTION_3840X2880P = 18, // 3840X2880P
RESOLUTION_3840X2280I = 19, // 3840X2280I
RESOLUTION_4096X2048P = 20, // 4096X2048P
RESOLUTION_4960X2048I = 21, // 4960X2048I
RESOLUTION_4096X2160P = 22, // 4096X2160P
RESOLUTION_4096X2160I = 23, // 4096X2160I
RESOLUTION_2704X1520P_16COLON9 = 24, // 2704X1520P,16:9
RESOLUTION_640X512P_FLIR = 26, // 640X512P_FLIR
RESOLUTION_4608X2160 = 27, // 4608X2160
RESOLUTION_4608X2592 = 28, // 4608X2592
RESOLUTION_2720X1530P = 31, // 2720X1530P
RESOLUTION_5280X2160P = 32, // 5280X2160P
RESOLUTION_5280X2970P = 33, // 5280X2970P
RESOLUTION_3840X1572P = 34, // 3840X1572P
RESOLUTION_5760X3240P = 35, // 5760X3240P
RESOLUTION_6016X3200P = 36, // 6016X3200P
RESOLUTION_2048X1080P = 37, // 2048X1080P
RESOLUTION_336X256P_FLIR = 38, // 336X256P_FLIR
RESOLUTION_5120X2880P = 39, // 5120x2880P
RESOLUTION_4096X2160P_RAW14 = 40, // 4096X2160P_RAW14
RESOLUTION_3840X2160P_RAW14 = 41, // 3840X2160P_RAW14
RESOLUTION_2720X1530P_RAW14 = 42, // 2720X1530P_RAW14
RESOLUTION_1920X1080P_RAW14 = 43, // 1920X1080P_RAW14
RESOLUTION_5440X2880P = 44, // 5440X2880P
RESOLUTION_2688X1512P = 45, // 2688X1512P
RESOLUTION_640X360P = 46, // 640X360P
RESOLUTION_4000X3000P = 48, // 4000X3000P
RESOLUTION_4000X3000I = 49, // 4000X3000I
RESOLUTION_2880X1620P = 50, // 2880X1620P
RESOLUTION_2880X1620I = 51, // 2880X1620I
RESOLUTION_2720X2040P = 52, // 2720X2040P
RESOLUTION_2720X2040I = 53, // 2720X2040I
RESOLUTION_720X576 = 54, // 720X576
RESOLUTION_MAX = 253, // MAX
RESOLUTION_UNSET = 254, // UNSET
RESOLUTION_KNOWN = 255, // KNOWN
};
enum class MediaVideoType {
NORMAL = 0, // 普通录像
SLOW_MOTION = 1, // 慢动作录像
HYPER_LAPSE = 2, // Hyperlapse
TIME_LAPSE = 3, // 延时视频(拍照合成方式)
HDR = 4, // HDR录像
LOOP = 5, // 循环录像
UNKNOWN = 0xFFFF, //Unknown
};
enum class MediaPhotoType {
NORMAL = 0, //普通
HDR = 1, //HDR单拍
AEB = 2, //AEB连拍
INTERVAL = 3, //定时拍
BURST = 4, //定时拍
UNKNOWN = 0xFFFF, //Unknown
};
enum class CameraPanoType {
TYPE_360AUTO = 1, // 360 pano
TYPE_BALL = 2, // ball pano
TYPE_SELF = 3, // self pano
TYPE_MANUAL = 4, // manul pano
TYPE_CYLINDRICAL = 5, // Cylindrical_180
TYPE_VERTICAL = 6, // 竖直拼接
TYPE_SECTORIAL = 7, // 3x3广角
UNKNOWN = 0xFFFF,
};
enum class PhotoRatio {
RATIO_4COLON3 = 0, // 4:3
RATIO_16COLON9 = 1, // 16:9
RATIO_3COLON2 = 2, // 3:2
RATIO_SQUARE = 3, // 1:1
RATIO_18COLON9 = 4, // 18:9
UNKNOWN = 0xFFFF, //Unknown
};
struct MediaFile {
bool valid; //文件是否有效
//bool isManualGroupFile; // 是否上层(SDK)手动成组文件, 即拉列表拉到几个index不一样但fileGroupIndex一致文件时,上层手动成组最终返回一个isManualGroupFile为true对象
int fileIndex; //文件编号
MediaFileType fileType; //文件类型
std::string fileName; //文件名
int64_t fileSize; //文件大小
DateTime date; //创建日期
//MediaFileStarTag starTag; //星标
int64_t duration; //时长
CameraOrientation orientation; //朝向
VideoFrameRate frameRate; //帧率
VideoResolution resolution; //分辨率信息
MediaVideoType videoType; //视频类型
MediaPhotoType photoType; //拍照类型
CameraPanoType panoType; // 全景拍照类型
//int videoSpeedRatio; // SlowMotion 及 FastMotion 倍速
//int panoCount; // 全景照片张数
//int guid; //视频guid
//int fileGroupIndex; //文件组
//int subIndex; // html占位组文件子index,正常文件默认为0
//int segSubIndex; // fat32文件系统中 4g以上文件会做切分
//int timeLapseInterval; //TimeLapse视频帧间隔,存储值乘以100ms
//FileExifInfo EXIFInfo;
PhotoRatio photoRatio;
//std::vector<MediaFile> subMediaFile;
};
struct FilePackage {
FileType type;
std::vector<MediaFile> media; //媒体文件
//std::vector<CommonFile> common; //普通文件
};
}
}
#endif //DJI_FILE_MGR_DEFINE_HPP
@@ -0,0 +1,153 @@
/** @file dji_file_mgr_impl.hpp
* @version 4.0
* @date July 2020
*
* @brief Implementation for file manager
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_FILE_MGR_IMPL_HPP
#define DJI_FILE_MGR_IMPL_HPP
#include <memory>
#include <atomic>
#include "dji_error.hpp"
#include "osdk_command.h"
#include "dji_file_mgr_internal_define.hpp"
#include "commondatarangehandler.h"
#include "downloadbufferqueue.h"
#include "dji_file_mgr_define.hpp"
#include "dji_file_mgr.hpp"
#if 0
#include "commondatarangehandler.h"
#include "downloadbufferqueue.h"
#endif
namespace DJI {
namespace OSDK {
// Forward Declaration
class Linker;
class FileMgrImpl {
public:
FileMgrImpl(Linker *linker, E_OSDKCommandDeiveType type, uint8_t index);
~FileMgrImpl();
ErrorCode::ErrorCodeType startReqFileList(FileMgr::FileListReqCBType cb);
ErrorCode::ErrorCodeType startReqFileData(int fileIndex, std::string localPath, FileMgr::FileDataReqCBType cb);
void HandlePushPack(dji_general_transfer_msg_ack *rsp);
ErrorCode::ErrorCodeType SendAbortPack(DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE taskId);
ErrorCode::ErrorCodeType SendACKPack(DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE taskId, dji_download_ack *ack);
ErrorCode::ErrorCodeType SendMissedAckPack(DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE taskId);
typedef enum DownloadStateEnum : int {
DOWNLOAD_IDLE,
RECVING_FILE_LIST,
RECVING_FILE_DATA,
MAX_INDEX_CNT,
} DownloadStateEnum;
std::atomic<int> downloadState;
CommonDataRangeHandler *range_handler_;
DownloadBufferQueue *download_buffer_;
Linker *linker;
E_OSDKCommandDeiveType type;
uint8_t index;
FileMgr::FileListReqCBType currentFileListReqCB;
FileMgr::FileDataReqCBType currentFileDataReqCB;
private:
//typedef void (*FileDataReqCBType)(E_OsdkStat ret_code, dji_general_transfer_msg_ack* ackData);
static void internalFileDataReqCB(E_OsdkStat ret_code, void *userData);
typedef struct ConsumeDataBuffer {
uint8_t data[1024];
uint16_t index;
} ConsumeDataBuffer;
ConsumeDataBuffer ConsumeChunk(DataPointer data_pointer, size_t &chunk_index, size_t consumSize);
FilePackage parseFileList(std::list<DataPointer> fullDataList);
bool parseFileData(std::list<DataPointer> fullDataList);
private:
void OnReceiveAbortPack(dji_general_transfer_msg_ack *rsp);
void OnReceiveUrgePack(dji_general_transfer_msg_ack *rsp);
void OnReceiveDataPack(dji_general_transfer_msg_ack *rsp);
uint16_t getNextReqSessionId() {return reqSessionId++;};
static std::atomic<uint16_t> reqSessionId;
T_OsdkTaskHandle reqFileListHandle;
static void downloadMonitorTask(void *arg);
//只是用于测试
private:
std::string currentLogFilePath;
FILE *fp = NULL;
uint64_t tempSize = 0;
bool confirmFilePath() {
fp = fopen(this->currentLogFilePath.c_str(), "w+");
if (fp) {
fclose(fp);
return true;
} else {
return false;
}
}
void prepareFile() {
printf("Preparing File : %s\n", this->currentLogFilePath.c_str());
fp = fopen(this->currentLogFilePath.c_str(), "a+");
printf("Prepare File ret : %p\n", fp);
}
int writeStreamData(const uint8_t *data, uint32_t len) {
size_t size = 0;
if (fp == NULL) {
printf("fopen failed!\n");
return -1;
}
size = fwrite(data, 1, len, fp);
if (size != len) {
return -1;
}
return 0;
}
void closeFile() {
printf("Close File : %s\n", this->currentLogFilePath.c_str());
fflush(fp);
if (fp) {
fclose(fp);
}
}
};
}
}
#endif // DJI_FILE_MGR_IMPL_HPP
@@ -0,0 +1,831 @@
/** @file dji_file_mgr_internal_define.hpp
* @version 4.0
* @date July 2020
*
* @brief Data struct defination for file manager
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef _DJI_FILE_INTERNAL_DEFINE_HPP_
#define _DJI_FILE_INTERNAL_DEFINE_HPP_
#include <stdint.h>
// 下载文件失败返回值
typedef enum
{
DJI_DOWNLOAD_FILE_ABORT_ERROR = 1, // 下载错误
DJI_DOWNLOAD_FILE_ABORT_FORCE = 2, // 强制退出
DJI_DOWNLOAD_FILE_ABORT_ERROR_FLASH = 3, // FLASH 介质问题导致读取文件错误
DJI_DOWNLOAD_FILE_ABORT_SESSION_REALLOC = 4, // Session 重复
DJI_DOWNLOAD_FILE_ABORT_SESSION_BUSY = 5, // Seesion 资源分配错误
DJI_DOWNLOAD_FILE_ABORT_ERROR_OTHER = 4294967295, // 未知错误
} DJI_DOWNLOAD_FILE_ABORT_ERROR_CODE;
typedef enum : uint32_t {
TransAbortReasonError = 0,
TransAbortReasonForce,
TransAbortReasonSizeError,
TransAbortReasonReadFailed,
} TransAbortReason;
typedef enum : uint8_t {
DJI_CAMERA_VIDEO_FRAME_RATE_15FPS = 0, // 14.985
DJI_CAMERA_VIDEO_FRAME_RATE_24FPS = 1, // 23.976
DJI_CAMERA_VIDEO_FRAME_RATE_25FPS = 2, // 25.000
DJI_CAMERA_VIDEO_FRAME_RATE_30FPS = 3, // 29.970
DJI_CAMERA_VIDEO_FRAME_RATE_48FPS = 4, // 47.952
DJI_CAMERA_VIDEO_FRAME_RATE_50FPS = 5, // 50FPS
DJI_CAMERA_VIDEO_FRAME_RATE_60FPS = 6, // 59.940
DJI_CAMERA_VIDEO_FRAME_RATE_120FPS = 7, // 119.880
DJI_CAMERA_VIDEO_FRAME_RATE_240FPS = 8, // 239.760
DJI_CAMERA_VIDEO_FRAME_RATE_480FPS = 9, // 479.520
DJI_CAMERA_VIDEO_FRAME_RATE_100PS = 10, // 100PS
DJI_CAMERA_VIDEO_FRAME_RATE_96FPS = 11, // 95.904
DJI_CAMERA_VIDEO_FRAME_RATE_180FPS = 12, // 179.820
DJI_CAMERA_VIDEO_FRAME_RATE_TRUE24FPS = 13, // 24
DJI_CAMERA_VIDEO_FRAME_RATE_TRUE30FPS = 14, // 30
DJI_CAMERA_VIDEO_FRAME_RATE_TRUE48FPS = 15, // 48
DJI_CAMERA_VIDEO_FRAME_RATE_TRUE60FPS = 16, // 60
DJI_CAMERA_VIDEO_FRAME_RATE_90FPS = 17, // 89.910
DJI_CAMERA_VIDEO_FRAME_RATE_192FPS = 18, // 191.808
DJI_CAMERA_VIDEO_FRAME_RATE_200FPS = 19, // 200FPS
DJI_CAMERA_VIDEO_FRAME_RATE_400FPS = 20, // 400FPS
DJI_CAMERA_VIDEO_FRAME_RATE_8FPS = 21, // 7.5fps(for flir camera)
DJI_CAMERA_VIDEO_FRAME_RATE_20FPS = 22, // 20
DJI_CAMERA_VIDEO_FRAME_RATE_8_DOT_8FPS = 23, // 8.8fps
} DJI_CAMERA_VIDEO_FRAME_RATE;
// 多媒体素材(照片,视频)旋转方向(顺时针旋转)
typedef enum : uint8_t {
DJI_ROTATE_0 = 0, // 旋转角度0°
DJI_ROTATE_90 = 1, // 旋转角度90°
DJI_ROTATE_180 = 2, // 旋转角度180°
DJI_ROTATE_270 = 3, // 旋转角度270°
} DJI_MULTIMEDIA_ROTATE;
typedef enum : uint8_t {
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_REQ = 0, // 请求
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_DATA = 1, // 数据
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_ACK = 2, // 应答
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_PUSH = 3, // 催促
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_ABORT = 4, // 退出
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_DEL = 5, // 删除
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_PAUSE = 6, // 暂停
DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE_RESUME = 7, // 继续
} DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE;
typedef enum : uint8_t {
DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_LIST = 0, // 文件列表
DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_FILE = 1, // 文件
DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_STREAM = 2, // 流
DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE_MULTI_STREAM =
3, // 多类型流,可以是H264、H265、MJPEG等。该类型相比于GENERAL_DOWNLOAD_FILE_TASK_TYPE_STREAM,响应数据段增加了头部信息
} DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE;
typedef enum : uint8_t {
DJI_CAMERA_VIDEO_RESOLUTION_640X480P = 0, // 640X480P
DJI_CAMERA_VIDEO_RESOLUTION_640X480I = 1, // 640X480I
DJI_CAMERA_VIDEO_RESOLUTION_1280X640P = 2, // 1280X640P
DJI_CAMERA_VIDEO_RESOLUTION_1280X640I = 3, // 1280X640I
DJI_CAMERA_VIDEO_RESOLUTION_1280X720P = 4, // 1280X720P
DJI_CAMERA_VIDEO_RESOLUTION_1280X720I = 5, // 1280X720I
DJI_CAMERA_VIDEO_RESOLUTION_1280X960P = 6, // 1280X960P
DJI_CAMERA_VIDEO_RESOLUTION_1280X960I = 7, // 1280X960I
DJI_CAMERA_VIDEO_RESOLUTION_1920X960P = 8, // 1920X960P
DJI_CAMERA_VIDEO_RESOLUTION_1920X960I = 9, // 1920X960I
DJI_CAMERA_VIDEO_RESOLUTION_1920X1080P = 10, // 1920X1080P
DJI_CAMERA_VIDEO_RESOLUTION_1920X1080I = 11, // 1920X1080I
DJI_CAMERA_VIDEO_RESOLUTION_1920X1440P = 12, // 1920X1440P
DJI_CAMERA_VIDEO_RESOLUTION_1920X1440I = 13, // 1920X1440I
DJI_CAMERA_VIDEO_RESOLUTION_3840X1920P = 14, // 3840X1920P
DJI_CAMERA_VIDEO_RESOLUTION_3840X1920I = 15, // 3840X1920I
DJI_CAMERA_VIDEO_RESOLUTION_3840X2160P = 16, // 3840X2160P
DJI_CAMERA_VIDEO_RESOLUTION_3840X2160I = 17, // 3840X2160I
DJI_CAMERA_VIDEO_RESOLUTION_3840X2880P = 18, // 3840X2880P
DJI_CAMERA_VIDEO_RESOLUTION_3840X2280I = 19, // 3840X2280I
DJI_CAMERA_VIDEO_RESOLUTION_4096X2048P = 20, // 4096X2048P
DJI_CAMERA_VIDEO_RESOLUTION_4960X2048I = 21, // 4960X2048I
DJI_CAMERA_VIDEO_RESOLUTION_4096X2160P = 22, // 4096X2160P
DJI_CAMERA_VIDEO_RESOLUTION_4096X2160I = 23, // 4096X2160I
DJI_CAMERA_VIDEO_RESOLUTION_2704X1520P_16COLON9 = 24, // 2704X1520P,16:9
DJI_CAMERA_VIDEO_RESOLUTION_640X512P_FLIR = 26, // 640X512P_FLIR
DJI_CAMERA_VIDEO_RESOLUTION_4608X2160 = 27, // 4608X2160
DJI_CAMERA_VIDEO_RESOLUTION_4608X2592 = 28, // 4608X2592
DJI_CAMERA_VIDEO_RESOLUTION_2720X1530P = 31, // 2720X1530P
DJI_CAMERA_VIDEO_RESOLUTION_5280X2160P = 32, // 5280X2160P
DJI_CAMERA_VIDEO_RESOLUTION_5280X2970P = 33, // 5280X2970P
DJI_CAMERA_VIDEO_RESOLUTION_3840X1572P = 34, // 3840X1572P
DJI_CAMERA_VIDEO_RESOLUTION_5760X3240P = 35, // 5760X3240P
DJI_CAMERA_VIDEO_RESOLUTION_6016X3200P = 36, // 6016X3200P
DJI_CAMERA_VIDEO_RESOLUTION_2048X1080P = 37, // 2048X1080P
DJI_CAMERA_VIDEO_RESOLUTION_336X256P_FLIR = 38, // 336X256P_FLIR
DJI_CAMERA_VIDEO_RESOLUTION_5120X2880P = 39, // 5120x2880P
DJI_CAMERA_VIDEO_RESOLUTION_4096X2160P_RAW14 = 40, // 4096X2160P_RAW14
DJI_CAMERA_VIDEO_RESOLUTION_3840X2160P_RAW14 = 41, // 3840X2160P_RAW14
DJI_CAMERA_VIDEO_RESOLUTION_2720X1530P_RAW14 = 42, // 2720X1530P_RAW14
DJI_CAMERA_VIDEO_RESOLUTION_1920X1080P_RAW14 = 43, // 1920X1080P_RAW14
DJI_CAMERA_VIDEO_RESOLUTION_5440X2880P = 44, // 5440X2880P
DJI_CAMERA_VIDEO_RESOLUTION_2688X1512P = 45, // 2688X1512P
DJI_CAMERA_VIDEO_RESOLUTION_640X360P = 46, // 640X360P
DJI_CAMERA_VIDEO_RESOLUTION_4000X3000P = 48, // 4000X3000P
DJI_CAMERA_VIDEO_RESOLUTION_4000X3000I = 49, // 4000X3000I
DJI_CAMERA_VIDEO_RESOLUTION_2880X1620P = 50, // 2880X1620P
DJI_CAMERA_VIDEO_RESOLUTION_2880X1620I = 51, // 2880X1620I
DJI_CAMERA_VIDEO_RESOLUTION_2720X2040P = 52, // 2720X2040P
DJI_CAMERA_VIDEO_RESOLUTION_2720X2040I = 53, // 2720X2040I
DJI_CAMERA_VIDEO_RESOLUTION_720X576 = 54, // 720X576
DJI_CAMERA_VIDEO_RESOLUTION_MAX = 253, // MAX
DJI_CAMERA_VIDEO_RESOLUTION_UNSET = 254, // UNSET
DJI_CAMERA_VIDEO_RESOLUTION_KNOWN = 255, // KNOWN
} DJI_CAMERA_VIDEO_RESOLUTION;
typedef enum : uint8_t {
DJI_CAMERA_FILE_TYPE_JPEG = 0,
DJI_CAMERA_FILE_TYPE_DNG = 1,
DJI_CAMERA_FILE_TYPE_MOV = 2,
DJI_CAMERA_FILE_TYPE_MP4 = 3,
DJI_CAMERA_FILE_TYPE_PANORAMA = 4,
DJI_CAMERA_FILE_TYPE_TIFF = 5,
DJI_CAMERA_FILE_TYPE_SEQ = 8, // (for XT2 Camera use)
DJI_CAMERA_FILE_TYPE_TIFFSEQ = 9, // (for XT2 Camera use)
DJI_CAMERA_FILE_TYPE_AUDIO = 10, // for WM245 accessory
DJI_CAMERA_FILE_TYPE_SURVEY = 12,
DJI_CAMERA_FILE_TYPE_USER_CTRL_INFO = 13, // 用户操作信息的原始文件类型
DJI_CAMERA_FILE_TYPE_USER_CTRL_INFO_LZ4 = 14, // 用户操作信息使用LZ4压缩后类型
DJI_CAMERA_FILE_TYPE_JSON = 15, // JSON文件
DJI_CAMERA_FILE_TYPE_PHOTO_FOLDER = 16, // 照片文件夹
DJI_CAMERA_FILE_TYPE_VIDEO_FOLDER = 17, // 视频文件夹
} DJI_CAMERA_FILE_TYPE;
// 视频传输数据流格式,app告诉camera想要什么格式的视频流。
typedef enum : uint8_t {
DJI_TRANS_VIDEO_STREAM_ORG = 0, // 原片码流格式
DJI_TRANS_VIDEO_STREAM_H264 = 1, // h264
DJI_TRANS_VIDEO_STREAM_H265 = 2, // h265
DJI_TRANS_VIDEO_STREAM_MJPEG = 3, // motion jpeg
} DJI_TRANS_VIDEO_STREAM_FORMAT;
// 请求下载的文件子类型
typedef enum : uint8_t {
DJI_DOWNLOAD_FILE_ORG = 0, // 原文件
DJI_DOWNLOAD_FILE_THM = 1, // 缩略图
DJI_DOWNLOAD_FILE_SCR = 2, // 截屏图
DJI_DOWNLOAD_FILE_CLIP = 3, // 视频剪辑
DJI_DOWNLOAD_FILE_STREAM = 4, // 流传输
DJI_DOWNLOAD_FILE_PANO = 5, // 全景照片
DJI_DOWNLOAD_FILE_PANO_SCR = 6, // 全景照片截屏图
DJI_DOWNLOAD_FILE_PANO_THM = 7, // 全景照片缩略图
DJI_DOWNLOAD_FILE_TIMELAPES = 8, // Timelapse照片
DJI_DOWNLOAD_FILE_2ND_STREAM = 9, // 第二路码流文件
DJI_DOWNLOAD_FILE_RESERVED = 10, // 预留
DJI_DOWNLOAD_FILE_PHOTO_METADATA = 11, // 照片元数据
DJI_DOWNLOAD_FILE_USER_CTRL_INFO = 12, // 用户操作信息数据
DJI_DOWNLOAD_FILE_JSON = 13, // JSON文件
} DJI_DOWNLOAD_FILE_SUBTYPE;
// 文件列表扩展数据信息类型
typedef enum : uint8_t {
DJI_EXT_TYPE_UUID = 1, // 视频UUID
DJI_EXT_TYPE_P_TID = 2, // 照片类型和ID
DJI_EXT_TYPE_STAR = 3, // 星标
DJI_EXT_TYPE_V_TID = 4, // 视频类型信息
DJI_EXT_TYPE_FUSION = 5, // 合成照片Group信息
DJI_EXT_TYPE_V_FILE_SYNC = 6, // 文件信息同步
DJI_EXT_TYPE_ORIGIN = 7, // 原片信息
DJI_EXT_TYPE_EXIF = 8, // EXIF信息
DJI_EXT_TYPE_AUDIO = 9, // 音频信息
DJI_EXT_TYPE_VIDEO_MISCINFO = 10, // 视频附加类型信息
DJI_EXT_TYPE_CUSTOMIZE_DCF_INFO = 11, // 自定义DCF照片信息
DJI_EXT_TYPE_FILE_NAME = 13, // 文件名信息
DJI_EXT_TYPE_FILE_MD5 = 14, // 文件MD5值
} DJI_FILE_LIST_EXT_TYPE;
typedef enum : uint8_t {
DJI_all = 0, // 喜欢不喜欢全都要
DJI_like = 1, // 喜欢
DJI_dislike = 2, // 不喜欢
DJI_unknown = 255, // 未知
} DJI_FILE_LIST_FILTER_LIKE;
typedef enum : uint8_t {
DJI_MEDIA = 0, // 媒体文件
DJI_THUMBNAIL = 1, // 缩略图
DJI_SCREENNAIL = 2, // 截屏图
DJI_VIDEO_CLIP = 3, // 视频剪辑
DJI_LOG = 12, // 固件日志文件
DJI_MEDIA_GROUP = 13, // 相机自动成组的媒体文件
// 逻辑:
// 成组逻辑包括 AEB、Burst、Interval、视频大于 4G 自动分段、Pano
// 1. 相机根据 Index 和 ReqCount 推送相应数量的素材信息,遇到 Group 照片、分段视频等,则只推送组内第一个文件信息
// 2. AEB、Burst 的张数显示在 0x27 的 dji_ext_fusion 的字段 amount,最大 9999 张
// 3. 分段视频相机自动计算所有分段合并后的总时长填充到视频 attribute_video_duration 字段
DJI_PSDK_WIDGET =
14, // PSDK 自定义控件配置,包括配置文件和图标文件,存储在第三方负载中。DJI Pilot 拉取配置文件和图标文件后可以显示控件,用于显示第三方负载状态数据并控制第三方负载。
} DJI_DOWNLOAD_FILE_LIST_TYPE;
typedef enum : uint8_t {
MAJOR_CAMERA = 0,
MAJOR_RADAR = 1,
MAJOR_PSDK = 2,
} MAJOR_TYPE;
typedef enum : uint8_t {
MINOR_CAMERA = 0,
MINOR_PSDK = 2,
} MINOR_TYPE;
#pragma pack(1)
/*! (0x00,0x26) 相关结构体定义*/
// 文件下载请求,由 App 向相机发出的文件下载请求。
typedef struct {
// 报文头长度
uint8_t header_length:6;
// 传输协议版本号
uint8_t version :2;
// 传输协议类型
uint8_t func_id:5; // enum-type: DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE
// 子业务ID
uint8_t task_id:3; // enum-type: DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE
// 报文总长度
uint16_t msg_length:12;
// 标志,最低位为1代表是最后一个包
uint16_t msg_flag :4;
// 回话ID
uint16_t session_id;
// 报文在业务中的编号
uint32_t seq;
// 消息数据
// dji_file_list_download_req : 文件列表下载请求
// dji_file_download_req : 文件下载请求
// dji_stream_download_req : 流下载请求
// dji_download_ack : 下载应答
uint8_t data[1];
} dji_general_transfer_msg_req;
// 文件列表过滤器 - 视频
// 各素材类型比特位如果为 **1** 表示需要过滤出该类型素材,为 **0** 则不过滤出来
typedef struct {
// 普通录像
uint32_t video_nomal :1;
// 慢动作录像
uint32_t video_slowmotion:1;
// 延时视频(拍照合成方式)
uint32_t video_timelapse :1;
// Hyperlapse
uint32_t video_hyperlapse:1;
// HDR录像
uint32_t video_hdr :1;
// 循环录像
uint32_t video_loop :1;
// 保留位
uint32_t reserved :26;
} dji_file_list_filter_video;
// 文件列表过滤器 - 照片
// 各素材类型比特位如果为 **1** 表示需要过滤出该类型素材,为 **0** 则不过滤出来
typedef struct {
// 普通照片
uint32_t photo_normal :1;
// HDR 照片
uint32_t photo_hdr :1;
// AEB 照片
uint32_t photo_aeb :1;
// 定时拍
uint32_t photo_interval:1;
// Burst 照片
uint32_t photo_burst :1;
// 全景照片
uint32_t photo_pano :1;
// 保留位
uint32_t reserved :26;
} dji_file_list_filter_photo;
// **文件列表下载过滤器**
// <br/>
// 过滤器组合规则:
// 1. **like** 过滤器作用于后续所有过滤器的结果,进行**逻辑与**运算;
// 2. **video**、**photo** 等 过滤器内部通过**逻辑或**运算取值,各过滤器结果取并集
// ```
// like && ((video) U (photo))
// 如:
// like = 1
// video = 1
// photo = 3
// 即表示过滤:所有(普通录像、普通照片、HDR 照片)中 被 like 的文件。
// ```
typedef struct {
// 媒体文件是否被喜欢加星
uint8_t like; // enum-type: DJI_FILE_LIST_FILTER_LIKE
// 视频素材过滤器,按位或取值
dji_file_list_filter_video video;
// 照片素材过滤器,按位或取值
dji_file_list_filter_photo photo;
} dji_download_file_list_filter;
// 文件index 定义
typedef struct {
// 文件index 信息
uint32_t index:30;
// 逻辑分区信息, 表示逻辑分区0 - 逻辑分区3
uint32_t drive:2;
} dji_file_index_t;
// 文件列表下载请求
typedef struct {
// 起始文件IndexUINT32LSB在前,MSB在后)。
// 注:=1表示从第一个文件开始
dji_file_index_t index;
// 文件个数(UINT16LSB在前,MSB在后)
// 注:=0xFFFF表示传之后所有的列表信息
uint16_t count;
// 请求下载信息的文件子类型
uint8_t type; // enum-type: DJI_DOWNLOAD_FILE_LIST_TYPE
// **type == DJI_MEDIA_GROUP 时生效**
// <br/><br/>
// filter_enable 为 `0` 时,表示不启用过滤器,从所有素材中进行文件列表拉取。<br/>
// filter_enable 为 `1` 时,表示启用过滤器,根据 filters 过滤规则进行文件过滤。
uint8_t filter_enable;
// **文件列表筛选过滤器**
// <br/>
// filter_enable 为 `1` 时生效
// download_file_list_filter
dji_download_file_list_filter filters;
} dji_file_list_download_req;
// 消息数据 – 文件下载请求(由App向相机发出的文件下载请求)
typedef struct {
// 起始文件IndexUINT32LSB在前,MSB在后)。
dji_file_index_t index;
// 请求下载的文件个数(UINT16,LSB在前,MSB在后)。
// 注:
// 当为0xffff时为传之后所有的文件
// 当前只支持1
uint16_t count;
// 请求下载的文件子类型
uint8_t type; // enum-type: DJI_DOWNLOAD_FILE_SUBTYPE
// 请求下载的文件子索引
// 当此字段为0xFF时,使用扩展文件子索引字段
uint8_t sub_index;
// 请求下载的文件数据偏移(UINT32,LSB在前,MSB在后)。
uint32_t offset;
// 请求下载的文件数据大小(UINT32,LSB在前,MSB在后)
uint32_t size;
// 扩展文件子索引
uint32_t ext_sub_index;
// 扩展分段文件子索引
uint16_t seg_sub_index;
} dji_file_download_req;
// 流数据传输
typedef struct {
// 流文件Index
dji_file_index_t index;
// 请求传输的流起始时间,单位ms
uint32_t offset;
union {
// 请求传输的流时长,单位ms, -1表示传输至本文件流结束,-2表示跨文件一直传输直到后续的所有文件流结束
int32_t duration;
// 请求传输的文件个数, -1表示传输之后的所有文件,目前只有video_type=DJI_TRANS_VIDEO_STREAM_MJPEG时使用
int32_t count;
};
// 请求传输的流子类型:视频码流格式
uint8_t video_type:4; // enum-type: DJI_TRANS_VIDEO_STREAM_FORMAT
// 请求传输的流子类型:音频开关及码流格式。0表示不需要音频,1表示原片码流格式的音频
uint8_t audio_type:4;
// 请求传输的流子索引(用于扩展)
uint8_t subindex;
// 播放速率控制。
// [7] – 加速/减速标志
// [6:0] – 变速倍数
uint8_t speed_ctrl;
// 视频分辨率
uint8_t resolution; // enum-type: DJI_CAMERA_VIDEO_RESOLUTION
// 视频码率
uint16_t bitrate;
} dji_stream_download_req;
// 丢失分片描述
typedef struct {
// 起始分片序号
uint32_t seq;
// 分片个数
uint32_t cnt;
} dji_loss_desc;
// 文件下载应答消息
typedef struct {
// 期望收到的分片序号,表示已收到expect_seq之前的所有分片。
uint32_t expect_seq;
// 丢包信息个数
uint8_t loss_nr;
// 丢包信息
dji_loss_desc loss_desc[1];
} dji_download_ack;
typedef struct {
// Return code
uint8_t ret_code;
} dji_general_transfer_msg_rsp;
/////////////(0x00,0x26) 相关结构体定义////////////
/*! (0x00,0x27) 相关结构体定义*/
// 文件列表扩展数据——照片类型和ID
typedef struct {
// 照片类型
uint8_t type; // enum-type: DJI_EXT_P_TID_TYPE
// 照片ID,同一组照片使用相同的照片ID,普通单拍的情况下设置成0
uint16_t id;
} dji_ext_p_tid;
// 文件列表扩展数据——视频UUID
typedef struct {
// 视频UUID
uint32_t uuid;
} dji_ext_video_uuid;
// 文件列表扩展数据——星标
typedef struct {
// 星标数值
uint8_t star;
} dji_ext_star;
// 文件列表扩展数据内容——视频类型信息
typedef struct {
// 视频类型
uint8_t type; // enum-type: DJI_EXT_V_TID_TYPE
// 视频子类型
// 当视频类型 = 变速视频时:
// 0 = 慢速视频
// 1 = 快速视频
// 其他 = 保留
// 当视频类型 = 一键短片时:
// 0 = 保留
// 1 = 环绕
// 2 = 斜飞
// 3 = 螺旋
// 4 = 火箭
// 其他 = 保留
// 当视频类型 = hyperlapse视频时:
// 0 = hyperlapse with interval
// 1 = hyperlapse with speed ratio
// 其他 = 保留
uint8_t subtype;
// 编码格式
// 0 = H.264
// 1 = H.265
// 其他 = 保留
uint8_t encode_format;
// 变速视频播放倍速(仅对变速视频有效)
// 对于慢速视频:
// 0 = default
// 1 = 1倍速
// 2 = 1/2倍速
// N = 1/N倍速
// 对于快速视频:
// 0 = default
// 1 = 1倍速
// 2 = 2倍速
// N = N倍速
uint8_t speed;
// 保留
uint8_t reserved;
} dji_ext_v_tid;
// 文件列表扩展数据内容—合成照片Group信息,用于相机端使用子文件夹方式存放原照片的情况
typedef struct {
// 照片子类型
// 对于全景照片:
// 0 = 保留
// 1 = 360 Panorama
// 2 = Ball Panorama
// 3 = Vertical Panorama
// 4 = 180 Panorama(云台横拍状态)
// 5 = Wide Panorama(云台横拍状态)
// 6 = 180 Panorama(云台竖拍状态)
// 7 = Wide Panorama(云台竖拍状态)
// 其他 = 保留
// 对于OSMO(X3X5系列)对于全景照片:
// 0 = 保留
// 1 = 360 Panorama
// 2 = Ball Panorama
// 3 = Self Panorama
// 4 = Manual Panorama
// 5 =180 Panorama
// 6 = Vertical Panorama
// 7 = Sectorial Panorama
// 其他 = 保留
uint8_t subtype;
// 原片张数(0~9999)
uint16_t amount:14;
// 机内合成结果,APP合成忽略此字段
// 0 = 保留
// 1 = 成功
// 2 = 失败
// 3 = 中止
uint16_t result:2;
} dji_ext_fusion;
// 文件列表扩展数据——文件同步,用于合成的全景图从APP反向下载到相机的同步指示
typedef struct {
// 1 - 已同步
// 其他 - 保留
uint8_t sync;
} dji_ext_file_sync;
// 文件列表扩展数据——原片信息
typedef struct {
// 是否有原片
// 0 -- 不存在
// 1 -- 存在
uint8_t exist_flag:2;
// 保留
uint8_t reserved :6;
} dji_ext_origin;
// 文件扩展数据——exif信息
typedef struct {
// exposure_time是否有效
uint8_t enable_exposure_time :1;
// fnumber是否有效
uint8_t enable_fnumber :1;
// exposure_program是否有效
uint8_t enable_exposure_program :1;
// iso是否有效
uint8_t enable_iso :1;
// exposure_compensation是否有效
uint8_t enable_exposure_compensation :1;
// metering_mode是否有效
uint8_t enable_metering_mode :1;
// light_source是否有效
uint8_t enable_light_source :1;
// focal_length_35mm_format是否有效
uint8_t enable_focal_length_35mm_format:1;
// exposure_time分子
uint32_t exposure_time_num;
// exposure_time分母
uint32_t exposure_time_den;
// fnumber分子
uint32_t fnumber_num;
// fnumber分母
uint32_t fnumber_den;
// exposure_program
uint16_t exposure_program;
// iso
uint16_t iso;
// exposure_compensation分子
int32_t exposure_compensation_num;
// exposure_compensation分母
int32_t exposure_compensation_den;
// metering_mode
uint16_t metering_mode;
// light_source
uint16_t light_source;
// focal_length_35mm_format
uint16_t focal_length_35mm_format;
} dji_ext_exif;
// 文件列表扩展数据——视频杂项信息
typedef struct {
// 分段视频子索引
uint16_t seg_idx;
// 视频时长(毫秒单位)
uint32_t video_time_in_ms;
union
{
// 当视频类型为1 = 延时视频,或视频类型为5(hyperlapse)且视频子类型是0hyperlapse with interval)时, 表示延时视频帧间隔(单位:100ms)
uint32_t video_timelapse_interval_100ms;
// 当视频类型为5(hyperlapse),且视频子类型是1hyperlapse with speed ratio)时,表示hyperlapse视频倍速值
uint32_t video_hyperlapse_speed_ratio;
// 其他视频类型时, 此字段保留
uint32_t reserved;
};
} dji_ext_misc_video;
// 描述照片或者视频文件的来源,设置拍照或录像要保存的流请参考capture_recording_streams
typedef struct
{
// 文件来源
uint8_t file_source; // enum-type: DJI_DCF_EXT_FILE_SOURCE
// 如果是相机原始照片,这里表明相机来源,不是原始照片时,值为0(DJI_DEFAULT_CAM)
uint8_t source_camera; // enum-type: DJI_STREAM_SOURCE_CAMERA
} dji_dcf_ext_file_source;
// 飞机起飞时间
typedef struct
{
// 保留位
uint32_t reserved:5;
// 分
uint32_t minute :6;
// 时
uint32_t hour :5;
// 日
uint32_t day :5;
// 月
uint32_t month :4;
// 年(从1980年开始)
uint32_t year :7;
} dji_departure_time;
// 自定义DCF文件信息
typedef struct {
// 用户标示信息
uint8_t customKey[8];
// 自定义dcf文件来源
dji_dcf_ext_file_source dcf_ext_file_source;
// 起飞时间
dji_departure_time departure_time;
// 自定义dcf文件所在目录Index
uint8_t dcf_directory_index;
// 自定义dcf文件文件Index
uint32_t dcf_file_index;
// 自定义dcf文件所在集合Id
uint32_t dcf_file_setId;
} dji_ext_customize_dcf_info;
// 媒体文件文件名信息
typedef struct {
// 文件名长度
uint8_t file_name_len;
// 文件名字符串(不包括空字符)
uint8_t file_name[1];
} dji_ext_file_name;
// 文件MD5值信息
typedef struct {
// MD5值校验,用于DJI Pilot 校验PSDK 自定义控件配置文件。DJI Pilot 会在本地缓存PSDK 自定义控件配置文件,如果MD5不一致才会重新拉取配置文件。
uint8_t file_md5[16];
} dji_ext_file_md5;
// 扩展数据描述符
typedef struct {
// 扩展信息数据类型
uint8_t id; // enum-type: DJI_FILE_LIST_EXT_TYPE
// 扩展信息数据内容
// ext_video_uuid : 视频UUID
// ext_p_tid : 照片类型和ID
// ext_star : 星标
// ext_v_tid : 视频类型信息
// ext_fusion : 合成照片Group信息
// ext_file_sync : 文件同步
// ext_origin : 原片信息
// ext_exif : EXIF信息
// ext_misc_video : 视频杂项信息
// ext_customize_dcf_info : 自定义DCF格式文件信息
// ext_file_name : 文件名信息
// ext_file_md5 : 文件MD5值校验
uint8_t data[1];
} dji_ext_info_descriptor;
// 文件列表扩展信息
typedef struct {
// 扩展信息项,注意新增扩展信息项时必须从尾部开始添加
dji_ext_info_descriptor ext_info_item[1];
// 扩展数据结束标记。固定为'\0'
uint8_t eof;
} dji_file_list_ext_info;
// file create time
typedef struct {
// 双秒(实际值 = 双秒 x 2)
uint32_t second:5;
// 分
uint32_t minute:6;
// 时
uint32_t hour :5;
// 日
uint32_t day :5;
// 月
uint32_t month :4;
// 年(从1980年开始)
uint32_t year :7;
} dji_file_create_time;
// 文件列表信息描述符
typedef struct {
// 文件的创建时间
dji_file_create_time create_time;
// 文件大小
uint32_t size;
// 文件索引
uint32_t index;
union {
struct video_attribute_type {
// 视频时长,单位(秒)
uint32_t attribute_video_duration :16;
// 视频帧率
uint32_t
attribute_video_framerate :6;// enum-type: DJI_CAMERA_VIDEO_FRAME_RATE
// 视频旋转方向
uint32_t attribute_video_rotation :2;// enum-type: DJI_MULTIMEDIA_ROTATE
// 视频分辨率
uint32_t
attribute_video_resolution:8;// enum-type: DJI_CAMERA_VIDEO_RESOLUTION
} video_attribute;
struct photo_attribute_type {
// 保留位
uint32_t attribute_photo_reserved:22;
// 照片旋转方向
uint32_t attribute_photo_rotation:2; // enum-type: DJI_MULTIMEDIA_ROTATE
// 照片宽高比
uint32_t attribute_photo_ratio :8; // enum-type: DJI_CAMERA_PHOTO_RATIO
} photo_attribute;
} attribute;
// 文件类型
uint8_t type; // enum-type: DJI_CAMERA_FILE_TYPE
// 扩展数据长度
uint8_t ext_size;
// 扩展数据内容,可以包含多项数据,每项数据包括数据类型(1字节)和数据内容(N字节)。
// 在最后一个扩展数据末尾添加1字节的’\0’结尾。
// 不同类型的文件的扩展数据长度保持一致,长度不足时在末端补’\0’。
dji_file_list_ext_info ext_data;
} dji_list_info_descriptor;
// 文件列表应答
typedef struct {
// 文件总数
uint32_t amount;
// 文件列表信息长度,包括文件总数字段
uint32_t len;
// 文件列表信息描述符
dji_list_info_descriptor list_info[1];
} dji_file_list_download_resp;
// camera发给app的stream数据包的头信息。
typedef struct {
// stream的格式
uint8_t format :6; // enum-type: DJI_TRANS_STREAM_FORMAT
// 版本号
uint8_t version:2;
// 该数据所在的流文件Index
dji_file_index_t index;
// 时间戳,单位us
int64_t timestamp;
// 数据的长度,不包含本头信息
uint32_t length;
// 数据
uint8_t data[1];
} dji_multi_stream_download_rsp;
// 0x00 0x27 文件下载返回结构体定义
typedef struct {
union {
// 文件列表应答数据
dji_file_list_download_resp file_list_download_rsp;
// 多类型流传输应答数据,单一码流无header信息(H264流)
dji_multi_stream_download_rsp multi_stream_download_rsp;
// 错误码
uint32_t abort_rsp; // enum-type: DJI_DOWNLOAD_FILE_ABORT_ERROR_CODE
};
} dji_download_file_ack_data;
// 文件下载请求的ack,由相机向App发出
typedef struct {
// 报文头长度
uint8_t header_length:6;
// 传输协议版本号
uint8_t version :2;
// 传输协议类型
uint8_t func_id:5; // enum-type: DJI_GENERAL_DOWNLOAD_FILE_FUNC_TYPE
// 子业务ID
uint8_t task_id:3; // enum-type: DJI_GENERAL_DOWNLOAD_FILE_TASK_TYPE
// 报文总长度
uint16_t msg_length:12;
// 标志,最低位为1代表是最后一个包
uint16_t msg_flag :4;
// 回话ID
uint16_t session_id;
// 报文在业务中的编号
uint32_t seq;
// 消息数据
// dji_download_file_ack_data : 返回数据定义
uint8_t data[1];
} dji_general_transfer_msg_ack;
/////////////(0x00,0x26) 相关结构体定义////////////
#pragma pack()
#endif //_DJI_FILE_INTERNAL_DEFINE_HPP_
+112
Ver Arquivo
@@ -0,0 +1,112 @@
/** @file dji_mop_client.hpp
* @version 4.0
* @date Jan 2020
*
* @brief Implementation of the mop client
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_MOP_CLIENT_HPP
#define DJI_MOP_CLIENT_HPP
#include "dji_mop_pipeline.hpp"
#include "dji_mop_pipeline_manager_base.hpp"
namespace DJI {
namespace OSDK {
// Forward Declarations
class Vehicle;
class MopClient : MopPipelineManagerBase {
public:
MopClient(SlotType slot);
~MopClient();
/*! @brief Connect the target device by a pipelineid with properties of
* pipeline type. If success, a pipeline object will be created.
* @note This is a blocking api
* @param id The pipeline id which to be connected, ref to
* DJI::OSDK::MOP::PipelineID
* @param type The pipeline type. It can be set to be RELIABLE or UBRELIABLE
* ref to the enum DJI::OSDK::MOP::PipelineType
* @param p The pointer of pipeline. If success, it will be pointed to be the
* target pipeline object.
* @return ref to the enum DJI::OSDK::MOP::MopErrCode
*/
MopErrCode connect(PipelineID id, PipelineType type, MopPipeline *&p);
/*! @brief Connect the target device by a pipelineid with properties of
* pipeline type. If success, a pipeline object will be created.
* @note This is a non-blocking api.
* @todo This api is not implemented yet, it will be implemented in the
* future.
* @param id The pipeline id which to be connected, ref to
* DJI::OSDK::MOP::PipelineID
* @param type The pipeline type. It can be set to be RELIABLE or UBRELIABLE
* ref to the enum DJI::OSDK::MOP::PipelineType
* @param cb Callback function defined by user
* @arg @b errCode is the DJI::OSDK::MOP::MopErrCode error code
* @arg @b p The pointer of pipeline. If success, it will be pointed to be the
* target pipeline object.
* @arg @b userData the interface to pass userData in when the callback is
* called
* @param userData when UserCallBack is called, used in UserCallBack
*/
void connect(PipelineID id, PipelineType type,
void (*cb)(MopErrCode errCode, MopPipeline *p,
void *userData),
void *userData);
/*! @brief Disonnect the target device by a pipelineid.
* @note This is a blocking api
* @param id The pipeline id which to be connected, ref to
* DJI::OSDK::MOP::PipelineID
* @return ref to the enum DJI::OSDK::MOP::MopErrCode
*/
MopErrCode disconnect(PipelineID id);
/*! @brief Disonnect the target device by a pipelineid.
* @note This is a non-blocking api
* @todo This api is not implemented yet, it will be implemented in the
* future.
* @param id The pipeline id which to be connected, ref to the enum
* @param cb Callback function defined by user
* @arg @b errCode is the DJI::OSDK::MOP::MopErrCode error code
* @arg @b userData the interface to pass userData in when the callback is
* called
* @param userData when UserCallBack is called, used in UserCallBack
*/
void disconnect(PipelineID id,
void (*cb)(MopErrCode errCode, void *userData),
void *userData);
private:
Vehicle *vehicle;
SlotType slot;
};
}
}
#endif //DJI_MOP_CLIENT_HPP
@@ -0,0 +1,85 @@
/** @file dji_mop_define.hpp
* @version 4.0
* @date Jan 2020
*
* @brief Enumeration of all mop data types, structures.
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_MOP_DEFINE_HPP
#define DJI_MOP_DEFINE_HPP
#include "mop_entry_osdk.h"
#include "dji_log.hpp"
/*!
* Top-level namespace
*/
namespace DJI {
/*!
* Onboard SDK related commands
*/
namespace OSDK {
/*! @brief This namespace encapsulates all available telemetry topics through
* either
* Broadcast or Subscribe
*/
namespace MOP {
typedef enum MopErrCode {
MOP_PASSED,
MOP_FAILED,
MOP_CRC,
MOP_PARM,
MOP_NOMEM,
MOP_NOTREADY,
MOP_SEND,
MOP_RECV,
MOP_TIMEOUT,
MOP_RESBUSY,
MOP_RESOCCUPIED,
MOP_CONNECTIONCLOSE,
MOP_NOTIMPLEMENT,
MOP_UNKNOWN_ERR,
} MopErrCode;
typedef enum {
RELIABLE,
UNRELIABLE,
} PipelineType;
typedef enum SlotType {
SLOT_0 = 0,
SLOT_1 = 1,
SLOT_2 = 2,
} SlotType;
/*! User define the pipeline in the range of uint16_t */
typedef uint16_t PipelineID;
MopErrCode getMopErrCode(int ret);
}
}
}
#endif // DJI_MOP_DEFINE_HPP
@@ -0,0 +1,67 @@
/** @file dji_mop_pipeline.hpp
* @version 4.0
* @date January 2020
*
* @brief Implementation of mop pipeline
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_MOP_PIPELINE_HPP
#define DJI_MOP_PIPELINE_HPP
#include <stdint.h>
#include "dji_mop_define.hpp"
using namespace DJI::OSDK;
using namespace DJI::OSDK::MOP;
namespace DJI {
namespace OSDK {
class MopPipeline {
public:
MopPipeline(PipelineID id, PipelineType type);
~MopPipeline();
typedef struct DataPackType {
uint8_t* data;
uint32_t length;
} DataPackType;
public:
MopErrCode sendData(DataPackType dataPacket, uint32_t *len);
MopErrCode recvData(DataPackType dataPacket, uint32_t *len);
void *channelHandle;
private:
PipelineID id;
PipelineType type;
};
} // namespace OSDK
} // namespace DJI
#endif // DJI_MOP_PIPELINE_HPP
@@ -0,0 +1,63 @@
/** @file dji_mop_pipeline_manager_base.hpp
* @version 4.0
* @date January 2020
*
* @brief Implementation of mop pipeline manager base
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_MOP_PIPELINE_MANAGER_BASE_HPP
#define DJI_MOP_PIPELINE_MANAGER_BASE_HPP
#include "dji_mop_define.hpp"
#include "dji_mop_pipeline.hpp"
#include "dji_log.hpp"
#include <map>
using namespace DJI::OSDK;
using namespace DJI::OSDK::MOP;
using namespace std;
/*! TODO:ugly code, will be fixed in the future */
extern map<PipelineID, MopPipeline*> pipelineMap;
namespace DJI {
namespace OSDK {
class MopPipelineManagerBase {
public:
MopPipelineManagerBase();
~MopPipelineManagerBase();
/*! TODO:MSDK 单单create的这种写法指代不明,在这个接口加上了"Pipeline"后缀 */
MopErrCode create(PipelineID id, MopPipeline *&p);
/*! TODO:MSDK 单单create的这种写法指代不明,在这个接口加上了"Pipeline"后缀 */
MopErrCode destroy(PipelineID id);
};
} // namespace OSDK
} // namespace DJI
#endif // DJI_MOP_PIPELINE_MANAGER_BASE_HPP
@@ -0,0 +1,75 @@
/** @file dji_mop_server.hpp
* @version 4.0
* @date Jan 2020
*
* @brief Implementation of the mop client
*
* @Copyright (c) 2020 DJI
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef DJI_MOP_SERVER_HPP
#define DJI_MOP_SERVER_HPP
#include "dji_mop_pipeline.hpp"
#include "dji_mop_pipeline_manager_base.hpp"
namespace DJI {
namespace OSDK {
// Forward Declarations
class Vehicle;
class MopServer : MopPipelineManagerBase {
public:
MopServer();
~MopServer();
/*! @brief Accept the connecting request from target device with properties of
* a pipelineid and pipeline type. If success, a pipeline object will be
* created.
* @note This is a blocking api
* @param id The pipeline id which to be connected, ref to
* DJI::OSDK::MOP::PipelineID
* @param type The pipeline type. It can be set to be RELIABLE or UBRELIABLE
* ref to the enum DJI::OSDK::MOP::PipelineType
* @param p The pointer of pipeline. If success, it will be pointed to be the
* target pipeline object.
* @return ref to the enum DJI::OSDK::MOP::MopErrCode
*/
MopErrCode accept(PipelineID id, PipelineType type, MopPipeline *&p);
/*! @brief Close the target pipeline by a pipelineid.
* @note This is a blocking api
* @param id The pipeline id which to be connected, ref to
* DJI::OSDK::MOP::PipelineID
* @return ref to the enum DJI::OSDK::MOP::MopErrCode
*/
MopErrCode close(PipelineID id);
private:
Vehicle *vehicle;
};
}
}
#endif //DJI_MOP_SERVER_HPP
@@ -103,6 +103,17 @@ class PSDKManager {
bool &enable);
public:
/*! @brief Get the mop client object of the target psdk module.
*
* @param index payload node index, input limit see enum
* DJI::OSDK::PayloadIndexType
* @param mopClient If this api called successfully, this pointer will point
* to the mop client object of target psdk module.
* @return ErrorCode::ErrorCodeType error code
*/
ErrorCode::ErrorCodeType getMopClient(
PayloadIndexType index, MopClient *&mopClient);
/*! @brief Sample to configure the value, blocking
*
* @param index payload node index, input limit see enum
+11 -1
Ver Arquivo
@@ -32,6 +32,9 @@
#include <vector>
#include "dji_payload_base.hpp"
#include "dji_payload_link.hpp"
#if defined(__linux__)
#include "dji_mop_client.hpp"
#endif
namespace DJI {
namespace OSDK {
@@ -115,6 +118,11 @@ class PSDKModule : public PayloadBase {
~PSDKModule();
public:
#if defined(__linux__)
/*! @breif Get the object of the mop client of this psdk module */
MopClient *getMopClient();
#endif
/*! @brief Sample to configure the value, blocking
*
* @param widgetIndex the index of target widget
@@ -200,7 +208,9 @@ class PSDKModule : public PayloadBase {
private:
static const int maxSize = 32;
#if defined(__linux__)
MopClient *mopClient;
#endif
PayloadLink *payloadLink;
/*! @brief handler to decoding the widget values raw data from raw data
+11
Ver Arquivo
@@ -59,6 +59,9 @@
#ifdef ADVANCED_SENSING
#include "dji_advanced_sensing.hpp"
#endif
#if defined(__linux__)
#include "dji_mop_server.hpp"
#endif
namespace DJI
{
@@ -116,6 +119,11 @@ public:
PSDKManager* psdkManager;
GimbalManager* gimbalManager;
DJIHMS* djiHms;
#if defined(__linux__)
MopServer* mopServer;
#endif
#ifdef ADVANCED_SENSING
AdvancedSensing* advancedSensing;
#endif
@@ -282,6 +290,9 @@ public:
bool initPSDKManager();
bool initGimbalManager();
bool initDJIHms();
#if defined(__linux__)
bool initMopServer();
#endif
bool initOSDKHeartBeatThread();
#ifdef ADVANCED_SENSING
bool initAdvancedSensing();
@@ -0,0 +1,77 @@
//
// downloadbufferqueue.h
// djisdk
//
// Created by husong on 12/27/17.
//
//
#ifndef downloadbufferqueue_h
#define downloadbufferqueue_h
#include <stdio.h>
#include <condition_variable>
#include <list>
#include <memory>
#include <mutex>
namespace DJI {
namespace OSDK {
typedef struct DJIDataPointer {
void* data;
int length;
} DataPointer;
class DownloadBufferQueue final {
public:
typedef enum InsertRetType {
INSERT_SUCCESS = 0,
INSERT_FAIL_FULL,
INSERT_FAIL_INVALID_PARAM,
INSERT_FAIL_MEMORY_USED,
INSERT_FAIL_UNKOWN,
} InsertRetType;
DownloadBufferQueue() = default;
virtual ~DownloadBufferQueue() = default;
DownloadBufferQueue(const DownloadBufferQueue& other) = delete;
DownloadBufferQueue(DownloadBufferQueue&& other) = delete;
DownloadBufferQueue& operator=(const DownloadBufferQueue& other) = delete;
DownloadBufferQueue& operator=(DownloadBufferQueue&& other) = delete;
bool InitBufferQueue(int size, int start_index);
bool FindBlockByIndex(int index);
InsertRetType InsertBlock(const uint8_t *data, uint32_t data_length, int index, bool flag);
DataPointer DequeueBuffer();
std::list<DataPointer> DequeueAllBuffer();
int GetConfirmSeq();
int GetBufMaxSeq();
int GetSize() {
return m_size;
};
void Clear();
void Dealloc();
private:
mutable std::mutex m_mutex;
std::condition_variable m_data_condition;
DataPointer* m_queue_ptr = nullptr;
// 确认收到并缓存最大index
int m_buf_max_index;
// 期待接受的index, 即确认收到连续序列index + 1
int m_expect_index;
// 期待接受的index对应的Buf数组下标
int m_head;
// Buffer 的大小
int m_size;
};
} // namespace OSDK
} // namespace DJI
#endif /* downloadbufferqueue_h */
+35
Ver Arquivo
@@ -0,0 +1,35 @@
/*************************************************************************
> File Name: mop_entry_osdk.h
> Author:pakchoi.zhang@dji.com
> Created Time: Mon 09 Dec 2019 12:09:58 PM CST
************************************************************************/
#ifndef __MOP_ENTRY_OSDK_H__
#define __MOP_ENTRY_OSDK_H__
#include <stdint.h>
#define MOP_ENTRY_LOGF(format, ...) \
MOP_LOGF("MOP_ENTRY:" format, ##__VA_ARGS__)
#define MOP_ENTRY_LOGE(format, ...) \
MOP_LOGE("MOP_ENTRY:" format, ##__VA_ARGS__)
#define MOP_ENTRY_LOGW(format, ...) \
MOP_LOGW("MOP_ENTRY:" format, ##__VA_ARGS__)
#define MOP_ENTRY_LOGI(format, ...) \
MOP_LOGI("MOP_ENTRY:" format, ##__VA_ARGS__)
#define MOP_ENTRY_LOGT(format, ...) \
MOP_LOGT("MOP_ENTRY:" format, ##__VA_ARGS__)
#define MOP_ENTRY_LOGV(format, ...) \
MOP_LOGV("MOP_ENTRY:" format, ##__VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
int32_t mop_osdk_init(void);
int32_t mop_osdk_deinit(void);
#ifdef __cplusplus
}
#endif
#endif
Arquivo binário não exibido.
@@ -0,0 +1,41 @@
%YAML:1.0
leftCameraIntrinsicMatrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 488.722778, 0.000000, 322.502625, 0.000000, 488.722778, 241.705963, 0.000000, 0.000000, 1.000000 ]
rightCameraIntrinsicMatrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [ 488.722778, 0.000000, 322.502625, 0.000000, 488.722778, 241.705963, 0.000000, 0.000000, 1.000000 ]
leftDistCoeffs: !!opencv-matrix
rows: 5
cols: 1
dt: d
data: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ]
rightDistCoeffs: !!opencv-matrix
rows: 5
cols: 1
dt: d
data: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ]
leftRectificationMatrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 ]
rightRectificationMatrix: !!opencv-matrix
rows: 3
cols: 3
dt: d
data: [1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 ]
leftProjectionMatrix: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [ 488.722778, 0.000000, 322.502625, 0.000000, 0.000000, 488.722778, 241.705963, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000 ]
rightProjectionMatrix: !!opencv-matrix
rows: 3
cols: 4
dt: d
data: [ 488.722778, 0.000000, 322.502625, -99.072990, 0.000000, 488.722778, 241.705963, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000 ]