Media Playback and Download

2022-08-09
No Rating

Implement playback and download function

Developers are requested to implement functions like download the original data of media files, create/destroy thumbnails, and creating/downloading thumbnails according to the selected development platform and the actual use requirements of industrial applications, according to the T_DjiCameraMediaDownloadPlaybackHandler structure. After registering the function with the interface specified in the PSDK, the user can use DJI Pilot or the Mobile App developed based on the MSDK to load the device from the camera class developed based on the PSDK, download media files, or implement video streaming playback.

// Implement the function of obtaining media file information
s_psdkCameraMedia.GetMediaFileDir = GetMediaFileDir;
s_psdkCameraMedia.GetMediaFileOriginInfo = GetMediaFileOriginInfo;
s_psdkCameraMedia.GetMediaFileOriginData = GetMediaFileOriginData;
// Implement the function of getting the thumbnail of the media file
s_psdkCameraMedia.CreateMediaFileThumbNail = CreateMediaFileThumbNail;
s_psdkCameraMedia.GetMediaFileThumbNailInfo = GetMediaFileThumbNailInfo;
s_psdkCameraMedia.GetMediaFileThumbNailData = GetMediaFileThumbNailData;
s_psdkCameraMedia.DestroyMediaFileThumbNail = DestroyMediaFileThumbNail;
// Implement the function of getting screenshots of media files
s_psdkCameraMedia.CreateMediaFileScreenNail = CreateMediaFileScreenNail;
s_psdkCameraMedia.GetMediaFileScreenNailInfo = GetMediaFileScreenNailInfo;
s_psdkCameraMedia.GetMediaFileScreenNailData = GetMediaFileScreenNailData;
s_psdkCameraMedia.DestroyMediaFileScreenNail = DestroyMediaFileScreenNail;
// Implement the function of deleting media files
s_psdkCameraMedia.DeleteMediaFile = DeleteMediaFile;
// Implement the function of controlling the playback of media files
s_psdkCameraMedia.SetMediaPlaybackFile = SetMediaPlaybackFile;
s_psdkCameraMedia.StartMediaPlayback = StartMediaPlayback;
s_psdkCameraMedia.StopMediaPlayback = StopMediaPlayback;
s_psdkCameraMedia.PauseMediaPlayback = PauseMediaPlayback;
s_psdkCameraMedia.SeekMediaPlayback = SeekMediaPlayback;
s_psdkCameraMedia.GetMediaPlaybackStatus = GetMediaPlaybackStatus;
// Implement the function of downloading media files
s_psdkCameraMedia.StartDownloadNotification = StartDownloadNotification;
s_psdkCameraMedia.StopDownloadNotification = StopDownloadNotification;

Using the playback download function

Note

  • Please use the codec tool FFmpeg 2.8.15open in new window to operate the files in the camera-like payload and execute the corresponding codec functions. Use ffmpeg -v to view the current FFmpeg version information.
  • Only load devices developed based on Linux support the use of playback download function.

1. Configure network parameters

To ensure that users can process the media files in the camera-like payload device developed on the Linux platform, please set the network parameters of the camera-like payload device in a manual way:

  • IP address: 192.168.5.3
  • Gateway: 192.168.5.1
  • Subnet mask: 255.255.255.0

After the IP address is set, use the ping and ifconfig commands to view the network status between the camera-like payload and the drone.

Note: If you use a virtual machine to debug camera-like payload devices, please set the mode of the virtual machine's network adapter to bridge mode, and enable "Copy physical network connection state".

2. Register the function in playback download

Note: Users can register the video playback and download function according to the actual use needs.

static T_DjiReturnCode StartMediaPlayback(void)
{
T_DjiReturnCode returnCode;

USER_LOG_INFO("start media playback");
returnCode = DjiPlayback_StartPlay(&s_playbackInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("start media playback status error, stat:0x%08llX", returnCode);
return returnCode;
}

return returnCode;
}

