NEW: release DJI Payload-SDK version 3.0
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
@ -0,0 +1,262 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_core.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include <dji_logger.h>
|
||||
|
||||
#include "dji_media_file_core.h"
|
||||
#include "dji_media_file_jpg.h"
|
||||
#include "dji_media_file_mp4.h"
|
||||
#include "dji_platform.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
|
||||
/* Private values ------------------------------------------------------------*/
|
||||
//@formatter:off
|
||||
static const T_DjiMediaFileOptItem s_mediaFileOpt[] =
|
||||
{
|
||||
//JPEG File Operation Item
|
||||
{
|
||||
DJI_CAMERA_FILE_TYPE_JPEG ,
|
||||
DjiMediaFile_IsSupported_JPG,
|
||||
DjiMediaFile_GetAttrFunc_JPG,
|
||||
DjiMediaFile_GetDataOrigin_JPG,
|
||||
DjiMediaFile_GetFileSizeOrigin_JPG,
|
||||
DjiMediaFile_CreateThumbNail_JPG,
|
||||
DjiMediaFile_GetFileSizeThumbNail_JPG,
|
||||
DjiMediaFile_GetDataThumbNail_JPG,
|
||||
DjiMediaFile_DestroyThumbNail_JPG,
|
||||
DjiMediaFile_CreateScreenNail_JPG,
|
||||
DjiMediaFile_GetFileSizeScreenNail_JPG,
|
||||
DjiMediaFile_GetDataScreenNail_JPG,
|
||||
DjiMediaFile_DestroyScreenNail_JPG,
|
||||
},
|
||||
//MP4 File Operation Item
|
||||
{
|
||||
DJI_CAMERA_FILE_TYPE_MP4 ,
|
||||
DjiMediaFile_IsSupported_MP4,
|
||||
DjiMediaFile_GetAttrFunc_MP4,
|
||||
DjiMediaFile_GetDataOrigin_MP4,
|
||||
DjiMediaFile_GetFileSizeOrigin_MP4,
|
||||
DjiMediaFile_CreateThumbNail_MP4,
|
||||
DjiMediaFile_GetFileSizeThumbNail_MP4,
|
||||
DjiMediaFile_GetDataThumbNail_MP4,
|
||||
DjiMediaFile_DestroyThumbNail_MP4,
|
||||
DjiMediaFile_CreateScreenNail_MP4,
|
||||
DjiMediaFile_GetFileSizeScreenNail_MP4,
|
||||
DjiMediaFile_GetDataScreenNail_MP4,
|
||||
DjiMediaFile_DestroyScreenNail_MP4,
|
||||
},
|
||||
};
|
||||
static const uint32_t s_mediaFileOptCount = sizeof (s_mediaFileOpt) / sizeof(T_DjiMediaFileOptItem);
|
||||
//@formatter:on
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported(const char *filePath)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < s_mediaFileOptCount; i++) {
|
||||
if (s_mediaFileOpt[i].isSupportedFunc(filePath) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateHandle(const char *filePath, T_DjiMediaFileHandle *pMediaFileHandle)
|
||||
{
|
||||
int optIndex;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
for (optIndex = 0; optIndex < s_mediaFileOptCount; optIndex++) {
|
||||
if (s_mediaFileOpt[optIndex].isSupportedFunc(filePath) == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optIndex == s_mediaFileOptCount) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*pMediaFileHandle = osalHandler->Malloc(sizeof(T_DjiMediaFile));
|
||||
if (*pMediaFileHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
(*pMediaFileHandle)->filePath = osalHandler->Malloc(strlen(filePath) + 1);
|
||||
if ((*pMediaFileHandle)->filePath == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
(*pMediaFileHandle)->mediaFileOptItem = s_mediaFileOpt[optIndex];
|
||||
(*pMediaFileHandle)->mediaFileThm.privThm = NULL;
|
||||
(*pMediaFileHandle)->mediaFileScr.privScr = NULL;
|
||||
|
||||
strcpy((*pMediaFileHandle)->filePath, filePath);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyHandle(T_DjiMediaFileHandle mediaFileHandle)
|
||||
{
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
osalHandler->Free(mediaFileHandle->filePath);
|
||||
osalHandler->Free(mediaFileHandle);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetMediaFileType(T_DjiMediaFileHandle mediaFileHandle,
|
||||
E_DjiCameraMediaFileType *mediaFileType)
|
||||
{
|
||||
*mediaFileType = mediaFileHandle->mediaFileOptItem.mediaFileType;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getAttrFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getAttrFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getAttrFunc(mediaFileHandle, mediaFileAttr);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getDataOrgFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getDataOrgFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getDataOrgFunc(mediaFileHandle, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getFileSizeOrgFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getFileSizeOrgFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getFileSizeOrgFunc(mediaFileHandle, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThm(T_DjiMediaFileHandle mediaFileHandle)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.createThmFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle createThmFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.createThmFunc(mediaFileHandle);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThm(T_DjiMediaFileHandle mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getFileSizeThmFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getFileSizeThmFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getFileSizeThmFunc(mediaFileHandle, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataThm(T_DjiMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getDataThmFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getDataThmFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getDataThmFunc(mediaFileHandle, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestoryThm(T_DjiMediaFileHandle mediaFileHandle)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.destroyThmFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle destroyThmFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.destroyThmFunc(mediaFileHandle);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScr(T_DjiMediaFileHandle mediaFileHandle)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.creatScrFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle creatScrFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.creatScrFunc(mediaFileHandle);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScr(T_DjiMediaFileHandle mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getFileSizeScrFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getFileSizeScrFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getFileSizeScrFunc(mediaFileHandle, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataScr(T_DjiMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getDataScrFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getDataScrFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.getDataScrFunc(mediaFileHandle, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScr(T_DjiMediaFileHandle mediaFileHandle)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.destroyScrFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle destroyScrFunc null error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return mediaFileHandle->mediaFileOptItem.destroyScrFunc(mediaFileHandle);
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
@ -0,0 +1,115 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_core.h
|
||||
* @brief This is the header file for "dji_media_file_core.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PSDK_MEDIA_FILE_CORE_H
|
||||
#define PSDK_MEDIA_FILE_CORE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <dji_typedef.h>
|
||||
#include <dji_payload_camera.h>
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define PSDK_MEDIA_FILE_PATH_LEN_MAX 512 /*max file path len */
|
||||
#define PSDK_MEDIA_DIR_PATH_LEN_MAX 256 /*max dir path len */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
void *privThm;
|
||||
} T_DjiMediaFileThm;
|
||||
|
||||
typedef struct {
|
||||
void *privScr;
|
||||
} T_DjiMediaFileScr;
|
||||
|
||||
struct _DjiMediaFile;
|
||||
|
||||
typedef struct {
|
||||
E_DjiCameraMediaFileType mediaFileType;
|
||||
bool (*isSupportedFunc)(const char *filePath);
|
||||
|
||||
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);
|
||||
T_DjiReturnCode (*getFileSizeOrgFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode (*createThmFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode (*getFileSizeThmFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode (*getDataThmFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode (*destroyThmFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
T_DjiReturnCode (*creatScrFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode (*getFileSizeScrFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode (*getDataScrFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode (*destroyScrFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
} T_DjiMediaFileOptItem;
|
||||
|
||||
typedef struct _DjiMediaFile {
|
||||
char *filePath;
|
||||
T_DjiMediaFileOptItem mediaFileOptItem;
|
||||
T_DjiMediaFileThm mediaFileThm;
|
||||
T_DjiMediaFileScr mediaFileScr;
|
||||
} T_DjiMediaFile, *T_DjiMediaFileHandle;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported(const char *filePath);
|
||||
T_DjiReturnCode DjiMediaFile_CreateHandle(const char *filePath, T_DjiMediaFileHandle *pMediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyHandle(T_DjiMediaFileHandle mediaFileHandle);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetMediaFileType(T_DjiMediaFileHandle mediaFileHandle,
|
||||
E_DjiCameraMediaFileType *mediaFileType);
|
||||
T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThm(T_DjiMediaFileHandle mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThm(T_DjiMediaFileHandle mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode DjiMediaFile_GetDataThm(T_DjiMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestoryThm(T_DjiMediaFileHandle mediaFileHandle);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScr(T_DjiMediaFileHandle mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScr(T_DjiMediaFileHandle mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode DjiMediaFile_GetDataScr(T_DjiMediaFileHandle mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScr(T_DjiMediaFileHandle mediaFileHandle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PSDK_MEDIA_FILE_CORE_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
@ -0,0 +1,228 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_jpg.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_media_file_jpg.h"
|
||||
#include "dji_media_file_core.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <dji_logger.h>
|
||||
#include <utils/util_misc.h>
|
||||
#include "dji_platform.h"
|
||||
#include "utils/util_time.h"
|
||||
#include "utils/util_file.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define JPG_FILE_SUFFIX ".jpg"
|
||||
#define JPG_TEMP_FILE_TEMPLATE_STR "JPG_TEMP_XXXXXX.jpg"
|
||||
#define JPG_TEMP_FILE_PATH_MAX_LEN 50
|
||||
#define FFMPEG_CMD_BUF_SIZE 1024
|
||||
|
||||
#define JPG_THM_SCALE_CFG_STR "scale=100:-1"
|
||||
#define JPG_SCR_SCALE_CFG_STR "scale=600:-1"
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
FILE *tempFile;
|
||||
char tempfilePath[JPG_TEMP_FILE_PATH_MAX_LEN];
|
||||
} T_DjiJPGTempFilePriv;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiMediaFile_CreateTempFilePriv_JPG(const char *srcFilePath, const char *scaleCfgStr,
|
||||
T_DjiJPGTempFilePriv **pTempFilePrivHandle);
|
||||
static T_DjiReturnCode DjiMediaFile_DestroyTempFilePriv_JPG(T_DjiJPGTempFilePriv *tempFilePrivHandle);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported_JPG(const char *filePath)
|
||||
{
|
||||
if (filePath == NULL) {
|
||||
USER_LOG_ERROR("input parameter is null error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(&filePath[strlen(filePath) - 4], JPG_FILE_SUFFIX) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr)
|
||||
{
|
||||
USER_UTIL_UNUSED(mediaFileHandle);
|
||||
|
||||
mediaFileAttr->attrVideoDuration = 0;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
return UtilFile_GetFileSizeByPath(mediaFileHandle->filePath, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_CreateTempFilePriv_JPG(mediaFileHandle->filePath, JPG_THM_SCALE_CFG_STR,
|
||||
(T_DjiJPGTempFilePriv **) &mediaFileHandle->mediaFileThm.privThm);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
T_DjiJPGTempFilePriv *jpgFileThmPriv = (T_DjiJPGTempFilePriv *) mediaFileHandle->mediaFileThm.privThm;
|
||||
|
||||
return UtilFile_GetFileSize(jpgFileThmPriv->tempFile, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
T_DjiJPGTempFilePriv *jpgFileThmPriv = (T_DjiJPGTempFilePriv *) mediaFileHandle->mediaFileThm.privThm;
|
||||
|
||||
return UtilFile_GetFileData(jpgFileThmPriv->tempFile, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_DestroyTempFilePriv_JPG(mediaFileHandle->mediaFileThm.privThm);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_CreateTempFilePriv_JPG(mediaFileHandle->filePath, JPG_SCR_SCALE_CFG_STR,
|
||||
(T_DjiJPGTempFilePriv **) &mediaFileHandle->mediaFileScr.privScr);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
T_DjiJPGTempFilePriv *jpgFileScrPriv = (T_DjiJPGTempFilePriv *) mediaFileHandle->mediaFileScr.privScr;
|
||||
|
||||
return UtilFile_GetFileSize(jpgFileScrPriv->tempFile, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
T_DjiJPGTempFilePriv *jpgFileScrPriv = (T_DjiJPGTempFilePriv *) mediaFileHandle->mediaFileScr.privScr;
|
||||
|
||||
return UtilFile_GetFileData(jpgFileScrPriv->tempFile, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_DestroyTempFilePriv_JPG(mediaFileHandle->mediaFileScr.privScr);
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiMediaFile_CreateTempFilePriv_JPG(const char *srcFilePath, const char *scaleCfgStr,
|
||||
T_DjiJPGTempFilePriv **pTempFilePrivHandle)
|
||||
{
|
||||
char ffmpeg_cmd[FFMPEG_CMD_BUF_SIZE];
|
||||
int cmdRet;
|
||||
T_DjiRunTimeStamps tiStart, tiEnd;
|
||||
T_DjiJPGTempFilePriv *jpgTempFilePriv;
|
||||
T_DjiReturnCode psdkStat;
|
||||
int tempFd;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
tiStart = DjiUtilTime_GetRunTimeStamps();
|
||||
|
||||
*pTempFilePrivHandle = osalHandler->Malloc(sizeof(T_DjiJPGTempFilePriv));
|
||||
if (*pTempFilePrivHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
jpgTempFilePriv = *pTempFilePrivHandle;
|
||||
|
||||
//get temp file name
|
||||
strcpy(jpgTempFilePriv->tempfilePath, JPG_TEMP_FILE_TEMPLATE_STR);
|
||||
tempFd = mkstemps(jpgTempFilePriv->tempfilePath, strlen(JPG_FILE_SUFFIX));
|
||||
if (tempFd < 0) {
|
||||
USER_LOG_ERROR("JPG Create Temp File Error, tempFd = %d\n", tempFd);
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_create_temp;
|
||||
}
|
||||
close(tempFd);
|
||||
unlink(jpgTempFilePriv->tempfilePath);
|
||||
|
||||
//ffmpeg cmd send
|
||||
snprintf(ffmpeg_cmd, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" -vf %s %s 1>/dev/null 2>&1",
|
||||
srcFilePath, scaleCfgStr, jpgTempFilePriv->tempfilePath);
|
||||
|
||||
cmdRet = system(ffmpeg_cmd);
|
||||
|
||||
tiEnd = DjiUtilTime_GetRunTimeStamps();
|
||||
|
||||
USER_LOG_DEBUG("JPG Create TempFile, RealTime = %ld us\n", tiEnd.realUsec - tiStart.realUsec);
|
||||
|
||||
if (cmdRet != 0) {
|
||||
USER_LOG_ERROR("JPG ffmpeg cmd call error, ret = %d\n", cmdRet);
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_system_cmd;
|
||||
}
|
||||
|
||||
//open temp file
|
||||
jpgTempFilePriv->tempFile = fopen(jpgTempFilePriv->tempfilePath, "rb+");
|
||||
if (jpgTempFilePriv->tempFile == NULL) {
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_file_open;
|
||||
}
|
||||
|
||||
//unlink temp file
|
||||
unlink(jpgTempFilePriv->tempfilePath);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
|
||||
err_file_open:
|
||||
unlink(jpgTempFilePriv->tempfilePath);
|
||||
err_system_cmd:
|
||||
err_create_temp:
|
||||
osalHandler->Free(*pTempFilePrivHandle);
|
||||
|
||||
return psdkStat;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiMediaFile_DestroyTempFilePriv_JPG(T_DjiJPGTempFilePriv *tempFilePrivHandle)
|
||||
{
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
fclose(tempFilePrivHandle->tempFile);
|
||||
osalHandler->Free(tempFilePrivHandle);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_jpg.h
|
||||
* @brief This is the header file for "dji_media_file_jpg.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PSDK_MEDIA_FILE_JPG_H
|
||||
#define PSDK_MEDIA_FILE_JPG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <dji_payload_camera.h>
|
||||
#include <dji_typedef.h>
|
||||
#include "dji_media_file_core.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported_JPG(const char *filePath);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScreenNail_JPG(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PSDK_MEIDA_FILE_JPG_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
@ -0,0 +1,262 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_mp4.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_media_file_mp4.h"
|
||||
#include "dji_media_file_core.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <dji_logger.h>
|
||||
#include <stdlib.h>
|
||||
#include "dji_platform.h"
|
||||
#include "utils/util_time.h"
|
||||
#include "utils/util_file.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
#define MP4_FILE_SUFFIX ".mp4"
|
||||
#define MP4_TEMP_FILE_TEMPLATE_STR "MP4_TEMP_XXXXXX.jpg"
|
||||
#define MP4_TEMP_FILE_PATH_MAX_LEN 50
|
||||
#define FFMPEG_CMD_BUF_SIZE (256 + 256)
|
||||
|
||||
#define MP4_THM_SCALE_CFG_STR "scale=100:-1"
|
||||
#define MP4_SCR_SCALE_CFG_STR "scale=600:-1"
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
FILE *tempFile;
|
||||
char tempfilePath[MP4_TEMP_FILE_PATH_MAX_LEN];
|
||||
} T_DjiMP4TempPicPriv;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiMediaFile_CreateTempPicPriv_MP4(const char *srcFilePath, const char *scaleCfgStr,
|
||||
T_DjiMP4TempPicPriv **pTempPicPrivHandle);
|
||||
static T_DjiReturnCode DjiMediaFile_DestroyTempPicPriv_MP4(T_DjiMP4TempPicPriv *tempPicPrivHandle);
|
||||
|
||||
/* Private values ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported_MP4(const char *filePath)
|
||||
{
|
||||
if (filePath == NULL) {
|
||||
USER_LOG_ERROR("input parameter is null error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(&filePath[strlen(filePath) - 4], MP4_FILE_SUFFIX) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetAttrFunc_MP4(struct _DjiMediaFile *mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr)
|
||||
{
|
||||
FILE *fp;
|
||||
char ffmpegCmdStr[FFMPEG_CMD_BUF_SIZE];
|
||||
float hour, minute, second;
|
||||
char tempTailStr[128];
|
||||
int ret;
|
||||
T_DjiReturnCode psdkStat;
|
||||
|
||||
snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" 2>&1 | grep \"Duration\"", mediaFileHandle->filePath);
|
||||
fp = popen(ffmpegCmdStr, "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
ret = fscanf(fp, " Duration: %f:%f:%f,%127s", &hour, &minute, &second, tempTailStr);
|
||||
if (ret <= 0) {
|
||||
USER_LOG_ERROR("MP4 File Get Duration Error\n");
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
mediaFileAttr->attrVideoDuration = (uint32_t) (hour * 3600 + minute * 60 + second + 0.5);
|
||||
|
||||
/*! The user needs to obtain the frame rate and resolution of the video file by ffmpeg tools.
|
||||
* Also the frame rate and resolution of video need convert to enum E_DjiCameraVideoFrameRate or
|
||||
* E_DjiCameraVideoResolution.
|
||||
*/
|
||||
mediaFileAttr->attrVideoFrameRate = DJI_CAMERA_VIDEO_FRAME_RATE_30_FPS;
|
||||
mediaFileAttr->attrVideoResolution = DJI_CAMERA_VIDEO_RESOLUTION_1920x1080;
|
||||
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
|
||||
out:
|
||||
pclose(fp);
|
||||
|
||||
return psdkStat;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
return UtilFile_GetFileSizeByPath(mediaFileHandle->filePath, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
|
||||
return DjiMediaFile_CreateTempPicPriv_MP4(mediaFileHandle->filePath, MP4_THM_SCALE_CFG_STR,
|
||||
(T_DjiMP4TempPicPriv **) &mediaFileHandle->mediaFileThm.privThm);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
T_DjiMP4TempPicPriv *jpgFileThmPriv = (T_DjiMP4TempPicPriv *) mediaFileHandle->mediaFileThm.privThm;
|
||||
|
||||
return UtilFile_GetFileSize(jpgFileThmPriv->tempFile, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
T_DjiMP4TempPicPriv *jpgFileThmPriv = (T_DjiMP4TempPicPriv *) mediaFileHandle->mediaFileThm.privThm;
|
||||
|
||||
return UtilFile_GetFileData(jpgFileThmPriv->tempFile, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyThumbNail_MP4(struct _DjiMediaFile *MediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_DestroyTempPicPriv_MP4(MediaFileHandle->mediaFileThm.privThm);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_CreateTempPicPriv_MP4(mediaFileHandle->filePath, MP4_SCR_SCALE_CFG_STR,
|
||||
(T_DjiMP4TempPicPriv **) &mediaFileHandle->mediaFileScr.privScr);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize)
|
||||
{
|
||||
T_DjiMP4TempPicPriv *jpgFileScrPriv = (T_DjiMP4TempPicPriv *) mediaFileHandle->mediaFileScr.privScr;
|
||||
|
||||
return UtilFile_GetFileSize(jpgFileScrPriv->tempFile, fileSize);
|
||||
}
|
||||
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
{
|
||||
T_DjiMP4TempPicPriv *jpgFileScrPriv = (T_DjiMP4TempPicPriv *) mediaFileHandle->mediaFileScr.privScr;
|
||||
|
||||
return UtilFile_GetFileData(jpgFileScrPriv->tempFile, offset, len, data, realLen);
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle)
|
||||
{
|
||||
return DjiMediaFile_DestroyTempPicPriv_MP4(mediaFileHandle->mediaFileScr.privScr);
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiMediaFile_CreateTempPicPriv_MP4(const char *srcFilePath, const char *scaleCfgStr,
|
||||
T_DjiMP4TempPicPriv **pTempPicPrivHandle)
|
||||
{
|
||||
char ffmpeg_cmd[FFMPEG_CMD_BUF_SIZE];
|
||||
int cmdRet;
|
||||
T_DjiRunTimeStamps tiStart, tiEnd;
|
||||
T_DjiMP4TempPicPriv *mp4TempPicFile;
|
||||
T_DjiReturnCode psdkStat;
|
||||
int tempFd;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
tiStart = DjiUtilTime_GetRunTimeStamps();
|
||||
|
||||
*pTempPicPrivHandle = osalHandler->Malloc(sizeof(T_DjiMP4TempPicPriv));
|
||||
if (*pTempPicPrivHandle == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
mp4TempPicFile = *pTempPicPrivHandle;
|
||||
|
||||
//get temp file name
|
||||
strcpy(mp4TempPicFile->tempfilePath, MP4_TEMP_FILE_TEMPLATE_STR);
|
||||
tempFd = mkstemps(mp4TempPicFile->tempfilePath, strlen(MP4_FILE_SUFFIX));
|
||||
if (tempFd < 0) {
|
||||
USER_LOG_ERROR("JPG Create Temp File Error, tempFd = %d\n", tempFd);
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_create_temp;
|
||||
}
|
||||
close(tempFd);
|
||||
unlink(mp4TempPicFile->tempfilePath);
|
||||
|
||||
//ffmpeg cmd send
|
||||
snprintf(ffmpeg_cmd, FFMPEG_CMD_BUF_SIZE, "ffmpeg -i \"%s\" -vf %s -ss 00:00:00 -vframes 1 %s 1>/dev/null 2>&1",
|
||||
srcFilePath, scaleCfgStr, mp4TempPicFile->tempfilePath);
|
||||
|
||||
cmdRet = system(ffmpeg_cmd);
|
||||
|
||||
tiEnd = DjiUtilTime_GetRunTimeStamps();
|
||||
|
||||
USER_LOG_DEBUG("JPG Create TempFile, RealTime = %ld us\n", tiEnd.realUsec - tiStart.realUsec);
|
||||
|
||||
if (cmdRet != 0) {
|
||||
USER_LOG_ERROR("JPG ffmpeg cmd call error, ret = %d\n", cmdRet);
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_system_cmd;
|
||||
}
|
||||
|
||||
//open temp file
|
||||
mp4TempPicFile->tempFile = fopen(mp4TempPicFile->tempfilePath, "rb+");
|
||||
if (mp4TempPicFile->tempFile == NULL) {
|
||||
psdkStat = DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
goto err_file_open;
|
||||
}
|
||||
|
||||
//unlink temp file
|
||||
unlink(mp4TempPicFile->tempfilePath);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
|
||||
err_file_open:
|
||||
unlink(mp4TempPicFile->tempfilePath);
|
||||
err_system_cmd:
|
||||
err_create_temp:
|
||||
osalHandler->Free(*pTempPicPrivHandle);
|
||||
|
||||
return psdkStat;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiMediaFile_DestroyTempPicPriv_MP4(T_DjiMP4TempPicPriv *tempPicPrivHandle)
|
||||
{
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
fclose(tempPicPrivHandle->tempFile);
|
||||
osalHandler->Free(tempPicPrivHandle);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_media_file_mp4.h
|
||||
* @brief This is the header file for "dji_media_file_mp4.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PSDK_MEDIA_FILE_MP4_H
|
||||
#define PSDK_MEDIA_FILE_MP4_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <dji_payload_camera.h>
|
||||
#include <dji_typedef.h>
|
||||
#include "dji_media_file_core.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
bool DjiMediaFile_IsSupported_MP4(const char *filePath);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetAttrFunc_MP4(struct _DjiMediaFile *mediaFileHandle,
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyThumbNail_MP4(struct _DjiMediaFile *MediaFileHandle);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
T_DjiReturnCode
|
||||
DjiMediaFile_GetDataScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_DestroyScreenNail_MP4(struct _DjiMediaFile *mediaFileHandle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PSDK_MEDIA_FILE_MP4_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 MiB |
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_payload_cam_emu_common.h
|
||||
* @brief This is the header file for "test_payload_cam_emu.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef TEST_PAYLOAD_CAM_EMU_BASE_H
|
||||
#define TEST_PAYLOAD_CAM_EMU_BASE_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
#include "dji_payload_camera.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_CameraEmuBaseStartService(void);
|
||||
T_DjiReturnCode DjiTest_CameraGetDigitalZoomFactor(dji_f32_t *factor);
|
||||
T_DjiReturnCode DjiTest_CameraGetOpticalZoomFactor(dji_f32_t *factor);
|
||||
T_DjiReturnCode DjiTest_CameraGetMode(E_DjiCameraMode *mode);
|
||||
T_DjiReturnCode DjiTest_CameraGetVideoStreamType(E_DjiCameraVideoStreamType *type);
|
||||
bool DjiTest_CameraIsInited(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_PAYLOAD_CAM_EMU_BASE_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,51 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_payload_cam_emu_media.h
|
||||
* @brief This is the header file for "test_payload_cam_media.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2021 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef TEST_PAYLOAD_CAM_EMU_MEDIA_H
|
||||
#define TEST_PAYLOAD_CAM_EMU_MEDIA_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
#include "dji_payload_camera.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void);
|
||||
T_DjiReturnCode DjiTest_CameraMediaGetFileInfo(const char *filePath, T_DjiCameraMediaFileInfo *fileInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_PAYLOAD_CAM_EMU_MEDIA_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
Reference in New Issue
Block a user