mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Improve:SixFrame protocol.
This commit is contained in:
parent
9a10d9e16a
commit
4780a46e8a
|
@ -91,7 +91,7 @@ StatusCode AppMonitor::GetStorageFileList(const AppGetFileInfo &fileInfo, std::v
|
|||
AppGetFileList file;
|
||||
file.mCreateTime_s = 123456789;
|
||||
file.mDuration = 15;
|
||||
file.mName = "/video/test.mp4";
|
||||
file.mName = "/DCIM/2024/01/15/20240115135444-20240115135504.mp4";
|
||||
file.mSize = 1024;
|
||||
file.mType = StorageFileType::VIDEO;
|
||||
param.push_back(file);
|
||||
|
|
|
@ -22,6 +22,7 @@ using std::placeholders::_3;
|
|||
// using std::placeholders::_4;
|
||||
// clang-format off
|
||||
const char *CJSON_INFO_STRING = "info";
|
||||
const char *CJSON_FILES_STRING = "files";
|
||||
const char *APP_GET_PRODUCT_INFO = "/app/getproductinfo";
|
||||
const char *APP_GET_DEVICE_ATTR = "/app/getdeviceattr";
|
||||
const char *APP_GET_MEDIA_INFO = "/app/getmediainfo";
|
||||
|
@ -38,6 +39,8 @@ const char *APP_SET_PARAM_VALUE = "/app/setparamvalue";
|
|||
const char *APP_ENTER_RECORDER = "/app/enterrecorder";
|
||||
const char *APP_PLAYBACK = "/app/playback";
|
||||
const char *APP_UPLOAD_FILE = "/upload";
|
||||
// /app/getparamvalue?param=rec
|
||||
// /app/exitrecorder
|
||||
// clang-format on
|
||||
constexpr bool SET_REQUEST_RESPONSE = true;
|
||||
SixFrameHandle::SixFrameHandle()
|
||||
|
@ -371,7 +374,7 @@ AppGetFileInfo inline SixFrameHandle::RequestGetFileListParse(const std::string
|
|||
std::dynamic_pointer_cast<ParseUrl<AppGetFileInfo>>(parse);
|
||||
if ("folder" == key) {
|
||||
if ("loop" == value) {
|
||||
parseyImpl->mData.mEvent = StorageFileEvent::END;
|
||||
parseyImpl->mData.mEvent = StorageFileEvent::LOOP;
|
||||
}
|
||||
if ("emr" == value) {
|
||||
parseyImpl->mData.mEvent = StorageFileEvent::END;
|
||||
|
@ -407,30 +410,57 @@ void SixFrameHandle::RequestGetFileList(const std::string &url, ResponseHandle r
|
|||
responseHandle("Device run out of memory.", context);
|
||||
return;
|
||||
}
|
||||
ResponseGetFileList(result, param);
|
||||
ResponseGetFileList(result, param, info);
|
||||
ResponseJsonString(result, responseHandle, context);
|
||||
cJSON_Delete(result);
|
||||
}
|
||||
void inline SixFrameHandle::ResponseGetFileList(cJSON *result, const std::vector<AppGetFileList> ¶m)
|
||||
/**
|
||||
* @brief
|
||||
{
|
||||
"result": 0,
|
||||
"info": [{
|
||||
"folder": "loop",
|
||||
"count": 1,
|
||||
"files": [{
|
||||
"name": "/DCIM/2024/01/15/20240115135444-20240115135504.mp4",
|
||||
"duration": 15,
|
||||
"size": 1024,
|
||||
"createtime": 123456789,
|
||||
"type": 0
|
||||
}]
|
||||
}]
|
||||
}
|
||||
* @param result
|
||||
* @param param
|
||||
* @param fileInfo
|
||||
*/
|
||||
void inline SixFrameHandle::ResponseGetFileList(cJSON *result, const std::vector<AppGetFileList> ¶m,
|
||||
const AppGetFileInfo &fileInfo)
|
||||
{
|
||||
cJSON *info = cJSON_CreateArray();
|
||||
if (nullptr == info) {
|
||||
cJSON *folder = cJSON_CreateObject();
|
||||
cJSON *files = cJSON_CreateArray();
|
||||
if (nullptr == info || nullptr == folder || nullptr == files) {
|
||||
LogError("cJSON_CreateArray failed.\n");
|
||||
return;
|
||||
}
|
||||
cJSON_AddItemToObject(result, CJSON_INFO_STRING, info);
|
||||
for (const auto &fileInfo : param) {
|
||||
cJSON_AddItemToArray(info, folder);
|
||||
for (const auto &fileList : param) {
|
||||
cJSON_AddStringToObject(folder, "folder", PrintfFileEvent(fileInfo));
|
||||
cJSON_AddNumberToObject(folder, "count", param.size());
|
||||
cJSON *file = nullptr;
|
||||
file = cJSON_CreateObject();
|
||||
if (nullptr != file) {
|
||||
cJSON_AddItemToArray(info, file);
|
||||
cJSON_AddStringToObject(file, "name", fileInfo.mName.c_str());
|
||||
cJSON_AddNumberToObject(file, "duration", fileInfo.mDuration);
|
||||
cJSON_AddNumberToObject(file, "size", fileInfo.mSize);
|
||||
cJSON_AddNumberToObject(file, "createtime", fileInfo.mCreateTime_s);
|
||||
cJSON_AddNumberToObject(file, "type", static_cast<int>(fileInfo.mType));
|
||||
cJSON_AddItemToArray(files, file);
|
||||
cJSON_AddStringToObject(file, "name", fileList.mName.c_str());
|
||||
cJSON_AddNumberToObject(file, "duration", fileList.mDuration);
|
||||
cJSON_AddNumberToObject(file, "size", fileList.mSize);
|
||||
cJSON_AddNumberToObject(file, "createtime", fileList.mCreateTime_s);
|
||||
cJSON_AddNumberToObject(file, "type", static_cast<int>(fileList.mType));
|
||||
}
|
||||
}
|
||||
cJSON_AddItemToObject(folder, CJSON_FILES_STRING, files);
|
||||
}
|
||||
AppSetDateTime inline SixFrameHandle::RequestSetDateTimeParse(const std::string &url)
|
||||
{
|
||||
|
@ -640,6 +670,21 @@ void SixFrameHandle::ResponseJsonString(cJSON *json, ResponseHandle responseHand
|
|||
responseHandle("Device run out of memory.", context);
|
||||
}
|
||||
}
|
||||
const char *SixFrameHandle::PrintfFileEvent(const AppGetFileInfo &fileInfo)
|
||||
{
|
||||
switch (fileInfo.mEvent) {
|
||||
case StorageFileEvent::LOOP: {
|
||||
return "loop";
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
LogWarning("Unknown event.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "unknown event";
|
||||
}
|
||||
void SixFrameHandle::SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor)
|
||||
{
|
||||
if (monitor) {
|
||||
|
|
|
@ -78,7 +78,7 @@ private:
|
|||
void ResponseGetStorageInfo(cJSON *result, const std::vector<AppGetStorageInfo> ¶m);
|
||||
AppGetFileInfo RequestGetFileListParse(const std::string &url);
|
||||
void RequestGetFileList(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
void ResponseGetFileList(cJSON *result, const std::vector<AppGetFileList> ¶m);
|
||||
void ResponseGetFileList(cJSON *result, const std::vector<AppGetFileList> ¶m, const AppGetFileInfo &fileInfo);
|
||||
AppSetDateTime RequestSetDateTimeParse(const std::string &url);
|
||||
void RequestSetDateTime(const std::string &url, ResponseHandle responseHandle, void *context);
|
||||
int RequestSetTimeZoneParse(const std::string &url);
|
||||
|
@ -93,6 +93,7 @@ private:
|
|||
private:
|
||||
cJSON *MakeResponseResult(const ResposeResult result, const bool requestSet = false);
|
||||
void ResponseJsonString(cJSON *json, ResponseHandle responseHandle, void *context);
|
||||
const char *PrintfFileEvent(const AppGetFileInfo &fileInfo);
|
||||
|
||||
protected:
|
||||
void SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor) override;
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Fancy Code.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "SixFrameMakePtr.h"
|
||||
#include "ILog.h"
|
||||
#include "SixFrameHandle.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user