static T_DjiReturnCode StopMediaPlayback(void)
{
T_DjiReturnCode returnCode;

USER_LOG_INFO("stop media playback");
returnCode = DjiPlayback_StopPlay(&s_playbackInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("stop media playback error, stat:0x%08llX", returnCode);
return returnCode;
}

return returnCode;
}

static T_DjiReturnCode PauseMediaPlayback(void)
{
T_DjiReturnCode returnCode;

USER_LOG_INFO("pause media playback");
returnCode = DjiPlayback_PausePlay(&s_playbackInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("pause media playback error, stat:0x%08llX", returnCode);
return returnCode;
}

return returnCode;
}

static T_DjiReturnCode SeekMediaPlayback(uint32_t playbackPosition)
{
T_DjiReturnCode returnCode;

USER_LOG_INFO("seek media playback:%d", playbackPosition);
returnCode = DjiPlayback_SeekPlay(&s_playbackInfo, playbackPosition);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("seek media playback error, stat:0x%08llX", returnCode);
return returnCode;
}

return returnCode;
}

Get file list

1. Get the path of the media file

The camera-like payload device developed with PSDK obtains the address of the file specified by the user through the GetMediaFileDir interface, and the user can obtain the path of the specified media file by using DJI Pilot and the Mobile App developed based on MSDK.

Note: The default path of media files is camera_media_emu/media_file, users can change the path of media files according to actual needs.

