更新到psdk 3.13.0,适配M400
This commit is contained in:
@ -155,7 +155,7 @@ T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHand
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
uint8_t *data, uint32_t *realLen)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getDataOrgFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getDataOrgFunc null error");
|
||||
|
||||
@ -57,7 +57,7 @@ typedef struct {
|
||||
T_DjiReturnCode (*getAttrFunc)(struct _DjiMediaFile *mediaFileHandle, T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode (*getDataOrgFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode (*getFileSizeOrgFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode (*createThmFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
@ -91,7 +91,7 @@ T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHand
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThm(T_DjiMediaFileHandle mediaFileHandle);
|
||||
|
||||
@ -82,7 +82,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHand
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
uint8_t *data, uint32_t *realLen)
|
||||
{
|
||||
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHand
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
@ -115,7 +115,7 @@ out:
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
uint8_t *data, uint32_t *realLen)
|
||||
{
|
||||
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_MP4(struct _DjiMediaFile *mediaFileHand
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include "dji_gimbal.h"
|
||||
#include "dji_xport.h"
|
||||
#include "gimbal_emu/test_payload_gimbal_emu.h"
|
||||
#include <widget_interaction_test/test_widget_interaction.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define PAYLOAD_CAMERA_EMU_TASK_FREQ (100)
|
||||
@ -118,6 +119,7 @@ static T_TestCameraGimbalRotationArgument s_tapZoomNewestGimbalRotationArgument
|
||||
static uint32_t s_tapZoomNewestTargetHybridFocalLength = 0; // unit: 0.1mm
|
||||
static T_DjiMutexHandle s_tapZoomMutex = NULL;
|
||||
static E_DjiCameraVideoStreamType s_cameraVideoStreamType;
|
||||
static uint32_t s_currentVideoRecordTimeInSeconds = 0;
|
||||
|
||||
static int sockfd;
|
||||
static struct sockaddr_in server;
|
||||
@ -222,6 +224,7 @@ static T_DjiReturnCode SetMode(E_DjiCameraMode mode)
|
||||
|
||||
s_cameraState.cameraMode = mode;
|
||||
USER_LOG_INFO("set camera mode:%d", mode);
|
||||
DjiTest_WidgetLogAppend("set cam mode %d", mode);
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_commonMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -252,6 +255,7 @@ static T_DjiReturnCode StartRecordVideo(void)
|
||||
|
||||
s_cameraState.isRecording = true;
|
||||
USER_LOG_INFO("start record video");
|
||||
DjiTest_WidgetLogAppend("start record video");
|
||||
|
||||
out:
|
||||
djiStat = osalHandler->MutexUnlock(s_commonMutex);
|
||||
@ -284,6 +288,7 @@ static T_DjiReturnCode StopRecordVideo(void)
|
||||
s_cameraState.isRecording = false;
|
||||
s_cameraState.currentVideoRecordingTimeInSeconds = 0;
|
||||
USER_LOG_INFO("stop record video");
|
||||
DjiTest_WidgetLogAppend("stop record video");
|
||||
|
||||
out:
|
||||
djiStat = osalHandler->MutexUnlock(s_commonMutex);
|
||||
@ -307,6 +312,7 @@ static T_DjiReturnCode StartShootPhoto(void)
|
||||
}
|
||||
|
||||
USER_LOG_INFO("start shoot photo");
|
||||
DjiTest_WidgetLogAppend("start shoot photo");
|
||||
s_cameraState.isStoring = true;
|
||||
|
||||
if (s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_SINGLE) {
|
||||
@ -317,6 +323,7 @@ static T_DjiReturnCode StartShootPhoto(void)
|
||||
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_INTERVAL_PHOTO;
|
||||
s_cameraState.isShootingIntervalStart = true;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInMs = s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds;
|
||||
}
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_commonMutex);
|
||||
@ -340,6 +347,7 @@ static T_DjiReturnCode StopShootPhoto(void)
|
||||
}
|
||||
|
||||
USER_LOG_INFO("stop shoot photo");
|
||||
DjiTest_WidgetLogAppend("stop shoot photo");
|
||||
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_PHOTO_IDLE;
|
||||
s_cameraState.isStoring = false;
|
||||
s_cameraState.isShootingIntervalStart = false;
|
||||
@ -456,8 +464,9 @@ static T_DjiReturnCode SetPhotoTimeIntervalSettings(T_DjiCameraPhotoTimeInterval
|
||||
|
||||
s_cameraPhotoTimeIntervalSettings.captureCount = settings.captureCount;
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds = settings.timeIntervalSeconds;
|
||||
USER_LOG_INFO("set photo interval settings count:%d seconds:%d", settings.captureCount,
|
||||
settings.timeIntervalSeconds);
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds = settings.timeIntervalMilliseconds;
|
||||
USER_LOG_INFO("set photo interval settings count:%d seconds:%d.%d", settings.captureCount,
|
||||
settings.timeIntervalSeconds, settings.timeIntervalMilliseconds / 100);
|
||||
s_cameraState.currentPhotoShootingIntervalCount = settings.captureCount;
|
||||
|
||||
returnCode = osalHandler->MutexUnlock(s_commonMutex);
|
||||
@ -929,6 +938,8 @@ static T_DjiReturnCode DjiTest_CameraRotationGimbal(T_TestCameraGimbalRotationAr
|
||||
}
|
||||
|
||||
if (aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
|
||||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
|
||||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE ||
|
||||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
|
||||
returnCode = DjiTest_GimbalRotate(gimbalRotationArgument.rotationMode, gimbalRotationArgument.rotationProperty,
|
||||
gimbalRotationArgument.rotationValue);
|
||||
@ -967,6 +978,7 @@ static void *UserCamera_Task(void *arg)
|
||||
uint32_t currentTime = 0;
|
||||
bool isStartIntervalPhotoAction = false;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint32_t intervalFreq = 10;
|
||||
|
||||
USER_UTIL_UNUSED(arg);
|
||||
|
||||
@ -1164,8 +1176,7 @@ out:
|
||||
}
|
||||
}
|
||||
|
||||
// 1Hz
|
||||
if (USER_UTIL_IS_WORK_TURN(step, 1, PAYLOAD_CAMERA_EMU_TASK_FREQ)) {
|
||||
if (USER_UTIL_IS_WORK_TURN(step, intervalFreq, PAYLOAD_CAMERA_EMU_TASK_FREQ)) {
|
||||
returnCode = osalHandler->MutexLock(s_commonMutex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
|
||||
@ -1174,13 +1185,21 @@ out:
|
||||
|
||||
// 预估可拍照张数和可录像时长的功能。
|
||||
if (s_cameraState.isRecording) {
|
||||
s_cameraState.currentVideoRecordingTimeInSeconds++;
|
||||
s_cameraSDCardState.remainSpaceInMB =
|
||||
s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB;
|
||||
if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) {
|
||||
s_cameraSDCardState.remainSpaceInMB = 0;
|
||||
s_cameraSDCardState.isFull = true;
|
||||
uint16_t preTimeInSeconds = s_cameraState.currentVideoRecordingTimeInSeconds;
|
||||
|
||||
s_currentVideoRecordTimeInSeconds++;
|
||||
|
||||
s_cameraState.currentVideoRecordingTimeInSeconds = s_currentVideoRecordTimeInSeconds / intervalFreq;
|
||||
if (s_cameraState.currentVideoRecordingTimeInSeconds > preTimeInSeconds) {
|
||||
s_cameraSDCardState.remainSpaceInMB =
|
||||
s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB;
|
||||
if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) {
|
||||
s_cameraSDCardState.remainSpaceInMB = 0;
|
||||
s_cameraSDCardState.isFull = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_currentVideoRecordTimeInSeconds = 0;
|
||||
}
|
||||
|
||||
if (s_cameraState.isShootingIntervalStart == false) {
|
||||
@ -1189,10 +1208,16 @@ out:
|
||||
|
||||
if (s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_INTERVAL
|
||||
&& s_cameraState.isShootingIntervalStart == true && s_cameraPhotoTimeIntervalSettings.captureCount > 0
|
||||
&& s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds > 0) {
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInSeconds--;
|
||||
&& (s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds > 0 || s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds > 0)) {
|
||||
uint16_t currentPhotoShootingIntervalTimeInMs = s_cameraState.currentPhotoShootingIntervalTimeInSeconds * 1000 +
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInMs;
|
||||
|
||||
if ((s_cameraState.currentPhotoShootingIntervalTimeInSeconds == 0 &&
|
||||
currentPhotoShootingIntervalTimeInMs -= 1000 / intervalFreq;
|
||||
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = currentPhotoShootingIntervalTimeInMs / 1000;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInMs = currentPhotoShootingIntervalTimeInMs % 1000;
|
||||
|
||||
if ((currentPhotoShootingIntervalTimeInMs == 0 &&
|
||||
s_cameraState.currentPhotoShootingIntervalCount > 0) ||
|
||||
(s_cameraState.isShootingIntervalStart == true && isStartIntervalPhotoAction == false)) {
|
||||
|
||||
@ -1200,13 +1225,14 @@ out:
|
||||
|
||||
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_INTERVAL_PHOTO;
|
||||
s_cameraState.isStoring = true;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInSeconds
|
||||
= s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
|
||||
s_cameraState.currentPhotoShootingIntervalTimeInMs = s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds;
|
||||
if (s_cameraState.currentPhotoShootingIntervalCount < INTERVAL_PHOTOGRAPH_ALWAYS_COUNT) {
|
||||
USER_LOG_INFO("interval taking photograph count:%d interval_time:%ds",
|
||||
USER_LOG_INFO("interval taking photograph count:%d interval_time:%d.%ds",
|
||||
(s_cameraPhotoTimeIntervalSettings.captureCount -
|
||||
s_cameraState.currentPhotoShootingIntervalCount + 1),
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds);
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
|
||||
s_cameraState.currentPhotoShootingIntervalCount--;
|
||||
if (s_cameraState.currentPhotoShootingIntervalCount == 0) {
|
||||
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_PHOTO_IDLE;
|
||||
@ -1214,8 +1240,9 @@ out:
|
||||
s_cameraState.isShootingIntervalStart = false;
|
||||
}
|
||||
} else {
|
||||
USER_LOG_INFO("interval taking photograph always, interval_time:%ds",
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds);
|
||||
USER_LOG_INFO("interval taking photograph always, interval_time:%d.%ds",
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
|
||||
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
|
||||
s_cameraState.currentPhotoShootingIntervalCount--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include "dji_logger.h"
|
||||
@ -132,6 +133,7 @@ static T_DjiPlaybackInfo s_playbackInfo = {0};//非常重要的变量!!!!!!!!!!!
|
||||
static T_DjiTaskHandle s_userSendVideoThread;
|
||||
static T_UtilBuffer s_mediaPlayCommandBufferHandler = {0};//非常重要的变量,用户自定义功能读取此变量中的命令执行相应的操作!!!!!!!!!!!!!!!!!!!
|
||||
static T_DjiMutexHandle s_mediaPlayCommandBufferMutex = {0};
|
||||
static T_DjiSemaHandle s_mediaPlayWorkSem = NULL;
|
||||
static uint8_t s_mediaPlayCommandBuffer[sizeof(T_TestPayloadCameraPlaybackCommand) * 32] = {0};
|
||||
static const char *s_frameKeyChar = "[PACKET]";
|
||||
static const char *s_frameDurationTimeKeyChar = "duration_time";
|
||||
@ -190,6 +192,11 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
|
||||
s_psdkCameraMedia.StartDownloadNotification = StartDownloadNotification;
|
||||
s_psdkCameraMedia.StopDownloadNotification = StopDownloadNotification;
|
||||
|
||||
if (DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreCreate(0, &s_mediaPlayWorkSem)) {
|
||||
USER_LOG_ERROR("SemaphoreCreate(\"%s\") error.", "s_mediaPlayWorkSem");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (osalHandler->MutexCreate(&s_mediaPlayCommandBufferMutex) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("mutex create error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
@ -199,7 +206,8 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
|
||||
|
||||
// 注册相机类负载设备的下载回放功能
|
||||
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK ||
|
||||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK) {
|
||||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK ||
|
||||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M400) {
|
||||
returnCode = DjiPayloadCamera_RegMediaDownloadPlaybackHandler(&s_psdkCameraMedia);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk camera media function init error.");
|
||||
@ -327,6 +335,7 @@ static T_DjiReturnCode DjiPlayback_PausePlay(T_DjiPlaybackInfo *playbackInfo)
|
||||
USER_LOG_ERROR("mutex unlock error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
|
||||
}
|
||||
|
||||
playbackInfo->isInPlayProcess = 0;
|
||||
@ -511,7 +520,7 @@ static T_DjiReturnCode DjiPlayback_StartPlayProcess(const char *filePath, uint32
|
||||
USER_LOG_ERROR("mutex unlock error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
@ -540,7 +549,7 @@ static T_DjiReturnCode DjiPlayback_StopPlayProcess(void)
|
||||
USER_LOG_ERROR("mutex unlock error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
@ -751,7 +760,7 @@ static T_DjiReturnCode DjiPlayback_GetFrameRateOfVideoFile(const char *path, flo
|
||||
|
||||
ret = fscanf(fpCommand, "r_frame_rate=%d/%d", &frameRateMolecule, &frameRateDenominator);
|
||||
if (ret <= 0) {
|
||||
USER_LOG_ERROR("can not find frame rate.");
|
||||
USER_LOG_ERROR("can not find frame rate form \"%s\".", path);
|
||||
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND;
|
||||
goto out;
|
||||
}
|
||||
@ -802,7 +811,7 @@ static T_DjiReturnCode GetMediaFileDir(char *dirPath)
|
||||
static T_DjiReturnCode GetMediaFileOriginData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
uint16_t realLen = 0;
|
||||
uint32_t realLen = 0;
|
||||
T_DjiMediaFileHandle mediaFileHandle;
|
||||
|
||||
returnCode = DjiMediaFile_CreateHandle(filePath, &mediaFileHandle);
|
||||
@ -1198,6 +1207,9 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
char *videoFilePath = NULL;
|
||||
char *transcodedFilePath = NULL;//转换视频编码后的文件路径
|
||||
float frameRate = 1.0f;
|
||||
uint32_t waitDuration = 1000 / SEND_VIDEO_TASK_FREQ;
|
||||
uint32_t rightNow = 0;
|
||||
uint32_t sendExpect = 0;
|
||||
T_TestPayloadCameraVideoFrameInfo *frameInfo = NULL;//时长,大小,此帧在文件中的位置
|
||||
uint32_t frameNumber = 0;
|
||||
uint32_t frameCount = 0;
|
||||
@ -1221,7 +1233,7 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
exit(1);
|
||||
}
|
||||
if (s_isMediaFileDirPathConfigured == true) {
|
||||
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%sPSDK_0005.h264", s_mediaFileDirPath);
|
||||
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file/PSDK_0005.h264", s_mediaFileDirPath);
|
||||
} else {
|
||||
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file/PSDK_0005.h264", curFileDirPath);
|
||||
}
|
||||
@ -1255,8 +1267,16 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
|
||||
int frameNumberSendCounter=0;
|
||||
|
||||
(void)osalHandler->GetTimeMs(&rightNow);
|
||||
sendExpect = rightNow + waitDuration;
|
||||
while (1) {
|
||||
osalHandler->TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ);
|
||||
(void)osalHandler->GetTimeMs(&rightNow);
|
||||
if (sendExpect > rightNow) {
|
||||
waitDuration = sendExpect - rightNow;
|
||||
} else {
|
||||
waitDuration = 1000 / SEND_VIDEO_TASK_FREQ;
|
||||
}
|
||||
(void)osalHandler->SemaphoreTimedWait(s_mediaPlayWorkSem, waitDuration);
|
||||
|
||||
// response playback command
|
||||
if (osalHandler->MutexLock(s_mediaPlayCommandBufferMutex) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -1335,13 +1355,13 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
|
||||
fpFile = fopen(transcodedFilePath, "rb+");//打开编码后的文件
|
||||
if (fpFile == NULL) {
|
||||
USER_LOG_ERROR("open video file fail.111111111111111111111111");
|
||||
USER_LOG_ERROR("open video file:\"%s\" fail:%d.", transcodedFilePath, errno);
|
||||
continue;
|
||||
}
|
||||
|
||||
send:
|
||||
if (fpFile == NULL) {
|
||||
USER_LOG_ERROR("open video file fail.222222222222222222222222222");
|
||||
USER_LOG_ERROR("open video file fail.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1363,16 +1383,10 @@ send:
|
||||
continue;
|
||||
}
|
||||
|
||||
//????????????????????????????????
|
||||
if (!USER_UTIL_IS_WORK_TURN(sendVideoStep++, frameRate, SEND_VIDEO_TASK_FREQ))
|
||||
continue;
|
||||
|
||||
|
||||
//3. 解析视频流文件
|
||||
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||
frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样
|
||||
printf("第 %d 帧大小:%d\n", frameNumberSendCounter, frameBufSize);
|
||||
frameNumberSendCounter++;
|
||||
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
||||
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
|
||||
}
|
||||
@ -1406,7 +1420,7 @@ send:
|
||||
|
||||
// for(int i=0;i<dataLength - VIDEO_FRAME_AUD_LEN;i++)
|
||||
// {
|
||||
//// printf("%c",data[i]);
|
||||
// //printf("%c",data[i]);
|
||||
// printf("%02X ",dataBuffer[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
@ -1423,6 +1437,9 @@ send:
|
||||
lengthOfDataHaveBeenSent += lengthOfDataToBeSent;
|
||||
}
|
||||
|
||||
(void)osalHandler->GetTimeMs(&sendExpect);
|
||||
sendExpect += (1000 / frameRate);
|
||||
|
||||
if ((frameNumber++) >= frameCount) {
|
||||
USER_LOG_DEBUG("reach file tail.");
|
||||
frameNumber = 0;
|
||||
@ -1436,10 +1453,10 @@ send:
|
||||
returnCode = DjiPayloadCamera_GetVideoStreamState(&videoStreamState);
|
||||
if (returnCode == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_DEBUG(
|
||||
"video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.",
|
||||
videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController,
|
||||
videoStreamState.realtimeBandwidthAfterFlowController,
|
||||
videoStreamState.busyState);
|
||||
"video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.",
|
||||
videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController,
|
||||
videoStreamState.realtimeBandwidthAfterFlowController,
|
||||
videoStreamState.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get video stream state error.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user