From 8d5564e1fa8f9fd13034122bd91148f2a13f3173 Mon Sep 17 00:00:00 2001 From: Tome Date: Wed, 27 Aug 2025 09:18:54 +0800 Subject: [PATCH] FPS add Signed-off-by: Tome --- .../constants/distributed_camera_constants.h | 1 + .../handler/include/dcamera_handler.h | 3 +- .../handler/src/dcamera_handler.cpp | 41 +++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index f86c12b3..63d92b6b 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -118,6 +118,7 @@ const std::string CAMERA_FORMAT_PREVIEW = "Preview"; const std::string CAMERA_FORMAT_VIDEO = "Video"; const std::string CAMERA_FORMAT_PHOTO = "Photo"; const std::string CAMERA_RESOLUTION_KEY = "Resolution"; +const std::string CAMERA_FPS_KEY = "Fps"; const std::string CAMERA_SURFACE_FORMAT = "CAMERA_SURFACE_FORMAT"; const std::string HDF_DCAMERA_EXT_SERVICE = "distributed_camera_provider_service"; const std::string CAMERA_SUPPORT_MODE = "Mode"; diff --git a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h index 5cb0dcb0..dc22bc4b 100644 --- a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h +++ b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h @@ -56,7 +56,8 @@ private: int32_t CreateAVCodecList(cJSON* root); std::string GetCameraPosition(CameraStandard::CameraPosition position); void ProcessProfile(const DCStreamType type, std::map>& formatMap, - std::vector& profileList, std::set& formatSet); + std::map>& fpsMap, std::vector& profileList, + std::set& formatSet); void ConfigFormatphoto(const DCStreamType type, cJSON* root, std::vector& profileList); void ConfigFormatvideo(const DCStreamType type, cJSON* root, diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index f54f6e35..b3682650 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -336,11 +336,13 @@ std::string DCameraHandler::GetCameraPosition(CameraStandard::CameraPosition pos } void DCameraHandler::ProcessProfile(const DCStreamType type, std::map>& formatMap, - std::vector& profileList, std::set& formatSet) + std::map>& fpsMap, std::vector& profileList, + std::set& formatSet) { for (auto& profile : profileList) { CameraStandard::CameraFormat format = profile.GetCameraFormat(); CameraStandard::Size picSize = profile.GetSize(); + CameraStandard::Fps fps = profile.GetFps(); int32_t dformat = CovertToDcameraFormat(format); if (dformat == INVALID_FORMAT) { continue; @@ -350,7 +352,10 @@ void DCameraHandler::ProcessProfile(const DCStreamType type, std::map> formatMap; - ProcessProfile(type, formatMap, profileList, formatSet); + std::map> fpsMap; + ProcessProfile(type, formatMap, fpsMap, profileList, formatSet); cJSON* resolutionObj = cJSON_CreateObject(); if (resolutionObj == nullptr) { return; @@ -379,6 +385,20 @@ void DCameraHandler::ConfigFormatphoto(const DCStreamType type, cJSON* root, } } cJSON_AddItemToObject(formatphotoObj, CAMERA_RESOLUTION_KEY.c_str(), resolutionObj); + + cJSON* fpsObj = cJSON_CreateObject(); + if (fpsObj == nullptr) { + return; + } + for (auto &pair : fpsMap) { + cJSON* array = cJSON_CreateArray(); + cJSON_AddItemToObject(fpsObj, pair.first.c_str(), array); + for (auto &value : pair.second) { + cJSON_AddItemToArray(array, cJSON_CreateString(value.c_str())); + } + } + cJSON_AddItemToObject(formatphotoObj, CAMERA_FPS_KEY.c_str(), fpsObj); + cJSON* array = cJSON_CreateArray(); if (array == nullptr) { return; @@ -400,7 +420,8 @@ void DCameraHandler::ConfigFormatvideo(const DCStreamType type, cJSON* root, } cJSON_AddItemToObject(root, CAMERA_FORMAT_PREVIEW.c_str(), formatpreviewObj); std::map> formatMap; - ProcessProfile(type, formatMap, profileList, formatSet); + std::map> fpsMap; + ProcessProfile(type, formatMap, fpsMap, profileList, formatSet); cJSON* resolutionObj = cJSON_CreateObject(); if (resolutionObj == nullptr) { return; @@ -413,6 +434,20 @@ void DCameraHandler::ConfigFormatvideo(const DCStreamType type, cJSON* root, } } cJSON_AddItemToObject(formatpreviewObj, CAMERA_RESOLUTION_KEY.c_str(), resolutionObj); + + cJSON* fpsObj = cJSON_CreateObject(); + if (fpsObj == nullptr) { + return; + } + for (auto &pair : fpsMap) { + cJSON* array = cJSON_CreateArray(); + cJSON_AddItemToObject(fpsObj, pair.first.c_str(), array); + for (auto &value : pair.second) { + cJSON_AddItemToArray(array, cJSON_CreateString(value.c_str())); + } + } + cJSON_AddItemToObject(formatpreviewObj, CAMERA_FPS_KEY.c_str(), fpsObj); + cJSON* array = cJSON_CreateArray(); if (array == nullptr) { return; -- Gitee