static T_DjiReturnCode GetMediaFileDir(char *dirPath)
{
T_DjiReturnCode returnCode;
char curFileDirPath[DJI_FILE_PATH_SIZE_MAX];
char tempPath[DJI_FILE_PATH_SIZE_MAX];

returnCode = DjiUserUtil_GetCurrentFileDirPath(__FILE__, DJI_FILE_PATH_SIZE_MAX, curFileDirPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", returnCode);
return returnCode;
}

snprintf(dirPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file", curFileDirPath);

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

2. Get a list of media files

After specifying the path where the media file is located, the Mobile App developed based on MSDK will send the command to obtain the file information to the camera-like payload device.

  • The load device developed based on PSDK can obtain the information of media files in the load device, such as file name, path and size, by calling the interface in PSDK to obtain media file information.
  • The camera class load device can obtain the length, frame rate and resolution of the media file through the FFmpeg command.
T_DjiReturnCode DjiTest_CameraMediaGetFileInfo(const char *filePath, T_DjiCameraMediaFileInfo *fileInfo)
{
T_DjiReturnCode returnCode;
T_DjiMediaFileHandle mediaFileHandle;

returnCode = DjiMediaFile_CreateHandle(filePath, &mediaFileHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create handle error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetMediaFileType(mediaFileHandle, &fileInfo->type);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get type error stat:0x%08llX", returnCode);
goto out;
}

returnCode = DjiMediaFile_GetMediaFileAttr(mediaFileHandle, &fileInfo->mediaFileAttr);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get attr error stat:0x%08llX", returnCode);
goto out;
}

returnCode = DjiMediaFile_GetFileSizeOrg(mediaFileHandle, &fileInfo->fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get size error stat:0x%08llX", returnCode);
goto out;
}

out:
returnCode = DjiMediaFile_DestroyHandle(mediaFileHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file destroy handle error stat:0x%08llX", returnCode);
return returnCode;
}

return returnCode;
}

3. Get the raw data of the media file

The camera-like payload device developed with PSDK can obtain the original data of the media file on the payload device through the GetMediaFileOriginData interface. Users can use DJI Pilot and the Mobile App developed based on MSDK to obtain the path of the specified media file.

static T_DjiReturnCode GetMediaFileOriginData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data)
{
T_DjiReturnCode returnCode;
uint16_t realLen = 0;
T_DjiMediaFileHandle mediaFileHandle;

returnCode = DjiMediaFile_CreateHandle(filePath, &mediaFileHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create handle error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetDataOrg(mediaFileHandle, offset, length, data, &realLen);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get data error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_DestroyHandle(mediaFileHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file destroy handle error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

Description

  • The function of getting the list of media files can only get the original files and thumbnails of the media files.
  • After realizing the function of obtaining the list of media files, the user can obtain the screenshot of the specified file.
  • The user can get the original file of the specified media file through the download function.

Create Thumbnails

1. Get the path of the specified object and create a thumbnail

The camera-like payload device developed with PSDK obtains the path of the media file specified by the user and creates a thumbnail through the CreateMediaFileThumbNail interface. The user can use DJI Pilot and the Mobile App developed based on MSDK to send the payload device to create a thumbnail of the specified media file. The command.

static T_DjiReturnCode CreateMediaFileThumbNail(const char *filePath)
{
T_DjiReturnCode returnCode;

returnCode = DjiMediaFile_CreateHandle(filePath, &s_mediaFileThumbNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create handle error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_CreateThm(s_mediaFileThumbNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create thumb nail error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

2. Get the information of the thumbnail

with PSDK can obtain the thumbnail information of the specified media file through the GetMediaFileThumbNailInfo interface. Users can use DJI Pilot and the Mobile App developed based on MSDK to send a command to the payload device to obtain the thumbnail information of the specified media file.

static T_DjiReturnCode GetMediaFileThumbNailInfo(const char *filePath, T_DjiCameraMediaFileInfo *fileInfo)
{
T_DjiReturnCode returnCode;

USER_UTIL_UNUSED(filePath);

if (s_mediaFileThumbNailHandle == NULL) {
USER_LOG_ERROR("Media file thumb nail handle null error");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}

returnCode = DjiMediaFile_GetMediaFileType(s_mediaFileThumbNailHandle, &fileInfo->type);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get type error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetMediaFileAttr(s_mediaFileThumbNailHandle, &fileInfo->mediaFileAttr);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get attr error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetFileSizeThm(s_mediaFileThumbNailHandle, &fileInfo->fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get size error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}0

3. Get Thumbnails

The camera payload device developed with PSDK can obtain the thumbnail of the specified media file through the GetMediaFileThumbNailData interface. The user can use DJI Pilot and the Mobile App developed based on MSDK to send the payload device the command to get the thumbnail of the specified media file, and Get the specified thumbnail.

static T_DjiReturnCode GetMediaFileThumbNailData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data)
{
T_DjiReturnCode returnCode;
uint16_t realLen = 0;

USER_UTIL_UNUSED(filePath);

if (s_mediaFileThumbNailHandle == NULL) {
USER_LOG_ERROR("Media file thumb nail handle null error");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}

returnCode = DjiMediaFile_GetDataThm(s_mediaFileThumbNailHandle, offset, length, data, &realLen);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get data error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

4. Destroy Thumbnails

The camera payload device developed with PSDK can destroy the thumbnails generated on the payload device through the DestroyMediaFileThumbNail interface. Users can use DJI Pilot and the Mobile App developed based on MSDK to send the payload device a command to delete the thumbnail of the specified media file.

Note: After DJI Pilot and the Mobile App developed based on MSDK receive the thumbnail image on the camera-like payload device, it will be cached locally in the APP.

static T_DjiReturnCode DestroyMediaFileThumbNail(const char *filePath)
{
T_DjiReturnCode returnCode;

USER_UTIL_UNUSED(filePath);

if (s_mediaFileThumbNailHandle == NULL) {
USER_LOG_ERROR("Media file thumb nail handle null error");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}

returnCode = DjiMediaFile_DestoryThm(s_mediaFileThumbNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file destroy thumb nail error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_DestroyHandle(s_mediaFileThumbNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file destroy handle error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

Create screenshot

1. Get the path of the specified object and create a screenshot

The camera-like payload device developed with PSDK can obtain the path of the media file specified by the user and create a screenshot through the CreateMediaFileScreenNail interface. The user can use DJI Pilot and the Mobile App developed based on MSDK to send the payload device to create a screenshot of the specified media file. The command.

static T_DjiReturnCode CreateMediaFileScreenNail(const char *filePath)
{
T_DjiReturnCode returnCode;

returnCode = DjiMediaFile_CreateHandle(filePath, &s_mediaFileScreenNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create handle error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_CreateScr(s_mediaFileScreenNailHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file create screen nail error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

2. Get screenshot information

The camera-like payload device developed with PSDK can obtain the screenshot information of the specified media file through the GetMediaFileScreenNailInfo interface. The user can use DJI Pilot and the Mobile App developed based on MSDK to send the payload device the command to obtain the screenshot information of the specified media file.

static T_DjiReturnCode GetMediaFileScreenNailInfo(const char *filePath, T_DjiCameraMediaFileInfo *fileInfo)
{
T_DjiReturnCode returnCode;

USER_UTIL_UNUSED(filePath);

if (s_mediaFileScreenNailHandle == NULL) {
USER_LOG_ERROR("Media file screen nail handle null error");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}

returnCode = DjiMediaFile_GetMediaFileType(s_mediaFileScreenNailHandle, &fileInfo->type);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get type error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetMediaFileAttr(s_mediaFileScreenNailHandle, &fileInfo->mediaFileAttr);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get attr error stat:0x%08llX", returnCode);
return returnCode;
}

returnCode = DjiMediaFile_GetFileSizeScr(s_mediaFileScreenNailHandle, &fileInfo->fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get size error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

3. Take screenshots

The camera payload device developed with PSDK can obtain the screenshot of the specified media file through the GetMediaFileScreenNailData interface. The user can use DJI Pilot and the Mobile App developed based on MSDK to send the command to the payload device to get the screenshot of the specified media file, and get The specified screenshot.

static T_DjiReturnCode GetMediaFileScreenNailData(const char *filePath, uint32_t offset, uint32_t length,
uint8_t *data)
{
T_DjiReturnCode returnCode;
uint16_t realLen = 0;

USER_UTIL_UNUSED(filePath);

if (s_mediaFileScreenNailHandle == NULL) {
USER_LOG_ERROR("Media file screen nail handle null error");
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
}

returnCode = DjiMediaFile_GetDataScr(s_mediaFileScreenNailHandle, offset, length, data, &realLen);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file get size error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

Using DJI Pilot or a Mobile App developed based on MSDK can automatically pull the media files in the /media_file directory of the camera-like payload, display the name and screenshot of the media file, and click to display the screenshot of the media file. Figure 1. View screenshot as shown.

Figure 1. View screenshot

Delete media files

The camera-type payload device developed with PSDK can delete media files on the payload device through the DeleteMediaFile interface. Users can send commands to delete media files to the payload device using DJI Pilot and the Mobile App developed based on MSDK.

static T_DjiReturnCode DeleteMediaFile(char *filePath)
{
T_DjiReturnCode returnCode;

USER_LOG_INFO("delete media file:%s", filePath);
returnCode = DjiFile_Delete(filePath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Media file delete error stat:0x%08llX", returnCode);
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

In the media list interface, select the file to be deleted and click the delete button to delete the media files in the camera-like load device, as shown in Figure 2. Delete media files.

Figure 2. Delete media files

Implement media file playback function

Description

  • Before using PSDK to develop the playback function of the camera-like payload device control program, it is necessary to realize the function of obtaining the payload device file list first.
  • When using PSDK to develop the playback function of the camera-like load device, you need to obtain the path of the media file first, and convert the specified media file to H.264 format.

1. Specify the path of the media file

The camera-like payload device developed with PSDK obtains the path of the media file specified by the user through the SetMediaPlaybackFile interface, and the user can send the path of the media file to the payload device by using DJI Pilot and the Mobile App developed based on MSDK.

static T_DjiReturnCode SetMediaPlaybackFile(const char *filePath)
{
USER_LOG_INFO("set media playback file:%s", filePath);
T_DjiReturnCode returnCode;

returnCode = DjiPlayback_StopPlay(&s_playbackInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
return returnCode;
}

returnCode = DjiPlayback_SetPlayFile(&s_playbackInfo, filePath, 0);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
return returnCode;
}

returnCode = DjiPlayback_StartPlay(&s_playbackInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
return returnCode;
}

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

2. Format conversion

The camera-like payload device developed with PSDK can convert the media file specified by the user into H, 264 format file through the DjiPlayback_VideoFileTranscode interface. The user can send the converted media file format to the payload device using DJI Pilot and the Mobile App developed based on MSDK, convert the specified file to H.264 format, and obtain the frame rate, frame information, total frame number ,and other information of the converted media file.

// video send preprocess
returnCode = DjiPlayback_VideoFileTranscode(videoFilePath, "h264", transcodedFilePath,
DJI_FILE_PATH_SIZE_MAX);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("transcode video file error: 0x%08llX.", returnCode);
continue;
}

returnCode = DjiPlayback_GetFrameRateOfVideoFile(transcodedFilePath, &frameRate);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get frame rate of video error: 0x%08llX.", returnCode);
continue;
}

returnCode = DjiPlayback_GetFrameInfoOfVideoFile(transcodedFilePath, frameInfo, VIDEO_FRAME_MAX_COUNT,
&frameCount);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get frame info of video error: 0x%08llX.", returnCode);
continue;
}

returnCode = DjiPlayback_GetFrameNumberByTime(frameInfo, frameCount, &frameNumber,
startTimeMs);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get start frame number error: 0x%08llX.", returnCode);
continue;
}

3. Send media files

The camera payload device developed with PSDK will find the frame header of the media file according to the frame rate, frame information, total number of frames and other information of the converted media file through the DjiPayloadCamera_SendVideoStream interface, and send it to DJI Pilot according to the specified bit rate. Or the APP developed based on MSDK can send media files. Users can use DJI Pilot and Mobile App developed based on MSDK to receive the media files sent by the payload device.

lengthOfDataHaveBeenSent = 0;
while (dataLength - lengthOfDataHaveBeenSent) {
lengthOfDataToBeSent = USER_UTIL_MIN(DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN,
dataLength - lengthOfDataHaveBeenSent);
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
lengthOfDataToBeSent);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("send video stream error: 0x%08llX.", returnCode);
}
lengthOfDataHaveBeenSent += lengthOfDataToBeSent;
}

4. Get the transfer status of the media file

The camera-like payload device developed with PSDK can obtain the transmission status of the current media file through the GetMediaPlaybackStatus interface. Users can use DJI Pilot or the Mobile App developed based on MSDK to obtain the status information of the currently transmitted media file.

static T_DjiReturnCode GetMediaPlaybackStatus(T_DjiCameraPlaybackStatus *status)
{
T_DjiReturnCode returnCode;

returnCode = DjiPlayback_GetPlaybackStatus(&s_playbackInfo, status);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get playback status error, stat:0x%08llX", returnCode);
return returnCode;
}

status->videoPlayProcess = (uint8_t) (((float) s_playbackInfo.playPosMs / (float) s_playbackInfo.videoLengthMs) *
100);

USER_LOG_DEBUG("get media playback status %d %d %d %d", status->videoPlayProcess, status->playPosMs,
status->videoLengthMs, status->playbackMode);

return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}

Use DJI Pilot or a Mobile App developed based on MSDK. On the media list interface, click the video file you want to play to enter the playback interface, and use the buttons and progress bar controls to play the video or adjust the video playback progress, as shown in Figure 3. Play In the media list interface, select the specified file and click the download button to download the media files in the camera-like load device, as shown in Figure 4. Media file download.

Figure 3. Play video file

Figure 4. Media file download

Note: The download speed of media files is about 300KB/s, and the actual download speed may vary due to the working environment of the aircraft.